aboutsummaryrefslogtreecommitdiff
path: root/documentation/manual-pages/ja/man9/driver.9
diff options
context:
space:
mode:
Diffstat (limited to 'documentation/manual-pages/ja/man9/driver.9')
-rw-r--r--documentation/manual-pages/ja/man9/driver.9114
1 files changed, 114 insertions, 0 deletions
diff --git a/documentation/manual-pages/ja/man9/driver.9 b/documentation/manual-pages/ja/man9/driver.9
new file mode 100644
index 0000000000..696dcffc24
--- /dev/null
+++ b/documentation/manual-pages/ja/man9/driver.9
@@ -0,0 +1,114 @@
+.\" -*- nroff -*-
+.\"
+.\" Copyright (c) 1998 Doug Rabson
+.\"
+.\" 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/driver.9,v 1.10 2003/10/23 01:54:06 hmp Exp %
+.\"
+.\" $FreeBSD$
+.Dd June 16, 1998
+.Dt DRIVER 9
+.Os
+.Sh 名称
+.Nm driver
+.Nd デバイスドライバを記述する構造体
+.Sh 書式
+.Bd -literal
+#include <sys/param.h>
+#include <sys/bus.h>
+
+static int foo_probe(device_t);
+static int foo_attach(device_t);
+static int foo_detach(device_t);
+static int foo_frob(device_t, int, int);
+static int foo_twiddle(device_t, char *);
+
+static struct device_method_t foo_methods[] = {
+ /* デバイスインタフェースからのメソッド */
+ DEVMETHOD(device_probe, foo_probe),
+ DEVMETHOD(device_attach, foo_attach),
+ DEVMETHOD(device_detach, foo_detach),
+
+ /* bogo インタフェースからのメソッド */
+ DEVMETHOD(bogo_frob, foo_frob),
+ DEVMETHOD(bogo_twiddle, foo_twiddle),
+
+ /* メソッドリストの終端 */
+ { 0, 0 }
+};
+
+static driver_t foo_driver {
+ "foo",
+ foo_methods,
+ sizeof(struct foo_softc)
+};
+
+static devclass_t foo_devclass;
+
+DRIVER_MODULE(foo, bogo, foo_driver, foo_devclass, 0, 0);
+.Ed
+.Sh 解説
+カーネルの中の個々のドライバは
+.Dv driver_t
+構造体によって記述されます。
+この構造体はデバイスの名称、メソッドのリストへのポインタ、
+ドライバが実装したデバイスの種類の表示、
+およびドライバがデバイスインスタンスに関連付けるために必要な私的データの大きさ
+を含んでいます。
+各々のドライバは 1 つ以上の (インタフェースと呼ばれる) メソッドの組を
+実装します。
+上記の例のドライバは標準の "driver" インタフェースと
+仮想的な "bogo" インタフェースを実装しています。
+.Pp
+ドライバが (
+.Dv DRIVER_MODULE
+マクロによって、
+.Xr DRIVER_MODULE 9
+を参照) システムに登録される時に、
+その親のバスタイプの devclass の中に含まれている
+ドライバのリストに追加されます。
+例えば、全ての PCI ドライバは "pci" と名付けられた devclass に含まれ、
+全ての ISA ドライバは "isa" と名付けられた devclass に含まれます。
+ドライバが親のバスのデバイスオブジェクトの中に保持されない理由は、
+与えられたバスのタイプの複数のインスタンスを取り扱うためです。
+.Dv DRIVER_MODULE
+マクロはそのドライバの名前の devclass も生成します。
+最後の 2 つの引数として追加のモジュールイベントハンドラとその引数を
+与えることによって、
+オプションでドライバの追加の初期化コードを呼び出すことができます。
+.Sh 関連項目
+.Xr devclass 9 ,
+.Xr device 9 ,
+.Xr DEVICE_ATTACH 9 ,
+.Xr DEVICE_DETACH 9 ,
+.Xr DEVICE_IDENTIFY 9 ,
+.Xr DEVICE_PROBE 9 ,
+.Xr DEVICE_SHUTDOWN 9 ,
+.Xr DRIVER_MODULE 9
+.Sh 作者
+このマニュアルページは
+.An Doug Rabson
+が書きました。