imprive at alloc failed

This commit is contained in:
pointer-to-bios 2024-09-23 12:55:00 +08:00
parent b2f52136df
commit 2c99270910
1 changed files with 4 additions and 2 deletions

View File

@ -1,10 +1,11 @@
use core::{ use core::{
alloc::{GlobalAlloc, Layout}, alloc::{GlobalAlloc, Layout},
ops::BitAnd, ops::BitAnd,
ptr::{addr_of_mut, null_mut}, ptr::addr_of_mut,
}; };
use nonx_api::nonx_api; use nonx_api::nonx_api;
#[repr(align(4096))]
struct PreInitializeAllocator { struct PreInitializeAllocator {
base: [u128; 1024], base: [u128; 1024],
inited: bool, inited: bool,
@ -42,7 +43,8 @@ impl PreInitializeAllocator {
} }
} }
if start == 0 { if start == 0 {
null_mut() panic!("PreInitializeAllocator runs out. Bit map:\n{:#x}\n{:#x}\n{:#x}\n{:#x}\n{:#x}\n{:#x}\n{:#x}\n{:#x}",
self.base[0], self.base[1], self.base[2], self.base[3], self.base[4], self.base[5], self.base[6], self.base[7]);
} else { } else {
addr_of_mut!(self.base[start]) as *mut u8 addr_of_mut!(self.base[start]) as *mut u8
} }