diff --git a/lkm/syscons/star/star_saver.c b/lkm/syscons/star/star_saver.c index 0ff3117cb339..465c493a3dcf 100644 --- a/lkm/syscons/star/star_saver.c +++ b/lkm/syscons/star/star_saver.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id$ + * $Id: star_saver.c,v 1.10 1997/02/22 12:49:22 peter Exp $ */ #include @@ -112,6 +112,6 @@ star_saver_unload(struct lkm_table *lkmtp, int cmd) int star_saver_mod(struct lkm_table *lkmtp, int cmd, int ver) { - DISPATCH(lkmtp, cmd, ver, star_saver_load, star_saver_unload, - lkm_nullcmd); + MOD_DISPATCH(star_saver, lkmtp, cmd, ver, + star_saver_load, star_saver_unload, lkm_nullcmd); } diff --git a/share/examples/lkm/misc/module/miscmod.c b/share/examples/lkm/misc/module/miscmod.c index 410b52622866..16bbeccf11a4 100644 --- a/share/examples/lkm/misc/module/miscmod.c +++ b/share/examples/lkm/misc/module/miscmod.c @@ -37,18 +37,11 @@ * */ #include -#include -#include #include #include -#include -#include #include #include #include -#include -#include -#include /* XXX this should be in a header. */ extern int misccall __P((struct proc *p, void *uap, int retval[])); @@ -186,5 +179,6 @@ struct lkm_table *lkmtp; int cmd; int ver; { - DISPATCH(lkmtp, cmd, ver, misc_load, misc_load, lkm_nullcmd); + MOD_DISPATCH(misc, lkmtp, cmd, ver, + misc_load, misc_load, lkm_nullcmd); } diff --git a/sys/dev/joy/joy.c b/sys/dev/joy/joy.c index 5f6ca2ebfa6b..9675e79b6bb4 100644 --- a/sys/dev/joy/joy.c +++ b/sys/dev/joy/joy.c @@ -259,7 +259,7 @@ MOD_DEV (joy, LM_DT_CHAR, CDEV_MAJOR, &joy_cdevsw); static struct isa_device dev = {0, &joydriver, IO_GAME, 0, -1, (caddr_t) 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0}; -int +static int joy_load (struct lkm_table *lkmtp, int cmd) { if (joyprobe (&dev)) { @@ -273,22 +273,24 @@ joy_load (struct lkm_table *lkmtp, int cmd) } } -int +static int joy_unload (struct lkm_table *lkmtp, int cmd) { uprintf ("Joystick driver unloaded\n"); return 0; } -int + +static int joy_stat (struct lkm_table *lkmtp, int cmd) { return 0; } + int joy_mod (struct lkm_table *lkmtp, int cmd, int ver) { -#define _module joy_module - DISPATCH(lkmtp, cmd, ver, joy_load, joy_unload, joy_stat); + MOD_DISPATCH(joy, lkmtp, cmd, ver, + joy_load, joy_unload, joy_stat); } #endif /* JOY_MODULE */ diff --git a/sys/dev/syscons/star/star_saver.c b/sys/dev/syscons/star/star_saver.c index 0ff3117cb339..465c493a3dcf 100644 --- a/sys/dev/syscons/star/star_saver.c +++ b/sys/dev/syscons/star/star_saver.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id$ + * $Id: star_saver.c,v 1.10 1997/02/22 12:49:22 peter Exp $ */ #include @@ -112,6 +112,6 @@ star_saver_unload(struct lkm_table *lkmtp, int cmd) int star_saver_mod(struct lkm_table *lkmtp, int cmd, int ver) { - DISPATCH(lkmtp, cmd, ver, star_saver_load, star_saver_unload, - lkm_nullcmd); + MOD_DISPATCH(star_saver, lkmtp, cmd, ver, + star_saver_load, star_saver_unload, lkm_nullcmd); } diff --git a/sys/i386/isa/atapi.c b/sys/i386/isa/atapi.c index 8d0b43aa95bd..05b8e451f152 100644 --- a/sys/i386/isa/atapi.c +++ b/sys/i386/isa/atapi.c @@ -1067,7 +1067,8 @@ static int atapi_unload (struct lkm_table *lkmtp, int cmd) */ int atapi_mod (struct lkm_table *lkmtp, int cmd, int ver) { - DISPATCH (lkmtp, cmd, ver, atapi_load, atapi_unload, lkm_nullcmd); + MOD_DISPATCH (atapi, lkmtp, cmd, ver, + atapi_load, atapi_unload, lkm_nullcmd); } #endif /* ATAPI_MODULE */ diff --git a/sys/i386/isa/joy.c b/sys/i386/isa/joy.c index 5f6ca2ebfa6b..9675e79b6bb4 100644 --- a/sys/i386/isa/joy.c +++ b/sys/i386/isa/joy.c @@ -259,7 +259,7 @@ MOD_DEV (joy, LM_DT_CHAR, CDEV_MAJOR, &joy_cdevsw); static struct isa_device dev = {0, &joydriver, IO_GAME, 0, -1, (caddr_t) 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0}; -int +static int joy_load (struct lkm_table *lkmtp, int cmd) { if (joyprobe (&dev)) { @@ -273,22 +273,24 @@ joy_load (struct lkm_table *lkmtp, int cmd) } } -int +static int joy_unload (struct lkm_table *lkmtp, int cmd) { uprintf ("Joystick driver unloaded\n"); return 0; } -int + +static int joy_stat (struct lkm_table *lkmtp, int cmd) { return 0; } + int joy_mod (struct lkm_table *lkmtp, int cmd, int ver) { -#define _module joy_module - DISPATCH(lkmtp, cmd, ver, joy_load, joy_unload, joy_stat); + MOD_DISPATCH(joy, lkmtp, cmd, ver, + joy_load, joy_unload, joy_stat); } #endif /* JOY_MODULE */ diff --git a/sys/i386/isa/qcam.c b/sys/i386/isa/qcam.c index ae09aa6e13a4..5cdb2e2eaeb3 100644 --- a/sys/i386/isa/qcam.c +++ b/sys/i386/isa/qcam.c @@ -312,9 +312,8 @@ qcam_stat (struct lkm_table *lkmtp, int cmd) int qcam_mod (struct lkm_table *lkmtp, int cmd, int ver) { -#define _module qcam_module - DISPATCH(lkmtp, cmd, ver, - qcam_load, qcam_unload, qcam_stat); + MOD_DISPATCH(qcam, lkmtp, cmd, ver, + qcam_load, qcam_unload, qcam_stat); } #endif /* QCAM_MODULE */ diff --git a/sys/i386/isa/wcd.c b/sys/i386/isa/wcd.c index 904b5ea770a1..702c7f24a04d 100644 --- a/sys/i386/isa/wcd.c +++ b/sys/i386/isa/wcd.c @@ -1179,14 +1179,16 @@ int wcd_mod (struct lkm_table *lkmtp, int cmd, int ver) if (err) return err; + /* XXX Poking around in the LKM internals like this is bad. + */ /* Register the cdevsw entry. */ - lkmtp->private.lkm_dev = &rwcd_module; + lkmtp->private.lkm_dev = & MOD_PRIVATE(rwcd); err = lkmdispatch (lkmtp, cmd); if (err) return err; /* Register the bdevsw entry. */ - lkmtp->private.lkm_dev = &wcd_module; + lkmtp->private.lkm_dev = & MOD_PRIVATE(wcd); return lkmdispatch (lkmtp, cmd); } #endif /* WCD_MODULE */ diff --git a/sys/isa/joy.c b/sys/isa/joy.c index 5f6ca2ebfa6b..9675e79b6bb4 100644 --- a/sys/isa/joy.c +++ b/sys/isa/joy.c @@ -259,7 +259,7 @@ MOD_DEV (joy, LM_DT_CHAR, CDEV_MAJOR, &joy_cdevsw); static struct isa_device dev = {0, &joydriver, IO_GAME, 0, -1, (caddr_t) 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0}; -int +static int joy_load (struct lkm_table *lkmtp, int cmd) { if (joyprobe (&dev)) { @@ -273,22 +273,24 @@ joy_load (struct lkm_table *lkmtp, int cmd) } } -int +static int joy_unload (struct lkm_table *lkmtp, int cmd) { uprintf ("Joystick driver unloaded\n"); return 0; } -int + +static int joy_stat (struct lkm_table *lkmtp, int cmd) { return 0; } + int joy_mod (struct lkm_table *lkmtp, int cmd, int ver) { -#define _module joy_module - DISPATCH(lkmtp, cmd, ver, joy_load, joy_unload, joy_stat); + MOD_DISPATCH(joy, lkmtp, cmd, ver, + joy_load, joy_unload, joy_stat); } #endif /* JOY_MODULE */ diff --git a/sys/kern/kern_lkm.c b/sys/kern/kern_lkm.c index f371c3713b1f..5d856aeaa4b7 100644 --- a/sys/kern/kern_lkm.c +++ b/sys/kern/kern_lkm.c @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: kern_lkm.c,v 1.38 1997/03/23 03:36:20 bde Exp $ + * $Id: kern_lkm.c,v 1.39 1997/03/24 11:24:35 bde Exp $ */ #include @@ -539,7 +539,7 @@ _lkm_syscall(lkmtp, cmd) /* don't load twice! */ if (lkmexists(lkmtp)) return(EEXIST); - if ((i = args->lkm_offset) == -1) { /* auto */ + if ((i = args->lkm_offset) == LKM_ANON) { /* auto */ /* * Search the table looking for a slot... */ @@ -707,7 +707,7 @@ _lkm_dev(lkmtp, cmd) return(EEXIST); switch(args->lkm_devtype) { case LM_DT_BLOCK: - if ((i = args->lkm_offset) == -1) + if ((i = args->lkm_offset) == LKM_ANON) descrip = (dev_t) -1; else descrip = makedev(args->lkm_offset,0); @@ -719,7 +719,7 @@ _lkm_dev(lkmtp, cmd) break; case LM_DT_CHAR: - if ((i = args->lkm_offset) == -1) + if ((i = args->lkm_offset) == LKM_ANON) descrip = (dev_t) -1; else descrip = makedev(args->lkm_offset,0); @@ -817,7 +817,7 @@ _lkm_exec(lkmtp, cmd) /* don't load twice! */ if (lkmexists(lkmtp)) return(EEXIST); - if ((i = args->lkm_offset) == -1) { /* auto */ + if ((i = args->lkm_offset) == LKM_ANON) { /* auto */ /* * Search the table looking for a slot... */ diff --git a/sys/modules/syscons/star/star_saver.c b/sys/modules/syscons/star/star_saver.c index 0ff3117cb339..465c493a3dcf 100644 --- a/sys/modules/syscons/star/star_saver.c +++ b/sys/modules/syscons/star/star_saver.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id$ + * $Id: star_saver.c,v 1.10 1997/02/22 12:49:22 peter Exp $ */ #include @@ -112,6 +112,6 @@ star_saver_unload(struct lkm_table *lkmtp, int cmd) int star_saver_mod(struct lkm_table *lkmtp, int cmd, int ver) { - DISPATCH(lkmtp, cmd, ver, star_saver_load, star_saver_unload, - lkm_nullcmd); + MOD_DISPATCH(star_saver, lkmtp, cmd, ver, + star_saver_load, star_saver_unload, lkm_nullcmd); } diff --git a/sys/netinet/ip_fw.c b/sys/netinet/ip_fw.c index 7352e3573b38..556710ee95ae 100644 --- a/sys/netinet/ip_fw.c +++ b/sys/netinet/ip_fw.c @@ -12,7 +12,7 @@ * * This software is provided ``AS IS'' without any warranties of any kind. * - * $Id$ + * $Id: ip_fw.c,v 1.55 1997/02/22 09:41:32 peter Exp $ */ /* @@ -823,6 +823,7 @@ ipfw_unload(struct lkm_table *lkmtp, int cmd) int ipfw_mod(struct lkm_table *lkmtp, int cmd, int ver) { - DISPATCH(lkmtp, cmd, ver, ipfw_load, ipfw_unload, lkm_nullcmd); + MOD_DISPATCH(ipfw, lkmtp, cmd, ver, + ipfw_load, ipfw_unload, lkm_nullcmd); } #endif diff --git a/sys/pccard/pcic.c b/sys/pccard/pcic.c index 74fcdcc247f1..27f934ba570c 100644 --- a/sys/pccard/pcic.c +++ b/sys/pccard/pcic.c @@ -213,7 +213,8 @@ pcic_handle(struct lkm_table *lkmtp, int cmd) int pcic_mod(struct lkm_table *lkmtp, int cmd, int ver) { - DISPATCH(lkmtp,cmd,ver,pcic_handle,pcic_handle,lkm_nullcmd); + MOD_DISPATCH(pcic, lkmtp, cmd, ver, + pcic_handle, pcic_handle, lkm_nullcmd); } /* diff --git a/sys/sys/kernel.h b/sys/sys/kernel.h index fa56797c2407..ded1c9f1d390 100644 --- a/sys/sys/kernel.h +++ b/sys/sys/kernel.h @@ -39,7 +39,7 @@ * SUCH DAMAGE. * * @(#)kernel.h 8.3 (Berkeley) 1/21/94 - * $Id: kernel.h,v 1.25 1997/02/22 09:45:25 peter Exp $ + * $Id: kernel.h,v 1.26 1997/03/22 08:03:45 bde Exp $ */ #ifndef _SYS_KERNEL_H_ @@ -249,7 +249,7 @@ void kproc_start __P((void *udata)); { return EINVAL; } \ int \ name ## _mod(struct lkm_table *lkmtp, int cmd, int ver) { \ - DISPATCH(lkmtp, cmd, ver, name ## _load, name ## _unload, \ + MOD_DISPATCH(name, lkmtp, cmd, ver, name ## _load, name ## _unload, \ lkm_nullcmd); } #else /* PSEUDO_LKM */ diff --git a/sys/sys/lkm.h b/sys/sys/lkm.h index de20dc5aa829..efd12083db69 100644 --- a/sys/sys/lkm.h +++ b/sys/sys/lkm.h @@ -34,7 +34,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id$ + * $Id: lkm.h,v 1.15 1997/02/22 09:45:30 peter Exp $ */ #ifndef _SYS_LKM_H_ @@ -67,7 +67,7 @@ typedef enum loadmod { struct lkm_syscall { MODTYPE lkm_type; int lkm_ver; - char *lkm_name; + const char *lkm_name; u_long lkm_offset; /* save/assign area */ struct sysent *lkm_sysent; struct sysent lkm_oldent; /* save area for unload */ @@ -79,7 +79,7 @@ struct lkm_syscall { struct lkm_vfs { MODTYPE lkm_type; int lkm_ver; - char *lkm_name; + const char *lkm_name; u_long lkm_offset; struct linker_set *lkm_vnodeops; struct vfsconf *lkm_vfsconf; @@ -99,7 +99,7 @@ typedef enum devtype { struct lkm_dev { MODTYPE lkm_type; int lkm_ver; - char *lkm_name; + const char *lkm_name; u_long lkm_offset; DEVTYPE lkm_devtype; union { @@ -119,7 +119,7 @@ struct lkm_dev { struct lkm_strmod { MODTYPE lkm_type; int lkm_ver; - char *lkm_name; + const char *lkm_name; u_long lkm_offset; /* * Removed: future release @@ -132,7 +132,7 @@ struct lkm_strmod { struct lkm_exec { MODTYPE lkm_type; int lkm_ver; - char *lkm_name; + const char *lkm_name; u_long lkm_offset; const struct execsw *lkm_exec; struct execsw lkm_oldexec; @@ -144,7 +144,7 @@ struct lkm_exec { struct lkm_misc { MODTYPE lkm_type; int lkm_ver; - char *lkm_name; + const char *lkm_name; u_long lkm_offset; }; @@ -154,7 +154,7 @@ struct lkm_misc { struct lkm_any { MODTYPE lkm_type; int lkm_ver; - char *lkm_name; + const char *lkm_name; u_long lkm_offset; }; @@ -208,25 +208,35 @@ struct lkm_table { #define LKM_E_UNLOAD 2 #define LKM_E_STAT 3 +/* Flag to indicate that LKM should select the slot, etc. Supported by: + * devslot in MOD_DEV + */ +#define LKM_ANON ((u_long)-1) + +/* XXX wcd.c pokes around in the lkm private structure, so until that + * is fixed here is a way to export the structure name. + */ +#define MOD_PRIVATE(name) name ## _mod_struct + #define MOD_DECL(name) \ static int name ## _load __P((struct lkm_table *lkmtp, int cmd)); \ static int name ## _unload __P((struct lkm_table *lkmtp, int cmd)); \ int name ## _mod __P((struct lkm_table *lkmtp, int cmd, int ver)) \ #define MOD_SYSCALL(name,callslot,sysentp) \ - static struct lkm_syscall _module = { \ + static struct lkm_syscall MOD_PRIVATE(name) = { \ LM_SYSCALL, \ LKM_VERSION, \ - name, \ + #name, \ callslot, \ sysentp \ } #define MOD_VFS(name,vnodeops,vfsconf) \ - static struct lkm_vfs _module = { \ + static struct lkm_vfs MOD_PRIVATE(name) = { \ LM_VFS, \ LKM_VERSION, \ - name, \ + #name, \ 0, \ vnodeops, \ vfsconf \ @@ -234,18 +244,18 @@ struct lkm_table { #define MOD_DEV(name,devtype,devslot,devp) \ MOD_DECL(name); \ - static struct lkm_dev name ## _module = { \ + static struct lkm_dev MOD_PRIVATE(name) = { \ LM_DEV, \ LKM_VERSION, \ #name ## "_mod", \ devslot, \ devtype, \ - (void *)devp \ + { (void *)devp } \ } #define MOD_EXEC(name,execslot,execsw) \ MOD_DECL(name); \ - static struct lkm_exec _module = { \ + static struct lkm_exec MOD_PRIVATE(name) = { \ LM_EXEC, \ LKM_VERSION, \ #name ## "_mod", \ @@ -255,28 +265,29 @@ struct lkm_table { #define MOD_MISC(name) \ MOD_DECL(name); \ - static struct lkm_misc _module = { \ + static struct lkm_misc MOD_PRIVATE(name) = { \ LM_MISC, \ LKM_VERSION, \ #name ## "_mod" \ } - /* - * DISPATCH -- body function for use in module entry point function; + * MOD_DISPATCH -- body function for use in module entry point function; * generally, the function body will consist entirely of a single - * DISPATCH line. + * MOD_DISPATCH line. * * Call load/unload/stat on each corresponding entry instance. "cmd" is * passed to each function so that a single function can be used if desired. + * */ -#define DISPATCH(lkmtp,cmd,ver,load,unload,stat) \ +#define MOD_DISPATCH(name,lkmtp,cmd,ver,load,unload,stat) \ if (ver != LKM_VERSION) \ return EINVAL; /* version mismatch */ \ switch (cmd) { \ int error; \ case LKM_E_LOAD: \ - lkmtp->private.lkm_any = (struct lkm_any *)&_module; \ + lkmtp->private.lkm_any = \ + (struct lkm_any *)& MOD_PRIVATE(name) ; \ if (lkmexists(lkmtp)) /* !!! */ \ return EEXIST; \ if ((error = load(lkmtp, cmd))) \ @@ -293,6 +304,12 @@ struct lkm_table { } \ return lkmdispatch(lkmtp, cmd); +/* Provide a backward compatible stub that will generate compile time errors. + * When fixing, prefer MOD_DISPATCH to be consistent with the others. + */ +#define DISPATCH(name,lkmtp,cmd,ver,load,unload,stat) \ + MOD_DISPATCH(name,lkmtp,cmd,ver,load,unload,stat) + int lkmdispatch __P((struct lkm_table *lkmtp, int cmd)); int lkmexists __P((struct lkm_table *lkmtp)); int lkm_nullcmd __P((struct lkm_table *lkmtp, int cmd)); @@ -325,7 +342,7 @@ int lkm_nullcmd __P((struct lkm_table *lkmtp, int cmd)); */ struct lmc_resrv { u_long size; /* IN: size of module to reserve */ - char *name; /* IN: name (must be provided */ + const char *name; /* IN: name (must be provided */ int slot; /* OUT: allocated slot (module ID) */ u_long addr; /* OUT: Link-to address */ }; @@ -355,7 +372,7 @@ struct lmc_load { */ struct lmc_unload { int id; /* IN: module ID to unload */ - char *name; /* IN: module name to unload if id -1 */ + const char *name; /* IN: module name to unload if id -1 */ int status; /* OUT: status of operation */ }; diff --git a/sys/sys/mount.h b/sys/sys/mount.h index bd13e2ec5ddb..4e3c9b37a3c7 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)mount.h 8.21 (Berkeley) 5/20/95 - * $Id: mount.h,v 1.40 1997/03/02 17:53:28 bde Exp $ + * $Id: mount.h,v 1.41 1997/03/03 11:55:47 bde Exp $ */ #ifndef _SYS_MOUNT_H_ @@ -355,10 +355,13 @@ struct vfsops { flags, \ }; \ extern struct linker_set MODVNOPS; \ - MOD_VFS(#fsname,&MODVNOPS,&_fs_vfsconf); \ + MOD_VFS(fsname,&MODVNOPS,&_fs_vfsconf); \ + extern int \ + fsname ## _mod __P((struct lkm_table *, int, int)); \ int \ fsname ## _mod(struct lkm_table *lkmtp, int cmd, int ver) { \ - DISPATCH(lkmtp, cmd, ver, lkm_nullcmd, lkm_nullcmd, lkm_nullcmd); } + MOD_DISPATCH(fsname, \ + lkmtp, cmd, ver, lkm_nullcmd, lkm_nullcmd, lkm_nullcmd); } #else #define VFS_SET(vfsops, fsname, index, flags) \