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 |
| 5 | * |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 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. |
| 9 | * |
| 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. |
| 14 | * |
| 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. |
| 18 | */ |
| 19 | |
| 20 | |
| 21 | #include <stdio.h> |
| 22 | #include <stdlib.h> |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 23 | #include "inteltool.h" |
| 24 | |
| 25 | /* |
| 26 | * (G)MCH MMIO Config Space |
| 27 | */ |
| 28 | int print_mchbar(struct pci_dev *nb) |
| 29 | { |
| 30 | int i, size = (16 * 1024); |
| 31 | volatile uint8_t *mchbar; |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 32 | uint64_t mchbar_phys; |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 33 | |
| 34 | printf("\n============= MCHBAR ============\n\n"); |
| 35 | |
| 36 | switch (nb->device_id) { |
Pat Erley | ca3548e | 2010-04-21 06:23:19 +0000 | [diff] [blame] | 37 | case PCI_DEVICE_ID_INTEL_82915: |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 38 | case PCI_DEVICE_ID_INTEL_82945GM: |
Stefan Reinauer | 3d9a12f | 2008-11-02 11:11:40 +0000 | [diff] [blame] | 39 | case PCI_DEVICE_ID_INTEL_82945P: |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 40 | case PCI_DEVICE_ID_INTEL_82975X: |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 41 | mchbar_phys = pci_read_long(nb, 0x44) & 0xfffffffe; |
| 42 | break; |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 43 | case PCI_DEVICE_ID_INTEL_PM965: |
Loïc Grenié | 8429de7 | 2009-11-02 15:01:49 +0000 | [diff] [blame] | 44 | case PCI_DEVICE_ID_INTEL_82Q35: |
| 45 | case PCI_DEVICE_ID_INTEL_82G33: |
| 46 | case PCI_DEVICE_ID_INTEL_82Q33: |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 47 | mchbar_phys = pci_read_long(nb, 0x48) & 0xfffffffe; |
| 48 | mchbar_phys |= ((uint64_t)pci_read_long(nb, 0x4c)) << 32; |
| 49 | break; |
Maciej Pijanka | 90d1740 | 2009-09-30 17:05:46 +0000 | [diff] [blame] | 50 | case PCI_DEVICE_ID_INTEL_82443LX: |
| 51 | case PCI_DEVICE_ID_INTEL_82443BX: |
Stefan Reinauer | b2aedb1 | 2009-08-29 15:45:43 +0000 | [diff] [blame] | 52 | case PCI_DEVICE_ID_INTEL_82810: |
Joseph Smith | e10757e | 2010-06-16 22:21:19 +0000 | [diff] [blame] | 53 | case PCI_DEVICE_ID_INTEL_82810E_MC: |
Stefan Reinauer | b2aedb1 | 2009-08-29 15:45:43 +0000 | [diff] [blame] | 54 | case PCI_DEVICE_ID_INTEL_82810DC: |
Stefan Reinauer | 0484481 | 2010-02-22 11:26:06 +0000 | [diff] [blame] | 55 | case PCI_DEVICE_ID_INTEL_82830M: |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 56 | printf("This northbrigde does not have MCHBAR.\n"); |
| 57 | return 1; |
Anton Kochkov | da0b456 | 2010-05-30 12:33:12 +0000 | [diff] [blame] | 58 | case PCI_DEVICE_ID_INTEL_GS45: |
| 59 | mchbar_phys = pci_read_long(nb, 0x48) & 0xfffffffe; |
| 60 | mchbar_phys |= ((uint64_t)pci_read_long(nb, 0x4c)) << 32; |
| 61 | break; |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 62 | default: |
| 63 | printf("Error: Dumping MCHBAR on this northbridge is not (yet) supported.\n"); |
| 64 | return 1; |
| 65 | } |
| 66 | |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 67 | mchbar = map_physical(mchbar_phys, size); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 68 | |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 69 | if (mchbar == NULL) { |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 70 | perror("Error mapping MCHBAR"); |
| 71 | exit(1); |
| 72 | } |
| 73 | |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 74 | printf("MCHBAR = 0x%08llx (MEM)\n\n", mchbar_phys); |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 75 | |
| 76 | for (i = 0; i < size; i += 4) { |
| 77 | if (*(uint32_t *)(mchbar + i)) |
| 78 | printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(mchbar+i)); |
| 79 | } |
| 80 | |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 81 | unmap_physical((void *)mchbar, size); |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 82 | return 0; |
| 83 | } |
| 84 | |
| 85 | |