1 /* $NetBSD: netbsd32_lwp.c,v 1.10.14.1 2009/01/04 01:56:02 christos Exp $ */
4 * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
29 #include <sys/cdefs.h>
30 __KERNEL_RCSID(0, "$NetBSD: netbsd32_lwp.c,v 1.10.14.1 2009/01/04 01:56:02 christos Exp $");
32 #include <sys/types.h>
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/kernel.h>
36 #include <sys/dirent.h>
37 #include <sys/mount.h>
39 #include <sys/syscallargs.h>
40 #include <sys/lwpctl.h>
42 #include <compat/netbsd32/netbsd32.h>
43 #include <compat/netbsd32/netbsd32_syscallargs.h>
44 #include <compat/netbsd32/netbsd32_conv.h>
46 /* Sycalls conversion */
49 netbsd32__lwp_create(struct lwp
*l
, const struct netbsd32__lwp_create_args
*uap
, register_t
*retval
)
52 syscallarg(const netbsd32_ucontextp) ucp;
53 syscallarg(netbsd32_u_long) flags;
54 syscallarg(netbsd32_lwpidp) new_lwp;
56 struct sys__lwp_create_args ua
;
58 NETBSD32TOP_UAP(ucp
, const ucontext_t
);
59 NETBSD32TO64_UAP(flags
);
60 NETBSD32TOP_UAP(new_lwp
, lwpid_t
);
62 return sys__lwp_create(l
, &ua
, retval
);
66 netbsd32__lwp_wait(struct lwp
*l
, const struct netbsd32__lwp_wait_args
*uap
, register_t
*retval
)
69 syscallarg(lwpid_t) wait_for;
70 syscallarg(netbsd32_lwpidp) departed;
72 struct sys__lwp_wait_args ua
;
74 NETBSD32TO64_UAP(wait_for
);
75 NETBSD32TOP_UAP(departed
, lwpid_t
);
76 return sys__lwp_wait(l
, &ua
, retval
);
80 netbsd32__lwp_suspend(struct lwp
*l
, const struct netbsd32__lwp_suspend_args
*uap
, register_t
*retval
)
83 syscallarg(lwpid_t) target;
85 struct sys__lwp_suspend_args ua
;
87 NETBSD32TO64_UAP(target
);
88 return sys__lwp_suspend(l
, &ua
, retval
);
92 netbsd32__lwp_continue(struct lwp
*l
, const struct netbsd32__lwp_continue_args
*uap
, register_t
*retval
)
95 syscallarg(lwpid_t) target;
97 struct sys__lwp_continue_args ua
;
99 NETBSD32TO64_UAP(target
);
100 return sys__lwp_continue(l
, &ua
, retval
);
104 netbsd32__lwp_wakeup(struct lwp
*l
, const struct netbsd32__lwp_wakeup_args
*uap
, register_t
*retval
)
107 syscallarg(lwpid_t) target;
109 struct sys__lwp_wakeup_args ua
;
111 NETBSD32TO64_UAP(target
);
112 return sys__lwp_wakeup(l
, &ua
, retval
);
116 netbsd32__lwp_setprivate(struct lwp
*l
, const struct netbsd32__lwp_setprivate_args
*uap
, register_t
*retval
)
119 syscallarg(netbsd32_voidp) ptr;
121 struct sys__lwp_setprivate_args ua
;
123 NETBSD32TOP_UAP(ptr
, void);
124 return sys__lwp_setprivate(l
, &ua
, retval
);
128 netbsd32____lwp_park50(struct lwp
*l
,
129 const struct netbsd32____lwp_park50_args
*uap
, register_t
*retval
)
132 syscallarg(const netbsd32_timespec50p) ts;
133 syscallarg(lwpid_t) unpark;
134 syscallarg(netbsd32_voidp) hint;
135 syscallarg(netbsd32_voidp) unparkhint;
137 struct timespec ts
, *tsp
;
138 struct netbsd32_timespec ts32
;
141 if (SCARG_P32(uap
, ts
) == NULL
)
144 error
= copyin(SCARG_P32(uap
, ts
), &ts32
, sizeof ts32
);
147 netbsd32_to_timespec(&ts32
, &ts
);
151 if (SCARG(uap
, unpark
) != 0) {
152 error
= lwp_unpark(SCARG(uap
, unpark
),
153 SCARG_P32(uap
, unparkhint
));
158 return lwp_park(tsp
, SCARG_P32(uap
, hint
));
162 netbsd32__lwp_kill(struct lwp
*l
, const struct netbsd32__lwp_kill_args
*uap
, register_t
*retval
)
165 syscallarg(lwpid_t) target;
166 syscallarg(int) signo;
168 struct sys__lwp_kill_args ua
;
170 NETBSD32TO64_UAP(target
);
171 NETBSD32TO64_UAP(signo
);
172 return sys__lwp_kill(l
, &ua
, retval
);
175 netbsd32__lwp_detach(struct lwp
*l
, const struct netbsd32__lwp_detach_args
*uap
, register_t
*retval
)
178 syscallarg(lwpid_t) target;
180 struct sys__lwp_detach_args ua
;
182 NETBSD32TO64_UAP(target
);
183 return sys__lwp_detach(l
, &ua
, retval
);
187 netbsd32__lwp_unpark(struct lwp
*l
, const struct netbsd32__lwp_unpark_args
*uap
, register_t
*retval
)
190 syscallarg(lwpid_t) target;
191 syscallarg(netbsd32_voidp) hint;
193 struct sys__lwp_unpark_args ua
;
195 NETBSD32TO64_UAP(target
);
196 NETBSD32TOP_UAP(hint
, void);
197 return sys__lwp_unpark(l
, &ua
, retval
);
201 netbsd32__lwp_unpark_all(struct lwp
*l
, const struct netbsd32__lwp_unpark_all_args
*uap
, register_t
*retval
)
204 syscallarg(const netbsd32_lwpidp) targets;
205 syscallarg(netbsd32_size_t) ntargets;
206 syscallarg(netbsd32_voidp) hint;
208 struct sys__lwp_unpark_all_args ua
;
210 NETBSD32TOP_UAP(targets
, const lwpid_t
);
211 NETBSD32TOX_UAP(ntargets
, size_t);
212 NETBSD32TOP_UAP(hint
, void);
213 return sys__lwp_unpark_all(l
, &ua
, retval
);
217 netbsd32__lwp_setname(struct lwp
*l
, const struct netbsd32__lwp_setname_args
*uap
, register_t
*retval
)
220 syscallarg(lwpid_t) target;
221 syscallarg(const netbsd32_charp) name;
223 struct sys__lwp_setname_args ua
;
225 NETBSD32TO64_UAP(target
);
226 NETBSD32TOP_UAP(name
, char *);
227 return sys__lwp_setname(l
, &ua
, retval
);
231 netbsd32__lwp_getname(struct lwp
*l
, const struct netbsd32__lwp_getname_args
*uap
, register_t
*retval
)
234 syscallarg(lwpid_t) target;
235 syscallarg(netbsd32_charp) name;
236 syscallarg(netbsd32_size_t) len;
238 struct sys__lwp_getname_args ua
;
240 NETBSD32TO64_UAP(target
);
241 NETBSD32TOP_UAP(name
, char *);
242 NETBSD32TOX_UAP(len
, size_t);
243 return sys__lwp_getname(l
, &ua
, retval
);
247 netbsd32__lwp_ctl(struct lwp
*l
, const struct netbsd32__lwp_ctl_args
*uap
, register_t
*retval
)
250 syscallarg(int) features;
251 syscallarg(netbsd32_pointer_t) address;
253 struct sys__lwp_ctl_args ua
;
255 NETBSD32TO64_UAP(features
);
256 NETBSD32TOP_UAP(address
, struct lwpctl
*);
257 return sys__lwp_ctl(l
, &ua
, retval
);