drivers/firmware/efi/libstub/arm32-stub.c
Source file repositories/reference/linux-study-clean/drivers/firmware/efi/libstub/arm32-stub.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firmware/efi/libstub/arm32-stub.c- Extension
.c- Size
- 3766 bytes
- Lines
- 135
- 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.hasm/efi.hefistub.h
Detected Declarations
function get_cpu_statefunction check_platform_featuresfunction efi_handle_post_ebs_statefunction handle_kernel_image
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 2013 Linaro Ltd; <roy.franz@linaro.org>
*/
#include <linux/efi.h>
#include <asm/efi.h>
#include "efistub.h"
static efi_guid_t cpu_state_guid = LINUX_EFI_ARM_CPU_STATE_TABLE_GUID;
struct efi_arm_entry_state *efi_entry_state;
static void get_cpu_state(u32 *cpsr, u32 *sctlr)
{
asm("mrs %0, cpsr" : "=r"(*cpsr));
if ((*cpsr & MODE_MASK) == HYP_MODE)
asm("mrc p15, 4, %0, c1, c0, 0" : "=r"(*sctlr));
else
asm("mrc p15, 0, %0, c1, c0, 0" : "=r"(*sctlr));
}
efi_status_t check_platform_features(void)
{
efi_status_t status;
u32 cpsr, sctlr;
int block;
get_cpu_state(&cpsr, &sctlr);
efi_info("Entering in %s mode with MMU %sabled\n",
((cpsr & MODE_MASK) == HYP_MODE) ? "HYP" : "SVC",
(sctlr & 1) ? "en" : "dis");
status = efi_bs_call(allocate_pool, EFI_LOADER_DATA,
sizeof(*efi_entry_state),
(void **)&efi_entry_state);
if (status != EFI_SUCCESS) {
efi_err("allocate_pool() failed\n");
return status;
}
efi_entry_state->cpsr_before_ebs = cpsr;
efi_entry_state->sctlr_before_ebs = sctlr;
status = efi_bs_call(install_configuration_table, &cpu_state_guid,
efi_entry_state);
if (status != EFI_SUCCESS) {
efi_err("install_configuration_table() failed\n");
goto free_state;
}
/* non-LPAE kernels can run anywhere */
if (!IS_ENABLED(CONFIG_ARM_LPAE))
return EFI_SUCCESS;
/* LPAE kernels need compatible hardware */
block = cpuid_feature_extract(CPUID_EXT_MMFR0, 0);
if (block < 5) {
efi_err("This LPAE kernel is not supported by your CPU\n");
status = EFI_UNSUPPORTED;
goto drop_table;
}
return EFI_SUCCESS;
drop_table:
efi_bs_call(install_configuration_table, &cpu_state_guid, NULL);
free_state:
efi_bs_call(free_pool, efi_entry_state);
return status;
}
void efi_handle_post_ebs_state(void)
{
get_cpu_state(&efi_entry_state->cpsr_after_ebs,
&efi_entry_state->sctlr_after_ebs);
}
efi_status_t handle_kernel_image(unsigned long *image_addr,
unsigned long *image_size,
unsigned long *reserve_addr,
unsigned long *reserve_size,
efi_loaded_image_t *image,
efi_handle_t image_handle)
{
const int slack = TEXT_OFFSET - 5 * PAGE_SIZE;
int alloc_size = MAX_UNCOMP_KERNEL_SIZE + EFI_PHYS_ALIGN;
unsigned long alloc_base, kernel_base;
efi_status_t status;
Annotation
- Immediate include surface: `linux/efi.h`, `asm/efi.h`, `efistub.h`.
- Detected declarations: `function get_cpu_state`, `function check_platform_features`, `function efi_handle_post_ebs_state`, `function handle_kernel_image`.
- 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.