Skip to content

Commit

Permalink
Merge pull request #337 from rust-osdev/fix-stage-4-panic
Browse files Browse the repository at this point in the history
Map BIOS stage-4 at lower address to avoid conflicts with the kernel
  • Loading branch information
phil-opp committed Jan 29, 2023
2 parents 1181a01 + 713a219 commit 093a338
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions bios/stage-2/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ mod vesa;
/// We use this partition type to store the second bootloader stage;
const BOOTLOADER_SECOND_STAGE_PARTITION_TYPE: u8 = 0x20;

const STAGE_3_DST: *mut u8 = 0x0010_0000 as *mut u8; // 1MiB (typically 14MiB accessible here)
const STAGE_4_DST: *mut u8 = 0x0020_0000 as *mut u8; // 2MiB (typically still 13MiB accessible here)
const KERNEL_DST: *mut u8 = 0x0100_0000 as *mut u8; // 16MiB
// 1MiB (typically 14MiB accessible here)
const STAGE_3_DST: *mut u8 = 0x0010_0000 as *mut u8;
// must match the start address in bios/stage-4/stage-4-link.ld
const STAGE_4_DST: *mut u8 = 0x0013_0000 as *mut u8;
// 16MiB
const KERNEL_DST: *mut u8 = 0x0100_0000 as *mut u8;

static mut DISK_BUFFER: AlignedArrayBuffer<0x4000> = AlignedArrayBuffer {
buffer: [0; 0x4000],
Expand Down
3 changes: 2 additions & 1 deletion bios/stage-4/stage-4-link.ld
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
ENTRY(_start)

SECTIONS {
. = 0x00200000;
# must match STAGE_4_DST address in bios/stage-2/src/main.rs
. = 0x00130000;

.start : {
*(.start)
Expand Down

0 comments on commit 093a338

Please sign in to comment.