1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67#include <asm/exceptions.h>
68#include <asm/unistd.h>
69#include <asm/page.h>
70
71#include <asm/entry.h>
72#include <asm/current.h>
73#include <linux/linkage.h>
74
75#include <asm/mmu.h>
76#include <asm/pgtable.h>
77#include <asm/signal.h>
78#include <asm/registers.h>
79#include <asm/asm-offsets.h>
80
81#undef DEBUG
82
83
84#define NUM_TO_REG(num) r
85
86#ifdef CONFIG_MMU
87 #define RESTORE_STATE \
88 lwi r5, r1, 0; \
89 mts rmsr, r5; \
90 nop; \
91 lwi r3, r1, PT_R3; \
92 lwi r4, r1, PT_R4; \
93 lwi r5, r1, PT_R5; \
94 lwi r6, r1, PT_R6; \
95 lwi r11, r1, PT_R11; \
96 lwi r31, r1, PT_R31; \
97 lwi r1, r1, PT_R1;
98#endif
99
100#define LWREG_NOP \
101 bri ex_handler_unhandled; \
102 nop;
103
104#define SWREG_NOP \
105 bri ex_handler_unhandled; \
106 nop;
107
108
109
110
111
112
113#define R3_TO_LWREG_V(regnum) \
114 swi r3, r1, 4 * regnum; \
115 bri ex_handler_done;
116
117
118#define R3_TO_LWREG(regnum) \
119 or NUM_TO_REG (regnum), r0, r3; \
120 bri ex_handler_done;
121
122
123#define SWREG_TO_R3_V(regnum) \
124 lwi r3, r1, 4 * regnum; \
125 bri ex_sw_tail;
126
127
128#define SWREG_TO_R3(regnum) \
129 or r3, r0, NUM_TO_REG (regnum); \
130 bri ex_sw_tail;
131
132#ifdef CONFIG_MMU
133 #define R3_TO_LWREG_VM_V(regnum) \
134 brid ex_lw_end_vm; \
135 swi r3, r7, 4 * regnum;
136
137 #define R3_TO_LWREG_VM(regnum) \
138 brid ex_lw_end_vm; \
139 or NUM_TO_REG (regnum), r0, r3;
140
141 #define SWREG_TO_R3_VM_V(regnum) \
142 brid ex_sw_tail_vm; \
143 lwi r3, r7, 4 * regnum;
144
145 #define SWREG_TO_R3_VM(regnum) \
146 brid ex_sw_tail_vm; \
147 or r3, r0, NUM_TO_REG (regnum);
148
149
150
151
152 #define BSRLI2(rD, rA) \
153 srl rD, rA; \
154 srl rD, rD;
155 #define BSRLI4(rD, rA) \
156 BSRLI2(rD, rA); \
157 BSRLI2(rD, rD)
158 #define BSRLI10(rD, rA) \
159 srl rD, rA; \
160 srl rD, rD; \
161 srl rD, rD; \
162 srl rD, rD; \
163 srl rD, rD; \
164 srl rD, rD; \
165 srl rD, rD; \
166 srl rD, rD; \
167 srl rD, rD; \
168 srl rD, rD
169 #define BSRLI20(rD, rA) \
170 BSRLI10(rD, rA); \
171 BSRLI10(rD, rD)
172
173 .macro bsrli, rD, rA, IMM
174 .if (\IMM) == 2
175 BSRLI2(\rD, \rA)
176 .elseif (\IMM) == 10
177 BSRLI10(\rD, \rA)
178 .elseif (\IMM) == 12
179 BSRLI2(\rD, \rA)
180 BSRLI10(\rD, \rD)
181 .elseif (\IMM) == 14
182 BSRLI4(\rD, \rA)
183 BSRLI10(\rD, \rD)
184 .elseif (\IMM) == 20
185 BSRLI20(\rD, \rA)
186 .elseif (\IMM) == 24
187 BSRLI4(\rD, \rA)
188 BSRLI20(\rD, \rD)
189 .elseif (\IMM) == 28
190 BSRLI4(\rD, \rA)
191 BSRLI4(\rD, \rD)
192 BSRLI20(\rD, \rD)
193 .else
194 .error "BSRLI shift macros \IMM"
195 .endif
196 .endm
197 #endif
198
199#endif
200
201.extern other_exception_handler
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
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
248
249
250
251
252
253
254
255
256
257#ifdef CONFIG_MMU
258.section .data
259.align 4
260pt_pool_space:
261 .space PT_SIZE
262
263#ifdef DEBUG
264
265.section .data
266.global exception_debug_table
267.align 4
268exception_debug_table:
269
270 .space (32 * 4)
271#endif
272
273.section .rodata
274.align 4
275_MB_HW_ExceptionVectorTable:
276
277 .long TOPHYS(ex_handler_unhandled)
278
279 .long TOPHYS(handle_unaligned_ex)
280
281 .long TOPHYS(full_exception_trapw)
282
283 .long TOPHYS(full_exception_trapw)
284
285 .long TOPHYS(full_exception_trapw)
286
287 .long TOPHYS(full_exception_trapw)
288
289 .long TOPHYS(full_exception_trapw)
290
291 .long TOPHYS(full_exception_trapw)
292
293 .long TOPHYS(ex_handler_unhandled)
294 .long TOPHYS(ex_handler_unhandled)
295 .long TOPHYS(ex_handler_unhandled)
296 .long TOPHYS(ex_handler_unhandled)
297 .long TOPHYS(ex_handler_unhandled)
298 .long TOPHYS(ex_handler_unhandled)
299 .long TOPHYS(ex_handler_unhandled)
300 .long TOPHYS(ex_handler_unhandled)
301
302 .long TOPHYS(handle_data_storage_exception)
303
304 .long TOPHYS(handle_instruction_storage_exception)
305
306 .long TOPHYS(handle_data_tlb_miss_exception)
307
308 .long TOPHYS(handle_instruction_tlb_miss_exception)
309
310 .long TOPHYS(ex_handler_unhandled)
311 .long TOPHYS(ex_handler_unhandled)
312 .long TOPHYS(ex_handler_unhandled)
313 .long TOPHYS(ex_handler_unhandled)
314 .long TOPHYS(ex_handler_unhandled)
315 .long TOPHYS(ex_handler_unhandled)
316 .long TOPHYS(ex_handler_unhandled)
317 .long TOPHYS(ex_handler_unhandled)
318 .long TOPHYS(ex_handler_unhandled)
319 .long TOPHYS(ex_handler_unhandled)
320 .long TOPHYS(ex_handler_unhandled)
321 .long TOPHYS(ex_handler_unhandled)
322#endif
323
324.global _hw_exception_handler
325.section .text
326.align 4
327.ent _hw_exception_handler
328_hw_exception_handler:
329#ifndef CONFIG_MMU
330 addik r1, r1, -(EX_HANDLER_STACK_SIZ);
331#else
332 swi r1, r0, TOPHYS(pt_pool_space + PT_R1);
333
334
335 ori r1, r0, TOPHYS(pt_pool_space);
336#endif
337 swi r3, r1, PT_R3
338 swi r4, r1, PT_R4
339 swi r5, r1, PT_R5
340 swi r6, r1, PT_R6
341
342#ifdef CONFIG_MMU
343 swi r11, r1, PT_R11
344 swi r31, r1, PT_R31
345 lwi r31, r0, TOPHYS(PER_CPU(CURRENT_SAVE))
346#endif
347
348 mfs r5, rmsr;
349 nop
350 swi r5, r1, 0;
351 mfs r4, resr
352 nop
353 mfs r3, rear;
354 nop
355
356#ifndef CONFIG_MMU
357 andi r5, r4, 0x1000;
358 beqi r5, not_in_delay_slot;
359 mfs r17, rbtr;
360 nop
361not_in_delay_slot:
362 swi r17, r1, PT_R17
363#endif
364
365 andi r5, r4, 0x1F;
366
367#ifdef CONFIG_MMU
368
369 addk r6, r5, r5;
370 addk r6, r6, r6;
371
372#ifdef DEBUG
373
374 lwi r5, r0, TOPHYS(exception_debug_table)
375 addi r5, r5, 1
376 swi r5, r0, TOPHYS(exception_debug_table)
377 lwi r5, r6, TOPHYS(exception_debug_table)
378 addi r5, r5, 1
379 swi r5, r6, TOPHYS(exception_debug_table)
380#endif
381
382
383 lwi r6, r6, TOPHYS(_MB_HW_ExceptionVectorTable)
384 bra r6
385
386full_exception_trapw:
387 RESTORE_STATE
388 bri full_exception_trap
389#else
390
391 mfs r6, rmsr;
392 nop
393 swi r6, r1, 0;
394 ori r6, r6, 0x100;
395 andi r6, r6, ~2;
396 mts rmsr, r6;
397 nop
398
399 xori r6, r5, 1;
400
401 beqi r6, handle_unaligned_ex;
402
403handle_other_ex:
404
405 swi r7, r1, PT_R7
406 swi r8, r1, PT_R8
407 swi r9, r1, PT_R9
408 swi r10, r1, PT_R10
409 swi r11, r1, PT_R11
410 swi r12, r1, PT_R12
411 swi r14, r1, PT_R14
412 swi r15, r1, PT_R15
413 swi r18, r1, PT_R18
414
415 or r5, r1, r0
416 andi r6, r4, 0x1F;
417 lwi r7, r0, PER_CPU(KM)
418 swi r7, r1, PT_MODE
419 mfs r7, rfsr
420 nop
421 addk r8, r17, r0;
422 bralid r15, full_exception;
423 nop;
424 mts rfsr, r0;
425 nop
426
427
428
429
430
431 mfs r5, rmsr;
432 nop
433 ori r5, r5, 2;
434 mts rmsr, r5;
435 nop
436 addi r12, r0, __NR_syscalls;
437 brki r14, 0x08;
438 mfs r5, rmsr;
439 nop
440 andi r5, r5, ~2;
441 mts rmsr, r5;
442 nop
443
444 lwi r7, r1, PT_R7
445 lwi r8, r1, PT_R8
446 lwi r9, r1, PT_R9
447 lwi r10, r1, PT_R10
448 lwi r11, r1, PT_R11
449 lwi r12, r1, PT_R12
450 lwi r14, r1, PT_R14
451 lwi r15, r1, PT_R15
452 lwi r18, r1, PT_R18
453
454 bri ex_handler_done;
455#endif
456
457
458
459
460
461
462
463
464handle_unaligned_ex:
465
466
467
468
469#ifdef CONFIG_MMU
470 andi r6, r4, 0x1000
471 beqi r6, _no_delayslot
472 mfs r17, rbtr;
473 nop
474_no_delayslot:
475
476 RESTORE_STATE;
477 bri unaligned_data_trap
478#endif
479 andi r6, r4, 0x3E0;
480 srl r6, r6;
481 srl r6, r6;
482 srl r6, r6;
483 srl r6, r6;
484 srl r6, r6;
485
486 sbi r6, r0, TOPHYS(ex_reg_op);
487
488 andi r6, r4, 0x400;
489 bnei r6, ex_sw;
490ex_lw:
491 andi r6, r4, 0x800;
492 beqi r6, ex_lhw;
493 lbui r5, r3, 0;
494
495
496 sbi r5, r0, TOPHYS(ex_tmp_data_loc_0);
497 lbui r5, r3, 1;
498 sbi r5, r0, TOPHYS(ex_tmp_data_loc_1);
499 lbui r5, r3, 2;
500 sbi r5, r0, TOPHYS(ex_tmp_data_loc_2);
501 lbui r5, r3, 3;
502 sbi r5, r0, TOPHYS(ex_tmp_data_loc_3);
503
504 lwi r4, r0, TOPHYS(ex_tmp_data_loc_0);
505 bri ex_lw_tail;
506ex_lhw:
507 lbui r5, r3, 0;
508
509
510 sbi r5, r0, TOPHYS(ex_tmp_data_loc_0);
511 lbui r5, r3, 1;
512 sbi r5, r0, TOPHYS(ex_tmp_data_loc_1);
513
514 lhui r4, r0, TOPHYS(ex_tmp_data_loc_0);
515ex_lw_tail:
516
517 lbui r5, r0, TOPHYS(ex_reg_op);
518
519 addik r6, r0, TOPHYS(lw_table);
520 addk r5, r5, r5;
521 addk r5, r5, r5;
522 addk r5, r5, r5;
523 addk r5, r5, r6;
524 bra r5;
525ex_lw_end:
526ex_sw:
527
528 lbui r5, r0, TOPHYS(ex_reg_op);
529
530 addik r6, r0, TOPHYS(sw_table);
531 add r5, r5, r5;
532 add r5, r5, r5;
533 add r5, r5, r5;
534 add r5, r5, r6;
535 bra r5;
536ex_sw_tail:
537 mfs r6, resr;
538 nop
539 andi r6, r6, 0x800;
540 beqi r6, ex_shw;
541
542 swi r4, r0, TOPHYS(ex_tmp_data_loc_0);
543
544 lbui r4, r0, TOPHYS(ex_tmp_data_loc_0);
545 sbi r4, r3, 0;
546 lbui r4, r0, TOPHYS(ex_tmp_data_loc_1);
547 sbi r4, r3, 1;
548 lbui r4, r0, TOPHYS(ex_tmp_data_loc_2);
549 sbi r4, r3, 2;
550 lbui r4, r0, TOPHYS(ex_tmp_data_loc_3);
551 sbi r4, r3, 3;
552 bri ex_handler_done;
553
554ex_shw:
555
556 swi r4, r0, TOPHYS(ex_tmp_data_loc_0);
557 lbui r4, r0, TOPHYS(ex_tmp_data_loc_2);
558 sbi r4, r3, 0;
559 lbui r4, r0, TOPHYS(ex_tmp_data_loc_3);
560 sbi r4, r3, 1;
561ex_sw_end:
562
563ex_handler_done:
564#ifndef CONFIG_MMU
565 lwi r5, r1, 0
566 mts rmsr, r5
567 nop
568 lwi r3, r1, PT_R3
569 lwi r4, r1, PT_R4
570 lwi r5, r1, PT_R5
571 lwi r6, r1, PT_R6
572 lwi r17, r1, PT_R17
573
574 rted r17, 0
575 addik r1, r1, (EX_HANDLER_STACK_SIZ);
576#else
577 RESTORE_STATE;
578 rted r17, 0
579 nop
580#endif
581
582#ifdef CONFIG_MMU
583
584
585
586
587
588
589
590
591
592
593
594 handle_data_storage_exception:
595
596
597
598 mfs r11, rpid
599 nop
600
601
602
603 ori r5, r0, CONFIG_KERNEL_START
604 cmpu r5, r3, r5
605 bgti r5, ex3
606
607
608
609
610 andi r4, r4, ESR_DIZ
611 bnei r4, ex2
612
613 ori r4, r0, swapper_pg_dir
614 mts rpid, r0
615 nop
616 bri ex4
617
618
619 ex3:
620
621
622
623
624 andi r4, r4, ESR_DIZ
625 bnei r4, ex2
626
627 addi r4 ,CURRENT_TASK, TOPHYS(0);
628 lwi r4, r4, TASK_THREAD+PGDIR
629 ex4:
630 tophys(r4,r4)
631
632 bsrli r5, r3, PGDIR_SHIFT - 2
633 andi r5, r5, PAGE_SIZE - 4
634
635 or r4, r4, r5
636 lwi r4, r4, 0
637 andi r5, r4, PAGE_MASK
638 beqi r5, ex2
639
640 tophys(r5,r5)
641 bsrli r6, r3, PTE_SHIFT
642 andi r6, r6, PAGE_SIZE - 4
643 or r5, r5, r6
644 lwi r4, r5, 0
645
646 andi r6, r4, _PAGE_RW
647 beqi r6, ex2
648
649
650 ori r4, r4, _PAGE_DIRTY|_PAGE_ACCESSED|_PAGE_HWWRITE
651 swi r4, r5, 0
652
653
654
655
656
657
658
659
660
661
662 andi r4, r4, PAGE_MASK | TLB_EX | TLB_WR | \
663 TLB_ZSEL(1) | TLB_ATTR_MASK
664 ori r4, r4, _PAGE_HWEXEC
665
666
667 mts rtlbsx, r3
668 nop
669 mfs r5, rtlbx
670 nop
671 mts rtlblo, r4
672 nop
673
674
675
676 mts rpid, r11
677 nop
678 bri 4
679
680 RESTORE_STATE;
681 rted r17, 0
682 nop
683 ex2:
684
685
686 mts rpid, r11
687 nop
688 bri 4
689 RESTORE_STATE;
690 bri page_fault_data_trap
691
692
693
694
695 handle_instruction_storage_exception:
696
697
698
699
700 RESTORE_STATE;
701 bri page_fault_instr_trap
702
703
704
705
706
707
708 handle_data_tlb_miss_exception:
709
710
711
712 mfs r11, rpid
713 nop
714
715
716
717 ori r6, r0, CONFIG_KERNEL_START
718 cmpu r4, r3, r6
719 bgti r4, ex5
720 ori r4, r0, swapper_pg_dir
721 mts rpid, r0
722 nop
723 bri ex6
724
725
726 ex5:
727
728 addi r4 ,CURRENT_TASK, TOPHYS(0);
729 lwi r4, r4, TASK_THREAD+PGDIR
730 ex6:
731 tophys(r4,r4)
732
733 bsrli r5, r3, PGDIR_SHIFT - 2
734 andi r5, r5, PAGE_SIZE - 4
735
736 or r4, r4, r5
737 lwi r4, r4, 0
738 andi r5, r4, PAGE_MASK
739 beqi r5, ex7
740
741 tophys(r5,r5)
742 bsrli r6, r3, PTE_SHIFT
743 andi r6, r6, PAGE_SIZE - 4
744 or r5, r5, r6
745 lwi r4, r5, 0
746
747 andi r6, r4, _PAGE_PRESENT
748 beqi r6, ex7
749
750 ori r4, r4, _PAGE_ACCESSED
751 swi r4, r5, 0
752
753
754
755
756
757
758
759
760
761 brid finish_tlb_load
762 andi r4, r4, PAGE_MASK | TLB_EX | TLB_WR | \
763 TLB_ZSEL(1) | TLB_ATTR_MASK
764 ex7:
765
766
767
768 mts rpid, r11
769 nop
770 bri 4
771 RESTORE_STATE;
772 bri page_fault_data_trap
773
774
775
776
777
778 handle_instruction_tlb_miss_exception:
779
780
781
782 mfs r11, rpid
783 nop
784
785
786
787
788 ori r4, r0, CONFIG_KERNEL_START
789 cmpu r4, r3, r4
790 bgti r4, ex8
791 ori r4, r0, swapper_pg_dir
792 mts rpid, r0
793 nop
794 bri ex9
795
796
797 ex8:
798
799 addi r4 ,CURRENT_TASK, TOPHYS(0);
800 lwi r4, r4, TASK_THREAD+PGDIR
801 ex9:
802 tophys(r4,r4)
803
804 bsrli r5, r3, PGDIR_SHIFT - 2
805 andi r5, r5, PAGE_SIZE - 4
806
807 or r4, r4, r5
808 lwi r4, r4, 0
809 andi r5, r4, PAGE_MASK
810 beqi r5, ex10
811
812 tophys(r5,r5)
813 bsrli r6, r3, PTE_SHIFT
814 andi r6, r6, PAGE_SIZE - 4
815 or r5, r5, r6
816 lwi r4, r5, 0
817
818 andi r6, r4, _PAGE_PRESENT
819 beqi r6, ex10
820
821 ori r4, r4, _PAGE_ACCESSED
822 swi r4, r5, 0
823
824
825
826
827
828
829
830
831
832 brid finish_tlb_load
833 andi r4, r4, PAGE_MASK | TLB_EX | TLB_WR | \
834 TLB_ZSEL(1) | TLB_ATTR_MASK
835 ex10:
836
837
838
839 mts rpid, r11
840 nop
841 bri 4
842 RESTORE_STATE;
843 bri page_fault_instr_trap
844
845
846
847
848
849
850
851
852
853.section .data
854.align 4
855.global tlb_skip
856 tlb_skip:
857 .long MICROBLAZE_TLB_SKIP
858 tlb_index:
859
860 .long MICROBLAZE_TLB_SIZE/2
861.previous
862 finish_tlb_load:
863
864 lwi r5, r0, TOPHYS(tlb_index)
865 addik r5, r5, 1
866
867
868 andi r5, r5, MICROBLAZE_TLB_SIZE - 1
869 ori r6, r0, 1
870 cmp r31, r5, r6
871 blti r31, ex12
872 lwi r5, r0, TOPHYS(tlb_skip)
873 ex12:
874
875 swi r5, r0, TOPHYS(tlb_index)
876
877 ori r4, r4, _PAGE_HWEXEC
878 mts rtlbx, r5
879 nop
880 mts rtlblo, r4
881 nop
882
883
884
885
886
887 andi r3, r3, PAGE_MASK
888#ifdef CONFIG_MICROBLAZE_64K_PAGES
889 ori r3, r3, TLB_VALID | TLB_PAGESZ(PAGESZ_64K)
890
891 ori r3, r3, TLB_VALID | TLB_PAGESZ(PAGESZ_16K)
892#else
893 ori r3, r3, TLB_VALID | TLB_PAGESZ(PAGESZ_4K)
894#endif
895 mts rtlbhi, r3
896 nop
897
898
899 mts rpid, r11
900 nop
901 bri 4
902 RESTORE_STATE;
903 rted r17, 0
904 nop
905
906
907
908
909
910
911 .globl giveup_fpu;
912 .align 4;
913 giveup_fpu:
914 bralid r15,0
915 nop
916
917
918 .globl abort;
919 .align 4;
920 abort:
921 br r0
922
923 .globl set_context;
924 .align 4;
925 set_context:
926 mts rpid, r5
927 nop
928 bri 4
929 rtsd r15,8
930 nop
931
932#endif
933.end _hw_exception_handler
934
935#ifdef CONFIG_MMU
936
937
938
939
940
941
942
943
944
945
946.global _unaligned_data_exception
947.ent _unaligned_data_exception
948_unaligned_data_exception:
949 andi r8, r3, 0x3E0;
950 bsrli r8, r8, 2;
951 andi r6, r3, 0x400;
952 bneid r6, ex_sw_vm;
953 andi r6, r3, 0x800;
954ex_lw_vm:
955 beqid r6, ex_lhw_vm;
956load1: lbui r5, r4, 0;
957
958 addik r6, r0, ex_tmp_data_loc_0;
959 sbi r5, r6, 0;
960load2: lbui r5, r4, 1;
961 sbi r5, r6, 1;
962load3: lbui r5, r4, 2;
963 sbi r5, r6, 2;
964load4: lbui r5, r4, 3;
965 sbi r5, r6, 3;
966 brid ex_lw_tail_vm;
967
968 lwi r3, r6, 0;
969ex_lhw_vm:
970
971
972 addik r6, r0, ex_tmp_data_loc_0;
973 sbi r5, r6, 0;
974load5: lbui r5, r4, 1;
975 sbi r5, r6, 1;
976 lhui r3, r6, 0;
977ex_lw_tail_vm:
978
979 addik r5, r8, lw_table_vm;
980 bra r5;
981ex_lw_end_vm:
982 brai ret_from_exc;
983ex_sw_vm:
984
985 addik r5, r8, sw_table_vm;
986 bra r5;
987ex_sw_tail_vm:
988 addik r5, r0, ex_tmp_data_loc_0;
989 beqid r6, ex_shw_vm;
990 swi r3, r5, 0;
991
992 lbui r3, r5, 0;
993store1: sbi r3, r4, 0;
994 lbui r3, r5, 1;
995store2: sbi r3, r4, 1;
996 lbui r3, r5, 2;
997store3: sbi r3, r4, 2;
998 lbui r3, r5, 3;
999 brid ret_from_exc;
1000store4: sbi r3, r4, 3;
1001ex_shw_vm:
1002
1003#ifdef __MICROBLAZEEL__
1004 lbui r3, r5, 0;
1005store5: sbi r3, r4, 0;
1006 lbui r3, r5, 1;
1007 brid ret_from_exc;
1008store6: sbi r3, r4, 1;
1009#else
1010 lbui r3, r5, 2;
1011store5: sbi r3, r4, 0;
1012 lbui r3, r5, 3;
1013 brid ret_from_exc;
1014store6: sbi r3, r4, 1;
1015#endif
1016
1017ex_sw_end_vm:
1018
1019
1020
1021
1022
1023ex_unaligned_fixup:
1024 ori r5, r7, 0
1025 lwi r6, r7, PT_PC;
1026 addik r6, r6, -4
1027 swi r6, r7, PT_PC;
1028 addik r7, r0, SIGSEGV
1029
1030
1031 addik r15, r0, ret_from_exc-8
1032 brid bad_page_fault
1033 nop
1034
1035
1036.section __ex_table,"a";
1037 .word load1,ex_unaligned_fixup;
1038 .word load2,ex_unaligned_fixup;
1039 .word load3,ex_unaligned_fixup;
1040 .word load4,ex_unaligned_fixup;
1041 .word load5,ex_unaligned_fixup;
1042 .word store1,ex_unaligned_fixup;
1043 .word store2,ex_unaligned_fixup;
1044 .word store3,ex_unaligned_fixup;
1045 .word store4,ex_unaligned_fixup;
1046 .word store5,ex_unaligned_fixup;
1047 .word store6,ex_unaligned_fixup;
1048.previous;
1049.end _unaligned_data_exception
1050#endif
1051
1052.global ex_handler_unhandled
1053ex_handler_unhandled:
1054
1055 bri 0
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065.section .text
1066.align 4
1067lw_table:
1068lw_r0: R3_TO_LWREG (0);
1069lw_r1: LWREG_NOP;
1070lw_r2: R3_TO_LWREG (2);
1071lw_r3: R3_TO_LWREG_V (3);
1072lw_r4: R3_TO_LWREG_V (4);
1073lw_r5: R3_TO_LWREG_V (5);
1074lw_r6: R3_TO_LWREG_V (6);
1075lw_r7: R3_TO_LWREG (7);
1076lw_r8: R3_TO_LWREG (8);
1077lw_r9: R3_TO_LWREG (9);
1078lw_r10: R3_TO_LWREG (10);
1079lw_r11: R3_TO_LWREG (11);
1080lw_r12: R3_TO_LWREG (12);
1081lw_r13: R3_TO_LWREG (13);
1082lw_r14: R3_TO_LWREG (14);
1083lw_r15: R3_TO_LWREG (15);
1084lw_r16: R3_TO_LWREG (16);
1085lw_r17: LWREG_NOP;
1086lw_r18: R3_TO_LWREG (18);
1087lw_r19: R3_TO_LWREG (19);
1088lw_r20: R3_TO_LWREG (20);
1089lw_r21: R3_TO_LWREG (21);
1090lw_r22: R3_TO_LWREG (22);
1091lw_r23: R3_TO_LWREG (23);
1092lw_r24: R3_TO_LWREG (24);
1093lw_r25: R3_TO_LWREG (25);
1094lw_r26: R3_TO_LWREG (26);
1095lw_r27: R3_TO_LWREG (27);
1096lw_r28: R3_TO_LWREG (28);
1097lw_r29: R3_TO_LWREG (29);
1098lw_r30: R3_TO_LWREG (30);
1099#ifdef CONFIG_MMU
1100lw_r31: R3_TO_LWREG_V (31);
1101#else
1102lw_r31: R3_TO_LWREG (31);
1103#endif
1104
1105sw_table:
1106sw_r0: SWREG_TO_R3 (0);
1107sw_r1: SWREG_NOP;
1108sw_r2: SWREG_TO_R3 (2);
1109sw_r3: SWREG_TO_R3_V (3);
1110sw_r4: SWREG_TO_R3_V (4);
1111sw_r5: SWREG_TO_R3_V (5);
1112sw_r6: SWREG_TO_R3_V (6);
1113sw_r7: SWREG_TO_R3 (7);
1114sw_r8: SWREG_TO_R3 (8);
1115sw_r9: SWREG_TO_R3 (9);
1116sw_r10: SWREG_TO_R3 (10);
1117sw_r11: SWREG_TO_R3 (11);
1118sw_r12: SWREG_TO_R3 (12);
1119sw_r13: SWREG_TO_R3 (13);
1120sw_r14: SWREG_TO_R3 (14);
1121sw_r15: SWREG_TO_R3 (15);
1122sw_r16: SWREG_TO_R3 (16);
1123sw_r17: SWREG_NOP;
1124sw_r18: SWREG_TO_R3 (18);
1125sw_r19: SWREG_TO_R3 (19);
1126sw_r20: SWREG_TO_R3 (20);
1127sw_r21: SWREG_TO_R3 (21);
1128sw_r22: SWREG_TO_R3 (22);
1129sw_r23: SWREG_TO_R3 (23);
1130sw_r24: SWREG_TO_R3 (24);
1131sw_r25: SWREG_TO_R3 (25);
1132sw_r26: SWREG_TO_R3 (26);
1133sw_r27: SWREG_TO_R3 (27);
1134sw_r28: SWREG_TO_R3 (28);
1135sw_r29: SWREG_TO_R3 (29);
1136sw_r30: SWREG_TO_R3 (30);
1137#ifdef CONFIG_MMU
1138sw_r31: SWREG_TO_R3_V (31);
1139#else
1140sw_r31: SWREG_TO_R3 (31);
1141#endif
1142
1143#ifdef CONFIG_MMU
1144lw_table_vm:
1145lw_r0_vm: R3_TO_LWREG_VM (0);
1146lw_r1_vm: R3_TO_LWREG_VM_V (1);
1147lw_r2_vm: R3_TO_LWREG_VM_V (2);
1148lw_r3_vm: R3_TO_LWREG_VM_V (3);
1149lw_r4_vm: R3_TO_LWREG_VM_V (4);
1150lw_r5_vm: R3_TO_LWREG_VM_V (5);
1151lw_r6_vm: R3_TO_LWREG_VM_V (6);
1152lw_r7_vm: R3_TO_LWREG_VM_V (7);
1153lw_r8_vm: R3_TO_LWREG_VM_V (8);
1154lw_r9_vm: R3_TO_LWREG_VM_V (9);
1155lw_r10_vm: R3_TO_LWREG_VM_V (10);
1156lw_r11_vm: R3_TO_LWREG_VM_V (11);
1157lw_r12_vm: R3_TO_LWREG_VM_V (12);
1158lw_r13_vm: R3_TO_LWREG_VM_V (13);
1159lw_r14_vm: R3_TO_LWREG_VM_V (14);
1160lw_r15_vm: R3_TO_LWREG_VM_V (15);
1161lw_r16_vm: R3_TO_LWREG_VM_V (16);
1162lw_r17_vm: R3_TO_LWREG_VM_V (17);
1163lw_r18_vm: R3_TO_LWREG_VM_V (18);
1164lw_r19_vm: R3_TO_LWREG_VM_V (19);
1165lw_r20_vm: R3_TO_LWREG_VM_V (20);
1166lw_r21_vm: R3_TO_LWREG_VM_V (21);
1167lw_r22_vm: R3_TO_LWREG_VM_V (22);
1168lw_r23_vm: R3_TO_LWREG_VM_V (23);
1169lw_r24_vm: R3_TO_LWREG_VM_V (24);
1170lw_r25_vm: R3_TO_LWREG_VM_V (25);
1171lw_r26_vm: R3_TO_LWREG_VM_V (26);
1172lw_r27_vm: R3_TO_LWREG_VM_V (27);
1173lw_r28_vm: R3_TO_LWREG_VM_V (28);
1174lw_r29_vm: R3_TO_LWREG_VM_V (29);
1175lw_r30_vm: R3_TO_LWREG_VM_V (30);
1176lw_r31_vm: R3_TO_LWREG_VM_V (31);
1177
1178sw_table_vm:
1179sw_r0_vm: SWREG_TO_R3_VM (0);
1180sw_r1_vm: SWREG_TO_R3_VM_V (1);
1181sw_r2_vm: SWREG_TO_R3_VM_V (2);
1182sw_r3_vm: SWREG_TO_R3_VM_V (3);
1183sw_r4_vm: SWREG_TO_R3_VM_V (4);
1184sw_r5_vm: SWREG_TO_R3_VM_V (5);
1185sw_r6_vm: SWREG_TO_R3_VM_V (6);
1186sw_r7_vm: SWREG_TO_R3_VM_V (7);
1187sw_r8_vm: SWREG_TO_R3_VM_V (8);
1188sw_r9_vm: SWREG_TO_R3_VM_V (9);
1189sw_r10_vm: SWREG_TO_R3_VM_V (10);
1190sw_r11_vm: SWREG_TO_R3_VM_V (11);
1191sw_r12_vm: SWREG_TO_R3_VM_V (12);
1192sw_r13_vm: SWREG_TO_R3_VM_V (13);
1193sw_r14_vm: SWREG_TO_R3_VM_V (14);
1194sw_r15_vm: SWREG_TO_R3_VM_V (15);
1195sw_r16_vm: SWREG_TO_R3_VM_V (16);
1196sw_r17_vm: SWREG_TO_R3_VM_V (17);
1197sw_r18_vm: SWREG_TO_R3_VM_V (18);
1198sw_r19_vm: SWREG_TO_R3_VM_V (19);
1199sw_r20_vm: SWREG_TO_R3_VM_V (20);
1200sw_r21_vm: SWREG_TO_R3_VM_V (21);
1201sw_r22_vm: SWREG_TO_R3_VM_V (22);
1202sw_r23_vm: SWREG_TO_R3_VM_V (23);
1203sw_r24_vm: SWREG_TO_R3_VM_V (24);
1204sw_r25_vm: SWREG_TO_R3_VM_V (25);
1205sw_r26_vm: SWREG_TO_R3_VM_V (26);
1206sw_r27_vm: SWREG_TO_R3_VM_V (27);
1207sw_r28_vm: SWREG_TO_R3_VM_V (28);
1208sw_r29_vm: SWREG_TO_R3_VM_V (29);
1209sw_r30_vm: SWREG_TO_R3_VM_V (30);
1210sw_r31_vm: SWREG_TO_R3_VM_V (31);
1211#endif
1212
1213
1214.section .data
1215.align 4
1216ex_tmp_data_loc_0:
1217 .byte 0
1218ex_tmp_data_loc_1:
1219 .byte 0
1220ex_tmp_data_loc_2:
1221 .byte 0
1222ex_tmp_data_loc_3:
1223 .byte 0
1224ex_reg_op:
1225 .byte 0
1226