aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/efi_32.c
diff options
context:
space:
mode:
authorHuang, Ying <ying.huang@intel.com>2008-01-30 07:31:19 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:31:19 -0500
commit2215e69d2cf5024647f9a034807990590d25dd4e (patch)
tree89b82b38e515d6e540420347151472d78adc8a51 /arch/x86/kernel/efi_32.c
parente429795c68d3001ecae74f6465420c9f043b0ece (diff)
x86 boot: use E820 memory map on EFI 32 platform
Because the EFI memory map are converted to e820 memory map in bootloader, the EFI memory map handling code is removed to clean up. Signed-off-by: Huang Ying <ying.huang@intel.com> Cc: Andi Kleen <ak@suse.de> Cc: "H. Peter Anvin" <hpa@zytor.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/efi_32.c')
-rw-r--r--arch/x86/kernel/efi_32.c150
1 files changed, 0 insertions, 150 deletions
diff --git a/arch/x86/kernel/efi_32.c b/arch/x86/kernel/efi_32.c
index 1df13725e519..30f937116288 100644
--- a/arch/x86/kernel/efi_32.c
+++ b/arch/x86/kernel/efi_32.c
@@ -125,22 +125,6 @@ void efi_call_phys_epilog(void) __releases(efi_rt_lock)
125 spin_unlock(&efi_rt_lock); 125 spin_unlock(&efi_rt_lock);
126} 126}
127 127
128int is_available_memory(efi_memory_desc_t * md)
129{
130 if (!(md->attribute & EFI_MEMORY_WB))
131 return 0;
132
133 switch (md->type) {
134 case EFI_LOADER_CODE:
135 case EFI_LOADER_DATA:
136 case EFI_BOOT_SERVICES_CODE:
137 case EFI_BOOT_SERVICES_DATA:
138 case EFI_CONVENTIONAL_MEMORY:
139 return 1;
140 }
141 return 0;
142}
143
144/* 128/*
145 * We need to map the EFI memory map again after paging_init(). 129 * We need to map the EFI memory map again after paging_init().
146 */ 130 */
@@ -155,137 +139,3 @@ void __init efi_map_memmap(void)
155 139
156 memmap.map_end = memmap.map + (memmap.nr_map * memmap.desc_size); 140 memmap.map_end = memmap.map + (memmap.nr_map * memmap.desc_size);
157} 141}
158
159/*
160 * Walks the EFI memory map and calls CALLBACK once for each EFI
161 * memory descriptor that has memory that is available for kernel use.
162 */
163void efi_memmap_walk(efi_freemem_callback_t callback, void *arg)
164{
165 int prev_valid = 0;
166 struct range {
167 unsigned long start;
168 unsigned long end;
169 } uninitialized_var(prev), curr;
170 efi_memory_desc_t *md;
171 unsigned long start, end;
172 void *p;
173
174 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
175 md = p;
176
177 if ((md->num_pages == 0) || (!is_available_memory(md)))
178 continue;
179
180 curr.start = md->phys_addr;
181 curr.end = curr.start + (md->num_pages << EFI_PAGE_SHIFT);
182
183 if (!prev_valid) {
184 prev = curr;
185 prev_valid = 1;
186 } else {
187 if (curr.start < prev.start)
188 printk(KERN_INFO PFX "Unordered memory map\n");
189 if (prev.end == curr.start)
190 prev.end = curr.end;
191 else {
192 start =
193 (unsigned long) (PAGE_ALIGN(prev.start));
194 end = (unsigned long) (prev.end & PAGE_MASK);
195 if ((end > start)
196 && (*callback) (start, end, arg) < 0)
197 return;
198 prev = curr;
199 }
200 }
201 }
202 if (prev_valid) {
203 start = (unsigned long) PAGE_ALIGN(prev.start);
204 end = (unsigned long) (prev.end & PAGE_MASK);
205 if (end > start)
206 (*callback) (start, end, arg);
207 }
208}
209
210void __init
211efi_initialize_iomem_resources(struct resource *code_resource,
212 struct resource *data_resource,
213 struct resource *bss_resource)
214{
215 struct resource *res;
216 efi_memory_desc_t *md;
217 void *p;
218
219 for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) {
220 md = p;
221
222 if ((md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT)) >
223 0x100000000ULL)
224 continue;
225 res = kzalloc(sizeof(struct resource), GFP_ATOMIC);
226 switch (md->type) {
227 case EFI_RESERVED_TYPE:
228 res->name = "Reserved Memory";
229 break;
230 case EFI_LOADER_CODE:
231 res->name = "Loader Code";
232 break;
233 case EFI_LOADER_DATA:
234 res->name = "Loader Data";
235 break;
236 case EFI_BOOT_SERVICES_DATA:
237 res->name = "BootServices Data";
238 break;
239 case EFI_BOOT_SERVICES_CODE:
240 res->name = "BootServices Code";
241 break;
242 case EFI_RUNTIME_SERVICES_CODE:
243 res->name = "Runtime Service Code";
244 break;
245 case EFI_RUNTIME_SERVICES_DATA:
246 res->name = "Runtime Service Data";
247 break;
248 case EFI_CONVENTIONAL_MEMORY:
249 res->name = "Conventional Memory";
250 break;
251 case EFI_UNUSABLE_MEMORY:
252 res->name = "Unusable Memory";
253 break;
254 case EFI_ACPI_RECLAIM_MEMORY:
255 res->name = "ACPI Reclaim";
256 break;
257 case EFI_ACPI_MEMORY_NVS:
258 res->name = "ACPI NVS";
259 break;
260 case EFI_MEMORY_MAPPED_IO:
261 res->name = "Memory Mapped IO";
262 break;
263 case EFI_MEMORY_MAPPED_IO_PORT_SPACE:
264 res->name = "Memory Mapped IO Port Space";
265 break;
266 default:
267 res->name = "Reserved";
268 break;
269 }
270 res->start = md->phys_addr;
271 res->end = res->start + ((md->num_pages << EFI_PAGE_SHIFT) - 1);
272 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
273 if (request_resource(&iomem_resource, res) < 0)
274 printk(KERN_ERR PFX "Failed to allocate res %s : "
275 "0x%llx-0x%llx\n", res->name,
276 (unsigned long long)res->start,
277 (unsigned long long)res->end);
278 /*
279 * We don't know which region contains kernel data so we try
280 * it repeatedly and let the resource manager test it.
281 */
282 if (md->type == EFI_CONVENTIONAL_MEMORY) {
283 request_resource(res, code_resource);
284 request_resource(res, data_resource);
285 request_resource(res, bss_resource);
286#ifdef CONFIG_KEXEC
287 request_resource(res, &crashk_res);
288#endif
289 }
290 }
291}