arch/x86/include/cpu: introduce CPUID_FROM_FMS macro

Introduce a macro to get the raw CPUID leaf 1 EAX value from a given set
of CPU family, model and stepping. The processor type in bits 12 and 13
is assumed to be always be zero; at least this is the case for all
CPUIDs that are currently in the coreboot tree. This can be used to
make the device values in the CPU device ID tables easier to read.

Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Change-Id: Idab77453712b14983b1d02ca365f7924239fc2bf
Reviewed-on: https://review.coreboot.org/c/coreboot/+/72856
Reviewed-by: Fred Reitberger <reitbergerfred@gmail.com>
Reviewed-by: Martin Roth <martin.roth@amd.corp-partner.google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Felix Held 2023-02-06 18:36:45 +01:00
parent 9700fe2f10
commit 180e414a80
1 changed files with 10 additions and 0 deletions

View File

@ -111,6 +111,16 @@ static inline bool cpu_is_intel(void)
struct device;
#define CPUID_FROM_FMS(family, model, stepping) ( \
/* bits 31..28: reserved, set to 0 */ \
((family) > 0xf ? ((family) - 0xf) & 0xff : 0) << 20 | \
((model) >> 4 & 0xf) << 16 | \
/* bits 15..14: reserved, set to 0 */ \
/* bits 13..12: processor type, set to 0 */ \
((family) > 0xf ? 0xf : (family) & 0xf) << 8 | \
((model) & 0xf) << 4 | \
((stepping) & 0xf) << 0)
#define CPUID_EXACT_MATCH_MASK 0xffffffff
#define CPUID_ALL_STEPPINGS_MASK 0xfffffff0