diff options
Diffstat (limited to 'arch/x86/mm/memblock.c')
-rw-r--r-- | arch/x86/mm/memblock.c | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/arch/x86/mm/memblock.c b/arch/x86/mm/memblock.c index 4107c1a32b78..a9d0972df10a 100644 --- a/arch/x86/mm/memblock.c +++ b/arch/x86/mm/memblock.c | |||
@@ -7,93 +7,6 @@ | |||
7 | #include <linux/mm.h> | 7 | #include <linux/mm.h> |
8 | #include <linux/range.h> | 8 | #include <linux/range.h> |
9 | 9 | ||
10 | static __init struct range *find_range_array(int count) | ||
11 | { | ||
12 | u64 end, size, mem; | ||
13 | struct range *range; | ||
14 | |||
15 | size = sizeof(struct range) * count; | ||
16 | end = memblock.current_limit; | ||
17 | |||
18 | mem = memblock_find_in_range(0, end, size, sizeof(struct range)); | ||
19 | if (!mem) | ||
20 | panic("can not find more space for range array"); | ||
21 | |||
22 | /* | ||
23 | * This range is tempoaray, so don't reserve it, it will not be | ||
24 | * overlapped because We will not alloccate new buffer before | ||
25 | * We discard this one | ||
26 | */ | ||
27 | range = __va(mem); | ||
28 | memset(range, 0, size); | ||
29 | |||
30 | return range; | ||
31 | } | ||
32 | |||
33 | static u64 __init __memblock_x86_memory_in_range(u64 addr, u64 limit, bool get_free) | ||
34 | { | ||
35 | int i, count; | ||
36 | struct range *range; | ||
37 | int nr_range; | ||
38 | u64 final_start, final_end; | ||
39 | u64 free_size; | ||
40 | struct memblock_region *r; | ||
41 | |||
42 | count = (memblock.reserved.cnt + memblock.memory.cnt) * 2; | ||
43 | |||
44 | range = find_range_array(count); | ||
45 | nr_range = 0; | ||
46 | |||
47 | addr = PFN_UP(addr); | ||
48 | limit = PFN_DOWN(limit); | ||
49 | |||
50 | for_each_memblock(memory, r) { | ||
51 | final_start = PFN_UP(r->base); | ||
52 | final_end = PFN_DOWN(r->base + r->size); | ||
53 | if (final_start >= final_end) | ||
54 | continue; | ||
55 | if (final_start >= limit || final_end <= addr) | ||
56 | continue; | ||
57 | |||
58 | nr_range = add_range(range, count, nr_range, final_start, final_end); | ||
59 | } | ||
60 | subtract_range(range, count, 0, addr); | ||
61 | subtract_range(range, count, limit, -1ULL); | ||
62 | |||
63 | /* Subtract memblock.reserved.region in range ? */ | ||
64 | if (!get_free) | ||
65 | goto sort_and_count_them; | ||
66 | for_each_memblock(reserved, r) { | ||
67 | final_start = PFN_DOWN(r->base); | ||
68 | final_end = PFN_UP(r->base + r->size); | ||
69 | if (final_start >= final_end) | ||
70 | continue; | ||
71 | if (final_start >= limit || final_end <= addr) | ||
72 | continue; | ||
73 | |||
74 | subtract_range(range, count, final_start, final_end); | ||
75 | } | ||
76 | |||
77 | sort_and_count_them: | ||
78 | nr_range = clean_sort_range(range, count); | ||
79 | |||
80 | free_size = 0; | ||
81 | for (i = 0; i < nr_range; i++) | ||
82 | free_size += range[i].end - range[i].start; | ||
83 | |||
84 | return free_size << PAGE_SHIFT; | ||
85 | } | ||
86 | |||
87 | u64 __init memblock_x86_free_memory_in_range(u64 addr, u64 limit) | ||
88 | { | ||
89 | return __memblock_x86_memory_in_range(addr, limit, true); | ||
90 | } | ||
91 | |||
92 | u64 __init memblock_x86_memory_in_range(u64 addr, u64 limit) | ||
93 | { | ||
94 | return __memblock_x86_memory_in_range(addr, limit, false); | ||
95 | } | ||
96 | |||
97 | void __init memblock_x86_reserve_range(u64 start, u64 end, char *name) | 10 | void __init memblock_x86_reserve_range(u64 start, u64 end, char *name) |
98 | { | 11 | { |
99 | if (start == end) | 12 | if (start == end) |