DEV_MODULE man page on DragonFly

Printed from http://www.polarhome.com/service/man/?qf=DEV_MODULE&af=0&tf=2&of=DragonFly

DEV_MODULE(9)		 BSD Kernel Developer's Manual		 DEV_MODULE(9)

NAME
     DEV_MODULE — device driver module declaration macro

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

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

DESCRIPTION
     The DEV_MODULE() macro declares a device driver kernel module.  It fills
     in a moduledata_t structure and then calls DECLARE_MODULE() with the cor‐
     rect args, where name is the name of the module and evh (with its argu‐
     ment 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
     #include <sys/module.h>
     #include <sys/conf.h>

     static struct dev_ops foo_ops = { ... };

     static cdev_t sdev;

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

	 dev_ops_add(&foo_ops, ...);

	 switch (cmd) {
	 case MOD_LOAD:
	     sdev = make_dev(&foo_ops, 0, UID_ROOT, GID_WHEEL, 0600, "foo");

	     /* We must obtain a reference to sdev, so we can destroy it later */
	     reference_dev(sdev);
	     break;	     /* Success*/

	 case MOD_UNLOAD:
	 case MOD_SHUTDOWN:
	     destroy_dev(sdev);

	     /* The same mask and match must be specified, as in dev_ops_add() */
	     dev_ops_remove(&foo_ops, ...);
	     break;	     /* Success*/

	 default:
	     err = EINVAL;
	     break;
	 }

	 return(err);
     }

     DEV_MODULE(foo, foo_load, NULL);

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

AUTHORS
     This manual page was written by Alexander Langer ⟨alex@FreeBSD.org⟩.

BSD			       February 10, 2009			   BSD
[top]

List of man pages available for DragonFly

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net