aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/platform/efi
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2012-02-12 16:24:25 -0500
committerH. Peter Anvin <hpa@zytor.com>2012-02-23 21:53:56 -0500
commit83e7ee6657dfcd6b0ee2406d11024b558064252a (patch)
tree76f3e07f4689681f1e4e58a508c987f9cdc1f854 /arch/x86/platform/efi
parentb01543dfe67bb1d191998e90d20534dc354de059 (diff)
x86, efi: Refactor efi_init() a bit
Break out some of the init steps into helper functions. Only change to execution flow is the removal of the warning when the kernel memdesc structure differ in size from what firmware specifies since it's a bogus warning (it's a valid difference per spec). v4: * Removed memdesc warning as per above Signed-off-by: Olof Johansson <olof@lixom.net> Link: http://lkml.kernel.org/r/1329081869-20779-2-git-send-email-olof@lixom.net Acked-by: Matt Fleming <matt.fleming@intel.com> Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/x86/platform/efi')
-rw-r--r--arch/x86/platform/efi/efi.c89
1 files changed, 54 insertions, 35 deletions
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 4cf9bd0a1653..6d88dcac466c 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -429,23 +429,8 @@ static void __init efi_free_boot_services(void)
429 } 429 }
430} 430}
431 431
432void __init efi_init(void) 432static void __init efi_systab_init(void *phys)
433{ 433{
434 efi_config_table_t *config_tables;
435 efi_runtime_services_t *runtime;
436 efi_char16_t *c16;
437 char vendor[100] = "unknown";
438 int i = 0;
439 void *tmp;
440
441#ifdef CONFIG_X86_32
442 efi_phys.systab = (efi_system_table_t *)boot_params.efi_info.efi_systab;
443#else
444 efi_phys.systab = (efi_system_table_t *)
445 (boot_params.efi_info.efi_systab |
446 ((__u64)boot_params.efi_info.efi_systab_hi<<32));
447#endif
448
449 efi.systab = early_ioremap((unsigned long)efi_phys.systab, 434 efi.systab = early_ioremap((unsigned long)efi_phys.systab,
450 sizeof(efi_system_table_t)); 435 sizeof(efi_system_table_t));
451 if (efi.systab == NULL) 436 if (efi.systab == NULL)
@@ -464,22 +449,12 @@ void __init efi_init(void)
464 "%d.%02d, expected 1.00 or greater!\n", 449 "%d.%02d, expected 1.00 or greater!\n",
465 efi.systab->hdr.revision >> 16, 450 efi.systab->hdr.revision >> 16,
466 efi.systab->hdr.revision & 0xffff); 451 efi.systab->hdr.revision & 0xffff);
452}
467 453
468 /* 454static void __init efi_config_init(u64 tables, int nr_tables)
469 * Show what we know for posterity 455{
470 */ 456 efi_config_table_t *config_tables;
471 c16 = tmp = early_ioremap(efi.systab->fw_vendor, 2); 457 int i;
472 if (c16) {
473 for (i = 0; i < sizeof(vendor) - 1 && *c16; ++i)
474 vendor[i] = *c16++;
475 vendor[i] = '\0';
476 } else
477 printk(KERN_ERR PFX "Could not map the firmware vendor!\n");
478 early_iounmap(tmp, 2);
479
480 printk(KERN_INFO "EFI v%u.%.02u by %s\n",
481 efi.systab->hdr.revision >> 16,
482 efi.systab->hdr.revision & 0xffff, vendor);
483 458
484 /* 459 /*
485 * Let's see what config tables the firmware passed to us. 460 * Let's see what config tables the firmware passed to us.
@@ -526,6 +501,11 @@ void __init efi_init(void)
526 printk("\n"); 501 printk("\n");
527 early_iounmap(config_tables, 502 early_iounmap(config_tables,
528 efi.systab->nr_tables * sizeof(efi_config_table_t)); 503 efi.systab->nr_tables * sizeof(efi_config_table_t));
504}
505
506static void __init efi_runtime_init(void)
507{
508 efi_runtime_services_t *runtime;
529 509
530 /* 510 /*
531 * Check out the runtime services table. We need to map 511 * Check out the runtime services table. We need to map
@@ -554,7 +534,10 @@ void __init efi_init(void)
554 printk(KERN_ERR "Could not map the EFI runtime service " 534 printk(KERN_ERR "Could not map the EFI runtime service "
555 "table!\n"); 535 "table!\n");
556 early_iounmap(runtime, sizeof(efi_runtime_services_t)); 536 early_iounmap(runtime, sizeof(efi_runtime_services_t));
537}
557 538
539static void __init efi_memmap_init(void)
540{
558 /* Map the EFI memory map */ 541 /* Map the EFI memory map */
559 memmap.map = early_ioremap((unsigned long)memmap.phys_map, 542 memmap.map = early_ioremap((unsigned long)memmap.phys_map,
560 memmap.nr_map * memmap.desc_size); 543 memmap.nr_map * memmap.desc_size);
@@ -562,12 +545,48 @@ void __init efi_init(void)
562 printk(KERN_ERR "Could not map the EFI memory map!\n"); 545 printk(KERN_ERR "Could not map the EFI memory map!\n");
563 memmap.map_end = memmap.map + (memmap.nr_map * memmap.desc_size); 546 memmap.map_end = memmap.map + (memmap.nr_map * memmap.desc_size);
564 547
565 if (memmap.desc_size != sizeof(efi_memory_desc_t))
566 printk(KERN_WARNING
567 "Kernel-defined memdesc doesn't match the one from EFI!\n");
568
569 if (add_efi_memmap) 548 if (add_efi_memmap)
570 do_add_efi_memmap(); 549 do_add_efi_memmap();
550}
551
552void __init efi_init(void)
553{
554 efi_char16_t *c16;
555 char vendor[100] = "unknown";
556 int i = 0;
557 void *tmp;
558
559#ifdef CONFIG_X86_32
560 efi_phys.systab = (efi_system_table_t *)boot_params.efi_info.efi_systab;
561#else
562 efi_phys.systab = (efi_system_table_t *)
563 (boot_params.efi_info.efi_systab |
564 ((__u64)boot_params.efi_info.efi_systab_hi<<32));
565#endif
566
567 efi_systab_init(efi_phys.systab);
568
569 /*
570 * Show what we know for posterity
571 */
572 c16 = tmp = early_ioremap(efi.systab->fw_vendor, 2);
573 if (c16) {
574 for (i = 0; i < sizeof(vendor) - 1 && *c16; ++i)
575 vendor[i] = *c16++;
576 vendor[i] = '\0';
577 } else
578 printk(KERN_ERR PFX "Could not map the firmware vendor!\n");
579 early_iounmap(tmp, 2);
580
581 printk(KERN_INFO "EFI v%u.%.02u by %s\n",
582 efi.systab->hdr.revision >> 16,
583 efi.systab->hdr.revision & 0xffff, vendor);
584
585 efi_config_init(efi.systab->tables, efi.systab->nr_tables);
586
587 efi_runtime_init();
588
589 efi_memmap_init();
571 590
572#ifdef CONFIG_X86_32 591#ifdef CONFIG_X86_32
573 x86_platform.get_wallclock = efi_get_time; 592 x86_platform.get_wallclock = efi_get_time;