Thu Apr 16 09:28:52 2020 UTC ()
Fix cur{lwp,cpu} and other bits for MODULES


(skrll)
diff -r1.30 -r1.31 src/sys/arch/hppa/hppa/hppa_machdep.c
diff -r1.9 -r1.10 src/sys/arch/hppa/include/cpu.h

cvs diff -r1.30 -r1.31 src/sys/arch/hppa/hppa/hppa_machdep.c (switch to unified diff)

--- src/sys/arch/hppa/hppa/hppa_machdep.c 2019/11/23 19:40:35 1.30
+++ src/sys/arch/hppa/hppa/hppa_machdep.c 2020/04/16 09:28:52 1.31
@@ -1,305 +1,320 @@ @@ -1,305 +1,320 @@
1/* $NetBSD: hppa_machdep.c,v 1.30 2019/11/23 19:40:35 ad Exp $ */ 1/* $NetBSD: hppa_machdep.c,v 1.31 2020/04/16 09:28:52 skrll Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1997, 2019 The NetBSD Foundation, Inc. 4 * Copyright (c) 1997, 2019 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: hppa_machdep.c,v 1.30 2019/11/23 19:40:35 ad Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: hppa_machdep.c,v 1.31 2020/04/16 09:28:52 skrll Exp $");
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/systm.h> 33#include <sys/systm.h>
34#include <sys/lwp.h> 34#include <sys/lwp.h>
35#include <sys/proc.h> 35#include <sys/proc.h>
36#include <sys/ras.h> 36#include <sys/ras.h>
37#include <sys/cpu.h> 37#include <sys/cpu.h>
38 38
39#include <sys/kernel.h> 39#include <sys/kernel.h>
40 40
41#include <uvm/uvm_extern.h> 41#include <uvm/uvm_extern.h>
42 42
43#include <machine/cpufunc.h> 43#include <machine/cpufunc.h>
44#include <machine/pcb.h> 44#include <machine/pcb.h>
45#include <machine/mcontext.h> 45#include <machine/mcontext.h>
46#include <hppa/hppa/machdep.h> 46#include <hppa/hppa/machdep.h>
47 47
48/* the following is used externally (sysctl_hw) */ 48/* the following is used externally (sysctl_hw) */
49char machine_arch[] = MACHINE_ARCH; /* from <machine/param.h> */ 49char machine_arch[] = MACHINE_ARCH; /* from <machine/param.h> */
50 50
51/* 51/*
52 * XXX fredette - much of the TLB trap handler setup should 52 * XXX fredette - much of the TLB trap handler setup should
53 * probably be moved here from hppa/hppa/machdep.c, seeing 53 * probably be moved here from hppa/hppa/machdep.c, seeing
54 * that there's related code already in hppa/hppa/trap.S. 54 * that there's related code already in hppa/hppa/trap.S.
55 */ 55 */
56 56
57void 57void
58cpu_getmcontext(struct lwp *l, mcontext_t *mcp, unsigned int *flags) 58cpu_getmcontext(struct lwp *l, mcontext_t *mcp, unsigned int *flags)
59{ 59{
60 struct trapframe *tf = l->l_md.md_regs; 60 struct trapframe *tf = l->l_md.md_regs;
61 struct pcb *pcb = lwp_getpcb(l); 61 struct pcb *pcb = lwp_getpcb(l);
62 __greg_t *gr = mcp->__gregs; 62 __greg_t *gr = mcp->__gregs;
63 __greg_t ras_pc; 63 __greg_t ras_pc;
64 64
65 gr[0] = tf->tf_ipsw; 65 gr[0] = tf->tf_ipsw;
66 gr[1] = tf->tf_r1; 66 gr[1] = tf->tf_r1;
67 gr[2] = tf->tf_rp; 67 gr[2] = tf->tf_rp;
68 gr[3] = tf->tf_r3; 68 gr[3] = tf->tf_r3;
69 gr[4] = tf->tf_r4; 69 gr[4] = tf->tf_r4;
70 gr[5] = tf->tf_r5; 70 gr[5] = tf->tf_r5;
71 gr[6] = tf->tf_r6; 71 gr[6] = tf->tf_r6;
72 gr[7] = tf->tf_r7; 72 gr[7] = tf->tf_r7;
73 gr[8] = tf->tf_r8; 73 gr[8] = tf->tf_r8;
74 gr[9] = tf->tf_r9; 74 gr[9] = tf->tf_r9;
75 gr[10] = tf->tf_r10; 75 gr[10] = tf->tf_r10;
76 gr[11] = tf->tf_r11; 76 gr[11] = tf->tf_r11;
77 gr[12] = tf->tf_r12; 77 gr[12] = tf->tf_r12;
78 gr[13] = tf->tf_r13; 78 gr[13] = tf->tf_r13;
79 gr[14] = tf->tf_r14; 79 gr[14] = tf->tf_r14;
80 gr[15] = tf->tf_r15; 80 gr[15] = tf->tf_r15;
81 gr[16] = tf->tf_r16; 81 gr[16] = tf->tf_r16;
82 gr[17] = tf->tf_r17; 82 gr[17] = tf->tf_r17;
83 gr[18] = tf->tf_r18; 83 gr[18] = tf->tf_r18;
84 gr[19] = tf->tf_t4; 84 gr[19] = tf->tf_t4;
85 gr[20] = tf->tf_t3; 85 gr[20] = tf->tf_t3;
86 gr[21] = tf->tf_t2; 86 gr[21] = tf->tf_t2;
87 gr[22] = tf->tf_t1; 87 gr[22] = tf->tf_t1;
88 gr[23] = tf->tf_arg3; 88 gr[23] = tf->tf_arg3;
89 gr[24] = tf->tf_arg2; 89 gr[24] = tf->tf_arg2;
90 gr[25] = tf->tf_arg1; 90 gr[25] = tf->tf_arg1;
91 gr[26] = tf->tf_arg0; 91 gr[26] = tf->tf_arg0;
92 gr[27] = tf->tf_dp; 92 gr[27] = tf->tf_dp;
93 gr[28] = tf->tf_ret0; 93 gr[28] = tf->tf_ret0;
94 gr[29] = tf->tf_ret1; 94 gr[29] = tf->tf_ret1;
95 gr[30] = tf->tf_sp; 95 gr[30] = tf->tf_sp;
96 gr[31] = tf->tf_r31; 96 gr[31] = tf->tf_r31;
97 97
98 gr[_REG_SAR] = tf->tf_sar; 98 gr[_REG_SAR] = tf->tf_sar;
99 gr[_REG_PCSQH] = tf->tf_iisq_head; 99 gr[_REG_PCSQH] = tf->tf_iisq_head;
100 gr[_REG_PCSQT] = tf->tf_iisq_tail; 100 gr[_REG_PCSQT] = tf->tf_iisq_tail;
101 gr[_REG_PCOQH] = tf->tf_iioq_head; 101 gr[_REG_PCOQH] = tf->tf_iioq_head;
102 gr[_REG_PCOQT] = tf->tf_iioq_tail; 102 gr[_REG_PCOQT] = tf->tf_iioq_tail;
103 gr[_REG_SR0] = tf->tf_sr0; 103 gr[_REG_SR0] = tf->tf_sr0;
104 gr[_REG_SR1] = tf->tf_sr1; 104 gr[_REG_SR1] = tf->tf_sr1;
105 gr[_REG_SR2] = tf->tf_sr2; 105 gr[_REG_SR2] = tf->tf_sr2;
106 gr[_REG_SR3] = tf->tf_sr3; 106 gr[_REG_SR3] = tf->tf_sr3;
107 gr[_REG_SR4] = tf->tf_sr4; 107 gr[_REG_SR4] = tf->tf_sr4;
108 gr[_REG_CR27] = tf->tf_cr27; 108 gr[_REG_CR27] = tf->tf_cr27;
109#if 0 109#if 0
110 gr[_REG_CR26] = tf->tf_cr26; 110 gr[_REG_CR26] = tf->tf_cr26;
111#endif 111#endif
112 112
113 ras_pc = (__greg_t)ras_lookup(l->l_proc, 113 ras_pc = (__greg_t)ras_lookup(l->l_proc,
114 (void *)(gr[_REG_PCOQH] & ~HPPA_PC_PRIV_MASK)); 114 (void *)(gr[_REG_PCOQH] & ~HPPA_PC_PRIV_MASK));
115 if (ras_pc != -1) { 115 if (ras_pc != -1) {
116 ras_pc |= HPPA_PC_PRIV_USER; 116 ras_pc |= HPPA_PC_PRIV_USER;
117 gr[_REG_PCOQH] = ras_pc; 117 gr[_REG_PCOQH] = ras_pc;
118 gr[_REG_PCOQT] = ras_pc + 4; 118 gr[_REG_PCOQT] = ras_pc + 4;
119 } 119 }
120 120
121 *flags |= _UC_CPU | _UC_TLSBASE; 121 *flags |= _UC_CPU | _UC_TLSBASE;
122 122
123 if (l->l_md.md_flags & 0) { 123 if (l->l_md.md_flags & 0) {
124 return; 124 return;
125 } 125 }
126 126
127 hppa_fpu_flush(l); 127 hppa_fpu_flush(l);
128 memcpy(&mcp->__fpregs, pcb->pcb_fpregs, sizeof(mcp->__fpregs)); 128 memcpy(&mcp->__fpregs, pcb->pcb_fpregs, sizeof(mcp->__fpregs));
129 *flags |= _UC_FPU; 129 *flags |= _UC_FPU;
130} 130}
131 131
132int 132int
133cpu_mcontext_validate(struct lwp *l, const mcontext_t *mcp) 133cpu_mcontext_validate(struct lwp *l, const mcontext_t *mcp)
134{ 134{
135 const __greg_t *gr = mcp->__gregs; 135 const __greg_t *gr = mcp->__gregs;
136 136
137 if ((gr[_REG_PSW] & (PSW_MBS|PSW_MBZ)) != PSW_MBS) { 137 if ((gr[_REG_PSW] & (PSW_MBS|PSW_MBZ)) != PSW_MBS) {
138 return EINVAL; 138 return EINVAL;
139 } 139 }
140 140
141#if 0 141#if 0
142 /* 142 /*
143 * XXX 143 * XXX
144 * Force the space regs and priviledge bits to 144 * Force the space regs and priviledge bits to
145 * the right values in the trapframe for now. 145 * the right values in the trapframe for now.
146 */ 146 */
147 147
148 if (gr[_REG_PCSQH] != pmap_sid(pmap, gr[_REG_PCOQH])) { 148 if (gr[_REG_PCSQH] != pmap_sid(pmap, gr[_REG_PCOQH])) {
149 return EINVAL; 149 return EINVAL;
150 } 150 }
151 151
152 if (gr[_REG_PCSQT] != pmap_sid(pmap, gr[_REG_PCOQT])) { 152 if (gr[_REG_PCSQT] != pmap_sid(pmap, gr[_REG_PCOQT])) {
153 return EINVAL; 153 return EINVAL;
154 } 154 }
155 155
156 if (gr[_REG_PCOQH] < 0xc0000020 && 156 if (gr[_REG_PCOQH] < 0xc0000020 &&
157 (gr[_REG_PCOQH] & HPPA_PC_PRIV_MASK) != HPPA_PC_PRIV_USER) { 157 (gr[_REG_PCOQH] & HPPA_PC_PRIV_MASK) != HPPA_PC_PRIV_USER) {
158 return EINVAL; 158 return EINVAL;
159 } 159 }
160 160
161 if (gr[_REG_PCOQT] < 0xc0000020 && 161 if (gr[_REG_PCOQT] < 0xc0000020 &&
162 (gr[_REG_PCOQT] & HPPA_PC_PRIV_MASK) != HPPA_PC_PRIV_USER) { 162 (gr[_REG_PCOQT] & HPPA_PC_PRIV_MASK) != HPPA_PC_PRIV_USER) {
163 return EINVAL; 163 return EINVAL;
164 } 164 }
165#endif 165#endif
166 166
167 return 0; 167 return 0;
168} 168}
169 169
170int 170int
171cpu_setmcontext(struct lwp *l, const mcontext_t *mcp, unsigned int flags) 171cpu_setmcontext(struct lwp *l, const mcontext_t *mcp, unsigned int flags)
172{ 172{
173 struct trapframe *tf = l->l_md.md_regs; 173 struct trapframe *tf = l->l_md.md_regs;
174 struct proc *p = l->l_proc; 174 struct proc *p = l->l_proc;
175 struct pmap *pmap = p->p_vmspace->vm_map.pmap; 175 struct pmap *pmap = p->p_vmspace->vm_map.pmap;
176 const __greg_t *gr = mcp->__gregs; 176 const __greg_t *gr = mcp->__gregs;
177 int error; 177 int error;
178 178
179 if ((flags & _UC_CPU) != 0) { 179 if ((flags & _UC_CPU) != 0) {
180 error = cpu_mcontext_validate(l, mcp); 180 error = cpu_mcontext_validate(l, mcp);
181 if (error) 181 if (error)
182 return error; 182 return error;
183 183
184 tf->tf_ipsw = gr[0] | 184 tf->tf_ipsw = gr[0] |
185 (hppa_cpu_ispa20_p() ? PSW_O : 0); 185 (hppa_cpu_ispa20_p() ? PSW_O : 0);
186 tf->tf_r1 = gr[1]; 186 tf->tf_r1 = gr[1];
187 tf->tf_rp = gr[2]; 187 tf->tf_rp = gr[2];
188 tf->tf_r3 = gr[3]; 188 tf->tf_r3 = gr[3];
189 tf->tf_r4 = gr[4]; 189 tf->tf_r4 = gr[4];
190 tf->tf_r5 = gr[5]; 190 tf->tf_r5 = gr[5];
191 tf->tf_r6 = gr[6]; 191 tf->tf_r6 = gr[6];
192 tf->tf_r7 = gr[7]; 192 tf->tf_r7 = gr[7];
193 tf->tf_r8 = gr[8]; 193 tf->tf_r8 = gr[8];
194 tf->tf_r9 = gr[9]; 194 tf->tf_r9 = gr[9];
195 tf->tf_r10 = gr[10]; 195 tf->tf_r10 = gr[10];
196 tf->tf_r11 = gr[11]; 196 tf->tf_r11 = gr[11];
197 tf->tf_r12 = gr[12]; 197 tf->tf_r12 = gr[12];
198 tf->tf_r13 = gr[13]; 198 tf->tf_r13 = gr[13];
199 tf->tf_r14 = gr[14]; 199 tf->tf_r14 = gr[14];
200 tf->tf_r15 = gr[15]; 200 tf->tf_r15 = gr[15];
201 tf->tf_r16 = gr[16]; 201 tf->tf_r16 = gr[16];
202 tf->tf_r17 = gr[17]; 202 tf->tf_r17 = gr[17];
203 tf->tf_r18 = gr[18]; 203 tf->tf_r18 = gr[18];
204 tf->tf_t4 = gr[19]; 204 tf->tf_t4 = gr[19];
205 tf->tf_t3 = gr[20]; 205 tf->tf_t3 = gr[20];
206 tf->tf_t2 = gr[21]; 206 tf->tf_t2 = gr[21];
207 tf->tf_t1 = gr[22]; 207 tf->tf_t1 = gr[22];
208 tf->tf_arg3 = gr[23]; 208 tf->tf_arg3 = gr[23];
209 tf->tf_arg2 = gr[24]; 209 tf->tf_arg2 = gr[24];
210 tf->tf_arg1 = gr[25]; 210 tf->tf_arg1 = gr[25];
211 tf->tf_arg0 = gr[26]; 211 tf->tf_arg0 = gr[26];
212 tf->tf_dp = gr[27]; 212 tf->tf_dp = gr[27];
213 tf->tf_ret0 = gr[28]; 213 tf->tf_ret0 = gr[28];
214 tf->tf_ret1 = gr[29]; 214 tf->tf_ret1 = gr[29];
215 tf->tf_sp = gr[30]; 215 tf->tf_sp = gr[30];
216 tf->tf_r31 = gr[31]; 216 tf->tf_r31 = gr[31];
217 tf->tf_sar = gr[_REG_SAR]; 217 tf->tf_sar = gr[_REG_SAR];
218 tf->tf_iisq_head = pmap_sid(pmap, gr[_REG_PCOQH]); 218 tf->tf_iisq_head = pmap_sid(pmap, gr[_REG_PCOQH]);
219 tf->tf_iisq_tail = pmap_sid(pmap, gr[_REG_PCOQT]); 219 tf->tf_iisq_tail = pmap_sid(pmap, gr[_REG_PCOQT]);
220 220
221 tf->tf_iioq_head = gr[_REG_PCOQH]; 221 tf->tf_iioq_head = gr[_REG_PCOQH];
222 tf->tf_iioq_tail = gr[_REG_PCOQT]; 222 tf->tf_iioq_tail = gr[_REG_PCOQT];
223 223
224 if (tf->tf_iioq_head >= 0xc0000020) { 224 if (tf->tf_iioq_head >= 0xc0000020) {
225 tf->tf_iioq_head &= ~HPPA_PC_PRIV_MASK; 225 tf->tf_iioq_head &= ~HPPA_PC_PRIV_MASK;
226 } else { 226 } else {
227 tf->tf_iioq_head |= HPPA_PC_PRIV_USER; 227 tf->tf_iioq_head |= HPPA_PC_PRIV_USER;
228 } 228 }
229 if (tf->tf_iioq_tail >= 0xc0000020) { 229 if (tf->tf_iioq_tail >= 0xc0000020) {
230 tf->tf_iioq_tail &= ~HPPA_PC_PRIV_MASK; 230 tf->tf_iioq_tail &= ~HPPA_PC_PRIV_MASK;
231 } else { 231 } else {
232 tf->tf_iioq_tail |= HPPA_PC_PRIV_USER; 232 tf->tf_iioq_tail |= HPPA_PC_PRIV_USER;
233 } 233 }
234 234
235#if 0 235#if 0
236 tf->tf_sr0 = gr[_REG_SR0]; 236 tf->tf_sr0 = gr[_REG_SR0];
237 tf->tf_sr1 = gr[_REG_SR1]; 237 tf->tf_sr1 = gr[_REG_SR1];
238 tf->tf_sr2 = gr[_REG_SR2]; 238 tf->tf_sr2 = gr[_REG_SR2];
239 tf->tf_sr3 = gr[_REG_SR3]; 239 tf->tf_sr3 = gr[_REG_SR3];
240 tf->tf_sr4 = gr[_REG_SR4]; 240 tf->tf_sr4 = gr[_REG_SR4];
241 tf->tf_cr26 = gr[_REG_CR26]; 241 tf->tf_cr26 = gr[_REG_CR26];
242#endif 242#endif
243 } 243 }
244 244
245 /* Restore the private thread context */ 245 /* Restore the private thread context */
246 if (flags & _UC_TLSBASE) { 246 if (flags & _UC_TLSBASE) {
247 lwp_setprivate(l, (void *)(uintptr_t)gr[_REG_CR27]); 247 lwp_setprivate(l, (void *)(uintptr_t)gr[_REG_CR27]);
248 tf->tf_cr27 = gr[_REG_CR27]; 248 tf->tf_cr27 = gr[_REG_CR27];
249 } 249 }
250 250
251 /* Restore the floating point registers */ 251 /* Restore the floating point registers */
252 if ((flags & _UC_FPU) != 0) { 252 if ((flags & _UC_FPU) != 0) {
253 struct pcb *pcb = lwp_getpcb(l); 253 struct pcb *pcb = lwp_getpcb(l);
254 254
255 hppa_fpu_flush(l); 255 hppa_fpu_flush(l);
256 memcpy(pcb->pcb_fpregs, &mcp->__fpregs, sizeof(mcp->__fpregs)); 256 memcpy(pcb->pcb_fpregs, &mcp->__fpregs, sizeof(mcp->__fpregs));
257 } 257 }
258 258
259 mutex_enter(p->p_lock); 259 mutex_enter(p->p_lock);
260 if (flags & _UC_SETSTACK) 260 if (flags & _UC_SETSTACK)
261 l->l_sigstk.ss_flags |= SS_ONSTACK; 261 l->l_sigstk.ss_flags |= SS_ONSTACK;
262 if (flags & _UC_CLRSTACK) 262 if (flags & _UC_CLRSTACK)
263 l->l_sigstk.ss_flags &= ~SS_ONSTACK; 263 l->l_sigstk.ss_flags &= ~SS_ONSTACK;
264 mutex_exit(p->p_lock); 264 mutex_exit(p->p_lock);
265 265
266 return 0; 266 return 0;
267} 267}
268 268
269/* 269/*
270 * Do RAS processing. 270 * Do RAS processing.
271 */ 271 */
272 272
273void 273void
274hppa_ras(struct lwp *l) 274hppa_ras(struct lwp *l)
275{ 275{
276 struct proc *p; 276 struct proc *p;
277 struct trapframe *tf; 277 struct trapframe *tf;
278 intptr_t rasaddr; 278 intptr_t rasaddr;
279 279
280 p = l->l_proc; 280 p = l->l_proc;
281 tf = l->l_md.md_regs; 281 tf = l->l_md.md_regs;
282 rasaddr = (intptr_t)ras_lookup(p, (void *)tf->tf_iioq_head); 282 rasaddr = (intptr_t)ras_lookup(p, (void *)tf->tf_iioq_head);
283 if (rasaddr != -1) { 283 if (rasaddr != -1) {
284 rasaddr |= HPPA_PC_PRIV_USER; 284 rasaddr |= HPPA_PC_PRIV_USER;
285 tf->tf_iioq_head = rasaddr; 285 tf->tf_iioq_head = rasaddr;
286 tf->tf_iioq_tail = rasaddr + 4; 286 tf->tf_iioq_tail = rasaddr + 4;
287 } 287 }
288} 288}
289 289
290/* 290/*
291 * Preempt the current LWP if in interrupt from user mode, 291 * Preempt the current LWP if in interrupt from user mode,
292 * or after the current trap/syscall if in system mode. 292 * or after the current trap/syscall if in system mode.
293 */ 293 */
294void 294void
295cpu_need_resched(struct cpu_info *ci, struct lwp *l, int flags) 295cpu_need_resched(struct cpu_info *ci, struct lwp *l, int flags)
296{ 296{
297 297
298 if ((flags & RESCHED_REMOTE) != 0) { 298 if ((flags & RESCHED_REMOTE) != 0) {
299#ifdef MULTIPROCESSOR 299#ifdef MULTIPROCESSOR
300 /* XXX send IPI */ 300 /* XXX send IPI */
301#endif 301#endif
302 } else { 302 } else {
303 setsoftast(l); 303 setsoftast(l);
304 } 304 }
305} 305}
 306
 307#ifdef MODULAR
 308struct lwp *
 309hppa_curlwp(void)
 310{
 311 return curlwp;
 312}
 313
 314struct cpu_info *
 315hppa_curcpu(void)
 316{
 317 return curcpu();
 318}
 319#endif
 320

cvs diff -r1.9 -r1.10 src/sys/arch/hppa/include/cpu.h (switch to unified diff)

--- src/sys/arch/hppa/include/cpu.h 2019/12/05 08:00:05 1.9
+++ src/sys/arch/hppa/include/cpu.h 2020/04/16 09:28:52 1.10
@@ -1,440 +1,450 @@ @@ -1,440 +1,450 @@
1/* $NetBSD: cpu.h,v 1.9 2019/12/05 08:00:05 skrll Exp $ */ 1/* $NetBSD: cpu.h,v 1.10 2020/04/16 09:28:52 skrll Exp $ */
2 2
3/* $OpenBSD: cpu.h,v 1.55 2008/07/23 17:39:35 kettenis Exp $ */ 3/* $OpenBSD: cpu.h,v 1.55 2008/07/23 17:39:35 kettenis Exp $ */
4 4
5/* 5/*
6 * Copyright (c) 2000-2004 Michael Shalayeff 6 * Copyright (c) 2000-2004 Michael Shalayeff
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the 15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution. 16 * documentation and/or other materials provided with the distribution.
17 * 17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 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 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 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, 21 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 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 27 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28 * THE POSSIBILITY OF SUCH DAMAGE. 28 * THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30/* 30/*
31 * Copyright (c) 1988-1994, The University of Utah and 31 * Copyright (c) 1988-1994, The University of Utah and
32 * the Computer Systems Laboratory at the University of Utah (CSL). 32 * the Computer Systems Laboratory at the University of Utah (CSL).
33 * All rights reserved. 33 * All rights reserved.
34 * 34 *
35 * Permission to use, copy, modify and distribute this software is hereby 35 * Permission to use, copy, modify and distribute this software is hereby
36 * granted provided that (1) source code retains these copyright, permission, 36 * granted provided that (1) source code retains these copyright, permission,
37 * and disclaimer notices, and (2) redistributions including binaries 37 * and disclaimer notices, and (2) redistributions including binaries
38 * reproduce the notices in supporting documentation, and (3) all advertising 38 * reproduce the notices in supporting documentation, and (3) all advertising
39 * materials mentioning features or use of this software display the following 39 * materials mentioning features or use of this software display the following
40 * acknowledgement: ``This product includes software developed by the 40 * acknowledgement: ``This product includes software developed by the
41 * Computer Systems Laboratory at the University of Utah.'' 41 * Computer Systems Laboratory at the University of Utah.''
42 * 42 *
43 * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS 43 * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
44 * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF 44 * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
45 * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 45 * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
46 * 46 *
47 * CSL requests users of this software to return to csl-dist@cs.utah.edu any 47 * CSL requests users of this software to return to csl-dist@cs.utah.edu any
48 * improvements that they make and grant CSL redistribution rights. 48 * improvements that they make and grant CSL redistribution rights.
49 * 49 *
50 * Utah $Hdr: cpu.h 1.19 94/12/16$ 50 * Utah $Hdr: cpu.h 1.19 94/12/16$
51 */ 51 */
52 52
53#ifndef _MACHINE_CPU_H_ 53#ifndef _MACHINE_CPU_H_
54#define _MACHINE_CPU_H_ 54#define _MACHINE_CPU_H_
55 55
56#ifdef _KERNEL_OPT 56#ifdef _KERNEL_OPT
57#include "opt_cputype.h" 57#include "opt_cputype.h"
58#include "opt_multiprocessor.h" 58#include "opt_multiprocessor.h"
59#endif 59#endif
60 60
61#include <machine/trap.h> 61#include <machine/trap.h>
62#include <machine/frame.h> 62#include <machine/frame.h>
63#include <machine/reg.h> 63#include <machine/reg.h>
64#include <machine/intrdefs.h> 64#include <machine/intrdefs.h>
65 65
66#ifndef __ASSEMBLER__ 66#ifndef __ASSEMBLER__
67#include <machine/intr.h> 67#include <machine/intr.h>
68#endif 68#endif
69 69
70#ifndef _LOCORE 70#ifndef _LOCORE
71 71
72/* types */ 72/* types */
73enum hppa_cpu_type { 73enum hppa_cpu_type {
74 hpc_unknown, 74 hpc_unknown,
75 hpcx, /* PA7000 (x) PA 1.0 */ 75 hpcx, /* PA7000 (x) PA 1.0 */
76 hpcxs, /* PA7000 (s) PA 1.1a */ 76 hpcxs, /* PA7000 (s) PA 1.1a */
77 hpcxt, /* PA7100 (t) PA 1.1b */ 77 hpcxt, /* PA7100 (t) PA 1.1b */
78 hpcxl, /* PA7100LC (l) PA 1.1c */ 78 hpcxl, /* PA7100LC (l) PA 1.1c */
79 hpcxtp, /* PA7200 (t') PA 1.1d */ 79 hpcxtp, /* PA7200 (t') PA 1.1d */
80 hpcxl2, /* PA7300LC (l2) PA 1.1e */ 80 hpcxl2, /* PA7300LC (l2) PA 1.1e */
81 hpcxu, /* PA8000 (u) PA 2.0 */ 81 hpcxu, /* PA8000 (u) PA 2.0 */
82 hpcxup, /* PA8200 (u+) PA 2.0 */ 82 hpcxup, /* PA8200 (u+) PA 2.0 */
83 hpcxw, /* PA8500 (w) PA 2.0 */ 83 hpcxw, /* PA8500 (w) PA 2.0 */
84 hpcxwp, /* PA8600 (w+) PA 2.0 */ 84 hpcxwp, /* PA8600 (w+) PA 2.0 */
85 hpcxw2, /* PA8700 (piranha) PA 2.0 */ 85 hpcxw2, /* PA8700 (piranha) PA 2.0 */
86 mako /* PA8800 (mako) PA 2.0 */ 86 mako /* PA8800 (mako) PA 2.0 */
87}; 87};
88 88
89#ifdef _KERNEL 89#ifdef _KERNEL
90/* 90/*
91 * A CPU description. 91 * A CPU description.
92 */ 92 */
93struct hppa_cpu_info { 93struct hppa_cpu_info {
94 /* The official name of the chip. */ 94 /* The official name of the chip. */
95 const char *hci_chip_name; 95 const char *hci_chip_name;
96 96
97 /* The nickname for the chip. */ 97 /* The nickname for the chip. */
98 const char *hci_chip_nickname; 98 const char *hci_chip_nickname;
99 99
100 /* The type and PA-RISC specification of the chip. */ 100 /* The type and PA-RISC specification of the chip. */
101 const char hci_chip_type[8]; 101 const char hci_chip_type[8];
102 enum hppa_cpu_type hci_cputype; 102 enum hppa_cpu_type hci_cputype;
103 int hci_cpuversion; 103 int hci_cpuversion;
104 int hci_features; /* CPU types and features */ 104 int hci_features; /* CPU types and features */
105#define HPPA_FTRS_TLBU 0x00000001 105#define HPPA_FTRS_TLBU 0x00000001
106#define HPPA_FTRS_BTLBU 0x00000002 106#define HPPA_FTRS_BTLBU 0x00000002
107#define HPPA_FTRS_HVT 0x00000004 107#define HPPA_FTRS_HVT 0x00000004
108#define HPPA_FTRS_W32B 0x00000008 108#define HPPA_FTRS_W32B 0x00000008
109 109
110 const char *hci_chip_spec; 110 const char *hci_chip_spec;
111 111
112 int (*desidhash)(void); 112 int (*desidhash)(void);
113 const u_int *itlbh, *dtlbh, *itlbnah, *dtlbnah, *tlbdh; 113 const u_int *itlbh, *dtlbh, *itlbnah, *dtlbnah, *tlbdh;
114 int (*dbtlbins)(int, pa_space_t, vaddr_t, paddr_t, vsize_t, u_int); 114 int (*dbtlbins)(int, pa_space_t, vaddr_t, paddr_t, vsize_t, u_int);
115 int (*ibtlbins)(int, pa_space_t, vaddr_t, paddr_t, vsize_t, u_int); 115 int (*ibtlbins)(int, pa_space_t, vaddr_t, paddr_t, vsize_t, u_int);
116 int (*btlbprg)(int); 116 int (*btlbprg)(int);
117 int (*hptinit)(vaddr_t, vsize_t); 117 int (*hptinit)(vaddr_t, vsize_t);
118}; 118};
119 119
120extern const struct hppa_cpu_info *hppa_cpu_info; 120extern const struct hppa_cpu_info *hppa_cpu_info;
121extern int cpu_modelno; 121extern int cpu_modelno;
122extern int cpu_revision; 122extern int cpu_revision;
123#endif 123#endif
124#endif 124#endif
125 125
126/* 126/*
127 * COPR/SFUs 127 * COPR/SFUs
128 */ 128 */
129#define HPPA_FPUS 0xc0 129#define HPPA_FPUS 0xc0
130#define HPPA_PMSFUS 0x20 /* ??? */ 130#define HPPA_PMSFUS 0x20 /* ??? */
131 131
132/* 132/*
133 * Exported definitions unique to hppa/PA-RISC cpu support. 133 * Exported definitions unique to hppa/PA-RISC cpu support.
134 */ 134 */
135 135
136/* 136/*
137 * COPR/SFUs 137 * COPR/SFUs
138 */ 138 */
139#define HPPA_FPUVER(w) (((w) & 0x003ff800) >> 11) 139#define HPPA_FPUVER(w) (((w) & 0x003ff800) >> 11)
140#define HPPA_FPU_OP(w) ((w) >> 26) 140#define HPPA_FPU_OP(w) ((w) >> 26)
141#define HPPA_FPU_UNMPL 0x01 /* exception reg, the rest is << 1 */ 141#define HPPA_FPU_UNMPL 0x01 /* exception reg, the rest is << 1 */
142#define HPPA_FPU_ILL 0x80 /* software-only */ 142#define HPPA_FPU_ILL 0x80 /* software-only */
143#define HPPA_FPU_I 0x01 143#define HPPA_FPU_I 0x01
144#define HPPA_FPU_U 0x02 144#define HPPA_FPU_U 0x02
145#define HPPA_FPU_O 0x04 145#define HPPA_FPU_O 0x04
146#define HPPA_FPU_Z 0x08 146#define HPPA_FPU_Z 0x08
147#define HPPA_FPU_V 0x10 147#define HPPA_FPU_V 0x10
148#define HPPA_FPU_D 0x20 148#define HPPA_FPU_D 0x20
149#define HPPA_FPU_T 0x40 149#define HPPA_FPU_T 0x40
150#define HPPA_FPU_XMASK 0x7f 150#define HPPA_FPU_XMASK 0x7f
151#define HPPA_FPU_T_POS 25 151#define HPPA_FPU_T_POS 25
152#define HPPA_FPU_RM 0x00000600 152#define HPPA_FPU_RM 0x00000600
153#define HPPA_FPU_CQ 0x00fff800 153#define HPPA_FPU_CQ 0x00fff800
154#define HPPA_FPU_C 0x04000000 154#define HPPA_FPU_C 0x04000000
155#define HPPA_FPU_FLSH 27 155#define HPPA_FPU_FLSH 27
156#define HPPA_FPU_INIT (0) 156#define HPPA_FPU_INIT (0)
157#define HPPA_FPU_FORK(s) ((s) & ~((uint64_t)(HPPA_FPU_XMASK) << 32)) 157#define HPPA_FPU_FORK(s) ((s) & ~((uint64_t)(HPPA_FPU_XMASK) << 32))
158 158
159/* 159/*
160 * definitions of cpu-dependent requirements 160 * definitions of cpu-dependent requirements
161 * referenced in generic code 161 * referenced in generic code
162 */ 162 */
163#if defined(HP8000_CPU) || defined(HP8200_CPU) || \ 163#if defined(HP8000_CPU) || defined(HP8200_CPU) || \
164 defined(HP8500_CPU) || defined(HP8600_CPU) 164 defined(HP8500_CPU) || defined(HP8600_CPU)
165 165
166/* PA2.0 aliases */ 166/* PA2.0 aliases */
167#define HPPA_PGALIAS 0x00400000 167#define HPPA_PGALIAS 0x00400000
168#define HPPA_PGAMASK 0xffc00000 /* PA bits 0-9 not used in index */ 168#define HPPA_PGAMASK 0xffc00000 /* PA bits 0-9 not used in index */
169#define HPPA_PGAOFF 0x003fffff 169#define HPPA_PGAOFF 0x003fffff
170 170
171#else 171#else
172 172
173/* PA1.x aliases */ 173/* PA1.x aliases */
174#define HPPA_PGALIAS 0x00100000 174#define HPPA_PGALIAS 0x00100000
175#define HPPA_PGAMASK 0xfff00000 /* PA bits 0-11 not used in index */ 175#define HPPA_PGAMASK 0xfff00000 /* PA bits 0-11 not used in index */
176#define HPPA_PGAOFF 0x000fffff 176#define HPPA_PGAOFF 0x000fffff
177 177
178#endif 178#endif
179 179
180#define HPPA_SPAMASK 0xf0f0f000 /* PA bits 0-3,8-11,16-19 not used */ 180#define HPPA_SPAMASK 0xf0f0f000 /* PA bits 0-3,8-11,16-19 not used */
181 181
182#define HPPA_IOSPACE 0xf0000000 182#define HPPA_IOSPACE 0xf0000000
183#define HPPA_IOLEN 0x10000000 183#define HPPA_IOLEN 0x10000000
184#define HPPA_PDC_LOW 0xef000000 184#define HPPA_PDC_LOW 0xef000000
185#define HPPA_PDC_HIGH 0xf1000000 185#define HPPA_PDC_HIGH 0xf1000000
186#define HPPA_IOBCAST 0xfffc0000 186#define HPPA_IOBCAST 0xfffc0000
187#define HPPA_LBCAST 0xfffc0000 187#define HPPA_LBCAST 0xfffc0000
188#define HPPA_GBCAST 0xfffe0000 188#define HPPA_GBCAST 0xfffe0000
189#define HPPA_FPA 0xfff80000 189#define HPPA_FPA 0xfff80000
190#define HPPA_FLEX_DATA 0xfff80001 190#define HPPA_FLEX_DATA 0xfff80001
191#define HPPA_DMA_ENABLE 0x00000001 191#define HPPA_DMA_ENABLE 0x00000001
192#define HPPA_SPA_ENABLE 0x00000020 192#define HPPA_SPA_ENABLE 0x00000020
193#define HPPA_NMODSPBUS 64 193#define HPPA_NMODSPBUS 64
194 194
195#ifdef MULTIPROCESSOR 195#ifdef MULTIPROCESSOR
196 196
197#define GET_CURCPU(r) mfctl CR_CURCPU, r 197#define GET_CURCPU(r) mfctl CR_CURCPU, r
198#define GET_CURCPU_SPACE(s, r) GET_CURCPU(r) 198#define GET_CURCPU_SPACE(s, r) GET_CURCPU(r)
199#define GET_CURLWP(r) mfctl CR_CURCPU, r ! ldw CI_CURLWP(r), r 199#define GET_CURLWP(r) mfctl CR_CURCPU, r ! ldw CI_CURLWP(r), r
200#define GET_CURLWP_SPACE(s, r) mfctl CR_CURCPU, r ! ldw CI_CURLWP(s, r), r 200#define GET_CURLWP_SPACE(s, r) mfctl CR_CURCPU, r ! ldw CI_CURLWP(s, r), r
201 201
202#define SET_CURLWP(r,t) mfctl CR_CURCPU, t ! stw r, CI_CURLWP(t) 202#define SET_CURLWP(r,t) mfctl CR_CURCPU, t ! stw r, CI_CURLWP(t)
203 203
204#else /* MULTIPROCESSOR */ 204#else /* MULTIPROCESSOR */
205 205
206#define GET_CURCPU(r) mfctl CR_CURLWP, r ! ldw L_CPU(r), r 206#define GET_CURCPU(r) mfctl CR_CURLWP, r ! ldw L_CPU(r), r
207#define GET_CURCPU_SPACE(s, r) mfctl CR_CURLWP, r ! ldw L_CPU(s, r), r 207#define GET_CURCPU_SPACE(s, r) mfctl CR_CURLWP, r ! ldw L_CPU(s, r), r
208#define GET_CURLWP(r) mfctl CR_CURLWP, r 208#define GET_CURLWP(r) mfctl CR_CURLWP, r
209#define GET_CURLWP_SPACE(s, r) GET_CURLWP(r) 209#define GET_CURLWP_SPACE(s, r) GET_CURLWP(r)
210 210
211#define SET_CURLWP(r,t) mtctl r, CR_CURLWP 211#define SET_CURLWP(r,t) mtctl r, CR_CURLWP
212 212
213#endif /* MULTIPROCESSOR */ 213#endif /* MULTIPROCESSOR */
214 214
215#ifndef _LOCORE 215#ifndef _LOCORE
216#ifdef _KERNEL 216#ifdef _KERNEL
217 217
218/* 218/*
219 * External definitions unique to PA-RISC cpu support. 219 * External definitions unique to PA-RISC cpu support.
220 * These are the "public" declarations - those needed in 220 * These are the "public" declarations - those needed in
221 * machine-independent source code. The "private" ones 221 * machine-independent source code. The "private" ones
222 * are in machdep.h. 222 * are in machdep.h.
223 * 223 *
224 * Note that the name of this file is NOT meant to imply 224 * Note that the name of this file is NOT meant to imply
225 * that it has anything to do with PA-RISC CPU stuff. 225 * that it has anything to do with PA-RISC CPU stuff.
226 * The name "cpu" is historical, and used in the common 226 * The name "cpu" is historical, and used in the common
227 * code to identify machine-dependent functions, etc. 227 * code to identify machine-dependent functions, etc.
228 */ 228 */
229 229
230/* clockframe describes the system before we took an interrupt. */ 230/* clockframe describes the system before we took an interrupt. */
231struct clockframe { 231struct clockframe {
232 int cf_flags; 232 int cf_flags;
233 int cf_spl; 233 int cf_spl;
234 u_int cf_pc; 234 u_int cf_pc;
235}; 235};
236#define CLKF_PC(framep) ((framep)->cf_pc) 236#define CLKF_PC(framep) ((framep)->cf_pc)
237#define CLKF_INTR(framep) ((framep)->cf_flags & TFF_INTR) 237#define CLKF_INTR(framep) ((framep)->cf_flags & TFF_INTR)
238#define CLKF_USERMODE(framep) ((framep)->cf_flags & T_USER) 238#define CLKF_USERMODE(framep) ((framep)->cf_flags & T_USER)
239 239
240int clock_intr(void *); 240int clock_intr(void *);
241 241
242/* 242/*
243 * LWP_PC: the program counter for the given lwp. 243 * LWP_PC: the program counter for the given lwp.
244 */ 244 */
245#define LWP_PC(l) ((l)->l_md.md_regs->tf_iioq_head) 245#define LWP_PC(l) ((l)->l_md.md_regs->tf_iioq_head)
246 246
247#define cpu_signotify(l) (setsoftast(l)) 247#define cpu_signotify(l) (setsoftast(l))
248#define cpu_need_proftick(l) ((l)->l_pflag |= LP_OWEUPC, setsoftast(l)) 248#define cpu_need_proftick(l) ((l)->l_pflag |= LP_OWEUPC, setsoftast(l))
249 249
250#endif /* _KERNEL */ 250#endif /* _KERNEL */
251 251
252#ifndef __ASSEMBLER__ 252#ifndef __ASSEMBLER__
253#if defined(_KERNEL) || defined(_KMEMUSER) 253#if defined(_KERNEL) || defined(_KMEMUSER)
254 254
255#include <sys/cpu_data.h> 255#include <sys/cpu_data.h>
256#include <sys/evcnt.h> 256#include <sys/evcnt.h>
257 257
258/* 258/*
259 * Note that the alignment of ci_trap_save is important since we want to keep 259 * Note that the alignment of ci_trap_save is important since we want to keep
260 * it within a single cache line. As a result, it must be kept as the first 260 * it within a single cache line. As a result, it must be kept as the first
261 * entry within the cpu_info struct. 261 * entry within the cpu_info struct.
262 */ 262 */
263struct cpu_info { 263struct cpu_info {
264 /* Keep this first to simplify the trap handlers */ 264 /* Keep this first to simplify the trap handlers */
265 register_t ci_trapsave[16];/* the "phys" part of frame */ 265 register_t ci_trapsave[16];/* the "phys" part of frame */
266 266
267 struct cpu_data ci_data; /* MI per-cpu data */ 267 struct cpu_data ci_data; /* MI per-cpu data */
268 268
269#ifndef _KMEMUSER 269#ifndef _KMEMUSER
270 hppa_hpa_t ci_hpa; 270 hppa_hpa_t ci_hpa;
271 register_t ci_psw; /* Processor Status Word. */ 271 register_t ci_psw; /* Processor Status Word. */
272 paddr_t ci_fpu_state; /* LWP FPU state address, or zero. */ 272 paddr_t ci_fpu_state; /* LWP FPU state address, or zero. */
273 u_long ci_itmr; 273 u_long ci_itmr;
274 274
275 int ci_cpuid; /* CPU index (see cpus[] array) */ 275 int ci_cpuid; /* CPU index (see cpus[] array) */
276 int ci_mtx_count; 276 int ci_mtx_count;
277 int ci_mtx_oldspl; 277 int ci_mtx_oldspl;
278 int ci_want_resched; 278 int ci_want_resched;
279 279
280 volatile int ci_cpl; 280 volatile int ci_cpl;
281 volatile int ci_ipending; /* The pending interrupts. */ 281 volatile int ci_ipending; /* The pending interrupts. */
282 u_int ci_intr_depth; /* Nonzero iff running an interrupt. */ 282 u_int ci_intr_depth; /* Nonzero iff running an interrupt. */
283 u_int ci_ishared; 283 u_int ci_ishared;
284 u_int ci_eiem; 284 u_int ci_eiem;
285 285
286 u_int ci_imask[NIPL]; 286 u_int ci_imask[NIPL];
287 287
288 struct hppa_interrupt_register ci_ir; 288 struct hppa_interrupt_register ci_ir;
289 struct hppa_interrupt_bit ci_ib[HPPA_INTERRUPT_BITS]; 289 struct hppa_interrupt_bit ci_ib[HPPA_INTERRUPT_BITS];
290 290
291 struct lwp *ci_onproc; /* current user LWP / kthread */ 291 struct lwp *ci_onproc; /* current user LWP / kthread */
292#if defined(MULTIPROCESSOR) 292#if defined(MULTIPROCESSOR)
293 struct lwp *ci_curlwp; /* CPU owner */ 293 struct lwp *ci_curlwp; /* CPU owner */
294 paddr_t ci_stack; /* stack for spin up */ 294 paddr_t ci_stack; /* stack for spin up */
295 volatile int ci_flags; /* CPU status flags */ 295 volatile int ci_flags; /* CPU status flags */
296#define CPUF_PRIMARY 0x0001 /* ... is monarch/primary */ 296#define CPUF_PRIMARY 0x0001 /* ... is monarch/primary */
297#define CPUF_RUNNING 0x0002 /* ... is running. */ 297#define CPUF_RUNNING 0x0002 /* ... is running. */
298 298
299 volatile u_long ci_ipi; /* IPIs pending */ 299 volatile u_long ci_ipi; /* IPIs pending */
300 300
301 struct cpu_softc *ci_softc; 301 struct cpu_softc *ci_softc;
302#endif 302#endif
303 303
304#endif /* !_KMEMUSER */ 304#endif /* !_KMEMUSER */
305} __aligned(64); 305} __aligned(64);
306 306
307#endif /* _KERNEL || _KMEMUSER */ 307#endif /* _KERNEL || _KMEMUSER */
308#endif /* __ASSEMBLER__ */ 308#endif /* __ASSEMBLER__ */
309 309
310#if defined(_KERNEL) 310#if defined(_KERNEL)
311 311
312/* 312/*
313 * definitions of cpu-dependent requirements 313 * definitions of cpu-dependent requirements
314 * referenced in generic code 314 * referenced in generic code
315 */ 315 */
316 316
317void cpu_proc_fork(struct proc *, struct proc *); 317void cpu_proc_fork(struct proc *, struct proc *);
318 318
319#ifdef MULTIPROCESSOR 319struct lwp *hppa_curlwp(void);
 320struct cpu_info *hppa_curcpu(void);
 321
 322#if defined(_MODULE)
 323#define curcpu() hppa_curcpu()
 324#define curlwp hppa_curlwp()
 325#endif
320 326
 327#if defined(MULTIPROCESSOR) || defined(_MODULE)
321/* Number of CPUs in the system */ 328/* Number of CPUs in the system */
322extern int hppa_ncpu; 329extern int hppa_ncpu;
323 330
324#define HPPA_MAXCPUS 4 331#define HPPA_MAXCPUS 4
 332
325#define cpu_number() (curcpu()->ci_cpuid) 333#define cpu_number() (curcpu()->ci_cpuid)
326 334
327#define CPU_IS_PRIMARY(ci) ((ci)->ci_cpuid == 0) 335#define CPU_IS_PRIMARY(ci) ((ci)->ci_cpuid == 0)
328#define CPU_INFO_ITERATOR int 336#define CPU_INFO_ITERATOR int
329#define CPU_INFO_FOREACH(cii, ci) cii = 0, ci = &cpus[0]; cii < hppa_ncpu; cii++, ci++ 337#define CPU_INFO_FOREACH(cii, ci) cii = 0, ci = &cpus[0]; cii < hppa_ncpu; cii++, ci++
330 338
331void cpu_boot_secondary_processors(void); 339void cpu_boot_secondary_processors(void);
332 340
 341#if !defined(_MODULE)
333static __inline struct cpu_info * 342static __inline struct cpu_info *
334hppa_curcpu(void) 343_hppa_curcpu(void)
335{ 344{
336 struct cpu_info *ci; 345 struct cpu_info *ci;
337 346
338 __asm volatile("mfctl %1, %0" : "=r" (ci): "i" (CR_CURCPU)); 347 __asm volatile("mfctl %1, %0" : "=r" (ci): "i" (CR_CURCPU));
339 348
340 return ci; 349 return ci;
341} 350}
342 351
343#define curcpu() hppa_curcpu() 352#define curcpu() _hppa_curcpu()
 353#endif
344 354
345#else /* MULTIPROCESSOR */ 355#else /* MULTIPROCESSOR */
346 356
347#define HPPA_MAXCPUS 1 357#define HPPA_MAXCPUS 1
348#define curcpu() (&cpus[0]) 358#define curcpu() (&cpus[0])
349#define cpu_number() 0 359#define cpu_number() 0
350 360
351static __inline struct lwp * 361static __inline struct lwp *
352hppa_curlwp(void) 362_hppa_curlwp(void)
353{ 363{
354 struct lwp *l; 364 struct lwp *l;
355 365
356 __asm volatile("mfctl %1, %0" : "=r" (l): "i" (CR_CURLWP)); 366 __asm volatile("mfctl %1, %0" : "=r" (l): "i" (CR_CURLWP));
357 367
358 return l; 368 return l;
359} 369}
360 370
361#define curlwp hppa_curlwp() 371#define curlwp _hppa_curlwp()
362 372
363#endif /* MULTIPROCESSOR */ 373#endif /* MULTIPROCESSOR */
364 374
365extern struct cpu_info cpus[HPPA_MAXCPUS]; 375extern struct cpu_info cpus[HPPA_MAXCPUS];
366 376
367#define DELAY(x) delay(x) 377#define DELAY(x) delay(x)
368 378
369static __inline paddr_t 379static __inline paddr_t
370kvtop(const void *va) 380kvtop(const void *va)
371{ 381{
372 paddr_t pa; 382 paddr_t pa;
373 383
374 __asm volatile ("lpa %%r0(%1), %0" : "=r" (pa) : "r" (va)); 384 __asm volatile ("lpa %%r0(%1), %0" : "=r" (pa) : "r" (va));
375 return pa; 385 return pa;
376} 386}
377 387
378extern int (*cpu_desidhash)(void); 388extern int (*cpu_desidhash)(void);
379 389
380static __inline bool 390static __inline bool
381hppa_cpu_ispa20_p(void) 391hppa_cpu_ispa20_p(void)
382{ 392{
383 393
384 return (hppa_cpu_info->hci_features & HPPA_FTRS_W32B) != 0; 394 return (hppa_cpu_info->hci_features & HPPA_FTRS_W32B) != 0;
385} 395}
386 396
387static __inline bool 397static __inline bool
388hppa_cpu_hastlbu_p(void) 398hppa_cpu_hastlbu_p(void)
389{ 399{
390 400
391 return (hppa_cpu_info->hci_features & HPPA_FTRS_TLBU) != 0; 401 return (hppa_cpu_info->hci_features & HPPA_FTRS_TLBU) != 0;
392} 402}
393 403
394void delay(u_int); 404void delay(u_int);
395void hppa_init(paddr_t, void *); 405void hppa_init(paddr_t, void *);
396void trap(int, struct trapframe *); 406void trap(int, struct trapframe *);
397void hppa_ras(struct lwp *); 407void hppa_ras(struct lwp *);
398int spcopy(pa_space_t, const void *, pa_space_t, void *, size_t); 408int spcopy(pa_space_t, const void *, pa_space_t, void *, size_t);
399int spstrcpy(pa_space_t, const void *, pa_space_t, void *, size_t, 409int spstrcpy(pa_space_t, const void *, pa_space_t, void *, size_t,
400 size_t *); 410 size_t *);
401int copy_on_fault(void); 411int copy_on_fault(void);
402void lwp_trampoline(void); 412void lwp_trampoline(void);
403int cpu_dumpsize(void); 413int cpu_dumpsize(void);
404int cpu_dump(void); 414int cpu_dump(void);
405 415
406#ifdef MULTIPROCESSOR 416#ifdef MULTIPROCESSOR
407void cpu_boot_secondary_processors(void); 417void cpu_boot_secondary_processors(void);
408void cpu_hw_init(void); 418void cpu_hw_init(void);
409void cpu_hatch(void); 419void cpu_hatch(void);
410#endif 420#endif
411#endif /* _KERNEL */ 421#endif /* _KERNEL */
412 422
413/* 423/*
414 * Boot arguments stuff 424 * Boot arguments stuff
415 */ 425 */
416 426
417#define BOOTARG_LEN (PAGE_SIZE) 427#define BOOTARG_LEN (PAGE_SIZE)
418#define BOOTARG_OFF (0x10000) 428#define BOOTARG_OFF (0x10000)
419 429
420/* 430/*
421 * CTL_MACHDEP definitions. 431 * CTL_MACHDEP definitions.
422 */ 432 */
423#define CPU_CONSDEV 1 /* dev_t: console terminal device */ 433#define CPU_CONSDEV 1 /* dev_t: console terminal device */
424#define CPU_BOOTED_KERNEL 2 /* string: booted kernel name */ 434#define CPU_BOOTED_KERNEL 2 /* string: booted kernel name */
425#define CPU_LCD_BLINK 3 /* int: twiddle heartbeat LED/LCD */ 435#define CPU_LCD_BLINK 3 /* int: twiddle heartbeat LED/LCD */
426 436
427#ifdef _KERNEL 437#ifdef _KERNEL
428#include <sys/queue.h> 438#include <sys/queue.h>
429 439
430struct blink_lcd { 440struct blink_lcd {
431 void (*bl_func)(void *, int); 441 void (*bl_func)(void *, int);
432 void *bl_arg; 442 void *bl_arg;
433 SLIST_ENTRY(blink_lcd) bl_next; 443 SLIST_ENTRY(blink_lcd) bl_next;
434}; 444};
435 445
436extern void blink_lcd_register(struct blink_lcd *); 446extern void blink_lcd_register(struct blink_lcd *);
437#endif /* _KERNEL */ 447#endif /* _KERNEL */
438#endif /* !_LOCORE */ 448#endif /* !_LOCORE */
439 449
440#endif /* _MACHINE_CPU_H_ */ 450#endif /* _MACHINE_CPU_H_ */