hw_exception_handler.S 33 KB

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