interrupt.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #pragma once
  2. #include <stdint.h>
  3. #include <types/types.h>
  4. struct saved_regs {
  5. unsigned long rax;
  6. unsigned long rbx;
  7. unsigned long rcx;
  8. unsigned long rdx;
  9. unsigned long rsi;
  10. unsigned long rdi;
  11. unsigned long r8;
  12. unsigned long r9;
  13. unsigned long r10;
  14. unsigned long r11;
  15. unsigned long r12;
  16. unsigned long r13;
  17. unsigned long r14;
  18. unsigned long r15;
  19. unsigned long rbp;
  20. };
  21. struct PACKED interrupt_stack_head {
  22. saved_regs s_regs;
  23. unsigned long int_no;
  24. };
  25. struct PACKED interrupt_stack_normal {
  26. interrupt_stack_head head;
  27. uintptr_t v_rip;
  28. unsigned long cs;
  29. unsigned long flags;
  30. uintptr_t rsp;
  31. unsigned long ss;
  32. };
  33. struct PACKED interrupt_stack_with_code {
  34. interrupt_stack_head head;
  35. unsigned long error_code;
  36. uintptr_t v_rip;
  37. unsigned long cs;
  38. unsigned long flags;
  39. uintptr_t rsp;
  40. unsigned long ss;
  41. };
  42. struct mmx_registers {
  43. uint8_t data[512]; // TODO: list of content
  44. };
  45. // present: When set, the page fault was caused by a page-protection violation.
  46. // When not set, it was caused by a non-present page.
  47. // write: When set, the page fault was caused by a write access.
  48. // When not set, it was caused by a read access.
  49. // user: When set, the page fault was caused while CPL = 3.
  50. // This does not necessarily mean that the page fault was a privilege violation.
  51. // from https://wiki.osdev.org/Exceptions#Page_Fault
  52. struct page_fault_error_code {
  53. unsigned long present : 1;
  54. unsigned long write : 1;
  55. unsigned long user : 1;
  56. unsigned long reserved_write : 1;
  57. unsigned long instruction_fetch : 1;
  58. unsigned long protection_key : 1;
  59. unsigned long shadow_stack : 1;
  60. unsigned long software_guard_extensions : 1;
  61. };
  62. namespace kernel::kinit {
  63. void init_interrupt();
  64. } // namespace kernel::kinit