allocator.rs 468 B

1234567891011121314151617
  1. use good_memory_allocator::SpinLockedAllocator;
  2. #[repr(align(0x4000))]
  3. struct Align16K<T>(T);
  4. /// 16 KiB naturally aligned backing storage for heap.
  5. static mut HEAP: Align16K<[u8; 0x4000]> = Align16K([0; 0x4000]);
  6. #[global_allocator]
  7. static ALLOCATOR: SpinLockedAllocator = SpinLockedAllocator::empty();
  8. /// Initializes the allocator. Call only once.
  9. pub fn init() {
  10. unsafe {
  11. ALLOCATOR.init(HEAP.0.as_ptr().cast::<usize>() as _, HEAP.0.len());
  12. }
  13. }