diff options
Diffstat (limited to 'share/examples')
-rw-r--r-- | share/examples/kld/cdev/module/Makefile | 4 | ||||
-rw-r--r-- | share/examples/kld/cdev/module/cdev.c | 5 | ||||
-rw-r--r-- | share/examples/kld/cdev/module/cdev.h | 21 | ||||
-rw-r--r-- | share/examples/kld/cdev/module/cdevmod.c | 32 | ||||
-rw-r--r-- | share/examples/kld/cdev/test/testcdev.c | 3 |
5 files changed, 34 insertions, 31 deletions
diff --git a/share/examples/kld/cdev/module/Makefile b/share/examples/kld/cdev/module/Makefile index aa07686..9e95e85 100644 --- a/share/examples/kld/cdev/module/Makefile +++ b/share/examples/kld/cdev/module/Makefile @@ -34,7 +34,7 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $Id: Makefile,v 1.5 1998/11/08 22:31:00 rv Exp $ +# $Id: Makefile,v 1.1 1998/12/11 10:44:30 dfr Exp $ # # Copyright (c) 1993 Terrence R. Lambert. # All rights reserved. @@ -69,7 +69,7 @@ BINDIR = /tmp SRCS = cdev.c cdevmod.c -KMOD = cdev_mod +KMOD = cdev NOMAN = t KLDMOD = t diff --git a/share/examples/kld/cdev/module/cdev.c b/share/examples/kld/cdev/module/cdev.c index 8739a52..4cbbc07 100644 --- a/share/examples/kld/cdev/module/cdev.c +++ b/share/examples/kld/cdev/module/cdev.c @@ -68,6 +68,9 @@ #include <sys/param.h> #include <sys/systm.h> #include <sys/ioccom.h> +#include <sys/systm.h> +#include <sys/conf.h> + #include "cdev.h" /* @@ -109,7 +112,7 @@ mydev_ioctl(dev_t dev, u_long cmd, caddr_t arg, int mode, struct proc *procp) int error = 0; printf("mydev_ioctl: dev_t=%d, cmd=%lx, arg=%p, mode=%x procp=%p\n", - dev, cmd, arg, mode, procp); + dev2udev(dev), cmd, arg, mode, procp); switch(cmd) { case CDEV_IOCTL1: diff --git a/share/examples/kld/cdev/module/cdev.h b/share/examples/kld/cdev/module/cdev.h index 34c8235..88b3cb9 100644 --- a/share/examples/kld/cdev/module/cdev.h +++ b/share/examples/kld/cdev/module/cdev.h @@ -70,29 +70,8 @@ #ifndef __CDEV_H_ #define __CDEV_H_ -#include <sys/conf.h> - d_open_t mydev_open; d_close_t mydev_close; d_ioctl_t mydev_ioctl; -#define CDEV_MAJOR 32 - -static struct cdevsw my_devsw = { - mydev_open, - mydev_close, - noread, - nowrite, - mydev_ioctl, - nostop, - noreset, - nodevtotty, - NULL, - nommap, - NULL, - "cdev", - NULL, - CDEV_MAJOR -}; - #endif diff --git a/share/examples/kld/cdev/module/cdevmod.c b/share/examples/kld/cdev/module/cdevmod.c index e2ee2e8..5c9ef47 100644 --- a/share/examples/kld/cdev/module/cdevmod.c +++ b/share/examples/kld/cdev/module/cdevmod.c @@ -69,10 +69,33 @@ #include <sys/systm.h> #include <sys/kernel.h> #include <sys/module.h> +#include <sys/conf.h> #include "cdev.h" -static int cdev_load(module_t, modeventtype_t, void *); +#define CDEV_MAJOR 32 + +static struct cdevsw my_devsw = { + /* open */ mydev_open, + /* close */ mydev_close, + /* read */ noread, + /* write */ nowrite, + /* ioctl */ mydev_ioctl, + /* stop */ nostop, + /* reset */ noreset, + /* devtotty */ nodevtotty, + /* poll */ nopoll, + /* mmap */ nommap, + /* strategy */ nostrategy, + /* name */ "cdev", + /* parms */ noparms, + /* maj */ CDEV_MAJOR, + /* dump */ nodump, + /* psize */ nopsize, + /* flags */ D_TTY, + /* maxio */ 0, + /* bmaj */ -1 +}; /* * This function is called each time the module is loaded or unloaded. @@ -86,10 +109,7 @@ static int cdev_load(module_t, modeventtype_t, void *); */ static int -cdev_load(mod, cmd, arg) - module_t mod; - modeventtype_t cmd; - void * arg; +cdev_load(module_t mod, int cmd, void *arg) { int err = 0; @@ -119,4 +139,4 @@ cdev_load(mod, cmd, arg) /* Now declare the module to the system */ -DEV_MODULE(cdev_mod, CDEV_MAJOR, -1, my_devsw, cdev_load, 0); +DEV_MODULE(cdev, CDEV_MAJOR, -1, my_devsw, cdev_load, 0); diff --git a/share/examples/kld/cdev/test/testcdev.c b/share/examples/kld/cdev/test/testcdev.c index c1aeeba..e43df97 100644 --- a/share/examples/kld/cdev/test/testcdev.c +++ b/share/examples/kld/cdev/test/testcdev.c @@ -74,8 +74,9 @@ #define CDEV_IOCTL1 _IOR('C', 1, u_int) #define CDEV_DEVICE "cdev" + int -main() +main(int argc, char *argv[]) { int kernel_fd; int one; |