summaryrefslogtreecommitdiffstats
path: root/freebsd/sys/x86/pci/pci_bus.c
diff options
context:
space:
mode:
Diffstat (limited to 'freebsd/sys/x86/pci/pci_bus.c')
-rw-r--r--freebsd/sys/x86/pci/pci_bus.c60
1 files changed, 42 insertions, 18 deletions
diff --git a/freebsd/sys/x86/pci/pci_bus.c b/freebsd/sys/x86/pci/pci_bus.c
index c14b17ff..1b43f53f 100644
--- a/freebsd/sys/x86/pci/pci_bus.c
+++ b/freebsd/sys/x86/pci/pci_bus.c
@@ -47,7 +47,7 @@ __FBSDID("$FreeBSD$");
#ifdef CPU_ELAN
#include <machine/md_var.h>
#endif
-#include <machine/legacyvar.h>
+#include <x86/legacyvar.h>
#include <machine/pci_cfgreg.h>
#include <machine/resource.h>
@@ -94,7 +94,7 @@ legacy_pcib_route_interrupt(device_t pcib, device_t dev, int pin)
/* Pass MSI requests up to the nexus. */
-static int
+int
legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount,
int *irqs)
{
@@ -105,7 +105,7 @@ legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount,
irqs));
}
-static int
+int
legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq)
{
device_t bus;
@@ -135,7 +135,6 @@ legacy_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr,
slot, func));
pci_ht_map_msi(hostb, *addr);
return (0);
-
}
static const char *
@@ -527,7 +526,7 @@ legacy_pcib_attach(device_t dev)
device_probe_and_attach(pir);
}
#endif
- device_add_child(dev, "pci", bus);
+ device_add_child(dev, "pci", -1);
return bus_generic_attach(dev);
}
@@ -578,12 +577,11 @@ legacy_pcib_write_ivar(device_t dev, device_t child, int which,
SYSCTL_DECL(_hw_pci);
static unsigned long host_mem_start = 0x80000000;
-TUNABLE_ULONG("hw.pci.host_mem_start", &host_mem_start);
SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, &host_mem_start,
0, "Limit the host bridge memory to being above this address.");
-u_long
-hostb_alloc_start(int type, u_long start, u_long end, u_long count)
+rman_res_t
+hostb_alloc_start(int type, rman_res_t start, rman_res_t end, rman_res_t count)
{
if (start + count - 1 != end) {
@@ -597,20 +595,41 @@ hostb_alloc_start(int type, u_long start, u_long end, u_long count)
struct resource *
legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid,
- u_long start, u_long end, u_long count, u_int flags)
+ rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
{
-#if defined(__rtems__) && defined(__i386__)
- /*
- * FIXME: This is a quick and dirty hack. See pci_reserve_map().
- */
-#else /* __rtems__ */
- start = hostb_alloc_start(type, start, end, count);
-#endif /* __rtems__ */
- return (bus_generic_alloc_resource(dev, child, type, rid, start, end,
- count, flags));
+#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
+ if (type == PCI_RES_BUS)
+ return (pci_domain_alloc_bus(0, child, rid, start, end, count,
+ flags));
+#endif
+ start = hostb_alloc_start(type, start, end, count);
+ return (bus_generic_alloc_resource(dev, child, type, rid, start, end,
+ count, flags));
}
+#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
+int
+legacy_pcib_adjust_resource(device_t dev, device_t child, int type,
+ struct resource *r, rman_res_t start, rman_res_t end)
+{
+
+ if (type == PCI_RES_BUS)
+ return (pci_domain_adjust_bus(0, child, r, start, end));
+ return (bus_generic_adjust_resource(dev, child, type, r, start, end));
+}
+
+int
+legacy_pcib_release_resource(device_t dev, device_t child, int type, int rid,
+ struct resource *r)
+{
+
+ if (type == PCI_RES_BUS)
+ return (pci_domain_release_bus(0, child, rid, r));
+ return (bus_generic_release_resource(dev, child, type, rid, r));
+}
+#endif
+
static device_method_t legacy_pcib_methods[] = {
/* Device interface */
DEVMETHOD(device_identify, legacy_pcib_identify),
@@ -624,8 +643,13 @@ static device_method_t legacy_pcib_methods[] = {
DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar),
DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar),
DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource),
+#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
+ DEVMETHOD(bus_adjust_resource, legacy_pcib_adjust_resource),
+ DEVMETHOD(bus_release_resource, legacy_pcib_release_resource),
+#else
DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
+#endif
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),