1 .\" $NetBSD: firmload.9,v 1.8 2014/03/18 18:20:40 riastradh Exp $
3 .\" Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
5 .\" Copyright (c) 2006 The NetBSD Foundation, Inc.
6 .\" All rights reserved.
8 .\" This code is derived from software contributed to The NetBSD Foundation
9 .\" by Jason R. Thorpe.
11 .\" Redistribution and use in source and binary forms, with or without
12 .\" modification, are permitted provided that the following conditions
14 .\" 1. Redistributions of source code must retain the above copyright
15 .\" notice, this list of conditions and the following disclaimer.
16 .\" 2. Redistributions in binary form must reproduce the above copyright
17 .\" notice, this list of conditions and the following disclaimer in the
18 .\" documentation and/or other materials provided with the distribution.
20 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 .\" POSSIBILITY OF SUCH DAMAGE.
37 .Nd Firmware loader API for device drivers
42 .Fa "const char *drvname"
43 .Fa "const char *imgname"
44 .Fa "firmware_handle_t *fhp"
48 .Fa "firmware_handle_t fh"
51 .Fo "firmware_get_size"
52 .Fa "firmware_handle_t fh"
56 .Fa "firmware_handle_t fh"
64 The name of the driver using
66 This is used as the subdirectory holding the firmware images.
68 The file name of a firmware image.
70 The pointer used for returing a firmware handle.
74 The offset in the firmware image to start reading from.
76 Pointer to a buffer to hold the firmware data.
78 Size of the buffer to hold the firmware data.
82 provides a simple and convenient API for device drivers to load firmware
83 images from files residing in the file system that are necessary for the
84 devices that they control.
85 It is primarily intended for devices without non-volatile firmware
86 memory, which usually require the driver to load a firmware image at
88 Firmware images reside in sub-directories, one for each driver, in the
89 namespace "firmware" in the system default module search path as
93 The following functions are provided by the
96 .Bl -tag -width indent
97 .It Fn "firmware_open"
98 Open the firmware image
102 The path to the firmware image file is constructed by appending the string
103 .Dq "firmware/drvname/imgname"
104 to each system module path prefix until opening the firmware image
106 .It Fn "firmware_close"
107 Close the firmware image file associated with the firmware handle
109 .It Fn "firmware_get_size"
110 Returns the size of the image file associated with the firmware handle
112 .It Fn "firmware_read"
113 Reads from the image file associated with the firmware handle
119 The firmware image data is placed into the buffer specified by
122 will either read as much data as requested or fail, there are no short
126 These functions can be called from user and kernel context.
128 Upon successful completion, the
130 function returns zero and stores a firmware handle in
132 Otherwise a non-zero error code is returned.
136 will return zero on success and
141 On failure -1 is returned.
144 .Fn firmware_get_size
145 returns the size of a firmware image.
148 will always return zero.
149 .Sh INTERFACE STABILITY