blob: a7429a020216628327972169ac7eda930f0e7708 [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 Reinauer1162f252008-12-04 15:18:20 +000097 case PCI_DEVICE_ID_INTEL_PM965:
Corey Osgood23d98c72010-07-29 19:25:31 +000098 case PCI_DEVICE_ID_INTEL_Q965:
Loïc Grenié8429de72009-11-02 15:01:49 +000099 case PCI_DEVICE_ID_INTEL_82Q35:
100 case PCI_DEVICE_ID_INTEL_82G33:
101 case PCI_DEVICE_ID_INTEL_82Q33:
Ruud Schrampbb41f502011-04-04 07:53:19 +0200102 case PCI_DEVICE_ID_INTEL_X44:
103 case PCI_DEVICE_ID_INTEL_32X0:
Anton Kochkovda0b4562010-05-30 12:33:12 +0000104 case PCI_DEVICE_ID_INTEL_GS45:
Corey Osgood23d98c72010-07-29 19:25:31 +0000105 case PCI_DEVICE_ID_INTEL_ATOM_DXXX:
106 case PCI_DEVICE_ID_INTEL_ATOM_NXXX:
Stefan Reinauer1162f252008-12-04 15:18:20 +0000107 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:
111 case PCI_DEVICE_ID_INTEL_82810DC:
Joseph Smithe10757e2010-06-16 22:21:19 +0000112 case PCI_DEVICE_ID_INTEL_82810E_MC:
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;
Warren Turkal53291952010-09-03 09:32:17 +0000159 case PCI_DEVICE_ID_INTEL_PM965:
Corey Osgood23d98c72010-07-29 19:25:31 +0000160 case PCI_DEVICE_ID_INTEL_Q965:
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:
Ruud Schrampbb41f502011-04-04 07:53:19 +0200164 case PCI_DEVICE_ID_INTEL_X44:
165 case PCI_DEVICE_ID_INTEL_32X0:
Anton Kochkovda0b4562010-05-30 12:33:12 +0000166 case PCI_DEVICE_ID_INTEL_GS45:
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:
173 case PCI_DEVICE_ID_INTEL_82810DC:
Joseph Smithe10757e2010-06-16 22:21:19 +0000174 case PCI_DEVICE_ID_INTEL_82810E_MC:
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;
Warren Turkal3235eea2010-09-03 09:31:13 +0000178 case PCI_DEVICE_ID_INTEL_X58:
179 dmibar_phys = pci_read_long(nb, 0x50) & 0xfffff000;
180 break;
Anton Kochkovc7fc4422012-07-21 06:36:47 +0400181 case PCI_DEVICE_ID_INTEL_HM65E:
182 dmibar_phys = pci_read_long(nb, 0x68) & 0xfffff000;
183 dmi_registers = sandybridge_dmi_registers;
184 size = ARRAY_SIZE(sandybridge_dmi_registers);
185 break;
Stefan Reinauer23190272008-08-20 13:41:24 +0000186 default:
187 printf("Error: Dumping DMIBAR on this northbridge is not (yet) supported.\n");
188 return 1;
189 }
190
Stefan Reinauer1162f252008-12-04 15:18:20 +0000191 dmibar = map_physical(dmibar_phys, size);
Stefan Reinauer14e22772010-04-27 06:56:47 +0000192
Stefan Reinauer1162f252008-12-04 15:18:20 +0000193 if (dmibar == NULL) {
Stefan Reinauer23190272008-08-20 13:41:24 +0000194 perror("Error mapping DMIBAR");
195 exit(1);
196 }
197
Stefan Reinauera7b296d2011-11-14 12:40:34 -0800198 printf("DMIBAR = 0x%08" PRIx64 " (MEM)\n\n", dmibar_phys);
Anton Kochkovc7fc4422012-07-21 06:36:47 +0400199 if (dmi_registers != NULL) {
200 for (i = 0; i < size; i++) {
201 switch (dmi_registers[i].size) {
202 case 4:
203 printf("dmibase+0x%04x: 0x%08x (%s)\n",
204 dmi_registers[i].addr,
205 *(uint32_t *)(dmibar+dmi_registers[i].addr),
206 dmi_registers[i].name);
207 break;
208 case 2:
209 printf("dmibase+0x%04x: 0x%04x (%s)\n",
210 dmi_registers[i].addr,
211 *(uint16_t *)(dmibar+dmi_registers[i].addr),
212 dmi_registers[i].name);
213 break;
214 case 1:
215 printf("dmibase+0x%04x: 0x%02x (%s)\n",
216 dmi_registers[i].addr,
217 *(uint8_t *)(dmibar+dmi_registers[i].addr),
218 dmi_registers[i].name);
219 break;
220 }
221 }
222 } else {
223 for (i = 0; i < size; i += 4) {
224 if (*(uint32_t *)(dmibar + i))
225 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(dmibar+i));
226 }
Stefan Reinauer23190272008-08-20 13:41:24 +0000227 }
228
Stefan Reinauer1162f252008-12-04 15:18:20 +0000229 unmap_physical((void *)dmibar, size);
Stefan Reinauer23190272008-08-20 13:41:24 +0000230 return 0;
231}
232
233/*
234 * PCIe MMIO configuration space
235 */
236int print_pciexbar(struct pci_dev *nb)
237{
Stefan Reinauer1162f252008-12-04 15:18:20 +0000238 uint64_t pciexbar_reg;
239 uint64_t pciexbar_phys;
Stefan Reinauer23190272008-08-20 13:41:24 +0000240 volatile uint8_t *pciexbar;
241 int max_busses, devbase, i;
242 int bus, dev, fn;
243
244 printf("========= PCIEXBAR ========\n\n");
245
246 switch (nb->device_id) {
Pat Erleyca3548e2010-04-21 06:23:19 +0000247 case PCI_DEVICE_ID_INTEL_82915:
Stefan Reinauer23190272008-08-20 13:41:24 +0000248 case PCI_DEVICE_ID_INTEL_82945GM:
Björn Busse2d33dc42010-08-01 15:33:30 +0000249 case PCI_DEVICE_ID_INTEL_82945GSE:
Stefan Reinauer3d9a12f2008-11-02 11:11:40 +0000250 case PCI_DEVICE_ID_INTEL_82945P:
Stefan Reinauer1162f252008-12-04 15:18:20 +0000251 case PCI_DEVICE_ID_INTEL_82975X:
Stefan Reinauer23190272008-08-20 13:41:24 +0000252 pciexbar_reg = pci_read_long(nb, 0x48);
253 break;
Stefan Reinauer1162f252008-12-04 15:18:20 +0000254 case PCI_DEVICE_ID_INTEL_PM965:
Corey Osgood23d98c72010-07-29 19:25:31 +0000255 case PCI_DEVICE_ID_INTEL_Q965:
Loïc Grenié8429de72009-11-02 15:01:49 +0000256 case PCI_DEVICE_ID_INTEL_82Q35:
257 case PCI_DEVICE_ID_INTEL_82G33:
258 case PCI_DEVICE_ID_INTEL_82Q33:
Ruud Schrampbb41f502011-04-04 07:53:19 +0200259 case PCI_DEVICE_ID_INTEL_X44:
260 case PCI_DEVICE_ID_INTEL_32X0:
Anton Kochkovda0b4562010-05-30 12:33:12 +0000261 case PCI_DEVICE_ID_INTEL_GS45:
Corey Osgood23d98c72010-07-29 19:25:31 +0000262 case PCI_DEVICE_ID_INTEL_ATOM_DXXX:
263 case PCI_DEVICE_ID_INTEL_ATOM_NXXX:
Stefan Reinauer1162f252008-12-04 15:18:20 +0000264 pciexbar_reg = pci_read_long(nb, 0x60);
265 pciexbar_reg |= ((uint64_t)pci_read_long(nb, 0x64)) << 32;
266 break;
Stefan Reinauerb2aedb12009-08-29 15:45:43 +0000267 case PCI_DEVICE_ID_INTEL_82810:
268 case PCI_DEVICE_ID_INTEL_82810DC:
Joseph Smithe10757e2010-06-16 22:21:19 +0000269 case PCI_DEVICE_ID_INTEL_82810E_MC:
Idwer Vollering312fc962010-12-17 22:34:58 +0000270 case PCI_DEVICE_ID_INTEL_82865:
271 printf("Error: This northbridge does not have PCIEXBAR.\n");
Stefan Reinauer23190272008-08-20 13:41:24 +0000272 return 1;
273 default:
274 printf("Error: Dumping PCIEXBAR on this northbridge is not (yet) supported.\n");
275 return 1;
276 }
277
278 if (!(pciexbar_reg & (1 << 0))) {
279 printf("PCIEXBAR register is disabled.\n");
280 return 0;
281 }
282
283 switch ((pciexbar_reg >> 1) & 3) {
284 case 0: // 256MB
Stefan Reinauer1162f252008-12-04 15:18:20 +0000285 pciexbar_phys = pciexbar_reg & (0xff << 28);
Stefan Reinauer23190272008-08-20 13:41:24 +0000286 max_busses = 256;
287 break;
288 case 1: // 128M
Stefan Reinauer1162f252008-12-04 15:18:20 +0000289 pciexbar_phys = pciexbar_reg & (0x1ff << 27);
Stefan Reinauer23190272008-08-20 13:41:24 +0000290 max_busses = 128;
291 break;
292 case 2: // 64M
Stefan Reinauer1162f252008-12-04 15:18:20 +0000293 pciexbar_phys = pciexbar_reg & (0x3ff << 26);
Stefan Reinauer23190272008-08-20 13:41:24 +0000294 max_busses = 64;
295 break;
296 default: // RSVD
297 printf("Undefined address base. Bailing out.\n");
298 return 1;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000299 }
Stefan Reinauer23190272008-08-20 13:41:24 +0000300
Stefan Reinauera7b296d2011-11-14 12:40:34 -0800301 printf("PCIEXBAR: 0x%08" PRIx64 "\n", pciexbar_phys);
Stefan Reinauer23190272008-08-20 13:41:24 +0000302
Stefan Reinauer1162f252008-12-04 15:18:20 +0000303 pciexbar = map_physical(pciexbar_phys, (max_busses * 1024 * 1024));
Stefan Reinauer14e22772010-04-27 06:56:47 +0000304
Stefan Reinauer1162f252008-12-04 15:18:20 +0000305 if (pciexbar == NULL) {
Stefan Reinauer23190272008-08-20 13:41:24 +0000306 perror("Error mapping PCIEXBAR");
307 exit(1);
308 }
Stefan Reinauer14e22772010-04-27 06:56:47 +0000309
Stefan Reinauer23190272008-08-20 13:41:24 +0000310 for (bus = 0; bus < max_busses; bus++) {
311 for (dev = 0; dev < 32; dev++) {
312 for (fn = 0; fn < 8; fn++) {
313 devbase = (bus * 1024 * 1024) + (dev * 32 * 1024) + (fn * 4 * 1024);
314
315 if (*(uint16_t *)(pciexbar + devbase) == 0xffff)
316 continue;
Stefan Reinauer14e22772010-04-27 06:56:47 +0000317
Stefan Reinauer23190272008-08-20 13:41:24 +0000318 /* This is a heuristics. Anyone got a better check? */
319 if( (*(uint32_t *)(pciexbar + devbase + 256) == 0xffffffff) &&
320 (*(uint32_t *)(pciexbar + devbase + 512) == 0xffffffff) ) {
321#if DEBUG
322 printf("Skipped non-PCIe device %02x:%02x.%01x\n", bus, dev, fn);
323#endif
324 continue;
325 }
326
327 printf("\nPCIe %02x:%02x.%01x extended config space:", bus, dev, fn);
328 for (i = 0; i < 4096; i++) {
329 if((i % 0x10) == 0)
330 printf("\n%04x:", i);
331 printf(" %02x", *(pciexbar+devbase+i));
332 }
333 printf("\n");
334 }
335 }
336 }
337
Stefan Reinauer1162f252008-12-04 15:18:20 +0000338 unmap_physical((void *)pciexbar, (max_busses * 1024 * 1024));
Stefan Reinauer23190272008-08-20 13:41:24 +0000339
340 return 0;
341}