Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/stand/efiboot efiboot: Add support for SMBIOS 2.x tables.
details: https://anonhg.NetBSD.org/src/rev/acbae51e59ae
branches: trunk
changeset: 1022518:acbae51e59ae
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Fri Jul 23 21:33:00 2021 +0000
description:
efiboot: Add support for SMBIOS 2.x tables.
diffstat:
sys/stand/efiboot/efiacpi.c | 25 +++++++++++++++----------
sys/stand/efiboot/smbios.c | 40 ++++++++++++++++++++++++++++++++++++----
2 files changed, 51 insertions(+), 14 deletions(-)
diffs (152 lines):
diff -r 02d458342e35 -r acbae51e59ae sys/stand/efiboot/efiacpi.c
--- a/sys/stand/efiboot/efiacpi.c Fri Jul 23 20:18:24 2021 +0000
+++ b/sys/stand/efiboot/efiacpi.c Fri Jul 23 21:33:00 2021 +0000
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
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");
diff -r 02d458342e35 -r acbae51e59ae sys/stand/efiboot/smbios.c
--- a/sys/stand/efiboot/smbios.c Fri Jul 23 20:18:24 2021 +0000
+++ b/sys/stand/efiboot/smbios.c Fri Jul 23 21:33:00 2021 +0000
@@ -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 @@
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_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 @@
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 @@
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++)
Home |
Main Index |
Thread Index |
Old Index