xref: /netbsd-src/sys/modules/examples/hello/hello.c (revision 14e2571904077c981cf5117cb4adbc7baa12af4b)
1*14e25719Spgoyette /*	$NetBSD: hello.c,v 1.1 2015/05/13 07:07:36 pgoyette Exp $	*/
2*14e25719Spgoyette 
3*14e25719Spgoyette /*-
4*14e25719Spgoyette  * Copyright (c) 2015 The NetBSD Foundation, Inc.
5*14e25719Spgoyette  * All rights reserved.
6*14e25719Spgoyette  *
7*14e25719Spgoyette  * Redistribution and use in source and binary forms, with or without
8*14e25719Spgoyette  * modification, are permitted provided that the following conditions
9*14e25719Spgoyette  * are met:
10*14e25719Spgoyette  * 1. Redistributions of source code must retain the above copyright
11*14e25719Spgoyette  *    notice, this list of conditions and the following disclaimer.
12*14e25719Spgoyette  * 2. Redistributions in binary form must reproduce the above copyright
13*14e25719Spgoyette  *    notice, this list of conditions and the following disclaimer in the
14*14e25719Spgoyette  *    documentation and/or other materials provided with the distribution.
15*14e25719Spgoyette  *
16*14e25719Spgoyette  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17*14e25719Spgoyette  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18*14e25719Spgoyette  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19*14e25719Spgoyette  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20*14e25719Spgoyette  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21*14e25719Spgoyette  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22*14e25719Spgoyette  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23*14e25719Spgoyette  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24*14e25719Spgoyette  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25*14e25719Spgoyette  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26*14e25719Spgoyette  * POSSIBILITY OF SUCH DAMAGE.
27*14e25719Spgoyette  */
28*14e25719Spgoyette 
29*14e25719Spgoyette #include <sys/cdefs.h>
30*14e25719Spgoyette __KERNEL_RCSID(0, "$NetBSD: hello.c,v 1.1 2015/05/13 07:07:36 pgoyette Exp $");
31*14e25719Spgoyette 
32*14e25719Spgoyette #include <sys/param.h>
33*14e25719Spgoyette #include <sys/module.h>
34*14e25719Spgoyette 
35*14e25719Spgoyette /*
36*14e25719Spgoyette  * Last parameter of MODULE macro is a list of names (as string; names are
37*14e25719Spgoyette  * separated by commas) of dependencies.  If module has no dependencies,
38*14e25719Spgoyette  * then NULL should be passed.
39*14e25719Spgoyette  */
40*14e25719Spgoyette 
41*14e25719Spgoyette MODULE(MODULE_CLASS_MISC, hello, NULL);
42*14e25719Spgoyette 
43*14e25719Spgoyette static int
hello_modcmd(modcmd_t cmd,void * arg __unused)44*14e25719Spgoyette hello_modcmd(modcmd_t cmd, void *arg __unused)
45*14e25719Spgoyette {
46*14e25719Spgoyette 	switch (cmd) {
47*14e25719Spgoyette 	case MODULE_CMD_INIT:
48*14e25719Spgoyette 		printf("Example module loaded.\n");
49*14e25719Spgoyette 		break;
50*14e25719Spgoyette 
51*14e25719Spgoyette 	case MODULE_CMD_FINI:
52*14e25719Spgoyette 		printf("Example module unloaded.\n");
53*14e25719Spgoyette 		break;
54*14e25719Spgoyette 
55*14e25719Spgoyette 	case MODULE_CMD_STAT:
56*14e25719Spgoyette 		printf("Example module status queried.\n");
57*14e25719Spgoyette 		break;
58*14e25719Spgoyette 
59*14e25719Spgoyette 	default:
60*14e25719Spgoyette 		return ENOTTY;
61*14e25719Spgoyette 	}
62*14e25719Spgoyette 
63*14e25719Spgoyette 	return 0;
64*14e25719Spgoyette }
65