add in a Memory Service

Currently it fully ignores messages and only allocates blocks in 4096 byte chunks
pull/12/head
able 2023-12-01 06:11:33 -06:00
parent 28d0d370a4
commit 9566b55754
2 changed files with 17 additions and 0 deletions

View File

@ -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(())
}

View File

@ -7,6 +7,8 @@ fn main(){
std::Debug("XYZ");
std::Trace("Trace Deez");
std::ipc_send(2, 0, 0);
tx();
}