blob: 7ca16a8d432bc7b9e8991f85c994962a9c60fa50 [file] [log] [blame]
Angel Ponsae593872020-04-04 18:50:57 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Marshall Dawson0b4a1e22018-09-04 13:11:42 -06002
Felix Heldf1093af2021-07-13 23:00:26 +02003#include <amdblocks/mca.h>
Felix Heldd1d64792021-07-14 18:00:32 +02004#include <cpu/x86/msr.h>
Felix Helde4a6edf2021-07-13 21:12:46 +02005#include <types.h>
Marshall Dawson0b4a1e22018-09-04 13:11:42 -06006
7static const char *const mca_bank_name[] = {
Felix Helda0112c12021-07-13 20:37:06 +02008 [0] = "Load-store unit",
9 [1] = "Instruction fetch unit",
10 [2] = "Combined unit",
Felix Held65deb242021-07-13 22:35:39 +020011 /* 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,
Felix Helda0112c12021-07-13 20:37:06 +020014 [4] = "Northbridge",
15 [5] = "Execution unit",
16 [6] = "Floating point unit"
Marshall Dawson0b4a1e22018-09-04 13:11:42 -060017};
18
Felix Heldd1d64792021-07-14 18:00:32 +020019bool mca_has_expected_bank_count(void)
20{
21 return ARRAY_SIZE(mca_bank_name) == mca_get_bank_count();
22}
23
Felix Helde84c3f12021-07-14 01:16:30 +020024bool mca_is_valid_bank(unsigned int bank)
Felix Held65deb242021-07-13 22:35:39 +020025{
26 return (bank < ARRAY_SIZE(mca_bank_name) && mca_bank_name[bank] != NULL);
27}
28
Felix Helde84c3f12021-07-14 01:16:30 +020029const char *mca_get_bank_name(unsigned int bank)
Felix Held65deb242021-07-13 22:35:39 +020030{
31 if (mca_is_valid_bank(bank))
32 return mca_bank_name[bank];
33 else
34 return "";
35}