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