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 516aec1278SMax Laier.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" 616aec1278SMax Laier.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 666aec1278SMax LaierThe firmware abstraction provides a convenient interface for loading firmware 676aec1278SMax Laierimages into the kernel. 686aec1278SMax LaierSpecially crafted kernel modules are used to hold the firmware images. 696aec1278SMax Laier.Pp 706aec1278SMax LaierThe function 716aec1278SMax Laier.Fn firmware_register 726aec1278SMax Laieris used on load of such modules to register contained firmware images. 736aec1278SMax LaierThe arguments to 746aec1278SMax Laier.Fn firmware_register 756aec1278SMax Laierinclude a name that identifies the image for later requests to the firmware 766aec1278SMax Laiersystem, a pointer to the actual image, the size of the image and an optional 776aec1278SMax Laierparent image. 786aec1278SMax LaierThe parent image is used to keep track of references to a given module so that 796aec1278SMax Laierit can be unloaded on last reference. 806aec1278SMax Laier.Pp 816aec1278SMax LaierThe function 826aec1278SMax Laier.Fn firmware_unregister 836aec1278SMax Laierremoves the firmware image identified by the name from the system if there 846aec1278SMax Laierare no pending references or returns an error otherwise. 856aec1278SMax Laier.Pp 866aec1278SMax LaierThe function 876aec1278SMax Laier.Fn firmware_get 886aec1278SMax Laierreturns the requested firmware image. 896aec1278SMax LaierIf the image is not yet registered with the system 906aec1278SMax Laier.Fn firmware_get 916aec1278SMax Laiertries to load a module with the corresponding name. 926aec1278SMax LaierThis involves the linker subsystem and disk access which is why 936aec1278SMax Laier.Fn firmware_get 946aec1278SMax Laiermust not be called with any locks (except for Giant). 956aec1278SMax LaierOn success 966aec1278SMax Laier.Fn firmware_get 976aec1278SMax Laierreturns a pointer to the image description and increases the reference count 986aec1278SMax Laierfor this image. 996aec1278SMax Laier.Pp 1006aec1278SMax LaierThe function 1016aec1278SMax Laier.Fn firmware_put 1026aec1278SMax Laieris used to drop the reference to a firmware image. 1036aec1278SMax LaierThe flags argument may be set to 1046aec1278SMax Laier.Dv FIRMWARE_UNLOAD 1056aec1278SMax Laierto indicate that the caller wishes to unload the corresponding module if the 1066aec1278SMax Laierimage becomes unreferenced. 1076aec1278SMax Laier.Sh SEE ALSO 1086aec1278SMax Laier.Xr module 9 1096aec1278SMax Laier.Pp 1106aec1278SMax Laier.Pa /usr/share/examples/kld 1116aec1278SMax Laier.Sh HISTORY 1126aec1278SMax LaierThe firmware system was introduced in 1136aec1278SMax Laier.Fx 7.0 . 1146aec1278SMax Laier.Sh AUTHORS 1156aec1278SMax LaierThis manual page was written by 1166aec1278SMax Laier.An Max Laier Aq mlaier@FreeBSD.org . 117