Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 0 additions & 79 deletions src/mm/allocator.rs

This file was deleted.

13 changes: 5 additions & 8 deletions src/mm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
//! │ │ │ │
//! ```

pub(crate) mod allocator;
pub(crate) mod device_alloc;
pub(crate) mod physicalmem;
pub(crate) mod virtualmem;
Expand All @@ -50,10 +49,10 @@ use core::ops::Range;

use align_address::Align;
use free_list::{PageLayout, PageRange};
use hermit_sync::Lazy;
use hermit_sync::{Lazy, RawInterruptTicketMutex};
pub use memory_addresses::{PhysAddr, VirtAddr};
use talc::{ErrOnOom, Span, Talc, Talck};

use self::allocator::LockedAllocator;
#[cfg(any(target_arch = "x86_64", target_arch = "riscv64"))]
use crate::arch::mm::paging::HugePageSize;
pub use crate::arch::mm::paging::virtual_to_physical;
Expand All @@ -64,7 +63,7 @@ use crate::{arch, env};

#[cfg(target_os = "none")]
#[global_allocator]
pub(crate) static ALLOCATOR: LockedAllocator = LockedAllocator::new();
pub(crate) static ALLOCATOR: Talck<RawInterruptTicketMutex, ErrOnOom> = Talc::new(ErrOnOom).lock();

/// Physical and virtual address range of the 2 MiB pages that map the kernel.
static KERNEL_ADDR_RANGE: Lazy<Range<VirtAddr>> = Lazy::new(|| {
Expand Down Expand Up @@ -276,11 +275,9 @@ pub(crate) fn init() {

let heap_end_addr = map_addr;

let arena = Span::new(heap_start_addr.as_mut_ptr(), heap_end_addr.as_mut_ptr());
unsafe {
ALLOCATOR.init(
heap_start_addr.as_mut_ptr(),
(heap_end_addr - heap_start_addr) as usize,
);
ALLOCATOR.lock().claim(arena).unwrap();
}

info!("Heap is located at {heap_start_addr:p}..{heap_end_addr:p} ({map_size} Bytes unmapped)");
Expand Down