firmware.h revision 159486
1139804Simp/*- 21960Sdg * Copyright (c) 2005, Sam Leffler <sam@errno.com> 31960Sdg * All rights reserved. 41960Sdg * 51960Sdg * Redistribution and use in source and binary forms, with or without 61960Sdg * modification, are permitted provided that the following conditions 71960Sdg * are met: 81960Sdg * 1. Redistributions of source code must retain the above copyright 91960Sdg * notice unmodified, this list of conditions, and the following 101960Sdg * disclaimer. 111960Sdg * 2. Redistributions in binary form must reproduce the above copyright 121960Sdg * notice, this list of conditions and the following disclaimer in the 131960Sdg * documentation and/or other materials provided with the distribution. 141960Sdg * 151960Sdg * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 161960Sdg * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 171960Sdg * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 181960Sdg * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 191960Sdg * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 201960Sdg * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 211960Sdg * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 221960Sdg * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 231960Sdg * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 241960Sdg * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 251960Sdg * 261960Sdg * $FreeBSD: head/sys/sys/firmware.h 159486 2006-06-10 17:04:07Z iedowse $ 271960Sdg */ 281960Sdg#ifndef _SYS_FIRMWARE_H_ 291960Sdg#define _SYS_FIRMWARE_H_ 301960Sdg/* 311960Sdg * Loadable firmware support. 321960Sdg * 331960Sdg * Firmware images are embedded in kernel loadable modules that can 341960Sdg * be loaded on-demand or pre-loaded as desired. Modules may contain 35116182Sobrien * one or more firmware images that are stored as opaque data arrays 36116182Sobrien * and registered with a unique string name. Consumers request 37116182Sobrien * firmware by name with held references counted to use in disallowing 3832929Seivind * module/data unload. 3932929Seivind * 401960Sdg * When multiple images are stored in one module the one image is 411960Sdg * treated as the master with the other images holding references 4241059Speter * to it. This means that to unload the module each dependent/subimage 43114216Skan * must first have its references removed. 4431561Sbde */ 45101778Sphkstruct firmware { 4676166Smarkm const char *name; /* system-wide name */ 471960Sdg const void *data; /* location of image */ 4818020Sbde size_t datasize; /* size of image in bytes */ 491960Sdg unsigned int version; /* version of the image */ 501960Sdg int refcnt; /* held references */ 511960Sdg int flags; /* FIRMWAREFLAG_ flags */ 521960Sdg struct firmware *parent; /* not null if a subimage */ 531960Sdg linker_file_t file; /* loadable module */ 541960Sdg}; 551960Sdg 561960Sdg/* "flags" field definitions */ 571960Sdg#define FIRMWAREFLAG_KEEPKLDREF 0x0001 /* don't release KLD reference */ 5822521Sdyson 591960Sdgstruct firmware *firmware_register(const char *, const void *, size_t, 601960Sdg unsigned int, struct firmware *); 6122880Sbdeint firmware_unregister(const char *); 6222880Sbdestruct firmware *firmware_get(const char *); 6322880Sbde#define FIRMWARE_UNLOAD 0x0001 /* unload if unreferenced */ 6422880Sbdevoid firmware_put(struct firmware *, int); 6522880Sbde#endif /* _SYS_FIRMWARE_H_ */ 6630309Sphk