include/cpu/x86/msr: add mca_clear_status function

In multiple locations within the coreboot tree all available
IA32_MC_STATUS registers are cleared, so add this to the common code to
avoid duplication of code.

Change-Id: I04af23c16021b0ce90f7105f7a3856bd26ffa736
Signed-off-by: Felix Held <felix-coreboot@felixheld.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/56258
Reviewed-by: Raul Rangel <rrangel@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Felix Held 2021-07-13 03:18:41 +02:00
parent bb0ecd49f2
commit bf1f1df41b
1 changed files with 10 additions and 0 deletions

View File

@ -166,6 +166,16 @@ static inline unsigned int mca_get_bank_count(void)
return msr.lo & MCA_BANKS_MASK; return msr.lo & MCA_BANKS_MASK;
} }
/* Clear all MCA status registers */
static inline void mca_clear_status(void)
{
const unsigned int num_banks = mca_get_bank_count();
const msr_t msr = {.lo = 0, .hi = 0};
for (unsigned int i = 0 ; i < num_banks ; i++)
wrmsr(IA32_MC_STATUS(i), msr);
}
/* Helpers for interpreting MC[i]_STATUS */ /* Helpers for interpreting MC[i]_STATUS */
static inline int mca_valid(msr_t msr) static inline int mca_valid(msr_t msr)