blob: 0f90fd88c669b7b0394e0e5a562233a1a6c7c988 [file] [log] [blame]
Felix Held3c44c622022-01-10 20:57:29 +01001/* SPDX-License-Identifier: GPL-2.0-only */
2
Felix Held3c44c622022-01-10 20:57:29 +01003#include <amdblocks/mca.h>
4#include <cpu/x86/msr.h>
5#include <types.h>
6
7static const char *const mca_bank_name[] = {
8 [0] = "Load-store unit",
9 [1] = "Instruction fetch unit",
10 [2] = "L2 cache unit",
11 [3] = "Decode unit",
12 [4] = "",
13 [5] = "Execution unit",
14 [6] = "Floating point unit",
15 [7] = "L3 cache unit",
16 [8] = "L3 cache unit",
17 [9] = "L3 cache unit",
18 [10] = "L3 cache unit",
Felix Held736d68c2022-02-07 17:22:57 +010019 [11] = "UMC",
20 [12] = "UMC",
21 [13] = "CS",
22 [14] = "CS",
23 [15] = "NBIO",
24 [16] = "PIE",
Felix Held3c44c622022-01-10 20:57:29 +010025};
26
27bool mca_has_expected_bank_count(void)
28{
29 return ARRAY_SIZE(mca_bank_name) == mca_get_bank_count();
30}
31
32bool mca_is_valid_bank(unsigned int bank)
33{
34 return (bank < ARRAY_SIZE(mca_bank_name) && mca_bank_name[bank] != NULL);
35}
36
37const char *mca_get_bank_name(unsigned int bank)
38{
39 if (mca_is_valid_bank(bank))
40 return mca_bank_name[bank];
41 else
42 return "";
43}