Source-Changes-HG archive

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

[src/trunk]: src/sys/arch This change modifies the mainbus(4) entry point for...



details:   https://anonhg.NetBSD.org/src/rev/58e86ef776c3
branches:  trunk
changeset: 446840:58e86ef776c3
user:      cherry <cherry%NetBSD.org@localhost>
date:      Sat Dec 22 07:45:58 2018 +0000

description:
This change modifies the mainbus(4) entry point for all x86 sub-archs
in the following way:

i) It provides a unified entry point in
   x86/x86/mainbus.c:mainbus_attach()
ii) It carves out the preliminary bus attachment sequence that is
   common to all sub-archs into
   x86/x86/mainbus.c: x86_cpubus_attach()
iii) It consolidates the remaining pathways as internal callee
   functions so that these may be called piecemeal if required. A
   special usecase of this is XEN PVHVM which may need to call the
   native configure path, the xen configure path, or both.
iv) It moves the driver private data structures from
   i386/i386_mainbus.c to an x86/ level one. This allows for other
   sub-arch's to do similar, if needed. (They do not at the moment).
v) For dom0 kernels, it enables 'acpi0 at mainbus?' and
   'acpi0 at hypervisorbus'. This serves two purposes:
   a) To demonstrate the possibility of dynamic configuration tree
      traversal ordering changes.
   b) To allow for the common acpi_check(self, "acpibus") call in
   x86/mainbus.c to not barf when it is called from the dom0 attach
   path. We allow for the acpi0 device to be a child of mainbus with
   the changes to amd64/conf/XEN3_DOM0 and i386/conf/XEN3PAE_DOM0
   without actually probing further in the code. This path will later
   be pursued in a PVHVM boot codepath.

There should be no operative changes with this change. If there are,
please complain loudly.

diffstat:

 sys/arch/amd64/amd64/amd64_mainbus.c |  104 +------------
 sys/arch/amd64/conf/XEN3_DOM0        |    8 +-
 sys/arch/amd64/conf/files.amd64      |    3 +-
 sys/arch/i386/conf/XEN3PAE_DOM0      |    6 +-
 sys/arch/i386/conf/files.i386        |    3 +-
 sys/arch/i386/i386/i386_mainbus.c    |  139 +++---------------
 sys/arch/x86/include/autoconf.h      |   18 ++-
 sys/arch/x86/x86/mainbus.c           |  255 +++++++++++++++++++++++++++++++++++
 sys/arch/xen/conf/files.xen          |    5 +-
 sys/arch/xen/x86/autoconf.c          |    7 +-
 sys/arch/xen/x86/xen_mainbus.c       |   92 +----------
 11 files changed, 344 insertions(+), 296 deletions(-)

diffs (truncated from 963 to 300 lines):

diff -r c390eb482c59 -r 58e86ef776c3 sys/arch/amd64/amd64/amd64_mainbus.c
--- a/sys/arch/amd64/amd64/amd64_mainbus.c      Sat Dec 22 06:59:27 2018 +0000
+++ b/sys/arch/amd64/amd64/amd64_mainbus.c      Sat Dec 22 07:45:58 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: amd64_mainbus.c,v 1.2 2018/12/22 06:59:27 cherry Exp $ */
+/*     $NetBSD: amd64_mainbus.c,v 1.3 2018/12/22 07:45:58 cherry Exp $ */
 /*     NetBSD: mainbus.c,v 1.39 2018/12/02 08:19:44 cherry Exp         */
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: amd64_mainbus.c,v 1.2 2018/12/22 06:59:27 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: amd64_mainbus.c,v 1.3 2018/12/22 07:45:58 cherry Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -83,15 +83,11 @@
  * XXXfvdl ACPI
  */
 
-int    mainbus_match(device_t, cfdata_t, void *);
-void   mainbus_attach(device_t, device_t, void *);
+int    amd64_mainbus_match(device_t, cfdata_t, void *);
+void   amd64_mainbus_attach(device_t, device_t, void *);
+int    amd64_mainbus_print(void *, const char *);
 
-CFATTACH_DECL_NEW(mainbus, 0,
-    mainbus_match, mainbus_attach, NULL, NULL);
-
-int    mainbus_print(void *, const char *);
-
-union mainbus_attach_args {
+union amd64_mainbus_attach_args {
        const char *mba_busname;                /* first elem of all */
        struct pcibus_attach_args mba_pba;
        struct isabus_attach_args mba_iba;
@@ -128,8 +124,8 @@
 int mp_isa_bus = -1;
 int mp_eisa_bus = -1;
 
-bool acpi_present;
-bool mpacpi_active;
+extern bool acpi_present;
+extern bool mpacpi_active;
 
 # ifdef MPVERBOSE
 #  if MPVERBOSE > 0
@@ -147,7 +143,7 @@
  * Probe for the mainbus; always succeeds.
  */
 int
-mainbus_match(device_t parent, cfdata_t match, void *aux)
+amd64_mainbus_match(device_t parent, cfdata_t match, void *aux)
 {
 
        return 1;
@@ -157,82 +153,10 @@
  * Attach the mainbus.
  */
 void
-mainbus_attach(device_t parent, device_t self, void *aux)
+amd64_mainbus_attach(device_t parent, device_t self, void *aux)
 {
 #if NPCI > 0 || NACPICA > 0 || NIPMI > 0
-       union mainbus_attach_args mba;
-#endif
-#if NPCI > 0
-       int mode;
-#endif
-#ifdef MPBIOS
-       int mpbios_present = 0;
-#endif
-       int numcpus = 0;
-#if defined(PCI_BUS_FIXUP)
-       int pci_maxbus = 0;
-#endif
-
-       aprint_naive("\n");
-       aprint_normal("\n");
-
-#ifdef MPBIOS
-       mpbios_present = mpbios_probe(self);
-#endif
-
-#if NPCI > 0
-#ifdef __HAVE_PCI_MSI_MSIX
-       msipic_init();
-#endif
-
-       /*
-        * ACPI needs to be able to access PCI configuration space.
-        */
-       mode = pci_mode_detect();
-#if defined(PCI_BUS_FIXUP)
-       if (mode != 0) {
-               pci_maxbus = pci_bus_fixup(NULL, 0);
-               aprint_debug("PCI bus max, after pci_bus_fixup: %i\n",
-                   pci_maxbus);
-#if defined(PCI_ADDR_FIXUP)
-               pciaddr.extent_port = NULL;
-               pciaddr.extent_mem = NULL;
-               pci_addr_fixup(NULL, pci_maxbus);
-#endif
-       }
-#endif
-#endif
-
-#if NACPICA > 0
-       if ((boothowto & RB_MD2) == 0 && acpi_check(self, "acpibus"))
-               acpi_present = acpi_probe() != 0;
-       /*
-        * First, see if the MADT contains CPUs, and possibly I/O APICs.
-        * Building the interrupt routing structures can only
-        * be done later (via a callback).
-        */
-       if (acpi_present)
-               mpacpi_active = mpacpi_scan_apics(self, &numcpus) != 0;
-
-       if (!mpacpi_active) {
-#endif         
-#ifdef MPBIOS
-               if (mpbios_present)
-                       mpbios_scan(self, &numcpus);
-               else
-#endif
-               if (numcpus == 0) {
-                       struct cpu_attach_args caa;
-                        
-                       memset(&caa, 0, sizeof(caa));
-                       caa.cpu_number = 0;
-                       caa.cpu_role = CPU_ROLE_SP;
-                       caa.cpu_func = 0;
-                        
-                       config_found_ia(self, "cpubus", &caa, mainbus_print);
-               }
-#if NACPICA > 0                
-       }
+       union amd64_mainbus_attach_args mba;
 #endif
 
 #if NISADMA > 0 && NACPICA > 0
@@ -268,7 +192,7 @@
 #endif
 
 #if NPCI > 0
-       if (mode != 0) {
+       if (pci_mode_detect() != 0) {
                int npcibus = 0;
 
                mba.mba_pba.pba_iot = x86_bus_space_io;
@@ -316,9 +240,9 @@
 }
 
 int
-mainbus_print(void *aux, const char *pnp)
+amd64_mainbus_print(void *aux, const char *pnp)
 {
-       union mainbus_attach_args *mba = aux;
+       union amd64_mainbus_attach_args *mba = aux;
 
        if (pnp)
                aprint_normal("%s at %s", mba->mba_busname, pnp);
diff -r c390eb482c59 -r 58e86ef776c3 sys/arch/amd64/conf/XEN3_DOM0
--- a/sys/arch/amd64/conf/XEN3_DOM0     Sat Dec 22 06:59:27 2018 +0000
+++ b/sys/arch/amd64/conf/XEN3_DOM0     Sat Dec 22 07:45:58 2018 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: XEN3_DOM0,v 1.160 2018/12/12 06:29:36 maxv Exp $
+# $NetBSD: XEN3_DOM0,v 1.161 2018/12/22 07:45:58 cherry Exp $
 
 include        "arch/amd64/conf/std.xen"
 
@@ -10,7 +10,7 @@
 #options       UVMHIST_PRINT
 #options       SYSCALL_DEBUG
 
-#ident         "XEN3_DOM0-$Revision: 1.160 $"
+#ident         "XEN3_DOM0-$Revision: 1.161 $"
 
 maxusers       32              # estimated number of users
 
@@ -202,7 +202,9 @@
 xencons*       at hypervisor?          # Xen virtual console
 balloon*       at xenbus?              # Xen balloon device
 
-acpi0          at hypervisor?
+acpi0          at hypervisor?          # ACPI access in PV mode
+acpi0          at mainbus?             # ACPI access in PVH(VM) mode
+
 #options       ACPI_ACTIVATE_DEV       # If set, activate inactive devices
 options        ACPI_SCANPCI            # find PCI roots using ACPI
 #options       ACPICA_PEDANTIC         # force strict conformance to the Spec.
diff -r c390eb482c59 -r 58e86ef776c3 sys/arch/amd64/conf/files.amd64
--- a/sys/arch/amd64/conf/files.amd64   Sat Dec 22 06:59:27 2018 +0000
+++ b/sys/arch/amd64/conf/files.amd64   Sat Dec 22 07:45:58 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.amd64,v 1.109 2018/12/22 06:33:36 cherry Exp $
+#      $NetBSD: files.amd64,v 1.110 2018/12/22 07:45:58 cherry Exp $
 #
 # new style config file for amd64 architecture
 #
@@ -95,6 +95,7 @@
 device mainbus: isabus, pcibus, bios32, acpibus, cpubus, ioapicbus, ipmibus
 attach mainbus at root
 file   arch/amd64/amd64/amd64_mainbus.c        mainbus
+file   arch/x86/x86/mainbus.c                  mainbus
 
 #
 # PCI-only drivers
diff -r c390eb482c59 -r 58e86ef776c3 sys/arch/i386/conf/XEN3PAE_DOM0
--- a/sys/arch/i386/conf/XEN3PAE_DOM0   Sat Dec 22 06:59:27 2018 +0000
+++ b/sys/arch/i386/conf/XEN3PAE_DOM0   Sat Dec 22 07:45:58 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: XEN3PAE_DOM0,v 1.9 2018/12/12 06:29:37 maxv Exp $
+#      $NetBSD: XEN3PAE_DOM0,v 1.10 2018/12/22 07:45:58 cherry Exp $
 #
 #      XEN3_0: Xen 3.0 domain0 kernel
 
@@ -877,7 +877,9 @@
 # pciback.hide=(00:1a.0)(00:1a.1)(00:1a.7)
 pciback* at pci?                       #pci backend device
 
-acpi0          at hypervisor?
+acpi0          at hypervisor?          # ACPI access in PV mode
+acpi0          at mainbus?             # ACPI access in PVH(VM) mode
+
 options        MPBIOS
 #options       MPDEBUG
 #options       MPVERBOSE
diff -r c390eb482c59 -r 58e86ef776c3 sys/arch/i386/conf/files.i386
--- a/sys/arch/i386/conf/files.i386     Sat Dec 22 06:59:27 2018 +0000
+++ b/sys/arch/i386/conf/files.i386     Sat Dec 22 07:45:58 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.i386,v 1.398 2018/12/22 06:33:36 cherry Exp $
+#      $NetBSD: files.i386,v 1.399 2018/12/22 07:45:58 cherry Exp $
 #
 # new style config file for i386 architecture
 #
@@ -130,6 +130,7 @@
        bioscall
 attach mainbus at root
 file   arch/i386/i386/i386_mainbus.c   mainbus
+file   arch/x86/x86/mainbus.c          mainbus
 
 #
 # PCI-only drivers
diff -r c390eb482c59 -r 58e86ef776c3 sys/arch/i386/i386/i386_mainbus.c
--- a/sys/arch/i386/i386/i386_mainbus.c Sat Dec 22 06:59:27 2018 +0000
+++ b/sys/arch/i386/i386/i386_mainbus.c Sat Dec 22 07:45:58 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i386_mainbus.c,v 1.2 2018/12/22 06:59:27 cherry Exp $  */
+/*     $NetBSD: i386_mainbus.c,v 1.3 2018/12/22 07:45:58 cherry Exp $  */
 /*     NetBSD: mainbus.c,v 1.104 2018/12/02 08:19:44 cherry Exp        */
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i386_mainbus.c,v 1.2 2018/12/22 06:59:27 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i386_mainbus.c,v 1.3 2018/12/22 07:45:58 cherry Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -76,6 +76,8 @@
 #include <dev/mca/mcavar.h>
 #endif
 
+#include <x86/autoconf.h>
+
 #if NIPMI > 0
 #include <x86/ipmivar.h>
 #endif
@@ -92,28 +94,12 @@
 #endif /* __HAVE_PCI_MSI_MSIX */
 #endif
 
-void   mainbus_childdetached(device_t, device_t);
-int    mainbus_match(device_t, cfdata_t, void *);
-void   mainbus_attach(device_t, device_t, void *);
-
-static int     mainbus_rescan(device_t, const char *, const int *);
+void   i386_mainbus_childdetached(device_t, device_t);
+int    i386_mainbus_match(device_t, cfdata_t, void *);
+void   i386_mainbus_attach(device_t, device_t, void *);
+int    i386_mainbus_rescan(device_t, const char *, const int *);
 
-struct mainbus_softc {
-       device_t        sc_acpi;
-       device_t        sc_dev;
-       device_t        sc_ipmi;
-       device_t        sc_pci;
-       device_t        sc_mca;
-       device_t        sc_pnpbios;
-};
-
-CFATTACH_DECL2_NEW(mainbus, sizeof(struct mainbus_softc),
-    mainbus_match, mainbus_attach, NULL, NULL, mainbus_rescan,
-    mainbus_childdetached);



Home | Main Index | Thread Index | Old Index