Skip to content

Commit

Permalink
[Blackfin] arch: add code to initialize globals declared in linux/boo…
Browse files Browse the repository at this point in the history
…tmem.h: max_pfn, max_low_pfn, min_low_pfn.

Signed-off-by: Yi Li <yi.li@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
  • Loading branch information
Yi Li authored and Bryan Wu committed Mar 25, 2008
1 parent 9df7a8f commit 2e8d796
Showing 1 changed file with 45 additions and 7 deletions.
52 changes: 45 additions & 7 deletions arch/blackfin/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,11 +547,38 @@ static __init void memory_setup(void)
);
}

/*
* Find the lowest, highest page frame number we have available
*/
void __init find_min_max_pfn(void)
{
int i;

max_pfn = 0;
min_low_pfn = memory_end;

for (i = 0; i < bfin_memmap.nr_map; i++) {
unsigned long start, end;
/* RAM? */
if (bfin_memmap.map[i].type != BFIN_MEMMAP_RAM)
continue;
start = PFN_UP(bfin_memmap.map[i].addr);
end = PFN_DOWN(bfin_memmap.map[i].addr +
bfin_memmap.map[i].size);
if (start >= end)
continue;
if (end > max_pfn)
max_pfn = end;
if (start < min_low_pfn)
min_low_pfn = start;
}
}

static __init void setup_bootmem_allocator(void)
{
int bootmap_size;
int i;
unsigned long min_pfn, max_pfn;
unsigned long start_pfn, end_pfn;
unsigned long curr_pfn, last_pfn, size;

/* mark memory between memory_start and memory_end usable */
Expand All @@ -561,16 +588,27 @@ static __init void setup_bootmem_allocator(void)
sanitize_memmap(bfin_memmap.map, &bfin_memmap.nr_map);
print_memory_map("boot memmap");

min_pfn = PAGE_OFFSET >> PAGE_SHIFT;
max_pfn = memory_end >> PAGE_SHIFT;
/* intialize globals in linux/bootmem.h */
find_min_max_pfn();
/* pfn of the last usable page frame */
if (max_pfn > memory_end >> PAGE_SHIFT)
max_pfn = memory_end >> PAGE_SHIFT;
/* pfn of last page frame directly mapped by kernel */
max_low_pfn = max_pfn;
/* pfn of the first usable page frame after kernel image*/
if (min_low_pfn < memory_start >> PAGE_SHIFT)
min_low_pfn = memory_start >> PAGE_SHIFT;

start_pfn = PAGE_OFFSET >> PAGE_SHIFT;
end_pfn = memory_end >> PAGE_SHIFT;

/*
* give all the memory to the bootmap allocator, tell it to put the
* boot mem_map at the start of memory.
*/
bootmap_size = init_bootmem_node(NODE_DATA(0),
memory_start >> PAGE_SHIFT, /* map goes here */
min_pfn, max_pfn);
start_pfn, end_pfn);

/* register the memmap regions with the bootmem allocator */
for (i = 0; i < bfin_memmap.nr_map; i++) {
Expand All @@ -583,16 +621,16 @@ static __init void setup_bootmem_allocator(void)
* We are rounding up the start address of usable memory:
*/
curr_pfn = PFN_UP(bfin_memmap.map[i].addr);
if (curr_pfn >= max_pfn)
if (curr_pfn >= end_pfn)
continue;
/*
* ... and at the end of the usable range downwards:
*/
last_pfn = PFN_DOWN(bfin_memmap.map[i].addr +
bfin_memmap.map[i].size);

if (last_pfn > max_pfn)
last_pfn = max_pfn;
if (last_pfn > end_pfn)
last_pfn = end_pfn;

/*
* .. finally, did all the rounding and playing
Expand Down

0 comments on commit 2e8d796

Please sign in to comment.