1 /*- 2 * Copyright (c) 2012 The NetBSD Foundation, Inc. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to The NetBSD Foundation 6 * by Matt Thomas of 3am Software Foundry. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 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 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 27 * POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 #include <sys/cdefs.h> 31 32 __KERNEL_RCSID(1, "$NetBSD: netbsd32_machdep.c,v 1.6 2014/05/05 17:45:24 skrll Exp $"); 33 34 #include "opt_compat_netbsd.h" 35 36 #include <sys/param.h> 37 #include <sys/core.h> 38 #include <sys/exec.h> 39 #include <sys/lwp.h> 40 #include <sys/signalvar.h> 41 #include <sys/syscallargs.h> 42 43 #include <uvm/uvm_extern.h> 44 45 #include <compat/netbsd32/netbsd32.h> 46 #include <compat/netbsd32/netbsd32_exec.h> 47 #include <compat/netbsd32/netbsd32_syscallargs.h> 48 49 const char machine32[] = MACHINE; 50 const char machine_arch32[] = MACHINE_ARCH; 51 52 int 53 cpu_coredump32(struct lwp *l, struct coredump_iostate *iocookie, 54 struct core32 *chdr) 55 { 56 return cpu_coredump(l, iocookie, (struct core *)chdr); 57 } 58 59 void 60 netbsd32_sendsig (const ksiginfo_t *ksi, const sigset_t *ss) 61 { 62 sendsig(ksi, ss); 63 } 64 65 void 66 startlwp32(void *arg) 67 { 68 startlwp(arg); 69 } 70 71 int 72 cpu_mcontext32_validate(struct lwp *l, const mcontext32_t *mcp) 73 { 74 return cpu_mcontext_validate(l, mcp); 75 } 76 void 77 cpu_getmcontext32(struct lwp *l, mcontext32_t *mcp, unsigned int *flagsp) 78 { 79 cpu_getmcontext(l, mcp, flagsp); 80 } 81 82 int 83 cpu_setmcontext32(struct lwp *l, const mcontext32_t *mcp, unsigned int flags) 84 { 85 return cpu_setmcontext(l, mcp, flags); 86 } 87 88 int 89 netbsd32_sysarch(struct lwp *l, const struct netbsd32_sysarch_args *uap, 90 register_t *retval) 91 { 92 return sys_sysarch(l, (const struct sys_sysarch_args *)uap, retval); 93 } 94 95 vaddr_t 96 netbsd32_vm_default_addr(struct proc *p, vaddr_t base, vsize_t sz) 97 { 98 if (p->p_vmspace->vm_map.flags & VM_MAP_TOPDOWN) 99 return VM_DEFAULT_ADDRESS_TOPDOWN(base, sz); 100 else 101 return VM_DEFAULT_ADDRESS_BOTTOMUP(base, sz); 102 } 103 104 105 #ifdef COMPAT_13 106 int 107 compat_13_netbsd32_sigreturn(struct lwp *l, 108 const struct compat_13_netbsd32_sigreturn_args *uap, 109 register_t *retval) 110 { 111 struct compat_13_sys_sigreturn_args ua; 112 113 NETBSD32TOP_UAP(sigcntxp, struct sigcontext13 *); 114 115 return compat_13_sys_sigreturn(l, &ua, retval); 116 } 117 #endif 118 119 #ifdef COMPAT_16 120 int 121 compat_16_netbsd32___sigreturn14(struct lwp *l, 122 const struct compat_16_netbsd32___sigreturn14_args *uap, 123 register_t *retval) 124 { 125 struct compat_16_sys___sigreturn14_args ua; 126 127 NETBSD32TOP_UAP(sigcntxp, struct sigcontext *); 128 129 return compat_16_sys___sigreturn14(l, &ua, retval); 130 } 131 #endif 132