4040//! │ │ │ │
4141//! ```
4242
43- pub ( crate ) mod allocator;
4443pub ( crate ) mod device_alloc;
4544pub ( crate ) mod physicalmem;
4645pub ( crate ) mod virtualmem;
@@ -50,10 +49,10 @@ use core::ops::Range;
5049
5150use align_address:: Align ;
5251use free_list:: { PageLayout , PageRange } ;
53- use hermit_sync:: Lazy ;
52+ use hermit_sync:: { Lazy , RawInterruptTicketMutex } ;
5453pub use memory_addresses:: { PhysAddr , VirtAddr } ;
54+ use talc:: { ErrOnOom , Span , Talc , Talck } ;
5555
56- use self :: allocator:: LockedAllocator ;
5756#[ cfg( any( target_arch = "x86_64" , target_arch = "riscv64" ) ) ]
5857use crate :: arch:: mm:: paging:: HugePageSize ;
5958pub use crate :: arch:: mm:: paging:: virtual_to_physical;
@@ -64,7 +63,7 @@ use crate::{arch, env};
6463
6564#[ cfg( target_os = "none" ) ]
6665#[ global_allocator]
67- pub ( crate ) static ALLOCATOR : LockedAllocator = LockedAllocator :: new ( ) ;
66+ pub ( crate ) static ALLOCATOR : Talck < RawInterruptTicketMutex , ErrOnOom > = Talc :: new ( ErrOnOom ) . lock ( ) ;
6867
6968/// Physical and virtual address range of the 2 MiB pages that map the kernel.
7069static KERNEL_ADDR_RANGE : Lazy < Range < VirtAddr > > = Lazy :: new ( || {
@@ -276,11 +275,9 @@ pub(crate) fn init() {
276275
277276 let heap_end_addr = map_addr;
278277
278+ let arena = Span :: new ( heap_start_addr. as_mut_ptr ( ) , heap_end_addr. as_mut_ptr ( ) ) ;
279279 unsafe {
280- ALLOCATOR . init (
281- heap_start_addr. as_mut_ptr ( ) ,
282- ( heap_end_addr - heap_start_addr) as usize ,
283- ) ;
280+ ALLOCATOR . lock ( ) . claim ( arena) . unwrap ( ) ;
284281 }
285282
286283 info ! ( "Heap is located at {heap_start_addr:p}..{heap_end_addr:p} ({map_size} Bytes unmapped)" ) ;
0 commit comments