1*ea5c7e85Sriastradh /* $NetBSD: uvm_50.c,v 1.3 2020/09/05 16:30:10 riastradh Exp $ */
245912c89Schristos
345912c89Schristos /*-
445912c89Schristos * Copyright (c) 2018 The NetBSD Foundation, Inc.
545912c89Schristos * All rights reserved.
645912c89Schristos *
745912c89Schristos * This code is derived from software contributed to The NetBSD Foundation
845912c89Schristos * by Christos Zoulas.
945912c89Schristos *
1045912c89Schristos * Redistribution and use in source and binary forms, with or without
1145912c89Schristos * modification, are permitted provided that the following conditions
1245912c89Schristos * are met:
1345912c89Schristos * 1. Redistributions of source code must retain the above copyright
1445912c89Schristos * notice, this list of conditions and the following disclaimer.
1545912c89Schristos * 2. Redistributions in binary form must reproduce the above copyright
1645912c89Schristos * notice, this list of conditions and the following disclaimer in the
1745912c89Schristos * documentation and/or other materials provided with the distribution.
1845912c89Schristos *
1945912c89Schristos * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2045912c89Schristos * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2145912c89Schristos * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2245912c89Schristos * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2345912c89Schristos * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2445912c89Schristos * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2545912c89Schristos * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2645912c89Schristos * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2745912c89Schristos * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2845912c89Schristos * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2945912c89Schristos * POSSIBILITY OF SUCH DAMAGE.
3045912c89Schristos */
3145912c89Schristos
3245912c89Schristos #include <sys/cdefs.h>
33*ea5c7e85Sriastradh __KERNEL_RCSID(0, "$NetBSD: uvm_50.c,v 1.3 2020/09/05 16:30:10 riastradh Exp $");
34cc17ee2eSpgoyette
35cc17ee2eSpgoyette #if defined(_KERNEL_OPT)
36cc17ee2eSpgoyette #include "opt_compat_netbsd.h"
37cc17ee2eSpgoyette #endif
3845912c89Schristos
3945912c89Schristos #if defined(_KERNEL) || defined(_MODULE)
4045912c89Schristos #if defined(_KERNEL_OPT)
4145912c89Schristos #include "opt_vmswap.h"
4245912c89Schristos #else
4345912c89Schristos #define VMSWAP /* XXX */
4445912c89Schristos #endif
4545912c89Schristos #endif
4645912c89Schristos
4745912c89Schristos #include <sys/param.h>
4845912c89Schristos #include <sys/types.h>
4945912c89Schristos #include <sys/systm.h>
5045912c89Schristos #include <sys/syscallargs.h>
5145912c89Schristos #include <sys/swap.h>
52*ea5c7e85Sriastradh
53*ea5c7e85Sriastradh #include <uvm/uvm_swap.h>
5445912c89Schristos
5545912c89Schristos #include <compat/sys/uvm.h>
5645912c89Schristos
5745912c89Schristos static void
swapent50_cvt(void * p,const struct swapent * se)5845912c89Schristos swapent50_cvt(void *p, const struct swapent *se)
5945912c89Schristos {
6045912c89Schristos struct swapent50 *sep50 = p;
6145912c89Schristos
6245912c89Schristos sep50->se50_dev = se->se_dev;
6345912c89Schristos sep50->se50_flags = se->se_flags;
6445912c89Schristos sep50->se50_nblks = se->se_nblks;
6545912c89Schristos sep50->se50_inuse = se->se_inuse;
6645912c89Schristos sep50->se50_priority = se->se_priority;
6745912c89Schristos KASSERT(sizeof(se->se_path) <= sizeof(sep50->se50_path));
6845912c89Schristos strcpy(sep50->se50_path, se->se_path);
6945912c89Schristos }
7045912c89Schristos
7145912c89Schristos
7245912c89Schristos static int
compat_uvm_swap_stats50(const struct sys_swapctl_args * uap,register_t * retval)7345912c89Schristos compat_uvm_swap_stats50(const struct sys_swapctl_args *uap, register_t *retval)
7445912c89Schristos {
7545912c89Schristos return uvm_swap_stats(SCARG(uap, arg), SCARG(uap, misc),
7645912c89Schristos swapent50_cvt, sizeof(struct swapent50), retval);
7745912c89Schristos
7845912c89Schristos }
7945912c89Schristos
8045912c89Schristos void
uvm_50_init(void)8145912c89Schristos uvm_50_init(void)
8245912c89Schristos {
8345912c89Schristos uvm_swap_stats50 = compat_uvm_swap_stats50;
8445912c89Schristos }
8545912c89Schristos
8645912c89Schristos void
uvm_50_fini(void)8745912c89Schristos uvm_50_fini(void)
8845912c89Schristos {
8945912c89Schristos uvm_swap_stats50 = (void *)enosys;
9045912c89Schristos }
91