diff options
author | Yinghai Lu <yinghai@kernel.org> | 2010-02-10 04:20:26 -0500 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2010-02-12 12:42:39 -0500 |
commit | efdd0e81df0f23830c6d2cb971cf87f415b8dbdb (patch) | |
tree | 377941fbfeee4cd887ace1de0826a8df03aa965c | |
parent | 7da657d1f1dd27fa9d8289d5f7e53479c7fd3a95 (diff) |
x86: Move back find_e820_area to e820.c
Makes early_res.c more clean, so later could move it to /kernel.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
LKML-Reference: <1265793639-15071-23-git-send-email-yinghai@kernel.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | arch/x86/include/asm/e820.h | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/early_res.h | 4 | ||||
-rw-r--r-- | arch/x86/kernel/e820.c | 53 | ||||
-rw-r--r-- | arch/x86/kernel/early_res.c | 57 |
4 files changed, 57 insertions, 59 deletions
diff --git a/arch/x86/include/asm/e820.h b/arch/x86/include/asm/e820.h index efad699a2c22..a8299e134437 100644 --- a/arch/x86/include/asm/e820.h +++ b/arch/x86/include/asm/e820.h | |||
@@ -109,6 +109,8 @@ static inline void early_memtest(unsigned long start, unsigned long end) | |||
109 | 109 | ||
110 | extern unsigned long end_user_pfn; | 110 | extern unsigned long end_user_pfn; |
111 | 111 | ||
112 | extern u64 find_e820_area(u64 start, u64 end, u64 size, u64 align); | ||
113 | extern u64 find_e820_area_size(u64 start, u64 *sizep, u64 align); | ||
112 | extern u64 early_reserve_e820(u64 startt, u64 sizet, u64 align); | 114 | extern u64 early_reserve_e820(u64 startt, u64 sizet, u64 align); |
113 | #include <asm/early_res.h> | 115 | #include <asm/early_res.h> |
114 | 116 | ||
diff --git a/arch/x86/include/asm/early_res.h b/arch/x86/include/asm/early_res.h index 2d43b166782d..5a4d2eb8e79c 100644 --- a/arch/x86/include/asm/early_res.h +++ b/arch/x86/include/asm/early_res.h | |||
@@ -2,8 +2,6 @@ | |||
2 | #define _ASM_X86_EARLY_RES_H | 2 | #define _ASM_X86_EARLY_RES_H |
3 | #ifdef __KERNEL__ | 3 | #ifdef __KERNEL__ |
4 | 4 | ||
5 | extern u64 find_e820_area(u64 start, u64 end, u64 size, u64 align); | ||
6 | extern u64 find_e820_area_size(u64 start, u64 *sizep, u64 align); | ||
7 | extern void reserve_early(u64 start, u64 end, char *name); | 5 | extern void reserve_early(u64 start, u64 end, char *name); |
8 | extern void reserve_early_overlap_ok(u64 start, u64 end, char *name); | 6 | extern void reserve_early_overlap_ok(u64 start, u64 end, char *name); |
9 | extern void free_early(u64 start, u64 end); | 7 | extern void free_early(u64 start, u64 end); |
@@ -12,6 +10,8 @@ extern void early_res_to_bootmem(u64 start, u64 end); | |||
12 | void reserve_early_without_check(u64 start, u64 end, char *name); | 10 | void reserve_early_without_check(u64 start, u64 end, char *name); |
13 | u64 find_early_area(u64 ei_start, u64 ei_last, u64 start, u64 end, | 11 | u64 find_early_area(u64 ei_start, u64 ei_last, u64 start, u64 end, |
14 | u64 size, u64 align); | 12 | u64 size, u64 align); |
13 | u64 find_early_area_size(u64 ei_start, u64 ei_last, u64 start, | ||
14 | u64 *sizep, u64 align); | ||
15 | #include <linux/range.h> | 15 | #include <linux/range.h> |
16 | int get_free_all_memory_range(struct range **rangep, int nodeid); | 16 | int get_free_all_memory_range(struct range **rangep, int nodeid); |
17 | 17 | ||
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 82db4015604e..b4e512b03aa7 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c | |||
@@ -723,6 +723,59 @@ core_initcall(e820_mark_nvs_memory); | |||
723 | #endif | 723 | #endif |
724 | 724 | ||
725 | /* | 725 | /* |
726 | * Find a free area with specified alignment in a specific range. | ||
727 | */ | ||
728 | u64 __init find_e820_area(u64 start, u64 end, u64 size, u64 align) | ||
729 | { | ||
730 | int i; | ||
731 | |||
732 | for (i = 0; i < e820.nr_map; i++) { | ||
733 | struct e820entry *ei = &e820.map[i]; | ||
734 | u64 addr; | ||
735 | u64 ei_start, ei_last; | ||
736 | |||
737 | if (ei->type != E820_RAM) | ||
738 | continue; | ||
739 | |||
740 | ei_last = ei->addr + ei->size; | ||
741 | ei_start = ei->addr; | ||
742 | addr = find_early_area(ei_start, ei_last, start, end, | ||
743 | size, align); | ||
744 | |||
745 | if (addr != -1ULL) | ||
746 | return addr; | ||
747 | } | ||
748 | return -1ULL; | ||
749 | } | ||
750 | |||
751 | /* | ||
752 | * Find next free range after *start | ||
753 | */ | ||
754 | u64 __init find_e820_area_size(u64 start, u64 *sizep, u64 align) | ||
755 | { | ||
756 | int i; | ||
757 | |||
758 | for (i = 0; i < e820.nr_map; i++) { | ||
759 | struct e820entry *ei = &e820.map[i]; | ||
760 | u64 addr; | ||
761 | u64 ei_start, ei_last; | ||
762 | |||
763 | if (ei->type != E820_RAM) | ||
764 | continue; | ||
765 | |||
766 | ei_last = ei->addr + ei->size; | ||
767 | ei_start = ei->addr; | ||
768 | addr = find_early_area_size(ei_start, ei_last, start, | ||
769 | sizep, align); | ||
770 | |||
771 | if (addr != -1ULL) | ||
772 | return addr; | ||
773 | } | ||
774 | |||
775 | return -1ULL; | ||
776 | } | ||
777 | |||
778 | /* | ||
726 | * pre allocated 4k and reserved it in e820 | 779 | * pre allocated 4k and reserved it in e820 |
727 | */ | 780 | */ |
728 | u64 __init early_reserve_e820(u64 startt, u64 sizet, u64 align) | 781 | u64 __init early_reserve_e820(u64 startt, u64 sizet, u64 align) |
diff --git a/arch/x86/kernel/early_res.c b/arch/x86/kernel/early_res.c index bfa1ba705d48..1b99a2619f9f 100644 --- a/arch/x86/kernel/early_res.c +++ b/arch/x86/kernel/early_res.c | |||
@@ -498,60 +498,3 @@ u64 __init find_early_area_size(u64 ei_start, u64 ei_last, u64 start, | |||
498 | out: | 498 | out: |
499 | return -1ULL; | 499 | return -1ULL; |
500 | } | 500 | } |
501 | |||
502 | /* | ||
503 | * Find a free area with specified alignment in a specific range. | ||
504 | */ | ||
505 | u64 __init find_e820_area(u64 start, u64 end, u64 size, u64 align) | ||
506 | { | ||
507 | int i; | ||
508 | |||
509 | for (i = 0; i < e820.nr_map; i++) { | ||
510 | struct e820entry *ei = &e820.map[i]; | ||
511 | u64 addr; | ||
512 | u64 ei_start, ei_last; | ||
513 | |||
514 | if (ei->type != E820_RAM) | ||
515 | continue; | ||
516 | |||
517 | ei_last = ei->addr + ei->size; | ||
518 | ei_start = ei->addr; | ||
519 | addr = find_early_area(ei_start, ei_last, start, end, | ||
520 | size, align); | ||
521 | |||
522 | if (addr == -1ULL) | ||
523 | continue; | ||
524 | |||
525 | return addr; | ||
526 | } | ||
527 | return -1ULL; | ||
528 | } | ||
529 | |||
530 | /* | ||
531 | * Find next free range after *start | ||
532 | */ | ||
533 | u64 __init find_e820_area_size(u64 start, u64 *sizep, u64 align) | ||
534 | { | ||
535 | int i; | ||
536 | |||
537 | for (i = 0; i < e820.nr_map; i++) { | ||
538 | struct e820entry *ei = &e820.map[i]; | ||
539 | u64 addr; | ||
540 | u64 ei_start, ei_last; | ||
541 | |||
542 | if (ei->type != E820_RAM) | ||
543 | continue; | ||
544 | |||
545 | ei_last = ei->addr + ei->size; | ||
546 | ei_start = ei->addr; | ||
547 | addr = find_early_area_size(ei_start, ei_last, start, | ||
548 | sizep, align); | ||
549 | |||
550 | if (addr == -1ULL) | ||
551 | continue; | ||
552 | |||
553 | return addr; | ||
554 | } | ||
555 | |||
556 | return -1ULL; | ||
557 | } | ||