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