Doxidization, reformat
[coreboot.git] / src / cpu / k8 / earlymtrr.inc
1 #include <cpu/k8/mtrr.h>
2
3
4         /* Save off the BIST value */
5         movl    %eax, %ebp
6
7 /* The fixed and variable MTRRs are powered-up with random values, clear them to
8  * MTRR_TYPE_UNCACHEABLE for safty reason 
9  */
10
11 earlymtrr_start:
12         xorl    %eax, %eax                      # clear %eax and %edx
13         xorl    %edx, %edx                      #
14         movl    $fixed_mtrr_msr, %esi
15
16 enable_fixed_mtrr_dram_modify:
17         /* Enable the access to AMD RdDram and WrDram extension bits */
18         movl    $SYSCFG_MSR, %ecx
19         rdmsr
20         orl     $SYSCFG_MSR_MtrrFixDramModEn, %eax
21         wrmsr
22                 
23 clear_fixed_var_mtrr:
24         lodsl   (%esi), %eax
25         testl   %eax, %eax
26         jz      clear_fixed_var_mtrr_out
27
28         movl    %eax, %ecx
29         xorl    %eax, %eax
30         wrmsr
31
32         jmp     clear_fixed_var_mtrr
33 clear_fixed_var_mtrr_out:
34
35 disable_fixed_mtrr_dram_modify:
36         /* Disable the access to AMD RdDram and WrDram extension bits */
37         movl    $SYSCFG_MSR, %ecx
38         rdmsr
39         andl    $(~SYSCFG_MSR_MtrrFixDramModEn), %eax
40         wrmsr
41
42         /* enable memory access for 0 - 1MB using top_mem */
43         movl    $TOP_MEM, %ecx
44         xorl    %edx, %edx
45         movl    $(((CONFIG_LB_MEM_TOPK << 10) + TOP_MEM_MASK) & ~TOP_MEM_MASK) , %eax
46         wrmsr
47
48 set_var_mtrr:
49         /* enable caching for 0 - 1MB using variable mtrr */
50         movl    $0x200, %ecx
51         rdmsr
52         andl    $0xfffffff0, %edx
53         orl     $0x00000000, %edx
54         andl    $0x00000f00, %eax
55         orl     $(0x00000000 | MTRR_TYPE_WRBACK), %eax
56         wrmsr
57
58         movl    $0x201, %ecx
59         rdmsr
60         andl    $0xfffffff0, %edx
61         orl     $0x0000000f, %edx
62         andl    $0x000007ff, %eax
63         orl     $((~((CONFIG_LB_MEM_TOPK << 10) - 1)) | 0x800), %eax
64         wrmsr
65
66 #if defined(XIP_ROM_SIZE) && defined(XIP_ROM_BASE)
67         /* enable write base caching so we can do execute in place
68          * on the flash rom.
69          */
70         movl    $0x202, %ecx
71         xorl    %edx, %edx
72         movl    $(XIP_ROM_BASE | MTRR_TYPE_WRBACK), %eax
73         wrmsr   
74
75         movl    $0x203, %ecx
76         movl    $0x0000000f, %edx
77         movl    $(~(XIP_ROM_SIZE - 1) | 0x800), %eax
78         wrmsr
79 #endif /* XIP_ROM_SIZE && XIP_ROM_BASE */
80
81 enable_mtrr:    
82         /* Set the default memory type and enable fixed and variable MTRRs */
83         movl    $MTRRdefType_MSR, %ecx
84         xorl    %edx, %edx
85         /* Enable Variable MTRRs */
86         movl    $0x00000800, %eax
87         wrmsr
88
89         /* Enable the MTRRs and IORRs in SYSCFG */
90         movl    $SYSCFG_MSR, %ecx
91         rdmsr
92         /* Don't enable SYSCFG_MSR_MtrrFixDramEn) untill we have done with VGA BIOS */
93         orl     $(SYSCFG_MSR_MtrrVarDramEn), %eax
94         wrmsr
95
96         /* enable cache */
97         movl    %cr0, %eax
98         andl    $0x9fffffff,%eax
99         movl    %eax, %cr0
100
101         jmp     earlymtrr_end
102
103 fixed_mtrr_msr: 
104         .long   0x250, 0x258, 0x259
105         .long   0x268, 0x269, 0x26A
106         .long   0x26B, 0x26C, 0x26D
107         .long   0x26E, 0x26F
108 var_mtrr_msr:
109         .long   0x200, 0x201, 0x202, 0x203
110         .long   0x204, 0x205, 0x206, 0x207
111         .long   0x208, 0x209, 0x20A, 0x20B
112         .long   0x20C, 0x20D, 0x20E, 0x20F
113 var_iorr_msr:
114         .long   0xC0010016, 0xC0010017, 0xC0010018, 0xC0010019
115 mem_top:
116         .long   0xC001001A, 0xC001001D
117         .long   0x000 /* NULL, end of table */
118 earlymtrr_end:
119         /* Restore the BIST value */
120         movl    %ebp, %eax