libxc: add xc_gnttab_map_domain_grant_refs.
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 21 Jul 2008 13:02:53 +0000 (14:02 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 21 Jul 2008 13:02:53 +0000 (14:02 +0100)
xc_gnttab_map_domain_grant_refs permits to simply map several pages
from the same domain.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
tools/libxc/xc_linux.c
tools/libxc/xenctrl.h

index b6f9b82a522ab2cd3779fabc2b8b3a91f6c975bc..d407299ff88e396f9a185c5d37fc848ef2d909aa 100644 (file)
@@ -418,9 +418,10 @@ void *xc_gnttab_map_grant_ref(int xcg_handle,
     return addr;
 }
 
-void *xc_gnttab_map_grant_refs(int xcg_handle,
+static void *do_gnttab_map_grant_refs(int xcg_handle,
                                uint32_t count,
                                uint32_t *domids,
+                               int domids_stride,
                                uint32_t *refs,
                                int prot)
 {
@@ -435,7 +436,7 @@ void *xc_gnttab_map_grant_refs(int xcg_handle,
 
     for ( i = 0; i < count; i++ )
     {
-        map->refs[i].domid = domids[i];
+        map->refs[i].domid = domids[i * domids_stride];
         map->refs[i].ref   = refs[i];
     }
 
@@ -464,6 +465,24 @@ void *xc_gnttab_map_grant_refs(int xcg_handle,
     return addr;
 }
 
+void *xc_gnttab_map_grant_refs(int xcg_handle,
+                               uint32_t count,
+                               uint32_t *domids,
+                               uint32_t *refs,
+                               int prot)
+{
+    return do_gnttab_map_grant_refs(xcg_handle, count, domids, 1, refs, prot);
+}
+
+void *xc_gnttab_map_domain_grant_refs(int xcg_handle,
+                               uint32_t count,
+                               uint32_t domid,
+                               uint32_t *refs,
+                               int prot)
+{
+    return do_gnttab_map_grant_refs(xcg_handle, count, &domid, 0, refs, prot);
+}
+
 int xc_gnttab_munmap(int xcg_handle,
                      void *start_address,
                      uint32_t count)
index 69d58950d53b7e51c9f7ba71515a1086d5667833..2f6aafb0c8e764f4d04ae93018b8d30297f77603 100644 (file)
@@ -865,6 +865,23 @@ void *xc_gnttab_map_grant_refs(int xcg_handle,
                                uint32_t *refs,
                                int prot);
 
+/**
+ * Memory maps one or more grant references from one domain to a
+ * contiguous local address range. Mappings should be unmapped with
+ * xc_gnttab_munmap.  Returns NULL on failure.
+ *
+ * @parm xcg_handle a handle on an open grant table interface
+ * @parm count the number of grant references to be mapped
+ * @parm domid the domain to map memory from
+ * @parm refs an array of @count grant references to be mapped
+ * @parm prot same flag as in mmap()
+ */
+void *xc_gnttab_map_domain_grant_refs(int xcg_handle,
+                                      uint32_t count,
+                                      uint32_t domid,
+                                      uint32_t *refs,
+                                      int prot);
+
 /*
  * Unmaps the @count pages starting at @start_address, which were mapped by a
  * call to xc_gnttab_map_grant_ref or xc_gnttab_map_grant_refs. Returns zero