excALib.s
上传用户:nvosite88
上传日期:2007-01-17
资源大小:4983k
文件大小:13k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* excALib.s - exception handling I80x86 assembly routines */
  2. /* Copyright 1984-2001 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01f,25sep01,hdn  called intEnt() in excIntStub() to support the interrupt stack
  7. 01e,23aug01,hdn  added FUNC/FUNC_LABEL, replaced .align with .balign
  8.  added "error" parameter for exc{Exc,Int}Handle.
  9. 01d,26sep95,hdn  fixed a bug by incrementing _intCnt in excIntStub.
  10. 01c,04jun93,hdn  updated to 5.1
  11.   -overhauled
  12.   -fixed #else and #endif
  13.   -changed ASMLANGUAGE to _ASMLANGUAGE
  14.   -changed copyright notice
  15. 01b,13oct92,hdn  debugged.
  16. 01a,28feb92,hdn  written based on TRON, 68k version.
  17. */
  18. /*
  19. DESCRIPTION
  20. This module contains the assembly language exception handling stub.
  21. It is connected directly to the 80x86 exception vectors.
  22. It sets up an appropriate environment and then calls a routine
  23. in excLib(1).
  24. .ne 26
  25. EXCEPTION STACK FRAME GROWTH
  26. .CS
  27.    Exception/Trap               Interrupt
  28.                                      -----------------------
  29.                                       vector-number
  30.   sp_5 -----------------------       -----------------------
  31. vector-number                 sp_1(pointer to ESFn) 
  32.   sp_4 -----------------------       -----------------------
  33.         sp_1(pointer to ESFn)         sp_2(pointer to REGS)
  34.   sp_3 -----------------------       -----------------------
  35.         sp_2(pointer to REGS)         errno
  36.   sp_2 -----------------------       -----------------------
  37.         edi                           edi
  38.          |                             |
  39.         eax                           eax
  40. eflags                        eflags
  41. pc / return-address           pc / return-address
  42.   sp_1 -----------------------       -----------------------
  43.         EIP        ERROR              EIP
  44.   0x04 ---------  ---------          -----------------------
  45.         CS         EIP                CS
  46.   0x08 ---------  ---------          ---------
  47.         EFLAGS     CS                 EFLAGS
  48.   0x0c ---------  ---------          ---------
  49.                    EFLAGS  
  50.   0x10            ---------
  51.         ESF0   or   ESF1              ESF0
  52. .CE
  53. SEE ALSO: excLib(1)
  54. */
  55. #define _ASMLANGUAGE
  56. #include "vxWorks.h"
  57. #include "asm.h"
  58. #include "esf.h"
  59. #include "iv.h"
  60. .data
  61. .globl FUNC(copyright_wind_river)
  62. .long FUNC(copyright_wind_river)
  63.         /* externals */
  64. .globl FUNC(windExit)     /* kernel exit routine */
  65. .globl FUNC(intEnt)     /* interrupt enter routine */
  66. .globl FUNC(intExit)     /* interrupt exit routine */
  67. /* internals */
  68. .globl GTEXT(excCallTbl)   /* call-table */
  69. .globl GTEXT(excStub)     /* uninitialized exception handler */
  70. .globl GTEXT(excIntStub)   /* uninitialized interrupt handler */
  71. .text
  72. .balign 16
  73. /**************************************************************************
  74. *
  75. * excCallTbl - table of Calls
  76. *
  77. * NOMANUAL
  78. */
  79. FUNC_LABEL(excCallTbl)
  80. call FUNC(excStub) /* 0x00 */ /* divide error */
  81. call FUNC(excStub) /* debug */
  82. call FUNC(excStub) /* non-maskable interrupt */
  83. call FUNC(excStub) /* breakpoint */
  84. call FUNC(excStub) /* overflow */
  85. call FUNC(excStub) /* bound */
  86. call FUNC(excStub) /* invalid opcode */
  87. call FUNC(excStub) /* device not available */
  88. call FUNC(excStub) /* double fault */
  89. call FUNC(excStub) /* co-processor overrun */
  90. call FUNC(excStub) /* invalid TSS */
  91. call FUNC(excStub) /* segment not present */
  92. call FUNC(excStub) /* stack fault */
  93. call FUNC(excStub) /* general protection fault */
  94. call FUNC(excStub) /* page fault */
  95. call FUNC(excStub) /* reserved */
  96. call FUNC(excStub) /* 0x10 */ /* co-processor error */
  97. call FUNC(excStub)  /* alignment check */
  98. call FUNC(excStub)  /* machine check */
  99. call FUNC(excStub)  /* streaming SIMD */
  100. call FUNC(excStub)  /* unassigned reserved */
  101. call FUNC(excStub)  /* unassigned reserved */
  102. call FUNC(excStub)  /* unassigned reserved */
  103. call FUNC(excStub)  /* unassigned reserved */
  104. call FUNC(excStub) /* unassigned reserved */
  105. call FUNC(excStub) /* unassigned reserved */
  106. call FUNC(excStub) /* unassigned reserved */
  107. call FUNC(excStub) /* unassigned reserved */
  108. call FUNC(excStub) /* unassigned reserved */
  109. call FUNC(excStub) /* unassigned reserved */
  110. call FUNC(excStub) /* unassigned reserved */
  111. call FUNC(excStub) /* unassigned reserved */
  112. call FUNC(excIntStub) /* 0x20 */ /* User Interrupts */
  113. call FUNC(excIntStub)
  114. call FUNC(excIntStub)
  115. call FUNC(excIntStub)
  116. call FUNC(excIntStub)
  117. call FUNC(excIntStub)
  118. call FUNC(excIntStub)
  119. call FUNC(excIntStub)
  120. call FUNC(excIntStub)
  121. call FUNC(excIntStub)
  122. call FUNC(excIntStub)
  123. call FUNC(excIntStub)
  124. call FUNC(excIntStub)
  125. call FUNC(excIntStub)
  126. call FUNC(excIntStub)
  127. call FUNC(excIntStub)
  128. call FUNC(excIntStub) /* 0x30 */
  129. call FUNC(excIntStub)
  130. call FUNC(excIntStub)
  131. call FUNC(excIntStub)
  132. call FUNC(excIntStub)
  133. call FUNC(excIntStub)
  134. call FUNC(excIntStub)
  135. call FUNC(excIntStub)
  136. call FUNC(excIntStub)
  137. call FUNC(excIntStub)
  138. call FUNC(excIntStub)
  139. call FUNC(excIntStub)
  140. call FUNC(excIntStub)
  141. call FUNC(excIntStub)
  142. call FUNC(excIntStub)
  143. call FUNC(excIntStub)
  144. call FUNC(excIntStub) /* 0x40 */
  145. call FUNC(excIntStub)
  146. call FUNC(excIntStub)
  147. call FUNC(excIntStub)
  148. call FUNC(excIntStub)
  149. call FUNC(excIntStub)
  150. call FUNC(excIntStub)
  151. call FUNC(excIntStub)
  152. call FUNC(excIntStub)
  153. call FUNC(excIntStub)
  154. call FUNC(excIntStub)
  155. call FUNC(excIntStub)
  156. call FUNC(excIntStub)
  157. call FUNC(excIntStub)
  158. call FUNC(excIntStub)
  159. call FUNC(excIntStub)
  160. call FUNC(excIntStub) /* 0x50 */
  161. call FUNC(excIntStub)
  162. call FUNC(excIntStub)
  163. call FUNC(excIntStub)
  164. call FUNC(excIntStub)
  165. call FUNC(excIntStub)
  166. call FUNC(excIntStub)
  167. call FUNC(excIntStub)
  168. call FUNC(excIntStub)
  169. call FUNC(excIntStub)
  170. call FUNC(excIntStub)
  171. call FUNC(excIntStub)
  172. call FUNC(excIntStub)
  173. call FUNC(excIntStub)
  174. call FUNC(excIntStub)
  175. call FUNC(excIntStub)
  176. call FUNC(excIntStub) /* 0x60 */
  177. call FUNC(excIntStub)
  178. call FUNC(excIntStub)
  179. call FUNC(excIntStub)
  180. call FUNC(excIntStub)
  181. call FUNC(excIntStub)
  182. call FUNC(excIntStub)
  183. call FUNC(excIntStub)
  184. call FUNC(excIntStub)
  185. call FUNC(excIntStub)
  186. call FUNC(excIntStub)
  187. call FUNC(excIntStub)
  188. call FUNC(excIntStub)
  189. call FUNC(excIntStub)
  190. call FUNC(excIntStub)
  191. call FUNC(excIntStub)
  192. call FUNC(excIntStub) /* 0x70 */
  193. call FUNC(excIntStub)
  194. call FUNC(excIntStub)
  195. call FUNC(excIntStub)
  196. call FUNC(excIntStub)
  197. call FUNC(excIntStub)
  198. call FUNC(excIntStub)
  199. call FUNC(excIntStub)
  200. call FUNC(excIntStub)
  201. call FUNC(excIntStub)
  202. call FUNC(excIntStub)
  203. call FUNC(excIntStub)
  204. call FUNC(excIntStub)
  205. call FUNC(excIntStub)
  206. call FUNC(excIntStub)
  207. call FUNC(excIntStub)
  208. call FUNC(excIntStub) /* 0x80 */
  209. call FUNC(excIntStub)
  210. call FUNC(excIntStub)
  211. call FUNC(excIntStub)
  212. call FUNC(excIntStub)
  213. call FUNC(excIntStub)
  214. call FUNC(excIntStub)
  215. call FUNC(excIntStub)
  216. call FUNC(excIntStub)
  217. call FUNC(excIntStub)
  218. call FUNC(excIntStub)
  219. call FUNC(excIntStub)
  220. call FUNC(excIntStub)
  221. call FUNC(excIntStub)
  222. call FUNC(excIntStub)
  223. call FUNC(excIntStub)
  224. call FUNC(excIntStub) /* 0x90 */
  225. call FUNC(excIntStub)
  226. call FUNC(excIntStub)
  227. call FUNC(excIntStub)
  228. call FUNC(excIntStub)
  229. call FUNC(excIntStub)
  230. call FUNC(excIntStub)
  231. call FUNC(excIntStub)
  232. call FUNC(excIntStub)
  233. call FUNC(excIntStub)
  234. call FUNC(excIntStub)
  235. call FUNC(excIntStub)
  236. call FUNC(excIntStub)
  237. call FUNC(excIntStub)
  238. call FUNC(excIntStub)
  239. call FUNC(excIntStub)
  240. call FUNC(excIntStub) /* 0xa0 */
  241. call FUNC(excIntStub)
  242. call FUNC(excIntStub)
  243. call FUNC(excIntStub)
  244. call FUNC(excIntStub)
  245. call FUNC(excIntStub)
  246. call FUNC(excIntStub)
  247. call FUNC(excIntStub)
  248. call FUNC(excIntStub)
  249. call FUNC(excIntStub)
  250. call FUNC(excIntStub)
  251. call FUNC(excIntStub)
  252. call FUNC(excIntStub)
  253. call FUNC(excIntStub)
  254. call FUNC(excIntStub)
  255. call FUNC(excIntStub)
  256. call FUNC(excIntStub) /* 0xb0 */
  257. call FUNC(excIntStub)
  258. call FUNC(excIntStub)
  259. call FUNC(excIntStub)
  260. call FUNC(excIntStub)
  261. call FUNC(excIntStub)
  262. call FUNC(excIntStub)
  263. call FUNC(excIntStub)
  264. call FUNC(excIntStub)
  265. call FUNC(excIntStub)
  266. call FUNC(excIntStub)
  267. call FUNC(excIntStub)
  268. call FUNC(excIntStub)
  269. call FUNC(excIntStub)
  270. call FUNC(excIntStub)
  271. call FUNC(excIntStub)
  272. call FUNC(excIntStub) /* 0xc0 */
  273. call FUNC(excIntStub)
  274. call FUNC(excIntStub)
  275. call FUNC(excIntStub)
  276. call FUNC(excIntStub)
  277. call FUNC(excIntStub)
  278. call FUNC(excIntStub)
  279. call FUNC(excIntStub)
  280. call FUNC(excIntStub)
  281. call FUNC(excIntStub)
  282. call FUNC(excIntStub)
  283. call FUNC(excIntStub)
  284. call FUNC(excIntStub)
  285. call FUNC(excIntStub)
  286. call FUNC(excIntStub)
  287. call FUNC(excIntStub)
  288. call FUNC(excIntStub) /* 0xd0 */
  289. call FUNC(excIntStub)
  290. call FUNC(excIntStub)
  291. call FUNC(excIntStub)
  292. call FUNC(excIntStub)
  293. call FUNC(excIntStub)
  294. call FUNC(excIntStub)
  295. call FUNC(excIntStub)
  296. call FUNC(excIntStub)
  297. call FUNC(excIntStub)
  298. call FUNC(excIntStub)
  299. call FUNC(excIntStub)
  300. call FUNC(excIntStub)
  301. call FUNC(excIntStub)
  302. call FUNC(excIntStub)
  303. call FUNC(excIntStub)
  304. call FUNC(excIntStub) /* 0xe0 */
  305. call FUNC(excIntStub)
  306. call FUNC(excIntStub)
  307. call FUNC(excIntStub)
  308. call FUNC(excIntStub)
  309. call FUNC(excIntStub)
  310. call FUNC(excIntStub)
  311. call FUNC(excIntStub)
  312. call FUNC(excIntStub)
  313. call FUNC(excIntStub)
  314. call FUNC(excIntStub)
  315. call FUNC(excIntStub)
  316. call FUNC(excIntStub)
  317. call FUNC(excIntStub)
  318. call FUNC(excIntStub)
  319. call FUNC(excIntStub)
  320. call FUNC(excIntStub) /* 0xf0 */
  321. call FUNC(excIntStub)
  322. call FUNC(excIntStub)
  323. call FUNC(excIntStub)
  324. call FUNC(excIntStub)
  325. call FUNC(excIntStub)
  326. call FUNC(excIntStub)
  327. call FUNC(excIntStub)
  328. call FUNC(excIntStub)
  329. call FUNC(excIntStub)
  330. call FUNC(excIntStub)
  331. call FUNC(excIntStub)
  332. call FUNC(excIntStub)
  333. call FUNC(excIntStub)
  334. call FUNC(excIntStub)
  335. call FUNC(excIntStub)
  336. /*********************************************************************
  337. *
  338. * excStub - exception handler
  339. *
  340. * NOMANUAL
  341. */
  342. .balign 16,0x90
  343. FUNC_LABEL(excStub)
  344. pushfl /* save eflags */
  345. pushal /* save regs */
  346. movl %esp, %ebx /* save pointer to regs */
  347. /* compute vector offset from return address to Call in table */
  348. movl 0x24(%esp), %eax /* get Call return adrs */
  349. subl $4, %eax /* adjust return adrs to be Call adrs */
  350. subl $FUNC(excCallTbl), %eax /* get offset from start of Call table
  351.  * (= vector offset) */
  352. movl $5, %ecx /* turn vector offset into excep num */
  353. cltd
  354. idivl %ecx /* %eax has exception num */
  355. /* check whether the exception stack frame is ESF0 or ESF1 */
  356. cmpl $ IN_DOUBLE_FAULT, %eax
  357. jl excStub1 /* vecNum <   8 , it is ESF0 */
  358. cmpl $ IN_CP_OVERRUN, %eax
  359. je excStub1 /* vecNum ==  9 , it is ESF0 */
  360. cmpl $ IN_RESERVED, %eax
  361. je excStub1 /* vecNum == 15 , it is ESF0 */
  362. cmpl $ IN_CP_ERROR, %eax
  363. je excStub1 /* vecNum == 16 , it is ESF0 */
  364. cmpl $ IN_MACHINE_CHECK, %eax
  365. je excStub1 /* vecNum == 18 , it is ESF0 */
  366. cmpl $ IN_SIMD, %eax
  367. je excStub1 /* vecNum == 19 , it is ESF0 */
  368. /* exception stack frame is ESF1 which has error-code */
  369. movl 0x2c(%esp), %edx /* get pc from ESF */
  370. movl %edx, 0x24(%esp) /* replace a return addr by the pc */
  371. pushl $ TRUE /* push flag (ERROR code) */
  372. pushl %ebx /* push pointer to REG_SET */
  373. addl $0x28, %ebx
  374. pushl %ebx /* push pointer to ESF */
  375. pushl %eax /* push exception number */
  376. call FUNC(excExcHandle)
  377. addl $16, %esp /* clean up pushed arguments */
  378. popal /* restore regs */
  379. addl $12, %esp /* get pointer to ESF */
  380. iret /* retry the instruction */
  381. .balign 16,0x90
  382. excStub1:
  383. /* exception stack frame is ESF0 */
  384. movl 0x28(%esp), %edx /* get pc from ESF */
  385. movl %edx, 0x24(%esp) /* replace a return addr by the pc */
  386. pushl $ FALSE /* push flag (no ERROR code) */
  387. pushl %ebx /* push pointer to REG_SET */
  388. addl $0x28, %ebx
  389. pushl %ebx /* push pointer to ESF */
  390. pushl %eax /* push exception number */
  391. call FUNC(excExcHandle) /* do exception processing */
  392. addl $16, %esp /* clean up pushed arguments */
  393. popal /* restore regs */
  394. addl $8, %esp /* get pointer to ESF */
  395. iret /* retry the instruction */
  396. /*********************************************************************
  397. *
  398. * excIntStub - uninitialized interrupt handler
  399. *
  400. * NOMANUAL
  401. */
  402. .balign 16,0x90
  403. FUNC_LABEL(excIntStub)
  404. popl    %eax                    /* save the return address */
  405. call    FUNC(intEnt)            /* call intEnt */
  406. pushl   %eax                    /* push PC (return address) */
  407. /* create REG_SET on the stack for the Show routine */
  408. pushfl /* save EFLAGS */
  409. pushal /* save regs */
  410. movl %esp, %ebx /* save pointer to REG_SET */
  411. /* compute vector offset from return address to Call in table */
  412. movl 0x24(%esp), %eax /* get Call return adrs */
  413. subl $4, %eax /* adjust return adrs to be Call adrs */
  414. subl $FUNC(excCallTbl), %eax /* get offset from start of Call table
  415.  * (= vector offset) */
  416. movl $5, %ecx /* turn vector offset into excep num */
  417. cltd
  418. idivl %ecx /* %eax has exception num */
  419. /* exception stack frame is ESF0. offset = REG_SET(0x28) + errno(4) */
  420. movl 0x28+4(%esp), %edx /* get pc from ESF */
  421. movl %edx, 0x24(%esp) /* replace a return addr by the pc */
  422. pushl $ FALSE /* push flag (no ERROR code) */
  423. pushl %ebx /* push pointer to REG_SET */
  424. addl $0x28+4, %ebx /* get addr of ESF by adding the offset */
  425. pushl %ebx /* push pointer to ESF */
  426. pushl %eax /* push exception number */
  427. call FUNC(excIntHandle) /* do exception processing */
  428. addl $16, %esp /* clean up pushed arguments */
  429. popal /* restore regs */
  430. addl $8, %esp /* skip EFLAGS, PC to get addr of errno */
  431. jmp FUNC(intExit)