2004-10-14 22:13:01 +02:00
|
|
|
#ifndef CPU_AMD_MTRR_H
|
|
|
|
#define CPU_AMD_MTRR_H
|
|
|
|
|
|
|
|
#define IORR_FIRST 0xC0010016
|
|
|
|
#define IORR_LAST 0xC0010019
|
|
|
|
|
|
|
|
#define MTRR_READ_MEM (1 << 4)
|
|
|
|
#define MTRR_WRITE_MEM (1 << 3)
|
|
|
|
|
|
|
|
#define SYSCFG_MSR 0xC0010010
|
2010-11-13 20:07:59 +01:00
|
|
|
#define SYSCFG_MSR_TOM2WB (1 << 22)
|
2004-10-14 22:13:01 +02:00
|
|
|
#define SYSCFG_MSR_TOM2En (1 << 21)
|
|
|
|
#define SYSCFG_MSR_MtrrVarDramEn (1 << 20)
|
|
|
|
#define SYSCFG_MSR_MtrrFixDramModEn (1 << 19)
|
|
|
|
#define SYSCFG_MSR_MtrrFixDramEn (1 << 18)
|
|
|
|
#define SYSCFG_MSR_UcLockEn (1 << 17)
|
|
|
|
#define SYSCFG_MSR_ChxToDirtyDis (1 << 16)
|
|
|
|
#define SYSCFG_MSR_ClVicBlkEn (1 << 11)
|
|
|
|
#define SYSCFG_MSR_SetDirtyEnO (1 << 10)
|
|
|
|
#define SYSCFG_MSR_SetDirtyEnS (1 << 9)
|
|
|
|
#define SYSCFG_MSR_SetDirtyEnE (1 << 8)
|
|
|
|
#define SYSCFG_MSR_SysVicLimitMask ((1 << 8) - (1 << 5))
|
|
|
|
#define SYSCFG_MSR_SysAckLimitMask ((1 << 5) - (1 << 0))
|
|
|
|
|
2010-10-12 08:13:40 +02:00
|
|
|
#define IORRBase_MSR(reg) (0xC0010016 + 2 * (reg))
|
|
|
|
#define IORRMask_MSR(reg) (0xC0010016 + 2 * (reg) + 1)
|
|
|
|
|
2015-03-05 13:35:04 +01:00
|
|
|
#if defined(__ASSEMBLER__)
|
|
|
|
#define TOP_MEM 0xC001001A
|
|
|
|
#define TOP_MEM2 0xC001001D
|
|
|
|
#else
|
|
|
|
#define TOP_MEM 0xC001001Aul
|
|
|
|
#define TOP_MEM2 0xC001001Dul
|
2011-08-05 00:18:16 +02:00
|
|
|
#endif
|
2004-10-14 22:13:01 +02:00
|
|
|
|
|
|
|
#define TOP_MEM_MASK 0x007fffff
|
|
|
|
#define TOP_MEM_MASK_KB (TOP_MEM_MASK >> 10)
|
|
|
|
|
2011-04-10 06:15:23 +02:00
|
|
|
#if !defined(__PRE_RAM__) && !defined(__ASSEMBLER__)
|
2004-10-14 22:13:01 +02:00
|
|
|
void amd_setup_mtrrs(void);
|
2012-08-05 11:11:40 +02:00
|
|
|
|
2013-03-25 11:48:49 +01:00
|
|
|
static inline __attribute__((always_inline)) msr_t rdmsr_amd(unsigned index)
|
|
|
|
{
|
|
|
|
msr_t result;
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"rdmsr"
|
|
|
|
: "=a" (result.lo), "=d" (result.hi)
|
|
|
|
: "c"(index), "D"(0x9c5a203a)
|
|
|
|
);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline __attribute__((always_inline)) void wrmsr_amd(unsigned index, msr_t msr)
|
|
|
|
{
|
|
|
|
__asm__ __volatile__ (
|
|
|
|
"wrmsr"
|
|
|
|
: /* No outputs */
|
|
|
|
: "c" (index), "a" (msr.lo), "d" (msr.hi), "D" (0x9c5a203a)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-08-05 11:11:40 +02:00
|
|
|
/* To distribute topmem MSRs to APs. */
|
|
|
|
void setup_bsp_ramtop(void);
|
|
|
|
uint64_t bsp_topmem(void);
|
|
|
|
uint64_t bsp_topmem2(void);
|
2010-03-28 23:26:54 +02:00
|
|
|
#endif
|
2004-10-14 22:13:01 +02:00
|
|
|
|
|
|
|
#endif /* CPU_AMD_MTRR_H */
|