use { crate::holeybytes::{ecah::LogError, kernel_services::mem_serve, Vm}, log::info, }; pub enum MemoryServiceError { InvalidMemoryFormat, } fn alloc_page(vm: &mut Vm, mem_addr: u64, length: usize) -> Result<(), MemoryServiceError> { 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(()) } pub fn memory_msg_handler( vm: &mut Vm, mem_addr: u64, length: usize, ) -> Result<(), MemoryServiceError> { let msg_type = (mem_addr) as *const u8; // info!("memory message type {:?}", unsafe { msg_type.read() }); let ptr = (mem_addr + 1) as *const u64; // info!("ptr: {:x?}", unsafe { ptr.read() }); let page_count_addr = (mem_addr + 9) as *const u8; // let page_count = unsafe { page_count_addr.read() }; // info!("page count {}", page_count); // if page_count > 16 { // use log::error; // error!("Map less pages at a time"); // } Ok(()) } // match memory_msg_handler(vm, mem_addr, length) { // Ok(()) => { // let free_chunks = allocator::get_free_chunks_count(); // debug!("Free chunk count: {}", free_chunks); // } // Err(err) => log::error!("Improper log format"), // };