1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#include <linux/linkage.h>
20
21#include <asm/processor.h>
22#include <asm/unistd.h>
23#include <asm/thread_info.h>
24#include <asm/errno.h>
25#include <asm/spr_defs.h>
26#include <asm/page.h>
27#include <asm/mmu.h>
28#include <asm/pgtable.h>
29#include <asm/asm-offsets.h>
30
31#define DISABLE_INTERRUPTS(t1,t2) \
32 l.mfspr t2,r0,SPR_SR ;\
33 l.movhi t1,hi(~(SPR_SR_IEE|SPR_SR_TEE)) ;\
34 l.ori t1,t1,lo(~(SPR_SR_IEE|SPR_SR_TEE)) ;\
35 l.and t2,t2,t1 ;\
36 l.mtspr r0,t2,SPR_SR
37
38#define ENABLE_INTERRUPTS(t1) \
39 l.mfspr t1,r0,SPR_SR ;\
40 l.ori t1,t1,lo(SPR_SR_IEE|SPR_SR_TEE) ;\
41 l.mtspr r0,t1,SPR_SR
42
43
44
45
46
47
48
49
50
51
52#define RESTORE_ALL \
53 DISABLE_INTERRUPTS(r3,r4) ;\
54 l.lwz r3,PT_PC(r1) ;\
55 l.mtspr r0,r3,SPR_EPCR_BASE ;\
56 l.lwz r3,PT_SR(r1) ;\
57 l.mtspr r0,r3,SPR_ESR_BASE ;\
58 l.lwz r2,PT_GPR2(r1) ;\
59 l.lwz r3,PT_GPR3(r1) ;\
60 l.lwz r4,PT_GPR4(r1) ;\
61 l.lwz r5,PT_GPR5(r1) ;\
62 l.lwz r6,PT_GPR6(r1) ;\
63 l.lwz r7,PT_GPR7(r1) ;\
64 l.lwz r8,PT_GPR8(r1) ;\
65 l.lwz r9,PT_GPR9(r1) ;\
66 l.lwz r10,PT_GPR10(r1) ;\
67 l.lwz r11,PT_GPR11(r1) ;\
68 l.lwz r12,PT_GPR12(r1) ;\
69 l.lwz r13,PT_GPR13(r1) ;\
70 l.lwz r14,PT_GPR14(r1) ;\
71 l.lwz r15,PT_GPR15(r1) ;\
72 l.lwz r16,PT_GPR16(r1) ;\
73 l.lwz r17,PT_GPR17(r1) ;\
74 l.lwz r18,PT_GPR18(r1) ;\
75 l.lwz r19,PT_GPR19(r1) ;\
76 l.lwz r20,PT_GPR20(r1) ;\
77 l.lwz r21,PT_GPR21(r1) ;\
78 l.lwz r22,PT_GPR22(r1) ;\
79 l.lwz r23,PT_GPR23(r1) ;\
80 l.lwz r24,PT_GPR24(r1) ;\
81 l.lwz r25,PT_GPR25(r1) ;\
82 l.lwz r26,PT_GPR26(r1) ;\
83 l.lwz r27,PT_GPR27(r1) ;\
84 l.lwz r28,PT_GPR28(r1) ;\
85 l.lwz r29,PT_GPR29(r1) ;\
86 l.lwz r30,PT_GPR30(r1) ;\
87 l.lwz r31,PT_GPR31(r1) ;\
88 l.lwz r1,PT_SP(r1) ;\
89 l.rfe
90
91
92#define EXCEPTION_ENTRY(handler) \
93 .global handler ;\
94handler: ;\
95 ;\
96 l.sw PT_GPR2(r1),r2 ;\
97 l.sw PT_GPR3(r1),r3 ;\
98 ;\
99 l.sw PT_GPR5(r1),r5 ;\
100 l.sw PT_GPR6(r1),r6 ;\
101 l.sw PT_GPR7(r1),r7 ;\
102 l.sw PT_GPR8(r1),r8 ;\
103 l.sw PT_GPR9(r1),r9 ;\
104 ;\
105 l.sw PT_GPR11(r1),r11 ;\
106 ;\
107 l.sw PT_GPR13(r1),r13 ;\
108 l.sw PT_GPR14(r1),r14 ;\
109 l.sw PT_GPR15(r1),r15 ;\
110 l.sw PT_GPR16(r1),r16 ;\
111 l.sw PT_GPR17(r1),r17 ;\
112 l.sw PT_GPR18(r1),r18 ;\
113 l.sw PT_GPR19(r1),r19 ;\
114 l.sw PT_GPR20(r1),r20 ;\
115 l.sw PT_GPR21(r1),r21 ;\
116 l.sw PT_GPR22(r1),r22 ;\
117 l.sw PT_GPR23(r1),r23 ;\
118 l.sw PT_GPR24(r1),r24 ;\
119 l.sw PT_GPR25(r1),r25 ;\
120 l.sw PT_GPR26(r1),r26 ;\
121 l.sw PT_GPR27(r1),r27 ;\
122 l.sw PT_GPR28(r1),r28 ;\
123 l.sw PT_GPR29(r1),r29 ;\
124 ;\
125 ;\
126 l.sw PT_GPR31(r1),r31 ;\
127 ;\
128 l.addi r30,r0,-1 ;\
129 l.sw PT_ORIG_GPR11(r1),r30
130
131#define UNHANDLED_EXCEPTION(handler,vector) \
132 .global handler ;\
133handler: ;\
134 ;\
135 l.sw PT_GPR2(r1),r2 ;\
136 l.sw PT_GPR3(r1),r3 ;\
137 l.sw PT_GPR5(r1),r5 ;\
138 l.sw PT_GPR6(r1),r6 ;\
139 l.sw PT_GPR7(r1),r7 ;\
140 l.sw PT_GPR8(r1),r8 ;\
141 l.sw PT_GPR9(r1),r9 ;\
142 ;\
143 l.sw PT_GPR11(r1),r11 ;\
144 ;\
145 l.sw PT_GPR13(r1),r13 ;\
146 l.sw PT_GPR14(r1),r14 ;\
147 l.sw PT_GPR15(r1),r15 ;\
148 l.sw PT_GPR16(r1),r16 ;\
149 l.sw PT_GPR17(r1),r17 ;\
150 l.sw PT_GPR18(r1),r18 ;\
151 l.sw PT_GPR19(r1),r19 ;\
152 l.sw PT_GPR20(r1),r20 ;\
153 l.sw PT_GPR21(r1),r21 ;\
154 l.sw PT_GPR22(r1),r22 ;\
155 l.sw PT_GPR23(r1),r23 ;\
156 l.sw PT_GPR24(r1),r24 ;\
157 l.sw PT_GPR25(r1),r25 ;\
158 l.sw PT_GPR26(r1),r26 ;\
159 l.sw PT_GPR27(r1),r27 ;\
160 l.sw PT_GPR28(r1),r28 ;\
161 l.sw PT_GPR29(r1),r29 ;\
162 ;\
163 l.sw PT_GPR30(r1),r30 ;\
164 ;\
165 ;\
166 l.addi r30,r0,-1 ;\
167 l.sw PT_ORIG_GPR11(r1),r30 ;\
168 l.addi r3,r1,0 ;\
169 ;\
170 l.addi r5,r0,vector ;\
171 l.jal unhandled_exception ;\
172 l.nop ;\
173 l.j _ret_from_exception ;\
174 l.nop
175
176
177#define CLEAR_LWA_FLAG(reg) \
178 l.movhi reg,hi(lwa_flag) ;\
179 l.ori reg,reg,lo(lwa_flag) ;\
180 l.sw 0(reg),r0
181
182
183
184
185
186
187
188
189
190
191
192
193
194EXCEPTION_ENTRY(_tng_kernel_start)
195 l.jal _start
196 l.andi r0,r0,0
197
198
199
200EXCEPTION_ENTRY(_bus_fault_handler)
201 CLEAR_LWA_FLAG(r3)
202
203 l.jal do_bus_fault
204 l.addi r3,r1,0
205
206 l.j _ret_from_exception
207 l.nop
208
209
210EXCEPTION_ENTRY(_dtlb_miss_page_fault_handler)
211 CLEAR_LWA_FLAG(r3)
212 l.and r5,r5,r0
213 l.j 1f
214 l.nop
215
216EXCEPTION_ENTRY(_data_page_fault_handler)
217 CLEAR_LWA_FLAG(r3)
218
219 l.ori r5,r0,0x300
2201:
221 l.addi r3,r1,0
222
223
224
225
226
227
228
229
230#ifdef CONFIG_OPENRISC_NO_SPR_SR_DSX
231 l.lwz r6,PT_PC(r3)
232 l.lwz r6,0(r6)
233
234 l.srli r6,r6,26
235 l.sfeqi r6,0
236 l.bf 8f
237 l.sfeqi r6,1
238 l.bf 8f
239 l.sfeqi r6,3
240 l.bf 8f
241 l.sfeqi r6,4
242 l.bf 8f
243 l.sfeqi r6,0x11
244 l.bf 8f
245 l.sfeqi r6,0x12
246 l.bf 8f
247 l.nop
248
249 l.j 9f
250 l.nop
251
2528:
253 l.lwz r6,PT_PC(r3)
254 l.addi r6,r6,4
255 l.lwz r6,0(r6)
256 l.srli r6,r6,26
2579:
258
259#else
260
261 l.lwz r6,PT_SR(r3)
262 l.andi r6,r6,SPR_SR_DSX
263 l.sfne r6,r0
264 l.bnf 7f
265 l.lwz r6,PT_PC(r3)
266
267 l.addi r6,r6,4
2687:
269 l.lwz r6,0(r6)
270 l.srli r6,r6,26
271#endif
272
273 l.sfgeui r6,0x33
274 l.bnf 1f
275 l.sfleui r6,0x37
276 l.bnf 1f
277 l.ori r6,r0,0x1
278 l.j 2f
279 l.nop
2801: l.ori r6,r0,0x0
2812:
282
283
284 l.jal do_page_fault
285 l.nop
286 l.j _ret_from_exception
287 l.nop
288
289
290EXCEPTION_ENTRY(_itlb_miss_page_fault_handler)
291 CLEAR_LWA_FLAG(r3)
292 l.and r5,r5,r0
293 l.j 1f
294 l.nop
295
296EXCEPTION_ENTRY(_insn_page_fault_handler)
297 CLEAR_LWA_FLAG(r3)
298
299 l.ori r5,r0,0x400
3001:
301 l.addi r3,r1,0
302
303 l.ori r6,r0,0x0
304
305
306 l.jal do_page_fault
307 l.nop
308 l.j _ret_from_exception
309 l.nop
310
311
312
313
314EXCEPTION_ENTRY(_timer_handler)
315 CLEAR_LWA_FLAG(r3)
316 l.jal timer_interrupt
317 l.addi r3,r1,0
318
319 l.j _ret_from_intr
320 l.nop
321
322
323
324EXCEPTION_ENTRY(_alignment_handler)
325 CLEAR_LWA_FLAG(r3)
326
327 l.jal do_unaligned_access
328 l.addi r3,r1,0
329
330 l.j _ret_from_exception
331 l.nop
332
333
334EXCEPTION_ENTRY(_alignment_handler)
335
336 l.addi r2,r4,0
337
338 l.lwz r5,PT_PC(r1)
339
340 l.lwz r3,0(r5)
341 l.srli r4,r3,26
342
343 l.sfeqi r4,0x00
344 l.bf jmp
345 l.sfeqi r4,0x01
346 l.bf jmp
347 l.sfeqi r4,0x03
348 l.bf jmp
349 l.sfeqi r4,0x04
350 l.bf jmp
351 l.sfeqi r4,0x11
352 l.bf jr
353 l.sfeqi r4,0x12
354 l.bf jr
355 l.nop
356 l.j 1f
357 l.addi r5,r5,4
358
359jmp:
360 l.slli r4,r3,6
361 l.srai r4,r4,4
362
363 l.lwz r3,4(r5)
364
365 l.add r5,r5,r4
366
367 l.j 1f
368 l.srli r4,r3,26
369
370jr:
371 l.slli r4,r3,9
372 l.andi r4,r4,0x7c
373
374 l.lwz r3,4(r5)
375
376 l.add r4,r4,r1
377 l.lwz r5,0(r4)
378
379 l.srli r4,r3,26
380
381
3821:
383
384 l.sw PT_PC(r1),r5
385
386 l.sfeqi r4,0x26
387 l.bf lhs
388 l.sfeqi r4,0x25
389 l.bf lhz
390 l.sfeqi r4,0x22
391 l.bf lws
392 l.sfeqi r4,0x21
393 l.bf lwz
394 l.sfeqi r4,0x37
395 l.bf sh
396 l.sfeqi r4,0x35
397 l.bf sw
398 l.nop
399
4001: l.j 1b
401 l.nop
402
403lhs: l.lbs r5,0(r2)
404 l.slli r5,r5,8
405 l.lbz r6,1(r2)
406 l.or r5,r5,r6
407 l.srli r4,r3,19
408 l.andi r4,r4,0x7c
409 l.add r4,r4,r1
410 l.j align_end
411 l.sw 0(r4),r5
412
413lhz: l.lbz r5,0(r2)
414 l.slli r5,r5,8
415 l.lbz r6,1(r2)
416 l.or r5,r5,r6
417 l.srli r4,r3,19
418 l.andi r4,r4,0x7c
419 l.add r4,r4,r1
420 l.j align_end
421 l.sw 0(r4),r5
422
423lws: l.lbs r5,0(r2)
424 l.slli r5,r5,24
425 l.lbz r6,1(r2)
426 l.slli r6,r6,16
427 l.or r5,r5,r6
428 l.lbz r6,2(r2)
429 l.slli r6,r6,8
430 l.or r5,r5,r6
431 l.lbz r6,3(r2)
432 l.or r5,r5,r6
433 l.srli r4,r3,19
434 l.andi r4,r4,0x7c
435 l.add r4,r4,r1
436 l.j align_end
437 l.sw 0(r4),r5
438
439lwz: l.lbz r5,0(r2)
440 l.slli r5,r5,24
441 l.lbz r6,1(r2)
442 l.slli r6,r6,16
443 l.or r5,r5,r6
444 l.lbz r6,2(r2)
445 l.slli r6,r6,8
446 l.or r5,r5,r6
447 l.lbz r6,3(r2)
448 l.or r5,r5,r6
449 l.srli r4,r3,19
450 l.andi r4,r4,0x7c
451 l.add r4,r4,r1
452 l.j align_end
453 l.sw 0(r4),r5
454
455sh:
456 l.srli r4,r3,9
457 l.andi r4,r4,0x7c
458 l.add r4,r4,r1
459 l.lwz r5,0(r4)
460 l.sb 1(r2),r5
461 l.srli r5,r5,8
462 l.j align_end
463 l.sb 0(r2),r5
464
465sw:
466 l.srli r4,r3,9
467 l.andi r4,r4,0x7c
468 l.add r4,r4,r1
469 l.lwz r5,0(r4)
470 l.sb 3(r2),r5
471 l.srli r5,r5,8
472 l.sb 2(r2),r5
473 l.srli r5,r5,8
474 l.sb 1(r2),r5
475 l.srli r5,r5,8
476 l.j align_end
477 l.sb 0(r2),r5
478
479align_end:
480 l.j _ret_from_intr
481 l.nop
482#endif
483
484
485
486EXCEPTION_ENTRY(_illegal_instruction_handler)
487
488 l.jal do_illegal_instruction
489 l.addi r3,r1,0
490
491 l.j _ret_from_exception
492 l.nop
493
494
495
496EXCEPTION_ENTRY(_external_irq_handler)
497#ifdef CONFIG_OPENRISC_ESR_EXCEPTION_BUG_CHECK
498 l.lwz r4,PT_SR(r1)
499 l.andi r4,r4,SPR_SR_IEE
500 l.sfeqi r4,0
501 l.bnf 1f
502 l.nop
503
504 l.addi r1,r1,-0x8
505 l.movhi r3,hi(42f)
506 l.ori r3,r3,lo(42f)
507 l.sw 0x0(r1),r3
508 l.jal printk
509 l.sw 0x4(r1),r4
510 l.addi r1,r1,0x8
511
512 .section .rodata, "a"
51342:
514 .string "\n\rESR interrupt bug: in _external_irq_handler (ESR %x)\n\r"
515 .align 4
516 .previous
517
518 l.ori r4,r4,SPR_SR_IEE
519
5201:
521#endif
522 CLEAR_LWA_FLAG(r3)
523 l.addi r3,r1,0
524 l.movhi r8,hi(do_IRQ)
525 l.ori r8,r8,lo(do_IRQ)
526 l.jalr r8
527 l.nop
528 l.j _ret_from_intr
529 l.nop
530
531
532
533
534
535
536
537
538
539UNHANDLED_EXCEPTION(_vector_0xb00,0xb00)
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555_string_syscall_return:
556 .string "syscall return %ld \n\r\0"
557 .align 4
558
559ENTRY(_sys_call_handler)
560
561 ENABLE_INTERRUPTS(r29)
562
563
564 l.sw PT_GPR2(r1),r2
565
566
567
568
569 l.sw PT_GPR3(r1),r3
570
571
572
573
574
575 CLEAR_LWA_FLAG(r4)
576 l.lwz r4,PT_GPR4(r1)
577 l.sw PT_GPR5(r1),r5
578 l.sw PT_GPR6(r1),r6
579 l.sw PT_GPR7(r1),r7
580 l.sw PT_GPR8(r1),r8
581 l.sw PT_GPR9(r1),r9
582
583 l.sw PT_GPR11(r1),r11
584
585 l.sw PT_ORIG_GPR11(r1),r11
586
587
588
589
590
591
592
593
594
595
596
597
598
599_syscall_check_trace_enter:
600
601 l.lwz r30,TI_FLAGS(r10)
602 l.andi r30,r30,_TIF_SYSCALL_TRACE
603 l.sfne r30,r0
604 l.bf _syscall_trace_enter
605 l.nop
606
607_syscall_check:
608
609 l.sfgeui r11,__NR_syscalls
610 l.bf _syscall_badsys
611 l.nop
612
613_syscall_call:
614 l.movhi r29,hi(sys_call_table)
615 l.ori r29,r29,lo(sys_call_table)
616 l.slli r11,r11,2
617 l.add r29,r29,r11
618 l.lwz r29,0(r29)
619
620 l.jalr r29
621 l.nop
622
623_syscall_return:
624
625
626
627 l.sw PT_GPR11(r1),r11
628
629
630_syscall_debug:
631 l.movhi r3,hi(_string_syscall_return)
632 l.ori r3,r3,lo(_string_syscall_return)
633 l.ori r27,r0,1
634 l.sw -4(r1),r27
635 l.sw -8(r1),r11
636 l.addi r1,r1,-8
637 l.movhi r27,hi(printk)
638 l.ori r27,r27,lo(printk)
639 l.jalr r27
640 l.nop
641 l.addi r1,r1,8
642#endif
643
644_syscall_check_trace_leave:
645
646
647
648
649 l.sfne r30,r0
650 l.bf _syscall_trace_leave
651 l.nop
652
653
654
655
656
657_syscall_check_work:
658
659 DISABLE_INTERRUPTS(r27,r29)
660 l.lwz r30,TI_FLAGS(r10)
661 l.andi r30,r30,_TIF_WORK_MASK
662 l.sfne r30,r0
663
664 l.bnf _syscall_resume_userspace
665 l.nop
666
667
668
669
670
671 l.sw PT_GPR14(r1),r14
672 l.sw PT_GPR16(r1),r16
673 l.sw PT_GPR18(r1),r18
674 l.sw PT_GPR20(r1),r20
675 l.sw PT_GPR22(r1),r22
676 l.sw PT_GPR24(r1),r24
677 l.sw PT_GPR26(r1),r26
678 l.sw PT_GPR28(r1),r28
679
680
681 l.j _work_pending
682 l.nop
683
684_syscall_resume_userspace:
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708 l.lwz r2,PT_GPR2(r1)
709
710
711
712
713
714 l.lwz r3,PT_GPR3(r1)
715 l.lwz r4,PT_GPR4(r1)
716 l.lwz r5,PT_GPR5(r1)
717 l.lwz r6,PT_GPR6(r1)
718 l.lwz r7,PT_GPR7(r1)
719 l.lwz r8,PT_GPR8(r1)
720
721 l.lwz r9,PT_GPR9(r1)
722 l.lwz r10,PT_GPR10(r1)
723 l.lwz r11,PT_GPR11(r1)
724
725
726 l.lwz r30,PT_GPR30(r1)
727
728
729 l.lwz r13,PT_PC(r1)
730 l.lwz r15,PT_SR(r1)
731 l.lwz r1,PT_SP(r1)
732
733
734
735 DISABLE_INTERRUPTS(r17,r19)
736 l.mtspr r0,r13,SPR_EPCR_BASE
737 l.mtspr r0,r15,SPR_ESR_BASE
738 l.rfe
739
740
741
742
743
744_syscall_trace_enter:
745
746
747
748
749
750
751
752 l.jal do_syscall_trace_enter
753 l.addi r3,r1,0
754
755
756
757
758
759 l.lwz r11,PT_GPR11(r1)
760 l.lwz r3,PT_GPR3(r1)
761 l.lwz r4,PT_GPR4(r1)
762 l.lwz r5,PT_GPR5(r1)
763 l.lwz r6,PT_GPR6(r1)
764 l.lwz r7,PT_GPR7(r1)
765
766 l.j _syscall_check
767 l.lwz r8,PT_GPR8(r1)
768
769_syscall_trace_leave:
770 l.jal do_syscall_trace_leave
771 l.addi r3,r1,0
772
773 l.j _syscall_check_work
774 l.nop
775
776_syscall_badsys:
777
778
779
780
781
782 l.j _syscall_return
783 l.addi r11,r0,-ENOSYS
784
785
786
787
788
789UNHANDLED_EXCEPTION(_vector_0xd00,0xd00)
790
791
792
793EXCEPTION_ENTRY(_trap_handler)
794 CLEAR_LWA_FLAG(r3)
795
796 l.jal do_trap
797 l.addi r3,r1,0
798
799 l.j _ret_from_exception
800 l.nop
801
802
803
804UNHANDLED_EXCEPTION(_vector_0xf00,0xf00)
805
806
807
808UNHANDLED_EXCEPTION(_vector_0x1000,0x1000)
809
810
811
812UNHANDLED_EXCEPTION(_vector_0x1100,0x1100)
813
814
815
816UNHANDLED_EXCEPTION(_vector_0x1200,0x1200)
817
818
819
820UNHANDLED_EXCEPTION(_vector_0x1300,0x1300)
821
822
823
824UNHANDLED_EXCEPTION(_vector_0x1400,0x1400)
825
826
827
828UNHANDLED_EXCEPTION(_vector_0x1500,0x1500)
829
830
831
832UNHANDLED_EXCEPTION(_vector_0x1600,0x1600)
833
834
835
836UNHANDLED_EXCEPTION(_vector_0x1700,0x1700)
837
838
839
840UNHANDLED_EXCEPTION(_vector_0x1800,0x1800)
841
842
843
844UNHANDLED_EXCEPTION(_vector_0x1900,0x1900)
845
846
847
848UNHANDLED_EXCEPTION(_vector_0x1a00,0x1a00)
849
850
851
852UNHANDLED_EXCEPTION(_vector_0x1b00,0x1b00)
853
854
855
856UNHANDLED_EXCEPTION(_vector_0x1c00,0x1c00)
857
858
859
860UNHANDLED_EXCEPTION(_vector_0x1d00,0x1d00)
861
862
863
864UNHANDLED_EXCEPTION(_vector_0x1e00,0x1e00)
865
866
867
868UNHANDLED_EXCEPTION(_vector_0x1f00,0x1f00)
869
870
871
872_resume_userspace:
873 DISABLE_INTERRUPTS(r3,r4)
874 l.lwz r4,TI_FLAGS(r10)
875 l.andi r13,r4,_TIF_WORK_MASK
876 l.sfeqi r13,0
877 l.bf _restore_all
878 l.nop
879
880_work_pending:
881 l.lwz r5,PT_ORIG_GPR11(r1)
882 l.sfltsi r5,0
883 l.bnf 1f
884 l.nop
885 l.andi r5,r5,0
8861:
887 l.jal do_work_pending
888 l.ori r3,r1,0
889
890 l.sfeqi r11,0
891 l.bf _restore_all
892 l.nop
893 l.sfltsi r11,0
894 l.bnf 1f
895 l.nop
896 l.and r11,r11,r0
897 l.ori r11,r11,__NR_restart_syscall
898 l.j _syscall_check_trace_enter
899 l.nop
9001:
901 l.lwz r11,PT_ORIG_GPR11(r1)
902
903 l.lwz r3,PT_GPR3(r1)
904 l.lwz r4,PT_GPR4(r1)
905 l.lwz r5,PT_GPR5(r1)
906 l.lwz r6,PT_GPR6(r1)
907 l.lwz r7,PT_GPR7(r1)
908 l.j _syscall_check_trace_enter
909 l.lwz r8,PT_GPR8(r1)
910
911_restore_all:
912 RESTORE_ALL
913
914
915
916ENTRY(_ret_from_intr)
917ENTRY(_ret_from_exception)
918 l.lwz r4,PT_SR(r1)
919 l.andi r3,r4,SPR_SR_SM
920 l.sfeqi r3,0
921 l.bnf _restore_all
922 l.nop
923 l.j _resume_userspace
924 l.nop
925
926ENTRY(ret_from_fork)
927 l.jal schedule_tail
928 l.nop
929
930
931 l.sfeqi r20,0
932 l.bf 1f
933 l.nop
934
935
936 l.jalr r20
937 l.or r3,r22,r0
938
9391:
940
941 l.lwz r11,PT_GPR11(r1)
942
943
944
945
946
947
948 l.lwz r12,PT_GPR12(r1)
949 l.lwz r14,PT_GPR14(r1)
950 l.lwz r16,PT_GPR16(r1)
951 l.lwz r18,PT_GPR18(r1)
952 l.lwz r20,PT_GPR20(r1)
953 l.lwz r22,PT_GPR22(r1)
954 l.lwz r24,PT_GPR24(r1)
955 l.lwz r26,PT_GPR26(r1)
956 l.lwz r28,PT_GPR28(r1)
957
958 l.j _syscall_return
959 l.nop
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000 .align 0x400
1001ENTRY(_switch)
1002
1003
1004
1005
1006 l.addi r1,r1,-(INT_FRAME_SIZE)
1007
1008
1009 l.sw PT_GPR2(r1),r2
1010 l.sw PT_GPR9(r1),r9
1011
1012
1013 l.sw PT_GPR12(r1),r12
1014 l.sw PT_GPR14(r1),r14
1015 l.sw PT_GPR16(r1),r16
1016 l.sw PT_GPR18(r1),r18
1017 l.sw PT_GPR20(r1),r20
1018 l.sw PT_GPR22(r1),r22
1019 l.sw PT_GPR24(r1),r24
1020 l.sw PT_GPR26(r1),r26
1021 l.sw PT_GPR28(r1),r28
1022 l.sw PT_GPR30(r1),r30
1023
1024 l.addi r11,r10,0
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034 l.lwz r29,TI_KSP(r10)
1035 l.sw PT_SP(r1),r29
1036
1037
1038 l.sw TI_KSP(r10),r1
1039 l.or r10,r4,r0
1040 l.lwz r1,TI_KSP(r10)
1041
1042
1043 l.lwz r29,PT_SP(r1)
1044 l.sw TI_KSP(r10),r29
1045
1046
1047
1048
1049 l.lwz r2,PT_GPR2(r1)
1050 l.lwz r9,PT_GPR9(r1)
1051
1052
1053
1054
1055
1056 l.lwz r12,PT_GPR12(r1)
1057 l.lwz r14,PT_GPR14(r1)
1058 l.lwz r16,PT_GPR16(r1)
1059 l.lwz r18,PT_GPR18(r1)
1060 l.lwz r20,PT_GPR20(r1)
1061 l.lwz r22,PT_GPR22(r1)
1062 l.lwz r24,PT_GPR24(r1)
1063 l.lwz r26,PT_GPR26(r1)
1064 l.lwz r28,PT_GPR28(r1)
1065 l.lwz r30,PT_GPR30(r1)
1066
1067
1068 l.addi r1,r1,(INT_FRAME_SIZE)
1069
1070
1071
1072
1073
1074
1075
1076 l.lwz r3,TI_TASK(r3)
1077 l.jr r9
1078 l.nop
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096_fork_save_extra_regs_and_call:
1097 l.sw PT_GPR14(r1),r14
1098 l.sw PT_GPR16(r1),r16
1099 l.sw PT_GPR18(r1),r18
1100 l.sw PT_GPR20(r1),r20
1101 l.sw PT_GPR22(r1),r22
1102 l.sw PT_GPR24(r1),r24
1103 l.sw PT_GPR26(r1),r26
1104 l.jr r29
1105 l.sw PT_GPR28(r1),r28
1106
1107ENTRY(__sys_clone)
1108 l.movhi r29,hi(sys_clone)
1109 l.ori r29,r29,lo(sys_clone)
1110 l.j _fork_save_extra_regs_and_call
1111 l.addi r7,r1,0
1112
1113ENTRY(__sys_fork)
1114 l.movhi r29,hi(sys_fork)
1115 l.ori r29,r29,lo(sys_fork)
1116 l.j _fork_save_extra_regs_and_call
1117 l.addi r3,r1,0
1118
1119ENTRY(sys_rt_sigreturn)
1120 l.jal _sys_rt_sigreturn
1121 l.addi r3,r1,0
1122 l.sfne r30,r0
1123 l.bnf _no_syscall_trace
1124 l.nop
1125 l.jal do_syscall_trace_leave
1126 l.addi r3,r1,0
1127_no_syscall_trace:
1128 l.j _resume_userspace
1129 l.nop
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145ENTRY(sys_or1k_atomic)
1146
1147 DISABLE_INTERRUPTS(r17,r19)
1148 l.lwz r29,0(r4)
1149 l.lwz r27,0(r5)
1150 l.sw 0(r4),r27
1151 l.sw 0(r5),r29
1152 ENABLE_INTERRUPTS(r17)
1153 l.jr r9
1154 l.or r11,r0,r0
1155
1156
1157