interrupt.h 1.5 KB

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