Make unsafe more limited in memory initialization.

This commit is contained in:
Drew Galbraith 2024-07-28 19:29:23 -07:00
parent d35e8d253f
commit 4d94bc0ea8
1 changed files with 10 additions and 11 deletions

View File

@ -19,18 +19,17 @@ pub fn init_heap() {
syscall::syscall(zion::kZionMemoryObjectCreate, &obj_req) syscall::syscall(zion::kZionMemoryObjectCreate, &obj_req)
.expect("Failed to create memory object"); .expect("Failed to create memory object");
unsafe { let mut vaddr: u64 = 0;
let mut vaddr: u64 = 0; let vmas_req = zion::ZAddressSpaceMapReq {
let vmas_req = zion::ZAddressSpaceMapReq { vmmo_cap,
vmmo_cap, vmas_cap: unsafe { SELF_VMAS_CAP },
vmas_cap: SELF_VMAS_CAP, align: 0x2000,
align: 0x2000, vaddr: &mut vaddr as *mut u64,
vaddr: &mut vaddr as *mut u64, vmas_offset: 0,
vmas_offset: 0, };
};
syscall::syscall(zion::kZionAddressSpaceMap, &vmas_req) syscall::syscall(zion::kZionAddressSpaceMap, &vmas_req).expect("Failed to map memory object");
.expect("Failed to map memory object"); unsafe {
ALLOCATOR.lock().init(vaddr as *mut u8, size as usize); ALLOCATOR.lock().init(vaddr as *mut u8, size as usize);
CAN_ALLOC = true; CAN_ALLOC = true;
} }