67ee619bfa
Submitted by: Akira Ikeuchi <a_ikeuchi@mic.mitsumi.co.jp>
107 lines
2.9 KiB
Groff
107 lines
2.9 KiB
Groff
.\" -*- nroff -*-
|
|
.\"
|
|
.\" 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 disclaimer in the
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
.\"
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
|
|
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
.\"
|
|
.\" %FreeBSD: src/share/man/man9/DEV_MODULE.9,v 1.4 2001/12/26 23:14:04 davidc Exp %
|
|
.\"
|
|
.\" $FreeBSD$
|
|
.Dd March 11, 2001
|
|
.Dt DEV_MODULE 9
|
|
.Os
|
|
.Sh 名称
|
|
.Nm DEV_MODULE
|
|
.Nd デバイスドライバモジュール宣言マクロ
|
|
.Sh 書式
|
|
.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"
|
|
.Sh 解説
|
|
.Fn DEV_MODULE
|
|
マクロはデバイスドライバカーネルモジュールを宣言します。
|
|
これは
|
|
.Vt moduledata_t
|
|
構造体を埋めて、それから
|
|
.Fn DECLARE_MODULE
|
|
を正しい引数で呼び出します。ここで、
|
|
.Fa name
|
|
はモジュール名で、
|
|
.Fa ( arg
|
|
を引数として持つ)
|
|
.Fa evh
|
|
はそのモジュールのためのイベントハンドラです (詳細については
|
|
.Xr DECLARE_MODULE 9
|
|
を参照)。
|
|
イベントハンドラはロード時に
|
|
.Fn make_dev
|
|
でデバイスを作成し、アンロードされる時に
|
|
.Fn destroy_dev
|
|
でそのデバイスを破壊することを、期待されています。
|
|
.Sh 使用例
|
|
.Bd -literal
|
|
#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; /* 成功 */
|
|
|
|
case MOD_UNLOAD:
|
|
case MOD_SHUTDOWN:
|
|
destroy_dev(sdev);
|
|
break; /* 成功 */
|
|
|
|
default:
|
|
err = EINVAL;
|
|
break;
|
|
}
|
|
|
|
return(err);
|
|
}
|
|
|
|
DEV_MODULE(foo, foo_load, NULL);
|
|
.Ed
|
|
.Sh 関連項目
|
|
.Xr DECLARE_MODULE 9 ,
|
|
.Xr destroy_dev 9 ,
|
|
.Xr make_dev 9 ,
|
|
.Xr module 9
|
|
.Sh 作者
|
|
このマニュアルページは
|
|
.An Alexander Langer Aq alex@FreeBSD.org
|
|
が書きました。
|