xref: /freebsd/share/man/man9/firmware.9 (revision bd84dd2f8f93421fe79b44568f0dfc003dc1dcbc)
16aec1278SMax Laier.\" Copyright (c) 2006 Max Laier <mlaier@FreeBSD.org>
26aec1278SMax Laier.\" All rights reserved.
36aec1278SMax Laier.\"
46aec1278SMax Laier.\" Redistribution and use in source and binary forms, with or without
56aec1278SMax Laier.\" modification, are permitted provided that the following conditions
66aec1278SMax Laier.\" are met:
76aec1278SMax Laier.\" 1. Redistributions of source code must retain the above copyright
86aec1278SMax Laier.\"    notice, this list of conditions and the following disclaimer.
96aec1278SMax Laier.\" 2. Redistributions in binary form must reproduce the above copyright
106aec1278SMax Laier.\"    notice, this list of conditions and the following disclaimer in the
116aec1278SMax Laier.\"    documentation and/or other materials provided with the distribution.
126aec1278SMax Laier.\"
136aec1278SMax Laier.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
146aec1278SMax Laier.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
156aec1278SMax Laier.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
166aec1278SMax Laier.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
176aec1278SMax Laier.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
186aec1278SMax Laier.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
196aec1278SMax Laier.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
206aec1278SMax Laier.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
216aec1278SMax Laier.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
226aec1278SMax Laier.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
236aec1278SMax Laier.\"
246aec1278SMax Laier.\" $FreeBSD$
256aec1278SMax Laier.\"
266aec1278SMax Laier.Dd January 6, 2006
276aec1278SMax Laier.Os
286aec1278SMax Laier.Dt FIRMWARE 9
296aec1278SMax Laier.Sh NAME
306aec1278SMax Laier.Nm firmware_register ,
316aec1278SMax Laier.Nm firmware_unregister ,
326aec1278SMax Laier.Nm firmware_get ,
336aec1278SMax Laier.Nm firmware_put
346aec1278SMax Laier.Nd firmware image loading and management
356aec1278SMax Laier.Sh SYNOPSIS
366aec1278SMax Laier.In sys/param.h
37dad5bb64SMax Laier.In sys/systm.h
386aec1278SMax Laier.In sys/linker.h
396aec1278SMax Laier.In sys/firmware.h
406aec1278SMax Laier.Bd -literal
416aec1278SMax Laierstruct firmware {
426aec1278SMax Laier	const char	*name;		/* system-wide name */
436aec1278SMax Laier	const void	*data;		/* location of image */
446aec1278SMax Laier	size_t		datasize;	/* size of image in bytes */
456aec1278SMax Laier	unsigned int	version;	/* version of the image */
466aec1278SMax Laier	int		refcnt;		/* held references */
476aec1278SMax Laier	struct firmware	*parent;	/* not null if a subimage */
486aec1278SMax Laier	linker_file_t	file;		/* loadable module */
496aec1278SMax Laier};
506aec1278SMax Laier.Ed
51bd84dd2fSRuslan Ermilov.Ft "struct firmware *"
526aec1278SMax Laier.Fo firmware_register
536aec1278SMax Laier.Fa "const char *imagename"
546aec1278SMax Laier.Fa "const void *data"
556aec1278SMax Laier.Fa "size_t datasize"
566aec1278SMax Laier.Fa "unsigned int version"
576aec1278SMax Laier.Fa "struct firmware *parent"
586aec1278SMax Laier.Fc
596aec1278SMax Laier.Ft int
606aec1278SMax Laier.Fn firmware_unregister "const char *imagename"
61bd84dd2fSRuslan Ermilov.Ft "struct firmware *"
626aec1278SMax Laier.Fn firmware_get "const char *imagename"
636aec1278SMax Laier.Ft void
646aec1278SMax Laier.Fn firmware_put "struct firmware *fp" "int flags"
656aec1278SMax Laier.Sh DESCRIPTION
66bd84dd2fSRuslan ErmilovThe
67bd84dd2fSRuslan Ermilov.Nm firmware
68bd84dd2fSRuslan Ermilovabstraction provides a convenient interface for loading firmware
696aec1278SMax Laierimages into the kernel.
706aec1278SMax LaierSpecially crafted kernel modules are used to hold the firmware images.
716aec1278SMax Laier.Pp
726aec1278SMax LaierThe function
736aec1278SMax Laier.Fn firmware_register
746aec1278SMax Laieris used on load of such modules to register contained firmware images.
756aec1278SMax LaierThe arguments to
766aec1278SMax Laier.Fn firmware_register
77bd84dd2fSRuslan Ermilovinclude a name that identifies the image for later requests to the
78bd84dd2fSRuslan Ermilov.Nm firmware
796aec1278SMax Laiersystem, a pointer to the actual image, the size of the image and an optional
806aec1278SMax Laierparent image.
816aec1278SMax LaierThe parent image is used to keep track of references to a given module so that
826aec1278SMax Laierit can be unloaded on last reference.
836aec1278SMax Laier.Pp
846aec1278SMax LaierThe function
856aec1278SMax Laier.Fn firmware_unregister
866aec1278SMax Laierremoves the firmware image identified by the name from the system if there
876aec1278SMax Laierare no pending references or returns an error otherwise.
886aec1278SMax Laier.Pp
896aec1278SMax LaierThe function
906aec1278SMax Laier.Fn firmware_get
916aec1278SMax Laierreturns the requested firmware image.
92bd84dd2fSRuslan ErmilovIf the image is not yet registered with the system,
936aec1278SMax Laier.Fn firmware_get
946aec1278SMax Laiertries to load a module with the corresponding name.
956aec1278SMax LaierThis involves the linker subsystem and disk access which is why
966aec1278SMax Laier.Fn firmware_get
97bd84dd2fSRuslan Ermilovmust not be called with any locks (except for
98bd84dd2fSRuslan Ermilov.Va Giant ) .
99bd84dd2fSRuslan ErmilovOn success,
1006aec1278SMax Laier.Fn firmware_get
1016aec1278SMax Laierreturns a pointer to the image description and increases the reference count
1026aec1278SMax Laierfor this image.
1036aec1278SMax Laier.Pp
1046aec1278SMax LaierThe function
1056aec1278SMax Laier.Fn firmware_put
1066aec1278SMax Laieris used to drop the reference to a firmware image.
107bd84dd2fSRuslan ErmilovThe
108bd84dd2fSRuslan Ermilov.Fa flags
109bd84dd2fSRuslan Ermilovargument may be set to
1106aec1278SMax Laier.Dv FIRMWARE_UNLOAD
1116aec1278SMax Laierto indicate that the caller wishes to unload the corresponding module if the
1126aec1278SMax Laierimage becomes unreferenced.
1136aec1278SMax Laier.Sh SEE ALSO
1146aec1278SMax Laier.Xr module 9
1156aec1278SMax Laier.Pp
1166aec1278SMax Laier.Pa /usr/share/examples/kld
1176aec1278SMax Laier.Sh HISTORY
118bd84dd2fSRuslan ErmilovThe
119bd84dd2fSRuslan Ermilov.Nm firmware
120bd84dd2fSRuslan Ermilovsystem was introduced in
121999b97c5SHiroki Sato.Fx 6.1 .
1226aec1278SMax Laier.Sh AUTHORS
1236aec1278SMax LaierThis manual page was written by
1246aec1278SMax Laier.An Max Laier Aq mlaier@FreeBSD.org .
125