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
|