Bring the BFE(4) manual page up-to-date with 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 .\" $DragonFly: src/share/man/man4/kld.4,v 1.2 2003/06/17 04:36:59 dillon Exp $
28 .\"
29 .Dd November 8, 1998
30 .Dt KLD 4
31 .Os
32 .Sh NAME
33 .Nm kld
34 .Nd dynamic kernel linker facility
35 .Sh DESCRIPTION
36 The LKM (Loadable Kernel Modules) facility has been deprecated in
37 .Fx 3.0
38 and above in favor of the
39 .Nm
40 interface.
41 This interface, like its
42 predecessor, allows the system administrator to dynamically add and remove
43 functionality from a running system.  This ability also helps software
44 developers to develop new parts of the kernel without constantly rebooting
45 to test their changes.
46 .Pp
47 Various types of modules can be loaded into the system.
48 There are several defined module types, listed below, which can
49 be added to the system in a predefined way.  In addition, there
50 is a generic type, for which the module itself handles loading and
51 unloading.
52 .Pp
53 The
54 .Fx
55 system makes extensive use of loadable kernel modules, and provides loadable
56 versions of most filesystems, the
57 .Tn NFS
58 client and server, all the screen-savers, and the
59 .Tn iBCS2
60 and
61 .Tn Linux
62 emulators.
63 .Nm
64 modules are placed by default in the
65 .Pa /modules
66 directory.
67 .Pp
68 The
69 .Nm
70 interface is used through the
71 .Xr kldload 8 ,
72 .Xr kldunload 8
73 and
74 .Xr kldstat 8
75 programs.
76 .Pp
77 The
78 .Xr kldload 8
79 program can load either
80 .Xr a.out 5
81 or ELF formatted loadable modules.
82 The
83 .Xr kldunload 8
84 program unloads any given loaded module, if no other module is dependent
85 upon the given module.
86 The
87 .Xr kldstat 8
88 program is used to check the status of the modules currently loaded into the
89 system.
90 .Sh "MODULE TYPES"
91 .Bl -ohang
92 .It Em "Device Driver modules"
93 New block and character device
94 drivers may be loaded into the system with
95 .Nm .
96 The major problem with loading
97 a device driver is that the driver's
98 device nodes must exist for the
99 devices to be accessed.  They are usually
100 created by using
101 .Xr MAKEDEV 8
102 or
103 .Xr mknod 8
104 (if the device is not supported by the
105 .Xr MAKEDEV 8
106 script) or, by writing a
107 shell script to run
108 .Xr kldload 8
109 which should run the appropriate program to create the devices when the
110 driver has been successfully loaded.
111 .El
112 .Sh FILES
113 .Bl -tag -width /usr/include/sys/module.h -compact
114 .It Pa /modules
115 directory containing module binaries shipped with the system
116 .It Pa /usr/include/sys/module.h
117 file containing definitions required to compile a
118 .Nm
119 module
120 .It Pa /usr/share/examples/kld
121 example source code implementing a sample kld module
122 .El
123 .Sh SEE ALSO
124 .Xr kldfind 2 ,
125 .Xr kldfirstmod 2 ,
126 .Xr kldload 2 ,
127 .Xr kldnext 2 ,
128 .Xr kldstat 2 ,
129 .Xr kldunload 2 ,
130 .Xr kldload 8 ,
131 .Xr kldstat 8 ,
132 .Xr kldunload 8
133 .Sh BUGS
134 If a module B, is dependent on another module A, but is not compiled with
135 module A as a dependency, then
136 .Xr kldload 8
137 fails to load module B, even if module A is already present in the system.
138 .Pp
139 If multiple modules are dependent on module A, and are compiled with module
140 A as a dependency, then
141 .Xr kldload 8
142 loads an instance of module A when any of the modules are loaded.
143 .Pp
144 If a custom entry point is used for a module, and the module is compiled as
145 an
146 .Sq ELF
147 binary, then
148 .Xr kldload 8
149 fails to execute the entry point.
150 .Pp
151 .Xr kldload 8
152 returns the cryptic message
153 .Sq Li "ENOEXEC (Exec format error)"
154 for any error encountered while loading a module.
155 .Pp
156 When system internal interfaces change, old modules often cannot
157 detect this, and such modules when loaded will often cause crashes or
158 mysterious failures.
159 .Sh AUTHORS
160 The
161 .Nm
162 facility was originally implemented by
163 .An Doug Rabson Aq dfr@FreeBSD.org .
164 .Sh HISTORY
165 The
166 .Nm
167 facility appeared in
168 .Fx 3.0
169 and was designed as a replacement for the
170 .Xr lkm 4
171 facility, which was similar in functionality to the loadable kernel modules
172 facility provided by
173 .Tn SunOS
174 4.1.3.