drivers/firmware/efi/libstub/x86-stub.c
Source file repositories/reference/linux-study-clean/drivers/firmware/efi/libstub/x86-stub.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firmware/efi/libstub/x86-stub.c- Extension
.c- Size
- 27650 bytes
- Lines
- 1071
- Domain
- Driver Families
- Bucket
- drivers/firmware
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/efi.hlinux/pci.hlinux/stddef.hasm/efi.hasm/e820/types.hasm/setup.hasm/desc.hasm/boot.hasm/kaslr.hasm/sev.hefistub.hx86-stub.h
Detected Declarations
struct smbios_entry_pointstruct __packedstruct exit_boot_structfunction preserve_pci_rom_imagefunction analysisfunction for_each_efi_handlefunction retrieve_apple_device_propertiesfunction verify_ep_checksumfunction verify_ep_integrityfunction apple_match_product_namefunction apple_set_osfunction efi_adjust_memory_range_protectionfunction setup_unaccepted_memoryfunction setup_quirksfunction setup_graphicsfunction efi_exitfunction ourselvesfunction add_e820extfunction setup_e820function alloc_e820extfunction allocate_e820function exit_boot_funcfunction exit_bootfunction have_unsupported_snp_featuresfunction efi_get_seedfunction errorfunction parse_optionsfunction efi_decompress_kernelfunction enter_kernelfunction efi_stub_entryfunction efi_pe_entryfunction efi_handover_entry
Annotated Snippet
struct smbios_entry_point {
u8 anchor[4];
u8 ep_checksum;
u8 ep_length;
u8 major_version;
u8 minor_version;
u16 max_size_entry;
u8 ep_rev;
u8 reserved[5];
struct __packed {
u8 anchor[5];
u8 checksum;
u16 st_length;
u32 st_address;
u16 number_of_entries;
u8 bcd_rev;
} intm;
};
static bool verify_ep_checksum(const void *ptr, int length)
{
u8 sum = 0;
for (int i = 0; i < length; i++)
sum += ((u8 *)ptr)[i];
return sum == 0;
}
static bool verify_ep_integrity(const struct smbios_entry_point *ep)
{
if (memcmp(ep->anchor, "_SM_", sizeof(ep->anchor)) != 0)
return false;
if (memcmp(ep->intm.anchor, "_DMI_", sizeof(ep->intm.anchor)) != 0)
return false;
if (!verify_ep_checksum(ep, ep->ep_length) ||
!verify_ep_checksum(&ep->intm, sizeof(ep->intm)))
return false;
return true;
}
static const struct efi_smbios_record *search_record(void *table, u32 length,
u8 type)
{
const u8 *p, *end;
p = (u8 *)table;
end = p + length;
while (p + sizeof(struct efi_smbios_record) < end) {
const struct efi_smbios_record *hdr =
(struct efi_smbios_record *)p;
const u8 *next;
if (hdr->type == type)
return hdr;
/* Type 127 = End-of-Table */
if (hdr->type == 0x7F)
return NULL;
/* Jumping to the unformed section */
next = p + hdr->length;
/* Unformed section ends with 0000h */
while ((next[0] != 0 || next[1] != 0) && next + 1 < end)
next++;
next += 2;
p = next;
}
return NULL;
}
static const struct efi_smbios_record *get_table_record(u8 type)
{
const struct smbios_entry_point *ep;
/*
* Locate the legacy 32-bit SMBIOS entrypoint in memory, and parse it
* directly. Needed by some Macs that do not implement the EFI protocol.
*/
ep = get_efi_config_table(SMBIOS_TABLE_GUID);
if (!ep)
return NULL;
Annotation
- Immediate include surface: `linux/efi.h`, `linux/pci.h`, `linux/stddef.h`, `asm/efi.h`, `asm/e820/types.h`, `asm/setup.h`, `asm/desc.h`, `asm/boot.h`.
- Detected declarations: `struct smbios_entry_point`, `struct __packed`, `struct exit_boot_struct`, `function preserve_pci_rom_image`, `function analysis`, `function for_each_efi_handle`, `function retrieve_apple_device_properties`, `function verify_ep_checksum`, `function verify_ep_integrity`, `function apple_match_product_name`.
- Atlas domain: Driver Families / drivers/firmware.
- 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.