diff --git a/Cargo.lock b/Cargo.lock index 4a13d710..33bd3581 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -213,12 +213,12 @@ dependencies = [ [[package]] name = "hbbytecode" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#9c4b84ce33ea6ac7fe0f1b00ee5c67718643a34a" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#3491814b4f1723e6b1f3ae485ed5d3b5cad16df0" [[package]] name = "hblang" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#9c4b84ce33ea6ac7fe0f1b00ee5c67718643a34a" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#3491814b4f1723e6b1f3ae485ed5d3b5cad16df0" dependencies = [ "hashbrown", "hbbytecode", @@ -229,7 +229,7 @@ dependencies = [ [[package]] name = "hbvm" version = "0.1.0" -source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#9c4b84ce33ea6ac7fe0f1b00ee5c67718643a34a" +source = "git+https://git.ablecorp.us/AbleOS/holey-bytes.git#3491814b4f1723e6b1f3ae485ed5d3b5cad16df0" dependencies = [ "hbbytecode", ] diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index 9cee4de7..e53ba452 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -9,7 +9,7 @@ ktest = [] [dependencies] # embedded-graphics = "0.8" hbvm = { git = "https://git.ablecorp.us/AbleOS/holey-bytes.git", features = [ - "nightly", + "nightly", "alloc", "disasm" ] } ktest_macro = { path = "ktest_macro" } log = "0.4" diff --git a/kernel/src/holeybytes/mem.rs b/kernel/src/holeybytes/mem.rs index 94d65833..a8f44958 100644 --- a/kernel/src/holeybytes/mem.rs +++ b/kernel/src/holeybytes/mem.rs @@ -15,8 +15,10 @@ fn calc_start_of_page(ptr: u64) -> u64 { panic!("unaligned"); } +#[derive(Default)] pub struct Memory { // TODO: map page aligned segments of memory into a table or some sort here + logger: hbvm::mem::InstrLogger, } impl Memory { @@ -56,4 +58,11 @@ impl hbvm::mem::Memory for Memory { unsafe fn prog_read(&mut self, addr: Address) -> T { (addr.get() as *const T).read() } + + #[inline(always)] + fn log_instr(&mut self, at: Address, regs: &[hbvm::value::Value]) { + //log::debug!("exec: [{:02x}] {}", at.get(), unsafe { + // self.logger.display_instr(at, regs) + //}); + } } diff --git a/kernel/src/holeybytes/mod.rs b/kernel/src/holeybytes/mod.rs index ab68d04f..c670d894 100644 --- a/kernel/src/holeybytes/mod.rs +++ b/kernel/src/holeybytes/mod.rs @@ -36,7 +36,7 @@ impl ExecThread { pub unsafe fn new(program: &[u8], entrypoint: Address) -> Self { let mut vm = Vm::new( - mem::Memory {}, + mem::Memory::default(), Address::new(program.as_ptr() as u64 + entrypoint.get()), ); diff --git a/sysdata/programs/test/src/tests/stn/hashers.hb b/sysdata/programs/test/src/tests/stn/hashers.hb index 354560c0..40e0bb00 100644 --- a/sysdata/programs/test/src/tests/stn/hashers.hb +++ b/sysdata/programs/test/src/tests/stn/hashers.hb @@ -3,7 +3,7 @@ test := fn(): uint { target := "abcdefghijklmnop" strings := .["abcdefshijklmnop", "abcdefghijklnnop", "abcdefshijklmnop", "abcdefghijklmnop", "abcdefghijflmnop", "dbcdefghijklmnop", "abcdefghijklmnop"] - len := @sizeof(@TypeOf(strings)) / @sizeof(^u8) + len := @sizeof(@TypeOf(strings)) / @sizeof([]u8) // hasher := hashers.foldhash.FoldHasher.new(1) hasher := hashers.foldhash.FoldHasher.default() @@ -23,4 +23,4 @@ test := fn(): uint { } log.print("done", .{}) return 0 -} \ No newline at end of file +}