]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man9/firmware.9
firmware(9) is a subsystem to load binary data into the kernel via a
[FreeBSD/FreeBSD.git] / share / man / man9 / firmware.9
1 .\" Copyright (c) 2006 Max Laier <mlaier@FreeBSD.org>
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 .\"
13 .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
14 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16 .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
17 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 .\"
24 .\" $FreeBSD$
25 .\"
26 .Dd January 6, 2006
27 .Os
28 .Dt FIRMWARE 9
29 .Sh NAME
30 .Nm firmware_register ,
31 .Nm firmware_unregister ,
32 .Nm firmware_get ,
33 .Nm firmware_put
34 .Nd firmware image loading and management
35 .Sh SYNOPSIS
36 .In sys/param.h
37 .In sys/linker.h
38 .In sys/firmware.h
39 .Bd -literal
40 struct firmware {
41         const char      *name;          /* system-wide name */
42         const void      *data;          /* location of image */
43         size_t          datasize;       /* size of image in bytes */
44         unsigned int    version;        /* version of the image */
45         int             refcnt;         /* held references */
46         struct firmware *parent;        /* not null if a subimage */
47         linker_file_t   file;           /* loadable module */
48 };
49 .Ed
50 .Ft struct firmware *
51 .Fo firmware_register
52 .Fa "const char *imagename"
53 .Fa "const void *data"
54 .Fa "size_t datasize"
55 .Fa "unsigned int version"
56 .Fa "struct firmware *parent"
57 .Fc
58 .Ft int
59 .Fn firmware_unregister "const char *imagename"
60 .Ft struct firmware *
61 .Fn firmware_get "const char *imagename"
62 .Ft void
63 .Fn firmware_put "struct firmware *fp" "int flags"
64 .Sh DESCRIPTION
65 The firmware abstraction provides a convenient interface for loading firmware
66 images into the kernel.
67 Specially crafted kernel modules are used to hold the firmware images.
68 .Pp
69 The function
70 .Fn firmware_register
71 is used on load of such modules to register contained firmware images.
72 The arguments to
73 .Fn firmware_register
74 include a name that identifies the image for later requests to the firmware
75 system, a pointer to the actual image, the size of the image and an optional
76 parent image.
77 The parent image is used to keep track of references to a given module so that
78 it can be unloaded on last reference.
79 .Pp
80 The function
81 .Fn firmware_unregister
82 removes the firmware image identified by the name from the system if there
83 are no pending references or returns an error otherwise.
84 .Pp
85 The function
86 .Fn firmware_get
87 returns the requested firmware image.
88 If the image is not yet registered with the system
89 .Fn firmware_get
90 tries to load a module with the corresponding name.
91 This involves the linker subsystem and disk access which is why
92 .Fn firmware_get
93 must not be called with any locks (except for Giant).
94 On success
95 .Fn firmware_get
96 returns a pointer to the image description and increases the reference count
97 for this image.
98 .Pp
99 The function
100 .Fn firmware_put
101 is used to drop the reference to a firmware image.
102 The flags argument may be set to
103 .Dv FIRMWARE_UNLOAD
104 to indicate that the caller wishes to unload the corresponding module if the
105 image becomes unreferenced.
106 .Sh SEE ALSO
107 .Xr module 9
108 .Pp
109 .Pa /usr/share/examples/kld
110 .Sh HISTORY
111 The firmware system was introduced in
112 .Fx 7.0 .
113 .Sh AUTHORS
114 This manual page was written by
115 .An Max Laier Aq mlaier@FreeBSD.org .