diff options
author | Patrick Rudolph <patrick.rudolph@9elements.com> | 2023-10-03 18:03:51 +0200 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2023-10-06 12:15:34 +0000 |
commit | 6a13b520e9ae8dbb85a2522f78b931285b0e8f95 (patch) | |
tree | 7dfaf89f47fb70dc8783717fd776af56a327caf7 /src | |
parent | 6a249d688ec4922e01e1143863a70a57bd0e51fd (diff) |
arch/x86/cpu_common: Add cpu_get_c_substate_support
Add a function to get the number of substates supported by
an Intel CPU C-state.
Test: Can read out the supported C-state substates.
Change-Id: Ie57e87609ea5d6ec6f37154e8b84f1e9574aa4a9
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/78224
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/arch/x86/cpu_common.c | 16 | ||||
-rw-r--r-- | src/arch/x86/include/arch/cpu.h | 13 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/arch/x86/cpu_common.c b/src/arch/x86/cpu_common.c index 9387f3bc76..0242dcebdd 100644 --- a/src/arch/x86/cpu_common.c +++ b/src/arch/x86/cpu_common.c @@ -187,6 +187,22 @@ size_t get_cache_size(const struct cpu_cache_info *info) return info->num_ways * info->physical_partitions * info->line_size * info->num_sets; } +/* + * Returns the sub-states supported by the specified CPU + * C-state level. + * + * Level 0 corresponds to the lowest C-state (C0). + * Higher levels are processor specific. + */ +uint8_t cpu_get_c_substate_support(const int state) +{ + if ((cpuid_get_max_func() < 5) || + !(cpuid_ecx(5) & CPUID_FEATURE_MONITOR_MWAIT) || (state > 4)) + return 0; + + return (cpuid_edx(5) >> (state * 4)) & 0xf; +} + bool fill_cpu_cache_info(uint8_t level, struct cpu_cache_info *info) { if (!info) diff --git a/src/arch/x86/include/arch/cpu.h b/src/arch/x86/include/arch/cpu.h index 2c98d1e98f..0c4decfc1b 100644 --- a/src/arch/x86/include/arch/cpu.h +++ b/src/arch/x86/include/arch/cpu.h @@ -99,6 +99,10 @@ static inline unsigned int cpuid_get_max_func(void) #define CPUID_CACHE_NO_OF_SETS_MASK 0xffffffff #define CPUID_CACHE_NO_OF_SETS(res) CPUID_CACHE(NO_OF_SETS, (res).ecx) +// Intel leaf 0x5 +#define CPUID_FEATURE_MONITOR_MWAIT (1 << 0) +#define CPUID_FEATURE_INTERUPT_BREAK_EVENT (1 << 1) + unsigned int cpu_cpuid_extended_level(void); int cpu_have_cpuid(void); @@ -311,6 +315,15 @@ size_t cpu_get_max_cache_share(const struct cpu_cache_info *info); size_t get_cache_size(const struct cpu_cache_info *info); /* + * Returns the sub-states supported by the specified CPU + * C-state level. + * + * Level 0 corresponds to the lowest C-state (C0). + * Higher levels are processor specific. + */ +uint8_t cpu_get_c_substate_support(const int state); + +/* * fill_cpu_cache_info to get all required cache info data and fill into cpu_cache_info * structure by calling CPUID.EAX=leaf and ECX=Cache Level. */ |