arch/x86/include/asm/cpuid/api.h
Source file repositories/reference/linux-study-clean/arch/x86/include/asm/cpuid/api.h
File Facts
- System
- Linux kernel
- Corpus path
arch/x86/include/asm/cpuid/api.h- Extension
.h- Size
- 15581 bytes
- Lines
- 540
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
asm/cpuid/types.hlinux/build_bug.hlinux/types.hasm/processor.hasm/string.hasm/paravirt.h
Detected Declarations
function cpuid_featurefunction native_cpuidfunction CPUsfunction cpuid_countfunction cpuid_eaxfunction cpuid_ebxfunction cpuid_ecxfunction cpuid_edxfunction __cpuid_readfunction __cpuid_read_regfunction cpuid_function_is_indexedfunction cpuid_base_hypervisorfunction for_each_possible_cpuid_base_hypervisorfunction CPUIDfunction for_each_cpuid_0x2_descfunction CPUID
Annotated Snippet
* for_each_cpuid_0x2_desc(regs, ptr, desc) {
* switch (desc->c_type) {
* ...
* }
* }
*/
#define for_each_cpuid_0x2_desc(_regs, _ptr, _desc) \
for (_ptr = &(_regs).desc[1]; \
_ptr < &(_regs).desc[16] && (_desc = &cpuid_0x2_table[*_ptr]); \
_ptr++)
/*
* CPUID(0x80000006) parsing:
*/
static inline bool cpuid_amd_hygon_has_l3_cache(void)
{
return cpuid_edx(0x80000006);
}
/*
* 'struct cpuid_leaves' accessors (without sanity checks):
*
* For internal use by the CPUID parser.
*/
/* Return constified pointers for all call-site APIs */
#define __const_ptr(_ptr) \
((const __typeof__(*(_ptr)) *)(_ptr))
#define __cpuid_leaves_subleaf(_leaves, _leaf, _subleaf) \
__const_ptr(&((_leaves)->leaf_ ## _leaf ## _ ## _subleaf)[0])
#define __cpuid_leaves_subleaf_n(_leaves, _leaf, _index) \
__const_ptr(&((_leaves)->leaf_ ## _leaf ## _ ## n)[_index])
#define __cpuid_leaves_subleaf_info(_leaves, _leaf, _subleaf) \
__const_ptr(&((_leaves)->leaf_ ## _leaf ## _ ## _subleaf ## _ ## info))
/*
* 'struct cpuid_table' accessors (with sanity checks):
*
* For internal use by the CPUID parser.
*/
#define __cpuid_table_nr_filled_subleaves(_table, _leaf, _subleaf) \
__cpuid_leaves_subleaf_info(&((_table)->leaves), _leaf, _subleaf)->nr_entries
#define __cpuid_table_subleaf_range_size(_table, _leaf) \
ARRAY_SIZE((_table)->leaves.leaf_ ## _leaf ## _n)
#define __cpuid_table_invalid_subleaf(_table, _leaf, _subleaf) \
(((_subleaf) < (__cpuid_leaf_first_subleaf(_leaf))) || \
((_subleaf) > (__cpuid_leaf_first_subleaf(_leaf) + \
__cpuid_table_subleaf_range_size(_table, _leaf) - 1)))
/* Return NULL if the parser did not fill that leaf. Check cpuid_subleaf(). */
#define __cpuid_table_subleaf(_table, _leaf, _subleaf) \
({ \
unsigned int ____f = __cpuid_table_nr_filled_subleaves(_table, _leaf, _subleaf); \
\
(____f != 1) ? NULL : __cpuid_leaves_subleaf(&((_table)->leaves), _leaf, _subleaf); \
})
/*
* Return NULL if the CPUID parser did not fill this leaf, or if the given
* dynamic subleaf value is out of range. Check cpuid_subleaf_n().
*/
#define __cpuid_table_subleaf_n(_table, _leaf, _subleaf) \
({ \
unsigned int ____i = (_subleaf) - __cpuid_leaf_first_subleaf(_leaf); \
unsigned int ____f = __cpuid_table_nr_filled_subleaves(_table, _leaf, n); \
\
/* CPUID parser might not have filled the entire subleaf range */ \
((____i >= ____f) || __cpuid_table_invalid_subleaf(_table, _leaf, _subleaf)) ? \
NULL : __cpuid_leaves_subleaf_n(&((_table)->leaves), _leaf, ____i); \
})
/*
* Compile-time checks for leaves with a subleaf range:
*/
#define __cpuid_assert_subleaf_range(_cpuinfo, _leaf) \
static_assert(__cpuid_table_subleaf_range_size(&(_cpuinfo)->cpuid, _leaf) > 1)
#define __cpuid_assert_subleaf_within_range(_cpuinfo, _leaf, _subleaf) \
BUILD_BUG_ON(__builtin_constant_p(_subleaf) && \
__cpuid_table_invalid_subleaf(&(_cpuinfo)->cpuid, _leaf, _subleaf))
/*
Annotation
- Immediate include surface: `asm/cpuid/types.h`, `linux/build_bug.h`, `linux/types.h`, `asm/processor.h`, `asm/string.h`, `asm/paravirt.h`.
- Detected declarations: `function cpuid_feature`, `function native_cpuid`, `function CPUs`, `function cpuid_count`, `function cpuid_eax`, `function cpuid_ebx`, `function cpuid_ecx`, `function cpuid_edx`, `function __cpuid_read`, `function __cpuid_read_reg`.
- 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.