1*d11110f4Schristos /* $NetBSD: kern_event_100.c,v 1.1 2023/07/28 18:19:00 christos Exp $ */
2*d11110f4Schristos
3*d11110f4Schristos /*-
4*d11110f4Schristos * Copyright (c) 2023 The NetBSD Foundation, Inc.
5*d11110f4Schristos * All rights reserved.
6*d11110f4Schristos *
7*d11110f4Schristos * Redistribution and use in source and binary forms, with or without
8*d11110f4Schristos * modification, are permitted provided that the following conditions
9*d11110f4Schristos * are met:
10*d11110f4Schristos * 1. Redistributions of source code must retain the above copyright
11*d11110f4Schristos * notice, this list of conditions and the following disclaimer.
12*d11110f4Schristos * 2. Redistributions in binary form must reproduce the above copyright
13*d11110f4Schristos * notice, this list of conditions and the following disclaimer in the
14*d11110f4Schristos * documentation and/or other materials provided with the distribution.
15*d11110f4Schristos *
16*d11110f4Schristos * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17*d11110f4Schristos * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18*d11110f4Schristos * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19*d11110f4Schristos * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20*d11110f4Schristos * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21*d11110f4Schristos * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22*d11110f4Schristos * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23*d11110f4Schristos * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24*d11110f4Schristos * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25*d11110f4Schristos * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26*d11110f4Schristos * POSSIBILITY OF SUCH DAMAGE.
27*d11110f4Schristos */
28*d11110f4Schristos #include <sys/cdefs.h>
29*d11110f4Schristos __KERNEL_RCSID(0, "$NetBSD: kern_event_100.c,v 1.1 2023/07/28 18:19:00 christos Exp $");
30*d11110f4Schristos
31*d11110f4Schristos #if defined(_KERNEL_OPT)
32*d11110f4Schristos #include "opt_compat_netbsd.h"
33*d11110f4Schristos #endif
34*d11110f4Schristos
35*d11110f4Schristos #include <sys/param.h>
36*d11110f4Schristos #include <sys/event.h>
37*d11110f4Schristos #include <sys/syscall.h>
38*d11110f4Schristos #include <sys/syscallvar.h>
39*d11110f4Schristos #include <sys/syscallargs.h>
40*d11110f4Schristos
41*d11110f4Schristos #include <compat/common/compat_mod.h>
42*d11110f4Schristos #include <compat/sys/event.h>
43*d11110f4Schristos
44*d11110f4Schristos static const struct syscall_package kern_event_100_syscalls[] = {
45*d11110f4Schristos { SYS_compat_100___kevent50, 0,
46*d11110f4Schristos (sy_call_t *)compat_100_sys___kevent50 },
47*d11110f4Schristos { 0, 0, NULL },
48*d11110f4Schristos };
49*d11110f4Schristos
50*d11110f4Schristos int
compat_100_sys___kevent50(struct lwp * l,const struct compat_100_sys___kevent50_args * uap,register_t * retval)51*d11110f4Schristos compat_100_sys___kevent50(struct lwp *l,
52*d11110f4Schristos const struct compat_100_sys___kevent50_args *uap,
53*d11110f4Schristos register_t *retval)
54*d11110f4Schristos {
55*d11110f4Schristos /* {
56*d11110f4Schristos syscallarg(int) fd;
57*d11110f4Schristos syscallarg(const struct kevent100 *) changelist;
58*d11110f4Schristos syscallarg(size_t) nchanges;
59*d11110f4Schristos syscallarg(struct kevent100 *) eventlist;
60*d11110f4Schristos syscallarg(size_t) nevents;
61*d11110f4Schristos syscallarg(const struct timespec *) timeout;
62*d11110f4Schristos } */
63*d11110f4Schristos static const struct kevent_ops compat_100_kevent_ops = {
64*d11110f4Schristos .keo_private = NULL,
65*d11110f4Schristos .keo_fetch_timeout = copyin,
66*d11110f4Schristos .keo_fetch_changes = compat_100___kevent50_fetch_changes,
67*d11110f4Schristos .keo_put_events = compat_100___kevent50_put_events,
68*d11110f4Schristos };
69*d11110f4Schristos
70*d11110f4Schristos return kevent1(retval, SCARG(uap, fd),
71*d11110f4Schristos (const struct kevent *)SCARG(uap, changelist), SCARG(uap, nchanges),
72*d11110f4Schristos (struct kevent *)SCARG(uap, eventlist), SCARG(uap, nevents),
73*d11110f4Schristos SCARG(uap, timeout), &compat_100_kevent_ops);
74*d11110f4Schristos }
75*d11110f4Schristos
76*d11110f4Schristos int
kern_event_100_init(void)77*d11110f4Schristos kern_event_100_init(void)
78*d11110f4Schristos {
79*d11110f4Schristos
80*d11110f4Schristos return syscall_establish(NULL, kern_event_100_syscalls);
81*d11110f4Schristos }
82*d11110f4Schristos
83*d11110f4Schristos int
kern_event_100_fini(void)84*d11110f4Schristos kern_event_100_fini(void)
85*d11110f4Schristos {
86*d11110f4Schristos
87*d11110f4Schristos return syscall_disestablish(NULL, kern_event_100_syscalls);
88*d11110f4Schristos }
89