aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/include/asm/e820.h2
-rw-r--r--arch/x86/include/asm/early_res.h4
-rw-r--r--arch/x86/kernel/e820.c53
-rw-r--r--arch/x86/kernel/early_res.c57
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
110extern unsigned long end_user_pfn; 110extern unsigned long end_user_pfn;
111 111
112extern u64 find_e820_area(u64 start, u64 end, u64 size, u64 align);
113extern u64 find_e820_area_size(u64 start, u64 *sizep, u64 align);
112extern u64 early_reserve_e820(u64 startt, u64 sizet, u64 align); 114extern 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
5extern u64 find_e820_area(u64 start, u64 end, u64 size, u64 align);
6extern u64 find_e820_area_size(u64 start, u64 *sizep, u64 align);
7extern void reserve_early(u64 start, u64 end, char *name); 5extern void reserve_early(u64 start, u64 end, char *name);
8extern void reserve_early_overlap_ok(u64 start, u64 end, char *name); 6extern void reserve_early_overlap_ok(u64 start, u64 end, char *name);
9extern void free_early(u64 start, u64 end); 7extern void free_early(u64 start, u64 end);
@@ -12,6 +10,8 @@ extern void early_res_to_bootmem(u64 start, u64 end);
12void reserve_early_without_check(u64 start, u64 end, char *name); 10void reserve_early_without_check(u64 start, u64 end, char *name);
13u64 find_early_area(u64 ei_start, u64 ei_last, u64 start, u64 end, 11u64 find_early_area(u64 ei_start, u64 ei_last, u64 start, u64 end,
14 u64 size, u64 align); 12 u64 size, u64 align);
13u64 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>
16int get_free_all_memory_range(struct range **rangep, int nodeid); 16int 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 */
728u64 __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 */
754u64 __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 */
728u64 __init early_reserve_e820(u64 startt, u64 sizet, u64 align) 781u64 __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,
498out: 498out:
499 return -1ULL; 499 return -1ULL;
500} 500}
501
502/*
503 * Find a free area with specified alignment in a specific range.
504 */
505u64 __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 */
533u64 __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}