xref: /netbsd-src/sys/compat/common/uvm_50.c (revision 9fc453562f6ebe8eabdfd51e21ae0a0058906d4f)
1*9fc45356Sriastradh /*	$NetBSD: uvm_50.c,v 1.3 2020/09/05 16:30:10 riastradh Exp $	*/
2cf6b63b1Schristos 
3cf6b63b1Schristos /*-
4cf6b63b1Schristos  * Copyright (c) 2018 The NetBSD Foundation, Inc.
5cf6b63b1Schristos  * All rights reserved.
6cf6b63b1Schristos  *
7cf6b63b1Schristos  * This code is derived from software contributed to The NetBSD Foundation
8cf6b63b1Schristos  * by Christos Zoulas.
9cf6b63b1Schristos  *
10cf6b63b1Schristos  * Redistribution and use in source and binary forms, with or without
11cf6b63b1Schristos  * modification, are permitted provided that the following conditions
12cf6b63b1Schristos  * are met:
13cf6b63b1Schristos  * 1. Redistributions of source code must retain the above copyright
14cf6b63b1Schristos  *    notice, this list of conditions and the following disclaimer.
15cf6b63b1Schristos  * 2. Redistributions in binary form must reproduce the above copyright
16cf6b63b1Schristos  *    notice, this list of conditions and the following disclaimer in the
17cf6b63b1Schristos  *    documentation and/or other materials provided with the distribution.
18cf6b63b1Schristos  *
19cf6b63b1Schristos  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20cf6b63b1Schristos  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21cf6b63b1Schristos  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22cf6b63b1Schristos  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23cf6b63b1Schristos  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24cf6b63b1Schristos  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25cf6b63b1Schristos  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26cf6b63b1Schristos  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27cf6b63b1Schristos  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28cf6b63b1Schristos  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29cf6b63b1Schristos  * POSSIBILITY OF SUCH DAMAGE.
30cf6b63b1Schristos  */
31cf6b63b1Schristos 
32cf6b63b1Schristos #include <sys/cdefs.h>
33*9fc45356Sriastradh __KERNEL_RCSID(0, "$NetBSD: uvm_50.c,v 1.3 2020/09/05 16:30:10 riastradh Exp $");
34d91f98a8Spgoyette 
35d91f98a8Spgoyette #if defined(_KERNEL_OPT)
36d91f98a8Spgoyette #include "opt_compat_netbsd.h"
37d91f98a8Spgoyette #endif
38cf6b63b1Schristos 
39cf6b63b1Schristos #if defined(_KERNEL) || defined(_MODULE)
40cf6b63b1Schristos #if defined(_KERNEL_OPT)
41cf6b63b1Schristos #include "opt_vmswap.h"
42cf6b63b1Schristos #else
43cf6b63b1Schristos #define VMSWAP	/* XXX */
44cf6b63b1Schristos #endif
45cf6b63b1Schristos #endif
46cf6b63b1Schristos 
47cf6b63b1Schristos #include <sys/param.h>
48cf6b63b1Schristos #include <sys/types.h>
49cf6b63b1Schristos #include <sys/systm.h>
50cf6b63b1Schristos #include <sys/syscallargs.h>
51cf6b63b1Schristos #include <sys/swap.h>
52*9fc45356Sriastradh 
53*9fc45356Sriastradh #include <uvm/uvm_swap.h>
54cf6b63b1Schristos 
55cf6b63b1Schristos #include <compat/sys/uvm.h>
56cf6b63b1Schristos 
57cf6b63b1Schristos static void
swapent50_cvt(void * p,const struct swapent * se)58cf6b63b1Schristos swapent50_cvt(void *p, const struct swapent *se)
59cf6b63b1Schristos {
60cf6b63b1Schristos 	struct swapent50 *sep50 = p;
61cf6b63b1Schristos 
62cf6b63b1Schristos 	sep50->se50_dev = se->se_dev;
63cf6b63b1Schristos 	sep50->se50_flags = se->se_flags;
64cf6b63b1Schristos 	sep50->se50_nblks = se->se_nblks;
65cf6b63b1Schristos 	sep50->se50_inuse = se->se_inuse;
66cf6b63b1Schristos 	sep50->se50_priority = se->se_priority;
67cf6b63b1Schristos 	KASSERT(sizeof(se->se_path) <= sizeof(sep50->se50_path));
68cf6b63b1Schristos 	strcpy(sep50->se50_path, se->se_path);
69cf6b63b1Schristos }
70cf6b63b1Schristos 
71cf6b63b1Schristos 
72cf6b63b1Schristos static int
compat_uvm_swap_stats50(const struct sys_swapctl_args * uap,register_t * retval)73cf6b63b1Schristos compat_uvm_swap_stats50(const struct sys_swapctl_args *uap, register_t *retval)
74cf6b63b1Schristos {
75cf6b63b1Schristos      return uvm_swap_stats(SCARG(uap, arg), SCARG(uap, misc),
76cf6b63b1Schristos 	 swapent50_cvt, sizeof(struct swapent50), retval);
77cf6b63b1Schristos 
78cf6b63b1Schristos }
79cf6b63b1Schristos 
80cf6b63b1Schristos void
uvm_50_init(void)81cf6b63b1Schristos uvm_50_init(void)
82cf6b63b1Schristos {
83cf6b63b1Schristos 	uvm_swap_stats50 = compat_uvm_swap_stats50;
84cf6b63b1Schristos }
85cf6b63b1Schristos 
86cf6b63b1Schristos void
uvm_50_fini(void)87cf6b63b1Schristos uvm_50_fini(void)
88cf6b63b1Schristos {
89cf6b63b1Schristos 	uvm_swap_stats50 = (void *)enosys;
90cf6b63b1Schristos }
91