diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2008-07-18 15:45:06 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2008-07-18 15:45:06 +0100 |
commit | ca28885fa775d60ad15575f58930c138141e682f (patch) | |
tree | 0f201418571543b344d64811c4550380bf35bb93 /extras/mini-os/arch/x86 | |
parent | 93a9aafe96ecb28c4271adb1e227a49c343f1574 (diff) | |
download | xen-ca28885fa775d60ad15575f58930c138141e682f.tar.gz xen-ca28885fa775d60ad15575f58930c138141e682f.tar.bz2 xen-ca28885fa775d60ad15575f58930c138141e682f.zip |
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@eu.citrix.com>
Diffstat (limited to 'extras/mini-os/arch/x86')
-rw-r--r-- | extras/mini-os/arch/x86/mm.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/extras/mini-os/arch/x86/mm.c b/extras/mini-os/arch/x86/mm.c index e528647ca8..b1c0084fe7 100644 --- a/extras/mini-os/arch/x86/mm.c +++ b/extras/mini-os/arch/x86/mm.c @@ -492,9 +492,7 @@ void do_map_frames(unsigned long addr, } } -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 @@ void *map_frames_ex(unsigned long *f, unsigned long n, unsigned long stride, } if (y != n) { printk("Failed to find %ld frames!\n", n); - return NULL; + 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) |