hdisr_gcc.S 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2006-09-15 QiuYi The first version
  9. */
  10. /**
  11. * @addtogroup I386
  12. */
  13. /*@{*/
  14. #define ENTRY(proc)\
  15. .align 2;\
  16. .globl proc;\
  17. .type proc,@function;\
  18. proc:
  19. #define HDINTERRUPTFNC(name,num) \
  20. ENTRY(name)\
  21. pushl $(num);\
  22. jmp _hdinterrupts;\
  23. .data;\
  24. .long name;\
  25. .text
  26. .globl hdinterrupt_func
  27. .data
  28. .align 4
  29. .type hdinterrupt_func,@object
  30. hdinterrupt_func :
  31. .text
  32. /* the external device interrupts */
  33. HDINTERRUPTFNC(irq0, 0)
  34. HDINTERRUPTFNC(irq1, 1)
  35. HDINTERRUPTFNC(irq2, 2)
  36. HDINTERRUPTFNC(irq3, 3)
  37. HDINTERRUPTFNC(irq4, 4)
  38. HDINTERRUPTFNC(irq5, 5)
  39. HDINTERRUPTFNC(irq6, 6)
  40. HDINTERRUPTFNC(irq7, 7)
  41. HDINTERRUPTFNC(irq8, 8)
  42. HDINTERRUPTFNC(irq9, 9)
  43. HDINTERRUPTFNC(irq10, 10)
  44. HDINTERRUPTFNC(irq11, 11)
  45. HDINTERRUPTFNC(irq12, 12)
  46. HDINTERRUPTFNC(irq13, 13)
  47. HDINTERRUPTFNC(irq14, 14)
  48. HDINTERRUPTFNC(irq15, 15)
  49. .p2align 4,0x90
  50. .globl _hdinterrupts
  51. .type _hdinterrupts,@function
  52. .globl rt_interrupt_enter
  53. .globl rt_interrupt_leave
  54. .globl rt_hw_isr
  55. .globl rt_thread_switch_interrupt_flag
  56. .globl rt_interrupt_from_thread
  57. .globl rt_interrupt_to_thread
  58. _hdinterrupts:
  59. push %ds
  60. push %es
  61. pushal
  62. movw $0x10, %ax
  63. movw %ax, %ds
  64. movw %ax, %es
  65. pushl %esp
  66. call rt_interrupt_enter
  67. movl %esp, %eax /* copy esp to eax */
  68. addl $0x2c, %eax /* move to vector address */
  69. movl (%eax), %eax /* vector(eax) = *eax */
  70. pushl %eax /* push argument : int vector */
  71. call rt_hw_isr
  72. add $4, %esp /* restore argument */
  73. call rt_interrupt_leave
  74. /* if rt_thread_switch_interrupt_flag set, jump to _interrupt_thread_switch and don't return */
  75. movl $rt_thread_switch_interrupt_flag, %eax
  76. movl (%eax), %ebx
  77. cmp $0x1, %ebx
  78. jz _interrupt_thread_switch
  79. popl %esp
  80. popal
  81. pop %es
  82. pop %ds
  83. add $4,%esp
  84. iret
  85. _interrupt_thread_switch:
  86. popl %esp
  87. movl $0x0, %ebx
  88. movl %ebx, (%eax)
  89. movl $rt_interrupt_from_thread, %eax
  90. movl (%eax), %ebx
  91. movl %esp, (%ebx)
  92. movl $rt_interrupt_to_thread, %ecx
  93. movl (%ecx), %edx
  94. movl (%edx), %esp
  95. popal
  96. pop %es
  97. pop %ds
  98. add $4,%esp
  99. iret
  100. /*@}*/