| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: syscall.c,v 1.37.12.4 2009/08/22 16:55:19 matt Exp $ */ | | 1 | /* $NetBSD: syscall.c,v 1.37.12.5 2009/08/23 03:52:52 matt Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2001 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 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 and by Charles M. Hannum. | | 8 | * by Jason R. Thorpe and by Charles M. Hannum. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -97,27 +97,27 @@ | | | @@ -97,27 +97,27 @@ |
97 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 97 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
98 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 98 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
99 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 99 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
100 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 100 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
101 | * SUCH DAMAGE. | | 101 | * SUCH DAMAGE. |
102 | * | | 102 | * |
103 | * from: Utah Hdr: trap.c 1.32 91/04/06 | | 103 | * from: Utah Hdr: trap.c 1.32 91/04/06 |
104 | * | | 104 | * |
105 | * @(#)trap.c 8.5 (Berkeley) 1/11/94 | | 105 | * @(#)trap.c 8.5 (Berkeley) 1/11/94 |
106 | */ | | 106 | */ |
107 | | | 107 | |
108 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ | | 108 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ |
109 | | | 109 | |
110 | __KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.37.12.4 2009/08/22 16:55:19 matt Exp $"); | | 110 | __KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.37.12.5 2009/08/23 03:52:52 matt Exp $"); |
111 | | | 111 | |
112 | #if defined(_KERNEL_OPT) | | 112 | #if defined(_KERNEL_OPT) |
113 | #include "opt_sa.h" | | 113 | #include "opt_sa.h" |
114 | #endif | | 114 | #endif |
115 | | | 115 | |
116 | #include <sys/param.h> | | 116 | #include <sys/param.h> |
117 | #include <sys/systm.h> | | 117 | #include <sys/systm.h> |
118 | #include <sys/endian.h> | | 118 | #include <sys/endian.h> |
119 | #include <sys/proc.h> | | 119 | #include <sys/proc.h> |
120 | #include <sys/user.h> | | 120 | #include <sys/user.h> |
121 | #include <sys/signal.h> | | 121 | #include <sys/signal.h> |
122 | #include <sys/syscall.h> | | 122 | #include <sys/syscall.h> |
123 | #include <sys/syscallvar.h> | | 123 | #include <sys/syscallvar.h> |
| @@ -373,36 +373,39 @@ EMULNAME(syscall)(struct lwp *l, u_int s | | | @@ -373,36 +373,39 @@ EMULNAME(syscall)(struct lwp *l, u_int s |
373 | goto out; | | 373 | goto out; |
374 | | | 374 | |
375 | error = (*callp->sy_call)(l, args, &frame->f_regs[_R_V0]); | | 375 | error = (*callp->sy_call)(l, args, &frame->f_regs[_R_V0]); |
376 | | | 376 | |
377 | out: | | 377 | out: |
378 | switch (error) { | | 378 | switch (error) { |
379 | case 0: | | 379 | case 0: |
380 | #if !defined(__mips_o32) | | 380 | #if !defined(__mips_o32) |
381 | if (abi == _MIPS_BSD_API_O32 && SYCALL_RET_64_P(callp)) { | | 381 | if (abi == _MIPS_BSD_API_O32 && SYCALL_RET_64_P(callp)) { |
382 | /* | | 382 | /* |
383 | * If this is from O32 and it's a 64bit quantity, | | 383 | * If this is from O32 and it's a 64bit quantity, |
384 | * split it into 2 32bit values in adjacent registers. | | 384 | * split it into 2 32bit values in adjacent registers. |
385 | */ | | 385 | */ |
386 | #if BYTE_ORDER == BIG_ENDIAN | | 386 | mips_reg_t tmp = frame->f_regs[_R_V0]; |
387 | frame->f_regs[_R_V1] = (int32_t) frame->f_regs[_R_V0]; | | 387 | frame->f_regs[_R_V0 + _QUAD_LOWWORD] = (int32_t) tmp; |
388 | frame->f_regs[_R_V0] >>= 32; | | 388 | frame->f_regs[_R_V0 + _QUAD_HIGHWORD] = tmp >> 32; |
389 | #endif | | | |
390 | #if BYTE_ORDER == LITTLE_ENDIAN | | | |
391 | frame->f_regs[_R_V1] = frame->f_regs[_R_V0] >> 32; | | | |
392 | frame->f_regs[_R_V0] = (int32_t) frame->f_regs[_R_V0]; | | | |
393 | #endif | | | |
394 | } | | 389 | } |
395 | #endif | | 390 | #endif |
| | | 391 | #if 0 |
| | | 392 | if (p->p_emul->e_syscallnames) |
| | | 393 | printf("syscall %s:", p->p_emul->e_syscallnames[code]); |
| | | 394 | else |
| | | 395 | printf("syscall %u:", code); |
| | | 396 | printf(" return v0=%#"PRIxREGISTER" v1=%#"PRIxREGISTER"\n", |
| | | 397 | frame->f_regs[_R_V0], frame->f_regs[_R_V1]); |
| | | 398 | #endif |
396 | frame->f_regs[_R_A3] = 0; | | 399 | frame->f_regs[_R_A3] = 0; |
397 | break; | | 400 | break; |
398 | case ERESTART: | | 401 | case ERESTART: |
399 | frame->f_regs[_R_V0] = saved_v0; /* restore syscall code */ | | 402 | frame->f_regs[_R_V0] = saved_v0; /* restore syscall code */ |
400 | frame->f_regs[_R_PC] = opc; | | 403 | frame->f_regs[_R_PC] = opc; |
401 | break; | | 404 | break; |
402 | case EJUSTRETURN: | | 405 | case EJUSTRETURN: |
403 | break; /* nothing to do */ | | 406 | break; /* nothing to do */ |
404 | default: | | 407 | default: |
405 | bad: | | 408 | bad: |
406 | if (p->p_emul->e_errno) | | 409 | if (p->p_emul->e_errno) |
407 | error = p->p_emul->e_errno[error]; | | 410 | error = p->p_emul->e_errno[error]; |
408 | frame->f_regs[_R_V0] = error; | | 411 | frame->f_regs[_R_V0] = error; |