arch/powerpc/kernel/dt_cpu_ftrs.c
Source file repositories/reference/linux-study-clean/arch/powerpc/kernel/dt_cpu_ftrs.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/kernel/dt_cpu_ftrs.c- Extension
.c- Size
- 27633 bytes
- Lines
- 1129
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/init.hlinux/jump_label.hlinux/libfdt.hlinux/memblock.hlinux/of_fdt.hlinux/printk.hlinux/sched.hlinux/string.hlinux/threads.hasm/cputable.hasm/dt_cpu_ftrs.hasm/mce.hasm/mmu.hasm/setup.h
Detected Declarations
struct dt_cpu_featurestruct dt_cpu_feature_matchfunction __restore_cpu_cpufeaturesfunction cpufeatures_setup_cpufunction feat_try_enable_unknownfunction feat_enablefunction feat_disablefunction feat_enable_hvfunction feat_enable_lefunction feat_enable_smtfunction feat_enable_idle_napfunction feat_enable_idle_stopfunction feat_enable_mmu_hashfunction feat_enable_mmu_hash_v3function feat_enable_mmu_radixfunction feat_enable_dscrfunction hfscr_pmu_enablefunction init_pmu_power8function feat_enable_mce_power8function feat_enable_pmu_power8function init_pmu_power9function feat_enable_mce_power9function feat_enable_pmu_power9function init_pmu_power10function feat_enable_pmu_power10function feat_enable_mce_power10function feat_enable_mce_power11function feat_enable_tmfunction feat_enable_fpfunction feat_enable_vectorfunction feat_enable_vsxfunction feat_enable_purrfunction feat_enable_ebbfunction feat_enable_dbellfunction feat_enable_hvifunction feat_enable_large_cifunction feat_enable_mmafunction dt_cpu_ftrs_parsefunction cpufeatures_setup_startfunction cpufeatures_process_featurefunction update_tlbie_feature_flagfunction cpufeatures_cpu_quirksfunction cpufeatures_setup_finishedfunction disabled_on_cmdlinefunction fdt_find_cpu_featuresfunction dt_cpu_ftrs_in_usefunction dt_cpu_ftrs_initfunction process_cpufeatures_node
Annotated Snippet
struct dt_cpu_feature {
const char *name;
uint32_t isa;
uint32_t usable_privilege;
uint32_t hv_support;
uint32_t os_support;
uint32_t hfscr_bit_nr;
uint32_t fscr_bit_nr;
uint32_t hwcap_bit_nr;
/* fdt parsing */
unsigned long node;
int enabled;
int disabled;
};
#define MMU_FTRS_HASH_BASE (MMU_FTRS_POWER8)
#define COMMON_USER_BASE (PPC_FEATURE_32 | PPC_FEATURE_64 | \
PPC_FEATURE_ARCH_2_06 |\
PPC_FEATURE_ICACHE_SNOOP)
#define COMMON_USER2_BASE (PPC_FEATURE2_ARCH_2_07 | \
PPC_FEATURE2_ISEL)
/*
* Set up the base CPU
*/
static int hv_mode;
static struct {
u64 lpcr;
u64 hfscr;
u64 fscr;
u64 pcr;
} system_registers;
static void (*init_pmu_registers)(void);
static void __restore_cpu_cpufeatures(void)
{
mtspr(SPRN_LPCR, system_registers.lpcr);
if (hv_mode) {
mtspr(SPRN_LPID, 0);
mtspr(SPRN_AMOR, ~0);
mtspr(SPRN_HFSCR, system_registers.hfscr);
mtspr(SPRN_PCR, system_registers.pcr);
}
mtspr(SPRN_FSCR, system_registers.fscr);
if (init_pmu_registers)
init_pmu_registers();
}
static char dt_cpu_name[64];
static struct cpu_spec __initdata base_cpu_spec = {
.cpu_name = NULL,
.cpu_features = CPU_FTRS_DT_CPU_BASE,
.cpu_user_features = COMMON_USER_BASE,
.cpu_user_features2 = COMMON_USER2_BASE,
.mmu_features = 0,
.icache_bsize = 32, /* minimum block size, fixed by */
.dcache_bsize = 32, /* cache info init. */
.num_pmcs = 0,
.pmc_type = PPC_PMC_DEFAULT,
.cpu_setup = NULL,
.cpu_restore = __restore_cpu_cpufeatures,
.machine_check_early = NULL,
.platform = NULL,
};
static void __init cpufeatures_setup_cpu(void)
{
set_cur_cpu_spec(&base_cpu_spec);
cur_cpu_spec->pvr_mask = -1;
cur_cpu_spec->pvr_value = mfspr(SPRN_PVR);
/* Initialize the base environment -- clear FSCR/HFSCR. */
hv_mode = !!(mfmsr() & MSR_HV);
if (hv_mode) {
cur_cpu_spec->cpu_features |= CPU_FTR_HVMODE;
mtspr(SPRN_HFSCR, 0);
}
mtspr(SPRN_FSCR, 0);
mtspr(SPRN_PCR, PCR_MASK);
/*
* LPCR does not get cleared, to match behaviour with secondaries
* in __restore_cpu_cpufeatures. Once the idle code is fixed, this
* could clear LPCR too.
Annotation
- Immediate include surface: `linux/export.h`, `linux/init.h`, `linux/jump_label.h`, `linux/libfdt.h`, `linux/memblock.h`, `linux/of_fdt.h`, `linux/printk.h`, `linux/sched.h`.
- Detected declarations: `struct dt_cpu_feature`, `struct dt_cpu_feature_match`, `function __restore_cpu_cpufeatures`, `function cpufeatures_setup_cpu`, `function feat_try_enable_unknown`, `function feat_enable`, `function feat_disable`, `function feat_enable_hv`, `function feat_enable_le`, `function feat_enable_smt`.
- Atlas domain: Architecture Layer / arch/powerpc.
- 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.