Skip to content

Commit

Permalink
feat: initialize heap after paging
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
mkroening committed Aug 24, 2023
1 parent a33b984 commit 45f6ac2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
12 changes: 0 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,6 @@ fn synch_all_cores() {
/// Entry Point of HermitCore for the Boot Processor
#[cfg(target_os = "none")]
fn boot_processor_main() -> ! {
let init_heap_start = env::get_base_address() + env::get_image_size();
let init_heap_len =
init_heap_start.align_up_to_large_page().as_usize() - init_heap_start.as_usize();
unsafe {
ALLOCATOR.init(init_heap_start.as_mut_ptr(), init_heap_len);
}

// Initialize the kernel and hardware.
arch::message_output_init();
unsafe {
Expand All @@ -326,11 +319,6 @@ fn boot_processor_main() -> ! {
env::get_tls_start(),
env::get_tls_memsz()
);
info!(
"Init heap: [0x{:p} - 0x{:p}]",
init_heap_start,
init_heap_start + init_heap_len
);
arch::boot_processor_init();
scheduler::add_current_core();

Expand Down
13 changes: 4 additions & 9 deletions src/mm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,21 +223,16 @@ pub(crate) fn init() {
}

let heap_end_addr = map_addr;
let init_heap_start_addr = env::get_base_address() + env::get_image_size();

#[cfg(not(feature = "newlib"))]
unsafe {
crate::ALLOCATOR.extend(
init_heap_start_addr.as_mut_ptr(),
(heap_end_addr - init_heap_start_addr).into(),
crate::ALLOCATOR.init(
heap_start_addr.as_mut_ptr(),
(heap_end_addr - heap_start_addr).into(),
);
}
info!(
"Heap extension from {:#x} to {:#x}",
heap_start_addr, heap_end_addr
);

let heap_addr_range = init_heap_start_addr..heap_end_addr;
let heap_addr_range = heap_start_addr..heap_end_addr;
info!("Heap is located at {heap_addr_range:#x?} ({map_size} Bytes unmapped)");
#[cfg(feature = "newlib")]
HEAP_ADDR_RANGE.set(heap_addr_range).unwrap();
Expand Down

0 comments on commit 45f6ac2

Please sign in to comment.