ia64/xen-unstable

changeset 18111:d85714c0a742

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>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jul 18 15:45:06 2008 +0100 (2008-07-18)
parents 60828077e175
children 689d31301c67
files extras/mini-os/arch/ia64/mm.c extras/mini-os/arch/x86/mm.c extras/mini-os/include/mm.h
line diff
     1.1 --- a/extras/mini-os/arch/ia64/mm.c	Fri Jul 18 15:44:39 2008 +0100
     1.2 +++ b/extras/mini-os/arch/ia64/mm.c	Fri Jul 18 15:45:06 2008 +0100
     1.3 @@ -130,6 +130,11 @@ arch_init_demand_mapping_area(unsigned l
     1.4  	max_pfn = max_pfn;
     1.5  }
     1.6  
     1.7 +unsigned long allocate_ondemand(unsigned long n, unsigned long alignment)
     1.8 +{
     1.9 +        return 0;
    1.10 +}
    1.11 +
    1.12  /* Helper function used in gnttab.c. */
    1.13  void do_map_frames(unsigned long addr,
    1.14          unsigned long *f, unsigned long n, unsigned long stride,
     2.1 --- a/extras/mini-os/arch/x86/mm.c	Fri Jul 18 15:44:39 2008 +0100
     2.2 +++ b/extras/mini-os/arch/x86/mm.c	Fri Jul 18 15:45:06 2008 +0100
     2.3 @@ -492,9 +492,7 @@ void do_map_frames(unsigned long addr,
     2.4      }
     2.5  }
     2.6  
     2.7 -void *map_frames_ex(unsigned long *f, unsigned long n, unsigned long stride,
     2.8 -	unsigned long increment, unsigned long alignment, domid_t id,
     2.9 -	int may_fail, unsigned long prot)
    2.10 +unsigned long allocate_ondemand(unsigned long n, unsigned long alignment)
    2.11  {
    2.12      unsigned long x;
    2.13      unsigned long y = 0;
    2.14 @@ -517,13 +515,24 @@ void *map_frames_ex(unsigned long *f, un
    2.15      }
    2.16      if (y != n) {
    2.17          printk("Failed to find %ld frames!\n", n);
    2.18 +        return 0;
    2.19 +    }
    2.20 +    return demand_map_area_start + x * PAGE_SIZE;
    2.21 +}
    2.22 +
    2.23 +void *map_frames_ex(unsigned long *f, unsigned long n, unsigned long stride,
    2.24 +	unsigned long increment, unsigned long alignment, domid_t id,
    2.25 +	int may_fail, unsigned long prot)
    2.26 +{
    2.27 +    unsigned long addr = allocate_ondemand(n, alignment);
    2.28 +
    2.29 +    if (!addr)
    2.30          return NULL;
    2.31 -    }
    2.32  
    2.33      /* Found it at x.  Map it in. */
    2.34 -    do_map_frames(demand_map_area_start + x * PAGE_SIZE, f, n, stride, increment, id, may_fail, prot);
    2.35 +    do_map_frames(addr, f, n, stride, increment, id, may_fail, prot);
    2.36  
    2.37 -    return (void *)(unsigned long)(demand_map_area_start + x * PAGE_SIZE);
    2.38 +    return (void *)addr;
    2.39  }
    2.40  
    2.41  static void clear_bootstrap(void)
     3.1 --- a/extras/mini-os/include/mm.h	Fri Jul 18 15:44:39 2008 +0100
     3.2 +++ b/extras/mini-os/include/mm.h	Fri Jul 18 15:45:06 2008 +0100
     3.3 @@ -63,6 +63,7 @@ void arch_init_demand_mapping_area(unsig
     3.4  void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p);
     3.5  void arch_init_p2m(unsigned long max_pfn_p);
     3.6  
     3.7 +unsigned long allocate_ondemand(unsigned long n, unsigned long alignment);
     3.8  /* map f[i*stride]+i*increment for i in 0..n-1, aligned on alignment pages */
     3.9  void *map_frames_ex(unsigned long *f, unsigned long n, unsigned long stride,
    3.10  	unsigned long increment, unsigned long alignment, domid_t id,