1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 3 #include <amdblocks/mca.h> 4 #include <cpu/x86/msr.h> 5 #include <types.h> 6 7 static const char *const mca_bank_name[] = { 8 [0] = "Load-store unit", 9 [1] = "Instruction fetch unit", 10 [2] = "Combined unit", 11 /* Bank 3 is reserved and not all corresponding MSRs are implemented in Family 15h. 12 Accessing non-existing MSRs causes a general protection fault. */ 13 [3] = NULL, 14 [4] = "Northbridge", 15 [5] = "Execution unit", 16 [6] = "Floating point unit" 17 }; 18 mca_has_expected_bank_count(void)19bool mca_has_expected_bank_count(void) 20 { 21 return ARRAY_SIZE(mca_bank_name) == mca_get_bank_count(); 22 } 23 mca_is_valid_bank(unsigned int bank)24bool mca_is_valid_bank(unsigned int bank) 25 { 26 return (bank < ARRAY_SIZE(mca_bank_name) && mca_bank_name[bank] != NULL); 27 } 28 mca_get_bank_name(unsigned int bank)29const char *mca_get_bank_name(unsigned int bank) 30 { 31 if (mca_is_valid_bank(bank)) 32 return mca_bank_name[bank]; 33 else 34 return ""; 35 } 36