use super::page_table::{PAGE_SIZE, PageTable}; use crate::board; // Boot bump allocator for kernel-only memory; must never reach the user pool. static mut NEXT_FREE: usize = 0; pub fn init_allocator(start: usize) { unsafe { NEXT_FREE = start; } } pub fn alloc_zeroed_page() -> usize { unsafe { let addr = NEXT_FREE; if addr + PAGE_SIZE > super::phys_to_virt(board::USER_POOL_BASE) { crate::halt(&crate::hw::uart::Uart::new(), "boot allocator exhausted"); } NEXT_FREE += PAGE_SIZE; core::ptr::write_bytes(addr as *mut u8, 0, PAGE_SIZE); addr } } pub fn alloc_page_table() -> &'static mut PageTable { unsafe { &mut *(alloc_zeroed_page() as *mut PageTable) } }