forked from AbleOS/ableos
did some stuff /shrug
This commit is contained in:
parent
5f136a66af
commit
f33cc0bf70
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -429,7 +429,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "hbbytecode"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#59705c062dbd0eeeaf2feb4a76230a393672c646"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#efa7271a5917c9b78ed06563df2bea13f895f8ca"
|
||||
|
||||
[[package]]
|
||||
name = "hbbytecode"
|
||||
|
@ -439,7 +439,7 @@ source = "git+https://git.ablecorp.us/ableos/holey-bytes#e494785f93dad2722ebd9e5
|
|||
[[package]]
|
||||
name = "hblang"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#59705c062dbd0eeeaf2feb4a76230a393672c646"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#efa7271a5917c9b78ed06563df2bea13f895f8ca"
|
||||
dependencies = [
|
||||
"hbvm 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)",
|
||||
]
|
||||
|
@ -447,7 +447,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "hbvm"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#59705c062dbd0eeeaf2feb4a76230a393672c646"
|
||||
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#efa7271a5917c9b78ed06563df2bea13f895f8ca"
|
||||
dependencies = [
|
||||
"hbbytecode 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)",
|
||||
]
|
||||
|
|
|
@ -116,12 +116,26 @@ pub fn handler(vm: &mut Vm) {
|
|||
}
|
||||
4 => {
|
||||
let buffer_id = vm.registers[3].cast::<u64>();
|
||||
let mut map_ptr = vm.registers[4].cast::<u64>();
|
||||
let max_length = vm.registers[5].cast::<u64>();
|
||||
|
||||
let mut buffs = IPC_BUFFERS.lock();
|
||||
let mut buff = buffs.get_mut(&buffer_id).unwrap();
|
||||
let msg = buff.pop();
|
||||
if msg.len() > max_length.try_into().unwrap() {
|
||||
info!("{}", max_length);
|
||||
error!("Message is too long to map in.");
|
||||
} else {
|
||||
unsafe {
|
||||
let ptr: *mut u64 = &mut map_ptr;
|
||||
for (index, byte) in msg.iter().enumerate() {
|
||||
ptr.offset(index.try_into().unwrap()).write_bytes(*byte, 1);
|
||||
}
|
||||
}
|
||||
|
||||
info!("Recieve {:?} from Buffer({})", msg, buffer_id);
|
||||
}
|
||||
}
|
||||
5 => {
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::{
|
|||
process::exit,
|
||||
};
|
||||
|
||||
use error_stack::Report;
|
||||
use {error_stack::Report, hblang::Options};
|
||||
|
||||
use crate::Error;
|
||||
pub struct Package {
|
||||
|
@ -69,8 +69,16 @@ impl Package {
|
|||
let path = format!("sysdata/programs/{}/{}", self.name, file);
|
||||
let mut bytes = Vec::new();
|
||||
// compile here
|
||||
let _ = hblang::run_compiler(&path, Default::default(), &mut bytes);
|
||||
|
||||
// let _ = hblang::run_compiler(
|
||||
// &path,
|
||||
// Options {
|
||||
// fmt: true,
|
||||
// ..Default::default()
|
||||
// },
|
||||
// &mut bytes,
|
||||
// );
|
||||
let _ = hblang::run_compiler(&path, Default::default(), &mut bytes);
|
||||
match std::fs::create_dir("target/programs") {
|
||||
Ok(_) => (),
|
||||
Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => (),
|
||||
|
|
20
sysdata/libraries/stn/src/buffer.hb
Normal file
20
sysdata/libraries/stn/src/buffer.hb
Normal file
|
@ -0,0 +1,20 @@
|
|||
string := @use("rel:string.hb");
|
||||
|
||||
receive_message := fn(buffer_id: int, memory_map_location: ^u8, length: int): ^u8 {
|
||||
return @eca(void, 4, buffer_id, memory_map_location, length);
|
||||
}
|
||||
|
||||
send_message := fn(buffer_id: int): void {
|
||||
message := "Hello there\0";
|
||||
message_length := string.length(message);
|
||||
|
||||
@eca(i32, 3, buffer_id, message, message_length);
|
||||
return;
|
||||
}
|
||||
|
||||
create := fn(): int {
|
||||
msg := "\{01}Number\0";
|
||||
msg_length := string.length(msg);
|
||||
*msg = 0;
|
||||
return @eca(int, 1, 0, msg, msg_length);
|
||||
}
|
|
@ -1,31 +1,4 @@
|
|||
char := struct {}
|
||||
|
||||
|
||||
log := fn(log_level: int, message: ^char, message_length: int): int {
|
||||
@eca(i32,1, 1, 1)
|
||||
return 0;
|
||||
}
|
||||
|
||||
error := fn(message: ^char, message_length: int): int {
|
||||
log(0, message, message_length)
|
||||
}
|
||||
|
||||
warn := fn(message: ^char, message_length: int): int {
|
||||
log(1, message, message_length)
|
||||
}
|
||||
|
||||
info := fn(message: ^char, message_length: int): int {
|
||||
log(2, message, message_length)
|
||||
}
|
||||
|
||||
debug := fn(message: ^char, message_length: int): int {
|
||||
log(3, message, message_length)
|
||||
}
|
||||
|
||||
trace := fn(message: ^char, message_length: int): int {
|
||||
log(4, message, message_length)
|
||||
}
|
||||
|
||||
test := fn(): int {
|
||||
@eca(i32, 1, 1, 1);
|
||||
}
|
||||
string := @use("rel:string.hb");
|
||||
log := @use("rel:log.hb");
|
||||
memory := @use("rel:memory.hb");
|
||||
buffer := @use("rel:buffer.hb");
|
15
sysdata/libraries/stn/src/log.hb
Normal file
15
sysdata/libraries/stn/src/log.hb
Normal file
|
@ -0,0 +1,15 @@
|
|||
string := @use("rel:string.hb");
|
||||
|
||||
log := fn(message: ^u8, level: u8): void {
|
||||
message_length := string.length(message);
|
||||
*(message + message_length) = level;
|
||||
|
||||
@eca(i32, 3, 1, message, message_length + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
error:= fn(message: ^u8):void return log(message, 0);
|
||||
warn:= fn(message: ^u8):void return log(message, 1);
|
||||
info:= fn(message: ^u8):void return log(message, 2);
|
||||
debug:= fn(message: ^u8):void return log(message, 3);
|
||||
trace:= fn(message: ^u8):void return log(message, 4);
|
18
sysdata/libraries/stn/src/memory.hb
Normal file
18
sysdata/libraries/stn/src/memory.hb
Normal file
|
@ -0,0 +1,18 @@
|
|||
request_page := fn(page_count: u8): ^u8 {
|
||||
msg := "\{00}\{01}xxxxxxxx\0";
|
||||
msg_page_count := msg + 1;
|
||||
*msg_page_count = page_count;
|
||||
return @eca(^u8, 3, 2, msg, 12);
|
||||
}
|
||||
|
||||
release_page := fn(ptr: ^u8, page_count: u8): void {
|
||||
msg := "\{01}\{00}xxxxxxxx\0";
|
||||
|
||||
msg_page_count := msg + 1;
|
||||
*msg_page_count = page_count;
|
||||
|
||||
msg_ptr := @as(^^u8, @bitcast(msg+2));
|
||||
*msg_ptr = ptr;
|
||||
|
||||
return @eca(void, 3, 2, msg, 12);
|
||||
}
|
8
sysdata/libraries/stn/src/string.hb
Normal file
8
sysdata/libraries/stn/src/string.hb
Normal file
|
@ -0,0 +1,8 @@
|
|||
length := fn(ptr: ^u8): int {
|
||||
len := 0;
|
||||
loop if *ptr == 0 break else {
|
||||
len += 1;
|
||||
ptr += 1;
|
||||
}
|
||||
return len;
|
||||
}
|
|
@ -1,16 +1,15 @@
|
|||
|
||||
main := fn(): int {
|
||||
frame_buffer := @as(^u32, @bitcast(18446603339442421760));
|
||||
color := 0;
|
||||
frame_buffer := @as(^u8, @bitcast(18446603339442421760));
|
||||
color := 17;
|
||||
|
||||
loop {
|
||||
len := 786432*4;
|
||||
len := (786432 * 4)+1;
|
||||
loop if len == 0 break else {
|
||||
fb := frame_buffer + @as(^u32, @bitcast(len));
|
||||
fb := frame_buffer + len;
|
||||
*fb = color;
|
||||
len -= 1;
|
||||
color += 100;
|
||||
len = len - 1;
|
||||
color += len;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,49 +1,20 @@
|
|||
log := fn(message: ^u8, level: u8): void {
|
||||
message_2 := message;
|
||||
len := 0;
|
||||
loop if *message_2 == 0 {
|
||||
*message_2 = level;
|
||||
break
|
||||
} else {
|
||||
len += 1;
|
||||
message_2 += 1;
|
||||
}
|
||||
len += 1;
|
||||
|
||||
@eca(i32, 3, 1, message, len);
|
||||
return;
|
||||
}
|
||||
|
||||
error:= fn(message: ^u8):void return log(message, 0);
|
||||
warn:= fn(message: ^u8):void return log(message, 1);
|
||||
info:= fn(message: ^u8):void return log(message, 2);
|
||||
debug:= fn(message: ^u8):void return log(message, 3);
|
||||
trace:= fn(message: ^u8):void return log(message, 4);
|
||||
|
||||
|
||||
request_mem_page := fn(page_count: u8): ^u8 {
|
||||
msg := "\{00}\{01}xxxxxxxx\0";
|
||||
msg_mem_page_count := msg + 1;
|
||||
*msg_mem_page_count = page_count;
|
||||
return @eca(^u8, 3, 2, msg, 12);
|
||||
}
|
||||
|
||||
release_mem_page := fn(ptr: ^u8, page_count: u8): void {
|
||||
msg := "\{01}\{00}xxxxxxxx\0";
|
||||
|
||||
msg_mem_page_count := msg + 1;
|
||||
*msg_mem_page_count = page_count;
|
||||
|
||||
msg_mem_ptr := @as(^^u8, @bitcast(msg+2));
|
||||
*msg_mem_ptr = ptr;
|
||||
|
||||
a := @eca(void, 3, 2, msg, 12);
|
||||
return;
|
||||
}
|
||||
stn := @use("../../../libraries/stn/src/lib.hb");
|
||||
log := stn.log;
|
||||
string := stn.string;
|
||||
memory := stn.memory;
|
||||
buffer := stn.buffer;
|
||||
|
||||
main := fn(): int {
|
||||
buffer := request_mem_page(3);
|
||||
release_mem_page(buffer, 3);
|
||||
// Create a buffer
|
||||
buffer_id := buffer.create();
|
||||
buffer.send_message(buffer_id);
|
||||
|
||||
memory_pages := memory.request_page(3);
|
||||
buffer.receive_message(buffer_id, memory_pages, 4096*3);
|
||||
|
||||
log.info("abc\0");
|
||||
|
||||
memory.release_page(memory_pages, 3);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue