mce_amd.h 2.0 KB
Newer Older
1 2 3
#ifndef _EDAC_MCE_AMD_H
#define _EDAC_MCE_AMD_H

B
Borislav Petkov 已提交
4 5
#include <linux/notifier.h>

6 7
#include <asm/mce.h>

B
Borislav Petkov 已提交
8 9
#define BIT_64(n)			(U64_C(1) << (n))

10 11
#define EC(x)				((x) & 0xffff)
#define XEC(x, mask)			(((x) >> 16) & mask)
12

13 14 15 16 17 18 19 20 21 22 23
#define LOW_SYNDROME(x)			(((x) >> 15) & 0xff)
#define HIGH_SYNDROME(x)		(((x) >> 24) & 0xff)

#define TLB_ERROR(x)			(((x) & 0xFFF0) == 0x0010)
#define MEM_ERROR(x)			(((x) & 0xFF00) == 0x0100)
#define BUS_ERROR(x)			(((x) & 0xF800) == 0x0800)

#define TT(x)				(((x) >> 2) & 0x3)
#define TT_MSG(x)			tt_msgs[TT(x)]
#define II(x)				(((x) >> 2) & 0x3)
#define II_MSG(x)			ii_msgs[II(x)]
24
#define LL(x)				((x) & 0x3)
25 26 27 28 29 30
#define LL_MSG(x)			ll_msgs[LL(x)]
#define TO(x)				(((x) >> 8) & 0x1)
#define TO_MSG(x)			to_msgs[TO(x)]
#define PP(x)				(((x) >> 9) & 0x3)
#define PP_MSG(x)			pp_msgs[PP(x)]

31 32
#define R4(x)				(((x) >> 4) & 0xf)
#define R4_MSG(x)			((R4(x) < 9) ?  rrrr_msgs[R4(x)] : "Wrong R4!")
B
Borislav Petkov 已提交
33

B
Borislav Petkov 已提交
34 35 36 37 38
/*
 * F3x4C bits (MCi_STATUS' high half)
 */
#define NBSH_VALID_ERROR_ADDR		BIT(26)
#define NBSH_ERR_CPU_VAL		BIT(24)
39

40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
enum tt_ids {
	TT_INSTR = 0,
	TT_DATA,
	TT_GEN,
	TT_RESV,
};

enum ll_ids {
	LL_RESV = 0,
	LL_L1,
	LL_L2,
	LL_LG,
};

enum ii_ids {
	II_MEM = 0,
	II_RESV,
	II_IO,
	II_GEN,
};

enum rrrr_ids {
	R4_GEN	= 0,
	R4_RD,
	R4_WR,
	R4_DRD,
	R4_DWR,
	R4_IRD,
	R4_PREF,
	R4_EVICT,
	R4_SNOOP,
};

73 74 75 76 77 78
extern const char *tt_msgs[];
extern const char *ll_msgs[];
extern const char *rrrr_msgs[];
extern const char *pp_msgs[];
extern const char *to_msgs[];
extern const char *ii_msgs[];
79 80 81 82 83 84 85 86 87 88 89 90

/*
 * relevant NB regs
 */
struct err_regs {
	u32 nbcfg;
	u32 nbsh;
	u32 nbsl;
	u32 nbeah;
	u32 nbeal;
};

91 92 93 94
/*
 * per-family decoder ops
 */
struct amd_decoder_ops {
95
	bool (*dc_mce)(u16, u8);
96
	bool (*ic_mce)(u16, u8);
97
	bool (*nb_mce)(u16, u8);
98 99
};

100
void amd_report_gart_errors(bool);
101 102 103
void amd_register_ecc_decoder(void (*f)(int, struct mce *, u32));
void amd_unregister_ecc_decoder(void (*f)(int, struct mce *, u32));
void amd_decode_nb_mce(int, struct mce *, u32);
B
Borislav Petkov 已提交
104
int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data);
105 106

#endif /* _EDAC_MCE_AMD_H */