]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/mini-os.git/commitdiff
minios: implement xc_map_foreign_bulk
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 18 Jan 2010 14:48:18 +0000 (14:48 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 18 Jan 2010 14:48:18 +0000 (14:48 +0000)
In order to do so it modifies map_frames_ex and do_map_frames to take
an int *err as parameter and return any error that way.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
arch/ia64/mm.c
arch/x86/ioremap.c
arch/x86/mm.c
include/ia64/arch_mm.h
include/mm.h
include/x86/arch_mm.h
lib/sys.c

index b171f75dc3395315744624d3a2657cb47d521d75..9040517fc2961e3c092827ba2c8b2af24fdcb654 100644 (file)
@@ -137,17 +137,17 @@ unsigned long allocate_ondemand(unsigned long n, unsigned long alignment)
 
 /* 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));
index f55d9e078e7c39274c20bb29d88f2aa2ca23ec59..c7f818609c25680c172697f3a3a5b0db06a8b7c9 100644 (file)
@@ -53,7 +53,7 @@ static void *__do_ioremap(unsigned long phys_addr, unsigned long size,
         }
     }   
     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:
index 8d688fc25a572a1e3d38ad5c20f45fce5ffcc969..cb7f03747773db6f97a0677769b5a68d66432712 100644 (file)
@@ -568,10 +568,9 @@ unsigned long allocate_ondemand(unsigned long n, unsigned long alignment)
  */
 #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;
@@ -585,12 +584,14 @@ void do_map_frames(unsigned long va,
     }
     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;
@@ -615,8 +616,8 @@ void do_map_frames(unsigned long va,
             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);
@@ -632,17 +633,17 @@ void do_map_frames(unsigned long va,
  * 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;
 }
index 5a1a1a9c50b258ebbeb2016fca8b960b05fb277a..8889164533184a1fa77c8c2a46bfc22268f63535 100644 (file)
@@ -35,9 +35,9 @@
 #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__ */
index 18622d85422e0f20c91d0595a63563df7cdab779..2fd43f30b20ab14ff048553c7ca7ee52c52b1a28 100644 (file)
@@ -65,12 +65,12 @@ void arch_init_p2m(unsigned long max_pfn_p);
 
 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
index 786064bf89375af25398dbe01309bb14bfdae5be..a95632ad4967f725cb02a1ff36b5455084dc443c 100644 (file)
@@ -224,9 +224,9 @@ static __inline__ paddr_t machine_to_phys(maddr_t machine)
 })
 #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);
index 6e12be0f4aa8b02512b61ca528a5dd332aceef90..9ce99544f5a57776ee51c1912b3b4476386237e7 100644 (file)
--- a/lib/sys.c
+++ b/lib/sys.c
@@ -1254,10 +1254,10 @@ void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset
         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);
 }