// ============================================================================ // arch/x86_64/entry.S - Kernel entry point (x86_64) // // Called by the UEFI loader after ExitBootServices. // - Long mode active, paging on (identity map from UEFI) // - RDI = pointer to BootInfo structure // - Interrupts disabled // ============================================================================ .section .text .global _start .extern kernel_main _start: // Disable interrupts cli // Set up kernel stack // Load Effective Address quadword // the address RIP (current exec instruction) + offset_to_stack_top // to the Stack pointer register (rsp) //(AT&T syntax: lea symbol(%rip), %reg) leaq _stack_top(%rip), %rsp // Align stack to 16 bytes (System V ABI) // Because ABI mandates that rsp must be 16-byte aligned at the point of a call instruction andq $-16, %rsp // The UEFI boot loader (PE/MS x64 ABI) passes BootInfo* in RCX. // kernel_main uses System V ABI and expects it in RDI. movq %rcx, %rdi call kernel_main // Should never return .Lhalt: cli hlt jmp .Lhalt // ============================================================================ // Kernel stack (16 KiB) // ============================================================================ .section .bss .align 4096 _stack_bottom: .space CONFIG_KERNEL_STACK_SIZE _stack_top: