void *xc_map_foreign_ranges(int xc_handle, uint32_t dom, size_t size, int prot, size_t chunksize, privcmd_mmap_entry_t entries[], int nentries) { unsigned long *mfns; int i, j, n; unsigned long pt_prot = 0; void *ret; #ifdef __ia64__ /* TODO */ #else if (prot & PROT_READ) pt_prot = L1_PROT_RO; if (prot & PROT_WRITE) pt_prot = L1_PROT; #endif mfns = malloc((size / PAGE_SIZE) * sizeof(*mfns)); n = 0; for (i = 0; i < nentries; i++) for (j = 0; j < chunksize / PAGE_SIZE; j++) mfns[n++] = entries[i].mfn + j; ret = map_frames_ex(mfns, n, 1, 0, 1, dom, 0, pt_prot); free(mfns); return ret; }
void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset) { unsigned long n = (length + PAGE_SIZE - 1) / PAGE_SIZE; ASSERT(!start); ASSERT(prot == (PROT_READ|PROT_WRITE)); ASSERT((fd == -1 && (flags == (MAP_SHARED|MAP_ANON) || flags == (MAP_PRIVATE|MAP_ANON))) || (fd != -1 && flags == MAP_SHARED)); if (fd == -1) return map_zero(n, 1); else if (files[fd].type == FTYPE_XC) { unsigned long zero = 0; return map_frames_ex(&zero, n, 0, 0, 1, DOMID_SELF, NULL, 0); } else if (files[fd].type == FTYPE_MEM) { unsigned long first_mfn = offset >> PAGE_SHIFT; return map_frames_ex(&first_mfn, n, 0, 1, 1, DOMID_IO, NULL, _PAGE_PRESENT|_PAGE_RW); } else ASSERT(0);
void *osdep_xenforeignmemory_map(xenforeignmemory_handle *fmem, uint32_t dom, void *addr, int prot, int flags, size_t num, const xen_pfn_t arr[/*num*/], int err[/*num*/]) { unsigned long pt_prot = 0; if (prot & PROT_READ) pt_prot = L1_PROT_RO; if (prot & PROT_WRITE) pt_prot = L1_PROT; return map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot); }
void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot, xen_pfn_t *arr, int num) { unsigned long pt_prot = 0; #ifdef __ia64__ /* TODO */ #else if (prot & PROT_READ) pt_prot = L1_PROT_RO; if (prot & PROT_WRITE) pt_prot = L1_PROT; #endif return map_frames_ex(arr, num, 1, 0, 1, dom, 1, pt_prot); }
void *xc_map_foreign_range(int xc_handle, uint32_t dom, int size, int prot, unsigned long mfn) { unsigned long pt_prot = 0; #ifdef __ia64__ /* TODO */ #else if (prot & PROT_READ) pt_prot = L1_PROT_RO; if (prot & PROT_WRITE) pt_prot = L1_PROT; #endif assert(!(size % getpagesize())); return map_frames_ex(&mfn, size / getpagesize(), 0, 1, 1, dom, 0, pt_prot); }