diff --git a/Cargo.lock b/Cargo.lock index acd04f9a7..da30e1309 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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)", ] diff --git a/kernel/src/holeybytes/ecah.rs b/kernel/src/holeybytes/ecah.rs index c75f51420..827c42b1b 100644 --- a/kernel/src/holeybytes/ecah.rs +++ b/kernel/src/holeybytes/ecah.rs @@ -68,7 +68,7 @@ pub fn handler(vm: &mut Vm) { let buffer_id = vm.registers[3].cast::(); let mem_addr = vm.registers[4].cast::(); let length = vm.registers[5].cast::() as usize; - trace!("IPC address: {:?}", mem_addr); + // debug!("IPC address: {:?}", mem_addr); use alloc::vec::Vec; match buffer_id { diff --git a/kernel/src/holeybytes/kernel_services/mem_serve.rs b/kernel/src/holeybytes/kernel_services/mem_serve.rs index 816f4be05..4796faf6d 100644 --- a/kernel/src/holeybytes/kernel_services/mem_serve.rs +++ b/kernel/src/holeybytes/kernel_services/mem_serve.rs @@ -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(()) diff --git a/repbuild/src/dev.rs b/repbuild/src/dev.rs index 3dc6d0e87..2978cd467 100644 --- a/repbuild/src/dev.rs +++ b/repbuild/src/dev.rs @@ -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(); diff --git a/sysdata/libraries/stn/src/lib.hb b/sysdata/libraries/stn/src/lib.hb index 663c3b2da..16e861865 100644 --- a/sysdata/libraries/stn/src/lib.hb +++ b/sysdata/libraries/stn/src/lib.hb @@ -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); } diff --git a/sysdata/programs/fb_driver/meta.toml b/sysdata/programs/fb_driver/meta.toml index f96168e34..9863f08ac 100644 --- a/sysdata/programs/fb_driver/meta.toml +++ b/sysdata/programs/fb_driver/meta.toml @@ -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" diff --git a/sysdata/programs/fb_driver/src/main.hb b/sysdata/programs/fb_driver/src/main.hb index 2caf07aea..00039dac6 100644 --- a/sysdata/programs/fb_driver/src/main.hb +++ b/sysdata/programs/fb_driver/src/main.hb @@ -1,4 +1,4 @@ -buffer := 18446603339442421960; +buffer := @as(^u32, @bitcast(18446603339442422060)); send_msg := fn(): int { msg := 10; diff --git a/sysdata/programs/tests/meta.toml b/sysdata/programs/tests/meta.toml index c68328900..a94c6669a 100644 --- a/sysdata/programs/tests/meta.toml +++ b/sysdata/programs/tests/meta.toml @@ -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" diff --git a/sysdata/programs/tests/src/main.hb b/sysdata/programs/tests/src/main.hb index 9e3c01e74..eb349c343 100644 --- a/sysdata/programs/tests/src/main.hb +++ b/sysdata/programs/tests/src/main.hb @@ -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; } \ No newline at end of file diff --git a/sysdata/spec/Memory Service spec.md b/sysdata/spec/Memory Service spec.md index 6144a0bd0..aaa27d2f5 100644 --- a/sysdata/spec/Memory Service spec.md +++ b/sysdata/spec/Memory Service spec.md @@ -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 - + [U64] -> ptr to alloc at ## Deallocate (12 bytes) diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index 14907dfe2..543e55807 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -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"