coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
mtrr.h
Go to the documentation of this file.
1 #ifndef CPU_AMD_MTRR_H
2 #define CPU_AMD_MTRR_H
3 
4 #define MTRR_IORR0_BASE 0xC0010016
5 #define MTRR_IORR0_MASK 0xC0010017
6 #define MTRR_IORR1_BASE 0xC0010018
7 #define MTRR_IORR1_MASK 0xC0010019
8 
9 #define MTRR_READ_MEM (1 << 4)
10 #define MTRR_WRITE_MEM (1 << 3)
11 
12 #define SYSCFG_MSR 0xC0010010
13 #define SYSCFG_MSR_TOM2WB (1 << 22)
14 #define SYSCFG_MSR_TOM2En (1 << 21)
15 #define SYSCFG_MSR_MtrrVarDramEn (1 << 20)
16 #define SYSCFG_MSR_MtrrFixDramModEn (1 << 19)
17 #define SYSCFG_MSR_MtrrFixDramEn (1 << 18)
18 #define SYSCFG_MSR_UcLockEn (1 << 17)
19 #define SYSCFG_MSR_ChxToDirtyDis (1 << 16)
20 #define SYSCFG_MSR_ClVicBlkEn (1 << 11)
21 #define SYSCFG_MSR_SetDirtyEnO (1 << 10)
22 #define SYSCFG_MSR_SetDirtyEnS (1 << 9)
23 #define SYSCFG_MSR_SetDirtyEnE (1 << 8)
24 #define SYSCFG_MSR_SysVicLimitMask ((1 << 8) - (1 << 5))
25 #define SYSCFG_MSR_SysAckLimitMask ((1 << 5) - (1 << 0))
26 
27 #define IORRBase_MSR(reg) (0xC0010016 + 2 * (reg))
28 #define IORRMask_MSR(reg) (0xC0010016 + 2 * (reg) + 1)
29 
30 #if defined(__ASSEMBLER__)
31 #define TOP_MEM 0xC001001A
32 #define TOP_MEM2 0xC001001D
33 #else
34 #define TOP_MEM 0xC001001Aul
35 #define TOP_MEM2 0xC001001Dul
36 #endif
37 
38 #define TOP_MEM_MASK 0x007fffff
39 #define TOP_MEM_MASK_KB (TOP_MEM_MASK >> 10)
40 
41 #if !defined(__ASSEMBLER__)
42 
43 #include <cpu/x86/msr.h>
44 #include <stdint.h>
45 
46 struct device;
47 void add_uma_resource_below_tolm(struct device *nb, int idx);
48 
49 static __always_inline msr_t rdmsr_amd(unsigned int index)
50 {
51  msr_t result;
52  __asm__ __volatile__ (
53  "rdmsr"
54  : "=a" (result.lo), "=d" (result.hi)
55  : "c"(index), "D"(0x9c5a203a)
56  );
57  return result;
58 }
59 
60 static __always_inline void wrmsr_amd(unsigned int index, msr_t msr)
61 {
62  __asm__ __volatile__ (
63  "wrmsr"
64  : /* No outputs */
65  : "c" (index), "a" (msr.lo), "d" (msr.hi), "D" (0x9c5a203a)
66  );
67 }
68 
69 static inline uint64_t amd_topmem(void)
70 {
71  return rdmsr(TOP_MEM).lo;
72 }
73 
74 static inline uint64_t amd_topmem2(void)
75 {
76  msr_t msr = rdmsr(TOP_MEM2);
77  return (uint64_t)msr.hi << 32 | msr.lo;
78 }
79 #endif
80 
81 #endif /* CPU_AMD_MTRR_H */
static uint64_t amd_topmem2(void)
Definition: mtrr.h:74
#define TOP_MEM
Definition: mtrr.h:34
void add_uma_resource_below_tolm(struct device *nb, int idx)
Definition: amd_mtrr.c:8
static uint64_t amd_topmem(void)
Definition: mtrr.h:69
static __always_inline void wrmsr_amd(unsigned int index, msr_t msr)
Definition: mtrr.h:60
#define TOP_MEM2
Definition: mtrr.h:35
static __always_inline msr_t rdmsr_amd(unsigned int index)
Definition: mtrr.h:49
#define __always_inline
Definition: compiler.h:35
static __always_inline msr_t rdmsr(unsigned int index)
Definition: msr.h:146
result
Definition: mrc_cache.c:35
unsigned long long uint64_t
Definition: stdint.h:17
Definition: device.h:107
unsigned int hi
Definition: msr.h:112
unsigned int lo
Definition: msr.h:111