aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386
diff options
context:
space:
mode:
Diffstat (limited to 'arch/i386')
-rw-r--r--arch/i386/kernel/e820.c52
-rw-r--r--arch/i386/kernel/setup.c55
2 files changed, 52 insertions, 55 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}
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index b7509aec0eb1..3d808054fdf7 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -63,9 +63,6 @@
63#include <setup_arch.h> 63#include <setup_arch.h>
64#include <bios_ebda.h> 64#include <bios_ebda.h>
65 65
66/* Forward Declaration. */
67void __init find_max_pfn(void);
68
69/* This value is set up by the early boot code to point to the value 66/* This value is set up by the early boot code to point to the value
70 immediately after the boot time page tables. It contains a *physical* 67 immediately after the boot time page tables. It contains a *physical*
71 address, and must not be in the .bss segment! */ 68 address, and must not be in the .bss segment! */
@@ -387,29 +384,6 @@ static int __init parse_reservetop(char *arg)
387} 384}
388early_param("reservetop", parse_reservetop); 385early_param("reservetop", parse_reservetop);
389 386
390/*
391 * Callback for efi_memory_walk.
392 */
393static int __init
394efi_find_max_pfn(unsigned long start, unsigned long end, void *arg)
395{
396 unsigned long *max_pfn = arg, pfn;
397
398 if (start < end) {
399 pfn = PFN_UP(end -1);
400 if (pfn > *max_pfn)
401 *max_pfn = pfn;
402 }
403 return 0;
404}
405
406static int __init
407efi_memory_present_wrapper(unsigned long start, unsigned long end, void *arg)
408{
409 memory_present(0, PFN_UP(start), PFN_DOWN(end));
410 return 0;
411}
412
413 /* 387 /*
414 * This function checks if the entire range <start,end> is mapped with type. 388 * This function checks if the entire range <start,end> is mapped with type.
415 * 389 *
@@ -443,35 +417,6 @@ e820_all_mapped(unsigned long s, unsigned long e, unsigned type)
443} 417}
444 418
445/* 419/*
446 * Find the highest page frame number we have available
447 */
448void __init find_max_pfn(void)
449{
450 int i;
451
452 max_pfn = 0;
453 if (efi_enabled) {
454 efi_memmap_walk(efi_find_max_pfn, &max_pfn);
455 efi_memmap_walk(efi_memory_present_wrapper, NULL);
456 return;
457 }
458
459 for (i = 0; i < e820.nr_map; i++) {
460 unsigned long start, end;
461 /* RAM? */
462 if (e820.map[i].type != E820_RAM)
463 continue;
464 start = PFN_UP(e820.map[i].addr);
465 end = PFN_DOWN(e820.map[i].addr + e820.map[i].size);
466 if (start >= end)
467 continue;
468 if (end > max_pfn)
469 max_pfn = end;
470 memory_present(0, start, end);
471 }
472}
473
474/*
475 * Determine low and high memory ranges: 420 * Determine low and high memory ranges:
476 */ 421 */
477unsigned long __init find_max_low_pfn(void) 422unsigned long __init find_max_low_pfn(void)