| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: machdep.c,v 1.33 2011/11/27 21:38:17 reinoud Exp $ */ | | 1 | /* $NetBSD: machdep.c,v 1.34 2011/12/12 19:57:12 reinoud Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2011 Reinoud Zandijk <reinoud@netbsd.org> | | 4 | * Copyright (c) 2011 Reinoud Zandijk <reinoud@netbsd.org> |
5 | * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca> | | 5 | * Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca> |
6 | * All rights reserved. | | 6 | * All rights reserved. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -22,27 +22,27 @@ | | | @@ -22,27 +22,27 @@ |
22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 24 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 25 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 26 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
27 | * POSSIBILITY OF SUCH DAMAGE. | | 27 | * POSSIBILITY OF SUCH DAMAGE. |
28 | */ | | 28 | */ |
29 | | | 29 | |
30 | #include "opt_memsize.h" | | 30 | #include "opt_memsize.h" |
31 | #include "opt_sdl.h" | | 31 | #include "opt_sdl.h" |
32 | #include "opt_urkelvisor.h" | | 32 | #include "opt_urkelvisor.h" |
33 | | | 33 | |
34 | #include <sys/cdefs.h> | | 34 | #include <sys/cdefs.h> |
35 | __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.33 2011/11/27 21:38:17 reinoud Exp $"); | | 35 | __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.34 2011/12/12 19:57:12 reinoud Exp $"); |
36 | | | 36 | |
37 | #include <sys/types.h> | | 37 | #include <sys/types.h> |
38 | #include <sys/param.h> | | 38 | #include <sys/param.h> |
39 | #include <sys/time.h> | | 39 | #include <sys/time.h> |
40 | #include <sys/exec.h> | | 40 | #include <sys/exec.h> |
41 | #include <sys/buf.h> | | 41 | #include <sys/buf.h> |
42 | #include <sys/boot_flag.h> | | 42 | #include <sys/boot_flag.h> |
43 | #include <sys/ucontext.h> | | 43 | #include <sys/ucontext.h> |
44 | #include <machine/pcb.h> | | 44 | #include <machine/pcb.h> |
45 | #include <machine/psl.h> | | 45 | #include <machine/psl.h> |
46 | | | 46 | |
47 | #include <uvm/uvm_extern.h> | | 47 | #include <uvm/uvm_extern.h> |
48 | #include <uvm/uvm_page.h> | | 48 | #include <uvm/uvm_page.h> |
| @@ -240,34 +240,34 @@ md_syscall_getargs(lwp_t *l, ucontext_t | | | @@ -240,34 +240,34 @@ md_syscall_getargs(lwp_t *l, ucontext_t |
240 | //dump_regs(reg); | | 240 | //dump_regs(reg); |
241 | ret = copyin(sp + 1, args, argsize); | | 241 | ret = copyin(sp + 1, args, argsize); |
242 | | | 242 | |
243 | return ret; | | 243 | return ret; |
244 | } | | 244 | } |
245 | | | 245 | |
246 | void | | 246 | void |
247 | md_syscall_set_returnargs(lwp_t *l, ucontext_t *ucp, | | 247 | md_syscall_set_returnargs(lwp_t *l, ucontext_t *ucp, |
248 | int error, register_t *rval) | | 248 | int error, register_t *rval) |
249 | { | | 249 | { |
250 | register_t *reg = (register_t *) &ucp->uc_mcontext; | | 250 | register_t *reg = (register_t *) &ucp->uc_mcontext; |
251 | | | 251 | |
252 | reg[16] &= ~PSL_C; /* EFL */ | | 252 | reg[16] &= ~PSL_C; /* EFL */ |
253 | if (error) { | | 253 | if (error > 0) { |
254 | rval[0] = error; | | 254 | rval[0] = error; |
255 | reg[16] |= PSL_C; /* EFL */ | | 255 | reg[16] |= PSL_C; /* EFL */ |
256 | } | | 256 | } |
257 | | | 257 | |
258 | /* set return parameters */ | | 258 | /* set return parameters */ |
259 | reg[11] = rval[0]; /* EAX */ | | 259 | reg[11] = rval[0]; /* EAX */ |
260 | if (!error) | | 260 | if (error == 0) |
261 | reg[ 9] = rval[1]; /* EDX */ | | 261 | reg[ 9] = rval[1]; /* EDX */ |
262 | | | 262 | |
263 | //dump_regs(reg); | | 263 | //dump_regs(reg); |
264 | } | | 264 | } |
265 | | | 265 | |
266 | int | | 266 | int |
267 | md_syscall_check_opcode(void *ptr) | | 267 | md_syscall_check_opcode(void *ptr) |
268 | { | | 268 | { |
269 | uint16_t *p16; | | 269 | uint16_t *p16; |
270 | | | 270 | |
271 | /* undefined instruction */ | | 271 | /* undefined instruction */ |
272 | p16 = (uint16_t *) ptr; | | 272 | p16 = (uint16_t *) ptr; |
273 | if (*p16 == 0xff0f) | | 273 | if (*p16 == 0xff0f) |