Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/i386/pci Add pci_bridge_foreach ().



details:   https://anonhg.NetBSD.org/src/rev/0eda4ad3a925
branches:  trunk
changeset: 521050:0eda4ad3a925
user:      uch <uch%NetBSD.org@localhost>
date:      Tue Jan 22 15:07:27 2002 +0000

description:
Add pci_bridge_foreach ().

diffstat:

 sys/arch/i386/pci/pcibios.c |  37 +++++++++++++++++++++++++++++++++++--
 sys/arch/i386/pci/pcibios.h |   5 ++++-
 2 files changed, 39 insertions(+), 3 deletions(-)

diffs (81 lines):

diff -r 1431f353b790 -r 0eda4ad3a925 sys/arch/i386/pci/pcibios.c
--- a/sys/arch/i386/pci/pcibios.c       Tue Jan 22 13:50:53 2002 +0000
+++ b/sys/arch/i386/pci/pcibios.c       Tue Jan 22 15:07:27 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pcibios.c,v 1.7 2001/11/15 07:03:35 lukem Exp $        */
+/*     $NetBSD: pcibios.c,v 1.8 2002/01/22 15:07:27 uch Exp $  */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pcibios.c,v 1.7 2001/11/15 07:03:35 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcibios.c,v 1.8 2002/01/22 15:07:27 uch Exp $");
 
 #include "opt_pcibios.h"
 
@@ -126,6 +126,12 @@
 #define        PCI_IRQ_TABLE_START     0xf0000
 #define        PCI_IRQ_TABLE_END       0xfffff
 
+static void pci_bridge_hook(pci_chipset_tag_t, pcitag_t, void *);
+struct pci_bridge_hook_arg {
+       void (*func)(pci_chipset_tag_t, pcitag_t, void *);
+       void *arg;
+};
+
 void
 pcibios_init()
 {
@@ -552,3 +558,30 @@
                }
        }
 }
+
+void
+pci_bridge_foreach(pci_chipset_tag_t pc, int minbus, int maxbus,
+    void (*func)(pci_chipset_tag_t, pcitag_t, void *), void *ctx)
+{
+       struct pci_bridge_hook_arg bridge_hook;
+
+       bridge_hook.func = func;
+       bridge_hook.arg = ctx;
+       
+       pci_device_foreach_min(pc, minbus, maxbus, pci_bridge_hook,
+           &bridge_hook);
+}
+
+void
+pci_bridge_hook(pci_chipset_tag_t pc, pcitag_t tag, void *ctx)
+{
+       struct pci_bridge_hook_arg *bridge_hook = (void *)ctx;
+       pcireg_t reg;
+
+       reg = pci_conf_read(pc, tag, PCI_CLASS_REG);
+       if (PCI_CLASS(reg) == PCI_CLASS_BRIDGE &&
+           (PCI_SUBCLASS(reg) == PCI_SUBCLASS_BRIDGE_PCI ||
+               PCI_SUBCLASS(reg) == PCI_SUBCLASS_BRIDGE_CARDBUS)) {
+               (*bridge_hook->func)(pc, tag, bridge_hook->arg);
+       }
+}
diff -r 1431f353b790 -r 0eda4ad3a925 sys/arch/i386/pci/pcibios.h
--- a/sys/arch/i386/pci/pcibios.h       Tue Jan 22 13:50:53 2002 +0000
+++ b/sys/arch/i386/pci/pcibios.h       Tue Jan 22 15:07:27 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pcibios.h,v 1.4 2001/07/06 18:04:58 mcr Exp $  */
+/*     $NetBSD: pcibios.h,v 1.5 2002/01/22 15:07:27 uch Exp $  */
 
 /*
  * Copyright (c) 1999, by UCHIYAMA Yasushi
@@ -97,6 +97,9 @@
                                 void (*) (pci_chipset_tag_t, pcitag_t, void*),
                                 void *context));
 
+void pci_bridge_foreach(pci_chipset_tag_t, int, int,
+    void (*) (pci_chipset_tag_t, pcitag_t, void *), void *);
+
 #ifdef PCIBIOSVERBOSE
 extern int pcibiosverbose;
 



Home | Main Index | Thread Index | Old Index