aarch64: add linux image header

This commit is contained in:
2025-07-16 12:03:16 +03:00
parent 21ff433b51
commit 04afd55f35
3 changed files with 24 additions and 11 deletions
+2 -1
View File
@@ -1,6 +1,6 @@
ENTRY(__aarch64_entry);
KERNEL_PHYS_BASE = 0x40080000;
KERNEL_PHYS_BASE = 0x40200000;
KERNEL_VIRT_OFFSET = 0xFFFFFF8000000000;
SECTIONS {
@@ -52,4 +52,5 @@ SECTIONS {
PROVIDE(__bss_size = __bss_end_phys - __bss_start_phys);
PROVIDE(__kernel_end = .);
PROVIDE(__kernel_size = __kernel_end - __kernel_start);
};
+2 -2
View File
@@ -35,7 +35,7 @@ pub struct KernelTableManagerImpl;
const MAPPING_OFFSET: usize = KERNEL_VIRT_OFFSET;
#[cfg(any(feature = "aarch64_board_virt", rust_analyzer))]
const KERNEL_PHYS_BASE: usize = 0x40080000;
const KERNEL_PHYS_BASE: usize = 0x40200000;
#[cfg(any(feature = "aarch64_board_raspi4b", rust_analyzer))]
const KERNEL_PHYS_BASE: usize = 0x80000;
@@ -45,7 +45,7 @@ const KERNEL_START_L2_INDEX: usize = page_index::<L2>(KERNEL_VIRT_OFFSET + KERNE
const KERNEL_END_L2_INDEX: usize = KERNEL_START_L2_INDEX + KERNEL_L3_COUNT;
// Must not be zero, should be at 4MiB
const_assert_eq!(KERNEL_START_L2_INDEX, 0);
// const_assert_eq!(KERNEL_START_L2_INDEX, 0);
// From static mapping
#[cfg(any(feature = "aarch64_board_raspi4b", rust_analyzer))]
const_assert_eq!(KERNEL_L1_INDEX, 0);
+20 -8
View File
@@ -49,8 +49,22 @@
.global __aarch64_ap_entry
.global __aarch64_ap_spin_table_entry
.extern __kernel_end
.extern __kernel_start
.section .text.entry
__aarch64_entry:
ccmp x18, #0, #0xd, pl // "MZ" magic
b __aarch64_real_entry // Jump to real entry
.quad 0 // Image load offset from start of RAM
.quad __kernel_size // Kernel size
.quad 0 // Kernel flags
.quad 0 // reserved
.quad 0 // reserved
.quad 0 // reserved
.ascii "ARM\x64"
.long 0
__aarch64_real_entry:
// x0 -- dtb_phys
//////////////////////////////
@@ -64,10 +78,8 @@ __aarch64_entry:
// Check CurrentEL //
//////////////////////////////
mrs x1, CurrentEL
lsr x1, x1, #2
and x1, x1, #3
MOV_ABS x2, .bsp_el_table
ldr x2, [x2, x1, lsl #3]
adr x2, .bsp_el_table
add x2, x2, x1
br x2
// TODO code for leaving EL3
@@ -118,10 +130,10 @@ __aarch64_entry:
.p2align 3
.bsp_el_table:
.dword .bsp_el0
.dword .bsp_el1
.dword .bsp_el2
.dword .bsp_el3
b .bsp_el0
b .bsp_el1
b .bsp_el2
b .bsp_el3
//////////////////////////////
// AP startup code //