# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1291369007 0
# Node ID 68996338758eabdecbdfc5cfb4aa82ab7589b4e6
# Parent 3e8cb37144eb01a1ebb843882f4c3f43d0b4bd26
libxc: osdep: convert xc_gnttab_map_{grant_ref,grant_refs,domain_grant_refs}()
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
diff -r 3e8cb37144eb -r 68996338758e tools/libxc/xc_gnttab.c
--- a/tools/libxc/xc_gnttab.c Fri Dec 03 09:36:47 2010 +0000
+++ b/tools/libxc/xc_gnttab.c Fri Dec 03 09:36:47 2010 +0000
@@ -145,3 +145,41 @@ grant_entry_v2_t *xc_gnttab_map_table_v2
return _gnttab_map_table(xch, domid, gnt_num);
}
+void *xc_gnttab_map_grant_ref(xc_gnttab *xcg,
+ uint32_t domid,
+ uint32_t ref,
+ int prot)
+{
+ return xcg->ops->u.gnttab.map_grant_ref(xcg, xcg->ops_handle,
+ domid, ref, prot);
+}
+
+void *xc_gnttab_map_grant_refs(xc_gnttab *xcg,
+ uint32_t count,
+ uint32_t *domids,
+ uint32_t *refs,
+ int prot)
+{
+ return xcg->ops->u.gnttab.map_grant_refs(xcg, xcg->ops_handle,
+ count, domids, refs, prot);
+}
+
+void *xc_gnttab_map_domain_grant_refs(xc_gnttab *xcg,
+ uint32_t count,
+ uint32_t domid,
+ uint32_t *refs,
+ int prot)
+{
+ return xcg->ops->u.gnttab.map_domain_grant_refs(xcg, xcg->ops_handle,
+ count, domid, refs,
prot);
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff -r 3e8cb37144eb -r 68996338758e tools/libxc/xc_linux.c
--- a/tools/libxc/xc_linux.c Fri Dec 03 09:36:47 2010 +0000
+++ b/tools/libxc/xc_linux.c Fri Dec 03 09:36:47 2010 +0000
@@ -508,8 +508,10 @@ static int linux_gnttab_close(xc_gnttab
return close(fd);
}
-void *xc_gnttab_map_grant_ref(xc_gnttab *xch, uint32_t domid, uint32_t ref,
int prot)
+static void *linux_gnttab_map_grant_ref(xc_gnttab *xch, xc_osdep_handle h,
+ uint32_t domid, uint32_t ref, int prot)
{
+ int fd = (int)h;
struct ioctl_gntdev_map_grant_ref map;
void *addr;
@@ -517,13 +519,13 @@ void *xc_gnttab_map_grant_ref(xc_gnttab
map.refs[0].domid = domid;
map.refs[0].ref = ref;
- if ( ioctl(xch->fd, IOCTL_GNTDEV_MAP_GRANT_REF, &map) ) {
+ if ( ioctl(fd, IOCTL_GNTDEV_MAP_GRANT_REF, &map) ) {
PERROR("xc_gnttab_map_grant_ref: ioctl MAP_GRANT_REF failed");
return NULL;
}
mmap_again:
- addr = mmap(NULL, PAGE_SIZE, prot, MAP_SHARED, xch->fd, map.index);
+ addr = mmap(NULL, PAGE_SIZE, prot, MAP_SHARED, fd, map.index);
if ( addr == MAP_FAILED )
{
int saved_errno = errno;
@@ -538,7 +540,7 @@ mmap_again:
PERROR("xc_gnttab_map_grant_ref: mmap failed");
unmap_grant.index = map.index;
unmap_grant.count = 1;
- ioctl(xch->fd, IOCTL_GNTDEV_UNMAP_GRANT_REF, &unmap_grant);
+ ioctl(fd, IOCTL_GNTDEV_UNMAP_GRANT_REF, &unmap_grant);
errno = saved_errno;
return NULL;
}
@@ -546,10 +548,12 @@ mmap_again:
return addr;
}
-static void *do_gnttab_map_grant_refs(xc_gnttab *xch, uint32_t count,
+static void *do_gnttab_map_grant_refs(xc_gnttab *xch, xc_osdep_handle h,
+ uint32_t count,
uint32_t *domids, int domids_stride,
uint32_t *refs, int prot)
{
+ int fd = (int)h;
struct ioctl_gntdev_map_grant_ref *map;
void *addr = NULL;
int i;
@@ -567,12 +571,12 @@ static void *do_gnttab_map_grant_refs(xc
map->count = count;
- if ( ioctl(xch->fd, IOCTL_GNTDEV_MAP_GRANT_REF, map) ) {
+ if ( ioctl(fd, IOCTL_GNTDEV_MAP_GRANT_REF, map) ) {
PERROR("xc_gnttab_map_grant_refs: ioctl MAP_GRANT_REF failed");
goto out;
}
- addr = mmap(NULL, PAGE_SIZE * count, prot, MAP_SHARED, xch->fd,
+ addr = mmap(NULL, PAGE_SIZE * count, prot, MAP_SHARED, fd,
map->index);
if ( addr == MAP_FAILED )
{
@@ -583,7 +587,7 @@ static void *do_gnttab_map_grant_refs(xc
PERROR("xc_gnttab_map_grant_refs: mmap failed");
unmap_grant.index = map->index;
unmap_grant.count = count;
- ioctl(xch->fd, IOCTL_GNTDEV_UNMAP_GRANT_REF, &unmap_grant);
+ ioctl(fd, IOCTL_GNTDEV_UNMAP_GRANT_REF, &unmap_grant);
errno = saved_errno;
addr = NULL;
}
@@ -594,16 +598,18 @@ static void *do_gnttab_map_grant_refs(xc
return addr;
}
-void *xc_gnttab_map_grant_refs(xc_gnttab *xcg, uint32_t count, uint32_t
*domids,
- uint32_t *refs, int prot)
+static void *linux_gnttab_map_grant_refs(xc_gnttab *xcg, xc_osdep_handle h,
+ uint32_t count, uint32_t *domids,
+ uint32_t *refs, int prot)
{
- return do_gnttab_map_grant_refs(xcg, count, domids, 1, refs, prot);
+ return do_gnttab_map_grant_refs(xcg, h, count, domids, 1, refs, prot);
}
-void *xc_gnttab_map_domain_grant_refs(xc_gnttab *xcg, uint32_t count,
- uint32_t domid, uint32_t *refs, int prot)
+static void *linux_gnttab_map_domain_grant_refs(xc_gnttab *xcg,
xc_osdep_handle h,
+ uint32_t count,
+ uint32_t domid, uint32_t
*refs, int prot)
{
- return do_gnttab_map_grant_refs(xcg, count, &domid, 0, refs, prot);
+ return do_gnttab_map_grant_refs(xcg, h, count, &domid, 0, refs, prot);
}
int xc_gnttab_munmap(xc_gnttab *xcg, void *start_address, uint32_t count)
@@ -660,6 +666,12 @@ static struct xc_osdep_ops linux_gnttab_
static struct xc_osdep_ops linux_gnttab_ops = {
.open = &linux_gnttab_open,
.close = &linux_gnttab_close,
+
+ .u.gnttab = {
+ .map_grant_ref = &linux_gnttab_map_grant_ref,
+ .map_grant_refs = &linux_gnttab_map_grant_refs,
+ .map_domain_grant_refs = &linux_gnttab_map_domain_grant_refs,
+ },
};
static struct xc_osdep_ops *linux_osdep_init(xc_interface *xch, enum
xc_osdep_type type)
diff -r 3e8cb37144eb -r 68996338758e tools/libxc/xc_minios.c
--- a/tools/libxc/xc_minios.c Fri Dec 03 09:36:47 2010 +0000
+++ b/tools/libxc/xc_minios.c Fri Dec 03 09:36:47 2010 +0000
@@ -447,38 +447,41 @@ void minios_gnttab_close_fd(int fd)
files[fd].type = FTYPE_NONE;
}
-void *xc_gnttab_map_grant_ref(xc_gnttab *xcg,
- uint32_t domid,
- uint32_t ref,
- int prot)
+static void *minios_gnttab_map_grant_ref(xc_gnttab *xcg, xc_osdep_handle h,
+ uint32_t domid,
+ uint32_t ref,
+ int prot)
{
- return gntmap_map_grant_refs(&files[xcg->fd].gntmap,
+ int fd = (int)h;
+ return gntmap_map_grant_refs(&files[fd].gntmap,
1,
&domid, 0,
&ref,
prot & PROT_WRITE);
}
-void *xc_gnttab_map_grant_refs(xc_gnttab *xcg,
- uint32_t count,
- uint32_t *domids,
- uint32_t *refs,
- int prot)
+static void *minios_gnttab_map_grant_refs(xc_gnttab *xcg, xc_osdep_handle h,
+ uint32_t count,
+ uint32_t *domids,
+ uint32_t *refs,
+ int prot)
{
- return gntmap_map_grant_refs(&files[xcg->fd].gntmap,
+ int fd = (int)h;
+ return gntmap_map_grant_refs(&files[fd].gntmap,
count,
domids, 1,
refs,
prot & PROT_WRITE);
}
-void *xc_gnttab_map_domain_grant_refs(xc_gnttab *xcg,
- uint32_t count,
- uint32_t domid,
- uint32_t *refs,
- int prot)
+static void *minios_gnttab_map_domain_grant_refs(xc_gnttab *xcg,
xc_osdep_handle h,
+ uint32_t count,
+ uint32_t domid,
+ uint32_t *refs,
+ int prot)
{
- return gntmap_map_grant_refs(&files[xcg->fd].gntmap,
+ int fd = (int)h;
+ return gntmap_map_grant_refs(&files[fd].gntmap,
count,
&domid, 0,
refs,
@@ -516,6 +519,12 @@ static struct xc_osdep_ops minios_gnttab
static struct xc_osdep_ops minios_gnttab_ops = {
.open = &minios_gnttab_open,
.close = &minios_gnttab_close,
+
+ .u.gnttab = {
+ .map_grant_ref = &minios_gnttab_map_grant_ref,
+ .map_grant_refs = &minios_gnttab_map_grant_refs,
+ .map_domain_grant_refs = &minios_gnttab_map_domain_grant_refs,
+ },
};
static struct xc_osdep_ops *minios_osdep_init(xc_interface *xch, enum
xc_osdep_type type)
diff -r 3e8cb37144eb -r 68996338758e tools/libxc/xenctrlosdep.h
--- a/tools/libxc/xenctrlosdep.h Fri Dec 03 09:36:47 2010 +0000
+++ b/tools/libxc/xenctrlosdep.h Fri Dec 03 09:36:47 2010 +0000
@@ -89,6 +89,22 @@ struct xc_osdep_ops
evtchn_port_or_error_t (*pending)(xc_evtchn *xce, xc_osdep_handle
h);
int (*unmask)(xc_evtchn *xce, xc_osdep_handle h, evtchn_port_t
port);
} evtchn;
+ struct {
+ void *(*map_grant_ref)(xc_gnttab *xcg, xc_osdep_handle h,
+ uint32_t domid,
+ uint32_t ref,
+ int prot);
+ void *(*map_grant_refs)(xc_gnttab *xcg, xc_osdep_handle h,
+ uint32_t count,
+ uint32_t *domids,
+ uint32_t *refs,
+ int prot);
+ void *(*map_domain_grant_refs)(xc_gnttab *xcg, xc_osdep_handle h,
+ uint32_t count,
+ uint32_t domid,
+ uint32_t *refs,
+ int prot);
+ } gnttab;
} u;
};
typedef struct xc_osdep_ops xc_osdep_ops;
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|