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