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