Return result type from syscall and format info on panic.

This commit is contained in:
Drew Galbraith 2024-07-26 16:31:57 -07:00
parent e310eee468
commit 51d40f6db6
4 changed files with 91 additions and 14 deletions

View file

@ -5,6 +5,8 @@ use linked_list_allocator::LockedHeap;
#[global_allocator]
static ALLOCATOR: LockedHeap = LockedHeap::empty();
pub static mut CAN_ALLOC: bool = false;
pub fn init_heap() {
// 1 MiB
let size = 0x10_0000;
@ -13,7 +15,8 @@ pub fn init_heap() {
size,
vmmo_cap: &mut vmmo_cap as *mut u64,
};
syscall::checked_syscall(syscall::kZionMemoryObjectCreate, &obj_req);
syscall::syscall(syscall::kZionMemoryObjectCreate, &obj_req)
.expect("Failed to create memory object");
unsafe {
let mut vaddr: u64 = 0;
@ -25,7 +28,9 @@ pub fn init_heap() {
vmas_offset: 0,
};
syscall::checked_syscall(syscall::kZionAddressSpaceMap, &vmas_req);
syscall::syscall(syscall::kZionAddressSpaceMap, &vmas_req)
.expect("Failed to map memory object");
ALLOCATOR.lock().init(vaddr as *mut u8, size as usize);
CAN_ALLOC = true;
}
}