2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * arch/sh64/kernel/entry.S
8 * Copyright (C) 2000, 2001 Paolo Alberelli
9 * Copyright (C) 2004, 2005 Paul Mundt
10 * Copyright (C) 2003, 2004 Richard Curnow
14 #include <linux/errno.h>
15 #include <linux/sys.h>
17 #include <asm/processor.h>
18 #include <asm/registers.h>
19 #include <asm/unistd.h>
20 #include <asm/thread_info.h>
21 #include <asm/asm-offsets.h>
26 #define SR_ASID_MASK 0x00ff0000
27 #define SR_FD_MASK 0x00008000
28 #define SR_SS 0x08000000
29 #define SR_BL 0x10000000
30 #define SR_MD 0x40000000
35 #define EVENT_INTERRUPT 0
36 #define EVENT_FAULT_TLB 1
37 #define EVENT_FAULT_NOT_TLB 2
41 #define RESET_CAUSE 0x20
42 #define DEBUGSS_CAUSE 0x980
45 * Frame layout. Quad index.
47 #define FRAME_T(x) FRAME_TBASE+(x*8)
48 #define FRAME_R(x) FRAME_RBASE+(x*8)
49 #define FRAME_S(x) FRAME_SBASE+(x*8)
54 /* Arrange the save frame to be a multiple of 32 bytes long */
56 #define FRAME_RBASE (FRAME_SBASE+(3*8)) /* SYSCALL_ID - SSR - SPC */
57 #define FRAME_TBASE (FRAME_RBASE+(63*8)) /* r0 - r62 */
58 #define FRAME_PBASE (FRAME_TBASE+(8*8)) /* tr0 -tr7 */
59 #define FRAME_SIZE (FRAME_PBASE+(2*8)) /* pad0-pad1 */
61 #define FP_FRAME_SIZE FP_FRAME_BASE+(33*8) /* dr0 - dr31 + fpscr */
62 #define FP_FRAME_BASE 0
72 /* These are the registers saved in the TLB path that aren't saved in the first
73 level of the normal one. */
74 #define TLB_SAVED_R25 7*8
75 #define TLB_SAVED_TR1 8*8
76 #define TLB_SAVED_TR2 9*8
77 #define TLB_SAVED_TR3 10*8
78 #define TLB_SAVED_TR4 11*8
79 /* Save R0/R1 : PT-migrating compiler currently dishounours -ffixed-r0 and -ffixed-r1 causing
80 breakage otherwise. */
81 #define TLB_SAVED_R0 12*8
82 #define TLB_SAVED_R1 13*8
95 # define preempt_stop() CLI()
97 # define preempt_stop()
98 # define resume_kernel restore_all
103 #define FAST_TLBMISS_STACK_CACHELINES 4
104 #define FAST_TLBMISS_STACK_QUADWORDS (4*FAST_TLBMISS_STACK_CACHELINES)
106 /* Register back-up area for all exceptions */
108 /* Allow for 16 quadwords to be pushed by fast tlbmiss handling
109 * register saves etc. */
110 .fill FAST_TLBMISS_STACK_QUADWORDS, 8, 0x0
111 /* This is 32 byte aligned by construction */
112 /* Register back-up area for all exceptions */
132 /* Save area for RESVEC exceptions. We cannot use reg_save_area because of
133 * reentrancy. Note this area may be accessed via physical address.
134 * Align so this fits a whole single cache line, for ease of purging.
145 /* Jump table of 3rd level handlers */
147 .long do_exception_error /* 0x000 */
148 .long do_exception_error /* 0x020 */
149 .long tlb_miss_load /* 0x040 */
150 .long tlb_miss_store /* 0x060 */
151 ! ARTIFICIAL pseudo-EXPEVT setting
152 .long do_debug_interrupt /* 0x080 */
153 .long tlb_miss_load /* 0x0A0 */
154 .long tlb_miss_store /* 0x0C0 */
155 .long do_address_error_load /* 0x0E0 */
156 .long do_address_error_store /* 0x100 */
158 .long do_fpu_error /* 0x120 */
160 .long do_exception_error /* 0x120 */
162 .long do_exception_error /* 0x140 */
163 .long system_call /* 0x160 */
164 .long do_reserved_inst /* 0x180 */
165 .long do_illegal_slot_inst /* 0x1A0 */
166 .long do_NMI /* 0x1C0 */
167 .long do_exception_error /* 0x1E0 */
169 .long do_IRQ /* 0x200 - 0x3C0 */
171 .long do_exception_error /* 0x3E0 */
173 .long do_IRQ /* 0x400 - 0x7E0 */
175 .long fpu_error_or_IRQA /* 0x800 */
176 .long fpu_error_or_IRQB /* 0x820 */
177 .long do_IRQ /* 0x840 */
178 .long do_IRQ /* 0x860 */
180 .long do_exception_error /* 0x880 - 0x920 */
182 .long do_software_break_point /* 0x940 */
183 .long do_exception_error /* 0x960 */
184 .long do_single_step /* 0x980 */
187 .long do_exception_error /* 0x9A0 - 0x9E0 */
189 .long do_IRQ /* 0xA00 */
190 .long do_IRQ /* 0xA20 */
191 .long itlb_miss_or_IRQ /* 0xA40 */
192 .long do_IRQ /* 0xA60 */
193 .long do_IRQ /* 0xA80 */
194 .long itlb_miss_or_IRQ /* 0xAA0 */
195 .long do_exception_error /* 0xAC0 */
196 .long do_address_error_exec /* 0xAE0 */
198 .long do_exception_error /* 0xB00 - 0xBE0 */
201 .long do_IRQ /* 0xC00 - 0xE20 */
204 .section .text64, "ax"
207 * --- Exception/Interrupt/Event Handling Section
211 * VBR and RESVEC blocks.
213 * First level handler for VBR-based exceptions.
215 * To avoid waste of space, align to the maximum text block size.
216 * This is assumed to be at most 128 bytes or 32 instructions.
217 * DO NOT EXCEED 32 instructions on the first level handlers !
219 * Also note that RESVEC is contained within the VBR block
220 * where the room left (1KB - TEXT_SIZE) allows placing
221 * the RESVEC block (at most 512B + TEXT_SIZE).
223 * So first (and only) level handler for RESVEC-based exceptions.
225 * Where the fault/interrupt is handled (not_a_tlb_miss, tlb_miss
226 * and interrupt) we are a lot tight with register space until
227 * saving onto the stack frame, which is done in handle_exception().
231 #define TEXT_SIZE 128
232 #define BLOCK_SIZE 1664 /* Dynamic check, 13*128 */
236 .space 256, 0 /* Power-on class handler, */
237 /* not required here */
239 synco /* TAKum03020 (but probably a good idea anyway.) */
240 /* Save original stack pointer into KCR1 */
243 /* Save other original registers into reg_save_area */
244 movi reg_save_area, SP
245 st.q SP, SAVED_R2, r2
246 st.q SP, SAVED_R3, r3
247 st.q SP, SAVED_R4, r4
248 st.q SP, SAVED_R5, r5
249 st.q SP, SAVED_R6, r6
250 st.q SP, SAVED_R18, r18
252 st.q SP, SAVED_TR0, r3
254 /* Set args for Non-debug, Not a TLB miss class handler */
256 movi ret_from_exception, r3
258 movi EVENT_FAULT_NOT_TLB, r4
261 pta handle_exception, tr0
272 * Instead of the natural .balign 1024 place RESVEC here
273 * respecting the final 1KB alignment.
277 * Instead of '.space 1024-TEXT_SIZE' place the RESVEC
278 * block making sure the final alignment is correct.
281 synco /* TAKum03020 (but probably a good idea anyway.) */
283 movi reg_save_area, SP
284 /* SP is guaranteed 32-byte aligned. */
285 st.q SP, TLB_SAVED_R0 , r0
286 st.q SP, TLB_SAVED_R1 , r1
287 st.q SP, SAVED_R2 , r2
288 st.q SP, SAVED_R3 , r3
289 st.q SP, SAVED_R4 , r4
290 st.q SP, SAVED_R5 , r5
291 st.q SP, SAVED_R6 , r6
292 st.q SP, SAVED_R18, r18
294 /* Save R25 for safety; as/ld may want to use it to achieve the call to
295 * the code in mm/tlbmiss.c */
296 st.q SP, TLB_SAVED_R25, r25
302 st.q SP, SAVED_TR0 , r2
303 st.q SP, TLB_SAVED_TR1 , r3
304 st.q SP, TLB_SAVED_TR2 , r4
305 st.q SP, TLB_SAVED_TR3 , r5
306 st.q SP, TLB_SAVED_TR4 , r18
308 pt do_fast_page_fault, tr0
313 andi r2, 1, r2 /* r2 = SSR.MD */
316 pt fixup_to_invoke_general_handler, tr1
318 /* If the fast path handler fixed the fault, just drop through quickly
319 to the restore code right away to return to the excepting context.
323 fast_tlb_miss_restore:
324 ld.q SP, SAVED_TR0, r2
325 ld.q SP, TLB_SAVED_TR1, r3
326 ld.q SP, TLB_SAVED_TR2, r4
328 ld.q SP, TLB_SAVED_TR3, r5
329 ld.q SP, TLB_SAVED_TR4, r18
337 ld.q SP, TLB_SAVED_R0, r0
338 ld.q SP, TLB_SAVED_R1, r1
339 ld.q SP, SAVED_R2, r2
340 ld.q SP, SAVED_R3, r3
341 ld.q SP, SAVED_R4, r4
342 ld.q SP, SAVED_R5, r5
343 ld.q SP, SAVED_R6, r6
344 ld.q SP, SAVED_R18, r18
345 ld.q SP, TLB_SAVED_R25, r25
349 nop /* for safety, in case the code is run on sh5-101 cut1.x */
351 fixup_to_invoke_general_handler:
353 /* OK, new method. Restore stuff that's not expected to get saved into
354 the 'first-level' reg save area, then just fall through to setting
355 up the registers and calling the second-level handler. */
357 /* 2nd level expects r2,3,4,5,6,18,tr0 to be saved. So we must restore
358 r25,tr1-4 and save r6 to get into the right state. */
360 ld.q SP, TLB_SAVED_TR1, r3
361 ld.q SP, TLB_SAVED_TR2, r4
362 ld.q SP, TLB_SAVED_TR3, r5
363 ld.q SP, TLB_SAVED_TR4, r18
364 ld.q SP, TLB_SAVED_R25, r25
366 ld.q SP, TLB_SAVED_R0, r0
367 ld.q SP, TLB_SAVED_R1, r1
374 /* Set args for Non-debug, TLB miss class handler */
376 movi ret_from_exception, r3
378 movi EVENT_FAULT_TLB, r4
381 pta handle_exception, tr0
384 /* NB TAKE GREAT CARE HERE TO ENSURE THAT THE INTERRUPT CODE
385 DOES END UP AT VBR+0x600 */
397 synco /* TAKum03020 (but probably a good idea anyway.) */
398 /* Save original stack pointer into KCR1 */
401 /* Save other original registers into reg_save_area */
402 movi reg_save_area, SP
403 st.q SP, SAVED_R2, r2
404 st.q SP, SAVED_R3, r3
405 st.q SP, SAVED_R4, r4
406 st.q SP, SAVED_R5, r5
407 st.q SP, SAVED_R6, r6
408 st.q SP, SAVED_R18, r18
410 st.q SP, SAVED_TR0, r3
412 /* Set args for interrupt class handler */
414 movi ret_from_irq, r3
416 movi EVENT_INTERRUPT, r4
419 pta handle_exception, tr0
421 .balign TEXT_SIZE /* let's waste the bare minimum */
423 LVBR_block_end: /* Marker. Used for total checking */
427 /* Panic handler. Called with MMU off. Possible causes/actions:
428 * - Reset: Jump to program start.
429 * - Single Step: Turn off Single Step & return.
430 * - Others: Call panic handler, passing PC as arg.
431 * (this may need to be extended...)
434 synco /* TAKum03020 (but probably a good idea anyway.) */
436 /* First save r0-1 and tr0, as we need to use these */
437 movi resvec_save_area-CONFIG_CACHED_MEMORY_OFFSET, SP
446 sub r1, r0, r1 /* r1=0 if reset */
447 movi _stext-CONFIG_CACHED_MEMORY_OFFSET, r0
450 beqi r1, 0, tr0 /* Jump to start address if reset */
453 movi DEBUGSS_CAUSE, r1
454 sub r1, r0, r1 /* r1=0 if single step */
455 pta single_step_panic, tr0
456 beqi r1, 0, tr0 /* jump if single step */
458 /* Now jump to where we save the registers. */
459 movi panic_stash_regs-CONFIG_CACHED_MEMORY_OFFSET, r1
464 /* We are in a handler with Single Step set. We need to resume the
465 * handler, by turning on MMU & turning off Single Step. */
472 /* Restore EXPEVT, as the rte won't do this */
487 synco /* TAKum03020 (but probably a good idea anyway.) */
489 * Single step/software_break_point first level handler.
490 * Called with MMU off, so the first thing we do is enable it
491 * by doing an rte with appropriate SSR.
494 /* Save SSR & SPC, together with R0 & R1, as we need to use 2 regs. */
495 movi resvec_save_area-CONFIG_CACHED_MEMORY_OFFSET, SP
497 /* With the MMU off, we are bypassing the cache, so purge any
498 * data that will be made stale by the following stores.
510 /* Enable MMU, block exceptions, set priv mode, disable single step */
511 movi SR_MMU | SR_BL | SR_MD, r1
516 /* Force control to debug_exception_2 when rte is executed */
517 movi debug_exeception_2, r0
518 ori r0, 1, r0 /* force SHmedia, just in case */
524 /* Restore saved regs */
526 movi resvec_save_area, SP
534 /* Save other original registers into reg_save_area */
535 movi reg_save_area, SP
536 st.q SP, SAVED_R2, r2
537 st.q SP, SAVED_R3, r3
538 st.q SP, SAVED_R4, r4
539 st.q SP, SAVED_R5, r5
540 st.q SP, SAVED_R6, r6
541 st.q SP, SAVED_R18, r18
543 st.q SP, SAVED_TR0, r3
545 /* Set args for debug class handler */
547 movi ret_from_exception, r3
552 pta handle_exception, tr0
557 /* !!! WE COME HERE IN REAL MODE !!! */
558 /* Hook-up debug interrupt to allow various debugging options to be
559 * hooked into its handler. */
560 /* Save original stack pointer into KCR1 */
563 movi resvec_save_area-CONFIG_CACHED_MEMORY_OFFSET, SP
568 /* Save other original registers into reg_save_area thru real addresses */
569 st.q SP, SAVED_R2, r2
570 st.q SP, SAVED_R3, r3
571 st.q SP, SAVED_R4, r4
572 st.q SP, SAVED_R5, r5
573 st.q SP, SAVED_R6, r6
574 st.q SP, SAVED_R18, r18
576 st.q SP, SAVED_TR0, r3
578 /* move (spc,ssr)->(pspc,pssr). The rte will shift
579 them back again, so that they look like the originals
580 as far as the real handler code is concerned. */
586 ! construct useful SR for handle_exception
593 ! SSR is now the current SR with the MD and MMU bits set
594 ! i.e. the rte will switch back to priv mode and put
598 movi handle_exception, r18
599 ori r18, 1, r18 ! for safety (do we need this?)
602 /* Set args for Non-debug, Not a TLB miss class handler */
604 ! EXPEVT==0x80 is unused, so 'steal' this value to put the
605 ! debug interrupt handler in the vectoring table
607 movi ret_from_exception, r3
609 movi EVENT_FAULT_NOT_TLB, r4
612 movi CONFIG_CACHED_MEMORY_OFFSET, r6
617 rte ! -> handle_exception, switch back to priv mode again
619 LRESVEC_block_end: /* Marker. Unused. */
624 * Second level handler for VBR-based exceptions. Pre-handler.
625 * In common to all stack-frame sensitive handlers.
628 * (KCR0) Current [current task union]
631 * (r3) appropriate return address
632 * (r4) Event (0 = interrupt, 1 = TLB miss fault, 2 = Not TLB miss fault, 3=debug)
633 * (r5) Pointer to reg_save_area
636 * Available registers:
643 /* Common 2nd level handler. */
645 /* First thing we need an appropriate stack pointer */
650 bne r6, ZERO, tr0 /* Original stack pointer is fine */
652 /* Set stack pointer for user fault */
654 movi THREAD_SIZE, r6 /* Point to the end */
659 /* DEBUG : check for underflow/overflow of the kernel stack */
660 pta no_underflow, tr0
664 bge SP, r6, tr0 ! ? below 1k from bottom of stack : danger zone
666 /* Just panic to cause a crash. */
674 movi THREAD_SIZE, r18
676 bgt SP, r6, tr0 ! sp above the stack
678 /* Make some room for the BASIC frame. */
679 movi -(FRAME_SIZE), r6
682 /* Could do this with no stalling if we had another spare register, but the
683 code below will be OK. */
684 ld.q r5, SAVED_R2, r6
685 ld.q r5, SAVED_R3, r18
686 st.q SP, FRAME_R(2), r6
687 ld.q r5, SAVED_R4, r6
688 st.q SP, FRAME_R(3), r18
689 ld.q r5, SAVED_R5, r18
690 st.q SP, FRAME_R(4), r6
691 ld.q r5, SAVED_R6, r6
692 st.q SP, FRAME_R(5), r18
693 ld.q r5, SAVED_R18, r18
694 st.q SP, FRAME_R(6), r6
695 ld.q r5, SAVED_TR0, r6
696 st.q SP, FRAME_R(18), r18
697 st.q SP, FRAME_T(0), r6
699 /* Keep old SP around */
702 /* Save the rest of the general purpose registers */
703 st.q SP, FRAME_R(0), r0
704 st.q SP, FRAME_R(1), r1
705 st.q SP, FRAME_R(7), r7
706 st.q SP, FRAME_R(8), r8
707 st.q SP, FRAME_R(9), r9
708 st.q SP, FRAME_R(10), r10
709 st.q SP, FRAME_R(11), r11
710 st.q SP, FRAME_R(12), r12
711 st.q SP, FRAME_R(13), r13
712 st.q SP, FRAME_R(14), r14
714 /* SP is somewhere else */
715 st.q SP, FRAME_R(15), r6
717 st.q SP, FRAME_R(16), r16
718 st.q SP, FRAME_R(17), r17
719 /* r18 is saved earlier. */
720 st.q SP, FRAME_R(19), r19
721 st.q SP, FRAME_R(20), r20
722 st.q SP, FRAME_R(21), r21
723 st.q SP, FRAME_R(22), r22
724 st.q SP, FRAME_R(23), r23
725 st.q SP, FRAME_R(24), r24
726 st.q SP, FRAME_R(25), r25
727 st.q SP, FRAME_R(26), r26
728 st.q SP, FRAME_R(27), r27
729 st.q SP, FRAME_R(28), r28
730 st.q SP, FRAME_R(29), r29
731 st.q SP, FRAME_R(30), r30
732 st.q SP, FRAME_R(31), r31
733 st.q SP, FRAME_R(32), r32
734 st.q SP, FRAME_R(33), r33
735 st.q SP, FRAME_R(34), r34
736 st.q SP, FRAME_R(35), r35
737 st.q SP, FRAME_R(36), r36
738 st.q SP, FRAME_R(37), r37
739 st.q SP, FRAME_R(38), r38
740 st.q SP, FRAME_R(39), r39
741 st.q SP, FRAME_R(40), r40
742 st.q SP, FRAME_R(41), r41
743 st.q SP, FRAME_R(42), r42
744 st.q SP, FRAME_R(43), r43
745 st.q SP, FRAME_R(44), r44
746 st.q SP, FRAME_R(45), r45
747 st.q SP, FRAME_R(46), r46
748 st.q SP, FRAME_R(47), r47
749 st.q SP, FRAME_R(48), r48
750 st.q SP, FRAME_R(49), r49
751 st.q SP, FRAME_R(50), r50
752 st.q SP, FRAME_R(51), r51
753 st.q SP, FRAME_R(52), r52
754 st.q SP, FRAME_R(53), r53
755 st.q SP, FRAME_R(54), r54
756 st.q SP, FRAME_R(55), r55
757 st.q SP, FRAME_R(56), r56
758 st.q SP, FRAME_R(57), r57
759 st.q SP, FRAME_R(58), r58
760 st.q SP, FRAME_R(59), r59
761 st.q SP, FRAME_R(60), r60
762 st.q SP, FRAME_R(61), r61
763 st.q SP, FRAME_R(62), r62
766 * Save the S* registers.
769 st.q SP, FRAME_S(FSSR), r61
771 st.q SP, FRAME_S(FSPC), r62
772 movi -1, r62 /* Reset syscall_nr */
773 st.q SP, FRAME_S(FSYSCALL_ID), r62
775 /* Save the rest of the target registers */
777 st.q SP, FRAME_T(1), r6
779 st.q SP, FRAME_T(2), r6
781 st.q SP, FRAME_T(3), r6
783 st.q SP, FRAME_T(4), r6
785 st.q SP, FRAME_T(5), r6
787 st.q SP, FRAME_T(6), r6
789 st.q SP, FRAME_T(7), r6
791 ! setup FP so that unwinder can wind back through nested kernel mode
795 #ifdef CONFIG_POOR_MANS_STRACE
796 /* We've pushed all the registers now, so only r2-r4 hold anything
797 * useful. Move them into callee save registers */
802 /* Preserve r2 as the event code */
816 /* For syscall and debug race condition, get TRA now */
819 /* We are in a safe position to turn SR.BL off, but set IMASK=0xf
820 * Also set FD, to catch FPU usage in the kernel.
822 * benedict.gaster@superh.com 29/07/2002
824 * On all SH5-101 revisions it is unsafe to raise the IMASK and at the
825 * same time change BL from 1->0, as any pending interrupt of a level
826 * higher than he previous value of IMASK will leak through and be
827 * taken unexpectedly.
829 * To avoid this we raise the IMASK and then issue another PUTCON to
833 movi SR_IMASK | SR_FD, r7
836 movi SR_UNBLOCK_EXC, r7
841 /* Now call the appropriate 3rd level handler */
852 * Second level handler for VBR-based exceptions. Post-handlers.
854 * Post-handlers for interrupts (ret_from_irq), exceptions
855 * (ret_from_exception) and common reentrance doors (restore_all
856 * to get back to the original context, ret_from_syscall loop to
857 * check kernel exiting).
859 * ret_with_reschedule and work_notifysig are an inner lables of
860 * the ret_from_syscall loop.
862 * In common to all stack-frame sensitive handlers.
865 * (SP) struct pt_regs *, original register's frame pointer (basic)
870 #ifdef CONFIG_POOR_MANS_STRACE
871 pta evt_debug_ret_from_irq, tr0
875 ld.q SP, FRAME_S(FSSR), r6
878 pta resume_kernel, tr0
879 bne r6, ZERO, tr0 /* no further checks */
881 pta ret_with_reschedule, tr0
882 blink tr0, ZERO /* Do not check softirqs */
884 .global ret_from_exception
888 #ifdef CONFIG_POOR_MANS_STRACE
889 pta evt_debug_ret_from_exc, tr0
894 ld.q SP, FRAME_S(FSSR), r6
897 pta resume_kernel, tr0
898 bne r6, ZERO, tr0 /* no further checks */
902 #ifdef CONFIG_PREEMPT
903 pta ret_from_syscall, tr0
910 ld.l r6, TI_PRE_COUNT, r7
914 ld.l r6, TI_FLAGS, r7
915 movi (1 << TIF_NEED_RESCHED), r8
923 movi ((PREEMPT_ACTIVE >> 16) & 65535), r8
924 shori (PREEMPT_ACTIVE & 65535), r8
925 st.l r6, TI_PRE_COUNT, r8
933 st.l r6, TI_PRE_COUNT, ZERO
936 pta need_resched, tr1
940 .global ret_from_syscall
944 getcon KCR0, r6 ! r6 contains current_thread_info
945 ld.l r6, TI_FLAGS, r7 ! r7 contains current_thread_info->flags
948 ! no handling of TIF_SYSCALL_TRACE yet!!
950 movi _TIF_NEED_RESCHED, r8
952 pta work_resched, tr0
957 movi (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK), r8
959 pta work_notifysig, tr0
965 pta ret_from_syscall, tr0
969 blink tr0, ZERO /* Call schedule(), return on top */
978 blink tr0, LINK /* Call do_signal(regs, 0), return here */
983 ld.q SP, FRAME_T(0), r6
984 ld.q SP, FRAME_T(1), r7
985 ld.q SP, FRAME_T(2), r8
986 ld.q SP, FRAME_T(3), r9
991 ld.q SP, FRAME_T(4), r6
992 ld.q SP, FRAME_T(5), r7
993 ld.q SP, FRAME_T(6), r8
994 ld.q SP, FRAME_T(7), r9
1000 ld.q SP, FRAME_R(0), r0
1001 ld.q SP, FRAME_R(1), r1
1002 ld.q SP, FRAME_R(2), r2
1003 ld.q SP, FRAME_R(3), r3
1004 ld.q SP, FRAME_R(4), r4
1005 ld.q SP, FRAME_R(5), r5
1006 ld.q SP, FRAME_R(6), r6
1007 ld.q SP, FRAME_R(7), r7
1008 ld.q SP, FRAME_R(8), r8
1009 ld.q SP, FRAME_R(9), r9
1010 ld.q SP, FRAME_R(10), r10
1011 ld.q SP, FRAME_R(11), r11
1012 ld.q SP, FRAME_R(12), r12
1013 ld.q SP, FRAME_R(13), r13
1014 ld.q SP, FRAME_R(14), r14
1016 ld.q SP, FRAME_R(16), r16
1017 ld.q SP, FRAME_R(17), r17
1018 ld.q SP, FRAME_R(18), r18
1019 ld.q SP, FRAME_R(19), r19
1020 ld.q SP, FRAME_R(20), r20
1021 ld.q SP, FRAME_R(21), r21
1022 ld.q SP, FRAME_R(22), r22
1023 ld.q SP, FRAME_R(23), r23
1024 ld.q SP, FRAME_R(24), r24
1025 ld.q SP, FRAME_R(25), r25
1026 ld.q SP, FRAME_R(26), r26
1027 ld.q SP, FRAME_R(27), r27
1028 ld.q SP, FRAME_R(28), r28
1029 ld.q SP, FRAME_R(29), r29
1030 ld.q SP, FRAME_R(30), r30
1031 ld.q SP, FRAME_R(31), r31
1032 ld.q SP, FRAME_R(32), r32
1033 ld.q SP, FRAME_R(33), r33
1034 ld.q SP, FRAME_R(34), r34
1035 ld.q SP, FRAME_R(35), r35
1036 ld.q SP, FRAME_R(36), r36
1037 ld.q SP, FRAME_R(37), r37
1038 ld.q SP, FRAME_R(38), r38
1039 ld.q SP, FRAME_R(39), r39
1040 ld.q SP, FRAME_R(40), r40
1041 ld.q SP, FRAME_R(41), r41
1042 ld.q SP, FRAME_R(42), r42
1043 ld.q SP, FRAME_R(43), r43
1044 ld.q SP, FRAME_R(44), r44
1045 ld.q SP, FRAME_R(45), r45
1046 ld.q SP, FRAME_R(46), r46
1047 ld.q SP, FRAME_R(47), r47
1048 ld.q SP, FRAME_R(48), r48
1049 ld.q SP, FRAME_R(49), r49
1050 ld.q SP, FRAME_R(50), r50
1051 ld.q SP, FRAME_R(51), r51
1052 ld.q SP, FRAME_R(52), r52
1053 ld.q SP, FRAME_R(53), r53
1054 ld.q SP, FRAME_R(54), r54
1055 ld.q SP, FRAME_R(55), r55
1056 ld.q SP, FRAME_R(56), r56
1057 ld.q SP, FRAME_R(57), r57
1058 ld.q SP, FRAME_R(58), r58
1061 movi SR_BLOCK_EXC, r60
1063 putcon r59, SR /* SR.BL = 1, keep nesting out */
1064 ld.q SP, FRAME_S(FSSR), r61
1065 ld.q SP, FRAME_S(FSPC), r62
1066 movi SR_ASID_MASK, r60
1068 andc r61, r60, r61 /* Clear out older ASID */
1069 or r59, r61, r61 /* Retain current ASID */
1073 /* Ignore FSYSCALL_ID */
1075 ld.q SP, FRAME_R(59), r59
1076 ld.q SP, FRAME_R(60), r60
1077 ld.q SP, FRAME_R(61), r61
1078 ld.q SP, FRAME_R(62), r62
1081 ld.q SP, FRAME_R(15), SP
1086 * Third level handlers for VBR-based exceptions. Adapting args to
1087 * and/or deflecting to fourth level handlers.
1089 * Fourth level handlers interface.
1090 * Most are C-coded handlers directly pointed by the trap_jtable.
1091 * (Third = Fourth level)
1093 * (r2) fault/interrupt code, entry number (e.g. NMI = 14,
1094 * IRL0-3 (0000) = 16, RTLBMISS = 2, SYSCALL = 11, etc ...)
1095 * (r3) struct pt_regs *, original register's frame pointer
1096 * (r4) Event (0 = interrupt, 1 = TLB miss fault, 2 = Not TLB miss fault)
1097 * (r5) TRA control register (for syscall/debug benefit only)
1098 * (LINK) return address
1101 * Kernel TLB fault handlers will get a slightly different interface.
1102 * (r2) struct pt_regs *, original register's frame pointer
1103 * (r3) writeaccess, whether it's a store fault as opposed to load fault
1104 * (r4) execaccess, whether it's a ITLB fault as opposed to DTLB fault
1105 * (r5) Effective Address of fault
1106 * (LINK) return address
1109 * fpu_error_or_IRQ? is a helper to deflect to the right cause.
1114 or ZERO, ZERO, r3 /* Read */
1115 or ZERO, ZERO, r4 /* Data */
1117 pta call_do_page_fault, tr0
1122 movi 1, r3 /* Write */
1123 or ZERO, ZERO, r4 /* Data */
1125 pta call_do_page_fault, tr0
1130 beqi/u r4, EVENT_INTERRUPT, tr0
1132 or ZERO, ZERO, r3 /* Read */
1133 movi 1, r4 /* Text */
1138 movi do_page_fault, r6
1144 beqi/l r4, EVENT_INTERRUPT, tr0
1145 #ifdef CONFIG_SH_FPU
1146 movi do_fpu_state_restore, r6
1148 movi do_exception_error, r6
1155 beqi/l r4, EVENT_INTERRUPT, tr0
1156 #ifdef CONFIG_SH_FPU
1157 movi do_fpu_state_restore, r6
1159 movi do_exception_error, r6
1170 * system_call/unknown_trap third level handler:
1173 * (r2) fault/interrupt code, entry number (TRAP = 11)
1174 * (r3) struct pt_regs *, original register's frame pointer
1175 * (r4) Not used. Event (0=interrupt, 1=TLB miss fault, 2=Not TLB miss fault)
1176 * (r5) TRA Control Reg (0x00xyzzzz: x=1 SYSCALL, y = #args, z=nr)
1178 * (LINK) return address: ret_from_exception
1179 * (*r3) Syscall parms: SC#, arg0, arg1, ..., arg5 in order (Saved r2/r7)
1182 * (*r3) Syscall reply (Saved r2)
1183 * (LINK) In case of syscall only it can be scrapped.
1184 * Common second level post handler will be ret_from_syscall.
1185 * Common (non-trace) exit point to that is syscall_ret (saving
1186 * result to r2). Common bad exit point is syscall_bad (returning
1187 * ENOSYS then saved to r2).
1192 /* Unknown Trap or User Trace */
1193 movi do_unknown_trapa, r6
1195 ld.q r3, FRAME_R(9), r2 /* r2 = #arg << 16 | syscall # */
1196 andi r2, 0x1ff, r2 /* r2 = syscall # */
1199 pta syscall_ret, tr0
1202 /* New syscall implementation*/
1204 pta unknown_trap, tr0
1205 or r5, ZERO, r4 /* TRA (=r5) -> r4 */
1207 bnei r4, 1, tr0 /* unknown_trap if not 0x1yzzzz */
1209 /* It's a system call */
1210 st.q r3, FRAME_S(FSYSCALL_ID), r5 /* ID (0x1yzzzz) -> stack */
1211 andi r5, 0x1ff, r5 /* syscall # -> r5 */
1215 pta syscall_allowed, tr0
1216 movi NR_syscalls - 1, r4 /* Last valid */
1220 /* Return ENOSYS ! */
1221 movi -(ENOSYS), r2 /* Fall-through */
1225 st.q SP, FRAME_R(9), r2 /* Expecting SP back to BASIC frame */
1227 #ifdef CONFIG_POOR_MANS_STRACE
1228 /* nothing useful in registers at this point */
1233 ld.q SP, FRAME_R(9), r2
1238 ld.q SP, FRAME_S(FSPC), r2
1239 addi r2, 4, r2 /* Move PC, being pre-execution event */
1240 st.q SP, FRAME_S(FSPC), r2
1241 pta ret_from_syscall, tr0
1245 /* A different return path for ret_from_fork, because we now need
1246 * to call schedule_tail with the later kernels. Because prev is
1247 * loaded into r2 by switch_to() means we can just call it straight away
1250 .global ret_from_fork
1253 movi schedule_tail,r5
1258 #ifdef CONFIG_POOR_MANS_STRACE
1259 /* nothing useful in registers at this point */
1264 ld.q SP, FRAME_R(9), r2
1269 ld.q SP, FRAME_S(FSPC), r2
1270 addi r2, 4, r2 /* Move PC, being pre-execution event */
1271 st.q SP, FRAME_S(FSPC), r2
1272 pta ret_from_syscall, tr0
1278 /* Use LINK to deflect the exit point, default is syscall_ret */
1279 pta syscall_ret, tr0
1281 pta syscall_notrace, tr0
1284 ld.l r2, TI_FLAGS, r4
1285 movi (1 << TIF_SYSCALL_TRACE), r6
1289 /* Trace it by calling syscall_trace before and after */
1290 movi syscall_trace, r4
1293 /* Reload syscall number as r5 is trashed by syscall_trace */
1294 ld.q SP, FRAME_S(FSYSCALL_ID), r5
1297 pta syscall_ret_trace, tr0
1301 /* Now point to the appropriate 4th level syscall handler */
1302 movi sys_call_table, r4
1307 /* Prepare original args */
1308 ld.q SP, FRAME_R(2), r2
1309 ld.q SP, FRAME_R(3), r3
1310 ld.q SP, FRAME_R(4), r4
1311 ld.q SP, FRAME_R(5), r5
1312 ld.q SP, FRAME_R(6), r6
1313 ld.q SP, FRAME_R(7), r7
1315 /* And now the trick for those syscalls requiring regs * ! */
1319 blink tr0, ZERO /* LINK is already properly set */
1322 /* We get back here only if under trace */
1323 st.q SP, FRAME_R(9), r2 /* Save return value */
1325 movi syscall_trace, LINK
1329 /* This needs to be done after any syscall tracing */
1330 ld.q SP, FRAME_S(FSPC), r2
1331 addi r2, 4, r2 /* Move PC, being pre-execution event */
1332 st.q SP, FRAME_S(FSPC), r2
1334 pta ret_from_syscall, tr0
1335 blink tr0, ZERO /* Resume normal return sequence */
1338 * --- Switch to running under a particular ASID and return the previous ASID value
1339 * --- The caller is assumed to have done a cli before calling this.
1341 * Input r2 : new ASID
1342 * Output r2 : old ASID
1345 .global switch_and_save_asid
1346 switch_and_save_asid:
1349 shlli r4, 16, r4 /* r4 = mask to select ASID */
1350 and r0, r4, r3 /* r3 = shifted old ASID */
1351 andi r2, 255, r2 /* mask down new ASID */
1352 shlli r2, 16, r2 /* align new ASID against SR.ASID */
1353 andc r0, r4, r0 /* efface old ASID from SR */
1354 or r0, r2, r0 /* insert the new ASID */
1362 shlri r3, 16, r2 /* r2 = old ASID */
1365 .global route_to_panic_handler
1366 route_to_panic_handler:
1367 /* Switch to real mode, goto panic_handler, don't return. Useful for
1368 last-chance debugging, e.g. if no output wants to go to the console.
1371 movi panic_handler - CONFIG_CACHED_MEMORY_OFFSET, r1
1383 1: /* Now in real mode */
1387 .global peek_real_address_q
1388 peek_real_address_q:
1390 r2 : real mode address to peek
1391 r2(out) : result quadword
1393 This is provided as a cheapskate way of manipulating device
1394 registers for debugging (to avoid the need to onchip_remap the debug
1395 module, and to avoid the need to onchip_remap the watchpoint
1396 controller in a way that identity maps sufficient bits to avoid the
1397 SH5-101 cut2 silicon defect).
1399 This code is not performance critical
1402 add.l r2, r63, r2 /* sign extend address */
1403 getcon sr, r0 /* r0 = saved original SR */
1406 or r0, r1, r1 /* r0 with block bit set */
1407 putcon r1, sr /* now in critical section */
1410 andc r1, r36, r1 /* turn sr.mmu off in real mode section */
1413 movi .peek0 - CONFIG_CACHED_MEMORY_OFFSET, r36 /* real mode target address */
1414 movi 1f, r37 /* virtual mode return addr */
1421 .peek0: /* come here in real mode, don't touch caches!!
1422 still in critical section (sr.bl==1) */
1425 /* Here's the actual peek. If the address is bad, all bets are now off
1426 * what will happen (handlers invoked in real-mode = bad news) */
1429 rte /* Back to virtual mode */
1436 .global poke_real_address_q
1437 poke_real_address_q:
1439 r2 : real mode address to poke
1440 r3 : quadword value to write.
1442 This is provided as a cheapskate way of manipulating device
1443 registers for debugging (to avoid the need to onchip_remap the debug
1444 module, and to avoid the need to onchip_remap the watchpoint
1445 controller in a way that identity maps sufficient bits to avoid the
1446 SH5-101 cut2 silicon defect).
1448 This code is not performance critical
1451 add.l r2, r63, r2 /* sign extend address */
1452 getcon sr, r0 /* r0 = saved original SR */
1455 or r0, r1, r1 /* r0 with block bit set */
1456 putcon r1, sr /* now in critical section */
1459 andc r1, r36, r1 /* turn sr.mmu off in real mode section */
1462 movi .poke0-CONFIG_CACHED_MEMORY_OFFSET, r36 /* real mode target address */
1463 movi 1f, r37 /* virtual mode return addr */
1470 .poke0: /* come here in real mode, don't touch caches!!
1471 still in critical section (sr.bl==1) */
1474 /* Here's the actual poke. If the address is bad, all bets are now off
1475 * what will happen (handlers invoked in real-mode = bad news) */
1478 rte /* Back to virtual mode */
1486 * --- User Access Handling Section
1490 * User Access support. It all moved to non inlined Assembler
1491 * functions in here.
1493 * __kernel_size_t __copy_user(void *__to, const void *__from,
1494 * __kernel_size_t __n)
1497 * (r2) target address
1498 * (r3) source address
1499 * (r4) size in bytes
1503 * (r2) non-copied bytes
1505 * If a fault occurs on the user pointer, bail out early and return the
1506 * number of bytes not copied in r2.
1507 * Strategy : for large blocks, call a real memcpy function which can
1508 * move >1 byte at a time using unaligned ld/st instructions, and can
1509 * manipulate the cache using prefetch + alloco to improve the speed
1510 * further. If a fault occurs in that function, just revert to the
1511 * byte-by-byte approach used for small blocks; this is rare so the
1512 * performance hit for that case does not matter.
1514 * For small blocks it's not worth the overhead of setting up and calling
1515 * the memcpy routine; do the copy a byte at a time.
1520 pta __copy_user_byte_by_byte, tr1
1521 movi 16, r0 ! this value is a best guess, should tune it by benchmarking
1523 pta copy_user_memcpy, tr0
1525 /* Save arguments in case we have to fix-up unhandled page fault */
1529 st.q SP, 24, r35 ! r35 is callee-save
1530 /* Save LINK in a register to reduce RTS time later (otherwise
1531 ld SP,*,LINK;ptabs LINK;trn;blink trn,r63 becomes a critical path) */
1535 /* Copy completed normally if we get back here */
1538 /* don't restore r2-r4, pointless */
1539 /* set result=r2 to zero as the copy must have succeeded. */
1542 blink tr0, r63 ! RTS
1544 .global __copy_user_fixup
1546 /* Restore stack frame */
1553 /* Fall through to original code, in the 'same' state we entered with */
1555 /* The slow byte-by-byte method is used if the fast copy traps due to a bad
1556 user address. In that rare case, the speed drop can be tolerated. */
1557 __copy_user_byte_by_byte:
1558 pta ___copy_user_exit, tr1
1559 pta ___copy_user1, tr0
1560 beq/u r4, r63, tr1 /* early exit for zero length copy */
1565 ld.b r3, 0, r5 /* Fault address 1 */
1567 /* Could rewrite this to use just 1 add, but the second comes 'free'
1568 due to load latency */
1570 addi r4, -1, r4 /* No real fixup required */
1572 stx.b r3, r0, r5 /* Fault address 2 */
1581 * __kernel_size_t __clear_user(void *addr, __kernel_size_t size)
1584 * (r2) target address
1585 * (r3) size in bytes
1588 * (*r2) zero-ed target data
1589 * (r2) non-zero-ed bytes
1591 .global __clear_user
1593 pta ___clear_user_exit, tr1
1594 pta ___clear_user1, tr0
1598 st.b r2, 0, ZERO /* Fault address */
1600 addi r3, -1, r3 /* No real fixup required */
1610 * int __strncpy_from_user(unsigned long __dest, unsigned long __src,
1614 * (r2) target address
1615 * (r3) source address
1616 * (r4) maximum size in bytes
1620 * (r2) -EFAULT (in case of faulting)
1621 * copied data (otherwise)
1623 .global __strncpy_from_user
1624 __strncpy_from_user:
1625 pta ___strncpy_from_user1, tr0
1626 pta ___strncpy_from_user_done, tr1
1627 or r4, ZERO, r5 /* r5 = original count */
1628 beq/u r4, r63, tr1 /* early exit if r4==0 */
1629 movi -(EFAULT), r6 /* r6 = reply, no real fixup */
1630 or ZERO, ZERO, r7 /* r7 = data, clear top byte of data */
1632 ___strncpy_from_user1:
1633 ld.b r3, 0, r7 /* Fault address: only in reading */
1638 addi r4, -1, r4 /* return real number of copied bytes */
1641 ___strncpy_from_user_done:
1642 sub r5, r4, r6 /* If done, return copied */
1644 ___strncpy_from_user_exit:
1650 * extern long __strnlen_user(const char *__s, long __n)
1653 * (r2) source address
1654 * (r3) source size in bytes
1657 * (r2) -EFAULT (in case of faulting)
1658 * string length (otherwise)
1660 .global __strnlen_user
1662 pta ___strnlen_user_set_reply, tr0
1663 pta ___strnlen_user1, tr1
1664 or ZERO, ZERO, r5 /* r5 = counter */
1665 movi -(EFAULT), r6 /* r6 = reply, no real fixup */
1666 or ZERO, ZERO, r7 /* r7 = data, clear top byte of data */
1670 ldx.b r2, r5, r7 /* Fault address: only in reading */
1671 addi r3, -1, r3 /* No real fixup */
1675 ! The line below used to be active. This meant led to a junk byte lying between each pair
1676 ! of entries in the argv & envp structures in memory. Whilst the program saw the right data
1677 ! via the argv and envp arguments to main, it meant the 'flat' representation visible through
1678 ! /proc/$pid/cmdline was corrupt, causing trouble with ps, for example.
1679 ! addi r5, 1, r5 /* Include '\0' */
1681 ___strnlen_user_set_reply:
1682 or r5, ZERO, r6 /* If done, return counter */
1684 ___strnlen_user_exit:
1690 * extern long __get_user_asm_?(void *val, long addr)
1694 * (r3) source address (in User Space)
1697 * (r2) -EFAULT (faulting)
1700 .global __get_user_asm_b
1703 movi -(EFAULT), r2 /* r2 = reply, no real fixup */
1706 ld.b r3, 0, r5 /* r5 = data */
1710 ___get_user_asm_b_exit:
1715 .global __get_user_asm_w
1718 movi -(EFAULT), r2 /* r2 = reply, no real fixup */
1721 ld.w r3, 0, r5 /* r5 = data */
1725 ___get_user_asm_w_exit:
1730 .global __get_user_asm_l
1733 movi -(EFAULT), r2 /* r2 = reply, no real fixup */
1736 ld.l r3, 0, r5 /* r5 = data */
1740 ___get_user_asm_l_exit:
1745 .global __get_user_asm_q
1748 movi -(EFAULT), r2 /* r2 = reply, no real fixup */
1751 ld.q r3, 0, r5 /* r5 = data */
1755 ___get_user_asm_q_exit:
1760 * extern long __put_user_asm_?(void *pval, long addr)
1763 * (r2) kernel pointer to value
1764 * (r3) dest address (in User Space)
1767 * (r2) -EFAULT (faulting)
1770 .global __put_user_asm_b
1772 ld.b r2, 0, r4 /* r4 = data */
1773 movi -(EFAULT), r2 /* r2 = reply, no real fixup */
1779 ___put_user_asm_b_exit:
1784 .global __put_user_asm_w
1786 ld.w r2, 0, r4 /* r4 = data */
1787 movi -(EFAULT), r2 /* r2 = reply, no real fixup */
1793 ___put_user_asm_w_exit:
1798 .global __put_user_asm_l
1800 ld.l r2, 0, r4 /* r4 = data */
1801 movi -(EFAULT), r2 /* r2 = reply, no real fixup */
1807 ___put_user_asm_l_exit:
1812 .global __put_user_asm_q
1814 ld.q r2, 0, r4 /* r4 = data */
1815 movi -(EFAULT), r2 /* r2 = reply, no real fixup */
1821 ___put_user_asm_q_exit:
1826 /* The idea is : when we get an unhandled panic, we dump the registers
1827 to a known memory location, the just sit in a tight loop.
1828 This allows the human to look at the memory region through the GDB
1829 session (assuming the debug module's SHwy initiator isn't locked up
1830 or anything), to hopefully analyze the cause of the panic. */
1832 /* On entry, former r15 (SP) is in DCR
1833 former r0 is at resvec_saved_area + 0
1834 former r1 is at resvec_saved_area + 8
1835 former tr0 is at resvec_saved_area + 32
1836 DCR is the only register whose value is lost altogether.
1839 movi 0xffffffff80000000, r0 ! phy of dump area
1840 ld.q SP, 0x000, r1 ! former r0
1842 ld.q SP, 0x008, r1 ! former r1
1906 st.q r0, 0x1f8, r63 ! bogus, but for consistency's sake...
1908 ld.q SP, 0x020, r1 ! former tr0
1958 /* Prepare to jump to C - physical address */
1959 movi panic_handler-CONFIG_CACHED_MEMORY_OFFSET, r1
1973 * --- Signal Handling Section
1977 * extern long long _sa_default_rt_restorer
1978 * extern long long _sa_default_restorer
1982 * extern void _sa_default_rt_restorer(void)
1983 * extern void _sa_default_restorer(void)
1985 * Code prototypes to do a sys_rt_sigreturn() or sys_sysreturn()
1986 * from user space. Copied into user space by signal management.
1987 * Both must be quad aligned and 2 quad long (4 instructions).
1991 .global sa_default_rt_restorer
1992 sa_default_rt_restorer:
1994 shori __NR_rt_sigreturn, r9
1999 .global sa_default_restorer
2000 sa_default_restorer:
2002 shori __NR_sigreturn, r9
2007 * --- __ex_table Section
2011 * User Access Exception Table.
2013 .section __ex_table, "a"
2015 .global asm_uaccess_start /* Just a marker */
2018 .long ___copy_user1, ___copy_user_exit
2019 .long ___copy_user2, ___copy_user_exit
2020 .long ___clear_user1, ___clear_user_exit
2021 .long ___strncpy_from_user1, ___strncpy_from_user_exit
2022 .long ___strnlen_user1, ___strnlen_user_exit
2023 .long ___get_user_asm_b1, ___get_user_asm_b_exit
2024 .long ___get_user_asm_w1, ___get_user_asm_w_exit
2025 .long ___get_user_asm_l1, ___get_user_asm_l_exit
2026 .long ___get_user_asm_q1, ___get_user_asm_q_exit
2027 .long ___put_user_asm_b1, ___put_user_asm_b_exit
2028 .long ___put_user_asm_w1, ___put_user_asm_w_exit
2029 .long ___put_user_asm_l1, ___put_user_asm_l_exit
2030 .long ___put_user_asm_q1, ___put_user_asm_q_exit
2032 .global asm_uaccess_end /* Just a marker */
2039 * --- .text.init Section
2042 .section .text.init, "ax"
2045 * void trap_init (void)
2050 addi SP, -24, SP /* Room to save r28/r29/r30 */
2055 /* Set VBR and RESVEC */
2056 movi LVBR_block, r19
2057 andi r19, -4, r19 /* reset MMUOFF + reserved */
2058 /* For RESVEC exceptions we force the MMU off, which means we need the
2059 physical address. */
2060 movi LRESVEC_block-CONFIG_CACHED_MEMORY_OFFSET, r20
2061 andi r20, -4, r20 /* reset reserved */
2062 ori r20, 1, r20 /* set MMUOFF */
2067 movi LVBR_block_end, r21
2069 movi BLOCK_SIZE, r29 /* r29 = expected size */
2074 * Ugly, but better loop forever now than crash afterwards.
2075 * We should print a message, but if we touch LVBR or
2076 * LRESVEC blocks we should not be surprised if we get stuck
2079 pta trap_init_loop, tr1
2080 gettr tr1, r28 /* r28 = trap_init_loop */
2081 sub r21, r30, r30 /* r30 = actual size */
2084 * VBR/RESVEC handlers overlap by being bigger than
2085 * allowed. Very bad. Just loop forever.
2086 * (r28) panic/loop address
2087 * (r29) expected size
2093 /* Now that exception vectors are set up reset SR.BL */
2095 movi SR_UNBLOCK_EXC, r23