174169a2cSAlexander Langer.\" -*- nroff -*- 274169a2cSAlexander Langer.\" 374169a2cSAlexander Langer.\" Copyright (c) 2001 Alexander Langer 474169a2cSAlexander Langer.\" 574169a2cSAlexander Langer.\" All rights reserved. 674169a2cSAlexander Langer.\" 774169a2cSAlexander Langer.\" This program is free software. 874169a2cSAlexander Langer.\" 974169a2cSAlexander Langer.\" Redistribution and use in source and binary forms, with or without 1074169a2cSAlexander Langer.\" modification, are permitted provided that the following conditions 1174169a2cSAlexander Langer.\" are met: 1274169a2cSAlexander Langer.\" 1. Redistributions of source code must retain the above copyright 1374169a2cSAlexander Langer.\" notice, this list of conditions and the following disclaimer. 1474169a2cSAlexander Langer.\" 2. Redistributions in binary form must reproduce the above copyright 1574169a2cSAlexander Langer.\" notice, this list of conditions and the following disclaimer in the 1674169a2cSAlexander Langer.\" documentation and/or other materials provided with the distribution. 1774169a2cSAlexander Langer.\" 1874169a2cSAlexander Langer.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR 1974169a2cSAlexander Langer.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 2074169a2cSAlexander Langer.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 2174169a2cSAlexander Langer.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, 2274169a2cSAlexander Langer.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2374169a2cSAlexander Langer.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2474169a2cSAlexander Langer.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2574169a2cSAlexander Langer.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2674169a2cSAlexander Langer.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2774169a2cSAlexander Langer.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2874169a2cSAlexander Langer.\" 295dc6c3a3SEd Schouten.Dd January 19, 2012 3074169a2cSAlexander Langer.Dt DEV_MODULE 9 3174169a2cSAlexander Langer.Os 3274169a2cSAlexander Langer.Sh NAME 3374169a2cSAlexander Langer.Nm DEV_MODULE 3474169a2cSAlexander Langer.Nd device driver module declaration macro 3574169a2cSAlexander Langer.Sh SYNOPSIS 36f16b3c0dSChad David.In sys/param.h 37f16b3c0dSChad David.In sys/kernel.h 3832eef9aeSRuslan Ermilov.In sys/module.h 3932eef9aeSRuslan Ermilov.In sys/conf.h 4074169a2cSAlexander Langer.Fn DEV_MODULE "name" "modeventhand_t evh" "void *arg" 4174169a2cSAlexander Langer.Sh DESCRIPTION 4274169a2cSAlexander LangerThe 4374169a2cSAlexander Langer.Fn DEV_MODULE 4474169a2cSAlexander Langermacro declares a device driver kernel module. 4574169a2cSAlexander LangerIt fills in a 4674169a2cSAlexander Langer.Vt moduledata_t 4774169a2cSAlexander Langerstructure and then calls 4874169a2cSAlexander Langer.Fn DECLARE_MODULE 4974169a2cSAlexander Langerwith the correct args, where 5074169a2cSAlexander Langer.Fa name 5174169a2cSAlexander Langeris the name of the module and 5274169a2cSAlexander Langer.Fa evh 5374169a2cSAlexander Langer(with its argument 5474169a2cSAlexander Langer.Fa arg ) 5574169a2cSAlexander Langeris the event handler for the module (refer to 5674169a2cSAlexander Langer.Xr DECLARE_MODULE 9 5774169a2cSAlexander Langerfor more information). 5874169a2cSAlexander LangerThe event handler is supposed to create the device with 5974169a2cSAlexander Langer.Fn make_dev 6074169a2cSAlexander Langeron load and to destroy it when it is unloaded using 6174169a2cSAlexander Langer.Fn destroy_dev . 6274169a2cSAlexander Langer.Sh EXAMPLES 6374169a2cSAlexander Langer.Bd -literal 6474169a2cSAlexander Langer#include <sys/module.h> 6574169a2cSAlexander Langer#include <sys/conf.h> 6674169a2cSAlexander Langer 6774169a2cSAlexander Langerstatic struct cdevsw foo_devsw = { ... }; 6874169a2cSAlexander Langer 695dc6c3a3SEd Schoutenstatic struct cdev *sdev; 7074169a2cSAlexander Langer 7174169a2cSAlexander Langerstatic int 7274169a2cSAlexander Langerfoo_load(module_t mod, int cmd, void *arg) 7374169a2cSAlexander Langer{ 7474169a2cSAlexander Langer int err = 0; 7574169a2cSAlexander Langer 7674169a2cSAlexander Langer switch (cmd) { 7774169a2cSAlexander Langer case MOD_LOAD: 7874169a2cSAlexander Langer sdev = make_dev(&foo_devsw, 0, UID_ROOT, GID_WHEEL, 0600, "foo"); 7974169a2cSAlexander Langer break; /* Success*/ 8074169a2cSAlexander Langer 8174169a2cSAlexander Langer case MOD_UNLOAD: 8274169a2cSAlexander Langer case MOD_SHUTDOWN: 8374169a2cSAlexander Langer destroy_dev(sdev); 8474169a2cSAlexander Langer break; /* Success*/ 8574169a2cSAlexander Langer 8674169a2cSAlexander Langer default: 8774169a2cSAlexander Langer err = EINVAL; 8874169a2cSAlexander Langer break; 8974169a2cSAlexander Langer } 9074169a2cSAlexander Langer 9174169a2cSAlexander Langer return(err); 9274169a2cSAlexander Langer} 9374169a2cSAlexander Langer 9474169a2cSAlexander LangerDEV_MODULE(foo, foo_load, NULL); 9574169a2cSAlexander Langer.Ed 9674169a2cSAlexander Langer.Sh SEE ALSO 9774169a2cSAlexander Langer.Xr DECLARE_MODULE 9 , 985521ff5aSRuslan Ermilov.Xr destroy_dev 9 , 9974169a2cSAlexander Langer.Xr make_dev 9 , 1005521ff5aSRuslan Ermilov.Xr module 9 10174169a2cSAlexander Langer.Sh AUTHORS 10274169a2cSAlexander LangerThis manual page was written by 103*8a7314fcSBaptiste Daroussin.An Alexander Langer Aq Mt alex@FreeBSD.org . 104