xref: /freebsd/share/man/man4/kld.4 (revision 5ab2dec31ea7fe9dd9125d547c32907733ed9f12)
122872b5fSGuy Helmer.\" Copyright (c) 1993 Christopher G. Demetriou
222872b5fSGuy Helmer.\" All rights reserved.
322872b5fSGuy Helmer.\"
422872b5fSGuy Helmer.\" Redistribution and use in source and binary forms, with or without
522872b5fSGuy Helmer.\" modification, are permitted provided that the following conditions
622872b5fSGuy Helmer.\" are met:
722872b5fSGuy Helmer.\" 1. Redistributions of source code must retain the above copyright
822872b5fSGuy Helmer.\"    notice, this list of conditions and the following disclaimer.
922872b5fSGuy Helmer.\" 2. Redistributions in binary form must reproduce the above copyright
1022872b5fSGuy Helmer.\"    notice, this list of conditions and the following disclaimer in the
1122872b5fSGuy Helmer.\"    documentation and/or other materials provided with the distribution.
1222872b5fSGuy Helmer.\" 3. The name of the author may not be used to endorse or promote products
1322872b5fSGuy Helmer.\"    derived from this software without specific prior written permission
1422872b5fSGuy Helmer.\"
1522872b5fSGuy Helmer.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1622872b5fSGuy Helmer.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1722872b5fSGuy Helmer.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1822872b5fSGuy Helmer.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
1922872b5fSGuy Helmer.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2022872b5fSGuy Helmer.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2122872b5fSGuy Helmer.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2222872b5fSGuy Helmer.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2322872b5fSGuy Helmer.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2422872b5fSGuy Helmer.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2522872b5fSGuy Helmer.\"
267f3dea24SPeter Wemm.\" $FreeBSD$
2722872b5fSGuy Helmer.\"
28d7b336c0SRuslan Ermilov.Dd November 8, 1998
2922872b5fSGuy Helmer.Dt KLD 4
303d45e180SRuslan Ermilov.Os
3122872b5fSGuy Helmer.Sh NAME
3222872b5fSGuy Helmer.Nm kld
3322872b5fSGuy Helmer.Nd dynamic kernel linker facility
3422872b5fSGuy Helmer.Sh DESCRIPTION
35b5c508fbSRuslan ErmilovThe LKM (Loadable Kernel Modules) facility has been deprecated in
36b5c508fbSRuslan Ermilov.Fx 3.0
37b5c508fbSRuslan Ermilovand above in favor of the
3822872b5fSGuy Helmer.Nm
396d249eeeSSheldon Hearninterface.
406d249eeeSSheldon HearnThis interface, like its
4122872b5fSGuy Helmerpredecessor, allows the system administrator to dynamically add and remove
42b5e7e999SRuslan Ermilovfunctionality from a running system.
43b5e7e999SRuslan ErmilovThis ability also helps software
4422872b5fSGuy Helmerdevelopers to develop new parts of the kernel without constantly rebooting
4522872b5fSGuy Helmerto test their changes.
4622872b5fSGuy Helmer.Pp
4722872b5fSGuy HelmerVarious types of modules can be loaded into the system.
4822872b5fSGuy HelmerThere are several defined module types, listed below, which can
49b5e7e999SRuslan Ermilovbe added to the system in a predefined way.
50b5e7e999SRuslan ErmilovIn addition, there
5122872b5fSGuy Helmeris a generic type, for which the module itself handles loading and
5222872b5fSGuy Helmerunloading.
5322872b5fSGuy Helmer.Pp
5422872b5fSGuy HelmerThe
55b5c508fbSRuslan Ermilov.Fx
5622872b5fSGuy Helmersystem makes extensive use of loadable kernel modules, and provides loadable
5722872b5fSGuy Helmerversions of most file systems, the
5822872b5fSGuy Helmer.Tn NFS
5922872b5fSGuy Helmerclient and server, all the screen-savers, and the
6022872b5fSGuy Helmer.Tn iBCS2
6122872b5fSGuy Helmerand
6222872b5fSGuy Helmer.Tn Linux
6322872b5fSGuy Helmeremulators.
6422872b5fSGuy Helmer.Nm
6522872b5fSGuy Helmermodules are placed by default in the
6631ab9a12SDima Dorfman.Pa /boot/kernel
6731ab9a12SDima Dorfmandirectory along with their matching kernel.
6822872b5fSGuy Helmer.Pp
6922872b5fSGuy HelmerThe
7022872b5fSGuy Helmer.Nm
7122872b5fSGuy Helmerinterface is used through the
7222872b5fSGuy Helmer.Xr kldload 8 ,
7322872b5fSGuy Helmer.Xr kldunload 8
7422872b5fSGuy Helmerand
7522872b5fSGuy Helmer.Xr kldstat 8
7622872b5fSGuy Helmerprograms.
7722872b5fSGuy Helmer.Pp
7822872b5fSGuy HelmerThe
7922872b5fSGuy Helmer.Xr kldload 8
8022872b5fSGuy Helmerprogram can load either
8122872b5fSGuy Helmer.Xr a.out 5
8222872b5fSGuy Helmeror ELF formatted loadable modules.
8322872b5fSGuy HelmerThe
8422872b5fSGuy Helmer.Xr kldunload 8
8522872b5fSGuy Helmerprogram unloads any given loaded module, if no other module is dependent
8622872b5fSGuy Helmerupon the given module.
8722872b5fSGuy HelmerThe
8822872b5fSGuy Helmer.Xr kldstat 8
8922872b5fSGuy Helmerprogram is used to check the status of the modules currently loaded into the
9022872b5fSGuy Helmersystem.
91b9e9c23dSKen Smith.Pp
92b9e9c23dSKen SmithKernel modules may only be loaded or unloaded if the system security level
93b9e9c23dSKen Smith.Va kern.securelevel
94b9e9c23dSKen Smithis less than one.
9522872b5fSGuy Helmer.Sh "MODULE TYPES"
9622872b5fSGuy Helmer.Bl -ohang
9722872b5fSGuy Helmer.It Em "Device Driver modules"
9822872b5fSGuy HelmerNew block and character device
9922872b5fSGuy Helmerdrivers may be loaded into the system with
1004b66483fSRuslan Ermilov.Nm .
10112c63b8eSGiorgos KeramidasDevice nodes for the loaded drivers are automatically created when a
10212c63b8eSGiorgos Keramidasmodule is loaded and destroyed when it is unloaded by
10312c63b8eSGiorgos Keramidas.Xr devfs 5 .
10412c63b8eSGiorgos KeramidasYou can specify userland programs that will run when new devices
10512c63b8eSGiorgos Keramidasbecome available as a result of loading modules, or existing devices
10612c63b8eSGiorgos Keramidasgo away when modules are unloaded, by configuring
10712c63b8eSGiorgos Keramidas.Xr devd 8 .
10822872b5fSGuy Helmer.El
10922872b5fSGuy Helmer.Sh FILES
11022872b5fSGuy Helmer.Bl -tag -width /usr/include/sys/module.h -compact
11131ab9a12SDima Dorfman.It Pa /boot/kernel
11231ab9a12SDima Dorfmandirectory containing module binaries built for the kernel also
11331ab9a12SDima Dorfmanresiding in the directory.
11422872b5fSGuy Helmer.It Pa /usr/include/sys/module.h
11522872b5fSGuy Helmerfile containing definitions required to compile a
11622872b5fSGuy Helmer.Nm
11722872b5fSGuy Helmermodule
11822872b5fSGuy Helmer.It Pa /usr/share/examples/kld
11922872b5fSGuy Helmerexample source code implementing a sample kld module
1203136363fSRuslan Ermilov.El
12122872b5fSGuy Helmer.Sh SEE ALSO
1224bef9e22SGuy Helmer.Xr kldfind 2 ,
1234bef9e22SGuy Helmer.Xr kldfirstmod 2 ,
1244bef9e22SGuy Helmer.Xr kldload 2 ,
1254bef9e22SGuy Helmer.Xr kldnext 2 ,
1264bef9e22SGuy Helmer.Xr kldstat 2 ,
1274bef9e22SGuy Helmer.Xr kldunload 2 ,
12812c63b8eSGiorgos Keramidas.Xr devfs 5 ,
12912c63b8eSGiorgos Keramidas.Xr devd 8 ,
13022872b5fSGuy Helmer.Xr kldload 8 ,
13122872b5fSGuy Helmer.Xr kldstat 8 ,
132b9e9c23dSKen Smith.Xr kldunload 8 ,
133b9e9c23dSKen Smith.Xr sysctl 8
1349cbda590SRuslan Ermilov.Sh HISTORY
1359cbda590SRuslan ErmilovThe
1369cbda590SRuslan Ermilov.Nm
1379cbda590SRuslan Ermilovfacility appeared in
1389cbda590SRuslan Ermilov.Fx 3.0
1399cbda590SRuslan Ermilovand was designed as a replacement for the
1405ab2dec3SChristian Brueffer.Nm lkm
1419cbda590SRuslan Ermilovfacility, which was similar in functionality to the loadable kernel modules
1429cbda590SRuslan Ermilovfacility provided by
1439cbda590SRuslan Ermilov.Tn SunOS
1449cbda590SRuslan Ermilov4.1.3.
1459cbda590SRuslan Ermilov.Sh AUTHORS
1469cbda590SRuslan ErmilovThe
1479cbda590SRuslan Ermilov.Nm
1489cbda590SRuslan Ermilovfacility was originally implemented by
1499cbda590SRuslan Ermilov.An Doug Rabson Aq dfr@FreeBSD.org .
15022872b5fSGuy Helmer.Sh BUGS
15122872b5fSGuy HelmerIf a module B, is dependent on another module A, but is not compiled with
15222872b5fSGuy Helmermodule A as a dependency, then
15322872b5fSGuy Helmer.Xr kldload 8
15422872b5fSGuy Helmerfails to load module B, even if module A is already present in the system.
15522872b5fSGuy Helmer.Pp
15622872b5fSGuy HelmerIf multiple modules are dependent on module A, and are compiled with module
15722872b5fSGuy HelmerA as a dependency, then
15822872b5fSGuy Helmer.Xr kldload 8
15922872b5fSGuy Helmerloads an instance of module A when any of the modules are loaded.
16022872b5fSGuy Helmer.Pp
16122872b5fSGuy HelmerIf a custom entry point is used for a module, and the module is compiled as
16222872b5fSGuy Helmeran
16322872b5fSGuy Helmer.Sq ELF
16422872b5fSGuy Helmerbinary, then
16522872b5fSGuy Helmer.Xr kldload 8
16622872b5fSGuy Helmerfails to execute the entry point.
16722872b5fSGuy Helmer.Pp
16822872b5fSGuy Helmer.Xr kldload 8
16922872b5fSGuy Helmerreturns the cryptic message
170b92a189eSRuslan Ermilov.Sq Li "ENOEXEC (Exec format error)"
17122872b5fSGuy Helmerfor any error encountered while loading a module.
17222872b5fSGuy Helmer.Pp
17322872b5fSGuy HelmerWhen system internal interfaces change, old modules often cannot
17422872b5fSGuy Helmerdetect this, and such modules when loaded will often cause crashes or
17522872b5fSGuy Helmermysterious failures.
176