Back to home page

LXR

 
 

    


0001 /* entry-table.S: main trap vector tables and exception jump table
0002  *
0003  * Copyright (C) 2003 Red Hat, Inc. All Rights Reserved.
0004  * Written by David Howells (dhowells@redhat.com)
0005  *
0006  * This program is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU General Public License
0008  * as published by the Free Software Foundation; either version
0009  * 2 of the License, or (at your option) any later version.
0010  *
0011  */
0012 
0013 #include <linux/sys.h>
0014 #include <linux/linkage.h>
0015 #include <asm/spr-regs.h>
0016 
0017 ###############################################################################
0018 #
0019 # Declare the main trap and vector tables
0020 #
0021 # There are six tables:
0022 #
0023 # (1) The trap table for debug mode
0024 # (2) The trap table for kernel mode
0025 # (3) The trap table for user mode
0026 #
0027 #     The CPU jumps to an appropriate slot in the appropriate table to perform
0028 #     exception processing. We have three different tables for the three
0029 #     different CPU modes because there is no hardware differentiation between
0030 #     stack pointers for these three modes, and so we have to invent one when
0031 #     crossing mode boundaries.
0032 #
0033 # (4) The exception handler vector table
0034 #
0035 #     The user and kernel trap tables use the same prologue for normal
0036 #     exception processing. The prologue then jumps to the handler in this
0037 #     table, as indexed by the exception ID from the TBR.
0038 #
0039 # (5) The fixup table for kernel-trap single-step
0040 # (6) The fixup table for user-trap single-step
0041 #
0042 #     Due to the way single-stepping works on this CPU (single-step is not
0043 #     disabled when crossing exception boundaries, only when in debug mode),
0044 #     we have to catch the single-step event in break.S and jump to the fixup
0045 #     routine pointed to by this table.
0046 #
0047 # The linker script places the user mode and kernel mode trap tables on to
0048 # the same 8Kb page, so that break.S can be more efficient when performing
0049 # single-step bypass management
0050 #
0051 ###############################################################################
0052 
0053     # trap table for entry from debug mode
0054     .section    .trap.break,"ax"
0055     .balign     256*16
0056     .globl      __entry_breaktrap_table
0057 __entry_breaktrap_table:
0058 
0059     # trap table for entry from user mode
0060     .section    .trap.user,"ax"
0061     .balign     256*16
0062     .globl      __entry_usertrap_table
0063 __entry_usertrap_table:
0064 
0065     # trap table for entry from kernel mode
0066     .section    .trap.kernel,"ax"
0067     .balign     256*16
0068     .globl      __entry_kerneltrap_table
0069 __entry_kerneltrap_table:
0070 
0071     # exception handler jump table
0072     .section    .trap.vector,"ax"
0073     .balign     256*4
0074     .globl      __entry_vector_table
0075 __entry_vector_table:
0076 
0077     # trap fixup table for single-stepping in user mode
0078     .section    .trap.fixup.user,"a"
0079     .balign     256*4
0080     .globl      __break_usertrap_fixup_table
0081 __break_usertrap_fixup_table:
0082 
0083     # trap fixup table for single-stepping in user mode
0084     .section    .trap.fixup.kernel,"a"
0085     .balign     256*4
0086     .globl      __break_kerneltrap_fixup_table
0087 __break_kerneltrap_fixup_table:
0088 
0089     # handler declaration for a software or program interrupt
0090 .macro VECTOR_SOFTPROG tbr_tt, vec
0091     .section .trap.user
0092     .org        \tbr_tt
0093     bra     __entry_uspace_softprog_interrupt
0094     .section .trap.fixup.user
0095     .org        \tbr_tt >> 2
0096     .long       __break_step_uspace_softprog_interrupt
0097     .section .trap.kernel
0098     .org        \tbr_tt
0099     bra     __entry_kernel_softprog_interrupt
0100     .section .trap.fixup.kernel
0101     .org        \tbr_tt >> 2
0102     .long       __break_step_kernel_softprog_interrupt
0103     .section .trap.vector
0104     .org        \tbr_tt >> 2
0105     .long       \vec
0106 .endm
0107 
0108     # handler declaration for a maskable external interrupt
0109 .macro VECTOR_IRQ tbr_tt, vec
0110     .section .trap.user
0111     .org        \tbr_tt
0112     bra     __entry_uspace_external_interrupt
0113     .section .trap.fixup.user
0114     .org        \tbr_tt >> 2
0115     .long       __break_step_uspace_external_interrupt
0116     .section .trap.kernel
0117     .org        \tbr_tt
0118     # deal with virtual interrupt disablement
0119     beq     icc2,#0,__entry_kernel_external_interrupt_virtually_disabled
0120     bra     __entry_kernel_external_interrupt
0121     .section .trap.fixup.kernel
0122     .org        \tbr_tt >> 2
0123     .long       __break_step_kernel_external_interrupt
0124     .section .trap.vector
0125     .org        \tbr_tt >> 2
0126     .long       \vec
0127 .endm
0128 
0129     # handler declaration for an NMI external interrupt
0130 .macro VECTOR_NMI tbr_tt, vec
0131     .section .trap.user
0132     .org        \tbr_tt
0133     break
0134     break
0135     break
0136     break
0137     .section .trap.kernel
0138     .org        \tbr_tt
0139     break
0140     break
0141     break
0142     break
0143     .section .trap.vector
0144     .org        \tbr_tt >> 2
0145     .long       \vec
0146 .endm
0147 
0148     # handler declaration for an MMU only software or program interrupt
0149 .macro VECTOR_SP_MMU tbr_tt, vec
0150 #ifdef CONFIG_MMU
0151     VECTOR_SOFTPROG \tbr_tt, \vec
0152 #else
0153     VECTOR_NMI  \tbr_tt, 0
0154 #endif
0155 .endm
0156 
0157 
0158 ###############################################################################
0159 #
0160 # specification of the vectors
0161 # - note: each macro inserts code into multiple sections
0162 #
0163 ###############################################################################
0164     VECTOR_SP_MMU   TBR_TT_INSTR_MMU_MISS,  __entry_insn_mmu_miss
0165     VECTOR_SOFTPROG TBR_TT_INSTR_ACC_ERROR, __entry_insn_access_error
0166     VECTOR_SOFTPROG TBR_TT_INSTR_ACC_EXCEP, __entry_insn_access_exception
0167     VECTOR_SOFTPROG TBR_TT_PRIV_INSTR,  __entry_privileged_instruction
0168     VECTOR_SOFTPROG TBR_TT_ILLEGAL_INSTR,   __entry_illegal_instruction
0169     VECTOR_SOFTPROG TBR_TT_FP_EXCEPTION,    __entry_media_exception
0170     VECTOR_SOFTPROG TBR_TT_MP_EXCEPTION,    __entry_media_exception
0171     VECTOR_SOFTPROG TBR_TT_DATA_ACC_ERROR,  __entry_data_access_error
0172     VECTOR_SP_MMU   TBR_TT_DATA_MMU_MISS,   __entry_data_mmu_miss
0173     VECTOR_SOFTPROG TBR_TT_DATA_ACC_EXCEP,  __entry_data_access_exception
0174     VECTOR_SOFTPROG TBR_TT_DATA_STR_ERROR,  __entry_data_store_error
0175     VECTOR_SOFTPROG TBR_TT_DIVISION_EXCEP,  __entry_division_exception
0176 
0177 #ifdef CONFIG_MMU
0178     .section .trap.user
0179     .org        TBR_TT_INSTR_TLB_MISS
0180     .globl      __trap_user_insn_tlb_miss
0181 __trap_user_insn_tlb_miss:
0182     movsg       ear0,gr28           /* faulting address */
0183     movsg       scr0,gr31           /* get mapped PTD coverage start address */
0184     xor.p       gr28,gr31,gr31          /* compare addresses */
0185     bra     __entry_user_insn_tlb_miss
0186 
0187     .org        TBR_TT_DATA_TLB_MISS
0188     .globl      __trap_user_data_tlb_miss
0189 __trap_user_data_tlb_miss:
0190     movsg       ear0,gr28           /* faulting address */
0191     movsg       scr1,gr31           /* get mapped PTD coverage start address */
0192     xor.p       gr28,gr31,gr31          /* compare addresses */
0193     bra     __entry_user_data_tlb_miss
0194 
0195     .section .trap.kernel
0196     .org        TBR_TT_INSTR_TLB_MISS
0197     .globl      __trap_kernel_insn_tlb_miss
0198 __trap_kernel_insn_tlb_miss:
0199     movsg       ear0,gr29           /* faulting address */
0200     movsg       scr0,gr31           /* get mapped PTD coverage start address */
0201     xor.p       gr29,gr31,gr31          /* compare addresses */
0202     bra     __entry_kernel_insn_tlb_miss
0203 
0204     .org        TBR_TT_DATA_TLB_MISS
0205     .globl      __trap_kernel_data_tlb_miss
0206 __trap_kernel_data_tlb_miss:
0207     movsg       ear0,gr29           /* faulting address */
0208     movsg       scr1,gr31           /* get mapped PTD coverage start address */
0209     xor.p       gr29,gr31,gr31          /* compare addresses */
0210     bra     __entry_kernel_data_tlb_miss
0211 
0212     .section .trap.fixup.user
0213     .org        TBR_TT_INSTR_TLB_MISS >> 2
0214     .globl      __trap_fixup_user_insn_tlb_miss
0215 __trap_fixup_user_insn_tlb_miss:
0216     .long       __break_user_insn_tlb_miss
0217     .org        TBR_TT_DATA_TLB_MISS >> 2
0218     .globl      __trap_fixup_user_data_tlb_miss
0219 __trap_fixup_user_data_tlb_miss:
0220     .long       __break_user_data_tlb_miss
0221 
0222     .section .trap.fixup.kernel
0223     .org        TBR_TT_INSTR_TLB_MISS >> 2
0224     .globl      __trap_fixup_kernel_insn_tlb_miss
0225 __trap_fixup_kernel_insn_tlb_miss:
0226     .long       __break_kernel_insn_tlb_miss
0227     .org        TBR_TT_DATA_TLB_MISS >> 2
0228     .globl      __trap_fixup_kernel_data_tlb_miss
0229 __trap_fixup_kernel_data_tlb_miss:
0230     .long       __break_kernel_data_tlb_miss
0231 
0232     .section .trap.vector
0233     .org        TBR_TT_INSTR_TLB_MISS >> 2
0234     .long       __entry_insn_mmu_fault
0235     .org        TBR_TT_DATA_TLB_MISS >> 2
0236     .long       __entry_data_mmu_fault
0237 #endif
0238 
0239     VECTOR_SP_MMU   TBR_TT_DATA_DAT_EXCEP,  __entry_data_dat_fault
0240     VECTOR_NMI  TBR_TT_DECREMENT_TIMER, __entry_do_NMI
0241     VECTOR_SOFTPROG TBR_TT_COMPOUND_EXCEP,  __entry_compound_exception
0242     VECTOR_IRQ  TBR_TT_INTERRUPT_1, __entry_do_IRQ
0243     VECTOR_IRQ  TBR_TT_INTERRUPT_2, __entry_do_IRQ
0244     VECTOR_IRQ  TBR_TT_INTERRUPT_3, __entry_do_IRQ
0245     VECTOR_IRQ  TBR_TT_INTERRUPT_4, __entry_do_IRQ
0246     VECTOR_IRQ  TBR_TT_INTERRUPT_5, __entry_do_IRQ
0247     VECTOR_IRQ  TBR_TT_INTERRUPT_6, __entry_do_IRQ
0248     VECTOR_IRQ  TBR_TT_INTERRUPT_7, __entry_do_IRQ
0249     VECTOR_IRQ  TBR_TT_INTERRUPT_8, __entry_do_IRQ
0250     VECTOR_IRQ  TBR_TT_INTERRUPT_9, __entry_do_IRQ
0251     VECTOR_IRQ  TBR_TT_INTERRUPT_10,    __entry_do_IRQ
0252     VECTOR_IRQ  TBR_TT_INTERRUPT_11,    __entry_do_IRQ
0253     VECTOR_IRQ  TBR_TT_INTERRUPT_12,    __entry_do_IRQ
0254     VECTOR_IRQ  TBR_TT_INTERRUPT_13,    __entry_do_IRQ
0255     VECTOR_IRQ  TBR_TT_INTERRUPT_14,    __entry_do_IRQ
0256     VECTOR_NMI  TBR_TT_INTERRUPT_15,    __entry_do_NMI
0257 
0258     # miscellaneous user mode entry points
0259     .section    .trap.user
0260     .org        TBR_TT_TRAP0
0261     .rept       127
0262     bra     __entry_uspace_softprog_interrupt
0263     .long       0,0,0
0264     .endr
0265     .org        TBR_TT_BREAK
0266     bra     __entry_break
0267     .long       0,0,0
0268 
0269     .section    .trap.fixup.user
0270     .org        TBR_TT_TRAP0 >> 2
0271     .rept       127
0272     .long       __break_step_uspace_softprog_interrupt
0273     .endr
0274     .org        TBR_TT_BREAK >> 2
0275     .long       0
0276 
0277     # miscellaneous kernel mode entry points
0278     .section    .trap.kernel
0279     .org        TBR_TT_TRAP0
0280     bra     __entry_kernel_softprog_interrupt
0281     .org        TBR_TT_TRAP1
0282     bra     __entry_kernel_softprog_interrupt
0283 
0284     # trap #2 in kernel - reenable interrupts
0285     .org        TBR_TT_TRAP2
0286     bra     __entry_kernel_external_interrupt_virtual_reenable
0287 
0288     # miscellaneous kernel traps
0289     .org        TBR_TT_TRAP3
0290     .rept       124
0291     bra     __entry_kernel_softprog_interrupt
0292     .long       0,0,0
0293     .endr
0294     .org        TBR_TT_BREAK
0295     bra     __entry_break
0296     .long       0,0,0
0297 
0298     .section    .trap.fixup.kernel
0299     .org        TBR_TT_TRAP0 >> 2
0300     .long       __break_step_kernel_softprog_interrupt
0301     .long       __break_step_kernel_softprog_interrupt
0302     .long       __break_step_kernel_external_interrupt_virtual_reenable
0303     .rept       124
0304     .long       __break_step_kernel_softprog_interrupt
0305     .endr
0306     .org        TBR_TT_BREAK >> 2
0307     .long       0
0308 
0309     # miscellaneous debug mode entry points
0310     .section    .trap.break
0311     .org        TBR_TT_BREAK
0312     movsg       bpcsr,gr30
0313     jmpl        @(gr30,gr0)
0314 
0315     # miscellaneous vectors
0316     .section    .trap.vector
0317     .org        TBR_TT_TRAP0 >> 2
0318     .long       system_call
0319     .rept       119
0320     .long       __entry_unsupported_trap
0321     .endr
0322 
0323     # userspace atomic op emulation, traps 120-126
0324     .rept       7
0325     .long       __entry_atomic_op
0326     .endr
0327     
0328     .org        TBR_TT_BREAK >> 2
0329     .long       __entry_debug_exception