2 * inteltool - dump all registers on an Intel CPU + chipset based system.
4 * Copyright (C) 2008-2010 by coresystems GmbH
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "inteltool.h"
26 * Egress Port Root Complex MMIO configuration space
28 int print_epbar(struct pci_dev
*nb
)
30 int i
, size
= (4 * 1024);
31 volatile uint8_t *epbar
;
34 printf("\n============= EPBAR =============\n\n");
36 switch (nb
->device_id
) {
37 case PCI_DEVICE_ID_INTEL_82915
:
38 case PCI_DEVICE_ID_INTEL_82945GM
:
39 case PCI_DEVICE_ID_INTEL_82945GSE
:
40 case PCI_DEVICE_ID_INTEL_82945P
:
41 case PCI_DEVICE_ID_INTEL_82975X
:
42 epbar_phys
= pci_read_long(nb
, 0x40) & 0xfffffffe;
44 case PCI_DEVICE_ID_INTEL_PM965
:
45 case PCI_DEVICE_ID_INTEL_Q965
:
46 case PCI_DEVICE_ID_INTEL_82Q35
:
47 case PCI_DEVICE_ID_INTEL_82G33
:
48 case PCI_DEVICE_ID_INTEL_82Q33
:
49 case PCI_DEVICE_ID_INTEL_X44
:
50 case PCI_DEVICE_ID_INTEL_32X0
:
51 case PCI_DEVICE_ID_INTEL_GS45
:
52 case PCI_DEVICE_ID_INTEL_ATOM_DXXX
:
53 case PCI_DEVICE_ID_INTEL_ATOM_NXXX
:
54 epbar_phys
= pci_read_long(nb
, 0x40) & 0xfffffffe;
55 epbar_phys
|= ((uint64_t)pci_read_long(nb
, 0x44)) << 32;
57 case PCI_DEVICE_ID_INTEL_82810
:
58 case PCI_DEVICE_ID_INTEL_82810DC
:
59 case PCI_DEVICE_ID_INTEL_82810E_MC
:
60 case PCI_DEVICE_ID_INTEL_82830M
:
61 case PCI_DEVICE_ID_INTEL_82865
:
62 printf("This northbridge does not have EPBAR.\n");
65 printf("Error: Dumping EPBAR on this northbridge is not (yet) supported.\n");
69 epbar
= map_physical(epbar_phys
, size
);
72 perror("Error mapping EPBAR");
76 printf("EPBAR = 0x%08" PRIx64
" (MEM)\n\n", epbar_phys
);
77 for (i
= 0; i
< size
; i
+= 4) {
78 if (*(uint32_t *)(epbar
+ i
))
79 printf("0x%04x: 0x%08x\n", i
, *(uint32_t *)(epbar
+i
));
82 unmap_physical((void *)epbar
, size
);
87 * MCH-ICH Serial Interconnect Ingress Root Complex MMIO configuration space
89 int print_dmibar(struct pci_dev
*nb
)
91 int i
, size
= (4 * 1024);
92 volatile uint8_t *dmibar
;
95 printf("\n============= DMIBAR ============\n\n");
97 switch (nb
->device_id
) {
98 case PCI_DEVICE_ID_INTEL_82915
:
99 case PCI_DEVICE_ID_INTEL_82945GM
:
100 case PCI_DEVICE_ID_INTEL_82945GSE
:
101 case PCI_DEVICE_ID_INTEL_82945P
:
102 case PCI_DEVICE_ID_INTEL_82975X
:
103 dmibar_phys
= pci_read_long(nb
, 0x4c) & 0xfffffffe;
105 case PCI_DEVICE_ID_INTEL_PM965
:
106 case PCI_DEVICE_ID_INTEL_Q965
:
107 case PCI_DEVICE_ID_INTEL_82Q35
:
108 case PCI_DEVICE_ID_INTEL_82G33
:
109 case PCI_DEVICE_ID_INTEL_82Q33
:
110 case PCI_DEVICE_ID_INTEL_X44
:
111 case PCI_DEVICE_ID_INTEL_32X0
:
112 case PCI_DEVICE_ID_INTEL_GS45
:
113 case PCI_DEVICE_ID_INTEL_ATOM_DXXX
:
114 case PCI_DEVICE_ID_INTEL_ATOM_NXXX
:
115 dmibar_phys
= pci_read_long(nb
, 0x68) & 0xfffffffe;
116 dmibar_phys
|= ((uint64_t)pci_read_long(nb
, 0x6c)) << 32;
118 case PCI_DEVICE_ID_INTEL_82810
:
119 case PCI_DEVICE_ID_INTEL_82810DC
:
120 case PCI_DEVICE_ID_INTEL_82810E_MC
:
121 case PCI_DEVICE_ID_INTEL_82865
:
122 printf("This northbridge does not have DMIBAR.\n");
124 case PCI_DEVICE_ID_INTEL_X58
:
125 dmibar_phys
= pci_read_long(nb
, 0x50) & 0xfffff000;
128 printf("Error: Dumping DMIBAR on this northbridge is not (yet) supported.\n");
132 dmibar
= map_physical(dmibar_phys
, size
);
134 if (dmibar
== NULL
) {
135 perror("Error mapping DMIBAR");
139 printf("DMIBAR = 0x%08" PRIx64
" (MEM)\n\n", dmibar_phys
);
140 for (i
= 0; i
< size
; i
+= 4) {
141 if (*(uint32_t *)(dmibar
+ i
))
142 printf("0x%04x: 0x%08x\n", i
, *(uint32_t *)(dmibar
+i
));
145 unmap_physical((void *)dmibar
, size
);
150 * PCIe MMIO configuration space
152 int print_pciexbar(struct pci_dev
*nb
)
154 uint64_t pciexbar_reg
;
155 uint64_t pciexbar_phys
;
156 volatile uint8_t *pciexbar
;
157 int max_busses
, devbase
, i
;
160 printf("========= PCIEXBAR ========\n\n");
162 switch (nb
->device_id
) {
163 case PCI_DEVICE_ID_INTEL_82915
:
164 case PCI_DEVICE_ID_INTEL_82945GM
:
165 case PCI_DEVICE_ID_INTEL_82945GSE
:
166 case PCI_DEVICE_ID_INTEL_82945P
:
167 case PCI_DEVICE_ID_INTEL_82975X
:
168 pciexbar_reg
= pci_read_long(nb
, 0x48);
170 case PCI_DEVICE_ID_INTEL_PM965
:
171 case PCI_DEVICE_ID_INTEL_Q965
:
172 case PCI_DEVICE_ID_INTEL_82Q35
:
173 case PCI_DEVICE_ID_INTEL_82G33
:
174 case PCI_DEVICE_ID_INTEL_82Q33
:
175 case PCI_DEVICE_ID_INTEL_X44
:
176 case PCI_DEVICE_ID_INTEL_32X0
:
177 case PCI_DEVICE_ID_INTEL_GS45
:
178 case PCI_DEVICE_ID_INTEL_ATOM_DXXX
:
179 case PCI_DEVICE_ID_INTEL_ATOM_NXXX
:
180 pciexbar_reg
= pci_read_long(nb
, 0x60);
181 pciexbar_reg
|= ((uint64_t)pci_read_long(nb
, 0x64)) << 32;
183 case PCI_DEVICE_ID_INTEL_82810
:
184 case PCI_DEVICE_ID_INTEL_82810DC
:
185 case PCI_DEVICE_ID_INTEL_82810E_MC
:
186 case PCI_DEVICE_ID_INTEL_82865
:
187 printf("Error: This northbridge does not have PCIEXBAR.\n");
190 printf("Error: Dumping PCIEXBAR on this northbridge is not (yet) supported.\n");
194 if (!(pciexbar_reg
& (1 << 0))) {
195 printf("PCIEXBAR register is disabled.\n");
199 switch ((pciexbar_reg
>> 1) & 3) {
201 pciexbar_phys
= pciexbar_reg
& (0xff << 28);
205 pciexbar_phys
= pciexbar_reg
& (0x1ff << 27);
209 pciexbar_phys
= pciexbar_reg
& (0x3ff << 26);
213 printf("Undefined address base. Bailing out.\n");
217 printf("PCIEXBAR: 0x%08" PRIx64
"\n", pciexbar_phys
);
219 pciexbar
= map_physical(pciexbar_phys
, (max_busses
* 1024 * 1024));
221 if (pciexbar
== NULL
) {
222 perror("Error mapping PCIEXBAR");
226 for (bus
= 0; bus
< max_busses
; bus
++) {
227 for (dev
= 0; dev
< 32; dev
++) {
228 for (fn
= 0; fn
< 8; fn
++) {
229 devbase
= (bus
* 1024 * 1024) + (dev
* 32 * 1024) + (fn
* 4 * 1024);
231 if (*(uint16_t *)(pciexbar
+ devbase
) == 0xffff)
234 /* This is a heuristics. Anyone got a better check? */
235 if( (*(uint32_t *)(pciexbar
+ devbase
+ 256) == 0xffffffff) &&
236 (*(uint32_t *)(pciexbar
+ devbase
+ 512) == 0xffffffff) ) {
238 printf("Skipped non-PCIe device %02x:%02x.%01x\n", bus
, dev
, fn
);
243 printf("\nPCIe %02x:%02x.%01x extended config space:", bus
, dev
, fn
);
244 for (i
= 0; i
< 4096; i
++) {
246 printf("\n%04x:", i
);
247 printf(" %02x", *(pciexbar
+devbase
+i
));
254 unmap_physical((void *)pciexbar
, (max_busses
* 1024 * 1024));