add in a Memory Service

Currently it fully ignores messages and only allocates blocks in 4096 byte chunks
This commit is contained in:
able 2023-12-01 06:11:33 -06:00
parent 7a2372d32a
commit 15515e6643
2 changed files with 17 additions and 0 deletions

View file

@ -70,6 +70,10 @@ pub fn handler(vm: &mut Vm) {
Ok(()) => {} Ok(()) => {}
Err(err) => log::error!("Improper log format"), 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 => { buffer_id => {
let mut buffs = IPC_BUFFERS.lock(); let mut buffs = IPC_BUFFERS.lock();
@ -140,3 +144,14 @@ pub enum LogError {
InvalidLogFormat, InvalidLogFormat,
} }
use {alloc::vec, log::Record}; 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::Debug("XYZ");
std::Trace("Trace Deez"); std::Trace("Trace Deez");
std::ipc_send(2, 0, 0);
tx(); tx();
} }