1 /* entry-table.S: main trap vector tables and exception jump table
3 * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
13 #include <linux/sys.h>
14 #include <linux/config.h>
15 #include <linux/linkage.h>
16 #include <asm/spr-regs.h>
18 ###############################################################################
20 # Declare the main trap and vector tables
22 # There are six tables:
24 # (1) The trap table for debug mode
25 # (2) The trap table for kernel mode
26 # (3) The trap table for user mode
28 # The CPU jumps to an appropriate slot in the appropriate table to perform
29 # exception processing. We have three different tables for the three
30 # different CPU modes because there is no hardware differentiation between
31 # stack pointers for these three modes, and so we have to invent one when
32 # crossing mode boundaries.
34 # (4) The exception handler vector table
36 # The user and kernel trap tables use the same prologue for normal
37 # exception processing. The prologue then jumps to the handler in this
38 # table, as indexed by the exception ID from the TBR.
40 # (5) The fixup table for kernel-trap single-step
41 # (6) The fixup table for user-trap single-step
43 # Due to the way single-stepping works on this CPU (single-step is not
44 # disabled when crossing exception boundaries, only when in debug mode),
45 # we have to catch the single-step event in break.S and jump to the fixup
46 # routine pointed to by this table.
48 # The linker script places the user mode and kernel mode trap tables on to
49 # the same 8Kb page, so that break.S can be more efficient when performing
50 # single-step bypass management
52 ###############################################################################
54 # trap table for entry from debug mode
55 .section .trap.break,"ax"
57 .globl __entry_breaktrap_table
58 __entry_breaktrap_table:
60 # trap table for entry from user mode
61 .section .trap.user,"ax"
63 .globl __entry_usertrap_table
64 __entry_usertrap_table:
66 # trap table for entry from kernel mode
67 .section .trap.kernel,"ax"
69 .globl __entry_kerneltrap_table
70 __entry_kerneltrap_table:
72 # exception handler jump table
73 .section .trap.vector,"ax"
75 .globl __entry_vector_table
78 # trap fixup table for single-stepping in user mode
79 .section .trap.fixup.user,"a"
81 .globl __break_usertrap_fixup_table
82 __break_usertrap_fixup_table:
84 # trap fixup table for single-stepping in user mode
85 .section .trap.fixup.kernel,"a"
87 .globl __break_kerneltrap_fixup_table
88 __break_kerneltrap_fixup_table:
90 # handler declaration for a sofware or program interrupt
91 .macro VECTOR_SOFTPROG tbr_tt, vec
94 bra __entry_uspace_softprog_interrupt
95 .section .trap.fixup.user
97 .long __break_step_uspace_softprog_interrupt
100 bra __entry_kernel_softprog_interrupt
101 .section .trap.fixup.kernel
103 .long __break_step_kernel_softprog_interrupt
104 .section .trap.vector
109 # handler declaration for a maskable external interrupt
110 .macro VECTOR_IRQ tbr_tt, vec
113 bra __entry_uspace_external_interrupt
114 .section .trap.fixup.user
116 .long __break_step_uspace_external_interrupt
117 .section .trap.kernel
119 # deal with virtual interrupt disablement
120 beq icc2,#0,__entry_kernel_external_interrupt_virtually_disabled
121 bra __entry_kernel_external_interrupt
122 .section .trap.fixup.kernel
124 .long __break_step_kernel_external_interrupt
125 .section .trap.vector
130 # handler declaration for an NMI external interrupt
131 .macro VECTOR_NMI tbr_tt, vec
138 .section .trap.kernel
144 .section .trap.vector
149 # handler declaration for an MMU only sofware or program interrupt
150 .macro VECTOR_SP_MMU tbr_tt, vec
152 VECTOR_SOFTPROG \tbr_tt, \vec
154 VECTOR_NMI \tbr_tt, 0
159 ###############################################################################
161 # specification of the vectors
162 # - note: each macro inserts code into multiple sections
164 ###############################################################################
165 VECTOR_SP_MMU TBR_TT_INSTR_MMU_MISS, __entry_insn_mmu_miss
166 VECTOR_SOFTPROG TBR_TT_INSTR_ACC_ERROR, __entry_insn_access_error
167 VECTOR_SOFTPROG TBR_TT_INSTR_ACC_EXCEP, __entry_insn_access_exception
168 VECTOR_SOFTPROG TBR_TT_PRIV_INSTR, __entry_privileged_instruction
169 VECTOR_SOFTPROG TBR_TT_ILLEGAL_INSTR, __entry_illegal_instruction
170 VECTOR_SOFTPROG TBR_TT_FP_EXCEPTION, __entry_media_exception
171 VECTOR_SOFTPROG TBR_TT_MP_EXCEPTION, __entry_media_exception
172 VECTOR_SOFTPROG TBR_TT_DATA_ACC_ERROR, __entry_data_access_error
173 VECTOR_SP_MMU TBR_TT_DATA_MMU_MISS, __entry_data_mmu_miss
174 VECTOR_SOFTPROG TBR_TT_DATA_ACC_EXCEP, __entry_data_access_exception
175 VECTOR_SOFTPROG TBR_TT_DATA_STR_ERROR, __entry_data_store_error
176 VECTOR_SOFTPROG TBR_TT_DIVISION_EXCEP, __entry_division_exception
180 .org TBR_TT_INSTR_TLB_MISS
181 .globl __trap_user_insn_tlb_miss
182 __trap_user_insn_tlb_miss:
183 movsg ear0,gr28 /* faulting address */
184 movsg scr0,gr31 /* get mapped PTD coverage start address */
185 xor.p gr28,gr31,gr31 /* compare addresses */
186 bra __entry_user_insn_tlb_miss
188 .org TBR_TT_DATA_TLB_MISS
189 .globl __trap_user_data_tlb_miss
190 __trap_user_data_tlb_miss:
191 movsg ear0,gr28 /* faulting address */
192 movsg scr1,gr31 /* get mapped PTD coverage start address */
193 xor.p gr28,gr31,gr31 /* compare addresses */
194 bra __entry_user_data_tlb_miss
196 .section .trap.kernel
197 .org TBR_TT_INSTR_TLB_MISS
198 .globl __trap_kernel_insn_tlb_miss
199 __trap_kernel_insn_tlb_miss:
200 movsg ear0,gr29 /* faulting address */
201 movsg scr0,gr31 /* get mapped PTD coverage start address */
202 xor.p gr29,gr31,gr31 /* compare addresses */
203 bra __entry_kernel_insn_tlb_miss
205 .org TBR_TT_DATA_TLB_MISS
206 .globl __trap_kernel_data_tlb_miss
207 __trap_kernel_data_tlb_miss:
208 movsg ear0,gr29 /* faulting address */
209 movsg scr1,gr31 /* get mapped PTD coverage start address */
210 xor.p gr29,gr31,gr31 /* compare addresses */
211 bra __entry_kernel_data_tlb_miss
213 .section .trap.fixup.user
214 .org TBR_TT_INSTR_TLB_MISS >> 2
215 .globl __trap_fixup_user_insn_tlb_miss
216 __trap_fixup_user_insn_tlb_miss:
217 .long __break_user_insn_tlb_miss
218 .org TBR_TT_DATA_TLB_MISS >> 2
219 .globl __trap_fixup_user_data_tlb_miss
220 __trap_fixup_user_data_tlb_miss:
221 .long __break_user_data_tlb_miss
223 .section .trap.fixup.kernel
224 .org TBR_TT_INSTR_TLB_MISS >> 2
225 .globl __trap_fixup_kernel_insn_tlb_miss
226 __trap_fixup_kernel_insn_tlb_miss:
227 .long __break_kernel_insn_tlb_miss
228 .org TBR_TT_DATA_TLB_MISS >> 2
229 .globl __trap_fixup_kernel_data_tlb_miss
230 __trap_fixup_kernel_data_tlb_miss:
231 .long __break_kernel_data_tlb_miss
233 .section .trap.vector
234 .org TBR_TT_INSTR_TLB_MISS >> 2
235 .long __entry_insn_mmu_fault
236 .org TBR_TT_DATA_TLB_MISS >> 2
237 .long __entry_data_mmu_fault
240 VECTOR_SP_MMU TBR_TT_DATA_DAT_EXCEP, __entry_data_dat_fault
241 VECTOR_NMI TBR_TT_DECREMENT_TIMER, __entry_do_NMI
242 VECTOR_SOFTPROG TBR_TT_COMPOUND_EXCEP, __entry_compound_exception
243 VECTOR_IRQ TBR_TT_INTERRUPT_1, __entry_do_IRQ
244 VECTOR_IRQ TBR_TT_INTERRUPT_2, __entry_do_IRQ
245 VECTOR_IRQ TBR_TT_INTERRUPT_3, __entry_do_IRQ
246 VECTOR_IRQ TBR_TT_INTERRUPT_4, __entry_do_IRQ
247 VECTOR_IRQ TBR_TT_INTERRUPT_5, __entry_do_IRQ
248 VECTOR_IRQ TBR_TT_INTERRUPT_6, __entry_do_IRQ
249 VECTOR_IRQ TBR_TT_INTERRUPT_7, __entry_do_IRQ
250 VECTOR_IRQ TBR_TT_INTERRUPT_8, __entry_do_IRQ
251 VECTOR_IRQ TBR_TT_INTERRUPT_9, __entry_do_IRQ
252 VECTOR_IRQ TBR_TT_INTERRUPT_10, __entry_do_IRQ
253 VECTOR_IRQ TBR_TT_INTERRUPT_11, __entry_do_IRQ
254 VECTOR_IRQ TBR_TT_INTERRUPT_12, __entry_do_IRQ
255 VECTOR_IRQ TBR_TT_INTERRUPT_13, __entry_do_IRQ
256 VECTOR_IRQ TBR_TT_INTERRUPT_14, __entry_do_IRQ
257 VECTOR_NMI TBR_TT_INTERRUPT_15, __entry_do_NMI
259 # miscellaneous user mode entry points
263 bra __entry_uspace_softprog_interrupt
270 .section .trap.fixup.user
271 .org TBR_TT_TRAP0 >> 2
273 .long __break_step_uspace_softprog_interrupt
275 .org TBR_TT_BREAK >> 2
278 # miscellaneous kernel mode entry points
279 .section .trap.kernel
281 bra __entry_kernel_softprog_interrupt
283 bra __entry_kernel_softprog_interrupt
285 # trap #2 in kernel - reenable interrupts
287 bra __entry_kernel_external_interrupt_virtual_reenable
289 # miscellaneous kernel traps
292 bra __entry_kernel_softprog_interrupt
299 .section .trap.fixup.kernel
300 .org TBR_TT_TRAP0 >> 2
301 .long __break_step_kernel_softprog_interrupt
302 .long __break_step_kernel_softprog_interrupt
303 .long __break_step_kernel_external_interrupt_virtual_reenable
305 .long __break_step_kernel_softprog_interrupt
307 .org TBR_TT_BREAK >> 2
310 # miscellaneous debug mode entry points
316 # miscellaneous vectors
317 .section .trap.vector
318 .org TBR_TT_TRAP0 >> 2
321 .long __entry_unsupported_trap
323 .org TBR_TT_BREAK >> 2
324 .long __entry_debug_exception