xref: /freebsd/share/man/man9/firmware.9 (revision 6aec1278dc6fd4790208608ee99bdc84dcf0b3da)
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
376aec1278SMax Laier.In sys/linker.h
386aec1278SMax Laier.In sys/firmware.h
396aec1278SMax Laier.Bd -literal
406aec1278SMax Laierstruct firmware {
416aec1278SMax Laier	const char	*name;		/* system-wide name */
426aec1278SMax Laier	const void	*data;		/* location of image */
436aec1278SMax Laier	size_t		datasize;	/* size of image in bytes */
446aec1278SMax Laier	unsigned int	version;	/* version of the image */
456aec1278SMax Laier	int		refcnt;		/* held references */
466aec1278SMax Laier	struct firmware	*parent;	/* not null if a subimage */
476aec1278SMax Laier	linker_file_t	file;		/* loadable module */
486aec1278SMax Laier};
496aec1278SMax Laier.Ed
506aec1278SMax Laier.Ft struct firmware *
516aec1278SMax Laier.Fo firmware_register
526aec1278SMax Laier.Fa "const char *imagename"
536aec1278SMax Laier.Fa "const void *data"
546aec1278SMax Laier.Fa "size_t datasize"
556aec1278SMax Laier.Fa "unsigned int version"
566aec1278SMax Laier.Fa "struct firmware *parent"
576aec1278SMax Laier.Fc
586aec1278SMax Laier.Ft int
596aec1278SMax Laier.Fn firmware_unregister "const char *imagename"
606aec1278SMax Laier.Ft struct firmware *
616aec1278SMax Laier.Fn firmware_get "const char *imagename"
626aec1278SMax Laier.Ft void
636aec1278SMax Laier.Fn firmware_put "struct firmware *fp" "int flags"
646aec1278SMax Laier.Sh DESCRIPTION
656aec1278SMax LaierThe firmware abstraction provides a convenient interface for loading firmware
666aec1278SMax Laierimages into the kernel.
676aec1278SMax LaierSpecially crafted kernel modules are used to hold the firmware images.
686aec1278SMax Laier.Pp
696aec1278SMax LaierThe function
706aec1278SMax Laier.Fn firmware_register
716aec1278SMax Laieris used on load of such modules to register contained firmware images.
726aec1278SMax LaierThe arguments to
736aec1278SMax Laier.Fn firmware_register
746aec1278SMax Laierinclude a name that identifies the image for later requests to the firmware
756aec1278SMax Laiersystem, a pointer to the actual image, the size of the image and an optional
766aec1278SMax Laierparent image.
776aec1278SMax LaierThe parent image is used to keep track of references to a given module so that
786aec1278SMax Laierit can be unloaded on last reference.
796aec1278SMax Laier.Pp
806aec1278SMax LaierThe function
816aec1278SMax Laier.Fn firmware_unregister
826aec1278SMax Laierremoves the firmware image identified by the name from the system if there
836aec1278SMax Laierare no pending references or returns an error otherwise.
846aec1278SMax Laier.Pp
856aec1278SMax LaierThe function
866aec1278SMax Laier.Fn firmware_get
876aec1278SMax Laierreturns the requested firmware image.
886aec1278SMax LaierIf the image is not yet registered with the system
896aec1278SMax Laier.Fn firmware_get
906aec1278SMax Laiertries to load a module with the corresponding name.
916aec1278SMax LaierThis involves the linker subsystem and disk access which is why
926aec1278SMax Laier.Fn firmware_get
936aec1278SMax Laiermust not be called with any locks (except for Giant).
946aec1278SMax LaierOn success
956aec1278SMax Laier.Fn firmware_get
966aec1278SMax Laierreturns a pointer to the image description and increases the reference count
976aec1278SMax Laierfor this image.
986aec1278SMax Laier.Pp
996aec1278SMax LaierThe function
1006aec1278SMax Laier.Fn firmware_put
1016aec1278SMax Laieris used to drop the reference to a firmware image.
1026aec1278SMax LaierThe flags argument may be set to
1036aec1278SMax Laier.Dv FIRMWARE_UNLOAD
1046aec1278SMax Laierto indicate that the caller wishes to unload the corresponding module if the
1056aec1278SMax Laierimage becomes unreferenced.
1066aec1278SMax Laier.Sh SEE ALSO
1076aec1278SMax Laier.Xr module 9
1086aec1278SMax Laier.Pp
1096aec1278SMax Laier.Pa /usr/share/examples/kld
1106aec1278SMax Laier.Sh HISTORY
1116aec1278SMax LaierThe firmware system was introduced in
1126aec1278SMax Laier.Fx 7.0 .
1136aec1278SMax Laier.Sh AUTHORS
1146aec1278SMax LaierThis manual page was written by
1156aec1278SMax Laier.An Max Laier Aq mlaier@FreeBSD.org .
116