arch/x86/platform/efi/efi.c
Source file repositories/reference/linux-study-clean/arch/x86/platform/efi/efi.c
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/platform/efi/efi.c- Extension
.c- Size
- 23331 bytes
- Lines
- 927
- Domain
- Architecture Layer
- Bucket
- arch/x86
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/init.hlinux/efi.hlinux/efi-bgrt.hlinux/export.hlinux/memblock.hlinux/slab.hlinux/spinlock.hlinux/uaccess.hlinux/time.hlinux/io.hlinux/reboot.hlinux/bcd.hasm/setup.hasm/efi.hasm/e820/api.hasm/time.hasm/tlbflush.hasm/x86_init.hasm/uv/uv.h
Detected Declarations
function setup_add_efi_memmapfunction legacyfunction for_each_efi_memory_descfunction do_efi_soft_reservefunction efi_memblock_x86_reserve_rangefunction efi_memmap_entry_validfunction efi_clean_memmapfunction OSfunction for_each_efi_memory_descfunction efi_print_memmapfunction for_each_efi_memory_descfunction efi_systab_initfunction efi_config_initfunction efi_initfunction efi_merge_regionsfunction for_each_efi_memory_descfunction efi_map_regionfunction should_map_regionfunction efi_map_regionsfunction kexec_enter_virtual_modefunction kexec_enter_virtual_modefunction efi_enter_virtual_modefunction efi_is_table_addressfunction efi_attr_is_visiblefunction __x86_efi_boot_mode
Annotated Snippet
switch (md->type) {
case EFI_LOADER_CODE:
case EFI_LOADER_DATA:
case EFI_BOOT_SERVICES_CODE:
case EFI_BOOT_SERVICES_DATA:
case EFI_CONVENTIONAL_MEMORY:
if (efi_soft_reserve_enabled()
&& (md->attribute & EFI_MEMORY_SP))
e820_type = E820_TYPE_SOFT_RESERVED;
else if (md->attribute & EFI_MEMORY_WB)
e820_type = E820_TYPE_RAM;
else
e820_type = E820_TYPE_RESERVED;
break;
case EFI_ACPI_RECLAIM_MEMORY:
e820_type = E820_TYPE_ACPI;
break;
case EFI_ACPI_MEMORY_NVS:
e820_type = E820_TYPE_NVS;
break;
case EFI_UNUSABLE_MEMORY:
e820_type = E820_TYPE_UNUSABLE;
break;
case EFI_PERSISTENT_MEMORY:
e820_type = E820_TYPE_PMEM;
break;
default:
/*
* EFI_RESERVED_TYPE EFI_RUNTIME_SERVICES_CODE
* EFI_RUNTIME_SERVICES_DATA EFI_MEMORY_MAPPED_IO
* EFI_MEMORY_MAPPED_IO_PORT_SPACE EFI_PAL_CODE
*/
e820_type = E820_TYPE_RESERVED;
break;
}
e820__range_add(start, size, e820_type);
}
e820__update_table(e820_table);
}
/*
* Given add_efi_memmap defaults to 0 and there is no alternative
* e820 mechanism for soft-reserved memory, import the full EFI memory
* map if soft reservations are present and enabled. Otherwise, the
* mechanism to disable the kernel's consideration of EFI_MEMORY_SP is
* the efi=nosoftreserve option.
*/
static bool do_efi_soft_reserve(void)
{
efi_memory_desc_t *md;
if (!efi_enabled(EFI_MEMMAP))
return false;
if (!efi_soft_reserve_enabled())
return false;
for_each_efi_memory_desc(md)
if (md->type == EFI_CONVENTIONAL_MEMORY &&
(md->attribute & EFI_MEMORY_SP))
return true;
return false;
}
int __init efi_memblock_x86_reserve_range(void)
{
struct efi_info *e = &boot_params.efi_info;
struct efi_memory_map_data data;
phys_addr_t pmap;
int rv;
if (efi_enabled(EFI_PARAVIRT))
return 0;
/* Can't handle firmware tables above 4GB on i386 */
if (IS_ENABLED(CONFIG_X86_32) && e->efi_memmap_hi > 0) {
pr_err("Memory map is above 4GB, disabling EFI.\n");
return -EINVAL;
}
pmap = (phys_addr_t)(e->efi_memmap | ((u64)e->efi_memmap_hi << 32));
data.phys_map = pmap;
data.size = e->efi_memmap_size;
data.desc_size = e->efi_memdesc_size;
data.desc_version = e->efi_memdesc_version;
if (!efi_enabled(EFI_PARAVIRT)) {
rv = efi_memmap_init_early(&data);
if (rv)
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/init.h`, `linux/efi.h`, `linux/efi-bgrt.h`, `linux/export.h`, `linux/memblock.h`, `linux/slab.h`, `linux/spinlock.h`.
- Detected declarations: `function setup_add_efi_memmap`, `function legacy`, `function for_each_efi_memory_desc`, `function do_efi_soft_reserve`, `function efi_memblock_x86_reserve_range`, `function efi_memmap_entry_valid`, `function efi_clean_memmap`, `function OS`, `function for_each_efi_memory_desc`, `function efi_print_memmap`.
- Atlas domain: Architecture Layer / arch/x86.
- Implementation status: source 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.