Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc64 use pci_bus_devorder() and pci_dev_funcorder()



details:   https://anonhg.NetBSD.org/src/rev/b3309b337535
branches:  trunk
changeset: 504425:b3309b337535
user:      mrg <mrg%NetBSD.org@localhost>
date:      Fri Mar 02 06:34:06 2001 +0000

description:
use pci_bus_devorder() and pci_dev_funcorder()

diffstat:

 sys/arch/sparc64/dev/pci_machdep.c     |  72 +++++++++++++++++++++++++++++++++-
 sys/arch/sparc64/include/pci_machdep.h |  15 ++++++-
 2 files changed, 84 insertions(+), 3 deletions(-)

diffs (133 lines):

diff -r efe8005d7888 -r b3309b337535 sys/arch/sparc64/dev/pci_machdep.c
--- a/sys/arch/sparc64/dev/pci_machdep.c        Fri Mar 02 06:24:17 2001 +0000
+++ b/sys/arch/sparc64/dev/pci_machdep.c        Fri Mar 02 06:34:06 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_machdep.c,v 1.18 2001/01/19 21:25:19 martin Exp $  */
+/*     $NetBSD: pci_machdep.c,v 1.19 2001/03/02 06:34:06 mrg Exp $     */
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -58,6 +58,9 @@
 #include <dev/pci/pcivar.h>
 #include <dev/pci/pcireg.h>
 
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_pci.h>
+
 #include <sparc64/dev/iommureg.h>
 #include <sparc64/dev/iommuvar.h>
 #include <sparc64/dev/psychoreg.h>
@@ -251,6 +254,73 @@
        return 32;
 }
 
+#ifdef __PCI_BUS_DEVORDER
+int
+pci_bus_devorder(pc, busno, devs)
+       pci_chipset_tag_t pc;
+       int busno;
+       char *devs;
+{
+       struct ofw_pci_register reg0;
+       int node, len, device, i = 0;
+       u_int32_t done = 0;
+
+       for (node = OF_child(pc->node); node; node = OF_peer(node)) {
+               len = OF_getproplen(node, "reg");
+               if (len < sizeof(reg0))
+                       continue;
+               if (OF_getprop(node, "reg", (void *)&reg0, sizeof(reg0)) != len)
+                       panic("pci_probe_bus: OF_getprop len botch");
+
+               device = OFW_PCI_PHYS_HI_DEVICE(reg0.phys_hi);
+
+               if (done & (1 << device))
+                       continue;
+
+               devs[i++] = device;
+               done |= 1 << device;
+               if (i == 32)
+                       break;
+       }
+       if (i < 32)
+               devs[i] = -1;
+
+       return i;
+}
+#endif
+
+#ifdef __PCI_DEV_FUNCORDER
+int
+pci_dev_funcorder(pc, busno, device, funcs)
+       pci_chipset_tag_t pc;
+       int busno;
+       int device;
+       char *funcs;
+{
+       struct ofw_pci_register reg0;
+       int node, len, i = 0;
+
+       for (node = OF_child(pc->node); node; node = OF_peer(node)) {
+               len = OF_getproplen(node, "reg");
+               if (len < sizeof(reg0))
+                       continue;
+               if (OF_getprop(node, "reg", (void *)&reg0, sizeof(reg0)) != len)
+                       panic("pci_probe_bus: OF_getprop len botch");
+
+               if (device != OFW_PCI_PHYS_HI_DEVICE(reg0.phys_hi))
+                       continue;
+
+               funcs[i++] = OFW_PCI_PHYS_HI_FUNCTION(reg0.phys_hi);
+               if (i == 8)
+                       break;
+       }
+       if (i < 8)
+               funcs[i] = -1;
+
+       return i;
+}
+#endif
+
 pcitag_t
 pci_make_tag(pc, b, d, f)
        pci_chipset_tag_t pc;
diff -r efe8005d7888 -r b3309b337535 sys/arch/sparc64/include/pci_machdep.h
--- a/sys/arch/sparc64/include/pci_machdep.h    Fri Mar 02 06:24:17 2001 +0000
+++ b/sys/arch/sparc64/include/pci_machdep.h    Fri Mar 02 06:34:06 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep.h,v 1.5 2000/12/28 22:59:10 sommerfeld Exp $ */
+/* $NetBSD: pci_machdep.h,v 1.6 2001/03/02 06:34:06 mrg Exp $ */
 
 /*
  * Copyright (c) 1999 Matthew R. Green
@@ -32,6 +32,12 @@
 #define _MACHINE_PCI_MACHDEP_H_
 
 /*
+ * We want to contro both device & function probe order.
+ */
+#define                __PCI_BUS_DEVORDER
+#define                __PCI_DEV_FUNCORDER
+
+/*
  * Forward declarations.
  */
 struct pci_attach_args;
@@ -48,11 +54,16 @@
        void                    *cookie;        /* psycho_pbm, but sssh! */
        int                     node;           /* OFW node */
        int                     busno;          /* PCI bus number */
-       /* do we need any more here? */
 };
 
 void           pci_attach_hook(struct device *, struct device *,
                                     struct pcibus_attach_args *);
+#ifdef __PCI_BUS_DEVORDER
+int            pci_bus_devorder(pci_chipset_tag_t, int, char *);
+#endif
+#ifdef __PCI_DEV_FUNCORDER
+int            pci_dev_funcorder(pci_chipset_tag_t, int, int, char *);
+#endif
 int            pci_bus_maxdevs(pci_chipset_tag_t, int);
 pcitag_t       pci_make_tag(pci_chipset_tag_t, int, int, int);
 pcireg_t       pci_conf_read(pci_chipset_tag_t, pcitag_t, int);



Home | Main Index | Thread Index | Old Index