1*d1c42b4fSad /* $NetBSD: netbsd32_compat_60.c,v 1.6 2020/01/29 15:47:52 ad Exp $ */
252c1f729Schristos
352c1f729Schristos /*-
4*d1c42b4fSad * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc.
552c1f729Schristos * All rights reserved.
652c1f729Schristos *
752c1f729Schristos * This code is derived from software contributed to The NetBSD Foundation
852c1f729Schristos * by Christos Zoulas.
952c1f729Schristos *
1052c1f729Schristos * Redistribution and use in source and binary forms, with or without
1152c1f729Schristos * modification, are permitted provided that the following conditions
1252c1f729Schristos * are met:
1352c1f729Schristos * 1. Redistributions of source code must retain the above copyright
1452c1f729Schristos * notice, this list of conditions and the following disclaimer.
1552c1f729Schristos * 2. Redistributions in binary form must reproduce the above copyright
1652c1f729Schristos * notice, this list of conditions and the following disclaimer in the
1752c1f729Schristos * documentation and/or other materials provided with the distribution.
1852c1f729Schristos *
1952c1f729Schristos * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2052c1f729Schristos * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2152c1f729Schristos * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2252c1f729Schristos * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2352c1f729Schristos * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2452c1f729Schristos * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2552c1f729Schristos * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2652c1f729Schristos * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2752c1f729Schristos * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2852c1f729Schristos * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2952c1f729Schristos * POSSIBILITY OF SUCH DAMAGE.
3052c1f729Schristos */
3152c1f729Schristos #include <sys/cdefs.h>
32*d1c42b4fSad __KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_60.c,v 1.6 2020/01/29 15:47:52 ad Exp $");
3352c1f729Schristos
3452c1f729Schristos #include <sys/param.h>
3552c1f729Schristos #include <sys/systm.h>
36d91f98a8Spgoyette #include <sys/module.h>
3752c1f729Schristos #include <sys/time.h>
3852c1f729Schristos #include <sys/dirent.h>
3952c1f729Schristos #include <sys/lwp.h>
4052c1f729Schristos #include <sys/syscallargs.h>
41d91f98a8Spgoyette #include <sys/syscallvar.h>
4252c1f729Schristos
4352c1f729Schristos #include <compat/netbsd32/netbsd32.h>
44d91f98a8Spgoyette #include <compat/netbsd32/netbsd32_syscall.h>
4552c1f729Schristos #include <compat/netbsd32/netbsd32_syscallargs.h>
4652c1f729Schristos #include <compat/netbsd32/netbsd32_conv.h>
4752c1f729Schristos
4852c1f729Schristos int
compat_60_netbsd32__lwp_park(struct lwp * l,const struct compat_60_netbsd32__lwp_park_args * uap,register_t * retval)4952c1f729Schristos compat_60_netbsd32__lwp_park(struct lwp *l,
5052c1f729Schristos const struct compat_60_netbsd32__lwp_park_args *uap, register_t *retval)
5152c1f729Schristos {
5252c1f729Schristos /* {
5352c1f729Schristos syscallarg(const netbsd32_timespecp) ts;
5452c1f729Schristos syscallarg(lwpid_t) unpark;
5552c1f729Schristos syscallarg(netbsd32_voidp) hint;
5652c1f729Schristos syscallarg(netbsd32_voidp) unparkhint;
5752c1f729Schristos } */
5852c1f729Schristos struct timespec ts, *tsp;
5952c1f729Schristos struct netbsd32_timespec ts32;
6052c1f729Schristos int error;
6152c1f729Schristos
6252c1f729Schristos if (SCARG_P32(uap, ts) == NULL)
6352c1f729Schristos tsp = NULL;
6452c1f729Schristos else {
6552c1f729Schristos error = copyin(SCARG_P32(uap, ts), &ts32, sizeof ts32);
6652c1f729Schristos if (error != 0)
6752c1f729Schristos return error;
68ce69bf4aSchristos netbsd32_to_timespec(&ts32, &ts);
6952c1f729Schristos tsp = &ts;
7052c1f729Schristos }
7152c1f729Schristos
7252c1f729Schristos if (SCARG(uap, unpark) != 0) {
73*d1c42b4fSad error = lwp_unpark(&SCARG(uap, unpark), 1);
7452c1f729Schristos if (error != 0)
7552c1f729Schristos return error;
7652c1f729Schristos }
7752c1f729Schristos
78*d1c42b4fSad return lwp_park(CLOCK_REALTIME, TIMER_ABSTIME, tsp);
7952c1f729Schristos }
80d91f98a8Spgoyette
81d91f98a8Spgoyette static struct syscall_package compat_netbsd32_60_syscalls[] = {
82d91f98a8Spgoyette { NETBSD32_SYS_compat_60_netbsd32__lwp_park, 0,
83d91f98a8Spgoyette (sy_call_t *)compat_60_netbsd32__lwp_park },
84d91f98a8Spgoyette { 0, 0, NULL }
85d91f98a8Spgoyette };
86d91f98a8Spgoyette
87d91f98a8Spgoyette
88d91f98a8Spgoyette MODULE(MODULE_CLASS_EXEC, compat_netbsd32_60, "compat_netbsd32_80,compat_60");
89d91f98a8Spgoyette
90d91f98a8Spgoyette static int
compat_netbsd32_60_modcmd(modcmd_t cmd,void * arg)91d91f98a8Spgoyette compat_netbsd32_60_modcmd(modcmd_t cmd, void *arg)
92d91f98a8Spgoyette {
93d91f98a8Spgoyette
94d91f98a8Spgoyette switch (cmd) {
95d91f98a8Spgoyette case MODULE_CMD_INIT:
96d91f98a8Spgoyette return syscall_establish(&emul_netbsd32,
97d91f98a8Spgoyette compat_netbsd32_60_syscalls);
98d91f98a8Spgoyette
99d91f98a8Spgoyette case MODULE_CMD_FINI:
100d91f98a8Spgoyette return syscall_disestablish(&emul_netbsd32,
101d91f98a8Spgoyette compat_netbsd32_60_syscalls);
102d91f98a8Spgoyette
103d91f98a8Spgoyette default:
104d91f98a8Spgoyette return ENOTTY;
105d91f98a8Spgoyette }
106d91f98a8Spgoyette }
107