WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] mini-os: export allocate_ondemand

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] mini-os: export allocate_ondemand
From: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>
Date: Fri, 18 Jul 2008 15:41:52 +0100
Delivery-date: Fri, 18 Jul 2008 07:43:04 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Mail-followup-to: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.12-2006-07-14
mini-os: export allocate_ondemand

allocate_ondemand can be used to allocate addresse space. Primarily used
for mapping MFNs, it can also be used e.g. to map grant refs.

Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>

diff -r e80d27b6e206 extras/mini-os/arch/ia64/mm.c
--- a/extras/mini-os/arch/ia64/mm.c     Fri Jul 18 14:34:49 2008 +0100
+++ b/extras/mini-os/arch/ia64/mm.c     Fri Jul 18 15:42:09 2008 +0100
@@ -130,6 +130,11 @@
        max_pfn = max_pfn;
 }
 
+unsigned long allocate_ondemand(unsigned long n, unsigned long alignment)
+{
+        return 0;
+}
+
 /* Helper function used in gnttab.c. */
 void do_map_frames(unsigned long addr,
         unsigned long *f, unsigned long n, unsigned long stride,
diff -r e80d27b6e206 extras/mini-os/arch/x86/mm.c
--- a/extras/mini-os/arch/x86/mm.c      Fri Jul 18 14:34:49 2008 +0100
+++ b/extras/mini-os/arch/x86/mm.c      Fri Jul 18 15:42:09 2008 +0100
@@ -492,9 +492,7 @@
     }
 }
 
-void *map_frames_ex(unsigned long *f, unsigned long n, unsigned long stride,
-       unsigned long increment, unsigned long alignment, domid_t id,
-       int may_fail, unsigned long prot)
+unsigned long allocate_ondemand(unsigned long n, unsigned long alignment)
 {
     unsigned long x;
     unsigned long y = 0;
@@ -517,13 +515,24 @@
     }
     if (y != n) {
         printk("Failed to find %ld frames!\n", n);
+        return 0;
+    }
+    return demand_map_area_start + x * PAGE_SIZE;
+}
+
+void *map_frames_ex(unsigned long *f, unsigned long n, unsigned long stride,
+       unsigned long increment, unsigned long alignment, domid_t id,
+       int may_fail, unsigned long prot)
+{
+    unsigned long addr = allocate_ondemand(n, alignment);
+
+    if (!addr)
         return NULL;
-    }
 
     /* Found it at x.  Map it in. */
-    do_map_frames(demand_map_area_start + x * PAGE_SIZE, f, n, stride, 
increment, id, may_fail, prot);
+    do_map_frames(addr, f, n, stride, increment, id, may_fail, prot);
 
-    return (void *)(unsigned long)(demand_map_area_start + x * PAGE_SIZE);
+    return (void *)addr;
 }
 
 static void clear_bootstrap(void)
diff -r e80d27b6e206 extras/mini-os/include/mm.h
--- a/extras/mini-os/include/mm.h       Fri Jul 18 14:34:49 2008 +0100
+++ b/extras/mini-os/include/mm.h       Fri Jul 18 15:42:09 2008 +0100
@@ -65,6 +65,7 @@
 void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p);
 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,
        unsigned long increment, unsigned long alignment, domid_t id,

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] mini-os: export allocate_ondemand, Samuel Thibault <=