irq.S 993 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. .section .text
  2. .align 4
  3. .macro IRQ ident byte
  4. .global _irq\ident
  5. .type _irq\ident, @function
  6. _irq\ident:
  7. cli
  8. push $0x00
  9. push $\byte
  10. jmp irq_common
  11. .endm
  12. /* Interrupt Requests */
  13. IRQ 0, 32
  14. IRQ 1, 33
  15. IRQ 2, 34
  16. IRQ 3, 35
  17. IRQ 4, 36
  18. IRQ 5, 37
  19. IRQ 6, 38
  20. IRQ 7, 39
  21. IRQ 8, 40
  22. IRQ 9, 41
  23. IRQ 10, 42
  24. IRQ 11, 43
  25. IRQ 12, 44
  26. IRQ 13, 45
  27. IRQ 14, 46
  28. IRQ 15, 47
  29. .extern irq_handler
  30. .type irq_handler, @function
  31. irq_common:
  32. /* Save all registers */
  33. pusha
  34. /* Save segment registers */
  35. push %ds
  36. push %es
  37. push %fs
  38. push %gs
  39. mov $0x10, %ax
  40. mov %ax, %ds
  41. mov %ax, %es
  42. mov %ax, %fs
  43. mov %ax, %gs
  44. cld
  45. /* Call interrupt handler */
  46. push %esp
  47. call irq_handler
  48. add $4, %esp
  49. /* Restore segment registers */
  50. pop %gs
  51. pop %fs
  52. pop %es
  53. pop %ds
  54. /* Restore all registers */
  55. popa
  56. /* Cleanup error code and IRQ # */
  57. add $8, %esp
  58. /* pop CS, EIP, EFLAGS, SS and ESP */
  59. iret