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