drivers/firmware/efi/libstub/loongarch.c
Source file repositories/reference/linux-study-clean/drivers/firmware/efi/libstub/loongarch.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firmware/efi/libstub/loongarch.c- Extension
.c- Size
- 2947 bytes
- Lines
- 106
- 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
asm/efi.hasm/addrspace.hefistub.hloongarch-stub.h
Detected Declarations
struct exit_boot_structfunction check_platform_featuresfunction efi_cache_sync_imagefunction efi_get_kimg_kaslr_addressfunction exit_boot_funcfunction kernel_entry_addressfunction efi_boot_kernel
Annotated Snippet
struct exit_boot_struct {
efi_memory_desc_t *runtime_map;
int runtime_entry_count;
};
static efi_status_t exit_boot_func(struct efi_boot_memmap *map, void *priv)
{
struct exit_boot_struct *p = priv;
/*
* Update the memory map with virtual addresses. The function will also
* populate @runtime_map with copies of just the EFI_MEMORY_RUNTIME
* entries so that we can pass it straight to SetVirtualAddressMap()
*/
efi_get_virtmap(map->map, map->map_size, map->desc_size,
p->runtime_map, &p->runtime_entry_count);
return EFI_SUCCESS;
}
unsigned long __weak kernel_entry_address(unsigned long kernel_addr,
efi_loaded_image_t *image)
{
return *(unsigned long *)(kernel_addr + 8) - PHYSADDR(VMLINUX_LOAD_ADDRESS) + kernel_addr;
}
efi_status_t efi_boot_kernel(void *handle, efi_loaded_image_t *image,
unsigned long kernel_addr, char *cmdline_ptr)
{
kernel_entry_t real_kernel_entry;
struct exit_boot_struct priv;
unsigned long desc_size;
efi_status_t status;
u32 desc_ver;
status = efi_alloc_virtmap(&priv.runtime_map, &desc_size, &desc_ver);
if (status != EFI_SUCCESS) {
efi_err("Unable to retrieve UEFI memory map.\n");
return status;
}
efi_info("Exiting boot services\n");
efi_novamap = false;
status = efi_exit_boot_services(handle, &priv, exit_boot_func);
if (status != EFI_SUCCESS)
return status;
/* Install the new virtual address map */
efi_rt_call(set_virtual_address_map,
priv.runtime_entry_count * desc_size, desc_size,
desc_ver, priv.runtime_map);
/* Config Direct Mapping */
csr_write(CSR_DMW0_INIT, LOONGARCH_CSR_DMWIN0);
csr_write(CSR_DMW1_INIT, LOONGARCH_CSR_DMWIN1);
csr_write(CSR_DMW2_INIT, LOONGARCH_CSR_DMWIN2);
csr_write(CSR_DMW3_INIT, LOONGARCH_CSR_DMWIN3);
real_kernel_entry = (void *)kernel_entry_address(kernel_addr, image);
real_kernel_entry(true, (unsigned long)cmdline_ptr,
(unsigned long)efi_system_table);
}
Annotation
- Immediate include surface: `asm/efi.h`, `asm/addrspace.h`, `efistub.h`, `loongarch-stub.h`.
- Detected declarations: `struct exit_boot_struct`, `function check_platform_features`, `function efi_cache_sync_image`, `function efi_get_kimg_kaslr_address`, `function exit_boot_func`, `function kernel_entry_address`, `function efi_boot_kernel`.
- 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.