1*d91f98a8Spgoyette /* $NetBSD: vm_12.c,v 1.21 2019/01/27 02:08:39 pgoyette Exp $ */
2bd8a2cdaSmrg
3bd8a2cdaSmrg /*
4bd8a2cdaSmrg * Copyright (c) 1997 Matthew R. Green
5bd8a2cdaSmrg * All rights reserved.
6bd8a2cdaSmrg *
7bd8a2cdaSmrg * Redistribution and use in source and binary forms, with or without
8bd8a2cdaSmrg * modification, are permitted provided that the following conditions
9bd8a2cdaSmrg * are met:
10bd8a2cdaSmrg * 1. Redistributions of source code must retain the above copyright
11bd8a2cdaSmrg * notice, this list of conditions and the following disclaimer.
12bd8a2cdaSmrg * 2. Redistributions in binary form must reproduce the above copyright
13bd8a2cdaSmrg * notice, this list of conditions and the following disclaimer in the
14bd8a2cdaSmrg * documentation and/or other materials provided with the distribution.
15bd8a2cdaSmrg *
16bd8a2cdaSmrg * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17bd8a2cdaSmrg * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18bd8a2cdaSmrg * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19bd8a2cdaSmrg * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20bd8a2cdaSmrg * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21bd8a2cdaSmrg * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22bd8a2cdaSmrg * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23bd8a2cdaSmrg * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24bd8a2cdaSmrg * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25bd8a2cdaSmrg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26bd8a2cdaSmrg * SUCH DAMAGE.
27bd8a2cdaSmrg */
28bd8a2cdaSmrg
29dab6ef8bSlukem #include <sys/cdefs.h>
30*d91f98a8Spgoyette __KERNEL_RCSID(0, "$NetBSD: vm_12.c,v 1.21 2019/01/27 02:08:39 pgoyette Exp $");
31*d91f98a8Spgoyette
32*d91f98a8Spgoyette #if defined(_KERNEL_OPT)
33*d91f98a8Spgoyette #include "opt_compat_netbsd.h"
34*d91f98a8Spgoyette #endif
35dab6ef8bSlukem
36bd8a2cdaSmrg #include <sys/param.h>
37bd8a2cdaSmrg #include <sys/systm.h>
38*d91f98a8Spgoyette #include <sys/syscall.h>
39*d91f98a8Spgoyette #include <sys/syscallvar.h>
40bd8a2cdaSmrg #include <sys/syscallargs.h>
41bd8a2cdaSmrg
42edda33e0Smrg #include <sys/swap.h>
43bb19445eSchristos #include <sys/mman.h>
44bd8a2cdaSmrg
45*d91f98a8Spgoyette #include <compat/common/compat_mod.h>
46*d91f98a8Spgoyette
47*d91f98a8Spgoyette static const struct syscall_package vm_12_syscalls[] = {
48*d91f98a8Spgoyette { SYS_compat_12_msync, 0, (sy_call_t *)compat_12_sys_msync },
49*d91f98a8Spgoyette { SYS_compat_12_oswapon, 0, (sy_call_t *)compat_12_sys_swapon },
50*d91f98a8Spgoyette { 0, 0, NULL }
51*d91f98a8Spgoyette };
52*d91f98a8Spgoyette
53bd8a2cdaSmrg int
compat_12_sys_swapon(struct lwp * l,const struct compat_12_sys_swapon_args * uap,register_t * retval)54*d91f98a8Spgoyette compat_12_sys_swapon(struct lwp *l,
55*d91f98a8Spgoyette const struct compat_12_sys_swapon_args *uap, register_t *retval)
56bd8a2cdaSmrg {
577e2790cfSdsl /* {
58bd8a2cdaSmrg syscallarg(const char *) name;
597e2790cfSdsl } */
607e2790cfSdsl struct sys_swapctl_args ua;
61bd8a2cdaSmrg
62bd8a2cdaSmrg SCARG(&ua, cmd) = SWAP_ON;
63fb4b40b7Schristos /*XXXUNCONST*/
64fb4b40b7Schristos SCARG(&ua, arg) = __UNCONST(SCARG(uap, name));
65bd8a2cdaSmrg SCARG(&ua, misc) = 0; /* priority */
666762b37eSthorpej return (sys_swapctl(l, &ua, retval));
67bd8a2cdaSmrg }
68bb19445eSchristos
69bb19445eSchristos int
compat_12_sys_msync(struct lwp * l,const struct compat_12_sys_msync_args * uap,register_t * retval)70*d91f98a8Spgoyette compat_12_sys_msync(struct lwp *l,
71*d91f98a8Spgoyette const struct compat_12_sys_msync_args *uap, register_t *retval)
72bb19445eSchristos {
737e2790cfSdsl /* {
7453524e44Schristos syscallarg(void *) addr;
75bb19445eSchristos syscallarg(size_t) len;
767e2790cfSdsl } */
777e2790cfSdsl struct sys___msync13_args ua;
78bb19445eSchristos
79276fd166Ssimonb SCARG(&ua, addr) = SCARG(uap, addr);
80276fd166Ssimonb SCARG(&ua, len) = SCARG(uap, len);
81bb19445eSchristos SCARG(&ua, flags) = MS_SYNC | MS_INVALIDATE;
826762b37eSthorpej return (sys___msync13(l, &ua, retval));
83bb19445eSchristos }
84*d91f98a8Spgoyette
85*d91f98a8Spgoyette int
vm_12_init(void)86*d91f98a8Spgoyette vm_12_init(void)
87*d91f98a8Spgoyette {
88*d91f98a8Spgoyette
89*d91f98a8Spgoyette return syscall_establish(NULL, vm_12_syscalls);
90*d91f98a8Spgoyette }
91*d91f98a8Spgoyette
92*d91f98a8Spgoyette int
vm_12_fini(void)93*d91f98a8Spgoyette vm_12_fini(void)
94*d91f98a8Spgoyette {
95*d91f98a8Spgoyette
96*d91f98a8Spgoyette return syscall_disestablish(NULL, vm_12_syscalls);
97*d91f98a8Spgoyette }
98