#include <sys/module.h>
#include <sys/pcpu.h>
#include <sys/smp.h>
+#include <sys/rman.h>
#include <xen/xen-os.h>
#include <xen/gnttab.h>
static devclass_t xenpv_devclass;
+/* End of MMIO region on x86 (4GB) */
+#define MMIO_END (4*1073741824UL)
+
static void
xenpv_identify(driver_t *driver, device_t parent)
{
return (0);
}
+static struct resource *
+xenpv_alloc_resource(device_t dev, device_t child, int type, int *rid,
+ u_long start, u_long end, u_long count, u_int flags)
+{
+
+ /*
+ * Devices hanging off xenpv request memory in order to
+ * map grants or foreign pages. By default use memory
+ * after the MMIO region in order to prevent clashes with
+ * real devices.
+ */
+ if (type == SYS_RES_MEMORY && start < MMIO_END)
+ start = MMIO_END;
+
+ return (bus_generic_alloc_resource(dev, child, type, rid, start, end,
+ count, flags));
+}
+
static device_method_t xenpv_methods[] = {
/* Device interface */
DEVMETHOD(device_identify, xenpv_identify),
/* Bus interface */
DEVMETHOD(bus_add_child, bus_generic_add_child),
- DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
+ DEVMETHOD(bus_alloc_resource, xenpv_alloc_resource),
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),