frame.h revision 1.23 1 /* $NetBSD: frame.h,v 1.23 2011/06/20 07:31:18 matt Exp $ */
2
3 /*
4 * Copyright (C) 1995, 1996 Wolfgang Solfrank.
5 * Copyright (C) 1995, 1996 TooLs GmbH.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by TooLs GmbH.
19 * 4. The name of TooLs GmbH may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33 #ifndef _POWERPC_FRAME_H_
34 #define _POWERPC_FRAME_H_
35
36 #include <machine/types.h>
37
38 #ifdef _KERNEL
39 #ifdef _KERNEL_OPT
40 #include "opt_ppcarch.h"
41 #endif
42 #endif
43
44 /*
45 * We have to save all registers on every trap, because
46 * 1. user could attach this process every time
47 * 2. we must be able to restore all user registers in case of fork
48 * Actually, we do not save the fp registers on trap, since
49 * these are not used by the kernel. They are saved only when switching
50 * between processes using the FPU.
51 *
52 * Change ordering to cluster together these register_t's. XXX
53 */
54 struct reg_sans_pc {
55 register_t r_fixreg[32];
56 register_t r_lr;
57 uint32_t r_cr;
58 uint32_t r_xer;
59 register_t r_ctr;
60 };
61
62 struct utrapframe {
63 register_t fixreg[32];
64 register_t lr;
65 int cr;
66 int xer;
67 register_t ctr;
68 register_t srr0;
69 register_t srr1;
70 int vrsave;
71 int mq;
72 int spare;
73 };
74
75 struct clockframe {
76 register_t cf_srr0;
77 register_t cf_srr1;
78 int cf_idepth;
79 };
80
81 struct trapframe {
82 struct reg_sans_pc tf_ureg;
83 struct clockframe tf_cf;
84 uint32_t tf_exc;
85 #if defined(PPC_OEA) || defined(PPC_OEA64) || defined(PPC_OEA64_BRIDGE)
86 register_t tf_dar;
87 register_t tf_pad0[2];
88 uint32_t tf_dsisr;
89 uint32_t tf_vrsave;
90 uint32_t tf_mq;
91 uint32_t tf_pad1[1];
92 #endif
93 #if defined(PPC_BOOKE) || defined(PPC_IBM4XX)
94 register_t tf_dear;
95 register_t tf_mcar;
96 register_t tf_sprg1;
97 uint32_t tf_esr;
98 uint32_t tf_mcsr;
99 uint32_t tf_pid;
100 uint32_t tf_spefscr;
101 #endif
102 };
103 #define tf_fixreg tf_ureg.r_fixreg
104 #define tf_lr tf_ureg.r_lr
105 #define tf_cr tf_ureg.r_cr
106 #define tf_xer tf_ureg.r_xer
107 #define tf_ctr tf_ureg.r_ctr
108 #define tf_srr0 tf_cf.cf_srr0
109 #define tf_srr1 tf_cf.cf_srr1
110 #define tf_idepth tf_cf.cf_idepth
111
112 struct ktrapframe {
113 register_t ktf_sp;
114 register_t ktf_lr;
115 struct trapframe ktf_tf;
116 };
117
118 #if defined(_KERNEL) || defined(_LKM)
119 #ifdef _LP64
120 struct utrapframe32 {
121 register32_t fixreg[32];
122 register32_t lr;
123 int cr;
124 int xer;
125 register32_t ctr;
126 register32_t srr0;
127 register32_t srr1;
128 int vrsave;
129 int mq;
130 int spare;
131 };
132 #endif
133 #endif /* _KERNEL || _LKM */
134
135 /*
136 * This is to ensure alignment of the stackpointer
137 */
138 #define FRAMELEN roundup(sizeof(struct ktrapframe), CALLFRAMELEN)
139 #define ktrapframe(l) ((struct ktrapframe *)(uvm_lwp_getuarea(l) + USPACE - CALLFRAMELEN - FRAMELEN))
140 #define trapframe(l) (&(ktrapframe(l)->ktf_tf))
141
142 #define SFRAMELEN roundup(sizeof(struct switchframe), CALLFRAMELEN)
143 struct switchframe {
144 register_t sf_sp;
145 register_t sf_lr;
146 register_t sf_user_sr; /* VSID on IBM4XX */
147 register_t sf_cr; /* why? CR is volatile. */
148 register_t sf_fixreg2;
149 register_t sf_fixreg[19]; /* R13-R31 */
150 };
151
152 /*
153 * Call frame for PowerPC used during fork.
154 */
155 #define CALLFRAMELEN sizeof(struct callframe)
156 struct callframe {
157 register_t cf_sp;
158 register_t cf_lr;
159 register_t cf_r30;
160 register_t cf_r31;
161 };
162
163 struct saframe {
164 register_t saf_r1; /* stack pointer */
165 register_t saf_lr; /* Callee lr save area */
166 #ifndef _LP64
167 register_t saf_fill[2]; /* Pad to multiple of 16 bytes */
168 #endif
169 };
170
171 #endif /* _POWERPC_FRAME_H_ */
172