Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86/pci tidy up.



details:   https://anonhg.NetBSD.org/src/rev/41dc7c64dc51
branches:  trunk
changeset: 795866:41dc7c64dc51
user:      christos <christos%NetBSD.org@localhost>
date:      Tue May 06 18:54:34 2014 +0000

description:
tidy up.

diffstat:

 sys/arch/x86/pci/pci_machdep.c |  32 ++++++++++++++++++--------------
 1 files changed, 18 insertions(+), 14 deletions(-)

diffs (74 lines):

diff -r 39dffa81c952 -r 41dc7c64dc51 sys/arch/x86/pci/pci_machdep.c
--- a/sys/arch/x86/pci/pci_machdep.c    Tue May 06 18:17:22 2014 +0000
+++ b/sys/arch/x86/pci/pci_machdep.c    Tue May 06 18:54:34 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_machdep.c,v 1.66 2014/05/06 09:01:26 sborrill Exp $        */
+/*     $NetBSD: pci_machdep.c,v 1.67 2014/05/06 18:54:34 christos Exp $        */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.66 2014/05/06 09:01:26 sborrill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.67 2014/05/06 18:54:34 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -526,7 +526,6 @@
        int i;
        pcireg_t idreg;
        extern char cpu_brand_string[];
-       const char *system_vendor, *system_product;
 
        if (pci_mode != -1)
                return pci_mode;
@@ -550,22 +549,28 @@
                idreg = pci_conf_read(NULL, t, PCI_ID_REG); /* needs "pci_mode" */
                if (idreg == pcim1_quirk_tbl[i].id) {
 #ifdef DEBUG
-                       printf("known mode 1 PCI chipset (%08x)\n",
-                              idreg);
+                       printf("%s: known mode 1 PCI chipset (%08x)\n",
+                           __func__, idreg);
 #endif
                        return (pci_mode);
                }
        }
 
-       system_vendor = pmf_get_platform("system-vendor");
-       system_product = pmf_get_platform("system-product");
-        if (memcmp(cpu_brand_string, "QEMU", 4) == 0 ||
-           (system_vendor != NULL && system_product != NULL &&
-            !strcmp(system_vendor, "Xen") &&
-            !strcmp(system_product, "HVM domU"))) {
+       const char *reason, *system_vendor, *system_product;
+       if (memcmp(cpu_brand_string, "QEMU", 4) == 0)
                /* PR 45671, https://bugs.launchpad.net/qemu/+bug/897771 */
+               reason = "QEMU";
+       else if ((system_vendor = pmf_get_platform("system-vendor")) != NULL &&
+           strcmp(system_vendor, "Xen") == 0 &&
+           (system_product = pmf_get_platform("system-product")) != NULL &&
+           strcmp(system_product, "HVM domU") == 0)
+               reason = "Xen";
+       else
+               reason = NULL;
+
+       if (reason) {
 #ifdef DEBUG
-               printf("forcing PCI mode 1 for QEMU\n");
+               printf("%s: forcing PCI mode 1 for %s\n", __func__, reason);
 #endif
                return (pci_mode);
        }
@@ -581,8 +586,7 @@
        val = inl(PCI_MODE1_ADDRESS_REG);
        if ((val & 0x80fffffc) != PCI_MODE1_ENABLE) {
 #ifdef DEBUG
-               printf("pci_mode_detect: mode 1 enable failed (%x)\n",
-                      val);
+               printf("%s: mode 1 enable failed (%x)\n", __func__, val);
 #endif
                goto not1;
        }



Home | Main Index | Thread Index | Old Index