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.
39 .Nm firmware_get_size ,
43 .Nd Firmware loader API for device drivers
48 .Fa "const char *drvname"
49 .Fa "const char *imgname"
50 .Fa "firmware_handle_t *fhp"
54 .Fa "firmware_handle_t fh"
57 .Fo "firmware_get_size"
58 .Fa "firmware_handle_t fh"
62 .Fa "firmware_handle_t fh"
70 The name of the driver using
72 This is used as the subdirectory holding the firmware images.
74 The file name of a firmware image.
76 The pointer used for returing a firmware handle.
80 The offset in the firmware image to start reading from.
82 Pointer to a buffer to hold the firmware data.
84 Size of the buffer to hold the firmware data.
88 provides a simple and convenient API for device drivers to load firmware
89 images from files residing in the file system that are necessary for the
90 devices that they control.
91 It is primarily intended for devices without non-volatile firmware
92 memory, which usually require the driver to load a firmware image at
94 Firmware images reside in sub-directories, one for each driver, in the
95 namespace "firmware" in the system default module search path as
99 The following functions are provided by the
102 .Bl -tag -width indent
103 .It Fn "firmware_open"
104 Open the firmware image
108 The path to the firmware image file is constructed by appending the string
109 .Dq "firmware/drvname/imgname"
110 to each system module path prefix until opening the firmware image
112 .It Fn "firmware_close"
113 Close the firmware image file associated with the firmware handle
115 .It Fn "firmware_get_size"
116 Returns the size of the image file associated with the firmware handle
118 .It Fn "firmware_read"
119 Reads from the image file associated with the firmware handle
125 The firmware image data is placed into the buffer specified by
128 will either read as much data as requested or fail, there are no short
132 These functions can be called from user and kernel context.
134 Upon successful completion, the
136 function returns zero and stores a firmware handle in
138 Otherwise a non-zero error code is returned.
142 will return zero on success and
147 On failure -1 is returned.
150 .Fn firmware_get_size
151 returns the size of a firmware image.
154 will always return zero.
155 .Sh INTERFACE STABILITY