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