]> rtime.felk.cvut.cz Git - arc.git/blob - arch/ppc/mpc55xx/drivers/Mcu_Exceptions.sx
Again, loads of refactoring and removing and adding files.
[arc.git] / arch / ppc / mpc55xx / drivers / Mcu_Exceptions.sx
1 \r
2 #define _ASSEMBLER_\r
3 #include "asm_ppc.h"\r
4 #include "asm_book_e.h"\r
5 #ifdef USE_KERNEL\r
6 #include "asm_offset.h"\r
7 #endif\r
8 \r
9 #define  INTC_IACKR  0xfff48010\r
10 #define  INTC_EOIR   0xfff48018\r
11 \r
12 #define SIU_MIDR    0xfffe8004\r
13 #define SIMULATOR(_reg,_inst,_label)   \\r
14          lis    _reg, SIU_MIDR@ha; \\r
15          lwz    _reg, SIU_MIDR@l(_reg); \\r
16          cmpwi  0,_reg,0; \\r
17          _inst    _label;\r
18 \r
19                 .section .text\r
20 //---------------------------------------------------------------\r
21 // just a small decrementer exception to trigger soft interrupt\r
22 // in the INTC( simluator addon )\r
23 \r
24 \r
25                 #define INTC_SSCIR7 0xFFF48027\r
26                 .global dec_exception\r
27 \r
28 dec_exception:\r
29     stwu        r3,-8(sp)\r
30     stw         r4,4(sp)\r
31 \r
32     # ack dec int\r
33     lis         r3,0x0800\r
34     mtspr   SPR_TSR,r3\r
35 \r
36     # Set soft int\r
37     li          r4,2\r
38     lis     r3, INTC_SSCIR7@ha\r
39     stb     r4, INTC_SSCIR7@l(r3)\r
40 \r
41     lwz     r3,0(sp)\r
42     lwz     r4,4(sp)\r
43     addi        sp,sp,8\r
44     rfi\r
45 \r
46 \r
47 EXCEPTION_CSRRx(exception_IVOR0,320)    //#CRITICAL_INPUT_EXCEPTION\r
48 EXCEPTION_CSRRx(exception_IVOR1,321)    //#MACHINE_CHECK_EXCEPTION\r
49 EXCEPTION_SRRx(exception_IVOR2,322)     //#DATA_STORAGE_EXCEPTION\r
50 EXCEPTION_SRRx(exception_IVOR3,323)     //#INSTRUCTION_STORAGE_EXCEPTION\r
51 // IVOR4, defined elsewhere\r
52 EXCEPTION_SRRx(exception_IVOR5,325)     //#ALIGNMENT_EXCEPTION\r
53 EXCEPTION_SRRx(exception_IVOR6,326)     //#PROGRAM_EXCEPTION\r
54 EXCEPTION_SRRx(exception_IVOR7,327)     //#FLOATING_POINT_EXCEPTION\r
55 EXCEPTION_SRRx(exception_IVOR8,328)     //#SYSTEM_CALL_EXCEPTION)\r
56 EXCEPTION_SRRx(exception_IVOR9,329)\r
57 // IVOR10, defined elsewhere\r
58 EXCEPTION_SRRx(exception_IVOR11,331)    //#FIXED_INTERVAL_TIMER_EXCEPTION\r
59 EXCEPTION_SRRx(exception_IVOR12,332)    //#WATCHDOG_TIMER_EXCEPTION\r
60 EXCEPTION_SRRx(exception_IVOR13,333)    //#DATA_TLB_EXCEPTION\r
61 EXCEPTION_SRRx(exception_IVOR14,334)    //#INSTRUCTION_TLB_EXCEPTION\r
62 \r
63 \r
64 //\r
65 //   EXC_FRAME\r
66 //   VGPR_FRAME\r
67 //  NVGPR_FRAME\r
68 //\r
69 \r
70                 .global exception_IVOR4\r
71                 .global os_lc_restore\r
72                 .balign 16\r
73 exception_IVOR4:\r
74 \r
75         SAVE_WORK_AND_MORE\r
76         // Save registers NOT preserved by functions\r
77         SAVE_VGPR(1,C_SIZE);\r
78         // Save registers preserved by functions\r
79         addi    r1,r1,C_SIZE\r
80         SAVE_NVGPR(1,0);\r
81         addi    r1,r1,-C_SIZE\r
82 \r
83         // TODO: Why 0, can't remember\r
84     li    r3,0\r
85     stw   r3,EXC_VECTOR_OFF(r4)\r
86         mr        r4,r1         // save stack\r
87 \r
88 #ifdef USE_KERNEL\r
89         li              r3,LC_PATTERN\r
90         stw             r3,C_CONTEXT_OFF(sp)\r
91 \r
92         // Switch to interrupt stack if at depth 0\r
93         LOAD_IND_32(3,os_sys+SYS_INT_NEST_CNT)\r
94         cmpli   0,r3,0\r
95         bne-    on_int_stack\r
96         // Load the interrupt stack\r
97         LOAD_IND_32(sp,os_sys+SYS_INT_STACK)\r
98 on_int_stack:\r
99 \r
100 #endif\r
101 \r
102     lis   r3, Irq_Entry@h\r
103     ori   r3, r3,Irq_Entry@l\r
104 \r
105     mtlr  r3\r
106     mr    r3,r4  /* "old" stack as arg1 */\r
107     blrl\r
108 \r
109 #ifdef USE_KERNEL\r
110 // Set the retun value as new stack\r
111         mr              sp,r3\r
112 #endif\r
113         addi    r1,r1,C_SIZE\r
114         RESTORE_NVGPR(1,0)\r
115         addi    r1,r1,-C_SIZE\r
116         RESTORE_VGPR(1,C_SIZE)\r
117 \r
118         RESTORE_WORK_AND_MORE\r
119         rfi\r
120 \r
121 bad_int:\r
122         b bad_int\r
123 \r
124 # Force this jump table to this address to match the\r
125 # value written to z1 IVPR\r
126 .section ".exception_tbl","ax"\r
127 .balign 0x0800  //TODO: 1000 eller 800?\r
128 .global exception_tbl\r
129 \r
130 # The .skip directive aligns the branch instructions\r
131 #   to the irq vector offsets\r
132 exception_tbl:\r
133     b      exception_IVOR0\r
134     .skip   +0xc\r
135     b      exception_IVOR1\r
136     .skip   +0xc\r
137     b      exception_IVOR2\r
138     .skip   +0xc\r
139     b      exception_IVOR3\r
140     .skip   +0xc\r
141     b      exception_IVOR4\r
142     .skip   +0xc\r
143     b      exception_IVOR5\r
144     .skip   +0xc\r
145     b      exception_IVOR6\r
146     .skip   +0xc\r
147     b      exception_IVOR7\r
148     .skip   +0xc\r
149     b      exception_IVOR8\r
150     .skip   +0xc\r
151     b      exception_IVOR9\r
152     .skip   +0xc\r
153     b      dec_exception\r
154     //b    exception_IVOR10\r
155     .skip   +0xc\r
156     b      exception_IVOR11\r
157     .skip   +0xc\r
158     b      exception_IVOR12\r
159     .skip   +0xc\r
160     b      exception_IVOR13\r
161     .skip   +0xc\r
162     b      exception_IVOR14\r
163     .skip   +0xc\r
164     b      bad_int\r