1*57718be8SEnji Cooper /* $NetBSD: k_uvm.c,v 1.1 2012/02/17 22:36:50 jmmv Exp $ */
2*57718be8SEnji Cooper /*
3*57718be8SEnji Cooper * Copyright (c) 2012 The NetBSD Foundation, Inc.
4*57718be8SEnji Cooper * All rights reserved.
5*57718be8SEnji Cooper *
6*57718be8SEnji Cooper * Redistribution and use in source and binary forms, with or without
7*57718be8SEnji Cooper * modification, are permitted provided that the following conditions
8*57718be8SEnji Cooper * are met:
9*57718be8SEnji Cooper * 1. Redistributions of source code must retain the above copyright
10*57718be8SEnji Cooper * notice, this list of conditions and the following disclaimer.
11*57718be8SEnji Cooper * 2. Redistributions in binary form must reproduce the above copyright
12*57718be8SEnji Cooper * notice, this list of conditions and the following disclaimer in the
13*57718be8SEnji Cooper * documentation and/or other materials provided with the distribution.
14*57718be8SEnji Cooper *
15*57718be8SEnji Cooper * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
16*57718be8SEnji Cooper * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
17*57718be8SEnji Cooper * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18*57718be8SEnji Cooper * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19*57718be8SEnji Cooper * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
20*57718be8SEnji Cooper * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21*57718be8SEnji Cooper * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
22*57718be8SEnji Cooper * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23*57718be8SEnji Cooper * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24*57718be8SEnji Cooper * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25*57718be8SEnji Cooper * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26*57718be8SEnji Cooper * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*57718be8SEnji Cooper */
28*57718be8SEnji Cooper
29*57718be8SEnji Cooper #include <sys/cdefs.h>
30*57718be8SEnji Cooper __KERNEL_RCSID(0, "$NetBSD: k_uvm.c,v 1.1 2012/02/17 22:36:50 jmmv Exp $");
31*57718be8SEnji Cooper
32*57718be8SEnji Cooper #include <sys/param.h>
33*57718be8SEnji Cooper #include <sys/kernel.h>
34*57718be8SEnji Cooper #include <sys/module.h>
35*57718be8SEnji Cooper #include <sys/sysctl.h>
36*57718be8SEnji Cooper
37*57718be8SEnji Cooper MODULE(MODULE_CLASS_MISC, k_uvm, NULL);
38*57718be8SEnji Cooper
39*57718be8SEnji Cooper /* --------------------------------------------------------------------- */
40*57718be8SEnji Cooper /* Sysctl interface to query information about the module. */
41*57718be8SEnji Cooper /* --------------------------------------------------------------------- */
42*57718be8SEnji Cooper
43*57718be8SEnji Cooper static struct sysctllog *clogp;
44*57718be8SEnji Cooper static int page_size;
45*57718be8SEnji Cooper
46*57718be8SEnji Cooper #define K_UVM 0x12345678
47*57718be8SEnji Cooper #define K_UVM_VALUE 0
48*57718be8SEnji Cooper
49*57718be8SEnji Cooper SYSCTL_SETUP(sysctl_k_uvm_setup, "sysctl k_uvm subtree setup")
50*57718be8SEnji Cooper {
51*57718be8SEnji Cooper
52*57718be8SEnji Cooper sysctl_createv(clog, 0, NULL, NULL,
53*57718be8SEnji Cooper CTLFLAG_PERMANENT,
54*57718be8SEnji Cooper CTLTYPE_NODE, "k_uvm", NULL,
55*57718be8SEnji Cooper NULL, 0, NULL, 0,
56*57718be8SEnji Cooper CTL_VENDOR, K_UVM, CTL_EOL);
57*57718be8SEnji Cooper
58*57718be8SEnji Cooper sysctl_createv(clog, 0, NULL, NULL,
59*57718be8SEnji Cooper CTLFLAG_PERMANENT,
60*57718be8SEnji Cooper CTLTYPE_INT, "page_size",
61*57718be8SEnji Cooper SYSCTL_DESCR("Value of PAGE_SIZE"),
62*57718be8SEnji Cooper NULL, 0, &page_size, 0,
63*57718be8SEnji Cooper CTL_VENDOR, K_UVM, K_UVM_VALUE, CTL_EOL);
64*57718be8SEnji Cooper }
65*57718be8SEnji Cooper
66*57718be8SEnji Cooper /* --------------------------------------------------------------------- */
67*57718be8SEnji Cooper /* Module management. */
68*57718be8SEnji Cooper /* --------------------------------------------------------------------- */
69*57718be8SEnji Cooper
70*57718be8SEnji Cooper static
71*57718be8SEnji Cooper int
k_uvm_init(prop_dictionary_t props)72*57718be8SEnji Cooper k_uvm_init(prop_dictionary_t props)
73*57718be8SEnji Cooper {
74*57718be8SEnji Cooper
75*57718be8SEnji Cooper page_size = PAGE_SIZE;
76*57718be8SEnji Cooper
77*57718be8SEnji Cooper sysctl_k_uvm_setup(&clogp);
78*57718be8SEnji Cooper
79*57718be8SEnji Cooper return 0;
80*57718be8SEnji Cooper }
81*57718be8SEnji Cooper
82*57718be8SEnji Cooper static
83*57718be8SEnji Cooper int
k_uvm_fini(void * arg)84*57718be8SEnji Cooper k_uvm_fini(void *arg)
85*57718be8SEnji Cooper {
86*57718be8SEnji Cooper
87*57718be8SEnji Cooper sysctl_teardown(&clogp);
88*57718be8SEnji Cooper
89*57718be8SEnji Cooper return 0;
90*57718be8SEnji Cooper }
91*57718be8SEnji Cooper
92*57718be8SEnji Cooper static
93*57718be8SEnji Cooper int
k_uvm_modcmd(modcmd_t cmd,void * arg)94*57718be8SEnji Cooper k_uvm_modcmd(modcmd_t cmd, void *arg)
95*57718be8SEnji Cooper {
96*57718be8SEnji Cooper int ret;
97*57718be8SEnji Cooper
98*57718be8SEnji Cooper switch (cmd) {
99*57718be8SEnji Cooper case MODULE_CMD_INIT:
100*57718be8SEnji Cooper ret = k_uvm_init(arg);
101*57718be8SEnji Cooper break;
102*57718be8SEnji Cooper
103*57718be8SEnji Cooper case MODULE_CMD_FINI:
104*57718be8SEnji Cooper ret = k_uvm_fini(arg);
105*57718be8SEnji Cooper break;
106*57718be8SEnji Cooper
107*57718be8SEnji Cooper case MODULE_CMD_STAT:
108*57718be8SEnji Cooper default:
109*57718be8SEnji Cooper ret = ENOTTY;
110*57718be8SEnji Cooper }
111*57718be8SEnji Cooper
112*57718be8SEnji Cooper return ret;
113*57718be8SEnji Cooper }
114