hdisr.S 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * File : hdisr.S
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Development Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://openlab.rt-thread.com/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. */
  13. /**
  14. * @addtogroup I386
  15. */
  16. /*@{*/
  17. #define ENTRY(proc)\
  18. .align 2;\
  19. .globl proc;\
  20. .type proc,@function;\
  21. proc:
  22. #define HDINTERRUPTFNC(name,num) \
  23. ENTRY(name)\
  24. pushl $(num);\
  25. jmp _hdinterrupts;\
  26. .data;\
  27. .long name;\
  28. .text
  29. .globl hdinterrupt_func
  30. .data
  31. .align 4
  32. .type hdinterrupt_func,@object
  33. hdinterrupt_func :
  34. .text
  35. /* the external device interrupts */
  36. HDINTERRUPTFNC(irq0, 0)
  37. HDINTERRUPTFNC(irq1, 1)
  38. HDINTERRUPTFNC(irq2, 2)
  39. HDINTERRUPTFNC(irq3, 3)
  40. HDINTERRUPTFNC(irq4, 4)
  41. HDINTERRUPTFNC(irq5, 5)
  42. HDINTERRUPTFNC(irq6, 6)
  43. HDINTERRUPTFNC(irq7, 7)
  44. HDINTERRUPTFNC(irq8, 8)
  45. HDINTERRUPTFNC(irq9, 9)
  46. HDINTERRUPTFNC(irq10, 10)
  47. HDINTERRUPTFNC(irq11, 11)
  48. HDINTERRUPTFNC(irq12, 12)
  49. HDINTERRUPTFNC(irq13, 13)
  50. HDINTERRUPTFNC(irq14, 14)
  51. HDINTERRUPTFNC(irq15, 15)
  52. .p2align 4,0x90
  53. .globl _hdinterrupts
  54. .type _hdinterrupts,@function
  55. .globl rt_interrupt_enter
  56. .globl rt_interrupt_leave
  57. .globl isr_table
  58. .globl rt_thread_switch_interrput_flag
  59. .globl rt_interrupt_from_thread
  60. .globl rt_interrupt_to_thread
  61. _hdinterrupts:
  62. push %ds
  63. push %es
  64. pushal
  65. movw $0x10, %ax
  66. movw %ax, %ds
  67. movw %ax, %es
  68. pushl %esp
  69. call rt_interrupt_enter
  70. movl %esp, %eax /* get irqno */
  71. addl $0x2c, %eax
  72. movl (%eax), %eax /* each item takes up 4bytes in isr_table,equl to isr_table[irqno] */
  73. shll $0x2, %eax
  74. movl $isr_table, %ebx
  75. addl %eax,%ebx
  76. call *(%ebx)
  77. call rt_interrupt_leave
  78. /* if rt_thread_switch_interrput_flag set, jump to _interrupt_thread_switch and don't return */
  79. movl $rt_thread_switch_interrput_flag, %eax
  80. movl (%eax), %ebx
  81. cmp $0x1, %ebx
  82. jz _interrupt_thread_switch
  83. popl %esp
  84. popal
  85. pop %es
  86. pop %ds
  87. add $4,%esp
  88. iret
  89. _interrupt_thread_switch:
  90. popl %esp
  91. movl $0x0, %ebx
  92. movl %ebx, (%eax)
  93. movl $rt_interrupt_from_thread, %eax
  94. movl (%eax), %ebx
  95. movl %esp, (%ebx)
  96. movl $rt_interrupt_to_thread, %ecx
  97. movl (%ecx), %edx
  98. movl (%edx), %esp
  99. popal
  100. pop %es
  101. pop %ds
  102. add $4,%esp
  103. iret
  104. /*@}*/