[panic] Add separate kernel-mode panic handler

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
This commit is contained in:
Justin C. Miller
2021-08-01 14:03:10 -07:00
parent fce22b0d35
commit ea9d20a250
37 changed files with 462 additions and 225 deletions

View File

@@ -17,16 +17,18 @@ _kernel_header:
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
mov qword [rsp + 0x00], 0 ; signal end of stack with 0 return address
mov qword [rsp + 0x08], 0 ; and a few extra entries in case of stack
mov qword [rsp + 0x10], 0 ; problems
mov qword [rsp + 0x18], 0
sub rsp, 16
mov rbp, rsp
extern kernel_main
call kernel_main
@@ -54,4 +56,3 @@ idle_stack_begin:
global idle_stack_end
idle_stack_end:
resq 4