Skip to content

Commit f03065e

Browse files
committed
Fix: Consider config file when initializing frame allocator
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`.
1 parent 38aa266 commit f03065e

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

bios/common/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub struct BiosInfo {
99
pub kernel: Region,
1010
pub ramdisk: Region,
1111
pub config_file: Region,
12+
pub last_used_addr: u64,
1213
pub framebuffer: BiosFramebufferInfo,
1314
pub memory_map_addr: u32,
1415
pub memory_map_len: u16,

bios/stage-2/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ fn start(disk_number: u16, partition_table_start: *const u8) -> ! {
161161
start: config_file_start as u64,
162162
len: config_file_len,
163163
},
164+
last_used_addr: config_file_start as u64 + config_file_len - 1,
164165
memory_map_addr: memory_map.as_mut_ptr() as u32,
165166
memory_map_len: memory_map.len().try_into().unwrap(),
166167
framebuffer: BiosFramebufferInfo {

bios/stage-4/src/main.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,7 @@ pub extern "C" fn _start(info: &mut BiosInfo) -> ! {
5454
PhysAddr::new(info.kernel.start)
5555
};
5656
let kernel_size = info.kernel.len;
57-
let next_free_frame = match info.ramdisk.len {
58-
0 => PhysFrame::containing_address(kernel_start + kernel_size - 1u64) + 1,
59-
_ => {
60-
PhysFrame::containing_address(PhysAddr::new(
61-
info.ramdisk.start + info.ramdisk.len - 1u64,
62-
)) + 1
63-
}
64-
};
57+
let next_free_frame = PhysFrame::containing_address(PhysAddr::new(info.last_used_addr)) + 1;
6558
let mut frame_allocator = LegacyFrameAllocator::new_starting_at(
6659
next_free_frame,
6760
memory_map.iter().copied().map(MemoryRegion),

0 commit comments

Comments
 (0)