Initial import from FreeBSD RELENG_4:
[dragonfly.git] / share / man / man4 / kld.4
1 .\" Copyright (c) 1993 Christopher G. Demetriou
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. The name of the author may not be used to endorse or promote products
13 .\"    derived from this software without specific prior written permission
14 .\"
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 .\"
26 .\" $FreeBSD: src/share/man/man4/kld.4,v 1.5.2.6 2001/08/17 13:08:38 ru Exp $
27 .\"
28 .Dd November 8, 1998
29 .Dt KLD 4
30 .Os
31 .Sh NAME
32 .Nm kld
33 .Nd dynamic kernel linker facility
34 .Sh DESCRIPTION
35 The LKM (Loadable Kernel Modules) facility has been deprecated in
36 .Fx 3.0
37 and above in favor of the
38 .Nm
39 interface.
40 This interface, like its
41 predecessor, allows the system administrator to dynamically add and remove
42 functionality from a running system.  This ability also helps software
43 developers to develop new parts of the kernel without constantly rebooting
44 to test their changes.
45 .Pp
46 Various types of modules can be loaded into the system.
47 There are several defined module types, listed below, which can
48 be added to the system in a predefined way.  In addition, there
49 is a generic type, for which the module itself handles loading and
50 unloading.
51 .Pp
52 The
53 .Fx
54 system makes extensive use of loadable kernel modules, and provides loadable
55 versions of most filesystems, the
56 .Tn NFS
57 client and server, all the screen-savers, and the
58 .Tn iBCS2
59 and
60 .Tn Linux
61 emulators.
62 .Nm
63 modules are placed by default in the
64 .Pa /modules
65 directory.
66 .Pp
67 The
68 .Nm
69 interface is used through the
70 .Xr kldload 8 ,
71 .Xr kldunload 8
72 and
73 .Xr kldstat 8
74 programs.
75 .Pp
76 The
77 .Xr kldload 8
78 program can load either
79 .Xr a.out 5
80 or ELF formatted loadable modules.
81 The
82 .Xr kldunload 8
83 program unloads any given loaded module, if no other module is dependent
84 upon the given module.
85 The
86 .Xr kldstat 8
87 program is used to check the status of the modules currently loaded into the
88 system.
89 .Sh "MODULE TYPES"
90 .Bl -ohang
91 .It Em "Device Driver modules"
92 New block and character device
93 drivers may be loaded into the system with
94 .Nm .
95 The major problem with loading
96 a device driver is that the driver's
97 device nodes must exist for the
98 devices to be accessed.  They are usually
99 created by using
100 .Xr MAKEDEV 8
101 or
102 .Xr mknod 8
103 (if the device is not supported by the
104 .Xr MAKEDEV 8
105 script) or, by writing a
106 shell script to run
107 .Xr kldload 8
108 which should run the appropriate program to create the devices when the
109 driver has been successfully loaded.
110 .El
111 .Sh FILES
112 .Bl -tag -width /usr/include/sys/module.h -compact
113 .It Pa /modules
114 directory containing module binaries shipped with the system
115 .It Pa /usr/include/sys/module.h
116 file containing definitions required to compile a
117 .Nm
118 module
119 .It Pa /usr/share/examples/kld
120 example source code implementing a sample kld module
121 .El
122 .Sh SEE ALSO
123 .Xr kldfind 2 ,
124 .Xr kldfirstmod 2 ,
125 .Xr kldload 2 ,
126 .Xr kldnext 2 ,
127 .Xr kldstat 2 ,
128 .Xr kldunload 2 ,
129 .Xr kldload 8 ,
130 .Xr kldstat 8 ,
131 .Xr kldunload 8
132 .Sh BUGS
133 If a module B, is dependent on another module A, but is not compiled with
134 module A as a dependency, then
135 .Xr kldload 8
136 fails to load module B, even if module A is already present in the system.
137 .Pp
138 If multiple modules are dependent on module A, and are compiled with module
139 A as a dependency, then
140 .Xr kldload 8
141 loads an instance of module A when any of the modules are loaded.
142 .Pp
143 If a custom entry point is used for a module, and the module is compiled as
144 an
145 .Sq ELF
146 binary, then
147 .Xr kldload 8
148 fails to execute the entry point.
149 .Pp
150 .Xr kldload 8
151 returns the cryptic message
152 .Sq Li "ENOEXEC (Exec format error)"
153 for any error encountered while loading a module.
154 .Pp
155 When system internal interfaces change, old modules often cannot
156 detect this, and such modules when loaded will often cause crashes or
157 mysterious failures.
158 .Sh AUTHORS
159 The
160 .Nm
161 facility was originally implemented by
162 .An Doug Rabson Aq dfr@FreeBSD.org .
163 .Sh HISTORY
164 The
165 .Nm
166 facility appeared in
167 .Fx 3.0
168 and was designed as a replacement for the
169 .Xr lkm 4
170 facility, which was similar in functionality to the loadable kernel modules
171 facility provided by
172 .Tn SunOS
173 4.1.3.