diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2008-07-24 14:14:27 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2008-07-24 14:14:27 +0100 |
commit | 7d0b678231c097279f86221eed0138df8badb3a4 (patch) | |
tree | 604e5077f1244c24bd113261ee8761db65a89894 /tools/libxc/xc_minios.c | |
parent | b5d7ddffa7bf654dcb094d9a66ce614657be06f2 (diff) | |
download | xen-7d0b678231c097279f86221eed0138df8badb3a4.tar.gz xen-7d0b678231c097279f86221eed0138df8badb3a4.tar.bz2 xen-7d0b678231c097279f86221eed0138df8badb3a4.zip |
minios: grant table map (gntdev) for minios
I've implemented a grant map for mini-os to support the xc_gnttab_*()
functions, the equivalent of gntdev in linux. This is useful for my
work in putting xenstored in a stub domain.
Signed-off-by: Diego Ongaro <diego.ongaro@citrix.com>
Diffstat (limited to 'tools/libxc/xc_minios.c')
-rw-r--r-- | tools/libxc/xc_minios.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tools/libxc/xc_minios.c b/tools/libxc/xc_minios.c index a07b17dd6f..f0c383bfd8 100644 --- a/tools/libxc/xc_minios.c +++ b/tools/libxc/xc_minios.c @@ -15,6 +15,7 @@ #include <os.h> #include <mm.h> #include <lib.h> +#include <gntmap.h> #include <events.h> #include <wait.h> #include <sys/mman.h> @@ -324,6 +325,76 @@ void discard_file_cache(int fd, int flush) if (flush) fsync(fd); } + +int xc_gnttab_open(void) +{ + int xcg_handle; + xcg_handle = alloc_fd(FTYPE_GNTMAP); + gntmap_init(&files[xcg_handle].gntmap); + return xcg_handle; +} + +int xc_gnttab_close(int xcg_handle) +{ + gntmap_fini(&files[xcg_handle].gntmap); + files[xcg_handle].type = FTYPE_NONE; + return 0; +} + +void *xc_gnttab_map_grant_ref(int xcg_handle, + uint32_t domid, + uint32_t ref, + int prot) +{ + return gntmap_map_grant_refs(&files[xcg_handle].gntmap, + 1, + &domid, 0, + &ref, + prot & PROT_WRITE); +} + +void *xc_gnttab_map_grant_refs(int xcg_handle, + uint32_t count, + uint32_t *domids, + uint32_t *refs, + int prot) +{ + return gntmap_map_grant_refs(&files[xcg_handle].gntmap, + count, + domids, 1, + refs, + prot & PROT_WRITE); +} + +void *xc_gnttab_map_domain_grant_refs(int xcg_handle, + uint32_t count, + uint32_t domid, + uint32_t *refs, + int prot) +{ + return gntmap_map_grant_refs(&files[xcg_handle].gntmap, + count, + &domid, 0, + refs, + prot & PROT_WRITE); +} + +int xc_gnttab_munmap(int xcg_handle, + void *start_address, + uint32_t count) +{ + return gntmap_munmap(&files[xcg_handle].gntmap, + (unsigned long) start_address, + count); +} + +int xc_gnttab_set_max_grants(int xcg_handle, + uint32_t count) +{ + return gntmap_set_max_grants(&files[xcg_handle].gntmap, + count); +} + /* * Local variables: * mode: C |