cdevmod.c (48212) | cdevmod.c (48275) |
---|---|
1/* 08 Nov 1998*/ 2/* 3 * cdevmod.c - a sample kld module implementing a character device driver. 4 * 5 * 08 Nov 1998 Rajesh Vaidheeswarran 6 * 7 * Copyright (c) 1998 Rajesh Vaidheeswarran 8 * All rights reserved. --- 55 unchanged lines hidden (view full) --- 64 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 65 * SUCH DAMAGE. 66 * 67 */ 68#include <sys/param.h> 69#include <sys/systm.h> 70#include <sys/kernel.h> 71#include <sys/module.h> | 1/* 08 Nov 1998*/ 2/* 3 * cdevmod.c - a sample kld module implementing a character device driver. 4 * 5 * 08 Nov 1998 Rajesh Vaidheeswarran 6 * 7 * Copyright (c) 1998 Rajesh Vaidheeswarran 8 * All rights reserved. --- 55 unchanged lines hidden (view full) --- 64 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 65 * SUCH DAMAGE. 66 * 67 */ 68#include <sys/param.h> 69#include <sys/systm.h> 70#include <sys/kernel.h> 71#include <sys/module.h> |
72#include <sys/conf.h> |
|
72 73#include "cdev.h" 74 | 73 74#include "cdev.h" 75 |
75static int cdev_load(module_t, modeventtype_t, void *); | 76#define CDEV_MAJOR 32 |
76 | 77 |
78static struct cdevsw my_devsw = { 79 /* open */ mydev_open, 80 /* close */ mydev_close, 81 /* read */ noread, 82 /* write */ nowrite, 83 /* ioctl */ mydev_ioctl, 84 /* stop */ nostop, 85 /* reset */ noreset, 86 /* devtotty */ nodevtotty, 87 /* poll */ nopoll, 88 /* mmap */ nommap, 89 /* strategy */ nostrategy, 90 /* name */ "cdev", 91 /* parms */ noparms, 92 /* maj */ CDEV_MAJOR, 93 /* dump */ nodump, 94 /* psize */ nopsize, 95 /* flags */ D_TTY, 96 /* maxio */ 0, 97 /* bmaj */ -1 98}; 99 |
|
77/* 78 * This function is called each time the module is loaded or unloaded. 79 * Since we are a miscellaneous module, we have to provide whatever 80 * code is necessary to patch ourselves into the area we are being 81 * loaded to change. 82 * 83 * The stat information is basically common to all modules, so there 84 * is no real issue involved with stat; we will leave it lkm_nullcmd(), 85 * since we don't have to do anything about it. 86 */ 87 88static int | 100/* 101 * This function is called each time the module is loaded or unloaded. 102 * Since we are a miscellaneous module, we have to provide whatever 103 * code is necessary to patch ourselves into the area we are being 104 * loaded to change. 105 * 106 * The stat information is basically common to all modules, so there 107 * is no real issue involved with stat; we will leave it lkm_nullcmd(), 108 * since we don't have to do anything about it. 109 */ 110 111static int |
89cdev_load(mod, cmd, arg) 90 module_t mod; 91 modeventtype_t cmd; 92 void * arg; | 112cdev_load(module_t mod, int cmd, void *arg) |
93{ 94 int err = 0; 95 96 switch (cmd) { 97 case MOD_LOAD: 98 99 /* Do any initialization that you should do with the kernel */ 100 --- 13 unchanged lines hidden (view full) --- 114 break; 115 } 116 117 return(err); 118} 119 120/* Now declare the module to the system */ 121 | 113{ 114 int err = 0; 115 116 switch (cmd) { 117 case MOD_LOAD: 118 119 /* Do any initialization that you should do with the kernel */ 120 --- 13 unchanged lines hidden (view full) --- 134 break; 135 } 136 137 return(err); 138} 139 140/* Now declare the module to the system */ 141 |
122DEV_MODULE(cdev_mod, CDEV_MAJOR, -1, my_devsw, cdev_load, 0); | 142DEV_MODULE(cdev, CDEV_MAJOR, -1, my_devsw, cdev_load, 0); |