1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#include <mainboard.h>
27#include <console.h>
28#include <string.h>
29#include <mtrr.h>
30#include <macros.h>
31#include <spd_ddr2.h>
32#include <cpu.h>
33#include <msr.h>
34#include <amd/k8/k8.h>
35#include <amd/k8/sysconf.h>
36#include <device/pci.h>
37#include <pci_ops.h>
38#include <mc146818rtc.h>
39#include <lib.h>
40
41#define BITS(r, shift, mask) (((r>>shift)&mask))
42
43
44
45
46static char *re(u32 i)
47{
48 return ((i & 1) ? "R" : "");
49}
50
51
52
53
54
55static char *we(u32 i)
56{
57 return ((i & 1) ? "W" : "");
58}
59
60
61
62
63static char *ileave(u32 base)
64{
65
66 switch ((base >> 8) & 7) {
67 case 0:
68 return "No interleave";
69 case 1:
70 return "2 nodes";
71 case 3:
72 return "4 nodes";
73 case 7:
74 return "8 nodes";
75 default:
76 return "Reserved";
77 }
78}
79
80
81
82
83
84static int node(u32 reg)
85{
86 return BITS(reg, 0, 0x7);
87}
88
89
90
91
92
93static int link(u32 reg)
94{
95 return BITS(reg, 4, 0x3);
96}
97
98
99
100
101
102
103
104
105
106
107
108
109void showdram(int level, u8 which, u32 base, u32 lim)
110{
111 printk(level, "DRAM(%02x)%010llx-%010llx, ->(%d), %s, %s, %s, %d\n",
112 which, (((u64) base & 0xffff0000) << 8),
113 (((u64) lim & 0xffff0000) << 8) + 0xffffff,
114 node(lim), re(base), we(base), ileave(base), (lim >> 8) & 3);
115}
116
117
118
119
120
121
122
123
124
125
126
127void showconfig(int level, u8 which, u32 reg)
128{
129
130 printk(level, "CONFIG(%02x)%02x-%02x ->(%d,%d),%s %s (%s numbers)\n",
131 which, BITS(reg, 16, 0xff), BITS(reg, 24, 0xff),
132 BITS(reg, 4, 0x7), BITS(reg, 8, 0x3),
133 re(reg), we(reg),
134 BITS(reg, 2, 0x1)?"dev":"bus");
135}
136
137
138
139
140
141
142
143
144
145
146
147
148void showpciio(int level, u8 which, u32 base, u32 lim)
149{
150 printk(level, "PCIIO(%02x)%07x-%07x, ->(%d,%d), %s, %s,VGA %d ISA %d\n",
151 which, BITS(base, 12, 0x3fff) << 12,
152 (BITS(lim, 12, 0x3fff) << 12) + 0xfff, node(lim), link(lim),
153 re(base), we(base), BITS(base, 4, 0x1), BITS(base, 5, 0x1));
154}
155
156
157
158
159
160
161
162
163
164
165
166
167void showmmio(int level, u8 which, u32 base, u32 lim)
168{
169 printk(level, "MMIO(%02x)%010llx-%010llx, ->(%d,%d), %s, %s, "
170 "CPU disable %d, Lock %d, Non posted %d\n",
171 which, ((u64) BITS(base, 0, 0xffffff00)) << 8,
172 (((u64) BITS(lim, 0, 0xffffff00)) << 8) + 0xffff, node(lim),
173 link(lim), re(base), we(base), BITS(base, 4, 0x1),
174 BITS(base, 7, 0x1), BITS(lim, 7, 0x1));
175}
176
177
178
179
180
181
182
183
184void showalldram(int level, u32 dev)
185{
186 u8 reg;
187 for (reg = DRAM_ROUTE_START; reg <= DRAM_ROUTE_END; reg += 8) {
188 u32 base = pci_conf1_read_config32(dev, reg);
189 u32 lim = pci_conf1_read_config32(dev, reg + 4);
190 showdram(level, reg, base, lim);
191 }
192}
193
194
195
196
197
198
199
200
201void showallmmio(int level, u32 dev)
202{
203 u8 reg;
204 for (reg = MMIO_ROUTE_START; reg <= MMIO_ROUTE_END; reg += 8) {
205 u32 base = pci_conf1_read_config32(dev, reg);
206 u32 lim = pci_conf1_read_config32(dev, reg + 4);
207 showmmio(level, reg, base, lim);
208 }
209}
210
211
212
213
214
215
216
217
218void showallpciio(int level, u32 dev)
219{
220 u8 reg;
221 for (reg = PCIIO_ROUTE_START; reg <= PCIIO_ROUTE_END; reg += 8) {
222 u32 base = pci_conf1_read_config32(dev, reg);
223 u32 lim = pci_conf1_read_config32(dev, reg + 4);
224 showpciio(level, reg, base, lim);
225 }
226}
227
228
229
230
231
232
233
234
235void showallconfig(int level, u32 dev)
236{
237 u8 reg;
238 for (reg = CONFIG_ROUTE_START; reg <= CONFIG_ROUTE_END; reg += 4) {
239 u32 val = pci_conf1_read_config32(dev, reg);
240 showconfig(level, reg, val);
241 }
242}
243
244
245
246
247
248
249
250
251void showallroutes(int level, u32 dev)
252{
253 showalldram(level, dev);
254 showallmmio(level, dev);
255 showallpciio(level, dev);
256 showallconfig(level, dev);
257}
258