Created
October 25, 2013 18:52
-
-
Save semahawk/7159890 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SRCS=skelkld.c | |
KMOD=skeleton | |
.include <bsd.kmod.mk> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* A simple KLD Skeleton example. | |
* | |
* http://www.freebsd.org/doc/en/books/arch-handbook/driverbasics-kld.html | |
* | |
*/ | |
#include <sys/types.h> | |
#include <sys/module.h> | |
#include <sys/systm.h> /* uprintf */ | |
#include <sys/errno.h> | |
#include <sys/param.h> | |
#include <sys/kernel.h> | |
/* | |
* Load handler that deals with the loading and unloading of a KLD. | |
*/ | |
static int | |
skel_loader(struct module *m, int what, void *arg) | |
{ | |
int err = 0; | |
switch (what){ | |
case MOD_LOAD: /* kldload */ | |
uprintf("Skeleton KLD loaded.\n"); | |
break; | |
case MOD_UNLOAD: /* kldunload */ | |
uprintf("Skeleton KLD unloaded.\n"); | |
break; | |
default: | |
err = EOPNOTSUPP; | |
break; | |
} | |
return err; | |
} | |
/* | |
* Declare this module to the rest of the kernel | |
*/ | |
static moduledata_t skel_mod = { | |
"skel", | |
skel_loader, | |
NULL | |
}; | |
DECLARE_MODULE(skeleton, skel_mod, SI_SUB_KLD, SI_ORDER_ANY); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment