blob: 795a3206acf5f83759f6c9d35e7938fc84e96aed [file] [log] [blame]
Borislav Petkov549d0422009-07-24 13:51:42 +02001#ifndef _EDAC_MCE_AMD_H
2#define _EDAC_MCE_AMD_H
3
Borislav Petkov9cdeb402010-09-02 18:33:24 +02004#include <linux/notifier.h>
5
Borislav Petkov549d0422009-07-24 13:51:42 +02006#include <asm/mce.h>
7
Borislav Petkovcf1d2202010-10-15 15:20:18 +02008#define BIT_64(n) (U64_C(1) << (n))
9
Borislav Petkov62452882010-09-22 16:08:37 +020010#define EC(x) ((x) & 0xffff)
11#define XEC(x, mask) (((x) >> 16) & mask)
Borislav Petkov5110dbd2009-06-25 19:51:04 +020012
Borislav Petkovb70ef012009-06-25 19:32:38 +020013#define LOW_SYNDROME(x) (((x) >> 15) & 0xff)
14#define HIGH_SYNDROME(x) (((x) >> 24) & 0xff)
15
16#define TLB_ERROR(x) (((x) & 0xFFF0) == 0x0010)
17#define MEM_ERROR(x) (((x) & 0xFF00) == 0x0100)
18#define BUS_ERROR(x) (((x) & 0xF800) == 0x0800)
19
20#define TT(x) (((x) >> 2) & 0x3)
21#define TT_MSG(x) tt_msgs[TT(x)]
22#define II(x) (((x) >> 2) & 0x3)
23#define II_MSG(x) ii_msgs[II(x)]
Borislav Petkov62452882010-09-22 16:08:37 +020024#define LL(x) ((x) & 0x3)
Borislav Petkovb70ef012009-06-25 19:32:38 +020025#define LL_MSG(x) ll_msgs[LL(x)]
Borislav Petkovb70ef012009-06-25 19:32:38 +020026#define TO(x) (((x) >> 8) & 0x1)
27#define TO_MSG(x) to_msgs[TO(x)]
28#define PP(x) (((x) >> 9) & 0x3)
29#define PP_MSG(x) pp_msgs[PP(x)]
30
Borislav Petkov62452882010-09-22 16:08:37 +020031#define R4(x) (((x) >> 4) & 0xf)
32#define R4_MSG(x) ((R4(x) < 9) ? rrrr_msgs[R4(x)] : "Wrong R4!")
Borislav Petkov63375832010-09-06 18:13:39 +020033
Borislav Petkovbcd781f2011-01-07 16:17:46 +010034/*
35 * F3x4C bits (MCi_STATUS' high half)
36 */
Borislav Petkovbcd781f2011-01-07 16:17:46 +010037#define NBSH_ERR_CPU_VAL BIT(24)
Borislav Petkov549d0422009-07-24 13:51:42 +020038
Borislav Petkov888ab8e2010-08-18 15:11:35 +020039enum tt_ids {
40 TT_INSTR = 0,
41 TT_DATA,
42 TT_GEN,
43 TT_RESV,
44};
45
46enum ll_ids {
47 LL_RESV = 0,
48 LL_L1,
49 LL_L2,
50 LL_LG,
51};
52
53enum ii_ids {
54 II_MEM = 0,
55 II_RESV,
56 II_IO,
57 II_GEN,
58};
59
60enum rrrr_ids {
61 R4_GEN = 0,
62 R4_RD,
63 R4_WR,
64 R4_DRD,
65 R4_DWR,
66 R4_IRD,
67 R4_PREF,
68 R4_EVICT,
69 R4_SNOOP,
70};
71
Borislav Petkovb70ef012009-06-25 19:32:38 +020072extern const char *tt_msgs[];
73extern const char *ll_msgs[];
74extern const char *rrrr_msgs[];
75extern const char *pp_msgs[];
76extern const char *to_msgs[];
77extern const char *ii_msgs[];
Borislav Petkov549d0422009-07-24 13:51:42 +020078
79/*
Borislav Petkov888ab8e2010-08-18 15:11:35 +020080 * per-family decoder ops
81 */
82struct amd_decoder_ops {
Borislav Petkov25a4f8b2010-09-17 19:22:34 +020083 bool (*dc_mce)(u16, u8);
Borislav Petkov86039cd2010-11-08 15:03:35 +010084 bool (*ic_mce)(u16, u8);
Borislav Petkov5ce88f62010-08-31 18:28:08 +020085 bool (*nb_mce)(u16, u8);
Borislav Petkov888ab8e2010-08-18 15:11:35 +020086};
87
Borislav Petkov549d0422009-07-24 13:51:42 +020088void amd_report_gart_errors(bool);
Borislav Petkov7cfd4a82010-09-01 14:45:20 +020089void amd_register_ecc_decoder(void (*f)(int, struct mce *, u32));
90void amd_unregister_ecc_decoder(void (*f)(int, struct mce *, u32));
91void amd_decode_nb_mce(int, struct mce *, u32);
Borislav Petkov9cdeb402010-09-02 18:33:24 +020092int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data);
Borislav Petkov549d0422009-07-24 13:51:42 +020093
94#endif /* _EDAC_MCE_AMD_H */