aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386/kernel/e820.c
diff options
context:
space:
mode:
authorbibo,mao <bibo.mao@intel.com>2006-12-06 20:14:06 -0500
committerAndi Kleen <andi@basil.nowhere.org>2006-12-06 20:14:06 -0500
commitb2dff6a88cbed59d787a8ca7367c76ba385e1187 (patch)
treecc0d407ac764eda23f09181b447ce5d347d73ad5 /arch/i386/kernel/e820.c
parent8e3342f736dd1c19ce7c28625dedd7d8730fc7ad (diff)
[PATCH] i386: Move find_max_pfn function to e820.c
Move more code from setup.c into e820.c Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Andi Kleen <ak@suse.de>
Diffstat (limited to 'arch/i386/kernel/e820.c')
-rw-r--r--arch/i386/kernel/e820.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/arch/i386/kernel/e820.c b/arch/i386/kernel/e820.c
index 0db95760b073..be4934f6f85b 100644
--- a/arch/i386/kernel/e820.c
+++ b/arch/i386/kernel/e820.c
@@ -8,6 +8,7 @@
8#include <linux/module.h> 8#include <linux/module.h>
9#include <linux/mm.h> 9#include <linux/mm.h>
10#include <linux/efi.h> 10#include <linux/efi.h>
11#include <linux/pfn.h>
11 12
12#include <asm/pgtable.h> 13#include <asm/pgtable.h>
13#include <asm/page.h> 14#include <asm/page.h>
@@ -539,3 +540,54 @@ int __init copy_e820_map(struct e820entry * biosmap, int nr_map)
539 return 0; 540 return 0;
540} 541}
541 542
543/*
544 * Callback for efi_memory_walk.
545 */
546static int __init
547efi_find_max_pfn(unsigned long start, unsigned long end, void *arg)
548{
549 unsigned long *max_pfn = arg, pfn;
550
551 if (start < end) {
552 pfn = PFN_UP(end -1);
553 if (pfn > *max_pfn)
554 *max_pfn = pfn;
555 }
556 return 0;
557}
558
559static int __init
560efi_memory_present_wrapper(unsigned long start, unsigned long end, void *arg)
561{
562 memory_present(0, PFN_UP(start), PFN_DOWN(end));
563 return 0;
564}
565
566/*
567 * Find the highest page frame number we have available
568 */
569void __init find_max_pfn(void)
570{
571 int i;
572
573 max_pfn = 0;
574 if (efi_enabled) {
575 efi_memmap_walk(efi_find_max_pfn, &max_pfn);
576 efi_memmap_walk(efi_memory_present_wrapper, NULL);
577 return;
578 }
579
580 for (i = 0; i < e820.nr_map; i++) {
581 unsigned long start, end;
582 /* RAM? */
583 if (e820.map[i].type != E820_RAM)
584 continue;
585 start = PFN_UP(e820.map[i].addr);
586 end = PFN_DOWN(e820.map[i].addr + e820.map[i].size);
587 if (start >= end)
588 continue;
589 if (end > max_pfn)
590 max_pfn = end;
591 memory_present(0, start, end);
592 }
593}