timer.S 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* IRQ stubs: save state, call C handler, restore, iret. */
  2. .code32
  3. .text
  4. .globl pit_irq_stub
  5. pit_irq_stub:
  6. pusha
  7. call pit_irq
  8. popa
  9. iret
  10. .globl kbd_irq_stub
  11. kbd_irq_stub:
  12. pusha
  13. call kbd_irq
  14. popa
  15. iret
  16. .globl fdc_irq_stub
  17. fdc_irq_stub:
  18. pusha
  19. call fdc_irq
  20. popa
  21. iret
  22. /* Default IRQ handler: send EOI and return. Catches spurious and
  23. unexpected hardware interrupts that would otherwise triple-fault. */
  24. .globl default_irq_stub
  25. default_irq_stub:
  26. pushl %eax
  27. movb $0x20, %al
  28. outb %al, $0x20
  29. popl %eax
  30. iret
  31. /* CPU exception stubs (vectors 0-31). The handler never returns,
  32. so we don't need to preserve the full frame for iret. */
  33. .macro exc_no_err vec
  34. exc_stub_\vec:
  35. pushl $\vec
  36. jmp exc_common
  37. .endm
  38. .macro exc_err vec
  39. exc_stub_\vec:
  40. addl $4, %esp
  41. pushl $\vec
  42. jmp exc_common
  43. .endm
  44. exc_no_err 0
  45. exc_no_err 1
  46. exc_no_err 2
  47. exc_no_err 3
  48. exc_no_err 4
  49. exc_no_err 5
  50. exc_no_err 6
  51. exc_no_err 7
  52. exc_err 8
  53. exc_no_err 9
  54. exc_err 10
  55. exc_err 11
  56. exc_err 12
  57. exc_err 13
  58. exc_err 14
  59. exc_no_err 15
  60. exc_no_err 16
  61. exc_err 17
  62. exc_no_err 18
  63. exc_no_err 19
  64. exc_no_err 20
  65. exc_no_err 21
  66. exc_no_err 22
  67. exc_no_err 23
  68. exc_no_err 24
  69. exc_no_err 25
  70. exc_no_err 26
  71. exc_no_err 27
  72. exc_no_err 28
  73. exc_no_err 29
  74. exc_no_err 30
  75. exc_no_err 31
  76. exc_common:
  77. call exc_handler
  78. cli
  79. 1: hlt
  80. jmp 1b
  81. /* Lookup table so C can iterate over the 32 stubs. */
  82. .section .rodata
  83. .globl exc_stub_table
  84. exc_stub_table:
  85. .long exc_stub_0, exc_stub_1, exc_stub_2, exc_stub_3
  86. .long exc_stub_4, exc_stub_5, exc_stub_6, exc_stub_7
  87. .long exc_stub_8, exc_stub_9, exc_stub_10, exc_stub_11
  88. .long exc_stub_12, exc_stub_13, exc_stub_14, exc_stub_15
  89. .long exc_stub_16, exc_stub_17, exc_stub_18, exc_stub_19
  90. .long exc_stub_20, exc_stub_21, exc_stub_22, exc_stub_23
  91. .long exc_stub_24, exc_stub_25, exc_stub_26, exc_stub_27
  92. .long exc_stub_28, exc_stub_29, exc_stub_30, exc_stub_31