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 bra __entry_kernel_external_interrupt
120 .section .trap.fixup.kernel
122 .long __break_step_kernel_external_interrupt
123 .section .trap.vector
128 # handler declaration for an NMI external interrupt
129 .macro VECTOR_NMI tbr_tt, vec
136 .section .trap.kernel
142 .section .trap.vector
147 # handler declaration for an MMU only sofware or program interrupt
148 .macro VECTOR_SP_MMU tbr_tt, vec
150 VECTOR_SOFTPROG \tbr_tt, \vec
152 VECTOR_NMI \tbr_tt, 0
157 ###############################################################################
159 # specification of the vectors
160 # - note: each macro inserts code into multiple sections
162 ###############################################################################
163 VECTOR_SP_MMU TBR_TT_INSTR_MMU_MISS, __entry_insn_mmu_miss
164 VECTOR_SOFTPROG TBR_TT_INSTR_ACC_ERROR, __entry_insn_access_error
165 VECTOR_SOFTPROG TBR_TT_INSTR_ACC_EXCEP, __entry_insn_access_exception
166 VECTOR_SOFTPROG TBR_TT_PRIV_INSTR, __entry_privileged_instruction
167 VECTOR_SOFTPROG TBR_TT_ILLEGAL_INSTR, __entry_illegal_instruction
168 VECTOR_SOFTPROG TBR_TT_FP_EXCEPTION, __entry_media_exception
169 VECTOR_SOFTPROG TBR_TT_MP_EXCEPTION, __entry_media_exception
170 VECTOR_SOFTPROG TBR_TT_DATA_ACC_ERROR, __entry_data_access_error
171 VECTOR_SP_MMU TBR_TT_DATA_MMU_MISS, __entry_data_mmu_miss
172 VECTOR_SOFTPROG TBR_TT_DATA_ACC_EXCEP, __entry_data_access_exception
173 VECTOR_SOFTPROG TBR_TT_DATA_STR_ERROR, __entry_data_store_error
174 VECTOR_SOFTPROG TBR_TT_DIVISION_EXCEP, __entry_division_exception
178 .org TBR_TT_INSTR_TLB_MISS
179 .globl __trap_user_insn_tlb_miss
180 __trap_user_insn_tlb_miss:
181 movsg ear0,gr28 /* faulting address */
182 movsg scr0,gr31 /* get mapped PTD coverage start address */
183 xor.p gr28,gr31,gr31 /* compare addresses */
184 bra __entry_user_insn_tlb_miss
186 .org TBR_TT_DATA_TLB_MISS
187 .globl __trap_user_data_tlb_miss
188 __trap_user_data_tlb_miss:
189 movsg ear0,gr28 /* faulting address */
190 movsg scr1,gr31 /* get mapped PTD coverage start address */
191 xor.p gr28,gr31,gr31 /* compare addresses */
192 bra __entry_user_data_tlb_miss
194 .section .trap.kernel
195 .org TBR_TT_INSTR_TLB_MISS
196 .globl __trap_kernel_insn_tlb_miss
197 __trap_kernel_insn_tlb_miss:
198 movsg ear0,gr29 /* faulting address */
199 movsg scr0,gr31 /* get mapped PTD coverage start address */
200 xor.p gr29,gr31,gr31 /* compare addresses */
201 bra __entry_kernel_insn_tlb_miss
203 .org TBR_TT_DATA_TLB_MISS
204 .globl __trap_kernel_data_tlb_miss
205 __trap_kernel_data_tlb_miss:
206 movsg ear0,gr29 /* faulting address */
207 movsg scr1,gr31 /* get mapped PTD coverage start address */
208 xor.p gr29,gr31,gr31 /* compare addresses */
209 bra __entry_kernel_data_tlb_miss
211 .section .trap.fixup.user
212 .org TBR_TT_INSTR_TLB_MISS >> 2
213 .globl __trap_fixup_user_insn_tlb_miss
214 __trap_fixup_user_insn_tlb_miss:
215 .long __break_user_insn_tlb_miss
216 .org TBR_TT_DATA_TLB_MISS >> 2
217 .globl __trap_fixup_user_data_tlb_miss
218 __trap_fixup_user_data_tlb_miss:
219 .long __break_user_data_tlb_miss
221 .section .trap.fixup.kernel
222 .org TBR_TT_INSTR_TLB_MISS >> 2
223 .globl __trap_fixup_kernel_insn_tlb_miss
224 __trap_fixup_kernel_insn_tlb_miss:
225 .long __break_kernel_insn_tlb_miss
226 .org TBR_TT_DATA_TLB_MISS >> 2
227 .globl __trap_fixup_kernel_data_tlb_miss
228 __trap_fixup_kernel_data_tlb_miss:
229 .long __break_kernel_data_tlb_miss
231 .section .trap.vector
232 .org TBR_TT_INSTR_TLB_MISS >> 2
233 .long __entry_insn_mmu_fault
234 .org TBR_TT_DATA_TLB_MISS >> 2
235 .long __entry_data_mmu_fault
238 VECTOR_SP_MMU TBR_TT_DATA_DAT_EXCEP, __entry_data_dat_fault
239 VECTOR_NMI TBR_TT_DECREMENT_TIMER, __entry_do_NMI
240 VECTOR_SOFTPROG TBR_TT_COMPOUND_EXCEP, __entry_compound_exception
241 VECTOR_IRQ TBR_TT_INTERRUPT_1, __entry_do_IRQ
242 VECTOR_IRQ TBR_TT_INTERRUPT_2, __entry_do_IRQ
243 VECTOR_IRQ TBR_TT_INTERRUPT_3, __entry_do_IRQ
244 VECTOR_IRQ TBR_TT_INTERRUPT_4, __entry_do_IRQ
245 VECTOR_IRQ TBR_TT_INTERRUPT_5, __entry_do_IRQ
246 VECTOR_IRQ TBR_TT_INTERRUPT_6, __entry_do_IRQ
247 VECTOR_IRQ TBR_TT_INTERRUPT_7, __entry_do_IRQ
248 VECTOR_IRQ TBR_TT_INTERRUPT_8, __entry_do_IRQ
249 VECTOR_IRQ TBR_TT_INTERRUPT_9, __entry_do_IRQ
250 VECTOR_IRQ TBR_TT_INTERRUPT_10, __entry_do_IRQ
251 VECTOR_IRQ TBR_TT_INTERRUPT_11, __entry_do_IRQ
252 VECTOR_IRQ TBR_TT_INTERRUPT_12, __entry_do_IRQ
253 VECTOR_IRQ TBR_TT_INTERRUPT_13, __entry_do_IRQ
254 VECTOR_IRQ TBR_TT_INTERRUPT_14, __entry_do_IRQ
255 VECTOR_NMI TBR_TT_INTERRUPT_15, __entry_do_NMI
257 # miscellaneous user mode entry points
261 bra __entry_uspace_softprog_interrupt
262 bra __break_step_uspace_softprog_interrupt
269 # miscellaneous kernel mode entry points
270 .section .trap.kernel
273 bra __entry_kernel_softprog_interrupt
274 bra __break_step_kernel_softprog_interrupt
281 # miscellaneous debug mode entry points
287 # miscellaneous vectors
288 .section .trap.vector
289 .org TBR_TT_TRAP0 >> 2
292 .long __entry_unsupported_trap
294 .org TBR_TT_BREAK >> 2
295 .long __entry_debug_exception