drivers/firmware/efi/efi-init.c
Source file repositories/reference/linux-study-clean/drivers/firmware/efi/efi-init.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firmware/efi/efi-init.c- Extension
.c- Size
- 7356 bytes
- Lines
- 279
- Domain
- Driver Families
- Bucket
- drivers/firmware
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/efi.hlinux/fwnode.hlinux/init.hlinux/kexec_handover.hlinux/memblock.hlinux/mm_types.hlinux/of.hlinux/of_address.hlinux/of_fdt.hlinux/platform_device.hlinux/sysfb.hasm/efi.h
Detected Declarations
function is_memoryfunction SetVirtualAddressMapfunction for_each_efi_memory_descfunction init_primary_displayfunction uefi_initfunction is_usable_memoryfunction reserve_regionsfunction for_each_mem_regionfunction for_each_efi_memory_descfunction efi_initexport sysfb_primary_display
Annotated Snippet
if (!dpy) {
pr_err("Could not map primary_display config table\n");
return;
}
sysfb_primary_display = *dpy;
memset(dpy, 0, sizeof(*dpy));
early_memunmap(dpy, sizeof(*dpy));
if (memblock_is_map_memory(sysfb_primary_display.screen.lfb_base))
memblock_mark_nomap(sysfb_primary_display.screen.lfb_base,
sysfb_primary_display.screen.lfb_size);
if (IS_ENABLED(CONFIG_EFI_EARLYCON))
efi_earlycon_reprobe();
}
}
static int __init uefi_init(u64 efi_system_table)
{
efi_config_table_t *config_tables;
efi_system_table_t *systab;
size_t table_size;
int retval;
systab = early_memremap_ro(efi_system_table, sizeof(efi_system_table_t));
if (systab == NULL) {
pr_warn("Unable to map EFI system table.\n");
return -ENOMEM;
}
set_bit(EFI_BOOT, &efi.flags);
if (IS_ENABLED(CONFIG_64BIT))
set_bit(EFI_64BIT, &efi.flags);
retval = efi_systab_check_header(&systab->hdr);
if (retval)
goto out;
efi.runtime = systab->runtime;
efi.runtime_version = systab->hdr.revision;
efi_systab_report_header(&systab->hdr, efi_to_phys(systab->fw_vendor));
table_size = sizeof(efi_config_table_t) * systab->nr_tables;
config_tables = early_memremap_ro(efi_to_phys(systab->tables),
table_size);
if (config_tables == NULL) {
pr_warn("Unable to map EFI config table array.\n");
retval = -ENOMEM;
goto out;
}
retval = efi_config_parse_tables(config_tables, systab->nr_tables,
efi_arch_tables);
early_memunmap(config_tables, table_size);
out:
early_memunmap(systab, sizeof(efi_system_table_t));
return retval;
}
/*
* Return true for regions that can be used as System RAM.
*/
static __init int is_usable_memory(efi_memory_desc_t *md)
{
switch (md->type) {
case EFI_LOADER_CODE:
case EFI_LOADER_DATA:
case EFI_ACPI_RECLAIM_MEMORY:
case EFI_BOOT_SERVICES_CODE:
case EFI_BOOT_SERVICES_DATA:
case EFI_CONVENTIONAL_MEMORY:
case EFI_PERSISTENT_MEMORY:
/*
* According to the spec, these regions are no longer reserved
* after calling ExitBootServices(). However, we can only use
* them as System RAM if they can be mapped writeback cacheable.
*/
return (md->attribute & EFI_MEMORY_WB);
default:
break;
}
return false;
}
static __init void reserve_regions(void)
{
efi_memory_desc_t *md;
u64 paddr, npages, size;
Annotation
- Immediate include surface: `linux/efi.h`, `linux/fwnode.h`, `linux/init.h`, `linux/kexec_handover.h`, `linux/memblock.h`, `linux/mm_types.h`, `linux/of.h`, `linux/of_address.h`.
- Detected declarations: `function is_memory`, `function SetVirtualAddressMap`, `function for_each_efi_memory_desc`, `function init_primary_display`, `function uefi_init`, `function is_usable_memory`, `function reserve_regions`, `function for_each_mem_region`, `function for_each_efi_memory_desc`, `function efi_init`.
- Atlas domain: Driver Families / drivers/firmware.
- Implementation status: integration implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.