diff options
Diffstat (limited to 'kernel/arch/aarch64/entry.S')
| -rw-r--r-- | kernel/arch/aarch64/entry.S | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/kernel/arch/aarch64/entry.S b/kernel/arch/aarch64/entry.S new file mode 100644 index 0000000..1ca9b0c --- /dev/null +++ b/kernel/arch/aarch64/entry.S @@ -0,0 +1,46 @@ +// ============================================================================ +// arch/aarch64/entry.S - Kernel entry point (AArch64) +// +// Called by the UEFI loader after ExitBootServices. +// - EL1, MMU on (identity map from UEFI) +// - X0 = pointer to BootInfo structure (AAPCS64 6.8.2 C.9 Pointer located in X[NGRN]) +// - Interrupts masked (DAIF) +// ============================================================================ + +.section .text +.global _start +.extern kernel_main + +_start: + // Mask all interrupts + msr daifset, #0xF + + // Set up kernel stack pointer to Stack Pointer(SP) + adrp x1, _stack_top + add x1, x1, :lo12:_stack_top + mov sp, x1 + + // Clear frame pointer for clean stack traces + // x29 is Frame Pointer (FP), points to the prev stack frame. Make kerne_main is root of the call chain (remove UEFI calls) + // x30 is Link Register (LR), holds the return address from the last bl. Same logic. + mov x29, #0 + mov x30, #0 + + // X0 already holds BootInfo* + bl kernel_main + + // Should never return +.Lhalt: + wfi + b .Lhalt + +// ============================================================================ +// Kernel stack (16 KiB) +// Maybe in future i will increase this value, but i hope it's not necessary +// ============================================================================ + +.section .bss +.balign 4096 +_stack_bottom: + .space CONFIG_KERNEL_STACK_SIZE +_stack_top: |
