Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F153850025
D55597.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D55597.diff
View Options
diff --git a/stand/defaults/loader.conf b/stand/defaults/loader.conf
--- a/stand/defaults/loader.conf
+++ b/stand/defaults/loader.conf
@@ -113,6 +113,7 @@
#console="vidconsole" # Comma- or space-separated list of consoles
#currdev="disk1s1a" # Set the current device
module_path="/boot/modules;/boot/firmware;/boot/dtb;/boot/dtb/overlays" # Set the module search path
+firmware_path="/boot/firmware;/usr/share/firmware" # Set the firmware search path
module_blacklist="drm drm2 radeonkms i915kms amdgpu if_iwlwifi if_rtw88 if_rtw89" # Loader module blacklist
module_blacklist="${module_blacklist} nvidia nvidia-drm nvidia-modeset"
#prompt="\\${interpret}" # Set the command prompt
diff --git a/sys/kern/subr_firmware.c b/sys/kern/subr_firmware.c
--- a/sys/kern/subr_firmware.c
+++ b/sys/kern/subr_firmware.c
@@ -264,10 +264,14 @@
uint32_t flags;
};
-static const char *fw_path = "/boot/firmware/";
+static char firmware_path[MAXPATHLEN] = "/boot/firmware;/usr/share/firmware";
-static void
-try_binary_file(const char *imagename, uint32_t flags)
+SYSCTL_STRING(_kern, OID_AUTO, firmware_path, CTLFLAG_RWTUN, firmware_path,
+ sizeof(firmware_path), "firmware load search path");
+
+static bool
+try_binary_file_path(const char *path, size_t pathlen,
+ const char *imagename, uint32_t flags)
{
struct nameidata nd;
struct thread *td = curthread;
@@ -281,19 +285,16 @@
int oflags;
size_t resid;
int error;
- bool warn = (flags & FIRMWARE_GET_NOWARN) == 0;
- /*
- * XXX TODO: Loop over some path instead of a single element path.
- * and fetch this path from the 'firmware_path' kenv the loader sets.
- */
sb = sbuf_new_auto();
- sbuf_printf(sb, "%s%s", fw_path, imagename);
+ sbuf_bcat(sb, path, pathlen);
+ if (path[pathlen - 1] != '/')
+ sbuf_putc(sb, '/');
+ sbuf_cat(sb, imagename);
sbuf_finish(sb);
fn = sbuf_data(sb);
if (bootverbose)
printf("Trying to load binary firmware from %s\n", fn);
-
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, fn);
oflags = FREAD;
error = vn_open(&nd, &oflags, 0, NULL);
@@ -331,16 +332,39 @@
if (bootverbose)
printf("%s: Loaded binary firmware using %s\n", imagename, fn);
sbuf_delete(sb);
- return;
+ return (true);
err2: /* cleanup in vn_open through vn_close */
VOP_UNLOCK(nd.ni_vp);
vn_close(nd.ni_vp, FREAD, cred, td);
err:
free(data, M_FIRMWARE);
- if (bootverbose || warn)
- printf("%s: could not load binary firmware %s either\n", imagename, fn);
sbuf_delete(sb);
+ return (false);
+}
+
+static void
+try_binary_file(const char *imagename, uint32_t flags)
+{
+ char *cp, *ep;
+ bool warn = (flags & FIRMWARE_GET_NOWARN) == 0;
+
+ for (cp = firmware_path; *cp; cp = ep + 1) {
+ ep = strchr(cp, ';');
+ if (ep == NULL)
+ ep = cp + strlen(cp);
+ if (ep == cp) {
+ if (*ep == 0)
+ break;
+ continue;
+ }
+ if (try_binary_file_path(cp, ep - cp, imagename, flags))
+ return;
+ if (*ep == 0)
+ break;
+ }
+ if (bootverbose || warn)
+ printf("%s: could not load binary firmware from %s\n", imagename, firmware_path);
}
static void
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 25, 6:11 AM (1 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32087149
Default Alt Text
D55597.diff (2 KB)
Attached To
Mode
D55597: sys/kern/subr_firmware: implement firmware_path search path
Attached
Detach File
Event Timeline
Log In to Comment