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/linkage.h>
15 #include <asm/spr-regs.h>
17 ###############################################################################
19 # Declare the main trap and vector tables
21 # There are six tables:
23 # (1) The trap table for debug mode
24 # (2) The trap table for kernel mode
25 # (3) The trap table for user mode
27 # The CPU jumps to an appropriate slot in the appropriate table to perform
28 # exception processing. We have three different tables for the three
29 # different CPU modes because there is no hardware differentiation between
30 # stack pointers for these three modes, and so we have to invent one when
31 # crossing mode boundaries.
33 # (4) The exception handler vector table
35 # The user and kernel trap tables use the same prologue for normal
36 # exception processing. The prologue then jumps to the handler in this
37 # table, as indexed by the exception ID from the TBR.
39 # (5) The fixup table for kernel-trap single-step
40 # (6) The fixup table for user-trap single-step
42 # Due to the way single-stepping works on this CPU (single-step is not
43 # disabled when crossing exception boundaries, only when in debug mode),
44 # we have to catch the single-step event in break.S and jump to the fixup
45 # routine pointed to by this table.
47 # The linker script places the user mode and kernel mode trap tables on to
48 # the same 8Kb page, so that break.S can be more efficient when performing
49 # single-step bypass management
51 ###############################################################################
53 # trap table for entry from debug mode
54 .section .trap.break,"ax"
56 .globl __entry_breaktrap_table
57 __entry_breaktrap_table:
59 # trap table for entry from user mode
60 .section .trap.user,"ax"
62 .globl __entry_usertrap_table
63 __entry_usertrap_table:
65 # trap table for entry from kernel mode
66 .section .trap.kernel,"ax"
68 .globl __entry_kerneltrap_table
69 __entry_kerneltrap_table:
71 # exception handler jump table
72 .section .trap.vector,"ax"
74 .globl __entry_vector_table
77 # trap fixup table for single-stepping in user mode
78 .section .trap.fixup.user,"a"
80 .globl __break_usertrap_fixup_table
81 __break_usertrap_fixup_table:
83 # trap fixup table for single-stepping in user mode
84 .section .trap.fixup.kernel,"a"
86 .globl __break_kerneltrap_fixup_table
87 __break_kerneltrap_fixup_table:
89 # handler declaration for a software or program interrupt
90 .macro VECTOR_SOFTPROG tbr_tt, vec
93 bra __entry_uspace_softprog_interrupt
94 .section .trap.fixup.user
96 .long __break_step_uspace_softprog_interrupt
99 bra __entry_kernel_softprog_interrupt
100 .section .trap.fixup.kernel
102 .long __break_step_kernel_softprog_interrupt
103 .section .trap.vector
108 # handler declaration for a maskable external interrupt
109 .macro VECTOR_IRQ tbr_tt, vec
112 bra __entry_uspace_external_interrupt
113 .section .trap.fixup.user
115 .long __break_step_uspace_external_interrupt
116 .section .trap.kernel
118 # deal with virtual interrupt disablement
119 beq icc2,#0,__entry_kernel_external_interrupt_virtually_disabled
120 bra __entry_kernel_external_interrupt
121 .section .trap.fixup.kernel
123 .long __break_step_kernel_external_interrupt
124 .section .trap.vector
129 # handler declaration for an NMI external interrupt
130 .macro VECTOR_NMI tbr_tt, vec
137 .section .trap.kernel
143 .section .trap.vector
148 # handler declaration for an MMU only software or program interrupt
149 .macro VECTOR_SP_MMU tbr_tt, vec
151 VECTOR_SOFTPROG \tbr_tt, \vec
153 VECTOR_NMI \tbr_tt, 0
158 ###############################################################################
160 # specification of the vectors
161 # - note: each macro inserts code into multiple sections
163 ###############################################################################
164 VECTOR_SP_MMU TBR_TT_INSTR_MMU_MISS, __entry_insn_mmu_miss
165 VECTOR_SOFTPROG TBR_TT_INSTR_ACC_ERROR, __entry_insn_access_error
166 VECTOR_SOFTPROG TBR_TT_INSTR_ACC_EXCEP, __entry_insn_access_exception
167 VECTOR_SOFTPROG TBR_TT_PRIV_INSTR, __entry_privileged_instruction
168 VECTOR_SOFTPROG TBR_TT_ILLEGAL_INSTR, __entry_illegal_instruction
169 VECTOR_SOFTPROG TBR_TT_FP_EXCEPTION, __entry_media_exception
170 VECTOR_SOFTPROG TBR_TT_MP_EXCEPTION, __entry_media_exception
171 VECTOR_SOFTPROG TBR_TT_DATA_ACC_ERROR, __entry_data_access_error
172 VECTOR_SP_MMU TBR_TT_DATA_MMU_MISS, __entry_data_mmu_miss
173 VECTOR_SOFTPROG TBR_TT_DATA_ACC_EXCEP, __entry_data_access_exception
174 VECTOR_SOFTPROG TBR_TT_DATA_STR_ERROR, __entry_data_store_error
175 VECTOR_SOFTPROG TBR_TT_DIVISION_EXCEP, __entry_division_exception
179 .org TBR_TT_INSTR_TLB_MISS
180 .globl __trap_user_insn_tlb_miss
181 __trap_user_insn_tlb_miss:
182 movsg ear0,gr28 /* faulting address */
183 movsg scr0,gr31 /* get mapped PTD coverage start address */
184 xor.p gr28,gr31,gr31 /* compare addresses */
185 bra __entry_user_insn_tlb_miss
187 .org TBR_TT_DATA_TLB_MISS
188 .globl __trap_user_data_tlb_miss
189 __trap_user_data_tlb_miss:
190 movsg ear0,gr28 /* faulting address */
191 movsg scr1,gr31 /* get mapped PTD coverage start address */
192 xor.p gr28,gr31,gr31 /* compare addresses */
193 bra __entry_user_data_tlb_miss
195 .section .trap.kernel
196 .org TBR_TT_INSTR_TLB_MISS
197 .globl __trap_kernel_insn_tlb_miss
198 __trap_kernel_insn_tlb_miss:
199 movsg ear0,gr29 /* faulting address */
200 movsg scr0,gr31 /* get mapped PTD coverage start address */
201 xor.p gr29,gr31,gr31 /* compare addresses */
202 bra __entry_kernel_insn_tlb_miss
204 .org TBR_TT_DATA_TLB_MISS
205 .globl __trap_kernel_data_tlb_miss
206 __trap_kernel_data_tlb_miss:
207 movsg ear0,gr29 /* faulting address */
208 movsg scr1,gr31 /* get mapped PTD coverage start address */
209 xor.p gr29,gr31,gr31 /* compare addresses */
210 bra __entry_kernel_data_tlb_miss
212 .section .trap.fixup.user
213 .org TBR_TT_INSTR_TLB_MISS >> 2
214 .globl __trap_fixup_user_insn_tlb_miss
215 __trap_fixup_user_insn_tlb_miss:
216 .long __break_user_insn_tlb_miss
217 .org TBR_TT_DATA_TLB_MISS >> 2
218 .globl __trap_fixup_user_data_tlb_miss
219 __trap_fixup_user_data_tlb_miss:
220 .long __break_user_data_tlb_miss
222 .section .trap.fixup.kernel
223 .org TBR_TT_INSTR_TLB_MISS >> 2
224 .globl __trap_fixup_kernel_insn_tlb_miss
225 __trap_fixup_kernel_insn_tlb_miss:
226 .long __break_kernel_insn_tlb_miss
227 .org TBR_TT_DATA_TLB_MISS >> 2
228 .globl __trap_fixup_kernel_data_tlb_miss
229 __trap_fixup_kernel_data_tlb_miss:
230 .long __break_kernel_data_tlb_miss
232 .section .trap.vector
233 .org TBR_TT_INSTR_TLB_MISS >> 2
234 .long __entry_insn_mmu_fault
235 .org TBR_TT_DATA_TLB_MISS >> 2
236 .long __entry_data_mmu_fault
239 VECTOR_SP_MMU TBR_TT_DATA_DAT_EXCEP, __entry_data_dat_fault
240 VECTOR_NMI TBR_TT_DECREMENT_TIMER, __entry_do_NMI
241 VECTOR_SOFTPROG TBR_TT_COMPOUND_EXCEP, __entry_compound_exception
242 VECTOR_IRQ TBR_TT_INTERRUPT_1, __entry_do_IRQ
243 VECTOR_IRQ TBR_TT_INTERRUPT_2, __entry_do_IRQ
244 VECTOR_IRQ TBR_TT_INTERRUPT_3, __entry_do_IRQ
245 VECTOR_IRQ TBR_TT_INTERRUPT_4, __entry_do_IRQ
246 VECTOR_IRQ TBR_TT_INTERRUPT_5, __entry_do_IRQ
247 VECTOR_IRQ TBR_TT_INTERRUPT_6, __entry_do_IRQ
248 VECTOR_IRQ TBR_TT_INTERRUPT_7, __entry_do_IRQ
249 VECTOR_IRQ TBR_TT_INTERRUPT_8, __entry_do_IRQ
250 VECTOR_IRQ TBR_TT_INTERRUPT_9, __entry_do_IRQ
251 VECTOR_IRQ TBR_TT_INTERRUPT_10, __entry_do_IRQ
252 VECTOR_IRQ TBR_TT_INTERRUPT_11, __entry_do_IRQ
253 VECTOR_IRQ TBR_TT_INTERRUPT_12, __entry_do_IRQ
254 VECTOR_IRQ TBR_TT_INTERRUPT_13, __entry_do_IRQ
255 VECTOR_IRQ TBR_TT_INTERRUPT_14, __entry_do_IRQ
256 VECTOR_NMI TBR_TT_INTERRUPT_15, __entry_do_NMI
258 # miscellaneous user mode entry points
262 bra __entry_uspace_softprog_interrupt
269 .section .trap.fixup.user
270 .org TBR_TT_TRAP0 >> 2
272 .long __break_step_uspace_softprog_interrupt
274 .org TBR_TT_BREAK >> 2
277 # miscellaneous kernel mode entry points
278 .section .trap.kernel
280 bra __entry_kernel_softprog_interrupt
282 bra __entry_kernel_softprog_interrupt
284 # trap #2 in kernel - reenable interrupts
286 bra __entry_kernel_external_interrupt_virtual_reenable
288 # miscellaneous kernel traps
291 bra __entry_kernel_softprog_interrupt
298 .section .trap.fixup.kernel
299 .org TBR_TT_TRAP0 >> 2
300 .long __break_step_kernel_softprog_interrupt
301 .long __break_step_kernel_softprog_interrupt
302 .long __break_step_kernel_external_interrupt_virtual_reenable
304 .long __break_step_kernel_softprog_interrupt
306 .org TBR_TT_BREAK >> 2
309 # miscellaneous debug mode entry points
315 # miscellaneous vectors
316 .section .trap.vector
317 .org TBR_TT_TRAP0 >> 2
320 .long __entry_unsupported_trap
323 # userspace atomic op emulation, traps 120-126
325 .long __entry_atomic_op
328 .org TBR_TT_BREAK >> 2
329 .long __entry_debug_exception