Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/fdt Expose SMBIOS tables using sysctl machdep.d...



details:   https://anonhg.NetBSD.org/src/rev/af974d372846
branches:  trunk
changeset: 1022492:af974d372846
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Thu Jul 22 00:47:55 2021 +0000

description:
Expose SMBIOS tables using sysctl machdep.dmi.*, same as x86.

diffstat:

 sys/arch/arm/fdt/acpi_fdt.c |  72 ++++++++++++++++++++++++++++++++++++--------
 sys/arch/arm/fdt/files.fdt  |   5 +-
 2 files changed, 62 insertions(+), 15 deletions(-)

diffs (153 lines):

diff -r c1fcf7560608 -r af974d372846 sys/arch/arm/fdt/acpi_fdt.c
--- a/sys/arch/arm/fdt/acpi_fdt.c       Wed Jul 21 23:26:15 2021 +0000
+++ b/sys/arch/arm/fdt/acpi_fdt.c       Thu Jul 22 00:47:55 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_fdt.c,v 1.19 2021/04/24 23:36:26 thorpej Exp $ */
+/* $NetBSD: acpi_fdt.c,v 1.20 2021/07/22 00:47:55 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -30,7 +30,7 @@
 #include "opt_efi.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.19 2021/04/24 23:36:26 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.20 2021/07/22 00:47:55 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -47,6 +47,7 @@
 
 #include <dev/acpi/acpivar.h>
 #include <dev/pci/pcivar.h>
+#include <dev/smbiosvar.h>
 
 #include <arm/arm/psci.h>
 
@@ -61,6 +62,7 @@
 
 static void    acpi_fdt_poweroff(device_t);
 
+static void    acpi_fdt_smbios_init(device_t);
 static void    acpi_fdt_sysctl_init(void);
 
 extern struct arm32_bus_dma_tag acpi_coherent_dma_tag;
@@ -89,18 +91,24 @@
 static void
 acpi_fdt_attach(device_t parent, device_t self, void *aux)
 {
+       extern void platform_init(void); /* XXX */
        struct fdt_attach_args * const faa = aux;
        struct acpibus_attach_args aa;
 
        aprint_naive("\n");
        aprint_normal("\n");
 
+       acpi_fdt_smbios_init(self);
+       platform_init();
+
        fdtbus_register_power_controller(self, faa->faa_phandle,
            &acpi_fdt_power_funcs);
 
        if (!acpi_probe())
                panic("ACPI subsystem failed to initialize");
 
+       platform_init();
+
        memset(&aa, 0, sizeof(aa));
 #if NPCI > 0
        aa.aa_pciflags =
@@ -133,26 +141,64 @@
 }
 
 static void
+acpi_fdt_smbios_init(device_t dev)
+{
+       struct smb3hdr *sh;
+       uint8_t *ptr;
+
+       const int chosen = OF_finddevice("/chosen");
+       if (chosen >= 0) {
+               of_getprop_uint64(chosen, "netbsd,smbios-table", &smbios_table);
+       }
+       if (smbios_table == 0) {
+               return;
+       }
+
+       sh = AcpiOsMapMemory(smbios_table, sizeof(*sh));
+       if (sh == NULL) {
+               return;
+       }
+       if (!smbios3_check_header((uint8_t *)sh)) {
+               AcpiOsUnmapMemory(sh, sizeof(*sh));
+               return;
+       }
+
+       ptr = AcpiOsMapMemory(sh->addr, sh->size);
+       if (ptr != NULL) {
+               smbios_entry.addr = ptr;
+               smbios_entry.len = sh->size;
+               smbios_entry.rev = sh->eprev;
+               smbios_entry.mjr = sh->majrev;
+               smbios_entry.min = sh->minrev;
+               smbios_entry.doc = sh->docrev;
+               smbios_entry.count = UINT16_MAX;
+
+               device_printf(dev, "SMBIOS rev. %d.%d.%d @ 0x%lx\n",
+                   sh->majrev, sh->minrev, sh->docrev, (u_long)sh->addr);
+       }
+       AcpiOsUnmapMemory(sh, sizeof(*sh));
+}
+
+static void
 acpi_fdt_sysctl_init(void)
 {
        const struct sysctlnode *rnode;
        int error;
 
-       const int chosen = OF_finddevice("/chosen");
-       if (chosen >= 0)
-               of_getprop_uint64(chosen, "netbsd,smbios-table", &smbios_table);
+       if (smbios_table == 0) {
+               return;
+       }
 
        error = sysctl_createv(NULL, 0, NULL, &rnode,
            CTLFLAG_PERMANENT, CTLTYPE_NODE, "machdep", NULL,
            NULL, 0, NULL, 0, CTL_MACHDEP, CTL_EOL);
-       if (error)
+       if (error) {
                return;
+       }
 
-       if (smbios_table != 0) {
-               (void)sysctl_createv(NULL, 0, &rnode, NULL,
-                   CTLFLAG_PERMANENT | CTLFLAG_READONLY | CTLFLAG_HEX, CTLTYPE_QUAD,
-                   "smbios", SYSCTL_DESCR("SMBIOS table pointer"),
-                   NULL, 0, &smbios_table, sizeof(smbios_table),
-                   CTL_CREATE, CTL_EOL);
-       }
+       (void)sysctl_createv(NULL, 0, &rnode, NULL,
+           CTLFLAG_PERMANENT | CTLFLAG_READONLY | CTLFLAG_HEX, CTLTYPE_QUAD,
+           "smbios", SYSCTL_DESCR("SMBIOS table pointer"),
+           NULL, 0, &smbios_table, sizeof(smbios_table),
+           CTL_CREATE, CTL_EOL);
 }
diff -r c1fcf7560608 -r af974d372846 sys/arch/arm/fdt/files.fdt
--- a/sys/arch/arm/fdt/files.fdt        Wed Jul 21 23:26:15 2021 +0000
+++ b/sys/arch/arm/fdt/files.fdt        Thu Jul 22 00:47:55 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.fdt,v 1.33 2021/04/26 14:44:16 thorpej Exp $
+# $NetBSD: files.fdt,v 1.34 2021/07/22 00:47:55 jmcneill Exp $
 
 include        "dev/pckbport/files.pckbport"
 
@@ -75,6 +75,7 @@
 attach genfb at fdt with plfb_fdt: fdt_display_timing
 file   arch/arm/fdt/plfb_fdt.c                 plfb_fdt
 
-device acpifdt: acpibus
+device acpifdt: acpibus, smbios
 attach acpifdt at fdt with acpi_fdt
 file   arch/arm/fdt/acpi_fdt.c                 acpi_fdt
+file   dev/smbios_platform.c                   acpi_fdt



Home | Main Index | Thread Index | Old Index