Skip to content

Commit

Permalink
Fix: Consider config file when initializing frame allocator
Browse files Browse the repository at this point in the history
We still considered the ramdisk file as the last used frame when initializing the frame allocator, so we overwrote the config file. This commit fixes this by setting the `last_used_addr` correctly when creating the `BiosInfo`.
  • Loading branch information
phil-opp committed Jan 30, 2023
1 parent 38aa266 commit f03065e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
1 change: 1 addition & 0 deletions bios/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub struct BiosInfo {
pub kernel: Region,
pub ramdisk: Region,
pub config_file: Region,
pub last_used_addr: u64,
pub framebuffer: BiosFramebufferInfo,
pub memory_map_addr: u32,
pub memory_map_len: u16,
Expand Down
1 change: 1 addition & 0 deletions bios/stage-2/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ fn start(disk_number: u16, partition_table_start: *const u8) -> ! {
start: config_file_start as u64,
len: config_file_len,
},
last_used_addr: config_file_start as u64 + config_file_len - 1,
memory_map_addr: memory_map.as_mut_ptr() as u32,
memory_map_len: memory_map.len().try_into().unwrap(),
framebuffer: BiosFramebufferInfo {
Expand Down
9 changes: 1 addition & 8 deletions bios/stage-4/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,7 @@ pub extern "C" fn _start(info: &mut BiosInfo) -> ! {
PhysAddr::new(info.kernel.start)
};
let kernel_size = info.kernel.len;
let next_free_frame = match info.ramdisk.len {
0 => PhysFrame::containing_address(kernel_start + kernel_size - 1u64) + 1,
_ => {
PhysFrame::containing_address(PhysAddr::new(
info.ramdisk.start + info.ramdisk.len - 1u64,
)) + 1
}
};
let next_free_frame = PhysFrame::containing_address(PhysAddr::new(info.last_used_addr)) + 1;
let mut frame_allocator = LegacyFrameAllocator::new_starting_at(
next_free_frame,
memory_map.iter().copied().map(MemoryRegion),
Expand Down

0 comments on commit f03065e

Please sign in to comment.