Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 1 | /* |
| 2 | * inteltool - dump all registers on an Intel CPU + chipset based system. |
| 3 | * |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 4 | * Copyright (C) 2008-2010 by coresystems GmbH |
Anton Kochkov | c7fc442 | 2012-07-21 06:36:47 +0400 | [diff] [blame] | 5 | * Copyright (C) 2012 Anton Kochkov |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 6 | * |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 7 | * 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 Reinauer | a7b296d | 2011-11-14 12:40:34 -0800 | [diff] [blame] | 23 | #include <inttypes.h> |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 24 | #include "inteltool.h" |
| 25 | |
Anton Kochkov | c7fc442 | 2012-07-21 06:36:47 +0400 | [diff] [blame] | 26 | static 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 Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 78 | /* |
| 79 | * Egress Port Root Complex MMIO configuration space |
| 80 | */ |
| 81 | int print_epbar(struct pci_dev *nb) |
| 82 | { |
| 83 | int i, size = (4 * 1024); |
| 84 | volatile uint8_t *epbar; |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 85 | uint64_t epbar_phys; |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 86 | |
| 87 | printf("\n============= EPBAR =============\n\n"); |
| 88 | |
| 89 | switch (nb->device_id) { |
Pat Erley | ca3548e | 2010-04-21 06:23:19 +0000 | [diff] [blame] | 90 | case PCI_DEVICE_ID_INTEL_82915: |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 91 | case PCI_DEVICE_ID_INTEL_82945GM: |
Björn Busse | 2d33dc4 | 2010-08-01 15:33:30 +0000 | [diff] [blame] | 92 | case PCI_DEVICE_ID_INTEL_82945GSE: |
Stefan Reinauer | 3d9a12f | 2008-11-02 11:11:40 +0000 | [diff] [blame] | 93 | case PCI_DEVICE_ID_INTEL_82945P: |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 94 | case PCI_DEVICE_ID_INTEL_82975X: |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 95 | epbar_phys = pci_read_long(nb, 0x40) & 0xfffffffe; |
| 96 | break; |
Stefan Tauner | 04c0600 | 2012-10-13 02:19:30 +0200 | [diff] [blame^] | 97 | 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 Schramp | bb41f50 | 2011-04-04 07:53:19 +0200 | [diff] [blame] | 103 | case PCI_DEVICE_ID_INTEL_32X0: |
Stefan Tauner | 04c0600 | 2012-10-13 02:19:30 +0200 | [diff] [blame^] | 104 | case PCI_DEVICE_ID_INTEL_82X4X: |
Corey Osgood | 23d98c7 | 2010-07-29 19:25:31 +0000 | [diff] [blame] | 105 | case PCI_DEVICE_ID_INTEL_ATOM_DXXX: |
| 106 | case PCI_DEVICE_ID_INTEL_ATOM_NXXX: |
Stefan Tauner | 04c0600 | 2012-10-13 02:19:30 +0200 | [diff] [blame^] | 107 | epbar_phys = pci_read_long(nb, 0x40) & 0xfffffffe; |
| 108 | epbar_phys |= ((uint64_t)pci_read_long(nb, 0x44)) << 32; |
| 109 | break; |
Stefan Reinauer | b2aedb1 | 2009-08-29 15:45:43 +0000 | [diff] [blame] | 110 | case PCI_DEVICE_ID_INTEL_82810: |
Stefan Tauner | 04c0600 | 2012-10-13 02:19:30 +0200 | [diff] [blame^] | 111 | case PCI_DEVICE_ID_INTEL_82810_DC: |
| 112 | case PCI_DEVICE_ID_INTEL_82810E_DC: |
Stefan Reinauer | 0484481 | 2010-02-22 11:26:06 +0000 | [diff] [blame] | 113 | case PCI_DEVICE_ID_INTEL_82830M: |
Idwer Vollering | 312fc96 | 2010-12-17 22:34:58 +0000 | [diff] [blame] | 114 | case PCI_DEVICE_ID_INTEL_82865: |
| 115 | printf("This northbridge does not have EPBAR.\n"); |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 116 | return 1; |
| 117 | default: |
| 118 | printf("Error: Dumping EPBAR on this northbridge is not (yet) supported.\n"); |
| 119 | return 1; |
| 120 | } |
| 121 | |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 122 | epbar = map_physical(epbar_phys, size); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 123 | |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 124 | if (epbar == NULL) { |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 125 | perror("Error mapping EPBAR"); |
| 126 | exit(1); |
| 127 | } |
| 128 | |
Stefan Reinauer | a7b296d | 2011-11-14 12:40:34 -0800 | [diff] [blame] | 129 | printf("EPBAR = 0x%08" PRIx64 " (MEM)\n\n", epbar_phys); |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 130 | 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 Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 135 | unmap_physical((void *)epbar, size); |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 136 | return 0; |
| 137 | } |
| 138 | |
| 139 | /* |
| 140 | * MCH-ICH Serial Interconnect Ingress Root Complex MMIO configuration space |
| 141 | */ |
| 142 | int print_dmibar(struct pci_dev *nb) |
| 143 | { |
| 144 | int i, size = (4 * 1024); |
| 145 | volatile uint8_t *dmibar; |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 146 | uint64_t dmibar_phys; |
Anton Kochkov | c7fc442 | 2012-07-21 06:36:47 +0400 | [diff] [blame] | 147 | const io_register_t *dmi_registers = NULL; |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 148 | |
| 149 | printf("\n============= DMIBAR ============\n\n"); |
| 150 | |
| 151 | switch (nb->device_id) { |
Pat Erley | ca3548e | 2010-04-21 06:23:19 +0000 | [diff] [blame] | 152 | case PCI_DEVICE_ID_INTEL_82915: |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 153 | case PCI_DEVICE_ID_INTEL_82945GM: |
Björn Busse | 2d33dc4 | 2010-08-01 15:33:30 +0000 | [diff] [blame] | 154 | case PCI_DEVICE_ID_INTEL_82945GSE: |
Stefan Reinauer | 3d9a12f | 2008-11-02 11:11:40 +0000 | [diff] [blame] | 155 | case PCI_DEVICE_ID_INTEL_82945P: |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 156 | case PCI_DEVICE_ID_INTEL_82975X: |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 157 | dmibar_phys = pci_read_long(nb, 0x4c) & 0xfffffffe; |
| 158 | break; |
Stefan Tauner | 04c0600 | 2012-10-13 02:19:30 +0200 | [diff] [blame^] | 159 | case PCI_DEVICE_ID_INTEL_82965PM: |
| 160 | case PCI_DEVICE_ID_INTEL_82Q965: |
Warren Turkal | 5329195 | 2010-09-03 09:32:17 +0000 | [diff] [blame] | 161 | case PCI_DEVICE_ID_INTEL_82Q35: |
| 162 | case PCI_DEVICE_ID_INTEL_82G33: |
| 163 | case PCI_DEVICE_ID_INTEL_82Q33: |
Stefan Tauner | 04c0600 | 2012-10-13 02:19:30 +0200 | [diff] [blame^] | 164 | case PCI_DEVICE_ID_INTEL_82X38: |
Ruud Schramp | bb41f50 | 2011-04-04 07:53:19 +0200 | [diff] [blame] | 165 | case PCI_DEVICE_ID_INTEL_32X0: |
Stefan Tauner | 04c0600 | 2012-10-13 02:19:30 +0200 | [diff] [blame^] | 166 | case PCI_DEVICE_ID_INTEL_82X4X: |
Corey Osgood | 23d98c7 | 2010-07-29 19:25:31 +0000 | [diff] [blame] | 167 | case PCI_DEVICE_ID_INTEL_ATOM_DXXX: |
| 168 | case PCI_DEVICE_ID_INTEL_ATOM_NXXX: |
Warren Turkal | 5329195 | 2010-09-03 09:32:17 +0000 | [diff] [blame] | 169 | dmibar_phys = pci_read_long(nb, 0x68) & 0xfffffffe; |
| 170 | dmibar_phys |= ((uint64_t)pci_read_long(nb, 0x6c)) << 32; |
| 171 | break; |
Stefan Reinauer | b2aedb1 | 2009-08-29 15:45:43 +0000 | [diff] [blame] | 172 | case PCI_DEVICE_ID_INTEL_82810: |
Stefan Tauner | 04c0600 | 2012-10-13 02:19:30 +0200 | [diff] [blame^] | 173 | case PCI_DEVICE_ID_INTEL_82810_DC: |
| 174 | case PCI_DEVICE_ID_INTEL_82810E_DC: |
Idwer Vollering | 312fc96 | 2010-12-17 22:34:58 +0000 | [diff] [blame] | 175 | case PCI_DEVICE_ID_INTEL_82865: |
| 176 | printf("This northbridge does not have DMIBAR.\n"); |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 177 | return 1; |
Stefan Tauner | 04c0600 | 2012-10-13 02:19:30 +0200 | [diff] [blame^] | 178 | case PCI_DEVICE_ID_INTEL_82X58: |
Warren Turkal | 3235eea | 2010-09-03 09:31:13 +0000 | [diff] [blame] | 179 | dmibar_phys = pci_read_long(nb, 0x50) & 0xfffff000; |
| 180 | break; |
Stefan Tauner | 04c0600 | 2012-10-13 02:19:30 +0200 | [diff] [blame^] | 181 | 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 Kochkov | c7fc442 | 2012-07-21 06:36:47 +0400 | [diff] [blame] | 188 | dmi_registers = sandybridge_dmi_registers; |
| 189 | size = ARRAY_SIZE(sandybridge_dmi_registers); |
Stefan Tauner | 04c0600 | 2012-10-13 02:19:30 +0200 | [diff] [blame^] | 190 | 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 Kochkov | c7fc442 | 2012-07-21 06:36:47 +0400 | [diff] [blame] | 194 | break; |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 195 | default: |
| 196 | printf("Error: Dumping DMIBAR on this northbridge is not (yet) supported.\n"); |
| 197 | return 1; |
| 198 | } |
| 199 | |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 200 | dmibar = map_physical(dmibar_phys, size); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 201 | |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 202 | if (dmibar == NULL) { |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 203 | perror("Error mapping DMIBAR"); |
| 204 | exit(1); |
| 205 | } |
| 206 | |
Stefan Reinauer | a7b296d | 2011-11-14 12:40:34 -0800 | [diff] [blame] | 207 | printf("DMIBAR = 0x%08" PRIx64 " (MEM)\n\n", dmibar_phys); |
Anton Kochkov | c7fc442 | 2012-07-21 06:36:47 +0400 | [diff] [blame] | 208 | 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 Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 236 | } |
| 237 | |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 238 | unmap_physical((void *)dmibar, size); |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 239 | return 0; |
| 240 | } |
| 241 | |
| 242 | /* |
| 243 | * PCIe MMIO configuration space |
| 244 | */ |
| 245 | int print_pciexbar(struct pci_dev *nb) |
| 246 | { |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 247 | uint64_t pciexbar_reg; |
| 248 | uint64_t pciexbar_phys; |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 249 | 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 Erley | ca3548e | 2010-04-21 06:23:19 +0000 | [diff] [blame] | 256 | case PCI_DEVICE_ID_INTEL_82915: |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 257 | case PCI_DEVICE_ID_INTEL_82945GM: |
Björn Busse | 2d33dc4 | 2010-08-01 15:33:30 +0000 | [diff] [blame] | 258 | case PCI_DEVICE_ID_INTEL_82945GSE: |
Stefan Reinauer | 3d9a12f | 2008-11-02 11:11:40 +0000 | [diff] [blame] | 259 | case PCI_DEVICE_ID_INTEL_82945P: |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 260 | case PCI_DEVICE_ID_INTEL_82975X: |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 261 | pciexbar_reg = pci_read_long(nb, 0x48); |
| 262 | break; |
Stefan Tauner | 04c0600 | 2012-10-13 02:19:30 +0200 | [diff] [blame^] | 263 | 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 Schramp | bb41f50 | 2011-04-04 07:53:19 +0200 | [diff] [blame] | 269 | case PCI_DEVICE_ID_INTEL_32X0: |
Stefan Tauner | 04c0600 | 2012-10-13 02:19:30 +0200 | [diff] [blame^] | 270 | case PCI_DEVICE_ID_INTEL_82X4X: |
Corey Osgood | 23d98c7 | 2010-07-29 19:25:31 +0000 | [diff] [blame] | 271 | case PCI_DEVICE_ID_INTEL_ATOM_DXXX: |
| 272 | case PCI_DEVICE_ID_INTEL_ATOM_NXXX: |
Stefan Tauner | 04c0600 | 2012-10-13 02:19:30 +0200 | [diff] [blame^] | 273 | pciexbar_reg = pci_read_long(nb, 0x60); |
| 274 | pciexbar_reg |= ((uint64_t)pci_read_long(nb, 0x64)) << 32; |
| 275 | break; |
Stefan Reinauer | b2aedb1 | 2009-08-29 15:45:43 +0000 | [diff] [blame] | 276 | case PCI_DEVICE_ID_INTEL_82810: |
Stefan Tauner | 04c0600 | 2012-10-13 02:19:30 +0200 | [diff] [blame^] | 277 | case PCI_DEVICE_ID_INTEL_82810_DC: |
| 278 | case PCI_DEVICE_ID_INTEL_82810E_DC: |
Idwer Vollering | 312fc96 | 2010-12-17 22:34:58 +0000 | [diff] [blame] | 279 | case PCI_DEVICE_ID_INTEL_82865: |
| 280 | printf("Error: This northbridge does not have PCIEXBAR.\n"); |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 281 | 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 Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 294 | pciexbar_phys = pciexbar_reg & (0xff << 28); |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 295 | max_busses = 256; |
| 296 | break; |
| 297 | case 1: // 128M |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 298 | pciexbar_phys = pciexbar_reg & (0x1ff << 27); |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 299 | max_busses = 128; |
| 300 | break; |
| 301 | case 2: // 64M |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 302 | pciexbar_phys = pciexbar_reg & (0x3ff << 26); |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 303 | max_busses = 64; |
| 304 | break; |
| 305 | default: // RSVD |
| 306 | printf("Undefined address base. Bailing out.\n"); |
| 307 | return 1; |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 308 | } |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 309 | |
Stefan Reinauer | a7b296d | 2011-11-14 12:40:34 -0800 | [diff] [blame] | 310 | printf("PCIEXBAR: 0x%08" PRIx64 "\n", pciexbar_phys); |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 311 | |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 312 | pciexbar = map_physical(pciexbar_phys, (max_busses * 1024 * 1024)); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 313 | |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 314 | if (pciexbar == NULL) { |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 315 | perror("Error mapping PCIEXBAR"); |
| 316 | exit(1); |
| 317 | } |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 318 | |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 319 | 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 Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 326 | |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 327 | /* 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 Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 347 | unmap_physical((void *)pciexbar, (max_busses * 1024 * 1024)); |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 348 | |
| 349 | return 0; |
| 350 | } |