*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->FreeBSD man pages -> DEV_MODULE (9)              
Title
Content
Arch
Section
 

DEV_MODULE(9)

Contents


NAME    [Toc]    [Back]

     DEV_MODULE -- device driver module declaration macro

SYNOPSIS    [Toc]    [Back]

     #include <sys/param.h>
     #include <sys/kernel.h>
     #include <sys/module.h>
     #include <sys/conf.h>

     DEV_MODULE(name, modeventhand_t evh, void *arg);

DESCRIPTION    [Toc]    [Back]

     The DEV_MODULE() macro declares a device driver kernel module.  It fills
     in a moduledata_t structure and then calls DECLARE_MODULE() with the correct
 args, where name is the name of the module and evh (with its argument
 arg) is the event handler for the module (refer to DECLARE_MODULE(9)
     for more information).  The event handler is supposed to create the
     device with make_dev() on load and to destroy it when it is unloaded
     using destroy_dev().

EXAMPLES    [Toc]    [Back]

     #include <sys/module.h>
     #include <sys/conf.h>

     static struct cdevsw foo_devsw = { ... };

     static dev_t sdev;

     static int
     foo_load(module_t mod, int cmd, void *arg)
     {
	 int err = 0;

	 switch (cmd) {
	 case MOD_LOAD:
	     sdev = make_dev(&foo_devsw, 0, UID_ROOT, GID_WHEEL, 0600, "foo");
	     break;	     /* Success*/

	 case MOD_UNLOAD:
	 case MOD_SHUTDOWN:
	     destroy_dev(sdev);
	     break;	     /* Success*/

	 default:
	     err = EINVAL;
	     break;
	 }

	 return(err);
     }

     DEV_MODULE(foo, foo_load, NULL);

SEE ALSO    [Toc]    [Back]

      
      
     DECLARE_MODULE(9), destroy_dev(9), make_dev(9), module(9)

AUTHORS    [Toc]    [Back]

     This manual page was written by Alexander Langer <[email protected]>.


FreeBSD 5.2.1			March 11, 2001			 FreeBSD 5.2.1
[ Back ]
 Similar pages
Name OS Title
DECLARE_MODULE FreeBSD kernel module declaration macro
SYSCALL_MODULE FreeBSD syscall kernel module declaration macro
MULTI_DRIVER_MODULE FreeBSD kernel driver declaration macro
DRIVER_MODULE FreeBSD kernel driver declaration macro
el FreeBSD Ethernet driver for 3Com Etherlink 3C501 device driver
hilid OpenBSD HIL ID module driver
utopia FreeBSD Driver module for ATM PHY chips
utopia FreeBSD Driver module for ATM PHY chips
streamadm Tru64 Defines configuration information about a STREAMS module or driver
event_class HP-UX The file that contains the declaration of an event class.
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service