Module Name: src
Committed By: jmcneill
Date: Fri Jul 23 21:33:00 UTC 2021
Modified Files:
src/sys/stand/efiboot: efiacpi.c smbios.c
Log Message:
efiboot: Add support for SMBIOS 2.x tables.
To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/stand/efiboot/efiacpi.c
cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/smbios.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/stand/efiboot/efiacpi.c
diff -u src/sys/stand/efiboot/efiacpi.c:1.9 src/sys/stand/efiboot/efiacpi.c:1.10
--- src/sys/stand/efiboot/efiacpi.c:1.9 Fri May 21 21:53:15 2021
+++ src/sys/stand/efiboot/efiacpi.c Fri Jul 23 21:33:00 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efiacpi.c,v 1.9 2021/05/21 21:53:15 jmcneill Exp $ */
+/* $NetBSD: efiacpi.c,v 1.10 2021/07/23 21:33:00 jmcneill Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -52,10 +52,11 @@ struct acpi_rdsp {
static EFI_GUID Acpi20TableGuid = ACPI_20_TABLE_GUID;
static EFI_GUID Smbios3TableGuid = SMBIOS3_TABLE_GUID;
+static EFI_GUID SmbiosTableGuid = SMBIOS_TABLE_GUID;
static int acpi_enable = 1;
static void *acpi_root = NULL;
-static void *smbios3_table = NULL;
+static void *smbios_table = NULL;
int
efi_acpi_probe(void)
@@ -66,9 +67,13 @@ efi_acpi_probe(void)
if (EFI_ERROR(status))
return EIO;
- status = LibGetSystemConfigurationTable(&Smbios3TableGuid, &smbios3_table);
- if (EFI_ERROR(status))
- smbios3_table = NULL;
+ status = LibGetSystemConfigurationTable(&Smbios3TableGuid, &smbios_table);
+ if (EFI_ERROR(status)) {
+ status = LibGetSystemConfigurationTable(&SmbiosTableGuid, &smbios_table);
+ }
+ if (EFI_ERROR(status)) {
+ smbios_table = NULL;
+ }
return 0;
}
@@ -103,8 +108,8 @@ efi_acpi_get_model(void)
memset(model_buf, 0, sizeof(model_buf));
- if (smbios3_table != NULL) {
- smbios_init(smbios3_table);
+ if (smbios_table != NULL) {
+ smbios_init(smbios_table);
buf = model_buf;
smbios.cookie = 0;
@@ -136,7 +141,7 @@ efi_acpi_show(void)
rsdp->oemid[0], rsdp->oemid[1], rsdp->oemid[2],
rsdp->oemid[3], rsdp->oemid[4], rsdp->oemid[5]);
- if (smbios3_table)
+ if (smbios_table)
printf("SMBIOS: %s\n", efi_acpi_get_model());
}
@@ -166,8 +171,8 @@ efi_acpi_create_fdt(void)
fdt_add_subnode(fdt, fdt_path_offset(fdt, "/"), "chosen");
fdt_setprop_u64(fdt, fdt_path_offset(fdt, "/chosen"), "netbsd,acpi-root-table", (uint64_t)(uintptr_t)acpi_root);
- if (smbios3_table)
- fdt_setprop_u64(fdt, fdt_path_offset(fdt, "/chosen"), "netbsd,smbios-table", (uint64_t)(uintptr_t)smbios3_table);
+ if (smbios_table)
+ fdt_setprop_u64(fdt, fdt_path_offset(fdt, "/chosen"), "netbsd,smbios-table", (uint64_t)(uintptr_t)smbios_table);
fdt_add_subnode(fdt, fdt_path_offset(fdt, "/"), "acpi");
fdt_setprop_string(fdt, fdt_path_offset(fdt, "/acpi"), "compatible", "netbsd,acpi");
Index: src/sys/stand/efiboot/smbios.c
diff -u src/sys/stand/efiboot/smbios.c:1.2 src/sys/stand/efiboot/smbios.c:1.3
--- src/sys/stand/efiboot/smbios.c:1.2 Fri Dec 27 09:45:27 2019
+++ src/sys/stand/efiboot/smbios.c Fri Jul 23 21:33:00 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: smbios.c,v 1.2 2019/12/27 09:45:27 msaitoh Exp $ */
+/* $NetBSD: smbios.c,v 1.3 2021/07/23 21:33:00 jmcneill Exp $ */
/*
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -82,7 +82,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smbios.c,v 1.2 2019/12/27 09:45:27 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smbios.c,v 1.3 2021/07/23 21:33:00 jmcneill Exp $");
#include <sys/param.h>
@@ -91,8 +91,22 @@ __KERNEL_RCSID(0, "$NetBSD: smbios.c,v 1
struct smbios_entry smbios_entry;
-void
-smbios_init(uint8_t *p)
+static void
+smbios2_init(uint8_t *p)
+{
+ const struct smbhdr *sh = (const struct smbhdr *)p;
+
+ smbios_entry.addr = (void *)(uintptr_t)sh->addr;
+ smbios_entry.len = sh->size;
+ smbios_entry.rev = 0;
+ smbios_entry.mjr = sh->majrev;
+ smbios_entry.min = sh->minrev;
+ smbios_entry.doc = 0;
+ smbios_entry.count = sh->count;
+}
+
+static void
+smbios3_init(uint8_t *p)
{
const struct smb3hdr *sh = (const struct smb3hdr *)p;
@@ -105,6 +119,16 @@ smbios_init(uint8_t *p)
smbios_entry.count = UINT16_MAX;
}
+void
+smbios_init(uint8_t *p)
+{
+ if (memcmp(p, "_SM3_", 5) == 0) {
+ smbios3_init(p);
+ } else if (memcmp(p, "_SM_", 4) == 0) {
+ smbios2_init(p);
+ }
+}
+
/*
* smbios_find_table() takes a caller supplied smbios struct type and
* a pointer to a handle (struct smbtable) returning one if the structure
@@ -121,6 +145,10 @@ smbios_find_table(uint8_t type, struct s
struct smbtblhdr *hdr;
int ret = 0, tcount = 1;
+ if (smbios_entry.addr == 0) {
+ return 0;
+ }
+
va = smbios_entry.addr;
end = va + smbios_entry.len;
@@ -173,6 +201,10 @@ smbios_get_string(struct smbtable *st, u
char *ret = NULL;
int i;
+ if (smbios_entry.addr == 0) {
+ return NULL;
+ }
+
va = (uint8_t *)st->hdr + st->hdr->size;
end = smbios_entry.addr + smbios_entry.len;
for (i = 1; va < end && i < indx && *va; i++)