hw_exception_handler.S 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166
  1. /*
  2. * Exception handling for Microblaze
  3. *
  4. * Rewriten interrupt handling
  5. *
  6. * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu>
  7. * Copyright (C) 2008-2009 PetaLogix
  8. *
  9. * uClinux customisation (C) 2005 John Williams
  10. *
  11. * MMU code derived from arch/ppc/kernel/head_4xx.S:
  12. * Copyright (C) 1995-1996 Gary Thomas <gdt@linuxppc.org>
  13. * Initial PowerPC version.
  14. * Copyright (C) 1996 Cort Dougan <cort@cs.nmt.edu>
  15. * Rewritten for PReP
  16. * Copyright (C) 1996 Paul Mackerras <paulus@cs.anu.edu.au>
  17. * Low-level exception handers, MMU support, and rewrite.
  18. * Copyright (C) 1997 Dan Malek <dmalek@jlc.net>
  19. * PowerPC 8xx modifications.
  20. * Copyright (C) 1998-1999 TiVo, Inc.
  21. * PowerPC 403GCX modifications.
  22. * Copyright (C) 1999 Grant Erickson <grant@lcse.umn.edu>
  23. * PowerPC 403GCX/405GP modifications.
  24. * Copyright 2000 MontaVista Software Inc.
  25. * PPC405 modifications
  26. * PowerPC 403GCX/405GP modifications.
  27. * Author: MontaVista Software, Inc.
  28. * frank_rowand@mvista.com or source@mvista.com
  29. * debbie_chu@mvista.com
  30. *
  31. * Original code
  32. * Copyright (C) 2004 Xilinx, Inc.
  33. *
  34. * This program is free software; you can redistribute it and/or modify it
  35. * under the terms of the GNU General Public License version 2 as published
  36. * by the Free Software Foundation.
  37. */
  38. /*
  39. * Here are the handlers which don't require enabling translation
  40. * and calling other kernel code thus we can keep their design very simple
  41. * and do all processing in real mode. All what they need is a valid current
  42. * (that is an issue for the CONFIG_REGISTER_TASK_PTR case)
  43. * This handlers use r3,r4,r5,r6 and optionally r[current] to work therefore
  44. * these registers are saved/restored
  45. * The handlers which require translation are in entry.S --KAA
  46. *
  47. * Microblaze HW Exception Handler
  48. * - Non self-modifying exception handler for the following exception conditions
  49. * - Unalignment
  50. * - Instruction bus error
  51. * - Data bus error
  52. * - Illegal instruction opcode
  53. * - Divide-by-zero
  54. *
  55. * - Privileged instruction exception (MMU)
  56. * - Data storage exception (MMU)
  57. * - Instruction storage exception (MMU)
  58. * - Data TLB miss exception (MMU)
  59. * - Instruction TLB miss exception (MMU)
  60. *
  61. * Note we disable interrupts during exception handling, otherwise we will
  62. * possibly get multiple re-entrancy if interrupt handles themselves cause
  63. * exceptions. JW
  64. */
  65. #include <asm/exceptions.h>
  66. #include <asm/unistd.h>
  67. #include <asm/page.h>
  68. #include <asm/entry.h>
  69. #include <asm/current.h>
  70. #include <linux/linkage.h>
  71. #include <asm/mmu.h>
  72. #include <asm/pgtable.h>
  73. #include <asm/signal.h>
  74. #include <asm/asm-offsets.h>
  75. /* Helpful Macros */
  76. #define NUM_TO_REG(num) r ## num
  77. #ifdef CONFIG_MMU
  78. #define RESTORE_STATE \
  79. lwi r5, r1, 0; \
  80. mts rmsr, r5; \
  81. nop; \
  82. lwi r3, r1, PT_R3; \
  83. lwi r4, r1, PT_R4; \
  84. lwi r5, r1, PT_R5; \
  85. lwi r6, r1, PT_R6; \
  86. lwi r11, r1, PT_R11; \
  87. lwi r31, r1, PT_R31; \
  88. lwi r1, r0, TOPHYS(r0_ram + 0);
  89. #endif /* CONFIG_MMU */
  90. #define LWREG_NOP \
  91. bri ex_handler_unhandled; \
  92. nop;
  93. #define SWREG_NOP \
  94. bri ex_handler_unhandled; \
  95. nop;
  96. /* FIXME this is weird - for noMMU kernel is not possible to use brid
  97. * instruction which can shorten executed time
  98. */
  99. /* r3 is the source */
  100. #define R3_TO_LWREG_V(regnum) \
  101. swi r3, r1, 4 * regnum; \
  102. bri ex_handler_done;
  103. /* r3 is the source */
  104. #define R3_TO_LWREG(regnum) \
  105. or NUM_TO_REG (regnum), r0, r3; \
  106. bri ex_handler_done;
  107. /* r3 is the target */
  108. #define SWREG_TO_R3_V(regnum) \
  109. lwi r3, r1, 4 * regnum; \
  110. bri ex_sw_tail;
  111. /* r3 is the target */
  112. #define SWREG_TO_R3(regnum) \
  113. or r3, r0, NUM_TO_REG (regnum); \
  114. bri ex_sw_tail;
  115. #ifdef CONFIG_MMU
  116. #define R3_TO_LWREG_VM_V(regnum) \
  117. brid ex_lw_end_vm; \
  118. swi r3, r7, 4 * regnum;
  119. #define R3_TO_LWREG_VM(regnum) \
  120. brid ex_lw_end_vm; \
  121. or NUM_TO_REG (regnum), r0, r3;
  122. #define SWREG_TO_R3_VM_V(regnum) \
  123. brid ex_sw_tail_vm; \
  124. lwi r3, r7, 4 * regnum;
  125. #define SWREG_TO_R3_VM(regnum) \
  126. brid ex_sw_tail_vm; \
  127. or r3, r0, NUM_TO_REG (regnum);
  128. /* Shift right instruction depending on available configuration */
  129. #if CONFIG_XILINX_MICROBLAZE0_USE_BARREL > 0
  130. #define BSRLI(rD, rA, imm) \
  131. bsrli rD, rA, imm
  132. #else
  133. #define BSRLI(rD, rA, imm) BSRLI ## imm (rD, rA)
  134. /* Only the used shift constants defined here - add more if needed */
  135. #define BSRLI2(rD, rA) \
  136. srl rD, rA; /* << 1 */ \
  137. srl rD, rD; /* << 2 */
  138. #define BSRLI10(rD, rA) \
  139. srl rD, rA; /* << 1 */ \
  140. srl rD, rD; /* << 2 */ \
  141. srl rD, rD; /* << 3 */ \
  142. srl rD, rD; /* << 4 */ \
  143. srl rD, rD; /* << 5 */ \
  144. srl rD, rD; /* << 6 */ \
  145. srl rD, rD; /* << 7 */ \
  146. srl rD, rD; /* << 8 */ \
  147. srl rD, rD; /* << 9 */ \
  148. srl rD, rD /* << 10 */
  149. #define BSRLI20(rD, rA) \
  150. BSRLI10(rD, rA); \
  151. BSRLI10(rD, rD)
  152. #endif
  153. #endif /* CONFIG_MMU */
  154. .extern other_exception_handler /* Defined in exception.c */
  155. /*
  156. * hw_exception_handler - Handler for exceptions
  157. *
  158. * Exception handler notes:
  159. * - Handles all exceptions
  160. * - Does not handle unaligned exceptions during load into r17, r1, r0.
  161. * - Does not handle unaligned exceptions during store from r17 (cannot be
  162. * done) and r1 (slows down common case)
  163. *
  164. * Relevant register structures
  165. *
  166. * EAR - |----|----|----|----|----|----|----|----|
  167. * - < ## 32 bit faulting address ## >
  168. *
  169. * ESR - |----|----|----|----|----| - | - |-----|-----|
  170. * - W S REG EXC
  171. *
  172. *
  173. * STACK FRAME STRUCTURE (for NO_MMU)
  174. * ---------------------------------
  175. *
  176. * +-------------+ + 0
  177. * | MSR |
  178. * +-------------+ + 4
  179. * | r1 |
  180. * | . |
  181. * | . |
  182. * | . |
  183. * | . |
  184. * | r18 |
  185. * +-------------+ + 76
  186. * | . |
  187. * | . |
  188. *
  189. * NO_MMU kernel use the same r0_ram pointed space - look to vmlinux.lds.S
  190. * which is used for storing register values - old style was, that value were
  191. * stored in stack but in case of failure you lost information about register.
  192. * Currently you can see register value in memory in specific place.
  193. * In compare to with previous solution the speed should be the same.
  194. *
  195. * MMU exception handler has different handling compare to no MMU kernel.
  196. * Exception handler use jump table for directing of what happen. For MMU kernel
  197. * is this approach better because MMU relate exception are handled by asm code
  198. * in this file. In compare to with MMU expect of unaligned exception
  199. * is everything handled by C code.
  200. */
  201. /*
  202. * every of these handlers is entered having R3/4/5/6/11/current saved on stack
  203. * and clobbered so care should be taken to restore them if someone is going to
  204. * return from exception
  205. */
  206. /* wrappers to restore state before coming to entry.S */
  207. #ifdef CONFIG_MMU
  208. .section .rodata
  209. .align 4
  210. _MB_HW_ExceptionVectorTable:
  211. /* 0 - Undefined */
  212. .long TOPHYS(ex_handler_unhandled)
  213. /* 1 - Unaligned data access exception */
  214. .long TOPHYS(handle_unaligned_ex)
  215. /* 2 - Illegal op-code exception */
  216. .long TOPHYS(full_exception_trapw)
  217. /* 3 - Instruction bus error exception */
  218. .long TOPHYS(full_exception_trapw)
  219. /* 4 - Data bus error exception */
  220. .long TOPHYS(full_exception_trapw)
  221. /* 5 - Divide by zero exception */
  222. .long TOPHYS(full_exception_trapw)
  223. /* 6 - Floating point unit exception */
  224. .long TOPHYS(full_exception_trapw)
  225. /* 7 - Privileged instruction exception */
  226. .long TOPHYS(full_exception_trapw)
  227. /* 8 - 15 - Undefined */
  228. .long TOPHYS(ex_handler_unhandled)
  229. .long TOPHYS(ex_handler_unhandled)
  230. .long TOPHYS(ex_handler_unhandled)
  231. .long TOPHYS(ex_handler_unhandled)
  232. .long TOPHYS(ex_handler_unhandled)
  233. .long TOPHYS(ex_handler_unhandled)
  234. .long TOPHYS(ex_handler_unhandled)
  235. .long TOPHYS(ex_handler_unhandled)
  236. /* 16 - Data storage exception */
  237. .long TOPHYS(handle_data_storage_exception)
  238. /* 17 - Instruction storage exception */
  239. .long TOPHYS(handle_instruction_storage_exception)
  240. /* 18 - Data TLB miss exception */
  241. .long TOPHYS(handle_data_tlb_miss_exception)
  242. /* 19 - Instruction TLB miss exception */
  243. .long TOPHYS(handle_instruction_tlb_miss_exception)
  244. /* 20 - 31 - Undefined */
  245. .long TOPHYS(ex_handler_unhandled)
  246. .long TOPHYS(ex_handler_unhandled)
  247. .long TOPHYS(ex_handler_unhandled)
  248. .long TOPHYS(ex_handler_unhandled)
  249. .long TOPHYS(ex_handler_unhandled)
  250. .long TOPHYS(ex_handler_unhandled)
  251. .long TOPHYS(ex_handler_unhandled)
  252. .long TOPHYS(ex_handler_unhandled)
  253. .long TOPHYS(ex_handler_unhandled)
  254. .long TOPHYS(ex_handler_unhandled)
  255. .long TOPHYS(ex_handler_unhandled)
  256. .long TOPHYS(ex_handler_unhandled)
  257. #endif
  258. .global _hw_exception_handler
  259. .section .text
  260. .align 4
  261. .ent _hw_exception_handler
  262. _hw_exception_handler:
  263. #ifndef CONFIG_MMU
  264. addik r1, r1, -(EX_HANDLER_STACK_SIZ); /* Create stack frame */
  265. #else
  266. swi r1, r0, TOPHYS(r0_ram + 0); /* GET_SP */
  267. /* Save date to kernel memory. Here is the problem
  268. * when you came from user space */
  269. ori r1, r0, TOPHYS(r0_ram + 28);
  270. #endif
  271. swi r3, r1, PT_R3
  272. swi r4, r1, PT_R4
  273. swi r5, r1, PT_R5
  274. swi r6, r1, PT_R6
  275. #ifdef CONFIG_MMU
  276. swi r11, r1, PT_R11
  277. swi r31, r1, PT_R31
  278. lwi r31, r0, TOPHYS(PER_CPU(CURRENT_SAVE)) /* get saved current */
  279. #endif
  280. mfs r5, rmsr;
  281. nop
  282. swi r5, r1, 0;
  283. mfs r4, resr
  284. nop
  285. mfs r3, rear;
  286. nop
  287. #ifndef CONFIG_MMU
  288. andi r5, r4, 0x1000; /* Check ESR[DS] */
  289. beqi r5, not_in_delay_slot; /* Branch if ESR[DS] not set */
  290. mfs r17, rbtr; /* ESR[DS] set - return address in BTR */
  291. nop
  292. not_in_delay_slot:
  293. swi r17, r1, PT_R17
  294. #endif
  295. andi r5, r4, 0x1F; /* Extract ESR[EXC] */
  296. #ifdef CONFIG_MMU
  297. /* Calculate exception vector offset = r5 << 2 */
  298. addk r6, r5, r5; /* << 1 */
  299. addk r6, r6, r6; /* << 2 */
  300. #ifdef DEBUG
  301. /* counting which exception happen */
  302. lwi r5, r0, 0x200 + TOPHYS(r0_ram)
  303. addi r5, r5, 1
  304. swi r5, r0, 0x200 + TOPHYS(r0_ram)
  305. lwi r5, r6, 0x200 + TOPHYS(r0_ram)
  306. addi r5, r5, 1
  307. swi r5, r6, 0x200 + TOPHYS(r0_ram)
  308. #endif
  309. /* end */
  310. /* Load the HW Exception vector */
  311. lwi r6, r6, TOPHYS(_MB_HW_ExceptionVectorTable)
  312. bra r6
  313. full_exception_trapw:
  314. RESTORE_STATE
  315. bri full_exception_trap
  316. #else
  317. /* Exceptions enabled here. This will allow nested exceptions */
  318. mfs r6, rmsr;
  319. nop
  320. swi r6, r1, 0; /* RMSR_OFFSET */
  321. ori r6, r6, 0x100; /* Turn ON the EE bit */
  322. andi r6, r6, ~2; /* Disable interrupts */
  323. mts rmsr, r6;
  324. nop
  325. xori r6, r5, 1; /* 00001 = Unaligned Exception */
  326. /* Jump to unalignment exception handler */
  327. beqi r6, handle_unaligned_ex;
  328. handle_other_ex: /* Handle Other exceptions here */
  329. /* Save other volatiles before we make procedure calls below */
  330. swi r7, r1, PT_R7
  331. swi r8, r1, PT_R8
  332. swi r9, r1, PT_R9
  333. swi r10, r1, PT_R10
  334. swi r11, r1, PT_R11
  335. swi r12, r1, PT_R12
  336. swi r14, r1, PT_R14
  337. swi r15, r1, PT_R15
  338. swi r18, r1, PT_R18
  339. or r5, r1, r0
  340. andi r6, r4, 0x1F; /* Load ESR[EC] */
  341. lwi r7, r0, PER_CPU(KM) /* MS: saving current kernel mode to regs */
  342. swi r7, r1, PT_MODE
  343. mfs r7, rfsr
  344. nop
  345. addk r8, r17, r0; /* Load exception address */
  346. bralid r15, full_exception; /* Branch to the handler */
  347. nop;
  348. mts rfsr, r0; /* Clear sticky fsr */
  349. nop
  350. /*
  351. * Trigger execution of the signal handler by enabling
  352. * interrupts and calling an invalid syscall.
  353. */
  354. mfs r5, rmsr;
  355. nop
  356. ori r5, r5, 2;
  357. mts rmsr, r5; /* enable interrupt */
  358. nop
  359. addi r12, r0, __NR_syscalls;
  360. brki r14, 0x08;
  361. mfs r5, rmsr; /* disable interrupt */
  362. nop
  363. andi r5, r5, ~2;
  364. mts rmsr, r5;
  365. nop
  366. lwi r7, r1, PT_R7
  367. lwi r8, r1, PT_R8
  368. lwi r9, r1, PT_R9
  369. lwi r10, r1, PT_R10
  370. lwi r11, r1, PT_R11
  371. lwi r12, r1, PT_R12
  372. lwi r14, r1, PT_R14
  373. lwi r15, r1, PT_R15
  374. lwi r18, r1, PT_R18
  375. bri ex_handler_done; /* Complete exception handling */
  376. #endif
  377. /* 0x01 - Unaligned data access exception
  378. * This occurs when a word access is not aligned on a word boundary,
  379. * or when a 16-bit access is not aligned on a 16-bit boundary.
  380. * This handler perform the access, and returns, except for MMU when
  381. * the unaligned address is last on a 4k page or the physical address is
  382. * not found in the page table, in which case unaligned_data_trap is called.
  383. */
  384. handle_unaligned_ex:
  385. /* Working registers already saved: R3, R4, R5, R6
  386. * R4 = ESR
  387. * R3 = EAR
  388. */
  389. #ifdef CONFIG_MMU
  390. andi r6, r4, 0x1000 /* Check ESR[DS] */
  391. beqi r6, _no_delayslot /* Branch if ESR[DS] not set */
  392. mfs r17, rbtr; /* ESR[DS] set - return address in BTR */
  393. nop
  394. _no_delayslot:
  395. /* jump to high level unaligned handler */
  396. RESTORE_STATE;
  397. bri unaligned_data_trap
  398. #endif
  399. andi r6, r4, 0x3E0; /* Mask and extract the register operand */
  400. srl r6, r6; /* r6 >> 5 */
  401. srl r6, r6;
  402. srl r6, r6;
  403. srl r6, r6;
  404. srl r6, r6;
  405. /* Store the register operand in a temporary location */
  406. sbi r6, r0, TOPHYS(ex_reg_op);
  407. andi r6, r4, 0x400; /* Extract ESR[S] */
  408. bnei r6, ex_sw;
  409. ex_lw:
  410. andi r6, r4, 0x800; /* Extract ESR[W] */
  411. beqi r6, ex_lhw;
  412. lbui r5, r3, 0; /* Exception address in r3 */
  413. /* Load a word, byte-by-byte from destination address
  414. and save it in tmp space */
  415. sbi r5, r0, TOPHYS(ex_tmp_data_loc_0);
  416. lbui r5, r3, 1;
  417. sbi r5, r0, TOPHYS(ex_tmp_data_loc_1);
  418. lbui r5, r3, 2;
  419. sbi r5, r0, TOPHYS(ex_tmp_data_loc_2);
  420. lbui r5, r3, 3;
  421. sbi r5, r0, TOPHYS(ex_tmp_data_loc_3);
  422. /* Get the destination register value into r4 */
  423. lwi r4, r0, TOPHYS(ex_tmp_data_loc_0);
  424. bri ex_lw_tail;
  425. ex_lhw:
  426. lbui r5, r3, 0; /* Exception address in r3 */
  427. /* Load a half-word, byte-by-byte from destination
  428. address and save it in tmp space */
  429. sbi r5, r0, TOPHYS(ex_tmp_data_loc_0);
  430. lbui r5, r3, 1;
  431. sbi r5, r0, TOPHYS(ex_tmp_data_loc_1);
  432. /* Get the destination register value into r4 */
  433. lhui r4, r0, TOPHYS(ex_tmp_data_loc_0);
  434. ex_lw_tail:
  435. /* Get the destination register number into r5 */
  436. lbui r5, r0, TOPHYS(ex_reg_op);
  437. /* Form load_word jump table offset (lw_table + (8 * regnum)) */
  438. la r6, r0, TOPHYS(lw_table);
  439. addk r5, r5, r5;
  440. addk r5, r5, r5;
  441. addk r5, r5, r5;
  442. addk r5, r5, r6;
  443. bra r5;
  444. ex_lw_end: /* Exception handling of load word, ends */
  445. ex_sw:
  446. /* Get the destination register number into r5 */
  447. lbui r5, r0, TOPHYS(ex_reg_op);
  448. /* Form store_word jump table offset (sw_table + (8 * regnum)) */
  449. la r6, r0, TOPHYS(sw_table);
  450. add r5, r5, r5;
  451. add r5, r5, r5;
  452. add r5, r5, r5;
  453. add r5, r5, r6;
  454. bra r5;
  455. ex_sw_tail:
  456. mfs r6, resr;
  457. nop
  458. andi r6, r6, 0x800; /* Extract ESR[W] */
  459. beqi r6, ex_shw;
  460. /* Get the word - delay slot */
  461. swi r4, r0, TOPHYS(ex_tmp_data_loc_0);
  462. /* Store the word, byte-by-byte into destination address */
  463. lbui r4, r0, TOPHYS(ex_tmp_data_loc_0);
  464. sbi r4, r3, 0;
  465. lbui r4, r0, TOPHYS(ex_tmp_data_loc_1);
  466. sbi r4, r3, 1;
  467. lbui r4, r0, TOPHYS(ex_tmp_data_loc_2);
  468. sbi r4, r3, 2;
  469. lbui r4, r0, TOPHYS(ex_tmp_data_loc_3);
  470. sbi r4, r3, 3;
  471. bri ex_handler_done;
  472. ex_shw:
  473. /* Store the lower half-word, byte-by-byte into destination address */
  474. swi r4, r0, TOPHYS(ex_tmp_data_loc_0);
  475. lbui r4, r0, TOPHYS(ex_tmp_data_loc_2);
  476. sbi r4, r3, 0;
  477. lbui r4, r0, TOPHYS(ex_tmp_data_loc_3);
  478. sbi r4, r3, 1;
  479. ex_sw_end: /* Exception handling of store word, ends. */
  480. ex_handler_done:
  481. #ifndef CONFIG_MMU
  482. lwi r5, r1, 0 /* RMSR */
  483. mts rmsr, r5
  484. nop
  485. lwi r3, r1, PT_R3
  486. lwi r4, r1, PT_R4
  487. lwi r5, r1, PT_R5
  488. lwi r6, r1, PT_R6
  489. lwi r17, r1, PT_R17
  490. rted r17, 0
  491. addik r1, r1, (EX_HANDLER_STACK_SIZ); /* Restore stack frame */
  492. #else
  493. RESTORE_STATE;
  494. rted r17, 0
  495. nop
  496. #endif
  497. #ifdef CONFIG_MMU
  498. /* Exception vector entry code. This code runs with address translation
  499. * turned off (i.e. using physical addresses). */
  500. /* Exception vectors. */
  501. /* 0x10 - Data Storage Exception
  502. * This happens for just a few reasons. U0 set (but we don't do that),
  503. * or zone protection fault (user violation, write to protected page).
  504. * If this is just an update of modified status, we do that quickly
  505. * and exit. Otherwise, we call heavyweight functions to do the work.
  506. */
  507. handle_data_storage_exception:
  508. /* Working registers already saved: R3, R4, R5, R6
  509. * R3 = ESR
  510. */
  511. mfs r11, rpid
  512. nop
  513. /* If we are faulting a kernel address, we have to use the
  514. * kernel page tables.
  515. */
  516. ori r5, r0, CONFIG_KERNEL_START
  517. cmpu r5, r3, r5
  518. bgti r5, ex3
  519. /* First, check if it was a zone fault (which means a user
  520. * tried to access a kernel or read-protected page - always
  521. * a SEGV). All other faults here must be stores, so no
  522. * need to check ESR_S as well. */
  523. andi r4, r4, 0x800 /* ESR_Z - zone protection */
  524. bnei r4, ex2
  525. ori r4, r0, swapper_pg_dir
  526. mts rpid, r0 /* TLB will have 0 TID */
  527. nop
  528. bri ex4
  529. /* Get the PGD for the current thread. */
  530. ex3:
  531. /* First, check if it was a zone fault (which means a user
  532. * tried to access a kernel or read-protected page - always
  533. * a SEGV). All other faults here must be stores, so no
  534. * need to check ESR_S as well. */
  535. andi r4, r4, 0x800 /* ESR_Z */
  536. bnei r4, ex2
  537. /* get current task address */
  538. addi r4 ,CURRENT_TASK, TOPHYS(0);
  539. lwi r4, r4, TASK_THREAD+PGDIR
  540. ex4:
  541. tophys(r4,r4)
  542. BSRLI(r5,r3,20) /* Create L1 (pgdir/pmd) address */
  543. andi r5, r5, 0xffc
  544. /* Assume pgdir aligned on 4K boundary, no need for "andi r4,r4,0xfffff003" */
  545. or r4, r4, r5
  546. lwi r4, r4, 0 /* Get L1 entry */
  547. andi r5, r4, 0xfffff000 /* Extract L2 (pte) base address */
  548. beqi r5, ex2 /* Bail if no table */
  549. tophys(r5,r5)
  550. BSRLI(r6,r3,10) /* Compute PTE address */
  551. andi r6, r6, 0xffc
  552. andi r5, r5, 0xfffff003
  553. or r5, r5, r6
  554. lwi r4, r5, 0 /* Get Linux PTE */
  555. andi r6, r4, _PAGE_RW /* Is it writeable? */
  556. beqi r6, ex2 /* Bail if not */
  557. /* Update 'changed' */
  558. ori r4, r4, _PAGE_DIRTY|_PAGE_ACCESSED|_PAGE_HWWRITE
  559. swi r4, r5, 0 /* Update Linux page table */
  560. /* Most of the Linux PTE is ready to load into the TLB LO.
  561. * We set ZSEL, where only the LS-bit determines user access.
  562. * We set execute, because we don't have the granularity to
  563. * properly set this at the page level (Linux problem).
  564. * If shared is set, we cause a zero PID->TID load.
  565. * Many of these bits are software only. Bits we don't set
  566. * here we (properly should) assume have the appropriate value.
  567. */
  568. andni r4, r4, 0x0ce2 /* Make sure 20, 21 are zero */
  569. ori r4, r4, _PAGE_HWEXEC /* make it executable */
  570. /* find the TLB index that caused the fault. It has to be here*/
  571. mts rtlbsx, r3
  572. nop
  573. mfs r5, rtlbx /* DEBUG: TBD */
  574. nop
  575. mts rtlblo, r4 /* Load TLB LO */
  576. nop
  577. /* Will sync shadow TLBs */
  578. /* Done...restore registers and get out of here. */
  579. mts rpid, r11
  580. nop
  581. bri 4
  582. RESTORE_STATE;
  583. rted r17, 0
  584. nop
  585. ex2:
  586. /* The bailout. Restore registers to pre-exception conditions
  587. * and call the heavyweights to help us out. */
  588. mts rpid, r11
  589. nop
  590. bri 4
  591. RESTORE_STATE;
  592. bri page_fault_data_trap
  593. /* 0x11 - Instruction Storage Exception
  594. * This is caused by a fetch from non-execute or guarded pages. */
  595. handle_instruction_storage_exception:
  596. /* Working registers already saved: R3, R4, R5, R6
  597. * R3 = ESR
  598. */
  599. RESTORE_STATE;
  600. bri page_fault_instr_trap
  601. /* 0x12 - Data TLB Miss Exception
  602. * As the name implies, translation is not in the MMU, so search the
  603. * page tables and fix it. The only purpose of this function is to
  604. * load TLB entries from the page table if they exist.
  605. */
  606. handle_data_tlb_miss_exception:
  607. /* Working registers already saved: R3, R4, R5, R6
  608. * R3 = EAR, R4 = ESR
  609. */
  610. mfs r11, rpid
  611. nop
  612. /* If we are faulting a kernel address, we have to use the
  613. * kernel page tables. */
  614. ori r6, r0, CONFIG_KERNEL_START
  615. cmpu r4, r3, r6
  616. bgti r4, ex5
  617. ori r4, r0, swapper_pg_dir
  618. mts rpid, r0 /* TLB will have 0 TID */
  619. nop
  620. bri ex6
  621. /* Get the PGD for the current thread. */
  622. ex5:
  623. /* get current task address */
  624. addi r4 ,CURRENT_TASK, TOPHYS(0);
  625. lwi r4, r4, TASK_THREAD+PGDIR
  626. ex6:
  627. tophys(r4,r4)
  628. BSRLI(r5,r3,20) /* Create L1 (pgdir/pmd) address */
  629. andi r5, r5, 0xffc
  630. /* Assume pgdir aligned on 4K boundary, no need for "andi r4,r4,0xfffff003" */
  631. or r4, r4, r5
  632. lwi r4, r4, 0 /* Get L1 entry */
  633. andi r5, r4, 0xfffff000 /* Extract L2 (pte) base address */
  634. beqi r5, ex7 /* Bail if no table */
  635. tophys(r5,r5)
  636. BSRLI(r6,r3,10) /* Compute PTE address */
  637. andi r6, r6, 0xffc
  638. andi r5, r5, 0xfffff003
  639. or r5, r5, r6
  640. lwi r4, r5, 0 /* Get Linux PTE */
  641. andi r6, r4, _PAGE_PRESENT
  642. beqi r6, ex7
  643. ori r4, r4, _PAGE_ACCESSED
  644. swi r4, r5, 0
  645. /* Most of the Linux PTE is ready to load into the TLB LO.
  646. * We set ZSEL, where only the LS-bit determines user access.
  647. * We set execute, because we don't have the granularity to
  648. * properly set this at the page level (Linux problem).
  649. * If shared is set, we cause a zero PID->TID load.
  650. * Many of these bits are software only. Bits we don't set
  651. * here we (properly should) assume have the appropriate value.
  652. */
  653. brid finish_tlb_load
  654. andni r4, r4, 0x0ce2 /* Make sure 20, 21 are zero */
  655. ex7:
  656. /* The bailout. Restore registers to pre-exception conditions
  657. * and call the heavyweights to help us out.
  658. */
  659. mts rpid, r11
  660. nop
  661. bri 4
  662. RESTORE_STATE;
  663. bri page_fault_data_trap
  664. /* 0x13 - Instruction TLB Miss Exception
  665. * Nearly the same as above, except we get our information from
  666. * different registers and bailout to a different point.
  667. */
  668. handle_instruction_tlb_miss_exception:
  669. /* Working registers already saved: R3, R4, R5, R6
  670. * R3 = ESR
  671. */
  672. mfs r11, rpid
  673. nop
  674. /* If we are faulting a kernel address, we have to use the
  675. * kernel page tables.
  676. */
  677. ori r4, r0, CONFIG_KERNEL_START
  678. cmpu r4, r3, r4
  679. bgti r4, ex8
  680. ori r4, r0, swapper_pg_dir
  681. mts rpid, r0 /* TLB will have 0 TID */
  682. nop
  683. bri ex9
  684. /* Get the PGD for the current thread. */
  685. ex8:
  686. /* get current task address */
  687. addi r4 ,CURRENT_TASK, TOPHYS(0);
  688. lwi r4, r4, TASK_THREAD+PGDIR
  689. ex9:
  690. tophys(r4,r4)
  691. BSRLI(r5,r3,20) /* Create L1 (pgdir/pmd) address */
  692. andi r5, r5, 0xffc
  693. /* Assume pgdir aligned on 4K boundary, no need for "andi r4,r4,0xfffff003" */
  694. or r4, r4, r5
  695. lwi r4, r4, 0 /* Get L1 entry */
  696. andi r5, r4, 0xfffff000 /* Extract L2 (pte) base address */
  697. beqi r5, ex10 /* Bail if no table */
  698. tophys(r5,r5)
  699. BSRLI(r6,r3,10) /* Compute PTE address */
  700. andi r6, r6, 0xffc
  701. andi r5, r5, 0xfffff003
  702. or r5, r5, r6
  703. lwi r4, r5, 0 /* Get Linux PTE */
  704. andi r6, r4, _PAGE_PRESENT
  705. beqi r6, ex10
  706. ori r4, r4, _PAGE_ACCESSED
  707. swi r4, r5, 0
  708. /* Most of the Linux PTE is ready to load into the TLB LO.
  709. * We set ZSEL, where only the LS-bit determines user access.
  710. * We set execute, because we don't have the granularity to
  711. * properly set this at the page level (Linux problem).
  712. * If shared is set, we cause a zero PID->TID load.
  713. * Many of these bits are software only. Bits we don't set
  714. * here we (properly should) assume have the appropriate value.
  715. */
  716. brid finish_tlb_load
  717. andni r4, r4, 0x0ce2 /* Make sure 20, 21 are zero */
  718. ex10:
  719. /* The bailout. Restore registers to pre-exception conditions
  720. * and call the heavyweights to help us out.
  721. */
  722. mts rpid, r11
  723. nop
  724. bri 4
  725. RESTORE_STATE;
  726. bri page_fault_instr_trap
  727. /* Both the instruction and data TLB miss get to this point to load the TLB.
  728. * r3 - EA of fault
  729. * r4 - TLB LO (info from Linux PTE)
  730. * r5, r6 - available to use
  731. * PID - loaded with proper value when we get here
  732. * Upon exit, we reload everything and RFI.
  733. * A common place to load the TLB.
  734. */
  735. tlb_index:
  736. .long 1 /* MS: storing last used tlb index */
  737. finish_tlb_load:
  738. /* MS: load the last used TLB index. */
  739. lwi r5, r0, TOPHYS(tlb_index)
  740. addik r5, r5, 1 /* MS: inc tlb_index -> use next one */
  741. /* MS: FIXME this is potential fault, because this is mask not count */
  742. andi r5, r5, (MICROBLAZE_TLB_SIZE-1)
  743. ori r6, r0, 1
  744. cmp r31, r5, r6
  745. blti r31, ex12
  746. addik r5, r6, 1
  747. ex12:
  748. /* MS: save back current TLB index */
  749. swi r5, r0, TOPHYS(tlb_index)
  750. ori r4, r4, _PAGE_HWEXEC /* make it executable */
  751. mts rtlbx, r5 /* MS: save current TLB */
  752. nop
  753. mts rtlblo, r4 /* MS: save to TLB LO */
  754. nop
  755. /* Create EPN. This is the faulting address plus a static
  756. * set of bits. These are size, valid, E, U0, and ensure
  757. * bits 20 and 21 are zero.
  758. */
  759. andi r3, r3, 0xfffff000
  760. ori r3, r3, 0x0c0
  761. mts rtlbhi, r3 /* Load TLB HI */
  762. nop
  763. /* Done...restore registers and get out of here. */
  764. mts rpid, r11
  765. nop
  766. bri 4
  767. RESTORE_STATE;
  768. rted r17, 0
  769. nop
  770. /* extern void giveup_fpu(struct task_struct *prev)
  771. *
  772. * The MicroBlaze processor may have an FPU, so this should not just
  773. * return: TBD.
  774. */
  775. .globl giveup_fpu;
  776. .align 4;
  777. giveup_fpu:
  778. bralid r15,0 /* TBD */
  779. nop
  780. /* At present, this routine just hangs. - extern void abort(void) */
  781. .globl abort;
  782. .align 4;
  783. abort:
  784. br r0
  785. .globl set_context;
  786. .align 4;
  787. set_context:
  788. mts rpid, r5 /* Shadow TLBs are automatically */
  789. nop
  790. bri 4 /* flushed by changing PID */
  791. rtsd r15,8
  792. nop
  793. #endif
  794. .end _hw_exception_handler
  795. #ifdef CONFIG_MMU
  796. /* Unaligned data access exception last on a 4k page for MMU.
  797. * When this is called, we are in virtual mode with exceptions enabled
  798. * and registers 1-13,15,17,18 saved.
  799. *
  800. * R3 = ESR
  801. * R4 = EAR
  802. * R7 = pointer to saved registers (struct pt_regs *regs)
  803. *
  804. * This handler perform the access, and returns via ret_from_exc.
  805. */
  806. .global _unaligned_data_exception
  807. .ent _unaligned_data_exception
  808. _unaligned_data_exception:
  809. andi r8, r3, 0x3E0; /* Mask and extract the register operand */
  810. BSRLI(r8,r8,2); /* r8 >> 2 = register operand * 8 */
  811. andi r6, r3, 0x400; /* Extract ESR[S] */
  812. bneid r6, ex_sw_vm;
  813. andi r6, r3, 0x800; /* Extract ESR[W] - delay slot */
  814. ex_lw_vm:
  815. beqid r6, ex_lhw_vm;
  816. load1: lbui r5, r4, 0; /* Exception address in r4 - delay slot */
  817. /* Load a word, byte-by-byte from destination address and save it in tmp space*/
  818. la r6, r0, ex_tmp_data_loc_0;
  819. sbi r5, r6, 0;
  820. load2: lbui r5, r4, 1;
  821. sbi r5, r6, 1;
  822. load3: lbui r5, r4, 2;
  823. sbi r5, r6, 2;
  824. load4: lbui r5, r4, 3;
  825. sbi r5, r6, 3;
  826. brid ex_lw_tail_vm;
  827. /* Get the destination register value into r3 - delay slot */
  828. lwi r3, r6, 0;
  829. ex_lhw_vm:
  830. /* Load a half-word, byte-by-byte from destination address and
  831. * save it in tmp space */
  832. la r6, r0, ex_tmp_data_loc_0;
  833. sbi r5, r6, 0;
  834. load5: lbui r5, r4, 1;
  835. sbi r5, r6, 1;
  836. lhui r3, r6, 0; /* Get the destination register value into r3 */
  837. ex_lw_tail_vm:
  838. /* Form load_word jump table offset (lw_table_vm + (8 * regnum)) */
  839. addik r5, r8, lw_table_vm;
  840. bra r5;
  841. ex_lw_end_vm: /* Exception handling of load word, ends */
  842. brai ret_from_exc;
  843. ex_sw_vm:
  844. /* Form store_word jump table offset (sw_table_vm + (8 * regnum)) */
  845. addik r5, r8, sw_table_vm;
  846. bra r5;
  847. ex_sw_tail_vm:
  848. la r5, r0, ex_tmp_data_loc_0;
  849. beqid r6, ex_shw_vm;
  850. swi r3, r5, 0; /* Get the word - delay slot */
  851. /* Store the word, byte-by-byte into destination address */
  852. lbui r3, r5, 0;
  853. store1: sbi r3, r4, 0;
  854. lbui r3, r5, 1;
  855. store2: sbi r3, r4, 1;
  856. lbui r3, r5, 2;
  857. store3: sbi r3, r4, 2;
  858. lbui r3, r5, 3;
  859. brid ret_from_exc;
  860. store4: sbi r3, r4, 3; /* Delay slot */
  861. ex_shw_vm:
  862. /* Store the lower half-word, byte-by-byte into destination address */
  863. #ifdef __MICROBLAZEEL__
  864. lbui r3, r5, 0;
  865. store5: sbi r3, r4, 0;
  866. lbui r3, r5, 1;
  867. brid ret_from_exc;
  868. store6: sbi r3, r4, 1; /* Delay slot */
  869. #else
  870. lbui r3, r5, 2;
  871. store5: sbi r3, r4, 0;
  872. lbui r3, r5, 3;
  873. brid ret_from_exc;
  874. store6: sbi r3, r4, 1; /* Delay slot */
  875. #endif
  876. ex_sw_end_vm: /* Exception handling of store word, ends. */
  877. /* We have to prevent cases that get/put_user macros get unaligned pointer
  878. * to bad page area. We have to find out which origin instruction caused it
  879. * and called fixup for that origin instruction not instruction in unaligned
  880. * handler */
  881. ex_unaligned_fixup:
  882. ori r5, r7, 0 /* setup pointer to pt_regs */
  883. lwi r6, r7, PT_PC; /* faulting address is one instruction above */
  884. addik r6, r6, -4 /* for finding proper fixup */
  885. swi r6, r7, PT_PC; /* a save back it to PT_PC */
  886. addik r7, r0, SIGSEGV
  887. /* call bad_page_fault for finding aligned fixup, fixup address is saved
  888. * in PT_PC which is used as return address from exception */
  889. la r15, r0, ret_from_exc-8 /* setup return address */
  890. brid bad_page_fault
  891. nop
  892. /* We prevent all load/store because it could failed any attempt to access */
  893. .section __ex_table,"a";
  894. .word load1,ex_unaligned_fixup;
  895. .word load2,ex_unaligned_fixup;
  896. .word load3,ex_unaligned_fixup;
  897. .word load4,ex_unaligned_fixup;
  898. .word load5,ex_unaligned_fixup;
  899. .word store1,ex_unaligned_fixup;
  900. .word store2,ex_unaligned_fixup;
  901. .word store3,ex_unaligned_fixup;
  902. .word store4,ex_unaligned_fixup;
  903. .word store5,ex_unaligned_fixup;
  904. .word store6,ex_unaligned_fixup;
  905. .previous;
  906. .end _unaligned_data_exception
  907. #endif /* CONFIG_MMU */
  908. .global ex_handler_unhandled
  909. ex_handler_unhandled:
  910. /* FIXME add handle function for unhandled exception - dump register */
  911. bri 0
  912. /*
  913. * hw_exception_handler Jump Table
  914. * - Contains code snippets for each register that caused the unalign exception
  915. * - Hence exception handler is NOT self-modifying
  916. * - Separate table for load exceptions and store exceptions.
  917. * - Each table is of size: (8 * 32) = 256 bytes
  918. */
  919. .section .text
  920. .align 4
  921. lw_table:
  922. lw_r0: R3_TO_LWREG (0);
  923. lw_r1: LWREG_NOP;
  924. lw_r2: R3_TO_LWREG (2);
  925. lw_r3: R3_TO_LWREG_V (3);
  926. lw_r4: R3_TO_LWREG_V (4);
  927. lw_r5: R3_TO_LWREG_V (5);
  928. lw_r6: R3_TO_LWREG_V (6);
  929. lw_r7: R3_TO_LWREG (7);
  930. lw_r8: R3_TO_LWREG (8);
  931. lw_r9: R3_TO_LWREG (9);
  932. lw_r10: R3_TO_LWREG (10);
  933. lw_r11: R3_TO_LWREG (11);
  934. lw_r12: R3_TO_LWREG (12);
  935. lw_r13: R3_TO_LWREG (13);
  936. lw_r14: R3_TO_LWREG (14);
  937. lw_r15: R3_TO_LWREG (15);
  938. lw_r16: R3_TO_LWREG (16);
  939. lw_r17: LWREG_NOP;
  940. lw_r18: R3_TO_LWREG (18);
  941. lw_r19: R3_TO_LWREG (19);
  942. lw_r20: R3_TO_LWREG (20);
  943. lw_r21: R3_TO_LWREG (21);
  944. lw_r22: R3_TO_LWREG (22);
  945. lw_r23: R3_TO_LWREG (23);
  946. lw_r24: R3_TO_LWREG (24);
  947. lw_r25: R3_TO_LWREG (25);
  948. lw_r26: R3_TO_LWREG (26);
  949. lw_r27: R3_TO_LWREG (27);
  950. lw_r28: R3_TO_LWREG (28);
  951. lw_r29: R3_TO_LWREG (29);
  952. lw_r30: R3_TO_LWREG (30);
  953. #ifdef CONFIG_MMU
  954. lw_r31: R3_TO_LWREG_V (31);
  955. #else
  956. lw_r31: R3_TO_LWREG (31);
  957. #endif
  958. sw_table:
  959. sw_r0: SWREG_TO_R3 (0);
  960. sw_r1: SWREG_NOP;
  961. sw_r2: SWREG_TO_R3 (2);
  962. sw_r3: SWREG_TO_R3_V (3);
  963. sw_r4: SWREG_TO_R3_V (4);
  964. sw_r5: SWREG_TO_R3_V (5);
  965. sw_r6: SWREG_TO_R3_V (6);
  966. sw_r7: SWREG_TO_R3 (7);
  967. sw_r8: SWREG_TO_R3 (8);
  968. sw_r9: SWREG_TO_R3 (9);
  969. sw_r10: SWREG_TO_R3 (10);
  970. sw_r11: SWREG_TO_R3 (11);
  971. sw_r12: SWREG_TO_R3 (12);
  972. sw_r13: SWREG_TO_R3 (13);
  973. sw_r14: SWREG_TO_R3 (14);
  974. sw_r15: SWREG_TO_R3 (15);
  975. sw_r16: SWREG_TO_R3 (16);
  976. sw_r17: SWREG_NOP;
  977. sw_r18: SWREG_TO_R3 (18);
  978. sw_r19: SWREG_TO_R3 (19);
  979. sw_r20: SWREG_TO_R3 (20);
  980. sw_r21: SWREG_TO_R3 (21);
  981. sw_r22: SWREG_TO_R3 (22);
  982. sw_r23: SWREG_TO_R3 (23);
  983. sw_r24: SWREG_TO_R3 (24);
  984. sw_r25: SWREG_TO_R3 (25);
  985. sw_r26: SWREG_TO_R3 (26);
  986. sw_r27: SWREG_TO_R3 (27);
  987. sw_r28: SWREG_TO_R3 (28);
  988. sw_r29: SWREG_TO_R3 (29);
  989. sw_r30: SWREG_TO_R3 (30);
  990. #ifdef CONFIG_MMU
  991. sw_r31: SWREG_TO_R3_V (31);
  992. #else
  993. sw_r31: SWREG_TO_R3 (31);
  994. #endif
  995. #ifdef CONFIG_MMU
  996. lw_table_vm:
  997. lw_r0_vm: R3_TO_LWREG_VM (0);
  998. lw_r1_vm: R3_TO_LWREG_VM_V (1);
  999. lw_r2_vm: R3_TO_LWREG_VM_V (2);
  1000. lw_r3_vm: R3_TO_LWREG_VM_V (3);
  1001. lw_r4_vm: R3_TO_LWREG_VM_V (4);
  1002. lw_r5_vm: R3_TO_LWREG_VM_V (5);
  1003. lw_r6_vm: R3_TO_LWREG_VM_V (6);
  1004. lw_r7_vm: R3_TO_LWREG_VM_V (7);
  1005. lw_r8_vm: R3_TO_LWREG_VM_V (8);
  1006. lw_r9_vm: R3_TO_LWREG_VM_V (9);
  1007. lw_r10_vm: R3_TO_LWREG_VM_V (10);
  1008. lw_r11_vm: R3_TO_LWREG_VM_V (11);
  1009. lw_r12_vm: R3_TO_LWREG_VM_V (12);
  1010. lw_r13_vm: R3_TO_LWREG_VM_V (13);
  1011. lw_r14_vm: R3_TO_LWREG_VM (14);
  1012. lw_r15_vm: R3_TO_LWREG_VM_V (15);
  1013. lw_r16_vm: R3_TO_LWREG_VM (16);
  1014. lw_r17_vm: R3_TO_LWREG_VM_V (17);
  1015. lw_r18_vm: R3_TO_LWREG_VM_V (18);
  1016. lw_r19_vm: R3_TO_LWREG_VM (19);
  1017. lw_r20_vm: R3_TO_LWREG_VM (20);
  1018. lw_r21_vm: R3_TO_LWREG_VM (21);
  1019. lw_r22_vm: R3_TO_LWREG_VM (22);
  1020. lw_r23_vm: R3_TO_LWREG_VM (23);
  1021. lw_r24_vm: R3_TO_LWREG_VM (24);
  1022. lw_r25_vm: R3_TO_LWREG_VM (25);
  1023. lw_r26_vm: R3_TO_LWREG_VM (26);
  1024. lw_r27_vm: R3_TO_LWREG_VM (27);
  1025. lw_r28_vm: R3_TO_LWREG_VM (28);
  1026. lw_r29_vm: R3_TO_LWREG_VM (29);
  1027. lw_r30_vm: R3_TO_LWREG_VM (30);
  1028. lw_r31_vm: R3_TO_LWREG_VM_V (31);
  1029. sw_table_vm:
  1030. sw_r0_vm: SWREG_TO_R3_VM (0);
  1031. sw_r1_vm: SWREG_TO_R3_VM_V (1);
  1032. sw_r2_vm: SWREG_TO_R3_VM_V (2);
  1033. sw_r3_vm: SWREG_TO_R3_VM_V (3);
  1034. sw_r4_vm: SWREG_TO_R3_VM_V (4);
  1035. sw_r5_vm: SWREG_TO_R3_VM_V (5);
  1036. sw_r6_vm: SWREG_TO_R3_VM_V (6);
  1037. sw_r7_vm: SWREG_TO_R3_VM_V (7);
  1038. sw_r8_vm: SWREG_TO_R3_VM_V (8);
  1039. sw_r9_vm: SWREG_TO_R3_VM_V (9);
  1040. sw_r10_vm: SWREG_TO_R3_VM_V (10);
  1041. sw_r11_vm: SWREG_TO_R3_VM_V (11);
  1042. sw_r12_vm: SWREG_TO_R3_VM_V (12);
  1043. sw_r13_vm: SWREG_TO_R3_VM_V (13);
  1044. sw_r14_vm: SWREG_TO_R3_VM (14);
  1045. sw_r15_vm: SWREG_TO_R3_VM_V (15);
  1046. sw_r16_vm: SWREG_TO_R3_VM (16);
  1047. sw_r17_vm: SWREG_TO_R3_VM_V (17);
  1048. sw_r18_vm: SWREG_TO_R3_VM_V (18);
  1049. sw_r19_vm: SWREG_TO_R3_VM (19);
  1050. sw_r20_vm: SWREG_TO_R3_VM (20);
  1051. sw_r21_vm: SWREG_TO_R3_VM (21);
  1052. sw_r22_vm: SWREG_TO_R3_VM (22);
  1053. sw_r23_vm: SWREG_TO_R3_VM (23);
  1054. sw_r24_vm: SWREG_TO_R3_VM (24);
  1055. sw_r25_vm: SWREG_TO_R3_VM (25);
  1056. sw_r26_vm: SWREG_TO_R3_VM (26);
  1057. sw_r27_vm: SWREG_TO_R3_VM (27);
  1058. sw_r28_vm: SWREG_TO_R3_VM (28);
  1059. sw_r29_vm: SWREG_TO_R3_VM (29);
  1060. sw_r30_vm: SWREG_TO_R3_VM (30);
  1061. sw_r31_vm: SWREG_TO_R3_VM_V (31);
  1062. #endif /* CONFIG_MMU */
  1063. /* Temporary data structures used in the handler */
  1064. .section .data
  1065. .align 4
  1066. ex_tmp_data_loc_0:
  1067. .byte 0
  1068. ex_tmp_data_loc_1:
  1069. .byte 0
  1070. ex_tmp_data_loc_2:
  1071. .byte 0
  1072. ex_tmp_data_loc_3:
  1073. .byte 0
  1074. ex_reg_op:
  1075. .byte 0