FreeBSD kernel kern code
subr_firmware.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/queue.h>
#include <sys/taskqueue.h>
#include <sys/systm.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/errno.h>
#include <sys/linker.h>
#include <sys/firmware.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/module.h>
#include <sys/eventhandler.h>
#include <sys/filedesc.h>
#include <sys/vnode.h>
Include dependency graph for subr_firmware.c:

Go to the source code of this file.

Data Structures

struct  priv_fw
 

Macros

#define FW_INUSE(p)   ((p)->file != NULL || (p)->fw.name != NULL)
 
#define FW_UNLOAD   0x100
 
#define PRIV_FW(x)
 
#define FIRMWARE_MAX   50
 

Functions

 __FBSDID ("$BSDSUniX$")
 
 MTX_SYSINIT (firmware,&firmware_mtx,"firmware table", MTX_DEF)
 
static struct priv_fwlookup (const char *name, struct priv_fw **empty_slot)
 
const struct firmware * firmware_register (const char *imagename, const void *data, size_t datasize, unsigned int version, const struct firmware *parent)
 
int firmware_unregister (const char *imagename)
 
static void loadimage (void *arg, int npending)
 
const struct firmware * firmware_get (const char *imagename)
 
void firmware_put (const struct firmware *p, int flags)
 
static void set_rootvnode (void *arg, int npending)
 
static void firmware_mountroot (void *arg)
 
 EVENTHANDLER_DEFINE (mountroot, firmware_mountroot, NULL, 0)
 
static void unloadentry (void *unused1, int unused2)
 
static int firmware_modevent (module_t mod, int type, void *unused)
 
 DECLARE_MODULE (firmware, firmware_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST)
 
 MODULE_VERSION (firmware, 1)
 

Variables

static struct priv_fw firmware_table [FIRMWARE_MAX]
 
static struct taskqueuefirmware_tq
 
static struct task firmware_unload_task
 
static struct mtx firmware_mtx
 
static moduledata_t firmware_mod
 

Macro Definition Documentation

#define FIRMWARE_MAX   50

Definition at line 124 of file subr_firmware.c.

Referenced by firmware_modevent(), lookup(), and unloadentry().

#define FW_INUSE (   p)    ((p)->file != NULL || (p)->fw.name != NULL)

Definition at line 58 of file subr_firmware.c.

Referenced by lookup().

#define FW_UNLOAD   0x100

Definition at line 91 of file subr_firmware.c.

Referenced by firmware_modevent(), firmware_put(), and unloadentry().

#define PRIV_FW (   x)
Value:
((struct priv_fw *) \
((intptr_t)(x) - offsetof(struct priv_fw, fw)) )
struct firmware fw

Definition at line 115 of file subr_firmware.c.

Referenced by firmware_put(), and firmware_register().

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
DECLARE_MODULE ( firmware  ,
firmware_mod  ,
SI_SUB_DRIVERS  ,
SI_ORDER_FIRST   
)
EVENTHANDLER_DEFINE ( mountroot  ,
firmware_mountroot  ,
NULL  ,
 
)
const struct firmware* firmware_get ( const char *  imagename)

Definition at line 298 of file subr_firmware.c.

References firmware_mtx, priv_fw::fw, loadimage(), lookup(), priv_fw::parent, printf(), priv_check(), priv_fw::refcnt, securelevel_gt(), and taskqueue_enqueue().

Here is the call graph for this function:

static int firmware_modevent ( module_t  mod,
int  type,
void *  unused 
)
static
static void firmware_mountroot ( void *  arg)
static

Definition at line 402 of file subr_firmware.c.

References malloc(), printf(), set_rootvnode(), and taskqueue_enqueue().

Referenced by firmware_modevent().

Here is the call graph for this function:

Here is the caller graph for this function:

void firmware_put ( const struct firmware *  p,
int  flags 
)

Definition at line 357 of file subr_firmware.c.

References priv_fw::file, firmware_mtx, firmware_unload_task, priv_fw::flags, FW_UNLOAD, priv_fw::parent, PRIV_FW, priv_fw::refcnt, and taskqueue_enqueue().

Here is the call graph for this function:

const struct firmware* firmware_register ( const char *  imagename,
const void *  data,
size_t  datasize,
unsigned int  version,
const struct firmware *  parent 
)

Definition at line 174 of file subr_firmware.c.

References bootverbose, firmware_mtx, priv_fw::fw, lookup(), priv_fw::parent, printf(), and PRIV_FW.

Here is the call graph for this function:

int firmware_unregister ( const char *  imagename)

Definition at line 216 of file subr_firmware.c.

References priv_fw::file, firmware_mtx, lookup(), and priv_fw::refcnt.

Here is the call graph for this function:

static void loadimage ( void *  arg,
int  npending 
)
static

Definition at line 250 of file subr_firmware.c.

References priv_fw::file, firmware_mtx, linker_reference_module(), linker_release_module(), lookup(), printf(), result, and wakeup_one().

Referenced by firmware_get().

Here is the call graph for this function:

Here is the caller graph for this function:

static struct priv_fw* lookup ( const char *  name,
struct priv_fw **  empty_slot 
)
static

Definition at line 148 of file subr_firmware.c.

References dummy, FIRMWARE_MAX, firmware_table, priv_fw::fw, and FW_INUSE.

Referenced by firmware_get(), firmware_register(), firmware_unregister(), and loadimage().

Here is the caller graph for this function:

MODULE_VERSION ( firmware  ,
 
)
MTX_SYSINIT ( firmware  ,
firmware_mtx,
"firmware table"  ,
MTX_DEF   
)
static void set_rootvnode ( void *  arg,
int  npending 
)
static

Definition at line 378 of file subr_firmware.c.

References free(), and rootvnode.

Referenced by firmware_mountroot().

Here is the call graph for this function:

Here is the caller graph for this function:

static void unloadentry ( void *  unused1,
int  unused2 
)
static

Definition at line 423 of file subr_firmware.c.

References priv_fw::file, FIRMWARE_MAX, firmware_mtx, firmware_table, priv_fw::flags, priv_fw::fw, FW_UNLOAD, linker_release_module(), and priv_fw::refcnt.

Referenced by firmware_modevent().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

moduledata_t firmware_mod
static
Initial value:
= {
"firmware",
NULL
}
static int firmware_modevent(module_t mod, int type, void *unused)

Definition at line 525 of file subr_firmware.c.

struct mtx firmware_mtx
static
struct priv_fw firmware_table[FIRMWARE_MAX]
static

Definition at line 125 of file subr_firmware.c.

Referenced by firmware_modevent(), lookup(), and unloadentry().

struct taskqueue* firmware_tq
static

Definition at line 131 of file subr_firmware.c.

struct task firmware_unload_task
static

Definition at line 132 of file subr_firmware.c.

Referenced by firmware_modevent(), and firmware_put().