tail head cat sleep
QR code linking to this page

manページ  — DEV_MODULE

名称

DEV_MODULE – デバイスドライバモジュール宣言マクロ

内容

書式

#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/conf.h>

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

解説

DEV_MODULE() マクロはデバイスドライバカーネルモジュールを宣言します。 これは moduledata_t 構造体を埋めて、それから DECLARE_MODULE() を正しい引数で呼び出します。ここで、 name はモジュール名で、 (, arg を引数として持つ) evh はそのモジュールのためのイベントハンドラです (詳細については DECLARE_MODULE(9) を参照)。 イベントハンドラはロード時に make_dev() でデバイスを作成し、アンロードされる時に destroy_dev() でそのデバイスを破壊することを、期待されています。

使用例

#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);

関連項目

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

作者

このマニュアルページは Alexander Langer <alex@FreeBSD.org> が書きました。

DEV_MODULE (9) March 11, 2001

tail head cat sleep
QR code linking to this page


このマニュアルページサービスについてのご意見は Ben Bullock にお知らせください。 Privacy policy.

Our grievance is not just against Unix itself, but against the cult of Unix zealots who defend and nurture it. They take the heat, disease, and pestilence as givens, and, as ancient shamans did, display their wounds, some self-inflicted, as proof of their power and wizardry. We aim, through bluntness and humor, to show them that they pray to a tin god, and that science, not religion, is the path to useful and friendly technology.
— The Unix Haters' handbook