Skip to content

Commit

Permalink
mini-os: export allocate_ondemand
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Samuel Thibault authored and Keir Fraser committed Jul 18, 2008
1 parent fffb164 commit 9f79d17
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
5 changes: 5 additions & 0 deletions arch/ia64/mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ arch_init_demand_mapping_area(unsigned long max_pfn)
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,
Expand Down
21 changes: 15 additions & 6 deletions arch/x86/mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions include/mm.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ void arch_init_demand_mapping_area(unsigned long max_pfn);
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,
Expand Down

0 comments on commit 9f79d17

Please sign in to comment.