From 3f1b70640a409458053775f8d56602dda1312f50 Mon Sep 17 00:00:00 2001 From: Felix Held Date: Fri, 9 Jul 2021 22:59:01 +0200 Subject: [PATCH] include/cpu/x86/msr: add mca_get_bank_count function In multiple locations within the coreboot tree the IA32_MCG_CAP MSR gets read and masked with MCA_BANKS_MASK to get the number of available MCA banks on the CPU, so add this to the common code to avoid duplication of code. Change-Id: Id118a900edbe1f67aabcd109d2654c167b6345ea Signed-off-by: Felix Held Reviewed-on: https://review.coreboot.org/c/coreboot/+/56183 Tested-by: build bot (Jenkins) Reviewed-by: Werner Zeh --- src/include/cpu/x86/msr.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/include/cpu/x86/msr.h b/src/include/cpu/x86/msr.h index bc367d72ec..ac48ca2de6 100644 --- a/src/include/cpu/x86/msr.h +++ b/src/include/cpu/x86/msr.h @@ -155,6 +155,13 @@ static __always_inline void wrmsr(unsigned int index, msr_t msr) #endif /* CONFIG_SOC_SETS_MSRS */ +/* Get MCA bank count from MSR */ +static inline unsigned int mca_get_bank_count(void) +{ + msr_t msr = rdmsr(IA32_MCG_CAP); + return msr.lo & MCA_BANKS_MASK; +} + /* Helpers for interpreting MC[i]_STATUS */ static inline int mca_valid(msr_t msr)