1597ab3a7SNathan Whitehorn /*- 2597ab3a7SNathan Whitehorn * Copyright (C) 1995, 1996 Wolfgang Solfrank. 3597ab3a7SNathan Whitehorn * Copyright (C) 1995, 1996 TooLs GmbH. 4597ab3a7SNathan Whitehorn * All rights reserved. 5597ab3a7SNathan Whitehorn * 6597ab3a7SNathan Whitehorn * Redistribution and use in source and binary forms, with or without 7597ab3a7SNathan Whitehorn * modification, are permitted provided that the following conditions 8597ab3a7SNathan Whitehorn * are met: 9597ab3a7SNathan Whitehorn * 1. Redistributions of source code must retain the above copyright 10597ab3a7SNathan Whitehorn * notice, this list of conditions and the following disclaimer. 11597ab3a7SNathan Whitehorn * 2. Redistributions in binary form must reproduce the above copyright 12597ab3a7SNathan Whitehorn * notice, this list of conditions and the following disclaimer in the 13597ab3a7SNathan Whitehorn * documentation and/or other materials provided with the distribution. 14597ab3a7SNathan Whitehorn * 3. All advertising materials mentioning features or use of this software 15597ab3a7SNathan Whitehorn * must display the following acknowledgement: 16597ab3a7SNathan Whitehorn * This product includes software developed by TooLs GmbH. 17597ab3a7SNathan Whitehorn * 4. The name of TooLs GmbH may not be used to endorse or promote products 18597ab3a7SNathan Whitehorn * derived from this software without specific prior written permission. 19597ab3a7SNathan Whitehorn * 20597ab3a7SNathan Whitehorn * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR 21597ab3a7SNathan Whitehorn * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 22597ab3a7SNathan Whitehorn * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 23597ab3a7SNathan Whitehorn * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24597ab3a7SNathan Whitehorn * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25597ab3a7SNathan Whitehorn * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26597ab3a7SNathan Whitehorn * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27597ab3a7SNathan Whitehorn * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28597ab3a7SNathan Whitehorn * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29597ab3a7SNathan Whitehorn * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30597ab3a7SNathan Whitehorn * 31597ab3a7SNathan Whitehorn * $NetBSD: trap.h,v 1.7 2002/02/22 13:51:40 kleink Exp $ 32597ab3a7SNathan Whitehorn * $FreeBSD$ 33597ab3a7SNathan Whitehorn */ 34f9bac91bSBenno Rice 35597ab3a7SNathan Whitehorn #ifndef _POWERPC_TRAP_H_ 36597ab3a7SNathan Whitehorn #define _POWERPC_TRAP_H_ 37597ab3a7SNathan Whitehorn 38597ab3a7SNathan Whitehorn #define EXC_RSVD 0x0000 /* Reserved */ 39597ab3a7SNathan Whitehorn #define EXC_RST 0x0100 /* Reset; all but IBM4xx */ 40597ab3a7SNathan Whitehorn #define EXC_MCHK 0x0200 /* Machine Check */ 41597ab3a7SNathan Whitehorn #define EXC_DSI 0x0300 /* Data Storage Interrupt */ 42597ab3a7SNathan Whitehorn #define EXC_DSE 0x0380 /* Data Segment Interrupt */ 43597ab3a7SNathan Whitehorn #define EXC_ISI 0x0400 /* Instruction Storage Interrupt */ 44597ab3a7SNathan Whitehorn #define EXC_ISE 0x0480 /* Instruction Segment Interrupt */ 45597ab3a7SNathan Whitehorn #define EXC_EXI 0x0500 /* External Interrupt */ 46597ab3a7SNathan Whitehorn #define EXC_ALI 0x0600 /* Alignment Interrupt */ 47597ab3a7SNathan Whitehorn #define EXC_PGM 0x0700 /* Program Interrupt */ 48597ab3a7SNathan Whitehorn #define EXC_FPU 0x0800 /* Floating-point Unavailable */ 49597ab3a7SNathan Whitehorn #define EXC_DECR 0x0900 /* Decrementer Interrupt */ 50597ab3a7SNathan Whitehorn #define EXC_SC 0x0c00 /* System Call */ 51597ab3a7SNathan Whitehorn #define EXC_TRC 0x0d00 /* Trace */ 52597ab3a7SNathan Whitehorn #define EXC_FPA 0x0e00 /* Floating-point Assist */ 53597ab3a7SNathan Whitehorn 54597ab3a7SNathan Whitehorn /* The following is only available on the 601: */ 55597ab3a7SNathan Whitehorn #define EXC_RUNMODETRC 0x2000 /* Run Mode/Trace Exception */ 56597ab3a7SNathan Whitehorn 57597ab3a7SNathan Whitehorn /* The following are only available on 970(G5): */ 58597ab3a7SNathan Whitehorn #define EXC_VECAST_G5 0x1700 /* AltiVec Assist */ 59597ab3a7SNathan Whitehorn 60597ab3a7SNathan Whitehorn /* The following are only available on 7400(G4): */ 61597ab3a7SNathan Whitehorn #define EXC_VEC 0x0f20 /* AltiVec Unavailable */ 62597ab3a7SNathan Whitehorn #define EXC_VECAST_G4 0x1600 /* AltiVec Assist */ 63597ab3a7SNathan Whitehorn 64597ab3a7SNathan Whitehorn /* The following are only available on 604/750/7400: */ 65597ab3a7SNathan Whitehorn #define EXC_PERF 0x0f00 /* Performance Monitoring */ 66597ab3a7SNathan Whitehorn #define EXC_BPT 0x1300 /* Instruction Breakpoint */ 67597ab3a7SNathan Whitehorn #define EXC_SMI 0x1400 /* System Managment Interrupt */ 68597ab3a7SNathan Whitehorn 69597ab3a7SNathan Whitehorn /* The following are only available on 750/7400: */ 70597ab3a7SNathan Whitehorn #define EXC_THRM 0x1700 /* Thermal Management Interrupt */ 71597ab3a7SNathan Whitehorn 72597ab3a7SNathan Whitehorn /* And these are only on the 603: */ 73597ab3a7SNathan Whitehorn #define EXC_IMISS 0x1000 /* Instruction translation miss */ 74597ab3a7SNathan Whitehorn #define EXC_DLMISS 0x1100 /* Data load translation miss */ 75597ab3a7SNathan Whitehorn #define EXC_DSMISS 0x1200 /* Data store translation miss */ 76597ab3a7SNathan Whitehorn 7735f612b8SNathan Whitehorn /* Power ISA 2.06+: */ 7835f612b8SNathan Whitehorn #define EXC_VSX 0x0f40 /* VSX Unavailable */ 7935f612b8SNathan Whitehorn 80597ab3a7SNathan Whitehorn /* The following are available on 4xx and 85xx */ 81597ab3a7SNathan Whitehorn #define EXC_CRIT 0x0100 /* Critical Input Interrupt */ 82597ab3a7SNathan Whitehorn #define EXC_PIT 0x1000 /* Programmable Interval Timer */ 83597ab3a7SNathan Whitehorn #define EXC_FIT 0x1010 /* Fixed Interval Timer */ 84597ab3a7SNathan Whitehorn #define EXC_WDOG 0x1020 /* Watchdog Timer */ 85597ab3a7SNathan Whitehorn #define EXC_DTMISS 0x1100 /* Data TLB Miss */ 86597ab3a7SNathan Whitehorn #define EXC_ITMISS 0x1200 /* Instruction TLB Miss */ 87597ab3a7SNathan Whitehorn #define EXC_APU 0x1300 /* Auxiliary Processing Unit */ 886d53f4a6SJustin Hibbits #define EXC_DEBUG 0x2f10 /* Debug trap */ 89a39f1053SJustin Hibbits #define EXC_VECAST_E 0x2f20 /* Altivec Assist (Book-E) */ 90597ab3a7SNathan Whitehorn 91597ab3a7SNathan Whitehorn #define EXC_LAST 0x2f00 /* Last possible exception vector */ 92597ab3a7SNathan Whitehorn 93597ab3a7SNathan Whitehorn #define EXC_AST 0x3000 /* Fake AST vector */ 94597ab3a7SNathan Whitehorn 95597ab3a7SNathan Whitehorn /* Trap was in user mode */ 96597ab3a7SNathan Whitehorn #define EXC_USER 0x10000 97597ab3a7SNathan Whitehorn 98597ab3a7SNathan Whitehorn 99597ab3a7SNathan Whitehorn /* 100597ab3a7SNathan Whitehorn * EXC_ALI sets bits in the DSISR and DAR to provide enough 101597ab3a7SNathan Whitehorn * information to recover from the unaligned access without needing to 102597ab3a7SNathan Whitehorn * parse the offending instruction. This includes certain bits of the 103597ab3a7SNathan Whitehorn * opcode, and information about what registers are used. The opcode 104597ab3a7SNathan Whitehorn * indicator values below come from Appendix F of Book III of "The 105597ab3a7SNathan Whitehorn * PowerPC Architecture". 106597ab3a7SNathan Whitehorn */ 107597ab3a7SNathan Whitehorn 108597ab3a7SNathan Whitehorn #define EXC_ALI_OPCODE_INDICATOR(dsisr) ((dsisr >> 10) & 0x7f) 109597ab3a7SNathan Whitehorn #define EXC_ALI_LFD 0x09 110597ab3a7SNathan Whitehorn #define EXC_ALI_STFD 0x0b 111597ab3a7SNathan Whitehorn 112597ab3a7SNathan Whitehorn /* Macros to extract register information */ 113597ab3a7SNathan Whitehorn #define EXC_ALI_RST(dsisr) ((dsisr >> 5) & 0x1f) /* source or target */ 114597ab3a7SNathan Whitehorn #define EXC_ALI_RA(dsisr) (dsisr & 0x1f) 115dc9b124dSJustin Hibbits #define EXC_ALI_SPE_REG(instr) ((instr >> 21) & 0x1f) 116597ab3a7SNathan Whitehorn 117597ab3a7SNathan Whitehorn /* 118597ab3a7SNathan Whitehorn * SRR1 bits for program exception traps. These identify what caused 119597ab3a7SNathan Whitehorn * the program exception. See section 6.5.9 of the Power ISA Version 120597ab3a7SNathan Whitehorn * 2.05. 121597ab3a7SNathan Whitehorn */ 122597ab3a7SNathan Whitehorn 123597ab3a7SNathan Whitehorn #define EXC_PGM_FPENABLED (1UL << 20) 124597ab3a7SNathan Whitehorn #define EXC_PGM_ILLEGAL (1UL << 19) 125597ab3a7SNathan Whitehorn #define EXC_PGM_PRIV (1UL << 18) 126597ab3a7SNathan Whitehorn #define EXC_PGM_TRAP (1UL << 17) 127597ab3a7SNathan Whitehorn 128a8920f67SJustin Hibbits /* DTrace trap opcode. */ 129*b3ae819eSJustin Hibbits #define EXC_DTRACE 0x7ffff808 130a8920f67SJustin Hibbits 131554dab44SNathan Whitehorn /* Magic pointer to store TOC base and other info for trap handlers on ppc64 */ 132554dab44SNathan Whitehorn #define TRAP_GENTRAP 0x1f0 133bb808254SNathan Whitehorn #define TRAP_TOCBASE 0x1f8 134bb808254SNathan Whitehorn 135597ab3a7SNathan Whitehorn #ifndef LOCORE 136597ab3a7SNathan Whitehorn struct trapframe; 137e537388bSNathan Whitehorn struct pcb; 138597ab3a7SNathan Whitehorn void trap(struct trapframe *); 139e537388bSNathan Whitehorn int ppc_instr_emulate(struct trapframe *, struct pcb *); 140ad9503cdSMarcel Moolenaar #endif 141ad9503cdSMarcel Moolenaar 142597ab3a7SNathan Whitehorn #endif /* _POWERPC_TRAP_H_ */ 143