ia64/xen-unstable

view xen/arch/ia64/linux-xen/efi.c @ 15423:cbf749e9961f

[IA64] Cleanup: Move is_platform_hp_ski() from xenmisc.c to xensetup.c

- only caller is start_kernel
- change to static __init
- also move running_on_sim to xensetup.c, and change it from unsigned
long to int, since it's just a boolean
- declare running_on_sim in config.h near some other externs

Tested by building, booting, starting a PV guest on rx2620.

Signed-off-by: Aron Griffis <aron@hp.com>
author Alex Williamson <alex.williamson@hp.com>
date Mon Jul 02 10:25:29 2007 -0600 (2007-07-02)
parents 301267d0db12
children 4108c2589fd1
line source
1 /*
2 * Extensible Firmware Interface
3 *
4 * Based on Extensible Firmware Interface Specification version 0.9 April 30, 1999
5 *
6 * Copyright (C) 1999 VA Linux Systems
7 * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
8 * Copyright (C) 1999-2003 Hewlett-Packard Co.
9 * David Mosberger-Tang <davidm@hpl.hp.com>
10 * Stephane Eranian <eranian@hpl.hp.com>
11 * (c) Copyright 2006 Hewlett-Packard Development Company, L.P.
12 * Bjorn Helgaas <bjorn.helgaas@hp.com>
13 *
14 * All EFI Runtime Services are not implemented yet as EFI only
15 * supports physical mode addressing on SoftSDV. This is to be fixed
16 * in a future version. --drummond 1999-07-20
17 *
18 * Implemented EFI runtime services and virtual mode calls. --davidm
19 *
20 * Goutham Rao: <goutham.rao@intel.com>
21 * Skip non-WB memory and ignore empty memory ranges.
22 */
23 #include <linux/module.h>
24 #include <linux/bootmem.h>
25 #include <linux/kernel.h>
26 #include <linux/init.h>
27 #include <linux/types.h>
28 #include <linux/time.h>
29 #include <linux/efi.h>
30 #include <linux/kexec.h>
32 #include <asm/io.h>
33 #include <asm/kregs.h>
34 #include <asm/meminit.h>
35 #include <asm/pgtable.h>
36 #include <asm/processor.h>
37 #include <asm/mca.h>
39 #define EFI_DEBUG 0
41 extern efi_status_t efi_call_phys (void *, ...);
42 #ifdef XEN
43 /* this should be defined in linux/kernel.h */
44 extern unsigned long long memparse (char *ptr, char **retptr);
45 /* this should be defined in linux/efi.h */
46 //#define EFI_INVALID_TABLE_ADDR (void *)(~0UL)
47 #endif
49 struct efi efi;
50 EXPORT_SYMBOL(efi);
51 static efi_runtime_services_t *runtime;
52 #if defined(XEN) && !defined(CONFIG_VIRTUAL_FRAME_TABLE)
53 // this is a temporary hack to avoid CONFIG_VIRTUAL_MEM_MAP
54 static unsigned long mem_limit = ~0UL, max_addr = 0x100000000UL, min_addr = 0UL;
55 #else
56 static unsigned long mem_limit = ~0UL, max_addr = ~0UL, min_addr = 0UL;
57 #endif
59 #define efi_call_virt(f, args...) (*(f))(args)
61 #define STUB_GET_TIME(prefix, adjust_arg) \
62 static efi_status_t \
63 prefix##_get_time (efi_time_t *tm, efi_time_cap_t *tc) \
64 { \
65 struct ia64_fpreg fr[6]; \
66 efi_time_cap_t *atc = NULL; \
67 efi_status_t ret; \
68 \
69 if (tc) \
70 atc = adjust_arg(tc); \
71 ia64_save_scratch_fpregs(fr); \
72 ret = efi_call_##prefix((efi_get_time_t *) __va(runtime->get_time), adjust_arg(tm), atc); \
73 ia64_load_scratch_fpregs(fr); \
74 return ret; \
75 }
77 #define STUB_SET_TIME(prefix, adjust_arg) \
78 static efi_status_t \
79 prefix##_set_time (efi_time_t *tm) \
80 { \
81 struct ia64_fpreg fr[6]; \
82 efi_status_t ret; \
83 \
84 ia64_save_scratch_fpregs(fr); \
85 ret = efi_call_##prefix((efi_set_time_t *) __va(runtime->set_time), adjust_arg(tm)); \
86 ia64_load_scratch_fpregs(fr); \
87 return ret; \
88 }
90 #define STUB_GET_WAKEUP_TIME(prefix, adjust_arg) \
91 static efi_status_t \
92 prefix##_get_wakeup_time (efi_bool_t *enabled, efi_bool_t *pending, efi_time_t *tm) \
93 { \
94 struct ia64_fpreg fr[6]; \
95 efi_status_t ret; \
96 \
97 ia64_save_scratch_fpregs(fr); \
98 ret = efi_call_##prefix((efi_get_wakeup_time_t *) __va(runtime->get_wakeup_time), \
99 adjust_arg(enabled), adjust_arg(pending), adjust_arg(tm)); \
100 ia64_load_scratch_fpregs(fr); \
101 return ret; \
102 }
104 #define STUB_SET_WAKEUP_TIME(prefix, adjust_arg) \
105 static efi_status_t \
106 prefix##_set_wakeup_time (efi_bool_t enabled, efi_time_t *tm) \
107 { \
108 struct ia64_fpreg fr[6]; \
109 efi_time_t *atm = NULL; \
110 efi_status_t ret; \
111 \
112 if (tm) \
113 atm = adjust_arg(tm); \
114 ia64_save_scratch_fpregs(fr); \
115 ret = efi_call_##prefix((efi_set_wakeup_time_t *) __va(runtime->set_wakeup_time), \
116 enabled, atm); \
117 ia64_load_scratch_fpregs(fr); \
118 return ret; \
119 }
121 #define STUB_GET_VARIABLE(prefix, adjust_arg) \
122 static efi_status_t \
123 prefix##_get_variable (efi_char16_t *name, efi_guid_t *vendor, u32 *attr, \
124 unsigned long *data_size, void *data) \
125 { \
126 struct ia64_fpreg fr[6]; \
127 u32 *aattr = NULL; \
128 efi_status_t ret; \
129 \
130 if (attr) \
131 aattr = adjust_arg(attr); \
132 ia64_save_scratch_fpregs(fr); \
133 ret = efi_call_##prefix((efi_get_variable_t *) __va(runtime->get_variable), \
134 adjust_arg(name), adjust_arg(vendor), aattr, \
135 adjust_arg(data_size), adjust_arg(data)); \
136 ia64_load_scratch_fpregs(fr); \
137 return ret; \
138 }
140 #define STUB_GET_NEXT_VARIABLE(prefix, adjust_arg) \
141 static efi_status_t \
142 prefix##_get_next_variable (unsigned long *name_size, efi_char16_t *name, efi_guid_t *vendor) \
143 { \
144 struct ia64_fpreg fr[6]; \
145 efi_status_t ret; \
146 \
147 ia64_save_scratch_fpregs(fr); \
148 ret = efi_call_##prefix((efi_get_next_variable_t *) __va(runtime->get_next_variable), \
149 adjust_arg(name_size), adjust_arg(name), adjust_arg(vendor)); \
150 ia64_load_scratch_fpregs(fr); \
151 return ret; \
152 }
154 #define STUB_SET_VARIABLE(prefix, adjust_arg) \
155 static efi_status_t \
156 prefix##_set_variable (efi_char16_t *name, efi_guid_t *vendor, unsigned long attr, \
157 unsigned long data_size, void *data) \
158 { \
159 struct ia64_fpreg fr[6]; \
160 efi_status_t ret; \
161 \
162 ia64_save_scratch_fpregs(fr); \
163 ret = efi_call_##prefix((efi_set_variable_t *) __va(runtime->set_variable), \
164 adjust_arg(name), adjust_arg(vendor), attr, data_size, \
165 adjust_arg(data)); \
166 ia64_load_scratch_fpregs(fr); \
167 return ret; \
168 }
170 #define STUB_GET_NEXT_HIGH_MONO_COUNT(prefix, adjust_arg) \
171 static efi_status_t \
172 prefix##_get_next_high_mono_count (u32 *count) \
173 { \
174 struct ia64_fpreg fr[6]; \
175 efi_status_t ret; \
176 \
177 ia64_save_scratch_fpregs(fr); \
178 ret = efi_call_##prefix((efi_get_next_high_mono_count_t *) \
179 __va(runtime->get_next_high_mono_count), adjust_arg(count)); \
180 ia64_load_scratch_fpregs(fr); \
181 return ret; \
182 }
184 #define STUB_RESET_SYSTEM(prefix, adjust_arg) \
185 static void \
186 prefix##_reset_system (int reset_type, efi_status_t status, \
187 unsigned long data_size, efi_char16_t *data) \
188 { \
189 struct ia64_fpreg fr[6]; \
190 efi_char16_t *adata = NULL; \
191 \
192 if (data) \
193 adata = adjust_arg(data); \
194 \
195 ia64_save_scratch_fpregs(fr); \
196 efi_call_##prefix((efi_reset_system_t *) __va(runtime->reset_system), \
197 reset_type, status, data_size, adata); \
198 /* should not return, but just in case... */ \
199 ia64_load_scratch_fpregs(fr); \
200 }
202 #define phys_ptr(arg) ((__typeof__(arg)) ia64_tpa(arg))
204 STUB_GET_TIME(phys, phys_ptr)
205 STUB_SET_TIME(phys, phys_ptr)
206 STUB_GET_WAKEUP_TIME(phys, phys_ptr)
207 STUB_SET_WAKEUP_TIME(phys, phys_ptr)
208 STUB_GET_VARIABLE(phys, phys_ptr)
209 STUB_GET_NEXT_VARIABLE(phys, phys_ptr)
210 STUB_SET_VARIABLE(phys, phys_ptr)
211 STUB_GET_NEXT_HIGH_MONO_COUNT(phys, phys_ptr)
212 STUB_RESET_SYSTEM(phys, phys_ptr)
214 #define id(arg) arg
216 STUB_GET_TIME(virt, id)
217 STUB_SET_TIME(virt, id)
218 STUB_GET_WAKEUP_TIME(virt, id)
219 STUB_SET_WAKEUP_TIME(virt, id)
220 STUB_GET_VARIABLE(virt, id)
221 STUB_GET_NEXT_VARIABLE(virt, id)
222 STUB_SET_VARIABLE(virt, id)
223 STUB_GET_NEXT_HIGH_MONO_COUNT(virt, id)
224 STUB_RESET_SYSTEM(virt, id)
226 #ifndef XEN
227 void
228 efi_gettimeofday (struct timespec *ts)
229 {
230 efi_time_t tm;
232 memset(ts, 0, sizeof(ts));
233 if ((*efi.get_time)(&tm, NULL) != EFI_SUCCESS)
234 return;
236 ts->tv_sec = mktime(tm.year, tm.month, tm.day, tm.hour, tm.minute, tm.second);
237 ts->tv_nsec = tm.nanosecond;
238 }
239 #endif
241 static int
242 is_memory_available (efi_memory_desc_t *md)
243 {
244 if (!(md->attribute & EFI_MEMORY_WB))
245 return 0;
247 switch (md->type) {
248 case EFI_LOADER_CODE:
249 case EFI_LOADER_DATA:
250 case EFI_BOOT_SERVICES_CODE:
251 case EFI_BOOT_SERVICES_DATA:
252 case EFI_CONVENTIONAL_MEMORY:
253 return 1;
254 }
255 return 0;
256 }
258 typedef struct kern_memdesc {
259 u64 attribute;
260 u64 start;
261 u64 num_pages;
262 } kern_memdesc_t;
264 static kern_memdesc_t *kern_memmap;
266 #define efi_md_size(md) (md->num_pages << EFI_PAGE_SHIFT)
268 static inline u64
269 kmd_end(kern_memdesc_t *kmd)
270 {
271 return (kmd->start + (kmd->num_pages << EFI_PAGE_SHIFT));
272 }
274 static inline u64
275 efi_md_end(efi_memory_desc_t *md)
276 {
277 return (md->phys_addr + efi_md_size(md));
278 }
280 static inline int
281 efi_wb(efi_memory_desc_t *md)
282 {
283 return (md->attribute & EFI_MEMORY_WB);
284 }
286 static inline int
287 efi_uc(efi_memory_desc_t *md)
288 {
289 return (md->attribute & EFI_MEMORY_UC);
290 }
292 static void
293 walk (efi_freemem_callback_t callback, void *arg, u64 attr)
294 {
295 kern_memdesc_t *k;
296 u64 start, end, voff;
298 voff = (attr == EFI_MEMORY_WB) ? PAGE_OFFSET : __IA64_UNCACHED_OFFSET;
299 for (k = kern_memmap; k->start != ~0UL; k++) {
300 if (k->attribute != attr)
301 continue;
302 start = PAGE_ALIGN(k->start);
303 end = (k->start + (k->num_pages << EFI_PAGE_SHIFT)) & PAGE_MASK;
304 if (start < end)
305 if ((*callback)(start + voff, end + voff, arg) < 0)
306 return;
307 }
308 }
310 /*
311 * Walks the EFI memory map and calls CALLBACK once for each EFI memory descriptor that
312 * has memory that is available for OS use.
313 */
314 void
315 efi_memmap_walk (efi_freemem_callback_t callback, void *arg)
316 {
317 walk(callback, arg, EFI_MEMORY_WB);
318 }
320 /*
321 * Walks the EFI memory map and calls CALLBACK once for each EFI memory descriptor that
322 * has memory that is available for uncached allocator.
323 */
324 void
325 efi_memmap_walk_uc (efi_freemem_callback_t callback, void *arg)
326 {
327 walk(callback, arg, EFI_MEMORY_UC);
328 }
330 /*
331 * Look for the PAL_CODE region reported by EFI and maps it using an
332 * ITR to enable safe PAL calls in virtual mode. See IA-64 Processor
333 * Abstraction Layer chapter 11 in ADAG
334 */
336 void *
337 efi_get_pal_addr (void)
338 {
339 void *efi_map_start, *efi_map_end, *p;
340 efi_memory_desc_t *md;
341 u64 efi_desc_size;
342 int pal_code_count = 0;
343 u64 vaddr, mask;
345 efi_map_start = __va(ia64_boot_param->efi_memmap);
346 efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size;
347 efi_desc_size = ia64_boot_param->efi_memdesc_size;
349 for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
350 md = p;
351 if (md->type != EFI_PAL_CODE)
352 continue;
354 if (++pal_code_count > 1) {
355 printk(KERN_ERR "Too many EFI Pal Code memory ranges, dropped @ %lx\n",
356 md->phys_addr);
357 continue;
358 }
359 /*
360 * The only ITLB entry in region 7 that is used is the one installed by
361 * __start(). That entry covers a 64MB range.
362 */
363 mask = ~((1 << KERNEL_TR_PAGE_SHIFT) - 1);
364 vaddr = PAGE_OFFSET + md->phys_addr;
366 /*
367 * We must check that the PAL mapping won't overlap with the kernel
368 * mapping.
369 *
370 * PAL code is guaranteed to be aligned on a power of 2 between 4k and
371 * 256KB and that only one ITR is needed to map it. This implies that the
372 * PAL code is always aligned on its size, i.e., the closest matching page
373 * size supported by the TLB. Therefore PAL code is guaranteed never to
374 * cross a 64MB unless it is bigger than 64MB (very unlikely!). So for
375 * now the following test is enough to determine whether or not we need a
376 * dedicated ITR for the PAL code.
377 */
378 if ((vaddr & mask) == (KERNEL_START & mask)) {
379 printk(KERN_INFO "%s: no need to install ITR for PAL code\n",
380 __FUNCTION__);
381 continue;
382 }
384 if (md->num_pages << EFI_PAGE_SHIFT > IA64_GRANULE_SIZE)
385 panic("Woah! PAL code size bigger than a granule!");
387 #if EFI_DEBUG
388 mask = ~((1 << IA64_GRANULE_SHIFT) - 1);
390 printk(KERN_INFO "CPU %d: mapping PAL code [0x%lx-0x%lx) into [0x%lx-0x%lx)\n",
391 smp_processor_id(), md->phys_addr,
392 md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT),
393 vaddr & mask, (vaddr & mask) + IA64_GRANULE_SIZE);
394 #endif
395 return __va(md->phys_addr);
396 }
397 printk(KERN_WARNING "%s: no PAL-code memory-descriptor found\n",
398 __FUNCTION__);
399 return NULL;
400 }
402 #ifdef XEN
403 void *pal_vaddr = 0;
404 #endif
406 void
407 efi_map_pal_code (void)
408 {
409 #ifdef XEN
410 u64 psr;
411 if (!pal_vaddr) {
412 pal_vaddr = efi_get_pal_addr ();
413 }
414 #else
415 void *pal_vaddr = efi_get_pal_addr ();
416 u64 psr;
418 if (!pal_vaddr)
419 return;
420 #endif
422 /*
423 * Cannot write to CRx with PSR.ic=1
424 */
425 psr = ia64_clear_ic();
426 ia64_itr(0x1, IA64_TR_PALCODE, GRANULEROUNDDOWN((unsigned long) pal_vaddr),
427 pte_val(pfn_pte(__pa(pal_vaddr) >> PAGE_SHIFT, PAGE_KERNEL)),
428 IA64_GRANULE_SHIFT);
429 ia64_set_psr(psr); /* restore psr */
430 ia64_srlz_i();
431 }
433 void __init
434 efi_init (void)
435 {
436 void *efi_map_start, *efi_map_end;
437 efi_config_table_t *config_tables;
438 efi_char16_t *c16;
439 u64 efi_desc_size;
440 char *cp, vendor[100] = "unknown";
441 int i;
443 /* it's too early to be able to use the standard kernel command line support... */
444 #ifdef XEN
445 extern char saved_command_line[];
446 for (cp = saved_command_line; *cp; ) {
447 #else
448 for (cp = boot_command_line; *cp; ) {
449 #endif
450 if (memcmp(cp, "mem=", 4) == 0) {
451 mem_limit = memparse(cp + 4, &cp);
452 } else if (memcmp(cp, "max_addr=", 9) == 0) {
453 max_addr = GRANULEROUNDDOWN(memparse(cp + 9, &cp));
454 } else if (memcmp(cp, "min_addr=", 9) == 0) {
455 min_addr = GRANULEROUNDDOWN(memparse(cp + 9, &cp));
456 } else {
457 while (*cp != ' ' && *cp)
458 ++cp;
459 while (*cp == ' ')
460 ++cp;
461 }
462 }
463 if (min_addr != 0UL)
464 printk(KERN_INFO "Ignoring memory below %luMB\n", min_addr >> 20);
465 if (max_addr != ~0UL)
466 printk(KERN_INFO "Ignoring memory above %luMB\n", max_addr >> 20);
468 efi.systab = __va(ia64_boot_param->efi_systab);
470 /*
471 * Verify the EFI Table
472 */
473 if (efi.systab == NULL)
474 panic("Woah! Can't find EFI system table.\n");
475 if (efi.systab->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE)
476 panic("Woah! EFI system table signature incorrect\n");
477 if ((efi.systab->hdr.revision ^ EFI_SYSTEM_TABLE_REVISION) >> 16 != 0)
478 printk(KERN_WARNING "Warning: EFI system table major version mismatch: "
479 "got %d.%02d, expected %d.%02d\n",
480 efi.systab->hdr.revision >> 16, efi.systab->hdr.revision & 0xffff,
481 EFI_SYSTEM_TABLE_REVISION >> 16, EFI_SYSTEM_TABLE_REVISION & 0xffff);
483 config_tables = __va(efi.systab->tables);
485 /* Show what we know for posterity */
486 c16 = __va(efi.systab->fw_vendor);
487 if (c16) {
488 for (i = 0;i < (int) sizeof(vendor) - 1 && *c16; ++i)
489 vendor[i] = *c16++;
490 vendor[i] = '\0';
491 }
493 printk(KERN_INFO "EFI v%u.%.02u by %s:",
494 efi.systab->hdr.revision >> 16, efi.systab->hdr.revision & 0xffff, vendor);
496 #ifndef XEN
497 efi.mps = EFI_INVALID_TABLE_ADDR;
498 efi.acpi = EFI_INVALID_TABLE_ADDR;
499 efi.acpi20 = EFI_INVALID_TABLE_ADDR;
500 efi.smbios = EFI_INVALID_TABLE_ADDR;
501 efi.sal_systab = EFI_INVALID_TABLE_ADDR;
502 efi.boot_info = EFI_INVALID_TABLE_ADDR;
503 efi.hcdp = EFI_INVALID_TABLE_ADDR;
504 efi.uga = EFI_INVALID_TABLE_ADDR;
506 for (i = 0; i < (int) efi.systab->nr_tables; i++) {
507 if (efi_guidcmp(config_tables[i].guid, MPS_TABLE_GUID) == 0) {
508 efi.mps = config_tables[i].table;
509 printk(" MPS=0x%lx", config_tables[i].table);
510 } else if (efi_guidcmp(config_tables[i].guid, ACPI_20_TABLE_GUID) == 0) {
511 efi.acpi20 = config_tables[i].table;
512 printk(" ACPI 2.0=0x%lx", config_tables[i].table);
513 } else if (efi_guidcmp(config_tables[i].guid, ACPI_TABLE_GUID) == 0) {
514 efi.acpi = config_tables[i].table;
515 printk(" ACPI=0x%lx", config_tables[i].table);
516 } else if (efi_guidcmp(config_tables[i].guid, SMBIOS_TABLE_GUID) == 0) {
517 efi.smbios = config_tables[i].table;
518 printk(" SMBIOS=0x%lx", config_tables[i].table);
519 } else if (efi_guidcmp(config_tables[i].guid, SAL_SYSTEM_TABLE_GUID) == 0) {
520 efi.sal_systab = config_tables[i].table;
521 printk(" SALsystab=0x%lx", config_tables[i].table);
522 } else if (efi_guidcmp(config_tables[i].guid, HCDP_TABLE_GUID) == 0) {
523 efi.hcdp = config_tables[i].table;
524 printk(" HCDP=0x%lx", config_tables[i].table);
525 }
526 }
527 #else
528 /* Members of efi are set with virtual address in old linux code.
529 The latest linux set wiht physicall address. */
530 for (i = 0; i < (int) efi.systab->nr_tables; i++) {
531 if (efi_guidcmp(config_tables[i].guid, MPS_TABLE_GUID) == 0) {
532 efi.mps = __va(config_tables[i].table);
533 printk(" MPS=0x%lx", config_tables[i].table);
534 } else if (efi_guidcmp(config_tables[i].guid, ACPI_20_TABLE_GUID) == 0) {
535 efi.acpi20 = __va(config_tables[i].table);
536 printk(" ACPI 2.0=0x%lx", config_tables[i].table);
537 } else if (efi_guidcmp(config_tables[i].guid, ACPI_TABLE_GUID) == 0) {
538 efi.acpi = __va(config_tables[i].table);
539 printk(" ACPI=0x%lx", config_tables[i].table);
540 } else if (efi_guidcmp(config_tables[i].guid, SMBIOS_TABLE_GUID) == 0) {
541 efi.smbios = __va(config_tables[i].table);
542 printk(" SMBIOS=0x%lx", config_tables[i].table);
543 } else if (efi_guidcmp(config_tables[i].guid, SAL_SYSTEM_TABLE_GUID) == 0) {
544 efi.sal_systab = __va(config_tables[i].table);
545 printk(" SALsystab=0x%lx", config_tables[i].table);
546 } else if (efi_guidcmp(config_tables[i].guid, HCDP_TABLE_GUID) == 0) {
547 efi.hcdp = __va(config_tables[i].table);
548 printk(" HCDP=0x%lx", config_tables[i].table);
549 }
550 }
551 #endif
552 printk("\n");
554 runtime = __va(efi.systab->runtime);
555 efi.get_time = phys_get_time;
556 efi.set_time = phys_set_time;
557 efi.get_wakeup_time = phys_get_wakeup_time;
558 efi.set_wakeup_time = phys_set_wakeup_time;
559 efi.get_variable = phys_get_variable;
560 efi.get_next_variable = phys_get_next_variable;
561 efi.set_variable = phys_set_variable;
562 efi.get_next_high_mono_count = phys_get_next_high_mono_count;
563 efi.reset_system = phys_reset_system;
565 efi_map_start = __va(ia64_boot_param->efi_memmap);
566 efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size;
567 efi_desc_size = ia64_boot_param->efi_memdesc_size;
569 #if EFI_DEBUG
570 /* print EFI memory map: */
571 {
572 efi_memory_desc_t *md;
573 void *p;
575 for (i = 0, p = efi_map_start; p < efi_map_end; ++i, p += efi_desc_size) {
576 md = p;
577 printk("mem%02u: type=%u, attr=0x%lx, range=[0x%016lx-0x%016lx) (%luMB)\n",
578 i, md->type, md->attribute, md->phys_addr,
579 md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT),
580 md->num_pages >> (20 - EFI_PAGE_SHIFT));
581 }
582 }
583 #endif
585 efi_map_pal_code();
586 efi_enter_virtual_mode();
587 }
589 void
590 efi_enter_virtual_mode (void)
591 {
592 void *efi_map_start, *efi_map_end, *p;
593 efi_memory_desc_t *md;
594 efi_status_t status;
595 u64 efi_desc_size;
597 efi_map_start = __va(ia64_boot_param->efi_memmap);
598 efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size;
599 efi_desc_size = ia64_boot_param->efi_memdesc_size;
601 for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
602 md = p;
603 if (md->attribute & EFI_MEMORY_RUNTIME) {
604 /*
605 * Some descriptors have multiple bits set, so the order of
606 * the tests is relevant.
607 */
608 if (md->attribute & EFI_MEMORY_WB) {
609 md->virt_addr = (u64) __va(md->phys_addr);
610 } else if (md->attribute & EFI_MEMORY_UC) {
611 md->virt_addr = (u64) ioremap(md->phys_addr, 0);
612 } else if (md->attribute & EFI_MEMORY_WC) {
613 #if 0
614 md->virt_addr = ia64_remap(md->phys_addr, (_PAGE_A | _PAGE_P
615 | _PAGE_D
616 | _PAGE_MA_WC
617 | _PAGE_PL_0
618 | _PAGE_AR_RW));
619 #else
620 printk(KERN_INFO "EFI_MEMORY_WC mapping\n");
621 md->virt_addr = (u64) ioremap(md->phys_addr, 0);
622 #endif
623 } else if (md->attribute & EFI_MEMORY_WT) {
624 #if 0
625 md->virt_addr = ia64_remap(md->phys_addr, (_PAGE_A | _PAGE_P
626 | _PAGE_D | _PAGE_MA_WT
627 | _PAGE_PL_0
628 | _PAGE_AR_RW));
629 #else
630 printk(KERN_INFO "EFI_MEMORY_WT mapping\n");
631 md->virt_addr = (u64) ioremap(md->phys_addr, 0);
632 #endif
633 }
634 }
635 }
637 status = efi_call_phys(__va(runtime->set_virtual_address_map),
638 ia64_boot_param->efi_memmap_size,
639 efi_desc_size, ia64_boot_param->efi_memdesc_version,
640 ia64_boot_param->efi_memmap);
641 if (status != EFI_SUCCESS) {
642 printk(KERN_WARNING "warning: unable to switch EFI into virtual mode "
643 "(status=%lu)\n", status);
644 return;
645 }
647 /*
648 * Now that EFI is in virtual mode, we call the EFI functions more efficiently:
649 */
650 efi.get_time = virt_get_time;
651 efi.set_time = virt_set_time;
652 efi.get_wakeup_time = virt_get_wakeup_time;
653 efi.set_wakeup_time = virt_set_wakeup_time;
654 efi.get_variable = virt_get_variable;
655 efi.get_next_variable = virt_get_next_variable;
656 efi.set_variable = virt_set_variable;
657 efi.get_next_high_mono_count = virt_get_next_high_mono_count;
658 efi.reset_system = virt_reset_system;
659 }
661 /*
662 * Walk the EFI memory map looking for the I/O port range. There can only be one entry of
663 * this type, other I/O port ranges should be described via ACPI.
664 */
665 u64
666 efi_get_iobase (void)
667 {
668 void *efi_map_start, *efi_map_end, *p;
669 efi_memory_desc_t *md;
670 u64 efi_desc_size;
672 efi_map_start = __va(ia64_boot_param->efi_memmap);
673 efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size;
674 efi_desc_size = ia64_boot_param->efi_memdesc_size;
676 for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
677 md = p;
678 if (md->type == EFI_MEMORY_MAPPED_IO_PORT_SPACE) {
679 if (md->attribute & EFI_MEMORY_UC)
680 return md->phys_addr;
681 }
682 }
683 return 0;
684 }
686 static struct kern_memdesc *
687 kern_memory_descriptor (unsigned long phys_addr)
688 {
689 struct kern_memdesc *md;
691 for (md = kern_memmap; md->start != ~0UL; md++) {
692 if (phys_addr - md->start < (md->num_pages << EFI_PAGE_SHIFT))
693 return md;
694 }
695 return NULL;
696 }
698 static efi_memory_desc_t *
699 efi_memory_descriptor (unsigned long phys_addr)
700 {
701 void *efi_map_start, *efi_map_end, *p;
702 efi_memory_desc_t *md;
703 u64 efi_desc_size;
705 efi_map_start = __va(ia64_boot_param->efi_memmap);
706 efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size;
707 efi_desc_size = ia64_boot_param->efi_memdesc_size;
709 for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
710 md = p;
712 if (phys_addr - md->phys_addr < (md->num_pages << EFI_PAGE_SHIFT))
713 return md;
714 }
715 return NULL;
716 }
718 u32
719 efi_mem_type (unsigned long phys_addr)
720 {
721 efi_memory_desc_t *md = efi_memory_descriptor(phys_addr);
723 if (md)
724 return md->type;
725 return 0;
726 }
728 u64
729 efi_mem_attributes (unsigned long phys_addr)
730 {
731 efi_memory_desc_t *md = efi_memory_descriptor(phys_addr);
733 if (md)
734 return md->attribute;
735 return 0;
736 }
737 EXPORT_SYMBOL(efi_mem_attributes);
739 u64
740 efi_mem_attribute (unsigned long phys_addr, unsigned long size)
741 {
742 unsigned long end = phys_addr + size;
743 efi_memory_desc_t *md = efi_memory_descriptor(phys_addr);
744 u64 attr;
746 if (!md)
747 return 0;
749 /*
750 * EFI_MEMORY_RUNTIME is not a memory attribute; it just tells
751 * the kernel that firmware needs this region mapped.
752 */
753 attr = md->attribute & ~EFI_MEMORY_RUNTIME;
754 do {
755 unsigned long md_end = efi_md_end(md);
757 if (end <= md_end)
758 return attr;
760 md = efi_memory_descriptor(md_end);
761 if (!md || (md->attribute & ~EFI_MEMORY_RUNTIME) != attr)
762 return 0;
763 } while (md);
764 return 0;
765 }
767 u64
768 kern_mem_attribute (unsigned long phys_addr, unsigned long size)
769 {
770 unsigned long end = phys_addr + size;
771 struct kern_memdesc *md;
772 u64 attr;
774 /*
775 * This is a hack for ioremap calls before we set up kern_memmap.
776 * Maybe we should do efi_memmap_init() earlier instead.
777 */
778 if (!kern_memmap) {
779 attr = efi_mem_attribute(phys_addr, size);
780 if (attr & EFI_MEMORY_WB)
781 return EFI_MEMORY_WB;
782 return 0;
783 }
785 md = kern_memory_descriptor(phys_addr);
786 if (!md)
787 return 0;
789 attr = md->attribute;
790 do {
791 unsigned long md_end = kmd_end(md);
793 if (end <= md_end)
794 return attr;
796 md = kern_memory_descriptor(md_end);
797 if (!md || md->attribute != attr)
798 return 0;
799 } while (md);
800 return 0;
801 }
802 EXPORT_SYMBOL(kern_mem_attribute);
804 #ifndef XEN
805 int
806 valid_phys_addr_range (unsigned long phys_addr, unsigned long size)
807 {
808 u64 attr;
810 /*
811 * /dev/mem reads and writes use copy_to_user(), which implicitly
812 * uses a granule-sized kernel identity mapping. It's really
813 * only safe to do this for regions in kern_memmap. For more
814 * details, see Documentation/ia64/aliasing.txt.
815 */
816 attr = kern_mem_attribute(phys_addr, size);
817 if (attr & EFI_MEMORY_WB || attr & EFI_MEMORY_UC)
818 return 1;
819 return 0;
820 }
822 int
823 valid_mmap_phys_addr_range (unsigned long pfn, unsigned long size)
824 {
825 /*
826 * MMIO regions are often missing from the EFI memory map.
827 * We must allow mmap of them for programs like X, so we
828 * currently can't do any useful validation.
829 */
830 return 1;
831 }
833 pgprot_t
834 phys_mem_access_prot(struct file *file, unsigned long pfn, unsigned long size,
835 pgprot_t vma_prot)
836 {
837 unsigned long phys_addr = pfn << PAGE_SHIFT;
838 u64 attr;
840 /*
841 * For /dev/mem mmap, we use user mappings, but if the region is
842 * in kern_memmap (and hence may be covered by a kernel mapping),
843 * we must use the same attribute as the kernel mapping.
844 */
845 attr = kern_mem_attribute(phys_addr, size);
846 if (attr & EFI_MEMORY_WB)
847 return pgprot_cacheable(vma_prot);
848 else if (attr & EFI_MEMORY_UC)
849 return pgprot_noncached(vma_prot);
851 /*
852 * Some chipsets don't support UC access to memory. If
853 * WB is supported, we prefer that.
854 */
855 if (efi_mem_attribute(phys_addr, size) & EFI_MEMORY_WB)
856 return pgprot_cacheable(vma_prot);
858 return pgprot_noncached(vma_prot);
859 }
860 #endif
862 int __init
863 efi_uart_console_only(void)
864 {
865 efi_status_t status;
866 char *s, name[] = "ConOut";
867 efi_guid_t guid = EFI_GLOBAL_VARIABLE_GUID;
868 efi_char16_t *utf16, name_utf16[32];
869 unsigned char data[1024];
870 unsigned long size = sizeof(data);
871 struct efi_generic_dev_path *hdr, *end_addr;
872 int uart = 0;
874 /* Convert to UTF-16 */
875 utf16 = name_utf16;
876 s = name;
877 while (*s)
878 *utf16++ = *s++ & 0x7f;
879 *utf16 = 0;
881 status = efi.get_variable(name_utf16, &guid, NULL, &size, data);
882 if (status != EFI_SUCCESS) {
883 printk(KERN_ERR "No EFI %s variable?\n", name);
884 return 0;
885 }
887 hdr = (struct efi_generic_dev_path *) data;
888 end_addr = (struct efi_generic_dev_path *) ((u8 *) data + size);
889 while (hdr < end_addr) {
890 if (hdr->type == EFI_DEV_MSG &&
891 hdr->sub_type == EFI_DEV_MSG_UART)
892 uart = 1;
893 else if (hdr->type == EFI_DEV_END_PATH ||
894 hdr->type == EFI_DEV_END_PATH2) {
895 if (!uart)
896 return 0;
897 if (hdr->sub_type == EFI_DEV_END_ENTIRE)
898 return 1;
899 uart = 0;
900 }
901 hdr = (struct efi_generic_dev_path *) ((u8 *) hdr + hdr->length);
902 }
903 printk(KERN_ERR "Malformed %s value\n", name);
904 return 0;
905 }
907 /*
908 * Look for the first granule aligned memory descriptor memory
909 * that is big enough to hold EFI memory map. Make sure this
910 * descriptor is atleast granule sized so it does not get trimmed
911 */
912 struct kern_memdesc *
913 find_memmap_space (void)
914 {
915 u64 contig_low=0, contig_high=0;
916 u64 as = 0, ae;
917 void *efi_map_start, *efi_map_end, *p, *q;
918 efi_memory_desc_t *md, *pmd = NULL, *check_md;
919 u64 space_needed, efi_desc_size;
920 unsigned long total_mem = 0;
922 efi_map_start = __va(ia64_boot_param->efi_memmap);
923 efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size;
924 efi_desc_size = ia64_boot_param->efi_memdesc_size;
926 /*
927 * Worst case: we need 3 kernel descriptors for each efi descriptor
928 * (if every entry has a WB part in the middle, and UC head and tail),
929 * plus one for the end marker.
930 */
931 space_needed = sizeof(kern_memdesc_t) *
932 (3 * (ia64_boot_param->efi_memmap_size/efi_desc_size) + 1);
934 for (p = efi_map_start; p < efi_map_end; pmd = md, p += efi_desc_size) {
935 md = p;
936 if (!efi_wb(md)) {
937 continue;
938 }
939 if (pmd == NULL || !efi_wb(pmd) || efi_md_end(pmd) != md->phys_addr) {
940 contig_low = GRANULEROUNDUP(md->phys_addr);
941 contig_high = efi_md_end(md);
942 for (q = p + efi_desc_size; q < efi_map_end; q += efi_desc_size) {
943 check_md = q;
944 if (!efi_wb(check_md))
945 break;
946 if (contig_high != check_md->phys_addr)
947 break;
948 contig_high = efi_md_end(check_md);
949 }
950 contig_high = GRANULEROUNDDOWN(contig_high);
951 }
952 if (!is_memory_available(md) || md->type == EFI_LOADER_DATA)
953 continue;
955 /* Round ends inward to granule boundaries */
956 as = max(contig_low, md->phys_addr);
957 ae = min(contig_high, efi_md_end(md));
959 /* keep within max_addr= and min_addr= command line arg */
960 as = max(as, min_addr);
961 ae = min(ae, max_addr);
962 if (ae <= as)
963 continue;
965 /* avoid going over mem= command line arg */
966 if (total_mem + (ae - as) > mem_limit)
967 ae -= total_mem + (ae - as) - mem_limit;
969 if (ae <= as)
970 continue;
972 if (ae - as > space_needed)
973 break;
974 }
975 if (p >= efi_map_end)
976 panic("Can't allocate space for kernel memory descriptors");
978 return __va(as);
979 }
981 /*
982 * Walk the EFI memory map and gather all memory available for kernel
983 * to use. We can allocate partial granules only if the unavailable
984 * parts exist, and are WB.
985 */
986 void
987 efi_memmap_init(unsigned long *s, unsigned long *e)
988 {
989 struct kern_memdesc *k, *prev = NULL;
990 u64 contig_low=0, contig_high=0;
991 u64 as, ae, lim;
992 void *efi_map_start, *efi_map_end, *p, *q;
993 efi_memory_desc_t *md, *pmd = NULL, *check_md;
994 u64 efi_desc_size;
995 unsigned long total_mem = 0;
997 k = kern_memmap = find_memmap_space();
999 efi_map_start = __va(ia64_boot_param->efi_memmap);
1000 efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size;
1001 efi_desc_size = ia64_boot_param->efi_memdesc_size;
1003 for (p = efi_map_start; p < efi_map_end; pmd = md, p += efi_desc_size) {
1004 md = p;
1005 if (!efi_wb(md)) {
1006 if (efi_uc(md) && (md->type == EFI_CONVENTIONAL_MEMORY ||
1007 md->type == EFI_BOOT_SERVICES_DATA)) {
1008 k->attribute = EFI_MEMORY_UC;
1009 k->start = md->phys_addr;
1010 k->num_pages = md->num_pages;
1011 k++;
1013 continue;
1015 #ifdef XEN
1016 /* this works around a problem in the ski bootloader */
1017 if (running_on_sim && md->type != EFI_CONVENTIONAL_MEMORY)
1018 continue;
1019 #endif
1020 if (pmd == NULL || !efi_wb(pmd) || efi_md_end(pmd) != md->phys_addr) {
1021 contig_low = GRANULEROUNDUP(md->phys_addr);
1022 contig_high = efi_md_end(md);
1023 for (q = p + efi_desc_size; q < efi_map_end; q += efi_desc_size) {
1024 check_md = q;
1025 if (!efi_wb(check_md))
1026 break;
1027 if (contig_high != check_md->phys_addr)
1028 break;
1029 contig_high = efi_md_end(check_md);
1031 contig_high = GRANULEROUNDDOWN(contig_high);
1033 if (!is_memory_available(md))
1034 continue;
1036 #ifdef CONFIG_CRASH_DUMP
1037 /* saved_max_pfn should ignore max_addr= command line arg */
1038 if (saved_max_pfn < (efi_md_end(md) >> PAGE_SHIFT))
1039 saved_max_pfn = (efi_md_end(md) >> PAGE_SHIFT);
1040 #endif
1041 /*
1042 * Round ends inward to granule boundaries
1043 * Give trimmings to uncached allocator
1044 */
1045 if (md->phys_addr < contig_low) {
1046 lim = min(efi_md_end(md), contig_low);
1047 if (efi_uc(md)) {
1048 if (k > kern_memmap && (k-1)->attribute == EFI_MEMORY_UC &&
1049 kmd_end(k-1) == md->phys_addr) {
1050 (k-1)->num_pages += (lim - md->phys_addr) >> EFI_PAGE_SHIFT;
1051 } else {
1052 k->attribute = EFI_MEMORY_UC;
1053 k->start = md->phys_addr;
1054 k->num_pages = (lim - md->phys_addr) >> EFI_PAGE_SHIFT;
1055 k++;
1058 as = contig_low;
1059 } else
1060 as = md->phys_addr;
1062 if (efi_md_end(md) > contig_high) {
1063 lim = max(md->phys_addr, contig_high);
1064 if (efi_uc(md)) {
1065 if (lim == md->phys_addr && k > kern_memmap &&
1066 (k-1)->attribute == EFI_MEMORY_UC &&
1067 kmd_end(k-1) == md->phys_addr) {
1068 (k-1)->num_pages += md->num_pages;
1069 } else {
1070 k->attribute = EFI_MEMORY_UC;
1071 k->start = lim;
1072 k->num_pages = (efi_md_end(md) - lim) >> EFI_PAGE_SHIFT;
1073 k++;
1076 ae = contig_high;
1077 } else
1078 ae = efi_md_end(md);
1080 /* keep within max_addr= and min_addr= command line arg */
1081 as = max(as, min_addr);
1082 ae = min(ae, max_addr);
1083 if (ae <= as)
1084 continue;
1086 /* avoid going over mem= command line arg */
1087 if (total_mem + (ae - as) > mem_limit)
1088 ae -= total_mem + (ae - as) - mem_limit;
1090 if (ae <= as)
1091 continue;
1092 if (prev && kmd_end(prev) == md->phys_addr) {
1093 prev->num_pages += (ae - as) >> EFI_PAGE_SHIFT;
1094 total_mem += ae - as;
1095 continue;
1097 k->attribute = EFI_MEMORY_WB;
1098 k->start = as;
1099 k->num_pages = (ae - as) >> EFI_PAGE_SHIFT;
1100 total_mem += ae - as;
1101 prev = k++;
1103 k->start = ~0L; /* end-marker */
1105 /* reserve the memory we are using for kern_memmap */
1106 *s = (u64)kern_memmap;
1107 *e = (u64)++k;
1110 #ifndef XEN
1111 void
1112 efi_initialize_iomem_resources(struct resource *code_resource,
1113 struct resource *data_resource)
1115 struct resource *res;
1116 void *efi_map_start, *efi_map_end, *p;
1117 efi_memory_desc_t *md;
1118 u64 efi_desc_size;
1119 char *name;
1120 unsigned long flags;
1122 efi_map_start = __va(ia64_boot_param->efi_memmap);
1123 efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size;
1124 efi_desc_size = ia64_boot_param->efi_memdesc_size;
1126 res = NULL;
1128 for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
1129 md = p;
1131 if (md->num_pages == 0) /* should not happen */
1132 continue;
1134 flags = IORESOURCE_MEM;
1135 switch (md->type) {
1137 case EFI_MEMORY_MAPPED_IO:
1138 case EFI_MEMORY_MAPPED_IO_PORT_SPACE:
1139 continue;
1141 case EFI_LOADER_CODE:
1142 case EFI_LOADER_DATA:
1143 case EFI_BOOT_SERVICES_DATA:
1144 case EFI_BOOT_SERVICES_CODE:
1145 case EFI_CONVENTIONAL_MEMORY:
1146 if (md->attribute & EFI_MEMORY_WP) {
1147 name = "System ROM";
1148 flags |= IORESOURCE_READONLY;
1149 } else {
1150 name = "System RAM";
1152 break;
1154 case EFI_ACPI_MEMORY_NVS:
1155 name = "ACPI Non-volatile Storage";
1156 flags |= IORESOURCE_BUSY;
1157 break;
1159 case EFI_UNUSABLE_MEMORY:
1160 name = "reserved";
1161 flags |= IORESOURCE_BUSY | IORESOURCE_DISABLED;
1162 break;
1164 case EFI_RESERVED_TYPE:
1165 case EFI_RUNTIME_SERVICES_CODE:
1166 case EFI_RUNTIME_SERVICES_DATA:
1167 case EFI_ACPI_RECLAIM_MEMORY:
1168 default:
1169 name = "reserved";
1170 flags |= IORESOURCE_BUSY;
1171 break;
1174 if ((res = kzalloc(sizeof(struct resource), GFP_KERNEL)) == NULL) {
1175 printk(KERN_ERR "failed to alocate resource for iomem\n");
1176 return;
1179 res->name = name;
1180 res->start = md->phys_addr;
1181 res->end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT) - 1;
1182 res->flags = flags;
1184 if (insert_resource(&iomem_resource, res) < 0)
1185 kfree(res);
1186 else {
1187 /*
1188 * We don't know which region contains
1189 * kernel data so we try it repeatedly and
1190 * let the resource manager test it.
1191 */
1192 insert_resource(res, code_resource);
1193 insert_resource(res, data_resource);
1194 #ifdef CONFIG_KEXEC
1195 insert_resource(res, &efi_memmap_res);
1196 insert_resource(res, &boot_param_res);
1197 if (crashk_res.end > crashk_res.start)
1198 insert_resource(res, &crashk_res);
1199 #endif
1204 #ifdef CONFIG_KEXEC
1205 /* find a block of memory aligned to 64M exclude reserved regions
1206 rsvd_regions are sorted
1207 */
1208 unsigned long __init
1209 kdump_find_rsvd_region (unsigned long size,
1210 struct rsvd_region *r, int n)
1212 int i;
1213 u64 start, end;
1214 u64 alignment = 1UL << _PAGE_SIZE_64M;
1215 void *efi_map_start, *efi_map_end, *p;
1216 efi_memory_desc_t *md;
1217 u64 efi_desc_size;
1219 efi_map_start = __va(ia64_boot_param->efi_memmap);
1220 efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size;
1221 efi_desc_size = ia64_boot_param->efi_memdesc_size;
1223 for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
1224 md = p;
1225 if (!efi_wb(md))
1226 continue;
1227 start = ALIGN(md->phys_addr, alignment);
1228 end = efi_md_end(md);
1229 for (i = 0; i < n; i++) {
1230 if (__pa(r[i].start) >= start && __pa(r[i].end) < end) {
1231 if (__pa(r[i].start) > start + size)
1232 return start;
1233 start = ALIGN(__pa(r[i].end), alignment);
1234 if (i < n-1 && __pa(r[i+1].start) < start + size)
1235 continue;
1236 else
1237 break;
1240 if (end > start + size)
1241 return start;
1244 printk(KERN_WARNING "Cannot reserve 0x%lx byte of memory for crashdump\n",
1245 size);
1246 return ~0UL;
1248 #endif
1250 #ifdef CONFIG_PROC_VMCORE
1251 /* locate the size find a the descriptor at a certain address */
1252 unsigned long
1253 vmcore_find_descriptor_size (unsigned long address)
1255 void *efi_map_start, *efi_map_end, *p;
1256 efi_memory_desc_t *md;
1257 u64 efi_desc_size;
1258 unsigned long ret = 0;
1260 efi_map_start = __va(ia64_boot_param->efi_memmap);
1261 efi_map_end = efi_map_start + ia64_boot_param->efi_memmap_size;
1262 efi_desc_size = ia64_boot_param->efi_memdesc_size;
1264 for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
1265 md = p;
1266 if (efi_wb(md) && md->type == EFI_LOADER_DATA
1267 && md->phys_addr == address) {
1268 ret = efi_md_size(md);
1269 break;
1273 if (ret == 0)
1274 printk(KERN_WARNING "Cannot locate EFI vmcore descriptor\n");
1276 return ret;
1278 #endif
1279 #endif /* XEN */