From 15515e6643955efe0b17227ed7897f171db6f5c3 Mon Sep 17 00:00:00 2001 From: able Date: Fri, 1 Dec 2023 06:11:33 -0600 Subject: [PATCH] add in a Memory Service Currently it fully ignores messages and only allocates blocks in 4096 byte chunks --- kernel/src/holeybytes/ecah.rs | 15 +++++++++++++++ sysdata/test-programs/main.rhai | 2 ++ 2 files changed, 17 insertions(+) diff --git a/kernel/src/holeybytes/ecah.rs b/kernel/src/holeybytes/ecah.rs index a5f1e94..b3f82a2 100644 --- a/kernel/src/holeybytes/ecah.rs +++ b/kernel/src/holeybytes/ecah.rs @@ -70,6 +70,10 @@ pub fn handler(vm: &mut Vm) { Ok(()) => {} Err(err) => log::error!("Improper log format"), }, + 2 => match memory_msg_handler(vm, mem_addr, length) { + Ok(()) => {} + Err(err) => log::error!("Improper log format"), + }, buffer_id => { let mut buffs = IPC_BUFFERS.lock(); @@ -140,3 +144,14 @@ pub enum LogError { InvalidLogFormat, } use {alloc::vec, log::Record}; + +fn memory_msg_handler(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), LogError> { + let mut val = alloc::vec::Vec::new(); + for _ in 0..4096 { + val.push(0); + } + info!("Block address: {:?}", val.as_ptr()); + vm.registers[1] = hbvm::value::Value(val.as_ptr() as u64); + vm.registers[2] = hbvm::value::Value(4096); + Ok(()) +} diff --git a/sysdata/test-programs/main.rhai b/sysdata/test-programs/main.rhai index d66433e..63a2f22 100644 --- a/sysdata/test-programs/main.rhai +++ b/sysdata/test-programs/main.rhai @@ -7,6 +7,8 @@ fn main(){ std::Debug("XYZ"); std::Trace("Trace Deez"); + std::ipc_send(2, 0, 0); + tx(); }