]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - share/man/man4/kld.4
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.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$
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.
43 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.
50 In addition, there
51 is a generic type, for which the module itself handles loading and
52 unloading.
53 .Pp
54 The
55 .Fx
56 system makes extensive use of loadable kernel modules, and provides loadable
57 versions of most file systems, the
58 .Tn NFS
59 client and server, all the screen-savers, and the
60 .Tn iBCS2
61 and
62 .Tn Linux
63 emulators.
64 .Nm
65 modules are placed by default in the
66 .Pa /boot/kernel
67 directory along with their matching kernel.
68 .Pp
69 The
70 .Nm
71 interface is used through the
72 .Xr kldload 8 ,
73 .Xr kldunload 8
74 and
75 .Xr kldstat 8
76 programs.
77 .Pp
78 The
79 .Xr kldload 8
80 program can load either
81 .Xr a.out 5
82 or ELF formatted loadable modules.
83 The
84 .Xr kldunload 8
85 program unloads any given loaded module, if no other module is dependent
86 upon the given module.
87 The
88 .Xr kldstat 8
89 program is used to check the status of the modules currently loaded into the
90 system.
91 .Pp
92 Kernel modules may only be loaded or unloaded if the system security level
93 .Va kern.securelevel
94 is less than one.
95 .Sh "MODULE TYPES"
96 .Bl -ohang
97 .It Em "Device Driver modules"
98 New block and character device
99 drivers may be loaded into the system with
100 .Nm .
101 Device nodes for the loaded drivers are automatically created when a
102 module is loaded and destroyed when it is unloaded by
103 .Xr devfs 5 .
104 You can specify userland programs that will run when new devices
105 become available as a result of loading modules, or existing devices
106 go away when modules are unloaded, by configuring
107 .Xr devd 8 .
108 .El
109 .Sh FILES
110 .Bl -tag -width /usr/include/sys/module.h -compact
111 .It Pa /boot/kernel
112 directory containing module binaries built for the kernel also
113 residing in the directory.
114 .It Pa /usr/include/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 devfs 5 ,
129 .Xr devd 8 ,
130 .Xr kldload 8 ,
131 .Xr kldstat 8 ,
132 .Xr kldunload 8 ,
133 .Xr sysctl 8
134 .Sh HISTORY
135 The
136 .Nm
137 facility appeared in
138 .Fx 3.0
139 and was designed as a replacement for the
140 .Nm lkm
141 facility, which was similar in functionality to the loadable kernel modules
142 facility provided by
143 .Tn SunOS
144 4.1.3.
145 .Sh AUTHORS
146 The
147 .Nm
148 facility was originally implemented by
149 .An Doug Rabson Aq dfr@FreeBSD.org .
150 .Sh BUGS
151 If a module B, is dependent on another module A, but is not compiled with
152 module A as a dependency, then
153 .Xr kldload 8
154 fails to load module B, even if module A is already present in the system.
155 .Pp
156 If multiple modules are dependent on module A, and are compiled with module
157 A as a dependency, then
158 .Xr kldload 8
159 loads an instance of module A when any of the modules are loaded.
160 .Pp
161 If a custom entry point is used for a module, and the module is compiled as
162 an
163 .Sq ELF
164 binary, then
165 .Xr kldload 8
166 fails to execute the entry point.
167 .Pp
168 .Xr kldload 8
169 returns the cryptic message
170 .Sq Li "ENOEXEC (Exec format error)"
171 for any error encountered while loading a module.
172 .Pp
173 When system internal interfaces change, old modules often cannot
174 detect this, and such modules when loaded will often cause crashes or
175 mysterious failures.