Felix Held | a24472a | 2021-07-13 18:21:27 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
Felix Held | f1093af | 2021-07-13 23:00:26 +0200 | [diff] [blame] | 3 | #include <amdblocks/mca.h> |
Felix Held | 2eb3ec7 | 2021-07-15 18:54:13 +0200 | [diff] [blame] | 4 | #include <cpu/x86/msr.h> |
Felix Held | e84c3f1 | 2021-07-14 01:16:30 +0200 | [diff] [blame] | 5 | #include <types.h> |
Felix Held | a24472a | 2021-07-13 18:21:27 +0200 | [diff] [blame] | 6 | |
Felix Held | 2eb3ec7 | 2021-07-15 18:54:13 +0200 | [diff] [blame] | 7 | static 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", |
| 19 | [11] = "L3 cache unit", |
| 20 | [12] = "L3 cache unit", |
| 21 | [13] = "L3 cache unit", |
| 22 | [14] = "L3 cache unit", |
| 23 | [15] = "", |
| 24 | [16] = "", |
| 25 | [17] = "UMC", |
| 26 | [18] = "UMC", |
| 27 | [19] = "CS", |
| 28 | [20] = "CS", |
| 29 | [21] = "", |
| 30 | [22] = "", |
| 31 | [23] = "", |
| 32 | [24] = "", |
| 33 | [25] = "", |
| 34 | [26] = "", |
| 35 | [27] = "PIE", |
| 36 | }; |
| 37 | |
Felix Held | e84c3f1 | 2021-07-14 01:16:30 +0200 | [diff] [blame] | 38 | bool mca_has_expected_bank_count(void) |
Felix Held | dc970fc | 2021-07-13 23:38:22 +0200 | [diff] [blame] | 39 | { |
Felix Held | 2eb3ec7 | 2021-07-15 18:54:13 +0200 | [diff] [blame] | 40 | return ARRAY_SIZE(mca_bank_name) == mca_get_bank_count(); |
Felix Held | e84c3f1 | 2021-07-14 01:16:30 +0200 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | bool mca_is_valid_bank(unsigned int bank) |
| 44 | { |
Felix Held | 2eb3ec7 | 2021-07-15 18:54:13 +0200 | [diff] [blame] | 45 | return (bank < ARRAY_SIZE(mca_bank_name) && mca_bank_name[bank] != NULL); |
Felix Held | e84c3f1 | 2021-07-14 01:16:30 +0200 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | const char *mca_get_bank_name(unsigned int bank) |
| 49 | { |
Felix Held | 2eb3ec7 | 2021-07-15 18:54:13 +0200 | [diff] [blame] | 50 | if (mca_is_valid_bank(bank)) |
| 51 | return mca_bank_name[bank]; |
| 52 | else |
| 53 | return ""; |
Felix Held | dc970fc | 2021-07-13 23:38:22 +0200 | [diff] [blame] | 54 | } |