Created the framework for using different loadable panic handlers, loaded by the bootloader. Initial panic handler is panic.serial, which contains its own serial driver and stacktrace code. Other related changes: - Asserts are now based on the NMI handler - panic handlers get installed as the NMI interrupt handler - Changed symbol table generation: now use nm's own demangling and sorting, and include symbol size in the table - Move the linker script argument out of the kernel target, and into the kernel's specific module, so that other programs (ie, panic handlers) can use the kernel target as well - Some asm changes to boot.s to help GDB see stack frames - but this might not actually be all that useful - Renamed user_rsp to just rsp in cpu_state - everything in there is describing the 'user' state
59 lines
1.0 KiB
ArmAsm
59 lines
1.0 KiB
ArmAsm
MAGIC equ 'j6KERNEL' ; jsix kernel header magic number
|
|
|
|
section .header
|
|
align 8
|
|
global _kernel_header
|
|
_kernel_header:
|
|
dq MAGIC ; Kernel header magic
|
|
dw 32 ; Kernel header length
|
|
dw 2 ; Header version 2
|
|
dw VERSION_MAJOR ; Kernel version
|
|
dw VERSION_MINOR
|
|
dw VERSION_PATCH
|
|
dw 0 ; reserved
|
|
dd VERSION_GITSHA
|
|
dq 0 ; Flags
|
|
|
|
section .text
|
|
align 16
|
|
global _kernel_start:function (_kernel_start.end - _kernel_start)
|
|
global _kernel_start.real
|
|
_kernel_start:
|
|
push rbp ; Never executed, fake function prelude
|
|
mov rbp, rsp ; to calm down gdb
|
|
|
|
.real:
|
|
cli
|
|
|
|
mov rsp, idle_stack_end
|
|
sub rsp, 16
|
|
mov rbp, rsp
|
|
|
|
extern kernel_main
|
|
call kernel_main
|
|
|
|
; Kernel init is over, wait for the scheduler to
|
|
; take over
|
|
.hang:
|
|
hlt
|
|
jmp .hang
|
|
.end:
|
|
|
|
global interrupts_enable
|
|
interrupts_enable:
|
|
sti
|
|
ret
|
|
|
|
global interrupts_disable
|
|
interrupts_disable:
|
|
cli
|
|
ret
|
|
|
|
section .bss
|
|
align 0x100
|
|
idle_stack_begin:
|
|
resb 0x4000 ; 16KiB stack space
|
|
|
|
global idle_stack_end
|
|
idle_stack_end:
|