1
2
3
4
5
6
7
8
9
10
11
12#include <linux/errno.h>
13#include <linux/init.h>
14#include <linux/sys.h>
15#include <cpu/registers.h>
16#include <asm/processor.h>
17#include <asm/unistd.h>
18#include <asm/thread_info.h>
19#include <asm/asm-offsets.h>
20
21
22
23
24#define SR_ASID_MASK 0x00ff0000
25#define SR_FD_MASK 0x00008000
26#define SR_SS 0x08000000
27#define SR_BL 0x10000000
28#define SR_MD 0x40000000
29
30
31
32
33#define EVENT_INTERRUPT 0
34#define EVENT_FAULT_TLB 1
35#define EVENT_FAULT_NOT_TLB 2
36#define EVENT_DEBUG 3
37
38
39#define RESET_CAUSE 0x20
40#define DEBUGSS_CAUSE 0x980
41
42
43
44
45#define FRAME_T(x) FRAME_TBASE+(x*8)
46#define FRAME_R(x) FRAME_RBASE+(x*8)
47#define FRAME_S(x) FRAME_SBASE+(x*8)
48#define FSPC 0
49#define FSSR 1
50#define FSYSCALL_ID 2
51
52
53#define FRAME_SBASE 0
54#define FRAME_RBASE (FRAME_SBASE+(3*8))
55#define FRAME_TBASE (FRAME_RBASE+(63*8))
56#define FRAME_PBASE (FRAME_TBASE+(8*8))
57#define FRAME_SIZE (FRAME_PBASE+(2*8))
58
59#define FP_FRAME_SIZE FP_FRAME_BASE+(33*8)
60#define FP_FRAME_BASE 0
61
62#define SAVED_R2 0*8
63#define SAVED_R3 1*8
64#define SAVED_R4 2*8
65#define SAVED_R5 3*8
66#define SAVED_R18 4*8
67#define SAVED_R6 5*8
68#define SAVED_TR0 6*8
69
70
71
72#define TLB_SAVED_R25 7*8
73#define TLB_SAVED_TR1 8*8
74#define TLB_SAVED_TR2 9*8
75#define TLB_SAVED_TR3 10*8
76#define TLB_SAVED_TR4 11*8
77
78
79#define TLB_SAVED_R0 12*8
80#define TLB_SAVED_R1 13*8
81
82#define CLI() \
83 getcon SR, r6; \
84 ori r6, 0xf0, r6; \
85 putcon r6, SR;
86
87#define STI() \
88 getcon SR, r6; \
89 andi r6, ~0xf0, r6; \
90 putcon r6, SR;
91
92#ifdef CONFIG_PREEMPT
93# define preempt_stop() CLI()
94#else
95# define preempt_stop()
96# define resume_kernel restore_all
97#endif
98
99 .section .data, "aw"
100
101#define FAST_TLBMISS_STACK_CACHELINES 4
102#define FAST_TLBMISS_STACK_QUADWORDS (4*FAST_TLBMISS_STACK_CACHELINES)
103
104
105 .balign 32
106
107
108 .fill FAST_TLBMISS_STACK_QUADWORDS, 8, 0x0
109
110
111reg_save_area:
112 .quad 0
113 .quad 0
114 .quad 0
115 .quad 0
116
117 .quad 0
118 .quad 0
119 .quad 0
120 .quad 0
121
122 .quad 0
123 .quad 0
124 .quad 0
125 .quad 0
126
127 .quad 0
128 .quad 0
129
130
131
132
133
134 .balign 32,0,32
135resvec_save_area:
136 .quad 0
137 .quad 0
138 .quad 0
139 .quad 0
140 .quad 0
141 .balign 32,0,32
142
143
144trap_jtable:
145 .long do_exception_error
146 .long do_exception_error
147#ifdef CONFIG_MMU
148 .long tlb_miss_load
149 .long tlb_miss_store
150#else
151 .long do_exception_error
152 .long do_exception_error
153#endif
154 ! ARTIFICIAL pseudo-EXPEVT setting
155 .long do_debug_interrupt
156#ifdef CONFIG_MMU
157 .long tlb_miss_load
158 .long tlb_miss_store
159#else
160 .long do_exception_error
161 .long do_exception_error
162#endif
163 .long do_address_error_load
164 .long do_address_error_store
165#ifdef CONFIG_SH_FPU
166 .long do_fpu_error
167#else
168 .long do_exception_error
169#endif
170 .long do_exception_error
171 .long system_call
172 .long do_reserved_inst
173 .long do_illegal_slot_inst
174 .long do_exception_error
175 .long do_exception_error
176 .rept 15
177 .long do_IRQ
178 .endr
179 .long do_exception_error
180 .rept 32
181 .long do_IRQ
182 .endr
183 .long fpu_error_or_IRQA
184 .long fpu_error_or_IRQB
185 .long do_IRQ
186 .long do_IRQ
187 .rept 6
188 .long do_exception_error
189 .endr
190 .long breakpoint_trap_handler
191 .long do_exception_error
192 .long do_single_step
193
194 .rept 3
195 .long do_exception_error
196 .endr
197 .long do_IRQ
198 .long do_IRQ
199#ifdef CONFIG_MMU
200 .long itlb_miss_or_IRQ
201#else
202 .long do_IRQ
203#endif
204 .long do_IRQ
205 .long do_IRQ
206#ifdef CONFIG_MMU
207 .long itlb_miss_or_IRQ
208#else
209 .long do_IRQ
210#endif
211 .long do_exception_error
212 .long do_address_error_exec
213 .rept 8
214 .long do_exception_error
215 .endr
216 .rept 18
217 .long do_IRQ
218 .endr
219
220 .section .text64, "ax"
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247#define TEXT_SIZE 128
248#define BLOCK_SIZE 1664
249
250 .balign TEXT_SIZE
251LVBR_block:
252 .space 256, 0
253
254not_a_tlb_miss:
255 synco
256
257 putcon SP, KCR1
258
259
260 movi reg_save_area, SP
261 st.q SP, SAVED_R2, r2
262 st.q SP, SAVED_R3, r3
263 st.q SP, SAVED_R4, r4
264 st.q SP, SAVED_R5, r5
265 st.q SP, SAVED_R6, r6
266 st.q SP, SAVED_R18, r18
267 gettr tr0, r3
268 st.q SP, SAVED_TR0, r3
269
270
271 getcon EXPEVT, r2
272 movi ret_from_exception, r3
273 ori r3, 1, r3
274 movi EVENT_FAULT_NOT_TLB, r4
275 or SP, ZERO, r5
276 getcon KCR1, SP
277 pta handle_exception, tr0
278 blink tr0, ZERO
279
280 .balign 256
281 ! VBR+0x200
282 nop
283 .balign 256
284 ! VBR+0x300
285 nop
286 .balign 256
287
288
289
290
291 .balign TEXT_SIZE
292
293
294
295
296#ifdef CONFIG_MMU
297tlb_miss:
298 synco
299 putcon SP, KCR1
300 movi reg_save_area, SP
301
302 st.q SP, TLB_SAVED_R0 , r0
303 st.q SP, TLB_SAVED_R1 , r1
304 st.q SP, SAVED_R2 , r2
305 st.q SP, SAVED_R3 , r3
306 st.q SP, SAVED_R4 , r4
307 st.q SP, SAVED_R5 , r5
308 st.q SP, SAVED_R6 , r6
309 st.q SP, SAVED_R18, r18
310
311
312
313 st.q SP, TLB_SAVED_R25, r25
314 gettr tr0, r2
315 gettr tr1, r3
316 gettr tr2, r4
317 gettr tr3, r5
318 gettr tr4, r18
319 st.q SP, SAVED_TR0 , r2
320 st.q SP, TLB_SAVED_TR1 , r3
321 st.q SP, TLB_SAVED_TR2 , r4
322 st.q SP, TLB_SAVED_TR3 , r5
323 st.q SP, TLB_SAVED_TR4 , r18
324
325 pt do_fast_page_fault, tr0
326 getcon SSR, r2
327 getcon EXPEVT, r3
328 getcon TEA, r4
329 shlri r2, 30, r2
330 andi r2, 1, r2
331 blink tr0, LINK
332
333 pt fixup_to_invoke_general_handler, tr1
334
335
336
337
338 bnei/u r2, 0, tr1
339
340fast_tlb_miss_restore:
341 ld.q SP, SAVED_TR0, r2
342 ld.q SP, TLB_SAVED_TR1, r3
343 ld.q SP, TLB_SAVED_TR2, r4
344
345 ld.q SP, TLB_SAVED_TR3, r5
346 ld.q SP, TLB_SAVED_TR4, r18
347
348 ptabs r2, tr0
349 ptabs r3, tr1
350 ptabs r4, tr2
351 ptabs r5, tr3
352 ptabs r18, tr4
353
354 ld.q SP, TLB_SAVED_R0, r0
355 ld.q SP, TLB_SAVED_R1, r1
356 ld.q SP, SAVED_R2, r2
357 ld.q SP, SAVED_R3, r3
358 ld.q SP, SAVED_R4, r4
359 ld.q SP, SAVED_R5, r5
360 ld.q SP, SAVED_R6, r6
361 ld.q SP, SAVED_R18, r18
362 ld.q SP, TLB_SAVED_R25, r25
363
364 getcon KCR1, SP
365 rte
366 nop
367
368fixup_to_invoke_general_handler:
369
370
371
372
373
374
375
376
377 ld.q SP, TLB_SAVED_TR1, r3
378 ld.q SP, TLB_SAVED_TR2, r4
379 ld.q SP, TLB_SAVED_TR3, r5
380 ld.q SP, TLB_SAVED_TR4, r18
381 ld.q SP, TLB_SAVED_R25, r25
382
383 ld.q SP, TLB_SAVED_R0, r0
384 ld.q SP, TLB_SAVED_R1, r1
385
386 ptabs/u r3, tr1
387 ptabs/u r4, tr2
388 ptabs/u r5, tr3
389 ptabs/u r18, tr4
390
391
392 getcon EXPEVT, r2
393 movi ret_from_exception, r3
394 ori r3, 1, r3
395 movi EVENT_FAULT_TLB, r4
396 or SP, ZERO, r5
397 getcon KCR1, SP
398 pta handle_exception, tr0
399 blink tr0, ZERO
400#else
401 .balign 256
402#endif
403
404
405
406 nop
407 nop
408 nop
409 nop
410 nop
411 nop
412
413 .balign 256
414
415
416interrupt:
417 synco
418
419 putcon SP, KCR1
420
421
422 movi reg_save_area, SP
423 st.q SP, SAVED_R2, r2
424 st.q SP, SAVED_R3, r3
425 st.q SP, SAVED_R4, r4
426 st.q SP, SAVED_R5, r5
427 st.q SP, SAVED_R6, r6
428 st.q SP, SAVED_R18, r18
429 gettr tr0, r3
430 st.q SP, SAVED_TR0, r3
431
432
433 getcon INTEVT, r2
434 movi ret_from_irq, r3
435 ori r3, 1, r3
436 movi EVENT_INTERRUPT, r4
437 or SP, ZERO, r5
438 getcon KCR1, SP
439 pta handle_exception, tr0
440 blink tr0, ZERO
441 .balign TEXT_SIZE
442
443LVBR_block_end:
444
445 .balign 256
446LRESVEC_block:
447
448
449
450
451
452
453reset_or_panic:
454 synco
455 putcon SP, DCR
456
457 movi resvec_save_area-CONFIG_PAGE_OFFSET, SP
458 st.q SP, 0, r0
459 st.q SP, 8, r1
460 gettr tr0, r0
461 st.q SP, 32, r0
462
463
464 getcon EXPEVT, r0
465 movi RESET_CAUSE, r1
466 sub r1, r0, r1
467 movi _stext-CONFIG_PAGE_OFFSET, r0
468 ori r0, 1, r0
469 ptabs r0, tr0
470 beqi r1, 0, tr0
471
472 getcon EXPEVT, r0
473 movi DEBUGSS_CAUSE, r1
474 sub r1, r0, r1
475 pta single_step_panic, tr0
476 beqi r1, 0, tr0
477
478
479 movi panic_stash_regs-CONFIG_PAGE_OFFSET, r1
480 ptabs r1, tr0
481 blink tr0, r63
482
483single_step_panic:
484
485
486 getcon SSR, r0
487 movi SR_MMU, r1
488 or r0, r1, r0
489 movi ~SR_SS, r1
490 and r0, r1, r0
491 putcon r0, SSR
492
493 getcon PEXPEVT, r0
494 putcon r0, EXPEVT
495
496 ld.q SP, 32, r0
497 ptabs r0, tr0
498 ld.q SP, 0, r0
499 ld.q SP, 8, r1
500 getcon DCR, SP
501 synco
502 rte
503
504
505 .balign 256
506debug_exception:
507 synco
508
509
510
511
512
513 putcon SP, DCR
514
515 movi resvec_save_area-CONFIG_PAGE_OFFSET, SP
516
517
518
519
520 ocbp SP, 0
521 synco
522
523 st.q SP, 0, r0
524 st.q SP, 8, r1
525 getcon SPC, r0
526 st.q SP, 16, r0
527 getcon SSR, r0
528 st.q SP, 24, r0
529
530
531 movi SR_MMU | SR_BL | SR_MD, r1
532 or r0, r1, r0
533 movi ~SR_SS, r1
534 and r0, r1, r0
535 putcon r0, SSR
536
537 movi debug_exeception_2, r0
538 ori r0, 1, r0
539 putcon r0, SPC
540 getcon DCR, SP
541 synco
542 rte
543debug_exeception_2:
544
545 putcon SP, KCR1
546 movi resvec_save_area, SP
547 ld.q SP, 24, r0
548 putcon r0, SSR
549 ld.q SP, 16, r0
550 putcon r0, SPC
551 ld.q SP, 0, r0
552 ld.q SP, 8, r1
553
554
555 movi reg_save_area, SP
556 st.q SP, SAVED_R2, r2
557 st.q SP, SAVED_R3, r3
558 st.q SP, SAVED_R4, r4
559 st.q SP, SAVED_R5, r5
560 st.q SP, SAVED_R6, r6
561 st.q SP, SAVED_R18, r18
562 gettr tr0, r3
563 st.q SP, SAVED_TR0, r3
564
565
566 getcon EXPEVT, r2
567 movi ret_from_exception, r3
568 ori r3, 1, r3
569 movi EVENT_DEBUG, r4
570 or SP, ZERO, r5
571 getcon KCR1, SP
572 pta handle_exception, tr0
573 blink tr0, ZERO
574
575 .balign 256
576debug_interrupt:
577
578
579
580
581 synco
582 putcon SP, KCR1
583 movi resvec_save_area-CONFIG_PAGE_OFFSET, SP
584 ocbp SP, 0
585 ocbp SP, 32
586 synco
587
588
589 st.q SP, SAVED_R2, r2
590 st.q SP, SAVED_R3, r3
591 st.q SP, SAVED_R4, r4
592 st.q SP, SAVED_R5, r5
593 st.q SP, SAVED_R6, r6
594 st.q SP, SAVED_R18, r18
595 gettr tr0, r3
596 st.q SP, SAVED_TR0, r3
597
598
599
600
601 getcon spc, r6
602 putcon r6, pspc
603 getcon ssr, r6
604 putcon r6, pssr
605
606 ! construct useful SR for handle_exception
607 movi 3, r6
608 shlli r6, 30, r6
609 getcon sr, r18
610 or r18, r6, r6
611 putcon r6, ssr
612
613 ! SSR is now the current SR with the MD and MMU bits set
614 ! i.e. the rte will switch back to priv mode and put
615 ! the mmu back on
616
617 ! construct spc
618 movi handle_exception, r18
619 ori r18, 1, r18 ! for safety (do we need this?)
620 putcon r18, spc
621
622
623
624 ! EXPEVT==0x80 is unused, so 'steal' this value to put the
625 ! debug interrupt handler in the vectoring table
626 movi 0x80, r2
627 movi ret_from_exception, r3
628 ori r3, 1, r3
629 movi EVENT_FAULT_NOT_TLB, r4
630
631 or SP, ZERO, r5
632 movi CONFIG_PAGE_OFFSET, r6
633 add r6, r5, r5
634 getcon KCR1, SP
635
636 synco ! for safety
637 rte ! -> handle_exception, switch back to priv mode again
638
639LRESVEC_block_end:
640
641 .balign TEXT_SIZE
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662handle_exception:
663
664
665
666 getcon SSR, r6
667 shlri r6, 30, r6
668 andi r6, 1, r6
669 pta stack_ok, tr0
670 bne r6, ZERO, tr0
671
672
673 getcon KCR0, SP
674 movi THREAD_SIZE, r6
675 add SP, r6, SP
676
677stack_ok:
678
679
680 pta no_underflow, tr0
681 getcon KCR0, r6
682 movi 1024, r18
683 add r6, r18, r6
684 bge SP, r6, tr0 ! ? below 1k from bottom of stack : danger zone
685
686
687bad_sp:
688 ld.b r63, 0, r6
689 nop
690
691no_underflow:
692 pta bad_sp, tr0
693 getcon kcr0, r6
694 movi THREAD_SIZE, r18
695 add r18, r6, r6
696 bgt SP, r6, tr0 ! sp above the stack
697
698
699 movi -(FRAME_SIZE), r6
700 add SP, r6, SP
701
702
703
704 ld.q r5, SAVED_R2, r6
705 ld.q r5, SAVED_R3, r18
706 st.q SP, FRAME_R(2), r6
707 ld.q r5, SAVED_R4, r6
708 st.q SP, FRAME_R(3), r18
709 ld.q r5, SAVED_R5, r18
710 st.q SP, FRAME_R(4), r6
711 ld.q r5, SAVED_R6, r6
712 st.q SP, FRAME_R(5), r18
713 ld.q r5, SAVED_R18, r18
714 st.q SP, FRAME_R(6), r6
715 ld.q r5, SAVED_TR0, r6
716 st.q SP, FRAME_R(18), r18
717 st.q SP, FRAME_T(0), r6
718
719
720 getcon KCR1, r6
721
722
723 st.q SP, FRAME_R(0), r0
724 st.q SP, FRAME_R(1), r1
725 st.q SP, FRAME_R(7), r7
726 st.q SP, FRAME_R(8), r8
727 st.q SP, FRAME_R(9), r9
728 st.q SP, FRAME_R(10), r10
729 st.q SP, FRAME_R(11), r11
730 st.q SP, FRAME_R(12), r12
731 st.q SP, FRAME_R(13), r13
732 st.q SP, FRAME_R(14), r14
733
734
735 st.q SP, FRAME_R(15), r6
736
737 st.q SP, FRAME_R(16), r16
738 st.q SP, FRAME_R(17), r17
739
740 st.q SP, FRAME_R(19), r19
741 st.q SP, FRAME_R(20), r20
742 st.q SP, FRAME_R(21), r21
743 st.q SP, FRAME_R(22), r22
744 st.q SP, FRAME_R(23), r23
745 st.q SP, FRAME_R(24), r24
746 st.q SP, FRAME_R(25), r25
747 st.q SP, FRAME_R(26), r26
748 st.q SP, FRAME_R(27), r27
749 st.q SP, FRAME_R(28), r28
750 st.q SP, FRAME_R(29), r29
751 st.q SP, FRAME_R(30), r30
752 st.q SP, FRAME_R(31), r31
753 st.q SP, FRAME_R(32), r32
754 st.q SP, FRAME_R(33), r33
755 st.q SP, FRAME_R(34), r34
756 st.q SP, FRAME_R(35), r35
757 st.q SP, FRAME_R(36), r36
758 st.q SP, FRAME_R(37), r37
759 st.q SP, FRAME_R(38), r38
760 st.q SP, FRAME_R(39), r39
761 st.q SP, FRAME_R(40), r40
762 st.q SP, FRAME_R(41), r41
763 st.q SP, FRAME_R(42), r42
764 st.q SP, FRAME_R(43), r43
765 st.q SP, FRAME_R(44), r44
766 st.q SP, FRAME_R(45), r45
767 st.q SP, FRAME_R(46), r46
768 st.q SP, FRAME_R(47), r47
769 st.q SP, FRAME_R(48), r48
770 st.q SP, FRAME_R(49), r49
771 st.q SP, FRAME_R(50), r50
772 st.q SP, FRAME_R(51), r51
773 st.q SP, FRAME_R(52), r52
774 st.q SP, FRAME_R(53), r53
775 st.q SP, FRAME_R(54), r54
776 st.q SP, FRAME_R(55), r55
777 st.q SP, FRAME_R(56), r56
778 st.q SP, FRAME_R(57), r57
779 st.q SP, FRAME_R(58), r58
780 st.q SP, FRAME_R(59), r59
781 st.q SP, FRAME_R(60), r60
782 st.q SP, FRAME_R(61), r61
783 st.q SP, FRAME_R(62), r62
784
785
786
787
788 getcon SSR, r61
789 st.q SP, FRAME_S(FSSR), r61
790 getcon SPC, r62
791 st.q SP, FRAME_S(FSPC), r62
792 movi -1, r62
793 st.q SP, FRAME_S(FSYSCALL_ID), r62
794
795
796 gettr tr1, r6
797 st.q SP, FRAME_T(1), r6
798 gettr tr2, r6
799 st.q SP, FRAME_T(2), r6
800 gettr tr3, r6
801 st.q SP, FRAME_T(3), r6
802 gettr tr4, r6
803 st.q SP, FRAME_T(4), r6
804 gettr tr5, r6
805 st.q SP, FRAME_T(5), r6
806 gettr tr6, r6
807 st.q SP, FRAME_T(6), r6
808 gettr tr7, r6
809 st.q SP, FRAME_T(7), r6
810
811 ! setup FP so that unwinder can wind back through nested kernel mode
812 ! exceptions
813 add SP, ZERO, r14
814
815
816 getcon TRA, r5
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831 getcon SR, r6
832 movi SR_IMASK | SR_FD, r7
833 or r6, r7, r6
834 putcon r6, SR
835 movi SR_UNBLOCK_EXC, r7
836 and r6, r7, r6
837 putcon r6, SR
838
839
840
841 or r3, ZERO, LINK
842 movi trap_jtable, r3
843 shlri r2, 3, r2
844 ldx.l r2, r3, r3
845 shlri r2, 2, r2
846 ptabs r3, tr0
847 or SP, ZERO, r3
848 blink tr0, ZERO
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867 .global ret_from_irq
868ret_from_irq:
869 ld.q SP, FRAME_S(FSSR), r6
870 shlri r6, 30, r6
871 andi r6, 1, r6
872 pta resume_kernel, tr0
873 bne r6, ZERO, tr0
874 STI()
875 pta ret_with_reschedule, tr0
876 blink tr0, ZERO
877
878 .global ret_from_exception
879ret_from_exception:
880 preempt_stop()
881
882 ld.q SP, FRAME_S(FSSR), r6
883 shlri r6, 30, r6
884 andi r6, 1, r6
885 pta resume_kernel, tr0
886 bne r6, ZERO, tr0
887
888
889
890#ifdef CONFIG_PREEMPT
891 pta ret_from_syscall, tr0
892 blink tr0, ZERO
893
894resume_kernel:
895 CLI()
896
897 pta restore_all, tr0
898
899 getcon KCR0, r6
900 ld.l r6, TI_PRE_COUNT, r7
901 beq/u r7, ZERO, tr0
902
903need_resched:
904 ld.l r6, TI_FLAGS, r7
905 movi (1 << TIF_NEED_RESCHED), r8
906 and r8, r7, r8
907 bne r8, ZERO, tr0
908
909 getcon SR, r7
910 andi r7, 0xf0, r7
911 bne r7, ZERO, tr0
912
913 movi preempt_schedule_irq, r7
914 ori r7, 1, r7
915 ptabs r7, tr1
916 blink tr1, LINK
917
918 pta need_resched, tr1
919 blink tr1, ZERO
920#endif
921
922 .global ret_from_syscall
923ret_from_syscall:
924
925ret_with_reschedule:
926 getcon KCR0, r6 ! r6 contains current_thread_info
927 ld.l r6, TI_FLAGS, r7 ! r7 contains current_thread_info->flags
928
929 movi _TIF_NEED_RESCHED, r8
930 and r8, r7, r8
931 pta work_resched, tr0
932 bne r8, ZERO, tr0
933
934 pta restore_all, tr1
935
936 movi (_TIF_SIGPENDING|_TIF_NOTIFY_RESUME), r8
937 and r8, r7, r8
938 pta work_notifysig, tr0
939 bne r8, ZERO, tr0
940
941 blink tr1, ZERO
942
943work_resched:
944 pta ret_from_syscall, tr0
945 gettr tr0, LINK
946 movi schedule, r6
947 ptabs r6, tr0
948 blink tr0, ZERO
949
950work_notifysig:
951 gettr tr1, LINK
952
953 movi do_notify_resume, r6
954 ptabs r6, tr0
955 or SP, ZERO, r2
956 or r7, ZERO, r3
957 blink tr0, LINK
958
959restore_all:
960
961
962 ld.q SP, FRAME_T(0), r6
963 ld.q SP, FRAME_T(1), r7
964 ld.q SP, FRAME_T(2), r8
965 ld.q SP, FRAME_T(3), r9
966 ptabs r6, tr0
967 ptabs r7, tr1
968 ptabs r8, tr2
969 ptabs r9, tr3
970 ld.q SP, FRAME_T(4), r6
971 ld.q SP, FRAME_T(5), r7
972 ld.q SP, FRAME_T(6), r8
973 ld.q SP, FRAME_T(7), r9
974 ptabs r6, tr4
975 ptabs r7, tr5
976 ptabs r8, tr6
977 ptabs r9, tr7
978
979 ld.q SP, FRAME_R(0), r0
980 ld.q SP, FRAME_R(1), r1
981 ld.q SP, FRAME_R(2), r2
982 ld.q SP, FRAME_R(3), r3
983 ld.q SP, FRAME_R(4), r4
984 ld.q SP, FRAME_R(5), r5
985 ld.q SP, FRAME_R(6), r6
986 ld.q SP, FRAME_R(7), r7
987 ld.q SP, FRAME_R(8), r8
988 ld.q SP, FRAME_R(9), r9
989 ld.q SP, FRAME_R(10), r10
990 ld.q SP, FRAME_R(11), r11
991 ld.q SP, FRAME_R(12), r12
992 ld.q SP, FRAME_R(13), r13
993 ld.q SP, FRAME_R(14), r14
994
995 ld.q SP, FRAME_R(16), r16
996 ld.q SP, FRAME_R(17), r17
997 ld.q SP, FRAME_R(18), r18
998 ld.q SP, FRAME_R(19), r19
999 ld.q SP, FRAME_R(20), r20
1000 ld.q SP, FRAME_R(21), r21
1001 ld.q SP, FRAME_R(22), r22
1002 ld.q SP, FRAME_R(23), r23
1003 ld.q SP, FRAME_R(24), r24
1004 ld.q SP, FRAME_R(25), r25
1005 ld.q SP, FRAME_R(26), r26
1006 ld.q SP, FRAME_R(27), r27
1007 ld.q SP, FRAME_R(28), r28
1008 ld.q SP, FRAME_R(29), r29
1009 ld.q SP, FRAME_R(30), r30
1010 ld.q SP, FRAME_R(31), r31
1011 ld.q SP, FRAME_R(32), r32
1012 ld.q SP, FRAME_R(33), r33
1013 ld.q SP, FRAME_R(34), r34
1014 ld.q SP, FRAME_R(35), r35
1015 ld.q SP, FRAME_R(36), r36
1016 ld.q SP, FRAME_R(37), r37
1017 ld.q SP, FRAME_R(38), r38
1018 ld.q SP, FRAME_R(39), r39
1019 ld.q SP, FRAME_R(40), r40
1020 ld.q SP, FRAME_R(41), r41
1021 ld.q SP, FRAME_R(42), r42
1022 ld.q SP, FRAME_R(43), r43
1023 ld.q SP, FRAME_R(44), r44
1024 ld.q SP, FRAME_R(45), r45
1025 ld.q SP, FRAME_R(46), r46
1026 ld.q SP, FRAME_R(47), r47
1027 ld.q SP, FRAME_R(48), r48
1028 ld.q SP, FRAME_R(49), r49
1029 ld.q SP, FRAME_R(50), r50
1030 ld.q SP, FRAME_R(51), r51
1031 ld.q SP, FRAME_R(52), r52
1032 ld.q SP, FRAME_R(53), r53
1033 ld.q SP, FRAME_R(54), r54
1034 ld.q SP, FRAME_R(55), r55
1035 ld.q SP, FRAME_R(56), r56
1036 ld.q SP, FRAME_R(57), r57
1037 ld.q SP, FRAME_R(58), r58
1038
1039 getcon SR, r59
1040 movi SR_BLOCK_EXC, r60
1041 or r59, r60, r59
1042 putcon r59, SR
1043 ld.q SP, FRAME_S(FSSR), r61
1044 ld.q SP, FRAME_S(FSPC), r62
1045 movi SR_ASID_MASK, r60
1046 and r59, r60, r59
1047 andc r61, r60, r61
1048 or r59, r61, r61
1049 putcon r61, SSR
1050 putcon r62, SPC
1051
1052
1053
1054 ld.q SP, FRAME_R(59), r59
1055 ld.q SP, FRAME_R(60), r60
1056 ld.q SP, FRAME_R(61), r61
1057 ld.q SP, FRAME_R(62), r62
1058
1059
1060 ld.q SP, FRAME_R(15), SP
1061 rte
1062 nop
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090#ifdef CONFIG_MMU
1091tlb_miss_load:
1092 or SP, ZERO, r2
1093 or ZERO, ZERO, r3
1094 getcon TEA, r4
1095 pta call_do_page_fault, tr0
1096 beq ZERO, ZERO, tr0
1097
1098tlb_miss_store:
1099 or SP, ZERO, r2
1100 movi FAULT_CODE_WRITE, r3
1101 getcon TEA, r4
1102 pta call_do_page_fault, tr0
1103 beq ZERO, ZERO, tr0
1104
1105itlb_miss_or_IRQ:
1106 pta its_IRQ, tr0
1107 beqi/u r4, EVENT_INTERRUPT, tr0
1108
1109
1110 or SP, ZERO, r2
1111 movi FAULT_CODE_ITLB, r3
1112 getcon TEA, r4
1113
1114
1115call_do_page_fault:
1116 movi do_page_fault, r6
1117 ptabs r6, tr0
1118 blink tr0, ZERO
1119#endif
1120
1121fpu_error_or_IRQA:
1122 pta its_IRQ, tr0
1123 beqi/l r4, EVENT_INTERRUPT, tr0
1124#ifdef CONFIG_SH_FPU
1125 movi fpu_state_restore_trap_handler, r6
1126#else
1127 movi do_exception_error, r6
1128#endif
1129 ptabs r6, tr0
1130 blink tr0, ZERO
1131
1132fpu_error_or_IRQB:
1133 pta its_IRQ, tr0
1134 beqi/l r4, EVENT_INTERRUPT, tr0
1135#ifdef CONFIG_SH_FPU
1136 movi fpu_state_restore_trap_handler, r6
1137#else
1138 movi do_exception_error, r6
1139#endif
1140 ptabs r6, tr0
1141 blink tr0, ZERO
1142
1143its_IRQ:
1144 movi do_IRQ, r6
1145 ptabs r6, tr0
1146 blink tr0, ZERO
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170unknown_trap:
1171
1172 movi do_unknown_trapa, r6
1173 ptabs r6, tr0
1174 ld.q r3, FRAME_R(9), r2
1175 andi r2, 0x1ff, r2
1176 blink tr0, LINK
1177
1178 pta syscall_ret, tr0
1179 blink tr0, ZERO
1180
1181
1182system_call:
1183 pta unknown_trap, tr0
1184 or r5, ZERO, r4
1185 shlri r4, 20, r4
1186 bnei r4, 1, tr0
1187
1188
1189 st.q r3, FRAME_S(FSYSCALL_ID), r5
1190 andi r5, 0x1ff, r5
1191
1192 STI()
1193
1194 pta syscall_allowed, tr0
1195 movi NR_syscalls - 1, r4
1196 bgeu/l r4, r5, tr0
1197
1198syscall_bad:
1199
1200 movi -(ENOSYS), r2
1201
1202 .global syscall_ret
1203syscall_ret:
1204 st.q SP, FRAME_R(9), r2
1205 ld.q SP, FRAME_S(FSPC), r2
1206 addi r2, 4, r2
1207 st.q SP, FRAME_S(FSPC), r2
1208 pta ret_from_syscall, tr0
1209 blink tr0, ZERO
1210
1211
1212
1213
1214
1215
1216
1217.global ret_from_fork
1218ret_from_fork:
1219
1220 movi schedule_tail,r5
1221 ori r5, 1, r5
1222 ptabs r5, tr0
1223 blink tr0, LINK
1224
1225 ld.q SP, FRAME_S(FSPC), r2
1226 addi r2, 4, r2
1227 st.q SP, FRAME_S(FSPC), r2
1228 pta ret_from_syscall, tr0
1229 blink tr0, ZERO
1230
1231.global ret_from_kernel_thread
1232ret_from_kernel_thread:
1233
1234 movi schedule_tail,r5
1235 ori r5, 1, r5
1236 ptabs r5, tr0
1237 blink tr0, LINK
1238
1239 ld.q SP, FRAME_R(2), r2
1240 ld.q SP, FRAME_R(3), r3
1241 ptabs r3, tr0
1242 blink tr0, LINK
1243
1244 ld.q SP, FRAME_S(FSPC), r2
1245 addi r2, 4, r2
1246 st.q SP, FRAME_S(FSPC), r2
1247 pta ret_from_syscall, tr0
1248 blink tr0, ZERO
1249
1250syscall_allowed:
1251
1252 pta syscall_ret, tr0
1253 gettr tr0, LINK
1254 pta syscall_notrace, tr0
1255
1256 getcon KCR0, r2
1257 ld.l r2, TI_FLAGS, r4
1258 movi _TIF_WORK_SYSCALL_MASK, r6
1259 and r6, r4, r6
1260 beq/l r6, ZERO, tr0
1261
1262
1263 movi do_syscall_trace_enter, r4
1264 or SP, ZERO, r2
1265 ptabs r4, tr0
1266 blink tr0, LINK
1267
1268
1269 st.q SP, FRAME_R(2), r2
1270
1271
1272 ld.q SP, FRAME_S(FSYSCALL_ID), r5
1273 andi r5, 0x1ff, r5
1274
1275 pta syscall_ret_trace, tr0
1276 gettr tr0, LINK
1277
1278syscall_notrace:
1279
1280 movi sys_call_table, r4
1281 shlli r5, 2, r5
1282 ldx.l r4, r5, r5
1283 ptabs r5, tr0
1284
1285
1286 ld.q SP, FRAME_R(2), r2
1287 ld.q SP, FRAME_R(3), r3
1288 ld.q SP, FRAME_R(4), r4
1289 ld.q SP, FRAME_R(5), r5
1290 ld.q SP, FRAME_R(6), r6
1291 ld.q SP, FRAME_R(7), r7
1292
1293
1294 or SP, ZERO, r8
1295
1296
1297 blink tr0, ZERO
1298
1299syscall_ret_trace:
1300
1301 st.q SP, FRAME_R(9), r2
1302
1303 movi do_syscall_trace_leave, LINK
1304 or SP, ZERO, r2
1305 ptabs LINK, tr0
1306 blink tr0, LINK
1307
1308
1309 ld.q SP, FRAME_S(FSPC), r2
1310 addi r2, 4, r2
1311 st.q SP, FRAME_S(FSPC), r2
1312
1313 pta ret_from_syscall, tr0
1314 blink tr0, ZERO
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324 .global switch_and_save_asid
1325switch_and_save_asid:
1326 getcon sr, r0
1327 movi 255, r4
1328 shlli r4, 16, r4
1329 and r0, r4, r3
1330 andi r2, 255, r2
1331 shlli r2, 16, r2
1332 andc r0, r4, r0
1333 or r0, r2, r0
1334 putcon r0, ssr
1335 movi 1f, r0
1336 putcon r0, spc
1337 rte
1338 nop
13391:
1340 ptabs LINK, tr0
1341 shlri r3, 16, r2
1342 blink tr0, r63
1343
1344 .global route_to_panic_handler
1345route_to_panic_handler:
1346
1347
1348
1349
1350 movi panic_handler - CONFIG_PAGE_OFFSET, r1
1351 ptabs r1, tr0
1352 pta 1f, tr1
1353 gettr tr1, r0
1354 putcon r0, spc
1355 getcon sr, r0
1356 movi 1, r1
1357 shlli r1, 31, r1
1358 andc r0, r1, r0
1359 putcon r0, ssr
1360 rte
1361 nop
13621:
1363 blink tr0, r63
1364 nop
1365
1366 .global peek_real_address_q
1367peek_real_address_q:
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381 add.l r2, r63, r2
1382 getcon sr, r0
1383 movi 1, r1
1384 shlli r1, 28, r1
1385 or r0, r1, r1
1386 putcon r1, sr
1387 movi 1, r36
1388 shlli r36, 31, r36
1389 andc r1, r36, r1
1390
1391 putcon r1, ssr
1392 movi .peek0 - CONFIG_PAGE_OFFSET, r36
1393 movi 1f, r37
1394 putcon r36, spc
1395
1396 synco
1397 rte
1398 nop
1399
1400.peek0:
1401
1402 putcon r0, ssr
1403 putcon r37, spc
1404
1405
1406 ld.q r2, 0, r2
1407 synco
1408 rte
1409 nop
1410
14111:
1412 ptabs LINK, tr0
1413 blink tr0, r63
1414
1415 .global poke_real_address_q
1416poke_real_address_q:
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430 add.l r2, r63, r2
1431 getcon sr, r0
1432 movi 1, r1
1433 shlli r1, 28, r1
1434 or r0, r1, r1
1435 putcon r1, sr
1436 movi 1, r36
1437 shlli r36, 31, r36
1438 andc r1, r36, r1
1439
1440 putcon r1, ssr
1441 movi .poke0-CONFIG_PAGE_OFFSET, r36
1442 movi 1f, r37
1443 putcon r36, spc
1444
1445 synco
1446 rte
1447 nop
1448
1449.poke0:
1450
1451 putcon r0, ssr
1452 putcon r37, spc
1453
1454
1455 st.q r2, 0, r3
1456 synco
1457 rte
1458 nop
1459
14601:
1461 ptabs LINK, tr0
1462 blink tr0, r63
1463
1464#ifdef CONFIG_MMU
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498 .global __copy_user
1499__copy_user:
1500 pta __copy_user_byte_by_byte, tr1
1501 movi 16, r0 ! this value is a best guess, should tune it by benchmarking
1502 bge/u r0, r4, tr1
1503 pta copy_user_memcpy, tr0
1504 addi SP, -32, SP
1505
1506 st.q SP, 0, r2
1507 st.q SP, 8, r3
1508 st.q SP, 16, r4
1509 st.q SP, 24, r35 ! r35 is callee-save
1510
1511
1512 ori LINK, 0, r35
1513 blink tr0, LINK
1514
1515
1516 ptabs r35, tr0
1517 ld.q SP, 24, r35
1518
1519
1520 or r63, r63, r2
1521 addi SP, 32, SP
1522 blink tr0, r63 ! RTS
1523
1524 .global __copy_user_fixup
1525__copy_user_fixup:
1526
1527 ori r35, 0, LINK
1528 ld.q SP, 24, r35
1529 ld.q SP, 16, r4
1530 ld.q SP, 8, r3
1531 ld.q SP, 0, r2
1532 addi SP, 32, SP
1533
1534
1535
1536
1537__copy_user_byte_by_byte:
1538 pta ___copy_user_exit, tr1
1539 pta ___copy_user1, tr0
1540 beq/u r4, r63, tr1
1541 sub r2, r3, r0
1542 addi r0, -1, r0
1543
1544___copy_user1:
1545 ld.b r3, 0, r5
1546
1547
1548
1549 addi r3, 1, r3
1550 addi r4, -1, r4
1551___copy_user2:
1552 stx.b r3, r0, r5
1553 bne r4, ZERO, tr0
1554
1555___copy_user_exit:
1556 or r4, ZERO, r2
1557 ptabs LINK, tr0
1558 blink tr0, ZERO
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571 .global __clear_user
1572__clear_user:
1573 pta ___clear_user_exit, tr1
1574 pta ___clear_user1, tr0
1575 beq/u r3, r63, tr1
1576
1577___clear_user1:
1578 st.b r2, 0, ZERO
1579 addi r2, 1, r2
1580 addi r3, -1, r3
1581 bne r3, ZERO, tr0
1582
1583___clear_user_exit:
1584 or r3, ZERO, r2
1585 ptabs LINK, tr0
1586 blink tr0, ZERO
1587
1588#endif
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601 .global __get_user_asm_b
1602__get_user_asm_b:
1603 or r2, ZERO, r4
1604 movi -(EFAULT), r2
1605
1606___get_user_asm_b1:
1607 ld.b r3, 0, r5
1608 st.b r4, 0, r5
1609 or ZERO, ZERO, r2
1610
1611___get_user_asm_b_exit:
1612 ptabs LINK, tr0
1613 blink tr0, ZERO
1614
1615
1616 .global __get_user_asm_w
1617__get_user_asm_w:
1618 or r2, ZERO, r4
1619 movi -(EFAULT), r2
1620
1621___get_user_asm_w1:
1622 ld.w r3, 0, r5
1623 st.w r4, 0, r5
1624 or ZERO, ZERO, r2
1625
1626___get_user_asm_w_exit:
1627 ptabs LINK, tr0
1628 blink tr0, ZERO
1629
1630
1631 .global __get_user_asm_l
1632__get_user_asm_l:
1633 or r2, ZERO, r4
1634 movi -(EFAULT), r2
1635
1636___get_user_asm_l1:
1637 ld.l r3, 0, r5
1638 st.l r4, 0, r5
1639 or ZERO, ZERO, r2
1640
1641___get_user_asm_l_exit:
1642 ptabs LINK, tr0
1643 blink tr0, ZERO
1644
1645
1646 .global __get_user_asm_q
1647__get_user_asm_q:
1648 or r2, ZERO, r4
1649 movi -(EFAULT), r2
1650
1651___get_user_asm_q1:
1652 ld.q r3, 0, r5
1653 st.q r4, 0, r5
1654 or ZERO, ZERO, r2
1655
1656___get_user_asm_q_exit:
1657 ptabs LINK, tr0
1658 blink tr0, ZERO
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671 .global __put_user_asm_b
1672__put_user_asm_b:
1673 ld.b r2, 0, r4
1674 movi -(EFAULT), r2
1675
1676___put_user_asm_b1:
1677 st.b r3, 0, r4
1678 or ZERO, ZERO, r2
1679
1680___put_user_asm_b_exit:
1681 ptabs LINK, tr0
1682 blink tr0, ZERO
1683
1684
1685 .global __put_user_asm_w
1686__put_user_asm_w:
1687 ld.w r2, 0, r4
1688 movi -(EFAULT), r2
1689
1690___put_user_asm_w1:
1691 st.w r3, 0, r4
1692 or ZERO, ZERO, r2
1693
1694___put_user_asm_w_exit:
1695 ptabs LINK, tr0
1696 blink tr0, ZERO
1697
1698
1699 .global __put_user_asm_l
1700__put_user_asm_l:
1701 ld.l r2, 0, r4
1702 movi -(EFAULT), r2
1703
1704___put_user_asm_l1:
1705 st.l r3, 0, r4
1706 or ZERO, ZERO, r2
1707
1708___put_user_asm_l_exit:
1709 ptabs LINK, tr0
1710 blink tr0, ZERO
1711
1712
1713 .global __put_user_asm_q
1714__put_user_asm_q:
1715 ld.q r2, 0, r4
1716 movi -(EFAULT), r2
1717
1718___put_user_asm_q1:
1719 st.q r3, 0, r4
1720 or ZERO, ZERO, r2
1721
1722___put_user_asm_q_exit:
1723 ptabs LINK, tr0
1724 blink tr0, ZERO
1725
1726panic_stash_regs:
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740 movi 0xffffffff80000000, r0 ! phy of dump area
1741 ld.q SP, 0x000, r1 ! former r0
1742 st.q r0, 0x000, r1
1743 ld.q SP, 0x008, r1 ! former r1
1744 st.q r0, 0x008, r1
1745 st.q r0, 0x010, r2
1746 st.q r0, 0x018, r3
1747 st.q r0, 0x020, r4
1748 st.q r0, 0x028, r5
1749 st.q r0, 0x030, r6
1750 st.q r0, 0x038, r7
1751 st.q r0, 0x040, r8
1752 st.q r0, 0x048, r9
1753 st.q r0, 0x050, r10
1754 st.q r0, 0x058, r11
1755 st.q r0, 0x060, r12
1756 st.q r0, 0x068, r13
1757 st.q r0, 0x070, r14
1758 getcon dcr, r14
1759 st.q r0, 0x078, r14
1760 st.q r0, 0x080, r16
1761 st.q r0, 0x088, r17
1762 st.q r0, 0x090, r18
1763 st.q r0, 0x098, r19
1764 st.q r0, 0x0a0, r20
1765 st.q r0, 0x0a8, r21
1766 st.q r0, 0x0b0, r22
1767 st.q r0, 0x0b8, r23
1768 st.q r0, 0x0c0, r24
1769 st.q r0, 0x0c8, r25
1770 st.q r0, 0x0d0, r26
1771 st.q r0, 0x0d8, r27
1772 st.q r0, 0x0e0, r28
1773 st.q r0, 0x0e8, r29
1774 st.q r0, 0x0f0, r30
1775 st.q r0, 0x0f8, r31
1776 st.q r0, 0x100, r32
1777 st.q r0, 0x108, r33
1778 st.q r0, 0x110, r34
1779 st.q r0, 0x118, r35
1780 st.q r0, 0x120, r36
1781 st.q r0, 0x128, r37
1782 st.q r0, 0x130, r38
1783 st.q r0, 0x138, r39
1784 st.q r0, 0x140, r40
1785 st.q r0, 0x148, r41
1786 st.q r0, 0x150, r42
1787 st.q r0, 0x158, r43
1788 st.q r0, 0x160, r44
1789 st.q r0, 0x168, r45
1790 st.q r0, 0x170, r46
1791 st.q r0, 0x178, r47
1792 st.q r0, 0x180, r48
1793 st.q r0, 0x188, r49
1794 st.q r0, 0x190, r50
1795 st.q r0, 0x198, r51
1796 st.q r0, 0x1a0, r52
1797 st.q r0, 0x1a8, r53
1798 st.q r0, 0x1b0, r54
1799 st.q r0, 0x1b8, r55
1800 st.q r0, 0x1c0, r56
1801 st.q r0, 0x1c8, r57
1802 st.q r0, 0x1d0, r58
1803 st.q r0, 0x1d8, r59
1804 st.q r0, 0x1e0, r60
1805 st.q r0, 0x1e8, r61
1806 st.q r0, 0x1f0, r62
1807 st.q r0, 0x1f8, r63 ! bogus, but for consistency's sake...
1808
1809 ld.q SP, 0x020, r1 ! former tr0
1810 st.q r0, 0x200, r1
1811 gettr tr1, r1
1812 st.q r0, 0x208, r1
1813 gettr tr2, r1
1814 st.q r0, 0x210, r1
1815 gettr tr3, r1
1816 st.q r0, 0x218, r1
1817 gettr tr4, r1
1818 st.q r0, 0x220, r1
1819 gettr tr5, r1
1820 st.q r0, 0x228, r1
1821 gettr tr6, r1
1822 st.q r0, 0x230, r1
1823 gettr tr7, r1
1824 st.q r0, 0x238, r1
1825
1826 getcon sr, r1
1827 getcon ssr, r2
1828 getcon pssr, r3
1829 getcon spc, r4
1830 getcon pspc, r5
1831 getcon intevt, r6
1832 getcon expevt, r7
1833 getcon pexpevt, r8
1834 getcon tra, r9
1835 getcon tea, r10
1836 getcon kcr0, r11
1837 getcon kcr1, r12
1838 getcon vbr, r13
1839 getcon resvec, r14
1840
1841 st.q r0, 0x240, r1
1842 st.q r0, 0x248, r2
1843 st.q r0, 0x250, r3
1844 st.q r0, 0x258, r4
1845 st.q r0, 0x260, r5
1846 st.q r0, 0x268, r6
1847 st.q r0, 0x270, r7
1848 st.q r0, 0x278, r8
1849 st.q r0, 0x280, r9
1850 st.q r0, 0x288, r10
1851 st.q r0, 0x290, r11
1852 st.q r0, 0x298, r12
1853 st.q r0, 0x2a0, r13
1854 st.q r0, 0x2a8, r14
1855
1856 getcon SPC,r2
1857 getcon SSR,r3
1858 getcon EXPEVT,r4
1859
1860 movi panic_handler-CONFIG_PAGE_OFFSET, r1
1861 ori r1, 1, r1
1862 ptabs r1, tr0
1863 getcon DCR, SP
1864 blink tr0, ZERO
1865 nop
1866 nop
1867 nop
1868 nop
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891 .balign 8
1892 .global sa_default_rt_restorer
1893sa_default_rt_restorer:
1894 movi 0x10, r9
1895 shori __NR_rt_sigreturn, r9
1896 trapa r9
1897 nop
1898
1899 .balign 8
1900 .global sa_default_restorer
1901sa_default_restorer:
1902 movi 0x10, r9
1903 shori __NR_sigreturn, r9
1904 trapa r9
1905 nop
1906
1907
1908
1909
1910
1911
1912
1913
1914 .section __ex_table, "a"
1915
1916 .global asm_uaccess_start
1917asm_uaccess_start:
1918
1919#ifdef CONFIG_MMU
1920 .long ___copy_user1, ___copy_user_exit
1921 .long ___copy_user2, ___copy_user_exit
1922 .long ___clear_user1, ___clear_user_exit
1923#endif
1924 .long ___get_user_asm_b1, ___get_user_asm_b_exit
1925 .long ___get_user_asm_w1, ___get_user_asm_w_exit
1926 .long ___get_user_asm_l1, ___get_user_asm_l_exit
1927 .long ___get_user_asm_q1, ___get_user_asm_q_exit
1928 .long ___put_user_asm_b1, ___put_user_asm_b_exit
1929 .long ___put_user_asm_w1, ___put_user_asm_w_exit
1930 .long ___put_user_asm_l1, ___put_user_asm_l_exit
1931 .long ___put_user_asm_q1, ___put_user_asm_q_exit
1932
1933 .global asm_uaccess_end
1934asm_uaccess_end:
1935
1936
1937
1938
1939
1940
1941
1942
1943 __INIT
1944
1945
1946
1947
1948
1949 .global trap_init
1950trap_init:
1951 addi SP, -24, SP
1952 st.q SP, 0, r28
1953 st.q SP, 8, r29
1954 st.q SP, 16, r30
1955
1956
1957 movi LVBR_block, r19
1958 andi r19, -4, r19
1959
1960
1961 movi LRESVEC_block-CONFIG_PAGE_OFFSET, r20
1962 andi r20, -4, r20
1963 ori r20, 1, r20
1964 putcon r19, VBR
1965 putcon r20, RESVEC
1966
1967
1968 movi LVBR_block_end, r21
1969 andi r21, -4, r21
1970 movi BLOCK_SIZE, r29
1971 or r19, ZERO, r30
1972 add r19, r29, r19
1973
1974
1975
1976
1977
1978
1979
1980 pta trap_init_loop, tr1
1981 gettr tr1, r28
1982 sub r21, r30, r30
1983
1984
1985
1986
1987
1988
1989
1990
1991trap_init_loop:
1992 bne r19, r21, tr1
1993
1994
1995 getcon SR, r22
1996 movi SR_UNBLOCK_EXC, r23
1997 and r22, r23, r22
1998 putcon r22, SR
1999
2000 addi SP, 24, SP
2001 ptabs LINK, tr0
2002 blink tr0, ZERO
2003
2004