Skip to content

Commit

Permalink
refactor(x86_64/newlib): manually allocate pages for heap
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
  • Loading branch information
mkroening committed May 2, 2024
1 parent c338f95 commit e403aa0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/mm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,17 @@ pub(crate) fn init() {
let kernel_heap_size = 10 * LargePageSize::SIZE as usize;

unsafe {
let start = allocate(kernel_heap_size, true);
let start = {
let physical_address = arch::mm::physicalmem::allocate(size).unwrap();
let virtual_address = arch::mm::virtualmem::allocate(size).unwrap();

let count = size / BasePageSize::SIZE as usize;
let mut flags = PageTableEntryFlags::empty();
flags.normal().writable().execute_disable();
arch::mm::paging::map::<BasePageSize>(virtual_address, physical_address, count, flags);

virtual_address
};
ALLOCATOR.init(start.as_mut_ptr(), kernel_heap_size);

info!("Kernel heap starts at {:#x}", start);
Expand Down

0 comments on commit e403aa0

Please sign in to comment.