aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/i386/kernel/setup.c30
-rw-r--r--arch/x86_64/kernel/e820.c33
-rw-r--r--include/asm-i386/e820.h4
-rw-r--r--include/asm-x86_64/e820.h1
4 files changed, 68 insertions, 0 deletions
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index eacc3f0a2ea4..8e70894a9f86 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -963,6 +963,36 @@ efi_memory_present_wrapper(unsigned long start, unsigned long end, void *arg)
963 return 0; 963 return 0;
964} 964}
965 965
966 /*
967 * This function checks if the entire range <start,end> is mapped with type.
968 *
969 * Note: this function only works correct if the e820 table is sorted and
970 * not-overlapping, which is the case
971 */
972int __init
973e820_all_mapped(unsigned long start, unsigned long end, unsigned type)
974{
975 int i;
976 for (i = 0; i < e820.nr_map; i++) {
977 struct e820entry *ei = &e820.map[i];
978 if (type && ei->type != type)
979 continue;
980 /* is the region (part) in overlap with the current region ?*/
981 if (ei->addr >= end || ei->addr + ei->size <= start)
982 continue;
983 /* if the region is at the beginning of <start,end> we move
984 * start to the end of the region since it's ok until there
985 */
986 if (ei->addr <= start)
987 start = ei->addr + ei->size;
988 /* if start is now at or beyond end, we're done, full
989 * coverage */
990 if (start >= end)
991 return 1; /* we're done */
992 }
993 return 0;
994}
995
966/* 996/*
967 * Find the highest page frame number we have available 997 * Find the highest page frame number we have available
968 */ 998 */
diff --git a/arch/x86_64/kernel/e820.c b/arch/x86_64/kernel/e820.c
index 1bee3184c5ab..62776c07cff1 100644
--- a/arch/x86_64/kernel/e820.c
+++ b/arch/x86_64/kernel/e820.c
@@ -80,6 +80,10 @@ static inline int bad_addr(unsigned long *addrp, unsigned long size)
80 return 0; 80 return 0;
81} 81}
82 82
83/*
84 * This function checks if any part of the range <start,end> is mapped
85 * with type.
86 */
83int __meminit 87int __meminit
84e820_any_mapped(unsigned long start, unsigned long end, unsigned type) 88e820_any_mapped(unsigned long start, unsigned long end, unsigned type)
85{ 89{
@@ -95,6 +99,35 @@ e820_any_mapped(unsigned long start, unsigned long end, unsigned type)
95 return 0; 99 return 0;
96} 100}
97 101
102/*
103 * This function checks if the entire range <start,end> is mapped with type.
104 *
105 * Note: this function only works correct if the e820 table is sorted and
106 * not-overlapping, which is the case
107 */
108int __init e820_all_mapped(unsigned long start, unsigned long end, unsigned type)
109{
110 int i;
111 for (i = 0; i < e820.nr_map; i++) {
112 struct e820entry *ei = &e820.map[i];
113 if (type && ei->type != type)
114 continue;
115 /* is the region (part) in overlap with the current region ?*/
116 if (ei->addr >= end || ei->addr + ei->size <= start)
117 continue;
118
119 /* if the region is at the beginning of <start,end> we move
120 * start to the end of the region since it's ok until there
121 */
122 if (ei->addr <= start)
123 start = ei->addr + ei->size;
124 /* if start is now at or beyond end, we're done, full coverage */
125 if (start >= end)
126 return 1; /* we're done */
127 }
128 return 0;
129}
130
98/* 131/*
99 * Find a free area in a specific range. 132 * Find a free area in a specific range.
100 */ 133 */
diff --git a/include/asm-i386/e820.h b/include/asm-i386/e820.h
index edf65be21a92..ca82acb8cb1f 100644
--- a/include/asm-i386/e820.h
+++ b/include/asm-i386/e820.h
@@ -35,6 +35,10 @@ struct e820map {
35}; 35};
36 36
37extern struct e820map e820; 37extern struct e820map e820;
38
39extern int e820_all_mapped(unsigned long start, unsigned long end,
40 unsigned type);
41
38#endif/*!__ASSEMBLY__*/ 42#endif/*!__ASSEMBLY__*/
39 43
40#endif/*__E820_HEADER*/ 44#endif/*__E820_HEADER*/
diff --git a/include/asm-x86_64/e820.h b/include/asm-x86_64/e820.h
index 4192d0ef093b..93b51df51687 100644
--- a/include/asm-x86_64/e820.h
+++ b/include/asm-x86_64/e820.h
@@ -48,6 +48,7 @@ extern unsigned long e820_end_of_ram(void);
48extern void e820_reserve_resources(void); 48extern void e820_reserve_resources(void);
49extern void e820_print_map(char *who); 49extern void e820_print_map(char *who);
50extern int e820_any_mapped(unsigned long start, unsigned long end, unsigned type); 50extern int e820_any_mapped(unsigned long start, unsigned long end, unsigned type);
51extern int e820_all_mapped(unsigned long start, unsigned long end, unsigned type);
51 52
52extern void e820_bootmem_free(pg_data_t *pgdat, unsigned long start,unsigned long end); 53extern void e820_bootmem_free(pg_data_t *pgdat, unsigned long start,unsigned long end);
53extern void e820_setup_gap(void); 54extern void e820_setup_gap(void);