icu.s 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /* $OpenBSD: icu.s,v 1.33 2015/07/16 05:10:14 guenther Exp $ */
  2. /* $NetBSD: icu.s,v 1.45 1996/01/07 03:59:34 mycroft Exp $ */
  3. /*-
  4. * Copyright (c) 1993, 1994, 1995 Charles M. Hannum. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. All advertising materials mentioning features or use of this software
  15. * must display the following acknowledgement:
  16. * This product includes software developed by Charles M. Hannum.
  17. * 4. The name of the author may not be used to endorse or promote products
  18. * derived from this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  21. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  22. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  23. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  25. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  29. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. */
  31. .data
  32. .globl _C_LABEL(imen)
  33. _C_LABEL(imen):
  34. .long 0xffff # interrupt mask enable (all off)
  35. .text
  36. /*
  37. * Process pending interrupts.
  38. *
  39. * Important registers:
  40. * ebx - cpl
  41. * esi - address to resume loop at
  42. * edi - scratch for Xsoftnet
  43. */
  44. IDTVEC(spllower)
  45. pushl %ebx
  46. pushl %esi
  47. pushl %edi
  48. movl CPL,%ebx # save priority
  49. movl $1f,%esi # address to resume loop at
  50. 1: movl %ebx,%eax # get cpl
  51. shrl $4,%eax # find its mask.
  52. movl _C_LABEL(iunmask)(,%eax,4),%eax
  53. cli
  54. andl CPUVAR(IPENDING),%eax # any non-masked bits left?
  55. jz 2f
  56. sti
  57. bsfl %eax,%eax
  58. btrl %eax,CPUVAR(IPENDING)
  59. jnc 1b
  60. jmp *_C_LABEL(Xrecurse)(,%eax,4)
  61. 2: movl %ebx,CPL
  62. sti
  63. popl %edi
  64. popl %esi
  65. popl %ebx
  66. ret
  67. /*
  68. * Handle return from interrupt after device handler finishes.
  69. *
  70. * Important registers:
  71. * ebx - cpl to restore
  72. * esi - address to resume loop at
  73. * edi - scratch for Xsoftnet
  74. */
  75. IDTVEC(doreti)
  76. popl %ebx # get previous priority
  77. movl $1f,%esi # address to resume loop at
  78. 1: movl %ebx,%eax
  79. shrl $4,%eax
  80. movl _C_LABEL(iunmask)(,%eax,4),%eax
  81. cli
  82. andl CPUVAR(IPENDING),%eax
  83. jz 2f
  84. sti
  85. bsfl %eax,%eax # slow, but not worth optimizing
  86. btrl %eax,CPUVAR(IPENDING)
  87. jnc 1b # some intr cleared the in-memory bit
  88. cli
  89. jmp *_C_LABEL(Xresume)(,%eax,4)
  90. 2: /* Check for ASTs on exit to user mode. */
  91. CHECK_ASTPENDING(%ecx)
  92. movl %ebx,CPL
  93. je 3f
  94. testb $SEL_RPL,TF_CS(%esp)
  95. #ifdef VM86
  96. jnz 4f
  97. testl $PSL_VM,TF_EFLAGS(%esp)
  98. #endif
  99. jz 3f
  100. 4: CLEAR_ASTPENDING(%ecx)
  101. sti
  102. pushl %esp
  103. call _C_LABEL(ast)
  104. addl $4,%esp
  105. cli
  106. jmp 2b
  107. 3: INTRFASTEXIT
  108. /*
  109. * Soft interrupt handlers
  110. */
  111. IDTVEC(softtty)
  112. movl $IPL_SOFTTTY,%eax
  113. movl %eax,CPL
  114. sti
  115. pushl $I386_SOFTINTR_SOFTTTY
  116. call _C_LABEL(softintr_dispatch)
  117. addl $4,%esp
  118. jmp *%esi
  119. IDTVEC(softnet)
  120. movl $IPL_SOFTNET,%eax
  121. movl %eax,CPL
  122. sti
  123. pushl $I386_SOFTINTR_SOFTNET
  124. call _C_LABEL(softintr_dispatch)
  125. addl $4,%esp
  126. jmp *%esi
  127. #undef DONETISR
  128. IDTVEC(softclock)
  129. movl $IPL_SOFTCLOCK,%eax
  130. movl %eax,CPL
  131. sti
  132. pushl $I386_SOFTINTR_SOFTCLOCK
  133. call _C_LABEL(softintr_dispatch)
  134. addl $4,%esp
  135. jmp *%esi