Source-Changes-HG archive

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

[src/trunk]: src/sys/dev move the creation of machdep.smbios into platform_in...



details:   https://anonhg.NetBSD.org/src/rev/8dcc4eb086e2
branches:  trunk
changeset: 372432:8dcc4eb086e2
user:      mrg <mrg%NetBSD.org@localhost>
date:      Fri Nov 25 22:17:20 2022 +0000

description:
move the creation of machdep.smbios into platform_init().

"dmidecode -d /dev/smbios" now works on x86.  also tested on arm64 (lx2k.)

diffstat:

 sys/arch/arm/fdt/acpi_fdt.c |  32 ++------------------------------
 sys/dev/smbios_platform.c   |  18 ++++++++++++++++--
 2 files changed, 18 insertions(+), 32 deletions(-)

diffs (110 lines):

diff -r 8833b8ce8a04 -r 8dcc4eb086e2 sys/arch/arm/fdt/acpi_fdt.c
--- a/sys/arch/arm/fdt/acpi_fdt.c       Fri Nov 25 16:15:39 2022 +0000
+++ b/sys/arch/arm/fdt/acpi_fdt.c       Fri Nov 25 22:17:20 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_fdt.c,v 1.23 2021/08/07 16:18:43 thorpej Exp $ */
+/* $NetBSD: acpi_fdt.c,v 1.24 2022/11/25 22:17:20 mrg 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.23 2021/08/07 16:18:43 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.24 2022/11/25 22:17:20 mrg Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -41,7 +41,6 @@
 #include <sys/lwp.h>
 #include <sys/kmem.h>
 #include <sys/queue.h>
-#include <sys/sysctl.h>
 
 #include <dev/fdt/fdtvar.h>
 
@@ -63,7 +62,6 @@
 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;
 
@@ -124,8 +122,6 @@
        aa.aa_dmat = NULL;
        aa.aa_dmat64 = NULL;
        config_found(self, &aa, NULL, CFARGS_NONE);
-
-       acpi_fdt_sysctl_init();
 }
 
 static void
@@ -226,27 +222,3 @@
                AcpiOsUnmapMemory(sh, sizeof(*sh));
        }
 }
-
-static void
-acpi_fdt_sysctl_init(void)
-{
-       const struct sysctlnode *rnode;
-       int error;
-
-       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) {
-               return;
-       }
-
-       (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 8833b8ce8a04 -r 8dcc4eb086e2 sys/dev/smbios_platform.c
--- a/sys/dev/smbios_platform.c Fri Nov 25 16:15:39 2022 +0000
+++ b/sys/dev/smbios_platform.c Fri Nov 25 22:17:20 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: smbios_platform.c,v 1.1 2021/07/21 23:26:15 jmcneill Exp $ */
+/* $NetBSD: smbios_platform.c,v 1.2 2022/11/25 22:17:20 mrg Exp $ */
 
 /*-
  * Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
 #include "isa.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smbios_platform.c,v 1.1 2021/07/21 23:26:15 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smbios_platform.c,v 1.2 2022/11/25 22:17:20 mrg Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -76,6 +76,20 @@
        struct smbios_slot *pslot;
        int nisa, nother;
 
+       if (smbios_entry.hdrphys) {
+               int err;
+
+               err = sysctl_createv(NULL, 0, NULL, NULL,
+                   CTLFLAG_PERMANENT | CTLFLAG_READONLY | CTLFLAG_HEX |
+                   CTLFLAG_IMMEDIATE, CTLTYPE_QUAD,
+                   "smbios", SYSCTL_DESCR("SMBIOS table pointer"),
+                   NULL, smbios_entry.hdrphys, 0, 0,
+                   CTL_MACHDEP, CTL_CREATE, CTL_EOL);
+               if (err != 0 && err != EEXIST)
+                       printf("platform: sysctl_createv "
+                           "(machdep.smbios) failed, err = %d\n", err);
+       }
+       
        smbios.cookie = 0;
        if (smbios_find_table(SMBIOS_TYPE_SYSTEM, &smbios)) {
                psys = smbios.tblhdr;



Home | Main Index | Thread Index | Old Index