Next round of fixing all kinds of spelling mistakes.
[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.7 2007/03/22 22:58:22 swildner Exp $
28 .\"
29 .Dd May 21, 2006
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 .Dx
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 Linux
60 emulator.
61 .Nm
62 modules are placed by default in the
63 .Pa /modules
64 directory.
65 .Pp
66 The
67 .Nm
68 interface is used through the
69 .Xr kldload 8 ,
70 .Xr kldunload 8
71 and
72 .Xr kldstat 8
73 programs.
74 .Pp
75 The
76 .Xr kldload 8
77 program can load either
78 .Xr a.out 5
79 or ELF formatted loadable modules.
80 The
81 .Xr kldunload 8
82 program unloads any given loaded module, if no other module is dependent
83 upon the given module.
84 The
85 .Xr kldstat 8
86 program is used to check the status of the modules currently loaded into the
87 system.
88 .Sh "MODULE TYPES"
89 .Bl -ohang
90 .It Em "Device Driver modules"
91 New block and character device
92 drivers may be loaded into the system with
93 .Nm .
94 The major problem with loading
95 a device driver is that the driver's
96 device nodes must exist for the
97 devices to be accessed.  They are usually
98 created by using
99 .Xr MAKEDEV 8
100 or
101 .Xr mknod 8
102 (if the device is not supported by the
103 .Xr MAKEDEV 8
104 script) or, by writing a
105 shell script to run
106 .Xr kldload 8
107 which should run the appropriate program to create the devices when the
108 driver has been successfully loaded.
109 .El
110 .Sh FILES
111 .Bl -tag -width ".In sys/module.h" -compact
112 .It Pa /modules
113 directory containing module binaries shipped with the system
114 .It In sys/module.h
115 file containing definitions required to compile a
116 .Nm
117 module
118 .It Pa /usr/share/examples/kld
119 example source code implementing a sample kld module
120 .El
121 .Sh SEE ALSO
122 .Xr kldfind 2 ,
123 .Xr kldfirstmod 2 ,
124 .Xr kldload 2 ,
125 .Xr kldnext 2 ,
126 .Xr kldstat 2 ,
127 .Xr kldunload 2 ,
128 .Xr kldload 8 ,
129 .Xr kldstat 8 ,
130 .Xr kldunload 8
131 .Sh HISTORY
132 The
133 .Nm
134 facility appeared in
135 .Fx 3.0
136 and was designed as a replacement for the
137 .Xr lkm 4
138 facility, which was similar in functionality to the loadable kernel modules
139 facility provided by
140 .Tn SunOS
141 4.1.3.
142 .Sh AUTHORS
143 The
144 .Nm
145 facility was originally implemented by
146 .An Doug Rabson Aq dfr@FreeBSD.org .
147 .Sh BUGS
148 If a module B, is dependent on another module A, but is not compiled with
149 module A as a dependency, then
150 .Xr kldload 8
151 fails to load module B, even if module A is already present in the system.
152 .Pp
153 If multiple modules are dependent on module A, and are compiled with module
154 A as a dependency, then
155 .Xr kldload 8
156 loads an instance of module A when any of the modules are loaded.
157 .Pp
158 If a custom entry point is used for a module, and the module is compiled as
159 an
160 .Sq ELF
161 binary, then
162 .Xr kldload 8
163 fails to execute the entry point.
164 .Pp
165 .Xr kldload 8
166 returns the cryptic message
167 .Sq Li "Exec format error"
168 for any error encountered while loading a module.
169 .Pp
170 When system internal interfaces change, old modules often cannot
171 detect this, and such modules when loaded will often cause crashes or
172 mysterious failures.