diff options
Diffstat (limited to 'arch/x86_64/kernel/e820.c')
-rw-r--r-- | arch/x86_64/kernel/e820.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/arch/x86_64/kernel/e820.c b/arch/x86_64/kernel/e820.c index 6ded3a50dfe6..b548dea4e5b9 100644 --- a/arch/x86_64/kernel/e820.c +++ b/arch/x86_64/kernel/e820.c | |||
@@ -185,6 +185,40 @@ unsigned long __init e820_end_of_ram(void) | |||
185 | } | 185 | } |
186 | 186 | ||
187 | /* | 187 | /* |
188 | * Compute how much memory is missing in a range. | ||
189 | * Unlike the other functions in this file the arguments are in page numbers. | ||
190 | */ | ||
191 | unsigned long __init | ||
192 | e820_hole_size(unsigned long start_pfn, unsigned long end_pfn) | ||
193 | { | ||
194 | unsigned long ram = 0; | ||
195 | unsigned long start = start_pfn << PAGE_SHIFT; | ||
196 | unsigned long end = end_pfn << PAGE_SHIFT; | ||
197 | int i; | ||
198 | for (i = 0; i < e820.nr_map; i++) { | ||
199 | struct e820entry *ei = &e820.map[i]; | ||
200 | unsigned long last, addr; | ||
201 | |||
202 | if (ei->type != E820_RAM || | ||
203 | ei->addr+ei->size <= start || | ||
204 | ei->addr >= end) | ||
205 | continue; | ||
206 | |||
207 | addr = round_up(ei->addr, PAGE_SIZE); | ||
208 | if (addr < start) | ||
209 | addr = start; | ||
210 | |||
211 | last = round_down(ei->addr + ei->size, PAGE_SIZE); | ||
212 | if (last >= end) | ||
213 | last = end; | ||
214 | |||
215 | if (last > addr) | ||
216 | ram += last - addr; | ||
217 | } | ||
218 | return ((end - start) - ram) >> PAGE_SHIFT; | ||
219 | } | ||
220 | |||
221 | /* | ||
188 | * Mark e820 reserved areas as busy for the resource manager. | 222 | * Mark e820 reserved areas as busy for the resource manager. |
189 | */ | 223 | */ |
190 | void __init e820_reserve_resources(void) | 224 | void __init e820_reserve_resources(void) |