aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/e820_32.c
diff options
context:
space:
mode:
authorHuang, Ying <ying.huang@intel.com>2008-01-30 07:31:19 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:31:19 -0500
commit2215e69d2cf5024647f9a034807990590d25dd4e (patch)
tree89b82b38e515d6e540420347151472d78adc8a51 /arch/x86/kernel/e820_32.c
parente429795c68d3001ecae74f6465420c9f043b0ece (diff)
x86 boot: use E820 memory map on EFI 32 platform
Because the EFI memory map are converted to e820 memory map in bootloader, the EFI memory map handling code is removed to clean up. Signed-off-by: Huang Ying <ying.huang@intel.com> Cc: Andi Kleen <ak@suse.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/e820_32.c')
-rw-r--r--arch/x86/kernel/e820_32.c117
1 files changed, 10 insertions, 107 deletions
diff --git a/arch/x86/kernel/e820_32.c b/arch/x86/kernel/e820_32.c
index 56335a85a15a..931934a7b353 100644
--- a/arch/x86/kernel/e820_32.c
+++ b/arch/x86/kernel/e820_32.c
@@ -7,7 +7,6 @@
7#include <linux/kexec.h> 7#include <linux/kexec.h>
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>
11#include <linux/pfn.h> 10#include <linux/pfn.h>
12#include <linux/uaccess.h> 11#include <linux/uaccess.h>
13#include <linux/suspend.h> 12#include <linux/suspend.h>
@@ -181,7 +180,7 @@ static void __init probe_roms(void)
181 * Request address space for all standard RAM and ROM resources 180 * Request address space for all standard RAM and ROM resources
182 * and also for regions reported as reserved by the e820. 181 * and also for regions reported as reserved by the e820.
183 */ 182 */
184void __init legacy_init_iomem_resources(struct resource *code_resource, 183void __init init_iomem_resources(struct resource *code_resource,
185 struct resource *data_resource, 184 struct resource *data_resource,
186 struct resource *bss_resource) 185 struct resource *bss_resource)
187{ 186{
@@ -261,19 +260,17 @@ void __init add_memory_region(unsigned long long start,
261{ 260{
262 int x; 261 int x;
263 262
264 if (!efi_enabled) { 263 x = e820.nr_map;
265 x = e820.nr_map;
266 264
267 if (x == E820MAX) { 265 if (x == E820MAX) {
268 printk(KERN_ERR "Ooops! Too many entries in the memory map!\n"); 266 printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
269 return; 267 return;
270 }
271
272 e820.map[x].addr = start;
273 e820.map[x].size = size;
274 e820.map[x].type = type;
275 e820.nr_map++;
276 } 268 }
269
270 e820.map[x].addr = start;
271 e820.map[x].size = size;
272 e820.map[x].type = type;
273 e820.nr_map++;
277} /* add_memory_region */ 274} /* add_memory_region */
278 275
279/* 276/*
@@ -489,29 +486,6 @@ int __init copy_e820_map(struct e820entry * biosmap, int nr_map)
489} 486}
490 487
491/* 488/*
492 * Callback for efi_memory_walk.
493 */
494static int __init
495efi_find_max_pfn(unsigned long start, unsigned long end, void *arg)
496{
497 unsigned long *max_pfn = arg, pfn;
498
499 if (start < end) {
500 pfn = PFN_UP(end -1);
501 if (pfn > *max_pfn)
502 *max_pfn = pfn;
503 }
504 return 0;
505}
506
507static int __init
508efi_memory_present_wrapper(unsigned long start, unsigned long end, void *arg)
509{
510 memory_present(0, PFN_UP(start), PFN_DOWN(end));
511 return 0;
512}
513
514/*
515 * Find the highest page frame number we have available 489 * Find the highest page frame number we have available
516 */ 490 */
517void __init find_max_pfn(void) 491void __init find_max_pfn(void)
@@ -519,11 +493,6 @@ void __init find_max_pfn(void)
519 int i; 493 int i;
520 494
521 max_pfn = 0; 495 max_pfn = 0;
522 if (efi_enabled) {
523 efi_memmap_walk(efi_find_max_pfn, &max_pfn);
524 efi_memmap_walk(efi_memory_present_wrapper, NULL);
525 return;
526 }
527 496
528 for (i = 0; i < e820.nr_map; i++) { 497 for (i = 0; i < e820.nr_map; i++) {
529 unsigned long start, end; 498 unsigned long start, end;
@@ -541,34 +510,12 @@ void __init find_max_pfn(void)
541} 510}
542 511
543/* 512/*
544 * Free all available memory for boot time allocation. Used
545 * as a callback function by efi_memory_walk()
546 */
547
548static int __init
549free_available_memory(unsigned long start, unsigned long end, void *arg)
550{
551 /* check max_low_pfn */
552 if (start >= (max_low_pfn << PAGE_SHIFT))
553 return 0;
554 if (end >= (max_low_pfn << PAGE_SHIFT))
555 end = max_low_pfn << PAGE_SHIFT;
556 if (start < end)
557 free_bootmem(start, end - start);
558
559 return 0;
560}
561/*
562 * Register fully available low RAM pages with the bootmem allocator. 513 * Register fully available low RAM pages with the bootmem allocator.
563 */ 514 */
564void __init register_bootmem_low_pages(unsigned long max_low_pfn) 515void __init register_bootmem_low_pages(unsigned long max_low_pfn)
565{ 516{
566 int i; 517 int i;
567 518
568 if (efi_enabled) {
569 efi_memmap_walk(free_available_memory, NULL);
570 return;
571 }
572 for (i = 0; i < e820.nr_map; i++) { 519 for (i = 0; i < e820.nr_map; i++) {
573 unsigned long curr_pfn, last_pfn, size; 520 unsigned long curr_pfn, last_pfn, size;
574 /* 521 /*
@@ -676,56 +623,12 @@ void __init print_memory_map(char *who)
676 } 623 }
677} 624}
678 625
679static __init __always_inline void efi_limit_regions(unsigned long long size)
680{
681 unsigned long long current_addr = 0;
682 efi_memory_desc_t *md, *next_md;
683 void *p, *p1;
684 int i, j;
685
686 j = 0;
687 p1 = memmap.map;
688 for (p = p1, i = 0; p < memmap.map_end; p += memmap.desc_size, i++) {
689 md = p;
690 next_md = p1;
691 current_addr = md->phys_addr +
692 PFN_PHYS(md->num_pages);
693 if (is_available_memory(md)) {
694 if (md->phys_addr >= size) continue;
695 memcpy(next_md, md, memmap.desc_size);
696 if (current_addr >= size) {
697 next_md->num_pages -=
698 PFN_UP(current_addr-size);
699 }
700 p1 += memmap.desc_size;
701 next_md = p1;
702 j++;
703 } else if ((md->attribute & EFI_MEMORY_RUNTIME) ==
704 EFI_MEMORY_RUNTIME) {
705 /* In order to make runtime services
706 * available we have to include runtime
707 * memory regions in memory map */
708 memcpy(next_md, md, memmap.desc_size);
709 p1 += memmap.desc_size;
710 next_md = p1;
711 j++;
712 }
713 }
714 memmap.nr_map = j;
715 memmap.map_end = memmap.map +
716 (memmap.nr_map * memmap.desc_size);
717}
718
719void __init limit_regions(unsigned long long size) 626void __init limit_regions(unsigned long long size)
720{ 627{
721 unsigned long long current_addr; 628 unsigned long long current_addr;
722 int i; 629 int i;
723 630
724 print_memory_map("limit_regions start"); 631 print_memory_map("limit_regions start");
725 if (efi_enabled) {
726 efi_limit_regions(size);
727 return;
728 }
729 for (i = 0; i < e820.nr_map; i++) { 632 for (i = 0; i < e820.nr_map; i++) {
730 current_addr = e820.map[i].addr + e820.map[i].size; 633 current_addr = e820.map[i].addr + e820.map[i].size;
731 if (current_addr < size) 634 if (current_addr < size)