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.11 2020/06/20 07:10:36 skrll Exp $");
33
34 #ifdef _KERNEL_OPT
35 #include "opt_compat_netbsd.h"
36 #include "opt_compat_netbsd32.h"
37 #endif
38
39 #include <sys/param.h>
40
41 #include <sys/core.h>
42 #include <sys/exec.h>
43 #include <sys/lwp.h>
44 #include <sys/signalvar.h>
45 #include <sys/syscallargs.h>
46
47 #include <uvm/uvm_extern.h>
48
49 #include <compat/netbsd32/netbsd32.h>
50 #include <compat/netbsd32/netbsd32_exec.h>
51 #include <compat/netbsd32/netbsd32_syscallargs.h>
52
53 const char machine32[] = MACHINE;
54 const char machine_arch32[] = MACHINE_ARCH;
55
56 int
cpu_coredump32(struct lwp * l,struct coredump_iostate * iocookie,struct core32 * chdr)57 cpu_coredump32(struct lwp *l, struct coredump_iostate *iocookie,
58 struct core32 *chdr)
59 {
60 return cpu_coredump(l, iocookie, (struct core *)chdr);
61 }
62
63 void
netbsd32_sendsig(const ksiginfo_t * ksi,const sigset_t * ss)64 netbsd32_sendsig (const ksiginfo_t *ksi, const sigset_t *ss)
65 {
66 sendsig(ksi, ss);
67 }
68
69 void
startlwp32(void * arg)70 startlwp32(void *arg)
71 {
72 startlwp(arg);
73 }
74
75 int
cpu_mcontext32_validate(struct lwp * l,const mcontext32_t * mcp)76 cpu_mcontext32_validate(struct lwp *l, const mcontext32_t *mcp)
77 {
78 return cpu_mcontext_validate(l, mcp);
79 }
80 void
cpu_getmcontext32(struct lwp * l,mcontext32_t * mcp,unsigned int * flagsp)81 cpu_getmcontext32(struct lwp *l, mcontext32_t *mcp, unsigned int *flagsp)
82 {
83 cpu_getmcontext(l, mcp, flagsp);
84 }
85
86 int
cpu_setmcontext32(struct lwp * l,const mcontext32_t * mcp,unsigned int flags)87 cpu_setmcontext32(struct lwp *l, const mcontext32_t *mcp, unsigned int flags)
88 {
89 return cpu_setmcontext(l, mcp, flags);
90 }
91
92 int
netbsd32_sysarch(struct lwp * l,const struct netbsd32_sysarch_args * uap,register_t * retval)93 netbsd32_sysarch(struct lwp *l, const struct netbsd32_sysarch_args *uap,
94 register_t *retval)
95 {
96 return sys_sysarch(l, (const struct sys_sysarch_args *)uap, retval);
97 }
98
99 vaddr_t
netbsd32_vm_default_addr(struct proc * p,vaddr_t base,vsize_t sz,int topdown)100 netbsd32_vm_default_addr(struct proc *p, vaddr_t base, vsize_t sz,
101 int topdown)
102 {
103 if (topdown)
104 return VM_DEFAULT_ADDRESS_TOPDOWN(base, sz);
105 else
106 return VM_DEFAULT_ADDRESS_BOTTOMUP(base, sz);
107 }
108
109 void
netbsd32_machdep_md_init(void)110 netbsd32_machdep_md_init(void)
111 {
112
113 /* nothing to do */
114 }
115
116 void
netbsd32_machdep_md_fini(void)117 netbsd32_machdep_md_fini(void)
118 {
119
120 /* nothing to do */
121 }
122
123