also update spec file ...
[linux-flexiantxendom0-3.2.10.git] / arch / mips64 / kernel / r4k_genex.S
1 /*
2  * This file is subject to the terms and conditions of the GNU General Public
3  * License.  See the file "COPYING" in the main directory of this archive
4  * for more details.
5  *
6  * Copyright (C) 1994 - 1999 by Ralf Baechle
7  * Copyright (C) 1999 Silicon Graphics
8  * Copyright (C) 2002  Maciej W. Rozycki
9  *
10  * Low level exception handling
11  */
12 #include <linux/init.h>
13 #include <asm/asm.h>
14 #include <asm/regdef.h>
15 #include <asm/fpregdef.h>
16 #include <asm/mipsregs.h>
17 #include <asm/stackframe.h>
18 #include <asm/exception.h>
19 #include <asm/cacheops.h>
20
21         BUILD_HANDLER adel ade ade silent               /* #4  */
22         BUILD_HANDLER ades ade ade silent               /* #5  */
23         BUILD_HANDLER ibe be cli silent                 /* #6  */
24         BUILD_HANDLER dbe be cli silent                 /* #7  */
25         BUILD_HANDLER bp bp sti silent                  /* #9  */
26         BUILD_HANDLER ri ri sti silent                  /* #10 */
27         BUILD_HANDLER cpu cpu sti silent                /* #11 */
28         BUILD_HANDLER ov ov sti silent                  /* #12 */
29         BUILD_HANDLER tr tr sti silent                  /* #13 */
30         BUILD_HANDLER fpe fpe fpe silent                /* #15 */
31         BUILD_HANDLER mdmx mdmx sti silent              /* #22 */
32         BUILD_HANDLER watch watch sti verbose           /* #23 */
33         BUILD_HANDLER mcheck mcheck cli verbose         /* #24 */
34         BUILD_HANDLER reserved reserved sti verbose     /* others */
35
36
37         __INIT
38
39 /* A temporary overflow handler used by check_daddi(). */
40
41         BUILD_HANDLER  daddi_ov daddi_ov none silent    /* #12 */
42
43
44 /* General exception handler for CPUs with virtual coherency exception.
45  *
46  * Be careful when changing this, it has to be at most 256 (as a special
47  * exception) bytes to fit into space reserved for the exception handler.
48  */
49         .set    push
50         .set    noat
51 NESTED(except_vec3_r4000, 0, sp)
52         mfc0    k1, CP0_CAUSE
53         li      k0, 31<<2
54         andi    k1, k1, 0x7c
55         .set    push
56         .set    noreorder
57         .set    nomacro
58         beq     k1, k0, handle_vced
59          li     k0, 14<<2
60         beq     k1, k0, handle_vcei
61          dsll   k1, k1, 1
62         .set    pop
63         ld      k0, exception_handlers(k1)
64         jr      k0
65
66 /*
67  * Big shit, we now may have two dirty primary cache lines for the same
68  * physical address.  We can savely invalidate the line pointed to by
69  * c0_badvaddr because after return from this exception handler the load /
70  * store will be re-executed.
71  */
72 handle_vced:
73         dmfc0   k0, CP0_BADVADDR
74         li      k1, -4                                  # Is this ...
75         and     k0, k1                                  # ... really needed?
76         mtc0    zero, CP0_TAGLO
77         cache   Index_Store_Tag_D,(k0)
78         cache   Hit_Writeback_Inv_SD,(k0)
79         dla     k0, vced_count
80         lw      k1, (k0)
81         addiu   k1, 1
82         sw      k1, (k0)
83         eret
84
85 handle_vcei:
86         dmfc0   k0, CP0_BADVADDR
87         cache   Hit_Writeback_Inv_SD,(k0)               # also cleans pi
88         dla     k0, vcei_count
89         lw      k1, (k0)
90         addiu   k1, 1
91         sw      k1, (k0)
92         eret
93 END(except_vec3_r4000)
94         .set    pop
95
96
97 /* General exception vector for all other CPUs.
98  *
99  * Be careful when changing this, it has to be at most 128 bytes
100  * to fit into space reserved for the exception handler.
101  */
102         .set    push
103         .set    noat
104 NESTED(except_vec3_generic, 0, sp)
105 #if R5432_CP0_INTERRUPT_WAR
106         mfc0    k0, CP0_INDEX
107 #endif
108         mfc0    k1, CP0_CAUSE
109         andi    k1, k1, 0x7c
110         dsll    k1, k1, 1
111         ld      k0, exception_handlers(k1)
112         jr      k0
113 END(except_vec3_generic)
114         .set    pop
115
116
117 /*
118  * Special interrupt vector for MIPS64 ISA & embedded MIPS processors.
119  * This is a dedicated interrupt exception vector which reduces the
120  * interrupt processing overhead.  The jump instruction will be replaced
121  * at the initialization time.
122  *
123  * Be careful when changing this, it has to be at most 128 bytes
124  * to fit into space reserved for the exception handler.
125  */
126 NESTED(except_vec4, 0, sp)
127 1:      j       1b                      /* Dummy, will be replaced */
128 END(except_vec4)
129
130         /*
131          * EJTAG debug exception handler.
132          * The EJTAG debug exception entry point is 0xbfc00480, which
133          * normally is in the boot PROM, so the boot PROM must do a
134          * unconditional jump to this vector.
135          */
136 NESTED(except_vec_ejtag_debug, 0, sp)
137         j       ejtag_debug_handler
138          nop
139         END(except_vec_ejtag_debug)
140
141         __FINIT
142
143                 /*
144                  * EJTAG debug exception handler.
145                  */
146                 NESTED(ejtag_debug_handler, PT_SIZE, sp)
147                 .set    noat
148                 .set    noreorder
149                 mtc0    k0, CP0_DESAVE
150                 mfc0    k0, CP0_DEBUG
151
152                 sll     k0, k0, 30      # Check for SDBBP.
153                 bgez    k0, ejtag_return
154
155                 la      k0, ejtag_debug_buffer
156                 sw      k1, 0(k0)
157                 SAVE_ALL
158                 jal     ejtag_exception_handler
159                  move   a0, sp
160                 RESTORE_ALL
161                 la      k0, ejtag_debug_buffer
162                 lw      k1, 0(k0)
163
164 ejtag_return:
165                 mfc0    k0, CP0_DESAVE
166                 .set    mips32
167                 deret
168                 .set    mips0
169                  nop
170                 .set    at
171                 END(ejtag_debug_handler)
172
173                 /*
174                  * This buffer is reserved for the use of the EJTAG debug
175                  * handler.
176                  */
177                 .data
178                 EXPORT(ejtag_debug_buffer)
179                 .fill   8