From 5659ae1d0aacdfd2cabd08cf4bdaa2426cc7d394 Mon Sep 17 00:00:00 2001 From: Jakub Doka Date: Sun, 22 Dec 2024 22:10:24 +0100 Subject: [PATCH] adding instruction log Signed-off-by: Jakub Doka --- Cargo.lock | 6 +++--- kernel/Cargo.toml | 2 +- kernel/src/holeybytes/mem.rs | 9 +++++++++ kernel/src/holeybytes/mod.rs | 2 +- sysdata/programs/test/src/tests/stn/hashers.hb | 4 ++-- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4a13d71..33bd358 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 9cee4de..e53ba45 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 94d6583..a8f4495 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 ab68d04..c670d89 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 354560c..40e0bb0 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 +}