l64acidt.S 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. /*
  2. * Interrupt/exception handling.
  3. */
  4. #include "amd64.h"
  5. .code64
  6. .global _acintrp
  7. _acintrp:
  8. pushq %rax // bogus error code. Makes stack look like intre.
  9. // Except in this case, bogus error code is at 0(%rsp)
  10. // vno pointer is at 8(%rsp)
  11. MOVQ 8(%rsp), %rax
  12. // Now %rax points to the vector number.
  13. JMP _acintrcommon
  14. .globl _acintre
  15. _acintre:
  16. ///jmp _intre
  17. // The error code has been pushed. How I love the x86.
  18. // So the error code is ABOVE the pointer to the vector #.
  19. XCHGQ %rax, (%rsp)
  20. _acintrcommon:
  21. // Get the vector number into %al
  22. MOVb (%rax), %al
  23. ANDQ $0xff, %rax
  24. // Put that at TOS (this is plan 9 argument style)
  25. XCHGQ %rax, 0(%rsp)
  26. // 0(%rsp) now has the vno
  27. CMPW $SSEL(SiCS, SsTIGDT|SsRPL0), 24(%rsp) /* old CS */
  28. JE _acintrnested
  29. SWAPGS
  30. _acintrnested:
  31. PUSHQ %r15
  32. PUSHQ %r14
  33. PUSHQ %r13
  34. PUSHQ %r12
  35. PUSHQ %r11
  36. PUSHQ %r10
  37. PUSHQ %r9
  38. PUSHQ %r8
  39. PUSHQ %rBP
  40. PUSHQ %rDI
  41. PUSHQ %rSI
  42. PUSHQ %rDX
  43. PUSHQ %rCX
  44. PUSHQ %rbx
  45. PUSHQ %rax
  46. MOVQ %rsp, %rdi // it's ok, we saved %rdi.
  47. CALL _trap
  48. .globl _acintrr
  49. _acintrr:
  50. POPQ %rax
  51. POPQ %rbx
  52. POPQ %rCX
  53. POPQ %rDX
  54. POPQ %rSI
  55. POPQ %rDI
  56. POPQ %rBP
  57. POPQ %r8
  58. POPQ %r9
  59. POPQ %r10
  60. POPQ %r11
  61. POPQ %r12
  62. POPQ %r13
  63. POPQ %r14
  64. POPQ %r15
  65. CMPW $SSEL(SiCS, SsTIGDT|SsRPL0), 24(%rsp) /* old CS */
  66. JE _aciretnested
  67. SWAPGS
  68. _aciretnested:
  69. // Throw away:
  70. // The %rax you pushed (error code)
  71. // EIP from the vector table.
  72. ADDQ $16, %rsp
  73. iretq
  74. .globl acidthandlers
  75. acidthandlers:
  76. CALL _acintrp; .byte IdtDE /* #DE Divide-by-Zero Error */
  77. CALL _acintrp; .byte IdtDB /* #DB Debug */
  78. CALL _acintrp; .byte IdtNMI /* #NMI Borked */
  79. CALL _acintrp; .byte IdtBP /* #BP Breakpoint */
  80. CALL _acintrp; .byte IdtOF /* #OF Overflow */
  81. CALL _acintrp; .byte IdtBR /* #BR Bound-Range */
  82. CALL _acintrp; .byte IdtUD /* #UD Invalid-Opcode */
  83. CALL _acintrp; .byte IdtNM /* #NM Device-Not-Available */
  84. CALL _acintre; .byte IdtDF /* #DF Double-Fault */
  85. CALL _acintrp; .byte Idt09 /* reserved */
  86. CALL _acintre; .byte IdtTS /* #TS Invalid-TSS */
  87. CALL _acintre; .byte IdtNP /* #NP Segment-Not-Present */
  88. CALL _acintre; .byte IdtSS /* #SS Stack */
  89. CALL _acintre; .byte IdtGP /* #GP General-Protection */
  90. CALL _acintre; .byte IdtPF /* #PF Page-Fault */
  91. CALL _acintrp; .byte Idt0F /* reserved */
  92. CALL _acintrp; .byte IdtMF /* #MF x87 FPE-Pending */
  93. CALL _acintre; .byte IdtAC /* #AC Alignment-Check */
  94. CALL _acintrp; .byte IdtMC /* #MC Machine-Check */
  95. CALL _acintrp; .byte IdtXF /* #XF SIMD Floating-Point */
  96. CALL _acintrp; .byte 0x14 /* reserved */
  97. CALL _acintrp; .byte 0x15 /* reserved */
  98. CALL _acintrp; .byte 0x16 /* reserved */
  99. CALL _acintrp; .byte 0x17 /* reserved */
  100. CALL _acintrp; .byte 0x18 /* reserved */
  101. CALL _acintrp; .byte 0x19 /* reserved */
  102. CALL _acintrp; .byte 0x1a /* reserved */
  103. CALL _acintrp; .byte 0x1b /* reserved */
  104. CALL _acintrp; .byte 0x1c /* reserved */
  105. CALL _acintrp; .byte 0x1d /* reserved */
  106. CALL _acintrp; .byte 0x1e /* reserved */
  107. CALL _acintrp; .byte 0x1f /* reserved */
  108. CALL _acintrp; .byte 0x20
  109. CALL _acintrp; .byte 0x21
  110. CALL _acintrp; .byte 0x22
  111. CALL _acintrp; .byte 0x23
  112. CALL _acintrp; .byte 0x24
  113. CALL _acintrp; .byte 0x25
  114. CALL _acintrp; .byte 0x26
  115. CALL _acintrp; .byte 0x27
  116. CALL _acintrp; .byte 0x28
  117. CALL _acintrp; .byte 0x29
  118. CALL _acintrp; .byte 0x2a
  119. CALL _acintrp; .byte 0x2b
  120. CALL _acintrp; .byte 0x2c
  121. CALL _acintrp; .byte 0x2d
  122. CALL _acintrp; .byte 0x2e
  123. CALL _acintrp; .byte 0x2f
  124. CALL _acintrp; .byte 0x30
  125. CALL _acintrp; .byte 0x31
  126. CALL _acintrp; .byte 0x32
  127. CALL _acintrp; .byte 0x33
  128. CALL _acintrp; .byte 0x34
  129. CALL _acintrp; .byte 0x35
  130. CALL _acintrp; .byte 0x36
  131. CALL _acintrp; .byte 0x37
  132. CALL _acintrp; .byte 0x38
  133. CALL _acintrp; .byte 0x39
  134. CALL _acintrp; .byte 0x3a
  135. CALL _acintrp; .byte 0x3b
  136. CALL _acintrp; .byte 0x3c
  137. CALL _acintrp; .byte 0x3d
  138. CALL _acintrp; .byte 0x3e
  139. CALL _acintrp; .byte 0x3f
  140. CALL _acintrp; .byte 0x40
  141. CALL _acintrp; .byte 0x41
  142. CALL _acintrp; .byte 0x42
  143. CALL _acintrp; .byte 0x43
  144. CALL _acintrp; .byte 0x44
  145. CALL _acintrp; .byte 0x45
  146. CALL _acintrp; .byte 0x46
  147. CALL _acintrp; .byte 0x47
  148. CALL _acintrp; .byte 0x48
  149. CALL _acintrp; .byte 0x49
  150. CALL _acintrp; .byte 0x4a
  151. CALL _acintrp; .byte 0x4b
  152. CALL _acintrp; .byte 0x4c
  153. CALL _acintrp; .byte 0x4d
  154. CALL _acintrp; .byte 0x4e
  155. CALL _acintrp; .byte 0x4f
  156. CALL _acintrp; .byte 0x50
  157. CALL _acintrp; .byte 0x51
  158. CALL _acintrp; .byte 0x52
  159. CALL _acintrp; .byte 0x53
  160. CALL _acintrp; .byte 0x54
  161. CALL _acintrp; .byte 0x55
  162. CALL _acintrp; .byte 0x56
  163. CALL _acintrp; .byte 0x57
  164. CALL _acintrp; .byte 0x58
  165. CALL _acintrp; .byte 0x59
  166. CALL _acintrp; .byte 0x5a
  167. CALL _acintrp; .byte 0x5b
  168. CALL _acintrp; .byte 0x5c
  169. CALL _acintrp; .byte 0x5d
  170. CALL _acintrp; .byte 0x5e
  171. CALL _acintrp; .byte 0x5f
  172. CALL _acintrp; .byte 0x60
  173. CALL _acintrp; .byte 0x61
  174. CALL _acintrp; .byte 0x62
  175. CALL _acintrp; .byte 0x63
  176. CALL _acintrp; .byte 0x64
  177. CALL _acintrp; .byte 0x65
  178. CALL _acintrp; .byte 0x66
  179. CALL _acintrp; .byte 0x67
  180. CALL _acintrp; .byte 0x68
  181. CALL _acintrp; .byte 0x69
  182. CALL _acintrp; .byte 0x6a
  183. CALL _acintrp; .byte 0x6b
  184. CALL _acintrp; .byte 0x6c
  185. CALL _acintrp; .byte 0x6d
  186. CALL _acintrp; .byte 0x6e
  187. CALL _acintrp; .byte 0x6f
  188. CALL _acintrp; .byte 0x70
  189. CALL _acintrp; .byte 0x71
  190. CALL _acintrp; .byte 0x72
  191. CALL _acintrp; .byte 0x73
  192. CALL _acintrp; .byte 0x74
  193. CALL _acintrp; .byte 0x75
  194. CALL _acintrp; .byte 0x76
  195. CALL _acintrp; .byte 0x77
  196. CALL _acintrp; .byte 0x78
  197. CALL _acintrp; .byte 0x79
  198. CALL _acintrp; .byte 0x7a
  199. CALL _acintrp; .byte 0x7b
  200. CALL _acintrp; .byte 0x7c
  201. CALL _acintrp; .byte 0x7d
  202. CALL _acintrp; .byte 0x7e
  203. CALL _acintrp; .byte 0x7f
  204. CALL _acintrp; .byte 0x80
  205. CALL _acintrp; .byte 0x81
  206. CALL _acintrp; .byte 0x82
  207. CALL _acintrp; .byte 0x83
  208. CALL _acintrp; .byte 0x84
  209. CALL _acintrp; .byte 0x85
  210. CALL _acintrp; .byte 0x86
  211. CALL _acintrp; .byte 0x87
  212. CALL _acintrp; .byte 0x88
  213. CALL _acintrp; .byte 0x89
  214. CALL _acintrp; .byte 0x8a
  215. CALL _acintrp; .byte 0x8b
  216. CALL _acintrp; .byte 0x8c
  217. CALL _acintrp; .byte 0x8d
  218. CALL _acintrp; .byte 0x8e
  219. CALL _acintrp; .byte 0x8f
  220. CALL _acintrp; .byte 0x90
  221. CALL _acintrp; .byte 0x91
  222. CALL _acintrp; .byte 0x92
  223. CALL _acintrp; .byte 0x93
  224. CALL _acintrp; .byte 0x94
  225. CALL _acintrp; .byte 0x95
  226. CALL _acintrp; .byte 0x96
  227. CALL _acintrp; .byte 0x97
  228. CALL _acintrp; .byte 0x98
  229. CALL _acintrp; .byte 0x99
  230. CALL _acintrp; .byte 0x9a
  231. CALL _acintrp; .byte 0x9b
  232. CALL _acintrp; .byte 0x9c
  233. CALL _acintrp; .byte 0x9d
  234. CALL _acintrp; .byte 0x9e
  235. CALL _acintrp; .byte 0x9f
  236. CALL _acintrp; .byte 0xa0
  237. CALL _acintrp; .byte 0xa1
  238. CALL _acintrp; .byte 0xa2
  239. CALL _acintrp; .byte 0xa3
  240. CALL _acintrp; .byte 0xa4
  241. CALL _acintrp; .byte 0xa5
  242. CALL _acintrp; .byte 0xa6
  243. CALL _acintrp; .byte 0xa7
  244. CALL _acintrp; .byte 0xa8
  245. CALL _acintrp; .byte 0xa9
  246. CALL _acintrp; .byte 0xaa
  247. CALL _acintrp; .byte 0xab
  248. CALL _acintrp; .byte 0xac
  249. CALL _acintrp; .byte 0xad
  250. CALL _acintrp; .byte 0xae
  251. CALL _acintrp; .byte 0xaf
  252. CALL _acintrp; .byte 0xb0
  253. CALL _acintrp; .byte 0xb1
  254. CALL _acintrp; .byte 0xb2
  255. CALL _acintrp; .byte 0xb3
  256. CALL _acintrp; .byte 0xb4
  257. CALL _acintrp; .byte 0xb5
  258. CALL _acintrp; .byte 0xb6
  259. CALL _acintrp; .byte 0xb7
  260. CALL _acintrp; .byte 0xb8
  261. CALL _acintrp; .byte 0xb9
  262. CALL _acintrp; .byte 0xba
  263. CALL _acintrp; .byte 0xbb
  264. CALL _acintrp; .byte 0xbc
  265. CALL _acintrp; .byte 0xbd
  266. CALL _acintrp; .byte 0xbe
  267. CALL _acintrp; .byte 0xbf
  268. CALL _acintrp; .byte 0xc0
  269. CALL _acintrp; .byte 0xc1
  270. CALL _acintrp; .byte 0xc2
  271. CALL _acintrp; .byte 0xc3
  272. CALL _acintrp; .byte 0xc4
  273. CALL _acintrp; .byte 0xc5
  274. CALL _acintrp; .byte 0xc6
  275. CALL _acintrp; .byte 0xc7
  276. CALL _acintrp; .byte 0xc8
  277. CALL _acintrp; .byte 0xc9
  278. CALL _acintrp; .byte 0xca
  279. CALL _acintrp; .byte 0xcb
  280. CALL _acintrp; .byte 0xcc
  281. CALL _acintrp; .byte 0xce
  282. CALL _acintrp; .byte 0xce
  283. CALL _acintrp; .byte 0xcf
  284. CALL _acintrp; .byte 0xd0
  285. CALL _acintrp; .byte 0xd1
  286. CALL _acintrp; .byte 0xd2
  287. CALL _acintrp; .byte 0xd3
  288. CALL _acintrp; .byte 0xd4
  289. CALL _acintrp; .byte 0xd5
  290. CALL _acintrp; .byte 0xd6
  291. CALL _acintrp; .byte 0xd7
  292. CALL _acintrp; .byte 0xd8
  293. CALL _acintrp; .byte 0xd9
  294. CALL _acintrp; .byte 0xda
  295. CALL _acintrp; .byte 0xdb
  296. CALL _acintrp; .byte 0xdc
  297. CALL _acintrp; .byte 0xdd
  298. CALL _acintrp; .byte 0xde
  299. CALL _acintrp; .byte 0xdf
  300. CALL _acintrp; .byte 0xe0
  301. CALL _acintrp; .byte 0xe1
  302. CALL _acintrp; .byte 0xe2
  303. CALL _acintrp; .byte 0xe3
  304. CALL _acintrp; .byte 0xe4
  305. CALL _acintrp; .byte 0xe5
  306. CALL _acintrp; .byte 0xe6
  307. CALL _acintrp; .byte 0xe7
  308. CALL _acintrp; .byte 0xe8
  309. CALL _acintrp; .byte 0xe9
  310. CALL _acintrp; .byte 0xea
  311. CALL _acintrp; .byte 0xeb
  312. CALL _acintrp; .byte 0xec
  313. CALL _acintrp; .byte 0xed
  314. CALL _acintrp; .byte 0xee
  315. CALL _acintrp; .byte 0xef
  316. CALL _acintrp; .byte 0xf0
  317. CALL _acintrp; .byte 0xf1
  318. CALL _acintrp; .byte 0xf2
  319. CALL _acintrp; .byte 0xf3
  320. CALL _acintrp; .byte 0xf4
  321. CALL _acintrp; .byte 0xf5
  322. CALL _acintrp; .byte 0xf6
  323. CALL _acintrp; .byte 0xf7
  324. CALL _acintrp; .byte 0xf8
  325. CALL _acintrp; .byte 0xf9
  326. CALL _acintrp; .byte 0xfa
  327. CALL _acintrp; .byte 0xfb
  328. CALL _acintrp; .byte 0xfc
  329. CALL _acintrp; .byte 0xfd
  330. CALL _acintrp; .byte 0xfe
  331. CALL _acintrp; .byte 0xff