| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: compat_16_machdep.c,v 1.15 2009/12/14 00:46:05 matt Exp $ */ | | 1 | /* $NetBSD: compat_16_machdep.c,v 1.16 2009/12/14 12:53:18 uebayasi Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, |
9 | * NASA Ames Research Center and by Chris Demetriou. | | 9 | * NASA Ames Research Center and by Chris Demetriou. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -35,27 +35,27 @@ | | | @@ -35,27 +35,27 @@ |
35 | * Junior University. All Rights Reserved. | | 35 | * Junior University. All Rights Reserved. |
36 | * | | 36 | * |
37 | * Permission to use, copy, modify, and distribute this | | 37 | * Permission to use, copy, modify, and distribute this |
38 | * software and its documentation for any purpose and without | | 38 | * software and its documentation for any purpose and without |
39 | * fee is hereby granted, provided that the above copyright | | 39 | * fee is hereby granted, provided that the above copyright |
40 | * notice appear in all copies. Stanford University | | 40 | * notice appear in all copies. Stanford University |
41 | * makes no representations about the suitability of this | | 41 | * makes no representations about the suitability of this |
42 | * software for any purpose. It is provided "as is" without | | 42 | * software for any purpose. It is provided "as is" without |
43 | * express or implied warranty. | | 43 | * express or implied warranty. |
44 | */ | | 44 | */ |
45 | | | 45 | |
46 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ | | 46 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ |
47 | | | 47 | |
48 | __KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.15 2009/12/14 00:46:05 matt Exp $"); | | 48 | __KERNEL_RCSID(0, "$NetBSD: compat_16_machdep.c,v 1.16 2009/12/14 12:53:18 uebayasi Exp $"); |
49 | | | 49 | |
50 | #ifdef _KERNEL_OPT | | 50 | #ifdef _KERNEL_OPT |
51 | #include "opt_cputype.h" | | 51 | #include "opt_cputype.h" |
52 | #include "opt_compat_netbsd.h" | | 52 | #include "opt_compat_netbsd.h" |
53 | #include "opt_compat_ultrix.h" | | 53 | #include "opt_compat_ultrix.h" |
54 | #endif | | 54 | #endif |
55 | | | 55 | |
56 | #include <sys/param.h> | | 56 | #include <sys/param.h> |
57 | #include <sys/systm.h> | | 57 | #include <sys/systm.h> |
58 | #include <sys/kernel.h> | | 58 | #include <sys/kernel.h> |
59 | #include <sys/proc.h> | | 59 | #include <sys/proc.h> |
60 | #include <sys/signal.h> | | 60 | #include <sys/signal.h> |
61 | #include <sys/signalvar.h> | | 61 | #include <sys/signalvar.h> |
| @@ -115,27 +115,28 @@ sendsig_sigcontext(const ksiginfo_t *ksi | | | @@ -115,27 +115,28 @@ sendsig_sigcontext(const ksiginfo_t *ksi |
115 | #endif | | 115 | #endif |
116 | | | 116 | |
117 | /* Build stack frame for signal trampoline. */ | | 117 | /* Build stack frame for signal trampoline. */ |
118 | ksc.sc_pc = f->f_regs[_R_PC]; | | 118 | ksc.sc_pc = f->f_regs[_R_PC]; |
119 | ksc.mullo = f->f_regs[_R_MULLO]; | | 119 | ksc.mullo = f->f_regs[_R_MULLO]; |
120 | ksc.mulhi = f->f_regs[_R_MULHI]; | | 120 | ksc.mulhi = f->f_regs[_R_MULHI]; |
121 | | | 121 | |
122 | /* Save register context. */ | | 122 | /* Save register context. */ |
123 | ksc.sc_regs[_R_ZERO] = 0xACEDBADE; /* magic number */ | | 123 | ksc.sc_regs[_R_ZERO] = 0xACEDBADE; /* magic number */ |
124 | #if defined(__mips_o32) | | 124 | #if defined(__mips_o32) |
125 | memcpy(&ksc.sc_regs[1], &f->f_regs[1], | | 125 | memcpy(&ksc.sc_regs[1], &f->f_regs[1], |
126 | sizeof(ksc.sc_regs) - sizeof(ksc.sc_regs[0])); | | 126 | sizeof(ksc.sc_regs) - sizeof(ksc.sc_regs[0])); |
127 | #else | | 127 | #else |
128 | for (size_t i = 1; i < 32; i++) | | 128 | size_t i; |
| | | 129 | for (i = 1; i < 32; i++) |
129 | ksc.sc_regs[i] = f->f_regs[i]; | | 130 | ksc.sc_regs[i] = f->f_regs[i]; |
130 | #endif | | 131 | #endif |
131 | | | 132 | |
132 | /* Save the FP state, if necessary, then copy it. */ | | 133 | /* Save the FP state, if necessary, then copy it. */ |
133 | pcb = lwp_getpcb(l); | | 134 | pcb = lwp_getpcb(l); |
134 | #ifndef SOFTFLOAT | | 135 | #ifndef SOFTFLOAT |
135 | ksc.sc_fpused = l->l_md.md_flags & MDP_FPUSED; | | 136 | ksc.sc_fpused = l->l_md.md_flags & MDP_FPUSED; |
136 | if (ksc.sc_fpused) { | | 137 | if (ksc.sc_fpused) { |
137 | /* if FPU has current state, save it first */ | | 138 | /* if FPU has current state, save it first */ |
138 | savefpregs(l); | | 139 | savefpregs(l); |
139 | } | | 140 | } |
140 | #endif | | 141 | #endif |
141 | *(struct fpreg *)ksc.sc_fpregs = *(struct fpreg *)&pcb->pcb_fpregs; | | 142 | *(struct fpreg *)ksc.sc_fpregs = *(struct fpreg *)&pcb->pcb_fpregs; |
| @@ -262,27 +263,28 @@ compat_16_sys___sigreturn14(struct lwp * | | | @@ -262,27 +263,28 @@ compat_16_sys___sigreturn14(struct lwp * |
262 | if ((u_int) ksc.sc_regs[_R_ZERO] != 0xacedbadeU)/* magic number */ | | 263 | if ((u_int) ksc.sc_regs[_R_ZERO] != 0xacedbadeU)/* magic number */ |
263 | return (EINVAL); | | 264 | return (EINVAL); |
264 | | | 265 | |
265 | /* Restore the register context. */ | | 266 | /* Restore the register context. */ |
266 | f = l->l_md.md_regs; | | 267 | f = l->l_md.md_regs; |
267 | f->f_regs[_R_PC] = ksc.sc_pc; | | 268 | f->f_regs[_R_PC] = ksc.sc_pc; |
268 | f->f_regs[_R_MULLO] = ksc.mullo; | | 269 | f->f_regs[_R_MULLO] = ksc.mullo; |
269 | f->f_regs[_R_MULHI] = ksc.mulhi; | | 270 | f->f_regs[_R_MULHI] = ksc.mulhi; |
270 | #if defined(__mips_o32) | | 271 | #if defined(__mips_o32) |
271 | memcpy(&f->f_regs[1], &scp->sc_regs[1], | | 272 | memcpy(&f->f_regs[1], &scp->sc_regs[1], |
272 | sizeof(scp->sc_regs) - sizeof(scp->sc_regs[0])); | | 273 | sizeof(scp->sc_regs) - sizeof(scp->sc_regs[0])); |
273 | | | 274 | |
274 | #else | | 275 | #else |
275 | for (size_t i = 1; i < __arraycount(f->f_regs); i++) | | 276 | size_t i; |
| | | 277 | for (i = 1; i < __arraycount(f->f_regs); i++) |
276 | f->f_regs[i] = ksc.sc_regs[i]; | | 278 | f->f_regs[i] = ksc.sc_regs[i]; |
277 | #endif | | 279 | #endif |
278 | #ifndef SOFTFLOAT | | 280 | #ifndef SOFTFLOAT |
279 | if (scp->sc_fpused) { | | 281 | if (scp->sc_fpused) { |
280 | /* Disable the FPU to fault in FP registers. */ | | 282 | /* Disable the FPU to fault in FP registers. */ |
281 | f->f_regs[_R_SR] &= ~MIPS_SR_COP_1_BIT; | | 283 | f->f_regs[_R_SR] &= ~MIPS_SR_COP_1_BIT; |
282 | fpcurlwp = &lwp0; | | 284 | fpcurlwp = &lwp0; |
283 | } | | 285 | } |
284 | #endif | | 286 | #endif |
285 | pcb = lwp_getpcb(l); | | 287 | pcb = lwp_getpcb(l); |
286 | *(struct fpreg *)&pcb->pcb_fpregs = *(struct fpreg *)scp->sc_fpregs; | | 288 | *(struct fpreg *)&pcb->pcb_fpregs = *(struct fpreg *)scp->sc_fpregs; |
287 | | | 289 | |
288 | mutex_enter(p->p_lock); | | 290 | mutex_enter(p->p_lock); |