hw_exception_handler.S 34 KB

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