blob: e454f44b16528a8bfe42c71e0e9535a8b2e8ebcb [file] [log] [blame]
Stefan Reinauer23190272008-08-20 13:41:24 +00001/*
2 * inteltool - dump all registers on an Intel CPU + chipset based system.
3 *
Stefan Reinauer14e22772010-04-27 06:56:47 +00004 * Copyright (C) 2008-2010 by coresystems GmbH
Anton Kochkovc7fc4422012-07-21 06:36:47 +04005 * Copyright (C) 2012 Anton Kochkov
Stefan Reinauer14e22772010-04-27 06:56:47 +00006 *
Stefan Reinauer23190272008-08-20 13:41:24 +00007 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21#include <stdio.h>
22#include <stdlib.h>
Stefan Reinauera7b296d2011-11-14 12:40:34 -080023#include <inttypes.h>
Stefan Reinauer23190272008-08-20 13:41:24 +000024#include "inteltool.h"
25
Anton Kochkovc7fc4422012-07-21 06:36:47 +040026static const io_register_t sandybridge_dmi_registers[] = {
27 { 0x00, 4, "DMI VCECH" }, // DMI Virtual Channel Enhanced Capability
28 { 0x04, 4, "DMI PVCCAP1" }, // DMI Port VC Capability Register 1
29 { 0x08, 4, "DMI PVVAP2" }, // DMI Port VC Capability Register 2
30 { 0x0C, 2, "DMI PVCCTL" }, // DMI Port VC Control
31/* { 0x0E, 2, "RSVD" }, // Reserved */
32 { 0x10, 4, "DMI VC0RCAP" }, // DMI VC0 Resource Capability
33 { 0x14, 4, "DMI VC0RCTL" }, // DMI VC0 Resource Control
34/* { 0x18, 2, "RSVD" }, // Reserved */
35 { 0x1A, 2, "DMI VC0RSTS" }, // DMI VC0 Resource Status
36 { 0x1C, 4, "DMI VC1RCAP" }, // DMI VC1 Resource Capability
37 { 0x20, 4, "DMI VC1RCTL" }, // DMI VC1 Resource Control
38/* { 0x24, 2, "RSVD" }, // Reserved */
39 { 0x26, 2, "DMI VC1RSTS" }, // DMI VC1 Resource Status
40 { 0x28, 4, "DMI VCPRCAP" }, // DMI VCp Resource Capability
41 { 0x2C, 4, "DMI VCPRCTL" }, // DMI VCp Resource Control
42/* { 0x30, 2, "RSVD" }, // Reserved */
43 { 0x32, 2, "DMI VCPRSTS" }, // DMI VCp Resource Status
44 { 0x34, 4, "DMI VCMRCAP" }, // DMI VCm Resource Capability
45 { 0x38, 4, "DMI VCMRCTL" }, // DMI VCm Resource Control
46/* { 0x3C, 2, "RSVD" }, // Reserved */
47 { 0x3E, 2, "DMI VCMRSTS" }, // DMI VCm Resource Status
48/* { 0x40, 4, "RSVD" }, // Reserved */
49 { 0x44, 4, "DMI ESC" }, // DMI Element Self Description
50/* { 0x48, 8, "RSVD" }, // Reserved */
51 { 0x50, 4, "DMI LE1D" }, // DMI Link Entry 1 Description
52/* { 0x54, 4, "RSVD" }, // Reserved */
53 { 0x58, 4, "DMI LE1A" }, // DMI Link Entry 1 Address
54 { 0x5C, 4, "DMI LUE1A" }, // DMI Link Upper Entry 1 Address
55 { 0x60, 4, "DMI LE2D" }, // DMI Link Entry 2 Description
56/* { 0x64, 4, "RSVD" }, // Reserved */
57 { 0x68, 4, "DMI LE2A" }, // DMI Link Entry 2 Address
58/* { 0x6C, 4, "RSVD" }, // Reserved
59 { 0x70, 8, "RSVD" }, // Reserved
60 { 0x78, 8, "RSVD" }, // Reserved
61 { 0x80, 4, "RSVD" }, // Reserved */
62 { 0x84, 4, "LCAP" }, // Link Capabilities
63 { 0x88, 2, "LCTL" }, // Link Control
64 { 0x8A, 2, "LSTS" }, // Link Status
65/* { 0x8C, 4, "RSVD" }, // Reserved
66 { 0x90, 4, "RSVD" }, // Reserved
67 { 0x94, 4, "RSVD" }, // Reserved */
68 { 0x98, 2, "LCTL2" }, // Link Control 2
69 { 0x9A, 2, "LSTS2" }, // Link Status 2
70/* ... - Reserved */
71 { 0xBC0, 4, "AFE_BMUF0" }, // AFE BMU Configuration Function 0
72 { 0xBC4, 4, "RSVD" }, // Reserved
73 { 0xBC8, 4, "RSVD" }, // Reserved
74 { 0xBCC, 4, "AFE_BMUT0" }, // AFE BMU Configuration Test 0
75/* ... - Reserved */
76};
77
Stefan Reinauer23190272008-08-20 13:41:24 +000078/*
79 * Egress Port Root Complex MMIO configuration space
80 */
81int print_epbar(struct pci_dev *nb)
82{
83 int i, size = (4 * 1024);
84 volatile uint8_t *epbar;
Stefan Reinauer1162f252008-12-04 15:18:20 +000085 uint64_t epbar_phys;
Stefan Reinauer23190272008-08-20 13:41:24 +000086
87 printf("\n============= EPBAR =============\n\n");
88
89 switch (nb->device_id) {
Pat Erleyca3548e2010-04-21 06:23:19 +000090 case PCI_DEVICE_ID_INTEL_82915:
Stefan Reinauer23190272008-08-20 13:41:24 +000091 case PCI_DEVICE_ID_INTEL_82945GM:
Björn Busse2d33dc42010-08-01 15:33:30 +000092 case PCI_DEVICE_ID_INTEL_82945GSE:
Stefan Reinauer3d9a12f2008-11-02 11:11:40 +000093 case PCI_DEVICE_ID_INTEL_82945P:
Stefan Reinauer1162f252008-12-04 15:18:20 +000094 case PCI_DEVICE_ID_INTEL_82975X:
Stefan Reinauer23190272008-08-20 13:41:24 +000095 epbar_phys = pci_read_long(nb, 0x40) & 0xfffffffe;
96 break;
Stefan Tauner04c06002012-10-13 02:19:30 +020097 case PCI_DEVICE_ID_INTEL_82965PM:
98 case PCI_DEVICE_ID_INTEL_82Q965:
99 case PCI_DEVICE_ID_INTEL_82Q35:
100 case PCI_DEVICE_ID_INTEL_82G33:
101 case PCI_DEVICE_ID_INTEL_82Q33:
102 case PCI_DEVICE_ID_INTEL_82X38:
Ruud Schrampbb41f502011-04-04 07:53:19 +0200103 case PCI_DEVICE_ID_INTEL_32X0:
Stefan Tauner04c06002012-10-13 02:19:30 +0200104 case PCI_DEVICE_ID_INTEL_82X4X:
Corey Osgood23d98c72010-07-29 19:25:31 +0000105 case PCI_DEVICE_ID_INTEL_ATOM_DXXX:
106 case PCI_DEVICE_ID_INTEL_ATOM_NXXX:
Stefan Tauner04c06002012-10-13 02:19:30 +0200107 epbar_phys = pci_read_long(nb, 0x40) & 0xfffffffe;
108 epbar_phys |= ((uint64_t)pci_read_long(nb, 0x44)) << 32;
109 break;
Stefan Reinauerb2aedb12009-08-29 15:45:43 +0000110 case PCI_DEVICE_ID_INTEL_82810:
Stefan Tauner04c06002012-10-13 02:19:30 +0200111 case PCI_DEVICE_ID_INTEL_82810_DC:
112 case PCI_DEVICE_ID_INTEL_82810E_DC:
Stefan Reinauer04844812010-02-22 11:26:06 +0000113 case PCI_DEVICE_ID_INTEL_82830M:
Idwer Vollering312fc962010-12-17 22:34:58 +0000114 case PCI_DEVICE_ID_INTEL_82865:
115 printf("This northbridge does not have EPBAR.\n");
Stefan Reinauer23190272008-08-20 13:41:24 +0000116 return 1;
117 default:
118 printf("Error: Dumping EPBAR on this northbridge is not (yet) supported.\n");
119 return 1;
120 }
121
Stefan Reinauer1162f252008-12-04 15:18:20 +0000122 epbar = map_physical(epbar_phys, size);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000123
Stefan Reinauer1162f252008-12-04 15:18:20 +0000124 if (epbar == NULL) {
Stefan Reinauer23190272008-08-20 13:41:24 +0000125 perror("Error mapping EPBAR");
126 exit(1);
127 }
128
Stefan Reinauera7b296d2011-11-14 12:40:34 -0800129 printf("EPBAR = 0x%08" PRIx64 " (MEM)\n\n", epbar_phys);
Stefan Reinauer23190272008-08-20 13:41:24 +0000130 for (i = 0; i < size; i += 4) {
131 if (*(uint32_t *)(epbar + i))
132 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(epbar+i));
133 }
134
Stefan Reinauer1162f252008-12-04 15:18:20 +0000135 unmap_physical((void *)epbar, size);
Stefan Reinauer23190272008-08-20 13:41:24 +0000136 return 0;
137}
138
139/*
140 * MCH-ICH Serial Interconnect Ingress Root Complex MMIO configuration space
141 */
142int print_dmibar(struct pci_dev *nb)
143{
144 int i, size = (4 * 1024);
145 volatile uint8_t *dmibar;
Stefan Reinauer1162f252008-12-04 15:18:20 +0000146 uint64_t dmibar_phys;
Anton Kochkovc7fc4422012-07-21 06:36:47 +0400147 const io_register_t *dmi_registers = NULL;
Stefan Reinauer23190272008-08-20 13:41:24 +0000148
149 printf("\n============= DMIBAR ============\n\n");
150
151 switch (nb->device_id) {
Pat Erleyca3548e2010-04-21 06:23:19 +0000152 case PCI_DEVICE_ID_INTEL_82915:
Stefan Reinauer23190272008-08-20 13:41:24 +0000153 case PCI_DEVICE_ID_INTEL_82945GM:
Björn Busse2d33dc42010-08-01 15:33:30 +0000154 case PCI_DEVICE_ID_INTEL_82945GSE:
Stefan Reinauer3d9a12f2008-11-02 11:11:40 +0000155 case PCI_DEVICE_ID_INTEL_82945P:
Stefan Reinauer1162f252008-12-04 15:18:20 +0000156 case PCI_DEVICE_ID_INTEL_82975X:
Stefan Reinauer23190272008-08-20 13:41:24 +0000157 dmibar_phys = pci_read_long(nb, 0x4c) & 0xfffffffe;
158 break;
Stefan Tauner04c06002012-10-13 02:19:30 +0200159 case PCI_DEVICE_ID_INTEL_82965PM:
160 case PCI_DEVICE_ID_INTEL_82Q965:
Warren Turkal53291952010-09-03 09:32:17 +0000161 case PCI_DEVICE_ID_INTEL_82Q35:
162 case PCI_DEVICE_ID_INTEL_82G33:
163 case PCI_DEVICE_ID_INTEL_82Q33:
Stefan Tauner04c06002012-10-13 02:19:30 +0200164 case PCI_DEVICE_ID_INTEL_82X38:
Ruud Schrampbb41f502011-04-04 07:53:19 +0200165 case PCI_DEVICE_ID_INTEL_32X0:
Stefan Tauner04c06002012-10-13 02:19:30 +0200166 case PCI_DEVICE_ID_INTEL_82X4X:
Corey Osgood23d98c72010-07-29 19:25:31 +0000167 case PCI_DEVICE_ID_INTEL_ATOM_DXXX:
168 case PCI_DEVICE_ID_INTEL_ATOM_NXXX:
Warren Turkal53291952010-09-03 09:32:17 +0000169 dmibar_phys = pci_read_long(nb, 0x68) & 0xfffffffe;
170 dmibar_phys |= ((uint64_t)pci_read_long(nb, 0x6c)) << 32;
171 break;
Stefan Reinauerb2aedb12009-08-29 15:45:43 +0000172 case PCI_DEVICE_ID_INTEL_82810:
Stefan Tauner04c06002012-10-13 02:19:30 +0200173 case PCI_DEVICE_ID_INTEL_82810_DC:
174 case PCI_DEVICE_ID_INTEL_82810E_DC:
Idwer Vollering312fc962010-12-17 22:34:58 +0000175 case PCI_DEVICE_ID_INTEL_82865:
176 printf("This northbridge does not have DMIBAR.\n");
Stefan Reinauer23190272008-08-20 13:41:24 +0000177 return 1;
Stefan Tauner04c06002012-10-13 02:19:30 +0200178 case PCI_DEVICE_ID_INTEL_82X58:
Warren Turkal3235eea2010-09-03 09:31:13 +0000179 dmibar_phys = pci_read_long(nb, 0x50) & 0xfffff000;
180 break;
Stefan Tauner04c06002012-10-13 02:19:30 +0200181 case PCI_DEVICE_ID_INTEL_CORE_1ST_GEN:
182 dmibar_phys = pci_read_long(nb, 0x68);
183 dmibar_phys |= ((uint64_t)pci_read_long(nb, 0x6c)) << 32;
184 dmibar_phys &= 0x0000000ffffff000UL; /* 35:12 */
185 dmi_registers = NULL; /* No public documentation */
186 break;
187 case PCI_DEVICE_ID_INTEL_CORE_2ND_GEN:
Anton Kochkovc7fc4422012-07-21 06:36:47 +0400188 dmi_registers = sandybridge_dmi_registers;
189 size = ARRAY_SIZE(sandybridge_dmi_registers);
Stefan Tauner04c06002012-10-13 02:19:30 +0200190 case PCI_DEVICE_ID_INTEL_CORE_3RD_GEN: /* pretty printing not implemented yet */
191 dmibar_phys = pci_read_long(nb, 0x68);
192 dmibar_phys |= ((uint64_t)pci_read_long(nb, 0x6c)) << 32;
193 dmibar_phys &= 0x0000007ffffff000UL; /* 38:12 */
Anton Kochkovc7fc4422012-07-21 06:36:47 +0400194 break;
Stefan Reinauer23190272008-08-20 13:41:24 +0000195 default:
196 printf("Error: Dumping DMIBAR on this northbridge is not (yet) supported.\n");
197 return 1;
198 }
199
Stefan Reinauer1162f252008-12-04 15:18:20 +0000200 dmibar = map_physical(dmibar_phys, size);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000201
Stefan Reinauer1162f252008-12-04 15:18:20 +0000202 if (dmibar == NULL) {
Stefan Reinauer23190272008-08-20 13:41:24 +0000203 perror("Error mapping DMIBAR");
204 exit(1);
205 }
206
Stefan Reinauera7b296d2011-11-14 12:40:34 -0800207 printf("DMIBAR = 0x%08" PRIx64 " (MEM)\n\n", dmibar_phys);
Anton Kochkovc7fc4422012-07-21 06:36:47 +0400208 if (dmi_registers != NULL) {
209 for (i = 0; i < size; i++) {
210 switch (dmi_registers[i].size) {
211 case 4:
212 printf("dmibase+0x%04x: 0x%08x (%s)\n",
213 dmi_registers[i].addr,
214 *(uint32_t *)(dmibar+dmi_registers[i].addr),
215 dmi_registers[i].name);
216 break;
217 case 2:
218 printf("dmibase+0x%04x: 0x%04x (%s)\n",
219 dmi_registers[i].addr,
220 *(uint16_t *)(dmibar+dmi_registers[i].addr),
221 dmi_registers[i].name);
222 break;
223 case 1:
224 printf("dmibase+0x%04x: 0x%02x (%s)\n",
225 dmi_registers[i].addr,
226 *(uint8_t *)(dmibar+dmi_registers[i].addr),
227 dmi_registers[i].name);
228 break;
229 }
230 }
231 } else {
232 for (i = 0; i < size; i += 4) {
233 if (*(uint32_t *)(dmibar + i))
234 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(dmibar+i));
235 }
Stefan Reinauer23190272008-08-20 13:41:24 +0000236 }
237
Stefan Reinauer1162f252008-12-04 15:18:20 +0000238 unmap_physical((void *)dmibar, size);
Stefan Reinauer23190272008-08-20 13:41:24 +0000239 return 0;
240}
241
242/*
243 * PCIe MMIO configuration space
244 */
245int print_pciexbar(struct pci_dev *nb)
246{
Stefan Reinauer1162f252008-12-04 15:18:20 +0000247 uint64_t pciexbar_reg;
248 uint64_t pciexbar_phys;
Stefan Reinauer23190272008-08-20 13:41:24 +0000249 volatile uint8_t *pciexbar;
250 int max_busses, devbase, i;
251 int bus, dev, fn;
252
253 printf("========= PCIEXBAR ========\n\n");
254
255 switch (nb->device_id) {
Pat Erleyca3548e2010-04-21 06:23:19 +0000256 case PCI_DEVICE_ID_INTEL_82915:
Stefan Reinauer23190272008-08-20 13:41:24 +0000257 case PCI_DEVICE_ID_INTEL_82945GM:
Björn Busse2d33dc42010-08-01 15:33:30 +0000258 case PCI_DEVICE_ID_INTEL_82945GSE:
Stefan Reinauer3d9a12f2008-11-02 11:11:40 +0000259 case PCI_DEVICE_ID_INTEL_82945P:
Stefan Reinauer1162f252008-12-04 15:18:20 +0000260 case PCI_DEVICE_ID_INTEL_82975X:
Stefan Reinauer23190272008-08-20 13:41:24 +0000261 pciexbar_reg = pci_read_long(nb, 0x48);
262 break;
Stefan Tauner04c06002012-10-13 02:19:30 +0200263 case PCI_DEVICE_ID_INTEL_82965PM:
264 case PCI_DEVICE_ID_INTEL_82Q965:
265 case PCI_DEVICE_ID_INTEL_82Q35:
266 case PCI_DEVICE_ID_INTEL_82G33:
267 case PCI_DEVICE_ID_INTEL_82Q33:
268 case PCI_DEVICE_ID_INTEL_82X38:
Ruud Schrampbb41f502011-04-04 07:53:19 +0200269 case PCI_DEVICE_ID_INTEL_32X0:
Stefan Tauner04c06002012-10-13 02:19:30 +0200270 case PCI_DEVICE_ID_INTEL_82X4X:
Corey Osgood23d98c72010-07-29 19:25:31 +0000271 case PCI_DEVICE_ID_INTEL_ATOM_DXXX:
272 case PCI_DEVICE_ID_INTEL_ATOM_NXXX:
Stefan Tauner04c06002012-10-13 02:19:30 +0200273 pciexbar_reg = pci_read_long(nb, 0x60);
274 pciexbar_reg |= ((uint64_t)pci_read_long(nb, 0x64)) << 32;
275 break;
Stefan Reinauerb2aedb12009-08-29 15:45:43 +0000276 case PCI_DEVICE_ID_INTEL_82810:
Stefan Tauner04c06002012-10-13 02:19:30 +0200277 case PCI_DEVICE_ID_INTEL_82810_DC:
278 case PCI_DEVICE_ID_INTEL_82810E_DC:
Idwer Vollering312fc962010-12-17 22:34:58 +0000279 case PCI_DEVICE_ID_INTEL_82865:
280 printf("Error: This northbridge does not have PCIEXBAR.\n");
Stefan Reinauer23190272008-08-20 13:41:24 +0000281 return 1;
282 default:
283 printf("Error: Dumping PCIEXBAR on this northbridge is not (yet) supported.\n");
284 return 1;
285 }
286
287 if (!(pciexbar_reg & (1 << 0))) {
288 printf("PCIEXBAR register is disabled.\n");
289 return 0;
290 }
291
292 switch ((pciexbar_reg >> 1) & 3) {
293 case 0: // 256MB
Stefan Reinauer1162f252008-12-04 15:18:20 +0000294 pciexbar_phys = pciexbar_reg & (0xff << 28);
Stefan Reinauer23190272008-08-20 13:41:24 +0000295 max_busses = 256;
296 break;
297 case 1: // 128M
Stefan Reinauer1162f252008-12-04 15:18:20 +0000298 pciexbar_phys = pciexbar_reg & (0x1ff << 27);
Stefan Reinauer23190272008-08-20 13:41:24 +0000299 max_busses = 128;
300 break;
301 case 2: // 64M
Stefan Reinauer1162f252008-12-04 15:18:20 +0000302 pciexbar_phys = pciexbar_reg & (0x3ff << 26);
Stefan Reinauer23190272008-08-20 13:41:24 +0000303 max_busses = 64;
304 break;
305 default: // RSVD
306 printf("Undefined address base. Bailing out.\n");
307 return 1;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000308 }
Stefan Reinauer23190272008-08-20 13:41:24 +0000309
Stefan Reinauera7b296d2011-11-14 12:40:34 -0800310 printf("PCIEXBAR: 0x%08" PRIx64 "\n", pciexbar_phys);
Stefan Reinauer23190272008-08-20 13:41:24 +0000311
Stefan Reinauer1162f252008-12-04 15:18:20 +0000312 pciexbar = map_physical(pciexbar_phys, (max_busses * 1024 * 1024));
Stefan Reinauer14e22772010-04-27 06:56:47 +0000313
Stefan Reinauer1162f252008-12-04 15:18:20 +0000314 if (pciexbar == NULL) {
Stefan Reinauer23190272008-08-20 13:41:24 +0000315 perror("Error mapping PCIEXBAR");
316 exit(1);
317 }
Stefan Reinauer14e22772010-04-27 06:56:47 +0000318
Stefan Reinauer23190272008-08-20 13:41:24 +0000319 for (bus = 0; bus < max_busses; bus++) {
320 for (dev = 0; dev < 32; dev++) {
321 for (fn = 0; fn < 8; fn++) {
322 devbase = (bus * 1024 * 1024) + (dev * 32 * 1024) + (fn * 4 * 1024);
323
324 if (*(uint16_t *)(pciexbar + devbase) == 0xffff)
325 continue;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000326
Stefan Reinauer23190272008-08-20 13:41:24 +0000327 /* This is a heuristics. Anyone got a better check? */
328 if( (*(uint32_t *)(pciexbar + devbase + 256) == 0xffffffff) &&
329 (*(uint32_t *)(pciexbar + devbase + 512) == 0xffffffff) ) {
330#if DEBUG
331 printf("Skipped non-PCIe device %02x:%02x.%01x\n", bus, dev, fn);
332#endif
333 continue;
334 }
335
336 printf("\nPCIe %02x:%02x.%01x extended config space:", bus, dev, fn);
337 for (i = 0; i < 4096; i++) {
338 if((i % 0x10) == 0)
339 printf("\n%04x:", i);
340 printf(" %02x", *(pciexbar+devbase+i));
341 }
342 printf("\n");
343 }
344 }
345 }
346
Stefan Reinauer1162f252008-12-04 15:18:20 +0000347 unmap_physical((void *)pciexbar, (max_busses * 1024 * 1024));
Stefan Reinauer23190272008-08-20 13:41:24 +0000348
349 return 0;
350}