Skip to content

Commit

Permalink
aarch64: enlarge memory range for grub loading
Browse files Browse the repository at this point in the history
For now, 0x40400000 ~ 0x40480000 is used for loading grub. But it may not
be enough sometime. Enlarge this area by movnge the ram_min to 0x40600000.
Thus there is 2M range for loading grub that is enough.

As PE loader will get image offset and size in the header to put it in the
right place, image header should also be updated.

Fixes: #261
Signed-off-by: Jianyong Wu <[email protected]>
  • Loading branch information
jongwu committed Jul 6, 2023
1 parent 180d1bd commit 6735c61
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion aarch64-unknown-none.ld
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ENTRY(ram64_start)
ACPI: [0x4020_0000-0x403f_ffff)
kernel: [0x4048_0000-]
The stack start is at the end of the DRAM region. */
ram_min = 0x40480000;
ram_min = 0x40600000;

SECTIONS
{
Expand Down
6 changes: 3 additions & 3 deletions src/arch/aarch64/ram64.s
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ ram64_start:
add x13, x18, #0x16 /* code0: UEFI "MZ" signature magic instruction */
b jump_to_rust /* code1 */

.quad 0 /* text_offset */
.quad 0 /* image_size */
.quad 0x200000 /* text_offset */
.quad 0x8000 /* image_size */
.quad 0 /* flags */
.quad 0 /* res2 */
.quad 0 /* res3 */
Expand All @@ -34,4 +34,4 @@ jump_to_rust:
mov sp, x30

/* x0: pointer to device tree */
b rust64_start
b rust64_start
9 changes: 9 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ use core::panic::PanicInfo;
#[cfg(target_arch = "x86_64")]
use x86_64::instructions::hlt;

#[cfg(target_arch = "aarch64")]
use crate::arch::aarch64::layout::code_range;

#[macro_use]
mod serial;

Expand Down Expand Up @@ -132,6 +135,12 @@ fn boot_from_device(device: &mut block::VirtioBlockDevice, info: &dyn bootinfo::
}
};

#[cfg(target_arch = "aarch64")]
if code_range().start < (info.kernel_load_addr() + size) as usize {
log!("error: Boot Image is too large!");
return false;
}

log!("Executable loaded");
efi::efi_exec(entry_addr, load_addr, size, info, &f, device);
true
Expand Down

0 comments on commit 6735c61

Please sign in to comment.