hw_exception_handler.S 33 KB

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