netbsd32_lwp.c revision 1.2.2.4 1 /* $NetBSD: netbsd32_lwp.c,v 1.2.2.4 2007/10/09 13:44:06 ad Exp $ */
2
3 /*
4 * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of The NetBSD Foundation nor the names of its
16 * contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: netbsd32_lwp.c,v 1.2.2.4 2007/10/09 13:44:06 ad Exp $");
34
35 #include <sys/types.h>
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/kernel.h>
39 #include <sys/dirent.h>
40 #include <sys/mount.h>
41 #include <sys/proc.h>
42 #include <sys/syscallargs.h>
43
44 #include <compat/netbsd32/netbsd32.h>
45 #include <compat/netbsd32/netbsd32_syscallargs.h>
46 #include <compat/netbsd32/netbsd32_conv.h>
47
48 /* Sycalls conversion */
49
50 int
51 netbsd32__lwp_create(struct lwp *l, void *v, register_t *retval)
52 {
53 struct netbsd32__lwp_create_args /* {
54 syscallarg(const netbsd32_ucontextp) ucp;
55 syscallarg(netbsd32_u_long) flags;
56 syscallarg(netbsd32_lwpidp) new_lwp;
57 } */ *uap = v;
58 struct sys__lwp_create_args ua;
59
60 NETBSD32TOP_UAP(ucp, const ucontext_t);
61 NETBSD32TO64_UAP(flags);
62 NETBSD32TOP_UAP(new_lwp, lwpid_t);
63
64 return sys__lwp_create(l, &ua, retval);
65 }
66
67 int
68 netbsd32__lwp_wait(struct lwp *l, void *v, register_t *retval)
69 {
70 struct netbsd32__lwp_wait_args /* {
71 syscallarg(lwpid_t) wait_for;
72 syscallarg(netbsd32_lwpidp) departed;
73 } */ *uap = v;
74 struct sys__lwp_wait_args ua;
75
76 NETBSD32TO64_UAP(wait_for);
77 NETBSD32TOP_UAP(departed, lwpid_t);
78 return sys__lwp_wait(l, &ua, retval);
79 }
80
81 int
82 netbsd32__lwp_suspend(struct lwp *l, void *v, register_t *retval)
83 {
84 struct netbsd32__lwp_suspend_args /* {
85 syscallarg(lwpid_t) target;
86 } */ *uap = v;
87 struct sys__lwp_suspend_args ua;
88
89 NETBSD32TO64_UAP(target);
90 return sys__lwp_suspend(l, &ua, retval);
91 }
92
93 int
94 netbsd32__lwp_continue(struct lwp *l, void *v, register_t *retval)
95 {
96 struct netbsd32__lwp_continue_args /* {
97 syscallarg(lwpid_t) target;
98 } */ *uap = v;
99 struct sys__lwp_continue_args ua;
100
101 NETBSD32TO64_UAP(target);
102 return sys__lwp_continue(l, &ua, retval);
103 }
104
105 int
106 netbsd32__lwp_wakeup(struct lwp *l, void *v, register_t *retval)
107 {
108 struct netbsd32__lwp_wakeup_args /* {
109 syscallarg(lwpid_t) target;
110 } */ *uap = v;
111 struct sys__lwp_wakeup_args ua;
112
113 NETBSD32TO64_UAP(target);
114 return sys__lwp_wakeup(l, &ua, retval);
115 }
116
117 int
118 netbsd32__lwp_setprivate(struct lwp *l, void *v, register_t *retval)
119 {
120 struct netbsd32__lwp_setprivate_args /* {
121 syscallarg(netbsd32_voidp) ptr;
122 } */ *uap = v;
123 struct sys__lwp_setprivate_args ua;
124
125 NETBSD32TOP_UAP(ptr, void);
126 return sys__lwp_setprivate(l, &ua, retval);
127 }
128
129 int
130 netbsd32__lwp_park(struct lwp *l, void *v, register_t *retval)
131 {
132 struct netbsd32__lwp_park_args /* {
133 syscallarg(const netbsd32_timespecp) ts;
134 syscallarg(lwpid_t) unpark;
135 syscallarg(netbsd32_voidp) hint;
136 syscallarg(netbsd32_voidp) unparkhint;
137 } */ *uap = v;
138 struct timespec ts, *tsp;
139 struct netbsd32_timespec ts32;
140 int error;
141
142 if (SCARG_P32(uap, ts) == NULL)
143 tsp = NULL;
144 else {
145 error = copyin(SCARG_P32(uap, ts), &ts32, sizeof ts32);
146 if (error != 0)
147 return error;
148 netbsd32_to_timespec(&ts32, &ts);
149 tsp = &ts;
150 }
151
152 if (SCARG(uap, unpark) != 0) {
153 error = lwp_unpark(SCARG(uap, unpark),
154 SCARG_P32(uap, unparkhint));
155 if (error != 0)
156 return error;
157 }
158
159 return lwp_park(tsp, SCARG_P32(uap, hint));
160 }
161
162 int
163 netbsd32__lwp_kill(struct lwp *l, void *v, register_t *retval)
164 {
165 struct netbsd32__lwp_kill_args /* {
166 syscallarg(lwpid_t) target;
167 syscallarg(int) signo;
168 } */ *uap = v;
169 struct sys__lwp_kill_args ua;
170
171 NETBSD32TO64_UAP(target);
172 NETBSD32TO64_UAP(signo);
173 return sys__lwp_kill(l, &ua, retval);
174 }
175 int
176 netbsd32__lwp_detach(struct lwp *l, void *v, register_t *retval)
177 {
178 struct netbsd32__lwp_detach_args /* {
179 syscallarg(lwpid_t) target;
180 } */ *uap = v;
181 struct sys__lwp_detach_args ua;
182
183 NETBSD32TO64_UAP(target);
184 return sys__lwp_detach(l, &ua, retval);
185 }
186
187 int
188 netbsd32__lwp_unpark(struct lwp *l, void *v, register_t *retval)
189 {
190 struct netbsd32__lwp_unpark_args /* {
191 syscallarg(lwpid_t) target;
192 syscallarg(netbsd32_voidp) hint;
193 } */ *uap = v;
194 struct sys__lwp_unpark_args ua;
195
196 NETBSD32TO64_UAP(target);
197 NETBSD32TOP_UAP(hint, void);
198 return sys__lwp_unpark(l, &ua, retval);
199 }
200
201 int
202 netbsd32__lwp_unpark_all(struct lwp *l, void *v, register_t *retval)
203 {
204 struct netbsd32__lwp_unpark_all_args /* {
205 syscallarg(const netbsd32_lwpidp) targets;
206 syscallarg(netbsd32_size_t) ntargets;
207 syscallarg(netbsd32_voidp) hint;
208 } */ *uap = v;
209 struct sys__lwp_unpark_all_args ua;
210
211 NETBSD32TOP_UAP(targets, const lwpid_t);
212 NETBSD32TOX_UAP(ntargets, size_t);
213 NETBSD32TOP_UAP(hint, void);
214 return sys__lwp_unpark_all(l, &ua, retval);
215 }
216