summaryrefslogtreecommitdiffstats
path: root/sys/pci/pcisupport.c
diff options
context:
space:
mode:
authordfr <dfr@FreeBSD.org>2000-08-28 21:48:13 +0000
committerdfr <dfr@FreeBSD.org>2000-08-28 21:48:13 +0000
commitdd8b44b3958fa67d802cbbec7c7d82f7fb476229 (patch)
tree61496c144b3ecd15192a2e07e755754e18346bc9 /sys/pci/pcisupport.c
parent9ed8ded4d312c58a27de9402fd9802e78a591cb9 (diff)
downloadFreeBSD-src-dd8b44b3958fa67d802cbbec7c7d82f7fb476229.zip
FreeBSD-src-dd8b44b3958fa67d802cbbec7c7d82f7fb476229.tar.gz
* Completely rewrite the alpha busspace to hide the implementation from
the drivers. * Remove legacy inx/outx support from chipset and replace with macros which call busspace. * Rework pci config accesses to route through the pcib device instead of calling a MD function directly. With these changes it is possible to cleanly support machines which have more than one independantly numbered PCI busses. As a bonus, the new busspace implementation should be measurably faster than the old one.
Diffstat (limited to 'sys/pci/pcisupport.c')
-rw-r--r--sys/pci/pcisupport.c65
1 files changed, 57 insertions, 8 deletions
diff --git a/sys/pci/pcisupport.c b/sys/pci/pcisupport.c
index e0a72e1..374a168 100644
--- a/sys/pci/pcisupport.c
+++ b/sys/pci/pcisupport.c
@@ -58,6 +58,8 @@
#include <vm/vm_object.h>
#include <vm/pmap.h>
+#include "pcib_if.h"
+
/*---------------------------------------------------------
**
** Intel chipsets for 486 / Pentium processor
@@ -762,7 +764,9 @@ static int pcib_attach(device_t dev)
secondary = pci_get_secondarybus(dev);
if (secondary) {
- device_add_child(dev, "pci", secondary);
+ device_t child;
+ child = device_add_child(dev, "pci", -1);
+ pcib_set_bus(child, secondary);
return bus_generic_attach(dev);
} else
return 0;
@@ -771,16 +775,55 @@ static int pcib_attach(device_t dev)
static int
pcib_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
{
- if (which == PCIB_IVAR_HOSE) {
- /*
- * Pass up to parent bus.
- */
- *result = pci_get_hose(dev);
- return(0);
+ switch (which) {
+ case PCIB_IVAR_BUS:
+ *result = *(int*) device_get_softc(dev);
+ return 0;
+ }
+ return ENOENT;
+}
+
+static int
+pcib_write_ivar(device_t dev, device_t child, int which, uintptr_t value)
+{
+ switch (which) {
+ case PCIB_IVAR_BUS:
+ *(int*) device_get_softc(dev) = value;
+ return 0;
}
return ENOENT;
}
+static int
+pcib_maxslots(device_t dev)
+{
+ return 31;
+}
+
+static u_int32_t
+pcib_read_config(device_t dev, int b, int s, int f,
+ int reg, int width)
+{
+ /*
+ * Pass through to the next ppb up the chain (i.e. our
+ * grandparent).
+ */
+ return PCIB_READ_CONFIG(device_get_parent(device_get_parent(dev)),
+ b, s, f, reg, width);
+}
+
+static void
+pcib_write_config(device_t dev, int b, int s, int f,
+ int reg, u_int32_t val, int width)
+{
+ /*
+ * Pass through to the next ppb up the chain (i.e. our
+ * grandparent).
+ */
+ PCIB_WRITE_CONFIG(device_get_parent(device_get_parent(dev)),
+ b, s, f, reg, val, width);
+}
+
static device_method_t pcib_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, pcib_probe),
@@ -792,6 +835,7 @@ static device_method_t pcib_methods[] = {
/* Bus interface */
DEVMETHOD(bus_print_child, bus_generic_print_child),
DEVMETHOD(bus_read_ivar, pcib_read_ivar),
+ DEVMETHOD(bus_write_ivar, pcib_write_ivar),
DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
@@ -799,13 +843,18 @@ static device_method_t pcib_methods[] = {
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
+ /* pcib interface */
+ DEVMETHOD(pcib_maxslots, pcib_maxslots),
+ DEVMETHOD(pcib_read_config, pcib_read_config),
+ DEVMETHOD(pcib_write_config, pcib_write_config),
+
{ 0, 0 }
};
static driver_t pcib_driver = {
"pcib",
pcib_methods,
- 1,
+ sizeof(int),
};
static devclass_t pcib_devclass;
OpenPOWER on IntegriCloud