module.9 (3d45e180f437865262fc7c39fc3239641f305737) module.9 (65a311fcb2f44fce7eb05160d3198cefed5c27f9)
1.\" -*- nroff -*-
2.\"
3.\" Copyright (c) 2000 Alexander Langer
4.\"
5.\" All rights reserved.
6.\"
7.\" This program is free software.
8.\"

--- 33 unchanged lines hidden (view full) ---

42a pointer to an event handler function and to an argument,
43which is given to the event handler,
44as well as some kernel internal data.
45.Pp
46The
47.Xr DECLARE_MODULE 9
48macro
49registers the module with the system.
1.\" -*- nroff -*-
2.\"
3.\" Copyright (c) 2000 Alexander Langer
4.\"
5.\" All rights reserved.
6.\"
7.\" This program is free software.
8.\"

--- 33 unchanged lines hidden (view full) ---

42a pointer to an event handler function and to an argument,
43which is given to the event handler,
44as well as some kernel internal data.
45.Pp
46The
47.Xr DECLARE_MODULE 9
48macro
49registers the module with the system.
50.Pp
50When the module is loaded, the event handler function is called with
51the
52.Fa what
53argument set to
54.Dv MOD_LOAD .
51When the module is loaded, the event handler function is called with
52the
53.Fa what
54argument set to
55.Dv MOD_LOAD .
55On unload,
56.Pp
57On unload it is first called with
56.Fa what
58.Fa what
59set to MOD_QUIESCE .
60If the unload was not forced, a non-zero return will prevent the
61unload from happening.
62.Pp
63If the unload continues
64.Fa what
57is set to
58.Dv MOD_UNLOAD .
65is set to
66.Dv MOD_UNLOAD .
67If the module returns non-zero to this, the unload will not happen.
68.Pp
69The difference between MOD_QUIESCE and MOD_UNLOAD is that the module
70should fail MOD_QUIESCE if it is currently in use, whereas MOD_UNLOAD
71should only fail if it is impossible to unload the module, for instance
72because there are memory references to the module which cannot be revoked.
73.Pp
59When the system is shutting down,
60.Fa what
61contains the value of
62.Dv MOD_SHUTDOWN .
74When the system is shutting down,
75.Fa what
76contains the value of
77.Dv MOD_SHUTDOWN .
78.Pp
79The module should return EOPNOTSUPP for unrecognized values of
80.Fa what .
63.Sh EXAMPLES
64.Bd -literal
65#include <sys/param.h>
66#include <sys/kernel.h>
67#include <sys/module.h>
68
69static int foo_handler(module_t mod, int /*modeventtype_t*/ what,
70 void *arg);

--- 24 unchanged lines hidden ---
81.Sh EXAMPLES
82.Bd -literal
83#include <sys/param.h>
84#include <sys/kernel.h>
85#include <sys/module.h>
86
87static int foo_handler(module_t mod, int /*modeventtype_t*/ what,
88 void *arg);

--- 24 unchanged lines hidden ---