isr.S 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. .section .text
  2. .align 4
  3. .macro ISR_NOERR index
  4. .global _isr\index
  5. _isr\index:
  6. cli
  7. push $0
  8. push $\index
  9. jmp isr_common
  10. .endm
  11. .macro ISR_ERR index
  12. .global _isr\index
  13. _isr\index:
  14. cli
  15. push $\index
  16. jmp isr_common
  17. .endm
  18. /* Standard X86 interrupt service routines */
  19. ISR_NOERR 0
  20. ISR_NOERR 1
  21. ISR_NOERR 2
  22. ISR_NOERR 3
  23. ISR_NOERR 4
  24. ISR_NOERR 5
  25. ISR_NOERR 6
  26. ISR_NOERR 7
  27. ISR_ERR 8
  28. ISR_NOERR 9
  29. ISR_ERR 10
  30. ISR_ERR 11
  31. ISR_ERR 12
  32. ISR_ERR 13
  33. ISR_ERR 14
  34. ISR_NOERR 15
  35. ISR_NOERR 16
  36. ISR_NOERR 17
  37. ISR_NOERR 18
  38. ISR_NOERR 19
  39. ISR_NOERR 20
  40. ISR_NOERR 21
  41. ISR_NOERR 22
  42. ISR_NOERR 23
  43. ISR_NOERR 24
  44. ISR_NOERR 25
  45. ISR_NOERR 26
  46. ISR_NOERR 27
  47. ISR_NOERR 28
  48. ISR_NOERR 29
  49. ISR_NOERR 30
  50. ISR_NOERR 31
  51. ISR_NOERR 127
  52. .extern fault_handler
  53. .type fault_handler, @function
  54. isr_common:
  55. /* Push all registers */
  56. pusha
  57. /* Save segment registers */
  58. push %ds
  59. push %es
  60. push %fs
  61. push %gs
  62. mov $0x10, %ax
  63. mov %ax, %ds
  64. mov %ax, %es
  65. mov %ax, %fs
  66. mov %ax, %gs
  67. cld
  68. /* Call fault handler */
  69. push %esp
  70. call fault_handler
  71. add $4, %esp
  72. /* Restore segment registers */
  73. pop %gs
  74. pop %fs
  75. pop %es
  76. pop %ds
  77. /* Restore registers */
  78. popa
  79. /* Cleanup error code and ISR # */
  80. add $8, %esp
  81. /* pop CS, EIP, EFLAGS, SS and ESP */
  82. iret