| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: hppa_machdep.c,v 1.25 2011/02/24 08:59:22 skrll Exp $ */ | | 1 | /* $NetBSD: hppa_machdep.c,v 1.26 2011/12/08 21:00:49 skrll Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1997 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1997 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. |
| @@ -17,27 +17,27 @@ | | | @@ -17,27 +17,27 @@ |
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.25 2011/02/24 08:59:22 skrll Exp $"); | | 30 | __KERNEL_RCSID(0, "$NetBSD: hppa_machdep.c,v 1.26 2011/12/08 21:00:49 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/sa.h> | | 34 | #include <sys/sa.h> |
35 | #include <sys/lwp.h> | | 35 | #include <sys/lwp.h> |
36 | #include <sys/savar.h> | | 36 | #include <sys/savar.h> |
37 | #include <sys/proc.h> | | 37 | #include <sys/proc.h> |
38 | #include <sys/ras.h> | | 38 | #include <sys/ras.h> |
39 | #include <sys/cpu.h> | | 39 | #include <sys/cpu.h> |
40 | | | 40 | |
41 | #include <sys/kernel.h> | | 41 | #include <sys/kernel.h> |
42 | | | 42 | |
43 | #include <uvm/uvm_extern.h> | | 43 | #include <uvm/uvm_extern.h> |
| @@ -191,27 +191,27 @@ cpu_getmcontext(struct lwp *l, mcontext_ | | | @@ -191,27 +191,27 @@ cpu_getmcontext(struct lwp *l, mcontext_ |
191 | gr[_REG_CR27] = tf->tf_cr27; | | 191 | gr[_REG_CR27] = tf->tf_cr27; |
192 | #if 0 | | 192 | #if 0 |
193 | gr[_REG_CR26] = tf->tf_cr26; | | 193 | gr[_REG_CR26] = tf->tf_cr26; |
194 | #endif | | 194 | #endif |
195 | | | 195 | |
196 | ras_pc = (__greg_t)ras_lookup(l->l_proc, | | 196 | ras_pc = (__greg_t)ras_lookup(l->l_proc, |
197 | (void *)(gr[_REG_PCOQH] & ~HPPA_PC_PRIV_MASK)); | | 197 | (void *)(gr[_REG_PCOQH] & ~HPPA_PC_PRIV_MASK)); |
198 | if (ras_pc != -1) { | | 198 | if (ras_pc != -1) { |
199 | ras_pc |= HPPA_PC_PRIV_USER; | | 199 | ras_pc |= HPPA_PC_PRIV_USER; |
200 | gr[_REG_PCOQH] = ras_pc; | | 200 | gr[_REG_PCOQH] = ras_pc; |
201 | gr[_REG_PCOQT] = ras_pc + 4; | | 201 | gr[_REG_PCOQT] = ras_pc + 4; |
202 | } | | 202 | } |
203 | | | 203 | |
204 | *flags |= _UC_CPU; | | 204 | *flags |= _UC_CPU | _UC_TLSBASE; |
205 | | | 205 | |
206 | if (l->l_md.md_flags & 0) { | | 206 | if (l->l_md.md_flags & 0) { |
207 | return; | | 207 | return; |
208 | } | | 208 | } |
209 | | | 209 | |
210 | hppa_fpu_flush(l); | | 210 | hppa_fpu_flush(l); |
211 | memcpy(&mcp->__fpregs, pcb->pcb_fpregs, sizeof(mcp->__fpregs)); | | 211 | memcpy(&mcp->__fpregs, pcb->pcb_fpregs, sizeof(mcp->__fpregs)); |
212 | *flags |= _UC_FPU; | | 212 | *flags |= _UC_FPU; |
213 | } | | 213 | } |
214 | | | 214 | |
215 | int | | 215 | int |
216 | cpu_setmcontext(struct lwp *l, const mcontext_t *mcp, unsigned int flags) | | 216 | cpu_setmcontext(struct lwp *l, const mcontext_t *mcp, unsigned int flags) |
217 | { | | 217 | { |
| @@ -293,39 +293,43 @@ cpu_setmcontext(struct lwp *l, const mco | | | @@ -293,39 +293,43 @@ cpu_setmcontext(struct lwp *l, const mco |
293 | tf->tf_iioq_tail = gr[_REG_PCOQT]; | | 293 | tf->tf_iioq_tail = gr[_REG_PCOQT]; |
294 | | | 294 | |
295 | if (tf->tf_iioq_head >= 0xc0000020) { | | 295 | if (tf->tf_iioq_head >= 0xc0000020) { |
296 | tf->tf_iioq_head &= ~HPPA_PC_PRIV_MASK; | | 296 | tf->tf_iioq_head &= ~HPPA_PC_PRIV_MASK; |
297 | } else { | | 297 | } else { |
298 | tf->tf_iioq_head |= HPPA_PC_PRIV_USER; | | 298 | tf->tf_iioq_head |= HPPA_PC_PRIV_USER; |
299 | } | | 299 | } |
300 | if (tf->tf_iioq_tail >= 0xc0000020) { | | 300 | if (tf->tf_iioq_tail >= 0xc0000020) { |
301 | tf->tf_iioq_tail &= ~HPPA_PC_PRIV_MASK; | | 301 | tf->tf_iioq_tail &= ~HPPA_PC_PRIV_MASK; |
302 | } else { | | 302 | } else { |
303 | tf->tf_iioq_tail |= HPPA_PC_PRIV_USER; | | 303 | tf->tf_iioq_tail |= HPPA_PC_PRIV_USER; |
304 | } | | 304 | } |
305 | | | 305 | |
306 | lwp_setprivate(l, (void *)(uintptr_t)gr[_REG_CR27]); | | | |
307 | tf->tf_cr27 = gr[_REG_CR27]; | | | |
308 | | | | |
309 | #if 0 | | 306 | #if 0 |
310 | tf->tf_sr0 = gr[_REG_SR0]; | | 307 | tf->tf_sr0 = gr[_REG_SR0]; |
311 | tf->tf_sr1 = gr[_REG_SR1]; | | 308 | tf->tf_sr1 = gr[_REG_SR1]; |
312 | tf->tf_sr2 = gr[_REG_SR2]; | | 309 | tf->tf_sr2 = gr[_REG_SR2]; |
313 | tf->tf_sr3 = gr[_REG_SR3]; | | 310 | tf->tf_sr3 = gr[_REG_SR3]; |
314 | tf->tf_sr4 = gr[_REG_SR4]; | | 311 | tf->tf_sr4 = gr[_REG_SR4]; |
315 | tf->tf_cr26 = gr[_REG_CR26]; | | 312 | tf->tf_cr26 = gr[_REG_CR26]; |
316 | #endif | | 313 | #endif |
317 | } | | 314 | } |
318 | | | 315 | |
| | | 316 | /* Restore the private thread context */ |
| | | 317 | if (flags & _UC_TLSBASE) { |
| | | 318 | lwp_setprivate(l, (void *)(uintptr_t)gr[_REG_CR27]); |
| | | 319 | tf->tf_cr27 = gr[_REG_CR27]; |
| | | 320 | } |
| | | 321 | |
| | | 322 | /* Restore the floating point registers */ |
319 | if ((flags & _UC_FPU) != 0) { | | 323 | if ((flags & _UC_FPU) != 0) { |
320 | struct pcb *pcb = lwp_getpcb(l); | | 324 | struct pcb *pcb = lwp_getpcb(l); |
321 | | | 325 | |
322 | hppa_fpu_flush(l); | | 326 | hppa_fpu_flush(l); |
323 | memcpy(pcb->pcb_fpregs, &mcp->__fpregs, sizeof(mcp->__fpregs)); | | 327 | memcpy(pcb->pcb_fpregs, &mcp->__fpregs, sizeof(mcp->__fpregs)); |
324 | } | | 328 | } |
325 | | | 329 | |
326 | mutex_enter(p->p_lock); | | 330 | mutex_enter(p->p_lock); |
327 | if (flags & _UC_SETSTACK) | | 331 | if (flags & _UC_SETSTACK) |
328 | l->l_sigstk.ss_flags |= SS_ONSTACK; | | 332 | l->l_sigstk.ss_flags |= SS_ONSTACK; |
329 | if (flags & _UC_CLRSTACK) | | 333 | if (flags & _UC_CLRSTACK) |
330 | l->l_sigstk.ss_flags &= ~SS_ONSTACK; | | 334 | l->l_sigstk.ss_flags &= ~SS_ONSTACK; |
331 | mutex_exit(p->p_lock); | | 335 | mutex_exit(p->p_lock); |