Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 1 | #ifndef _EDAC_MCE_AMD_H |
| 2 | #define _EDAC_MCE_AMD_H |
| 3 | |
Borislav Petkov | 9cdeb40 | 2010-09-02 18:33:24 +0200 | [diff] [blame] | 4 | #include <linux/notifier.h> |
| 5 | |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 6 | #include <asm/mce.h> |
| 7 | |
Borislav Petkov | 6245288 | 2010-09-22 16:08:37 +0200 | [diff] [blame] | 8 | #define EC(x) ((x) & 0xffff) |
| 9 | #define XEC(x, mask) (((x) >> 16) & mask) |
Borislav Petkov | 5110dbd | 2009-06-25 19:51:04 +0200 | [diff] [blame] | 10 | |
Borislav Petkov | b70ef01 | 2009-06-25 19:32:38 +0200 | [diff] [blame] | 11 | #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) |
Jacob Shin | 980eec8 | 2012-12-18 15:06:11 -0600 | [diff] [blame] | 17 | #define INT_ERROR(x) (((x) & 0xF4FF) == 0x0400) |
Borislav Petkov | b70ef01 | 2009-06-25 19:32:38 +0200 | [diff] [blame] | 18 | |
| 19 | #define TT(x) (((x) >> 2) & 0x3) |
| 20 | #define TT_MSG(x) tt_msgs[TT(x)] |
| 21 | #define II(x) (((x) >> 2) & 0x3) |
| 22 | #define II_MSG(x) ii_msgs[II(x)] |
Borislav Petkov | 6245288 | 2010-09-22 16:08:37 +0200 | [diff] [blame] | 23 | #define LL(x) ((x) & 0x3) |
Borislav Petkov | b70ef01 | 2009-06-25 19:32:38 +0200 | [diff] [blame] | 24 | #define LL_MSG(x) ll_msgs[LL(x)] |
Borislav Petkov | b70ef01 | 2009-06-25 19:32:38 +0200 | [diff] [blame] | 25 | #define TO(x) (((x) >> 8) & 0x1) |
| 26 | #define TO_MSG(x) to_msgs[TO(x)] |
| 27 | #define PP(x) (((x) >> 9) & 0x3) |
| 28 | #define PP_MSG(x) pp_msgs[PP(x)] |
Jacob Shin | 980eec8 | 2012-12-18 15:06:11 -0600 | [diff] [blame] | 29 | #define UU(x) (((x) >> 8) & 0x3) |
| 30 | #define UU_MSG(x) uu_msgs[UU(x)] |
Borislav Petkov | b70ef01 | 2009-06-25 19:32:38 +0200 | [diff] [blame] | 31 | |
Borislav Petkov | 6245288 | 2010-09-22 16:08:37 +0200 | [diff] [blame] | 32 | #define R4(x) (((x) >> 4) & 0xf) |
| 33 | #define R4_MSG(x) ((R4(x) < 9) ? rrrr_msgs[R4(x)] : "Wrong R4!") |
Borislav Petkov | 6337583 | 2010-09-06 18:13:39 +0200 | [diff] [blame] | 34 | |
Borislav Petkov | 0f08669 | 2012-12-23 12:40:45 +0100 | [diff] [blame] | 35 | extern const char * const pp_msgs[]; |
| 36 | |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame] | 37 | enum tt_ids { |
| 38 | TT_INSTR = 0, |
| 39 | TT_DATA, |
| 40 | TT_GEN, |
| 41 | TT_RESV, |
| 42 | }; |
| 43 | |
| 44 | enum ll_ids { |
| 45 | LL_RESV = 0, |
| 46 | LL_L1, |
| 47 | LL_L2, |
| 48 | LL_LG, |
| 49 | }; |
| 50 | |
| 51 | enum ii_ids { |
| 52 | II_MEM = 0, |
| 53 | II_RESV, |
| 54 | II_IO, |
| 55 | II_GEN, |
| 56 | }; |
| 57 | |
| 58 | enum 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 Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 70 | /* |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame] | 71 | * per-family decoder ops |
| 72 | */ |
| 73 | struct amd_decoder_ops { |
Borislav Petkov | f05c41a | 2012-09-11 18:57:43 +0200 | [diff] [blame] | 74 | bool (*mc0_mce)(u16, u8); |
| 75 | bool (*mc1_mce)(u16, u8); |
Jacob Shin | 4a73d3d | 2012-12-18 15:06:10 -0600 | [diff] [blame] | 76 | bool (*mc2_mce)(u16, u8); |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame] | 77 | }; |
| 78 | |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 79 | void amd_report_gart_errors(bool); |
Borislav Petkov | b0b07a2 | 2011-08-24 18:44:22 +0200 | [diff] [blame] | 80 | void amd_register_ecc_decoder(void (*f)(int, struct mce *)); |
| 81 | void amd_unregister_ecc_decoder(void (*f)(int, struct mce *)); |
Borislav Petkov | 9cdeb40 | 2010-09-02 18:33:24 +0200 | [diff] [blame] | 82 | int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data); |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 83 | |
| 84 | #endif /* _EDAC_MCE_AMD_H */ |