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>
This commit is contained in:
Patrick Rudolph
2023-10-03 18:03:51 +02:00
committed by Felix Held
parent 6a249d688e
commit 6a13b520e9
2 changed files with 29 additions and 0 deletions

View File

@@ -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)