timer.S 1.8 KB

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