summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2024-07-03 20:12:31 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2024-07-03 20:12:31 +0000
commit8d92a043b0c46a73c7557ffdccd9b0010be7e9a5 (patch)
tree1dff40ff050b4c4ba9dca438faf535f2a55d5fe1 /sys/arch
parentd361ed5b791a3de1c4d1931662979097ed3d7cd2 (diff)
Switch to a table for mapping smbios vendor/product to device tree file
name. Check for a partial match of the vendor like we already do for the product. This will help adding more machines to the list. ok patrick@, deraadt@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/arm64/stand/efiboot/efiboot.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/sys/arch/arm64/stand/efiboot/efiboot.c b/sys/arch/arm64/stand/efiboot/efiboot.c
index 564921d0cf2..f912edb4996 100644
--- a/sys/arch/arm64/stand/efiboot/efiboot.c
+++ b/sys/arch/arm64/stand/efiboot/efiboot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: efiboot.c,v 1.53 2024/06/20 21:52:08 kettenis Exp $ */
+/* $OpenBSD: efiboot.c,v 1.54 2024/07/03 20:12:30 kettenis Exp $ */
/*
* Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net>
@@ -1109,10 +1109,24 @@ mdrandom(char *buf, size_t buflen)
#define FW_PATH "/etc/firmware/dtb/"
+struct smbios_dtb {
+ const char *vendor;
+ const char *prod;
+ const char *dtb;
+} smbios_dtb[] = {
+ { "LENOVO", "21BX",
+ "qcom/sc8280xp-lenovo-thinkpad-x13s.dtb" },
+ { "LENOVO", "21BY",
+ "qcom/sc8280xp-lenovo-thinkpad-x13s.dtb" },
+};
+
void *
efi_fdt(void)
{
extern char *hw_vendor, *hw_prod;
+ size_t vendorlen, prodlen;
+ char dtb[256];
+ int i;
/* 'mach dtb' has precedence */
if (fdt_override != NULL)
@@ -1122,11 +1136,14 @@ efi_fdt(void)
if (hw_vendor == NULL || hw_prod == NULL)
return fdt_sys;
- if (strcmp(hw_vendor, "LENOVO") == 0) {
- if (strncmp(hw_prod, "21BX", 4) == 0 ||
- strncmp(hw_prod, "21BY", 4) == 0) {
- fdt_load_override(FW_PATH
- "qcom/sc8280xp-lenovo-thinkpad-x13s.dtb");
+ for (i = 0; i < nitems(smbios_dtb); i++) {
+ vendorlen = strlen(smbios_dtb[i].vendor);
+ prodlen = strlen(smbios_dtb[i].prod);
+ if (strncmp(hw_vendor, smbios_dtb[i].vendor, vendorlen) == 0 &&
+ strncmp(hw_prod, smbios_dtb[i].prod, prodlen) == 0) {
+ snprintf(dtb, sizeof(dtb), "%s%s", FW_PATH,
+ smbios_dtb[i].dtb);
+ fdt_load_override(dtb);
/* TODO: find a better mechanism */
cnset(ttydev("fb0"));
}