pub struct KernelHeap {
stage: UnsafeCell<Stage>,
primitive_ptr: *const u8,
primitive_end: *const u8,
}
Expand description
Implementation of GlobalAlloc
for objects belong to kernel space.
This allocator has 2 stages. The first stage will allocate a memory from a static buffer (AKA arena). This stage will be primary used for bootstrapping the kernel. The second stage will be activated once the required subsystems has been initialized.
The first stage is not thread safe so stage 2 must be activated before start a new CPU.
Fields§
§stage: UnsafeCell<Stage>
§primitive_ptr: *const u8
§primitive_end: *const u8
Implementations§
Source§impl KernelHeap
impl KernelHeap
Sourcepub const unsafe fn new<const L: usize>(primitive: *mut [u8; L]) -> Self
pub const unsafe fn new<const L: usize>(primitive: *mut [u8; L]) -> Self
§Safety
The specified memory must be valid for reads and writes and it must be exclusively available
to KernelHeap
.
Sourcepub unsafe fn activate_stage2(&self)
pub unsafe fn activate_stage2(&self)
§Safety
This must be called by main CPU and can be called only once.
Trait Implementations§
Source§impl GlobalAlloc for KernelHeap
impl GlobalAlloc for KernelHeap
Source§unsafe fn alloc(&self, layout: Layout) -> *mut u8
unsafe fn alloc(&self, layout: Layout) -> *mut u8
Allocates memory as described by the given
layout
. Read moreimpl Send for KernelHeap
impl Sync for KernelHeap
Auto Trait Implementations§
impl !Freeze for KernelHeap
impl !RefUnwindSafe for KernelHeap
impl Unpin for KernelHeap
impl !UnwindSafe for KernelHeap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more