1 /*        $NetBSD: trap.h,v 1.5 2021/09/06 21:56:03 andvar Exp $      */
2 
3 /*        $OpenBSD: trap.h,v 1.8 2000/02/10 20:05:39 mickey Exp $     */
4 
5 /*
6  * Copyright (c) 1999-2004 Michael Shalayeff
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21  * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
22  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24  * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28  * THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #ifndef   _HPPA_TRAP_H_
32 #define   _HPPA_TRAP_H_
33 
34 /*
35  * This is PA-RISC trap types per 1.1 specs, see .c files for references.
36  */
37 #define   T_NONEXIST          0         /* invalid interrupt vector */
38 #define   T_HPMC              1         /* high priority machine check */
39 #define   T_POWERFAIL         2         /* power failure */
40 #define   T_RECOVERY          3         /* recovery counter */
41 #define   T_INTERRUPT         4         /* external interrupt */
42 #define   T_LPMC              5         /* low-priority machine check */
43 #define   T_ITLBMISS          6         /* instruction TLB miss fault */
44 #define   T_IPROT             7         /* instruction protection */
45 #define   T_ILLEGAL 8         /* Illegal instruction */
46 #define   T_IBREAK  9         /* break instruction */
47 #define   T_PRIV_OP 10        /* privileged operation */
48 #define   T_PRIV_REG          11        /* privileged register */
49 #define   T_OVERFLOW          12        /* overflow */
50 #define   T_CONDITION         13        /* conditional */
51 #define   T_EXCEPTION         14        /* assist exception */
52 #define   T_DTLBMISS          15        /* data TLB miss */
53 #define   T_ITLBMISSNA        16        /* ITLB non-access miss */
54 #define   T_DTLBMISSNA        17        /* DTLB non-access miss */
55 #define   T_DPROT             18        /* data protection/rights/alignment <7100 */
56 #define   T_DBREAK  19        /* data memory break */
57 #define   T_TLB_DIRTY         20        /* TLB dirty bit */
58 #define   T_PAGEREF 21        /* page reference */
59 #define   T_EMULATION         22        /* assist emulation */
60 #define   T_HIGHERPL          23        /* higher-privilege transfer */
61 #define   T_LOWERPL 24        /* lower-privilege transfer */
62 #define   T_TAKENBR 25        /* taken branch */
63 #define   T_DATACC  26        /* data access rights >=7100 */
64 #define   T_DATAPID 27        /* data protection ID >=7100 */
65 #define   T_DATALIGN          28        /* unaligned data ref */
66 #define   T_PERFMON 29        /* performance monitor interrupt */
67 #define   T_IDEBUG  30        /* debug SFU interrupt */
68 #define   T_DDEBUG  31        /* debug SFU interrupt */
69 
70 /*
71  * Reserved range for traps is 0-63, place user flag at 6th bit
72  */
73 #define   T_USER_POS          25
74 #define   T_USER              (1 << (31 - T_USER_POS))
75 
76 /*
77  * Various trap frame flags.
78  */
79 #define   TFF_LAST_POS        0
80 #define   TFF_ITLB_POS        1
81 #define   TFF_SYS_POS         2
82 #define   TFF_INTR_POS        3
83 
84 #define   TFF_LAST  (1 << (31 - TFF_LAST_POS))
85 #define   TFF_ITLB  (1 << (31 - TFF_ITLB_POS))
86 #define   TFF_SYS             (1 << (31 - TFF_SYS_POS))
87 #define   TFF_INTR  (1 << (31 - TFF_INTR_POS))
88 
89 /*
90  * Define this for pretty printings of trapflags.
91  */
92 #define   T_BITS    "\020\07user\036intr\037itlb\040last"
93 
94 /*
95  * These are break instruction entry points.
96  */
97 /* im5 */
98 #define   HPPA_BREAK_KERNEL   0
99 /* im13 */
100 #define   HPPA_BREAK_SS                 4
101 #define   HPPA_BREAK_KGDB               5
102 #define   HPPA_BREAK_GET_PSW  9
103 #define   HPPA_BREAK_SET_PSW  10
104 
105 /*
106  * break instruction decoding.
107  */
108 #define   break5(i) ((i) & 0x1f)
109 #define   break13(i)          (((i) >> 13) & 0x1fff)
110 
111 #endif    /* _HPPA_TRAP_H_ */
112 
113