DEV_MODULE (9)
Leading comments
Copyright (c) 2001 Alexander Langer
All rights reserved.
This program is free software.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaim...
(The comments found at the beginning of the groff file "man9/DEV_MODULE.9freebsd".)
NAME
DEV_MODULE
- device driver module declaration macro
SYNOPSIS
In sys/param.h
In sys/kernel.h
In sys/module.h
In sys/conf.h
Fn DEV_MODULE name modeventhand_t evh void *arg
DESCRIPTION
The
Fn DEV_MODULE
macro declares a device driver kernel module.
It fills in a
Vt moduledata_t
structure and then calls
Fn DECLARE_MODULE
with the correct args, where
Fa name
is the name of the module and
Fa evh
(with its argument
Fa arg )
is the event handler for the module (refer to
DECLARE_MODULE9
for more information).
The event handler is supposed to create the device with
Fn make_dev
on load and to destroy it when it is unloaded using
Fn destroy_dev .
EXAMPLES
#include <sys/module.h>
#include <sys/conf.h>
static struct cdevsw foo_devsw = { ... };
static struct cdev *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
DECLARE_MODULE9,
destroy_dev9,
make_dev9,
module(9)
AUTHORS
This manual page was written by
An Alexander Langer Aq alex@FreeBSD.org .