blob: ccbb3607693425ea49461524751c37fa7fffb512 [file] [log] [blame]
Martin Roth1a3de8e2022-10-06 15:57:21 -06001/* SPDX-License-Identifier: GPL-2.0-only */
2
Martin Roth1a3de8e2022-10-06 15:57:21 -06003#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",
Fred Reitbergerc6d7fca2022-10-21 14:33:12 -040019 [11] = "L3 cache unit",
20 [12] = "L3 cache unit",
21 [13] = "L3 cache unit",
22 [14] = "L3 cache unit",
23 [15] = "UMC",
24 [16] = "UMC",
25 [17] = "UMC",
26 [18] = "UMC",
27 [19] = "CS",
28 [20] = "CS",
29 [21] = "CS",
30 [22] = "CS",
31 [23] = "",
32 [24] = "",
33 [25] = "NBIO",
34 [26] = "",
35 [27] = "",
36 [28] = "PIE",
37 [29] = "",
38 [30] = "",
39 [31] = "",
Martin Roth1a3de8e2022-10-06 15:57:21 -060040};
41
42bool mca_has_expected_bank_count(void)
43{
44 return ARRAY_SIZE(mca_bank_name) == mca_get_bank_count();
45}
46
47bool mca_is_valid_bank(unsigned int bank)
48{
49 return (bank < ARRAY_SIZE(mca_bank_name) && mca_bank_name[bank] != NULL);
50}
51
52const char *mca_get_bank_name(unsigned int bank)
53{
54 if (mca_is_valid_bank(bank))
55 return mca_bank_name[bank];
56 else
57 return "";
58}