interrupt.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #pragma once
  2. #include <types/types.h>
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #define KERNEL_INTERRUPT_GATE_TYPE (0x8e)
  7. #define USER_INTERRUPT_GATE_TYPE (0xee)
  8. struct regs_64 {
  9. uint64_t rax;
  10. uint64_t rbx;
  11. uint64_t rcx;
  12. uint64_t rdx;
  13. uint64_t rsi;
  14. uint64_t rdi;
  15. uint64_t rsp;
  16. uint64_t rbp;
  17. uint64_t r8;
  18. uint64_t r9;
  19. uint64_t r10;
  20. uint64_t r11;
  21. uint64_t r12;
  22. uint64_t r13;
  23. uint64_t r14;
  24. uint64_t r15;
  25. };
  26. struct interrupt_stack {
  27. regs_64 s_regs;
  28. void* v_rip;
  29. uint64_t cs;
  30. uint64_t flags;
  31. uint64_t rsp;
  32. uint64_t ss;
  33. };
  34. struct mmx_registers {
  35. uint8_t data[512]; // TODO: list of content
  36. };
  37. // present: When set, the page fault was caused by a page-protection violation.
  38. // When not set, it was caused by a non-present page.
  39. // write: When set, the page fault was caused by a write access.
  40. // When not set, it was caused by a read access.
  41. // user: When set, the page fault was caused while CPL = 3.
  42. // This does not necessarily mean that the page fault was a privilege violation.
  43. // from https://wiki.osdev.org/Exceptions#Page_Fault
  44. struct page_fault_error_code {
  45. uint32_t present : 1;
  46. uint32_t write : 1;
  47. uint32_t user : 1;
  48. uint32_t reserved_write : 1;
  49. uint32_t instruction_fetch : 1;
  50. uint32_t protection_key : 1;
  51. uint32_t shadow_stack : 1;
  52. uint32_t software_guard_extensions : 1;
  53. };
  54. void init_idt(void);
  55. void init_pic(void);
  56. #ifdef __cplusplus
  57. }
  58. #endif