diff options
author | Yinghai Lu <Yinghai.Lu@Sun.COM> | 2008-04-17 11:40:45 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-04-17 11:40:45 -0400 |
commit | 48c508b364324c35018284328b5b92c51d2b30e0 (patch) | |
tree | 664a69bcb8b583d526af6d870fa6efeb6d83c02f | |
parent | ef9257668e3199f9566dc4a31f5292838bd99b49 (diff) |
x86: clean up find_e820_area(), 64-bit
Change size to unsigned long, becase caller and user all used unsigned long.
Also make bad_addr take an alignment parameter.
Signed-off-by: Yinghai Lu <yinghai.lu@sun.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | arch/x86/kernel/e820_64.c | 22 | ||||
-rw-r--r-- | include/asm-x86/e820_64.h | 2 |
2 files changed, 13 insertions, 11 deletions
diff --git a/arch/x86/kernel/e820_64.c b/arch/x86/kernel/e820_64.c index 9be697126013..a8694a35352b 100644 --- a/arch/x86/kernel/e820_64.c +++ b/arch/x86/kernel/e820_64.c | |||
@@ -95,7 +95,8 @@ void __init early_res_to_bootmem(void) | |||
95 | } | 95 | } |
96 | 96 | ||
97 | /* Check for already reserved areas */ | 97 | /* Check for already reserved areas */ |
98 | static inline int bad_addr(unsigned long *addrp, unsigned long size) | 98 | static inline int |
99 | bad_addr(unsigned long *addrp, unsigned long size, unsigned long align) | ||
99 | { | 100 | { |
100 | int i; | 101 | int i; |
101 | unsigned long addr = *addrp, last; | 102 | unsigned long addr = *addrp, last; |
@@ -105,7 +106,7 @@ again: | |||
105 | for (i = 0; i < MAX_EARLY_RES && early_res[i].end; i++) { | 106 | for (i = 0; i < MAX_EARLY_RES && early_res[i].end; i++) { |
106 | struct early_res *r = &early_res[i]; | 107 | struct early_res *r = &early_res[i]; |
107 | if (last >= r->start && addr < r->end) { | 108 | if (last >= r->start && addr < r->end) { |
108 | *addrp = addr = r->end; | 109 | *addrp = addr = round_up(r->end, align); |
109 | changed = 1; | 110 | changed = 1; |
110 | goto again; | 111 | goto again; |
111 | } | 112 | } |
@@ -174,26 +175,27 @@ int __init e820_all_mapped(unsigned long start, unsigned long end, | |||
174 | * Find a free area with specified alignment in a specific range. | 175 | * Find a free area with specified alignment in a specific range. |
175 | */ | 176 | */ |
176 | unsigned long __init find_e820_area(unsigned long start, unsigned long end, | 177 | unsigned long __init find_e820_area(unsigned long start, unsigned long end, |
177 | unsigned size, unsigned long align) | 178 | unsigned long size, unsigned long align) |
178 | { | 179 | { |
179 | int i; | 180 | int i; |
180 | unsigned long mask = ~(align - 1); | ||
181 | 181 | ||
182 | for (i = 0; i < e820.nr_map; i++) { | 182 | for (i = 0; i < e820.nr_map; i++) { |
183 | struct e820entry *ei = &e820.map[i]; | 183 | struct e820entry *ei = &e820.map[i]; |
184 | unsigned long addr = ei->addr, last; | 184 | unsigned long addr, last; |
185 | unsigned long ei_last; | ||
185 | 186 | ||
186 | if (ei->type != E820_RAM) | 187 | if (ei->type != E820_RAM) |
187 | continue; | 188 | continue; |
189 | addr = round_up(ei->addr, align); | ||
190 | ei_last = ei->addr + ei->size; | ||
188 | if (addr < start) | 191 | if (addr < start) |
189 | addr = start; | 192 | addr = round_up(start, align); |
190 | if (addr > ei->addr + ei->size) | 193 | if (addr > ei_last) |
191 | continue; | 194 | continue; |
192 | while (bad_addr(&addr, size) && addr+size <= ei->addr+ei->size) | 195 | while (bad_addr(&addr, size, align) && addr+size <= ei_last) |
193 | ; | 196 | ; |
194 | addr = (addr + align - 1) & mask; | ||
195 | last = addr + size; | 197 | last = addr + size; |
196 | if (last > ei->addr + ei->size) | 198 | if (last > ei_last) |
197 | continue; | 199 | continue; |
198 | if (last > end) | 200 | if (last > end) |
199 | continue; | 201 | continue; |
diff --git a/include/asm-x86/e820_64.h b/include/asm-x86/e820_64.h index 22ede73ae724..9e06c6eb4e27 100644 --- a/include/asm-x86/e820_64.h +++ b/include/asm-x86/e820_64.h | |||
@@ -15,7 +15,7 @@ | |||
15 | 15 | ||
16 | #ifndef __ASSEMBLY__ | 16 | #ifndef __ASSEMBLY__ |
17 | extern unsigned long find_e820_area(unsigned long start, unsigned long end, | 17 | extern unsigned long find_e820_area(unsigned long start, unsigned long end, |
18 | unsigned size, unsigned long align); | 18 | unsigned long size, unsigned long align); |
19 | extern void add_memory_region(unsigned long start, unsigned long size, | 19 | extern void add_memory_region(unsigned long start, unsigned long size, |
20 | int type); | 20 | int type); |
21 | extern void update_memory_range(u64 start, u64 size, unsigned old_type, | 21 | extern void update_memory_range(u64 start, u64 size, unsigned old_type, |