summaryrefslogtreecommitdiffstats
path: root/sys/xen/gnttab.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/xen/gnttab.c')
-rw-r--r--sys/xen/gnttab.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/sys/xen/gnttab.c b/sys/xen/gnttab.c
index 03c32b7..ca6fa3b 100644
--- a/sys/xen/gnttab.c
+++ b/sys/xen/gnttab.c
@@ -25,6 +25,9 @@ __FBSDID("$FreeBSD$");
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mman.h>
+#include <sys/limits.h>
+#include <sys/rman.h>
+#include <machine/resource.h>
#include <xen/xen-os.h>
#include <xen/hypervisor.h>
@@ -51,6 +54,17 @@ static int gnttab_free_count;
static grant_ref_t gnttab_free_head;
static struct mtx gnttab_list_lock;
+#ifdef XENHVM
+/*
+ * Resource representing allocated physical address space
+ * for the grant table metainfo
+ */
+static struct resource *gnttab_pseudo_phys_res;
+
+/* Resource id for allocated physical address space. */
+static int gnttab_pseudo_phys_res_id;
+#endif
+
static grant_entry_t *shared;
static struct gnttab_free_callback *gnttab_free_callback_list = NULL;
@@ -542,7 +556,7 @@ gnttab_map(unsigned int start_idx, unsigned int end_idx)
}
int
-gnttab_resume(void)
+gnttab_resume(device_t dev)
{
if (max_nr_grant_frames() < nr_grant_frames)
@@ -563,8 +577,6 @@ gnttab_suspend(void)
#else /* XENHVM */
-#include <dev/xen/xenpci/xenpcivar.h>
-
static vm_paddr_t resume_frames;
static int
@@ -603,9 +615,8 @@ gnttab_map(unsigned int start_idx, unsigned int end_idx)
}
int
-gnttab_resume(void)
+gnttab_resume(device_t dev)
{
- int error;
unsigned int max_nr_gframes, nr_gframes;
nr_gframes = nr_grant_frames;
@@ -614,12 +625,15 @@ gnttab_resume(void)
return (ENOSYS);
if (!resume_frames) {
- error = xenpci_alloc_space(PAGE_SIZE * max_nr_gframes,
- &resume_frames);
- if (error) {
- printf("error mapping gnttab share frames\n");
- return (error);
- }
+ KASSERT(dev != NULL,
+ ("No resume frames and no device provided"));
+
+ gnttab_pseudo_phys_res = bus_alloc_resource(dev,
+ SYS_RES_MEMORY, &gnttab_pseudo_phys_res_id, 0, ~0,
+ PAGE_SIZE * max_nr_gframes, RF_ACTIVE);
+ if (gnttab_pseudo_phys_res == NULL)
+ panic("Unable to reserve physical memory for gnttab");
+ resume_frames = rman_get_start(gnttab_pseudo_phys_res);
}
return (gnttab_map(0, nr_gframes - 1));
@@ -647,7 +661,7 @@ gnttab_expand(unsigned int req_entries)
}
int
-gnttab_init()
+gnttab_init(device_t dev)
{
int i;
unsigned int max_nr_glist_frames;
@@ -679,7 +693,7 @@ gnttab_init()
goto ini_nomem;
}
- if (gnttab_resume())
+ if (gnttab_resume(dev))
return (ENODEV);
nr_init_grefs = nr_grant_frames * GREFS_PER_GRANT_FRAME;
OpenPOWER on IntegriCloud