aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/subr_firmware.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/subr_firmware.c')
-rw-r--r--sys/kern/subr_firmware.c45
1 files changed, 31 insertions, 14 deletions
diff --git a/sys/kern/subr_firmware.c b/sys/kern/subr_firmware.c
index db262c121918..0465f2a88483 100644
--- a/sys/kern/subr_firmware.c
+++ b/sys/kern/subr_firmware.c
@@ -238,36 +238,42 @@ firmware_unregister(const char *imagename)
return (err);
}
+struct fw_loadimage {
+ const char *imagename;
+ uint32_t flags;
+};
+
static void
-loadimage(void *arg, int npending)
+loadimage(void *arg, int npending __unused)
{
- char *imagename = arg;
+ struct fw_loadimage *fwli = arg;
struct priv_fw *fp;
linker_file_t result;
int error;
- error = linker_reference_module(imagename, NULL, &result);
+ error = linker_reference_module(fwli->imagename, NULL, &result);
if (error != 0) {
- printf("%s: could not load firmware image, error %d\n",
- imagename, error);
+ if (bootverbose || (fwli->flags & FIRMWARE_GET_NOWARN) == 0)
+ printf("%s: could not load firmware image, error %d\n",
+ fwli->imagename, error);
mtx_lock(&firmware_mtx);
goto done;
}
mtx_lock(&firmware_mtx);
- fp = lookup(imagename);
+ fp = lookup(fwli->imagename);
if (fp == NULL || fp->file != NULL) {
mtx_unlock(&firmware_mtx);
if (fp == NULL)
printf("%s: firmware image loaded, "
- "but did not register\n", imagename);
- (void) linker_release_module(imagename, NULL, NULL);
+ "but did not register\n", fwli->imagename);
+ (void) linker_release_module(fwli->imagename, NULL, NULL);
mtx_lock(&firmware_mtx);
goto done;
}
fp->file = result; /* record the module identity */
done:
- wakeup_one(imagename);
+ wakeup_one(arg);
mtx_unlock(&firmware_mtx);
}
@@ -279,7 +285,7 @@ done:
* release this reference for the image to be eligible for removal/unload.
*/
const struct firmware *
-firmware_get(const char *imagename)
+firmware_get_flags(const char *imagename, uint32_t flags)
{
struct task fwload_task;
struct thread *td;
@@ -306,11 +312,15 @@ firmware_get(const char *imagename)
* Also we must not hold any mtx's over this call which is problematic.
*/
if (!cold) {
- TASK_INIT(&fwload_task, 0, loadimage, __DECONST(void *,
- imagename));
+ struct fw_loadimage fwli;
+
+ fwli.imagename = imagename;
+ fwli.flags = flags;
+ TASK_INIT(&fwload_task, 0, loadimage, (void *)&fwli);
taskqueue_enqueue(firmware_tq, &fwload_task);
- msleep(__DECONST(void *, imagename), &firmware_mtx, 0,
- "fwload", 0);
+ PHOLD(curproc);
+ msleep((void *)&fwli, &firmware_mtx, 0, "fwload", 0);
+ PRELE(curproc);
}
/*
* After attempting to load the module, see if the image is registered.
@@ -328,6 +338,13 @@ found: /* common exit point on success */
return &fp->fw;
}
+const struct firmware *
+firmware_get(const char *imagename)
+{
+
+ return (firmware_get_flags(imagename, 0));
+}
+
/*
* Release a reference to a firmware image returned by firmware_get.
* The caller may specify, with the FIRMWARE_UNLOAD flag, its desire