interrupt.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_32 {
  10. uint32_t edi;
  11. uint32_t esi;
  12. uint32_t ebp;
  13. uint32_t esp;
  14. uint32_t ebx;
  15. uint32_t edx;
  16. uint32_t ecx;
  17. uint32_t eax;
  18. };
  19. struct interrupt_stack {
  20. struct regs_32 s_regs;
  21. void* v_eip;
  22. uint32_t cs;
  23. uint32_t eflags;
  24. uint32_t esp;
  25. uint32_t ss;
  26. };
  27. struct mmx_registers {
  28. uint8_t data[512]; // TODO: list of content
  29. };
  30. // present: When set, the page fault was caused by a page-protection violation.
  31. // When not set, it was caused by a non-present page.
  32. // write: When set, the page fault was caused by a write access.
  33. // When not set, it was caused by a read access.
  34. // user: When set, the page fault was caused while CPL = 3.
  35. // This does not necessarily mean that the page fault was a privilege violation.
  36. // from https://wiki.osdev.org/Exceptions#Page_Fault
  37. struct page_fault_error_code {
  38. uint32_t present : 1;
  39. uint32_t write : 1;
  40. uint32_t user : 1;
  41. uint32_t reserved_write : 1;
  42. uint32_t instruction_fetch : 1;
  43. uint32_t protection_key : 1;
  44. uint32_t shadow_stack : 1;
  45. uint32_t software_guard_extensions : 1;
  46. };
  47. void init_idt(void);
  48. void init_pic(void);
  49. #ifdef __cplusplus
  50. }
  51. #endif