1 .\" $NetBSD: firmload.9,v 1.4 2008/04/30 13:10:58 martin Exp $
3 .\" Copyright (c) 2006 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Jason R. Thorpe.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
35 .Nd Firmware loader API for device drivers
40 .Fn "firmware_open" "const char *drvname" "const char *imgname" \
41 "firmware_handle_t *fhp"
44 .Fn "firmware_close" "firmware_handle_t fh"
47 .Fn "firmware_get_size" "firmware_handle_t fh"
50 .Fn "firmware_read" "firmware_handle_t fh" "off_t offset" "void *buf" \
54 .Fn "firmware_malloc" "size_t size"
57 .Fn "firmware_free" "void *buf" "size_t size"
60 provides a simple and convenient API for device drivers to load firmware
61 images from files residing in the file system that are necessary for the
62 devices that they control.
63 Firmware images reside in sub-directories, one for each driver, of a series
64 of colon-separated path prefixes specified by the sysctl variable
65 .Dv hw.firmware.path .
67 The following functions are provided by the
70 .Bl -tag -width indent
71 .It int Fn "firmware_open" "const char *drvname" "const char *imgname" \
72 "firmware_handle_t *fhp"
74 Open then firmware image
78 The path to the firmware image file is constructed by appending the string
79 .Dq "/drvname/imgname"
80 to each configured path prefix until opening the firmware image file succeeds.
83 returns 0 and stores a firmware image handle in the location pointed to by
85 Otherwise, an error code is returned to indicate the reason for failure.
86 .It int Fn "firmware_close" "firmware_handle_t fh"
88 Close the firmware image file associated with the firmware handle
90 Returns 0 upon success or an error code to indicate the reason for failure.
91 .It off_t Fn "firmware_get_size" "firmware_handle_t fh"
93 Returns the size of the image file associated with the firmware handle
95 .It int Fn "firmware_read" "firmware_handle_t fh" "off_t offset" "void *buf" \
98 Reads from the image file associated with the firmware handle
104 The firmware image data is placed into the buffer specified by
106 Returns 0 upon success or an error code to indicate the reason for failure.
107 .It void * Ns Fn "firmware_malloc" "size_t size"
109 Allocates a region of wired kernel memory of size
114 .It void Fn "firmware_free" "void *buf" "size_t size"
116 Frees a region of memory previously allocated by
117 .Fn firmware_malloc .
126 framework first appeared in
129 .An Jason Thorpe Aq thorpej@NetBSD.org