/* Helper function used in gnttab.c. */
void do_map_frames(unsigned long addr,
- unsigned long *f, unsigned long n, unsigned long stride,
- unsigned long increment, domid_t id, int may_fail, unsigned long prot)
+ const unsigned long *f, unsigned long n, unsigned long stride,
+ unsigned long increment, domid_t id, int *err, unsigned long prot)
{
/* TODO */
ASSERT(0);
}
void*
-map_frames_ex(unsigned long* frames, unsigned long n, unsigned long stride,
+map_frames_ex(const unsigned long* frames, unsigned long n, unsigned long stride,
unsigned long increment, unsigned long alignment, domid_t id,
- int may_fail, unsigned long prot)
+ int *err, unsigned long prot)
{
/* TODO: incomplete! */
ASSERT(n == 1 || (stride == 0 && increment == 1));
}
}
va = (unsigned long)map_frames_ex(&mfns, num_pages, 0, 1, 1,
- DOMID_IO, 0, prot);
+ DOMID_IO, NULL, prot);
return (void *)(va + offset);
mfn_invalid:
*/
#define MAP_BATCH ((STACK_SIZE / 2) / sizeof(mmu_update_t))
void do_map_frames(unsigned long va,
- unsigned long *mfns, unsigned long n,
+ const unsigned long *mfns, unsigned long n,
unsigned long stride, unsigned long incr,
- domid_t id, int may_fail,
- unsigned long prot)
+ domid_t id, int *err, unsigned long prot)
{
pgentry_t *pgt = NULL;
unsigned long done = 0;
}
DEBUG("va=%p n=0x%lx, mfns[0]=0x%lx stride=0x%lx incr=0x%lx prot=0x%lx\n",
va, n, mfns[0], stride, incr, prot);
-
+
+ if ( err )
+ memset(err, 0x00, n * sizeof(int));
while ( done < n )
{
unsigned long todo;
- if ( may_fail )
+ if ( err )
todo = 1;
else
todo = n - done;
rc = HYPERVISOR_mmu_update(mmu_updates, todo, NULL, id);
if ( rc < 0 )
{
- if (may_fail)
- mfns[done * stride] |= 0xF0000000;
+ if (err)
+ err[done * stride] = rc;
else {
printk("Map %ld (%lx, ...) at %p failed: %d.\n",
todo, mfns[done * stride] + done * incr, va, rc);
* Map an array of MFNs contiguous into virtual address space. Virtual
* addresses are allocated from the on demand area.
*/
-void *map_frames_ex(unsigned long *mfns, unsigned long n,
+void *map_frames_ex(const unsigned long *mfns, unsigned long n,
unsigned long stride, unsigned long incr,
unsigned long alignment,
- domid_t id, int may_fail, unsigned long prot)
+ domid_t id, int *err, unsigned long prot)
{
unsigned long va = allocate_ondemand(n, alignment);
if ( !va )
return NULL;
- do_map_frames(va, mfns, n, stride, incr, id, may_fail, prot);
+ do_map_frames(va, mfns, n, stride, incr, id, err, prot);
return (void *)va;
}
#define virt_to_mfn(x) virt_to_pfn(x)
#define virtual_to_mfn(x) (ia64_tpa((uint64_t)(x)) >> PAGE_SHIFT)
-#define map_frames(f, n) map_frames_ex(f, n, 1, 0, 1, DOMID_SELF, 0, 0)
+#define map_frames(f, n) map_frames_ex(f, n, 1, 0, 1, DOMID_SELF, NULL, 0)
/* TODO */
-#define map_zero(n, a) map_frames_ex(NULL, n, 0, 0, a, DOMID_SELF, 0, 0)
+#define map_zero(n, a) map_frames_ex(NULL, n, 0, 0, a, DOMID_SELF, NULL, 0)
#define do_map_zero(start, n) ASSERT(n == 0)
#endif /* __ARCH_MM_H__ */
unsigned long allocate_ondemand(unsigned long n, unsigned long alignment);
/* map f[i*stride]+i*increment for i in 0..n-1, aligned on alignment pages */
-void *map_frames_ex(unsigned long *f, unsigned long n, unsigned long stride,
+void *map_frames_ex(const unsigned long *f, unsigned long n, unsigned long stride,
unsigned long increment, unsigned long alignment, domid_t id,
- int may_fail, unsigned long prot);
+ int *err, unsigned long prot);
void do_map_frames(unsigned long addr,
- unsigned long *f, unsigned long n, unsigned long stride,
- unsigned long increment, domid_t id, int may_fail, unsigned long prot);
+ const unsigned long *f, unsigned long n, unsigned long stride,
+ unsigned long increment, domid_t id, int *err, unsigned long prot);
int unmap_frames(unsigned long va, unsigned long num_frames);
unsigned long alloc_contig_pages(int order, unsigned int addr_bits);
#ifdef HAVE_LIBC
})
#define virtual_to_mfn(_virt) pte_to_mfn(virtual_to_pte(_virt))
-#define map_frames(f, n) map_frames_ex(f, n, 1, 0, 1, DOMID_SELF, 0, L1_PROT)
-#define map_zero(n, a) map_frames_ex(&mfn_zero, n, 0, 0, a, DOMID_SELF, 0, L1_PROT_RO)
-#define do_map_zero(start, n) do_map_frames(start, &mfn_zero, n, 0, 0, DOMID_SELF, 0, L1_PROT_RO)
+#define map_frames(f, n) map_frames_ex(f, n, 1, 0, 1, DOMID_SELF, NULL, L1_PROT)
+#define map_zero(n, a) map_frames_ex(&mfn_zero, n, 0, 0, a, DOMID_SELF, NULL, L1_PROT_RO)
+#define do_map_zero(start, n) do_map_frames(start, &mfn_zero, n, 0, 0, DOMID_SELF, NULL, L1_PROT_RO)
pgentry_t *need_pgt(unsigned long addr);
int mfn_is_ram(unsigned long mfn);
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, 0, 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, 0, _PAGE_PRESENT|_PAGE_RW);
+ return map_frames_ex(&first_mfn, n, 0, 1, 1, DOMID_IO, NULL, _PAGE_PRESENT|_PAGE_RW);
} else ASSERT(0);
}