diff --git a/src/allocator.rs b/src/allocator.rs index e47a40cc0..f77fef9d6 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -1,5 +1,6 @@ use alloc::alloc::{GlobalAlloc, Layout}; use core::ptr::null_mut; +use linked_list_allocator::LockedHeap; use x86_64::{ structures::paging::{ mapper::MapToError, FrameAllocator, Mapper, Page, PageTableFlags, Size4KiB, @@ -10,6 +11,9 @@ use x86_64::{ pub const HEAP_START: usize = 0x_4444_4444_0000; pub const HEAP_SIZE: usize = 100 * 1024; // 100 KiB +#[global_allocator] +static ALLOCATOR: LockedHeap = LockedHeap::empty(); + pub fn init_heap( mapper: &mut impl Mapper, frame_allocator: &mut impl FrameAllocator, @@ -31,7 +35,7 @@ pub fn init_heap( } unsafe { - super::ALLOCATOR.lock().init(HEAP_START, HEAP_SIZE); + ALLOCATOR.lock().init(HEAP_START, HEAP_SIZE); } Ok(()) diff --git a/src/lib.rs b/src/lib.rs index f416c1e5c..250e1ba96 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,6 @@ extern crate alloc; use core::panic::PanicInfo; -use linked_list_allocator::LockedHeap; pub mod allocator; pub mod gdt; @@ -18,9 +17,6 @@ pub mod memory; pub mod serial; pub mod vga_buffer; -#[global_allocator] -static ALLOCATOR: LockedHeap = LockedHeap::empty(); - pub fn init() { gdt::init(); interrupts::init_idt();