1
0
Fork 0
forked from AbleOS/ableos
This commit is contained in:
Able 2024-07-06 09:24:23 -05:00
parent 62c181fb6a
commit 54d7e6b02b
11 changed files with 71 additions and 48 deletions

6
Cargo.lock generated
View file

@ -429,7 +429,7 @@ dependencies = [
[[package]]
name = "hbbytecode"
version = "0.1.0"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#e494785f93dad2722ebd9e5d81c2bcb3c471cc07"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#59705c062dbd0eeeaf2feb4a76230a393672c646"
[[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#e494785f93dad2722ebd9e5d81c2bcb3c471cc07"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#59705c062dbd0eeeaf2feb4a76230a393672c646"
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#e494785f93dad2722ebd9e5d81c2bcb3c471cc07"
source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#59705c062dbd0eeeaf2feb4a76230a393672c646"
dependencies = [
"hbbytecode 0.1.0 (git+https://git.ablecorp.us/AbleOS/holey-bytes.git)",
]

View file

@ -68,7 +68,7 @@ pub fn handler(vm: &mut Vm) {
let buffer_id = vm.registers[3].cast::<u64>();
let mem_addr = vm.registers[4].cast::<u64>();
let length = vm.registers[5].cast::<u64>() as usize;
trace!("IPC address: {:?}", mem_addr);
// debug!("IPC address: {:?}", mem_addr);
use alloc::vec::Vec;
match buffer_id {

View file

@ -37,16 +37,17 @@ pub fn memory_msg_handler(
) -> Result<(), MemoryServiceError> {
let mut msg_vec = block_read(mem_addr, length);
let msg_type = msg_vec[0];
msg_vec.remove(0);
match msg_type {
0 => {
let page_count = msg_vec[0];
msg_vec.remove(0);
// let mptr_raw: [u8; 8] = msg_vec[0..8].try_into().unwrap();
// let mptr: u64 = u64::from_le_bytes(mptr_raw);
let mptr_raw: [u8; 8] = msg_vec[0..8].try_into().unwrap();
let mptr: u64 = u64::from_le_bytes(mptr_raw);
// log::debug!("Allocating {} pages @ {}", page_count, mptr);
log::debug!("Allocating {} pages @ {:x}", page_count, mptr);
let mut val = alloc::vec::Vec::new();
for _ in 0..(page_count as isize * 4096) {
@ -85,7 +86,15 @@ pub fn memory_msg_handler(
hid, pid, quota_type
)
}
_ => {}
3 => {
let page_count = msg_vec[0];
log::debug!(" {} pages", page_count);
msg_vec.remove(0);
}
_ => {
log::debug!("Unknown memory service message type: {}", msg_type);
}
}
Ok(())

View file

@ -64,37 +64,17 @@ impl Package {
}
pub fn build(&self) {
if self.binaries.contains(&"hblang".to_string()) {
let file_order = self.build_cmd.split_ascii_whitespace();
let mut files = vec![];
for (count, file) in file_order.enumerate() {
if count != 0 {
files.push(file);
}
}
let mut bundle = vec![];
for file in files {
let file_path = if file.starts_with("libraries") {
format!("sysdata/{}", file)
} else {
format!("sysdata/programs/{}/{}", self.name, file)
};
let contents = read_to_string(file_path).unwrap();
bundle.push((file, contents));
}
let file = self.build_cmd.split_ascii_whitespace().last().unwrap();
let path = format!("sysdata/programs/{}/{}", self.name, file);
let mut bytes = Vec::new();
// compile here
let _ = hblang::run_compiler(&path, Default::default(), &mut bytes);
use hblang::{codegen, parser};
let mut codegen = codegen::Codegen::default();
for (path, content) in bundle.iter() {
codegen.files = vec![parser::Ast::new(path, content, &parser::no_loader)];
codegen.generate();
}
let mut buf = BufWriter::new(Vec::new());
codegen.dump(&mut buf);
let bytes = buf.into_inner().unwrap();
match std::fs::create_dir("target/programs") {
Ok(_) => (),
Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => (),
Err(e) => panic!(),
Err(e) => panic!("{}", e),
}
let path = format!("target/programs/{}.hbf", self.name);
let mut file = File::create(path).unwrap();

View file

@ -26,10 +26,6 @@ trace := fn(message: ^char, message_length: int): int {
log(4, message, message_length)
}
main := fn(): int {
return 0;
}
test := fn(): int {
@eca(i32, 1, 1, 1);
}

View file

@ -8,4 +8,4 @@ authors = ["able"]
hblang.version = "1.0.0"
[build]
command = "hblang libraries/stn/src/lib.hb src/main.hb"
command = "hblang src/main.hb"

View file

@ -1,4 +1,4 @@
buffer := 18446603339442421960;
buffer := @as(^u32, @bitcast(18446603339442422060));
send_msg := fn(): int {
msg := 10;

View file

@ -8,4 +8,4 @@ authors = ["able"]
hblang.version = "1.0.0"
[build]
command = "hblang libraries/stn/src/lib.hb src/main.hb"
command = "hblang src/main.hb"

View file

@ -1,4 +1,42 @@
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 := "\{01}\{01}00000\0";
msg_mem_page_count := msg + 1;
*msg_mem_page_count = page_count;
return @eca(^u8, 3, 2, msg, 8);
}
alloc := fn(): void {
error("Did not allocate.\0");
return;
}
main := fn(): int {
buffer := request_mem_page(3);
alloc();
return 0;
}

View file

@ -4,7 +4,7 @@ The memory service uses the first byte in the message to identify the request ty
## Allocate (12 bytes)
[U8] -> 0
[U8] -> Page count
<!-- Currently this does not allocate here, check r1 for a ptr to alloc to -->
<!-- Currently this does not allocate here, check r2 for a ptr to alloc to -->
[U64] -> ptr to alloc at
## Deallocate (12 bytes)

View file

@ -21,8 +21,8 @@ resolution = "1024x768x24"
[boot.limine.ableos.modules.tests]
path = "boot:///tests.hbf"
[boot.limine.ableos.modules.diskio_driver]
path = "boot:///diskio_driver.hbf"
# [boot.limine.ableos.modules.diskio_driver]
# path = "boot:///diskio_driver.hbf"
[boot.limine.ableos.modules.fat32_filesystem_driver]
path = "boot:///fat32_filesystem_driver.hbf"
# [boot.limine.ableos.modules.fb_driver]
# path = "boot:///fb_driver.hbf"