Skip to content

Commit

Permalink
[Kernel] PMM excludes contiguous chunk pool from general allocator
Browse files Browse the repository at this point in the history
  • Loading branch information
codyd51 committed Feb 12, 2024
1 parent f1817f5 commit b0b386f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,4 @@ Auto install LLD link? Or llvm with brew? Need lld-link for the UEFI build
// different on each OS), we could have an enum to model the possible font options, with an escape hatch
// 'get from this path' variant, which could perhaps hold different values depending on the OS.

Better errors when you try to use (ex.) printf before the VMM has initialized
3 changes: 2 additions & 1 deletion rust_kernel_libs/pmm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ pub unsafe fn pmm_init() {
}
// Floor each region to a frame boundary
// This will cut off a bit of usable memory, but we'll only lose a few frames at most
let base = page_ceil(region.addr);
let mut base = page_ceil(region.addr);
// Subtract whatever extra we got by aligning to a frame boundary above
let mut region_size = page_floor(region.len - (base - region.addr));

Expand All @@ -182,6 +182,7 @@ pub unsafe fn pmm_init() {
// Trim the contiguous chunk pool from the region and allow the rest of the frames to
// be given to the general-purpose allocator
region_size -= CONTIGUOUS_CHUNK_POOL_SIZE;
base += CONTIGUOUS_CHUNK_POOL_SIZE;
}

let page_count = (region_size + (PAGE_SIZE - 1)) / PAGE_SIZE;
Expand Down

0 comments on commit b0b386f

Please sign in to comment.