blob: 8c87a5e870577c06b0082ca7d3b19eb7a81a252b [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 Petkov62452882010-09-22 16:08:37 +02008#define EC(x) ((x) & 0xffff)
9#define XEC(x, mask) (((x) >> 16) & mask)
Borislav Petkov5110dbd2009-06-25 19:51:04 +020010
Borislav Petkovb70ef012009-06-25 19:32:38 +020011#define LOW_SYNDROME(x) (((x) >> 15) & 0xff)
12#define HIGH_SYNDROME(x) (((x) >> 24) & 0xff)
13
14#define TLB_ERROR(x) (((x) & 0xFFF0) == 0x0010)
15#define MEM_ERROR(x) (((x) & 0xFF00) == 0x0100)
16#define BUS_ERROR(x) (((x) & 0xF800) == 0x0800)
17
18#define TT(x) (((x) >> 2) & 0x3)
19#define TT_MSG(x) tt_msgs[TT(x)]
20#define II(x) (((x) >> 2) & 0x3)
21#define II_MSG(x) ii_msgs[II(x)]
Borislav Petkov62452882010-09-22 16:08:37 +020022#define LL(x) ((x) & 0x3)
Borislav Petkovb70ef012009-06-25 19:32:38 +020023#define LL_MSG(x) ll_msgs[LL(x)]
Borislav Petkovb70ef012009-06-25 19:32:38 +020024#define TO(x) (((x) >> 8) & 0x1)
25#define TO_MSG(x) to_msgs[TO(x)]
26#define PP(x) (((x) >> 9) & 0x3)
27#define PP_MSG(x) pp_msgs[PP(x)]
28
Borislav Petkov62452882010-09-22 16:08:37 +020029#define R4(x) (((x) >> 4) & 0xf)
30#define R4_MSG(x) ((R4(x) < 9) ? rrrr_msgs[R4(x)] : "Wrong R4!")
Borislav Petkov63375832010-09-06 18:13:39 +020031
Borislav Petkovbcd781f2011-01-07 16:17:46 +010032/*
33 * F3x4C bits (MCi_STATUS' high half)
34 */
Borislav Petkovbcd781f2011-01-07 16:17:46 +010035#define NBSH_ERR_CPU_VAL BIT(24)
Borislav Petkov549d0422009-07-24 13:51:42 +020036
Borislav Petkov888ab8e2010-08-18 15:11:35 +020037enum tt_ids {
38 TT_INSTR = 0,
39 TT_DATA,
40 TT_GEN,
41 TT_RESV,
42};
43
44enum ll_ids {
45 LL_RESV = 0,
46 LL_L1,
47 LL_L2,
48 LL_LG,
49};
50
51enum ii_ids {
52 II_MEM = 0,
53 II_RESV,
54 II_IO,
55 II_GEN,
56};
57
58enum rrrr_ids {
59 R4_GEN = 0,
60 R4_RD,
61 R4_WR,
62 R4_DRD,
63 R4_DWR,
64 R4_IRD,
65 R4_PREF,
66 R4_EVICT,
67 R4_SNOOP,
68};
69
Borislav Petkovebe2aea2011-11-29 19:03:25 +010070extern const char * const tt_msgs[];
71extern const char * const ll_msgs[];
72extern const char * const rrrr_msgs[];
73extern const char * const pp_msgs[];
74extern const char * const to_msgs[];
75extern const char * const ii_msgs[];
Borislav Petkov549d0422009-07-24 13:51:42 +020076
77/*
Borislav Petkov888ab8e2010-08-18 15:11:35 +020078 * per-family decoder ops
79 */
80struct amd_decoder_ops {
Borislav Petkov25a4f8b2010-09-17 19:22:34 +020081 bool (*dc_mce)(u16, u8);
Borislav Petkov86039cd2010-11-08 15:03:35 +010082 bool (*ic_mce)(u16, u8);
Borislav Petkov888ab8e2010-08-18 15:11:35 +020083};
84
Borislav Petkov549d0422009-07-24 13:51:42 +020085void amd_report_gart_errors(bool);
Borislav Petkovb0b07a22011-08-24 18:44:22 +020086void amd_register_ecc_decoder(void (*f)(int, struct mce *));
87void amd_unregister_ecc_decoder(void (*f)(int, struct mce *));
88void amd_decode_nb_mce(struct mce *);
Borislav Petkov9cdeb402010-09-02 18:33:24 +020089int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data);
Borislav Petkov549d0422009-07-24 13:51:42 +020090
91#endif /* _EDAC_MCE_AMD_H */