panic.h 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. /* Fatal exception screen.
  2. *
  3. * Only ring-0 faults reach this path: a fault from ring 3 kills the offending
  4. * process and the kernel keeps running (see exc_handler() in kernel.c). The
  5. * handler runs with interrupts off and never returns, so this code must not
  6. * depend on the scheduler, the heap or the current screen buffer: it draws
  7. * straight into the VESA LFB (bypassing the WM and the shadow buffer) and
  8. * mirrors everything to COM1.
  9. *
  10. * Addresses printed here are raw kernel addresses; resolve them with
  11. * `nm kernel.elf` / `addr2line -e kernel.elf`. */
  12. #ifndef PANIC_H
  13. #define PANIC_H
  14. /* CPU state captured by the exception stubs (timer.S). The layout must
  15. * match the stub exactly, low to high:
  16. *
  17. * pusha block: EDI, ESI, EBP, ESP(as saved by pusha), EBX, EDX, ECX, EAX
  18. * exception frame: vector, error code, EIP, CS, EFLAGS, [user ESP, user SS]
  19. *
  20. * The ESP/SS fields are only meaningful for a fault from ring 3 (the CPU
  21. * pushes them on a privilege change). */
  22. struct exc_state {
  23. unsigned int edi, esi, ebp, esp_pusha;
  24. unsigned int ebx, edx, ecx, eax;
  25. unsigned int vector, err, eip, cs, eflags, esp, ss;
  26. };
  27. /* Draw the banner and dump the state to COM1. `name` is the vector name. */
  28. void panic_report(const struct exc_state *st, const char *name);
  29. #endif