arch/x86/kernel/cpu/cpuid_parser.h

Source file repositories/reference/linux-study-clean/arch/x86/kernel/cpu/cpuid_parser.h

File Facts

System
Linux kernel
Corpus path
arch/x86/kernel/cpu/cpuid_parser.h
Extension
.h
Size
4415 bytes
Lines
121
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.

Dependency Surface

Detected Declarations

Annotated Snippet

struct cpuid_read_output {
	struct cpuid_regs	*regs;
	struct leaf_parse_info	*info;
};

/**
 * struct cpuid_parse_entry - CPUID parse table entry
 * @leaf:	Leaf number to be parsed
 * @subleaf:	Subleaf number to be parsed
 * @regs_offs:	Offset within 'struct cpuid_leaves' for saving the CPUID query output; to be
 *		passed to cpuid_table_regs_p().
 * @info_offs:	Offset within 'struct cpuid_leaves' for saving the CPUID query parse info; to be
 *		passed to cpuid_table_info_p().
 * @maxcnt:	Maximum number of output storage entries available for the CPUID query.
 * @read:	Read function for this entry.  It must save the parsed CPUID output to the passed
 *		'struct cpuid_read_output'->regs array of size >= @maxcnt.  It must set
 *		'struct cpuid_read_output'->info.nr_entries to the number of CPUID output entries
 *		parsed and filled.  A generic implementation is provided at cpuid_read_generic().
 */
struct cpuid_parse_entry {
	unsigned int	leaf;
	unsigned int	subleaf;
	unsigned int	regs_offs;
	unsigned int	info_offs;
	unsigned int	maxcnt;
	void		(*read)(const struct cpuid_parse_entry *e, const struct cpuid_read_output *o);
};

#define __CPUID_PARSE_ENTRY(_leaf, _subleaf, _suffix, _reader_fn)		\
	{									\
		.leaf		= _leaf,					\
		.subleaf	= _subleaf,					\
		.regs_offs	= __cpuid_leaves_regs_offset(_leaf, _suffix),	\
		.info_offs	= __cpuid_leaves_info_offset(_leaf, _suffix),	\
		.maxcnt		= __cpuid_leaves_regs_maxcnt(_leaf, _suffix),	\
		.read		= cpuid_read_ ## _reader_fn,			\
	}

/*
 * CPUID_PARSE_ENTRY_N() is for parsing CPUID leaves with a subleaf range.
 * Check <asm/cpuid/types.h> __CPUID_LEAF() vs. CPUID_LEAF_N().
 */

#define CPUID_PARSE_ENTRY(_leaf, _subleaf, _reader_fn)				\
	__CPUID_PARSE_ENTRY(_leaf, _subleaf, _subleaf, _reader_fn)

#define CPUID_PARSE_ENTRY_N(_leaf, _reader_fn)					\
	__CPUID_PARSE_ENTRY(_leaf, __cpuid_leaf_first_subleaf(_leaf), n, _reader_fn)

/*
 * CPUID parser table:
 */

#define CPUID_PARSE_ENTRIES									\
	/*			Leaf		Subleaf		Reader function */		\
	CPUID_PARSE_ENTRY   (	0x0,		0,		generic			),	\
	CPUID_PARSE_ENTRY   (	0x1,		0,		generic			),	\

#endif /* _ARCH_X86_CPUID_PARSER_H */

Annotation

Implementation Notes