2008-08-20 15:41:24 +02:00
|
|
|
/*
|
|
|
|
* inteltool - dump all registers on an Intel CPU + chipset based system.
|
|
|
|
*
|
2010-02-22 12:26:06 +01:00
|
|
|
* Copyright (C) 2008-2010 by coresystems GmbH
|
2008-08-20 15:41:24 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "inteltool.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Egress Port Root Complex MMIO configuration space
|
|
|
|
*/
|
|
|
|
int print_epbar(struct pci_dev *nb)
|
|
|
|
{
|
|
|
|
int i, size = (4 * 1024);
|
|
|
|
volatile uint8_t *epbar;
|
2008-12-04 16:18:20 +01:00
|
|
|
uint64_t epbar_phys;
|
2008-08-20 15:41:24 +02:00
|
|
|
|
|
|
|
printf("\n============= EPBAR =============\n\n");
|
|
|
|
|
|
|
|
switch (nb->device_id) {
|
|
|
|
case PCI_DEVICE_ID_INTEL_82945GM:
|
2008-11-02 12:11:40 +01:00
|
|
|
case PCI_DEVICE_ID_INTEL_82945P:
|
2008-12-04 16:18:20 +01:00
|
|
|
case PCI_DEVICE_ID_INTEL_82975X:
|
2008-08-20 15:41:24 +02:00
|
|
|
epbar_phys = pci_read_long(nb, 0x40) & 0xfffffffe;
|
|
|
|
break;
|
2008-12-04 16:18:20 +01:00
|
|
|
case PCI_DEVICE_ID_INTEL_PM965:
|
2009-11-02 16:01:49 +01:00
|
|
|
case PCI_DEVICE_ID_INTEL_82Q35:
|
|
|
|
case PCI_DEVICE_ID_INTEL_82G33:
|
|
|
|
case PCI_DEVICE_ID_INTEL_82Q33:
|
2008-12-04 16:18:20 +01:00
|
|
|
epbar_phys = pci_read_long(nb, 0x40) & 0xfffffffe;
|
|
|
|
epbar_phys |= ((uint64_t)pci_read_long(nb, 0x44)) << 32;
|
|
|
|
break;
|
2009-08-29 17:45:43 +02:00
|
|
|
case PCI_DEVICE_ID_INTEL_82810:
|
|
|
|
case PCI_DEVICE_ID_INTEL_82810DC:
|
2010-02-22 12:26:06 +01:00
|
|
|
case PCI_DEVICE_ID_INTEL_82830M:
|
2008-08-20 15:41:24 +02:00
|
|
|
printf("This northbrigde does not have EPBAR.\n");
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
printf("Error: Dumping EPBAR on this northbridge is not (yet) supported.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-12-04 16:18:20 +01:00
|
|
|
epbar = map_physical(epbar_phys, size);
|
2008-08-20 15:41:24 +02:00
|
|
|
|
2008-12-04 16:18:20 +01:00
|
|
|
if (epbar == NULL) {
|
2008-08-20 15:41:24 +02:00
|
|
|
perror("Error mapping EPBAR");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2008-12-04 16:18:20 +01:00
|
|
|
printf("EPBAR = 0x%08llx (MEM)\n\n", epbar_phys);
|
2008-08-20 15:41:24 +02:00
|
|
|
for (i = 0; i < size; i += 4) {
|
|
|
|
if (*(uint32_t *)(epbar + i))
|
|
|
|
printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(epbar+i));
|
|
|
|
}
|
|
|
|
|
2008-12-04 16:18:20 +01:00
|
|
|
unmap_physical((void *)epbar, size);
|
2008-08-20 15:41:24 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* MCH-ICH Serial Interconnect Ingress Root Complex MMIO configuration space
|
|
|
|
*/
|
|
|
|
int print_dmibar(struct pci_dev *nb)
|
|
|
|
{
|
|
|
|
int i, size = (4 * 1024);
|
|
|
|
volatile uint8_t *dmibar;
|
2008-12-04 16:18:20 +01:00
|
|
|
uint64_t dmibar_phys;
|
2008-08-20 15:41:24 +02:00
|
|
|
|
|
|
|
printf("\n============= DMIBAR ============\n\n");
|
|
|
|
|
|
|
|
switch (nb->device_id) {
|
|
|
|
case PCI_DEVICE_ID_INTEL_82945GM:
|
2008-11-02 12:11:40 +01:00
|
|
|
case PCI_DEVICE_ID_INTEL_82945P:
|
2008-12-04 16:18:20 +01:00
|
|
|
case PCI_DEVICE_ID_INTEL_82975X:
|
2008-08-20 15:41:24 +02:00
|
|
|
dmibar_phys = pci_read_long(nb, 0x4c) & 0xfffffffe;
|
|
|
|
break;
|
2008-12-04 16:18:20 +01:00
|
|
|
case PCI_DEVICE_ID_INTEL_PM965:
|
2009-11-02 16:01:49 +01:00
|
|
|
case PCI_DEVICE_ID_INTEL_82Q35:
|
|
|
|
case PCI_DEVICE_ID_INTEL_82G33:
|
|
|
|
case PCI_DEVICE_ID_INTEL_82Q33:
|
2008-12-04 16:18:20 +01:00
|
|
|
dmibar_phys = pci_read_long(nb, 0x68) & 0xfffffffe;
|
|
|
|
dmibar_phys |= ((uint64_t)pci_read_long(nb, 0x6c)) << 32;
|
|
|
|
break;
|
2009-08-29 17:45:43 +02:00
|
|
|
case PCI_DEVICE_ID_INTEL_82810:
|
|
|
|
case PCI_DEVICE_ID_INTEL_82810DC:
|
2010-02-22 12:26:06 +01:00
|
|
|
case PCI_DEVICE_ID_INTEL_82830M:
|
2008-08-20 15:41:24 +02:00
|
|
|
printf("This northbrigde does not have DMIBAR.\n");
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
printf("Error: Dumping DMIBAR on this northbridge is not (yet) supported.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-12-04 16:18:20 +01:00
|
|
|
dmibar = map_physical(dmibar_phys, size);
|
2008-08-20 15:41:24 +02:00
|
|
|
|
2008-12-04 16:18:20 +01:00
|
|
|
if (dmibar == NULL) {
|
2008-08-20 15:41:24 +02:00
|
|
|
perror("Error mapping DMIBAR");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2008-12-04 16:18:20 +01:00
|
|
|
printf("DMIBAR = 0x%08llx (MEM)\n\n", dmibar_phys);
|
2008-08-20 15:41:24 +02:00
|
|
|
for (i = 0; i < size; i += 4) {
|
|
|
|
if (*(uint32_t *)(dmibar + i))
|
|
|
|
printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(dmibar+i));
|
|
|
|
}
|
|
|
|
|
2008-12-04 16:18:20 +01:00
|
|
|
unmap_physical((void *)dmibar, size);
|
2008-08-20 15:41:24 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PCIe MMIO configuration space
|
|
|
|
*/
|
|
|
|
int print_pciexbar(struct pci_dev *nb)
|
|
|
|
{
|
2008-12-04 16:18:20 +01:00
|
|
|
uint64_t pciexbar_reg;
|
|
|
|
uint64_t pciexbar_phys;
|
2008-08-20 15:41:24 +02:00
|
|
|
volatile uint8_t *pciexbar;
|
|
|
|
int max_busses, devbase, i;
|
|
|
|
int bus, dev, fn;
|
|
|
|
|
|
|
|
printf("========= PCIEXBAR ========\n\n");
|
|
|
|
|
|
|
|
switch (nb->device_id) {
|
|
|
|
case PCI_DEVICE_ID_INTEL_82945GM:
|
2008-11-02 12:11:40 +01:00
|
|
|
case PCI_DEVICE_ID_INTEL_82945P:
|
2008-12-04 16:18:20 +01:00
|
|
|
case PCI_DEVICE_ID_INTEL_82975X:
|
2008-08-20 15:41:24 +02:00
|
|
|
pciexbar_reg = pci_read_long(nb, 0x48);
|
|
|
|
break;
|
2008-12-04 16:18:20 +01:00
|
|
|
case PCI_DEVICE_ID_INTEL_PM965:
|
2009-11-02 16:01:49 +01:00
|
|
|
case PCI_DEVICE_ID_INTEL_82Q35:
|
|
|
|
case PCI_DEVICE_ID_INTEL_82G33:
|
|
|
|
case PCI_DEVICE_ID_INTEL_82Q33:
|
2008-12-04 16:18:20 +01:00
|
|
|
pciexbar_reg = pci_read_long(nb, 0x60);
|
|
|
|
pciexbar_reg |= ((uint64_t)pci_read_long(nb, 0x64)) << 32;
|
|
|
|
break;
|
2009-08-29 17:45:43 +02:00
|
|
|
case PCI_DEVICE_ID_INTEL_82810:
|
|
|
|
case PCI_DEVICE_ID_INTEL_82810DC:
|
2008-08-20 15:41:24 +02:00
|
|
|
printf("Error: This northbrigde does not have PCIEXBAR.\n");
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
printf("Error: Dumping PCIEXBAR on this northbridge is not (yet) supported.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(pciexbar_reg & (1 << 0))) {
|
|
|
|
printf("PCIEXBAR register is disabled.\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ((pciexbar_reg >> 1) & 3) {
|
|
|
|
case 0: // 256MB
|
2008-12-04 16:18:20 +01:00
|
|
|
pciexbar_phys = pciexbar_reg & (0xff << 28);
|
2008-08-20 15:41:24 +02:00
|
|
|
max_busses = 256;
|
|
|
|
break;
|
|
|
|
case 1: // 128M
|
2008-12-04 16:18:20 +01:00
|
|
|
pciexbar_phys = pciexbar_reg & (0x1ff << 27);
|
2008-08-20 15:41:24 +02:00
|
|
|
max_busses = 128;
|
|
|
|
break;
|
|
|
|
case 2: // 64M
|
2008-12-04 16:18:20 +01:00
|
|
|
pciexbar_phys = pciexbar_reg & (0x3ff << 26);
|
2008-08-20 15:41:24 +02:00
|
|
|
max_busses = 64;
|
|
|
|
break;
|
|
|
|
default: // RSVD
|
|
|
|
printf("Undefined address base. Bailing out.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-12-04 16:18:20 +01:00
|
|
|
printf("PCIEXBAR: 0x%08llx\n", pciexbar_phys);
|
2008-08-20 15:41:24 +02:00
|
|
|
|
2008-12-04 16:18:20 +01:00
|
|
|
pciexbar = map_physical(pciexbar_phys, (max_busses * 1024 * 1024));
|
2008-08-20 15:41:24 +02:00
|
|
|
|
2008-12-04 16:18:20 +01:00
|
|
|
if (pciexbar == NULL) {
|
2008-08-20 15:41:24 +02:00
|
|
|
perror("Error mapping PCIEXBAR");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (bus = 0; bus < max_busses; bus++) {
|
|
|
|
for (dev = 0; dev < 32; dev++) {
|
|
|
|
for (fn = 0; fn < 8; fn++) {
|
|
|
|
devbase = (bus * 1024 * 1024) + (dev * 32 * 1024) + (fn * 4 * 1024);
|
|
|
|
|
|
|
|
if (*(uint16_t *)(pciexbar + devbase) == 0xffff)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* This is a heuristics. Anyone got a better check? */
|
|
|
|
if( (*(uint32_t *)(pciexbar + devbase + 256) == 0xffffffff) &&
|
|
|
|
(*(uint32_t *)(pciexbar + devbase + 512) == 0xffffffff) ) {
|
|
|
|
#if DEBUG
|
|
|
|
printf("Skipped non-PCIe device %02x:%02x.%01x\n", bus, dev, fn);
|
|
|
|
#endif
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\nPCIe %02x:%02x.%01x extended config space:", bus, dev, fn);
|
|
|
|
for (i = 0; i < 4096; i++) {
|
|
|
|
if((i % 0x10) == 0)
|
|
|
|
printf("\n%04x:", i);
|
|
|
|
printf(" %02x", *(pciexbar+devbase+i));
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-04 16:18:20 +01:00
|
|
|
unmap_physical((void *)pciexbar, (max_busses * 1024 * 1024));
|
2008-08-20 15:41:24 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|