blob: a2060cbed07c747a354e840eddf243f57c3576cf [file] [log] [blame]
Stefan Reinauer23190272008-08-20 13:41:24 +00001/*
2 * inteltool - dump all registers on an Intel CPU + chipset based system.
3 *
4 * Copyright (C) 2008 by coresystems GmbH
5 *
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 Reinauer23190272008-08-20 13:41:24 +000023#include "inteltool.h"
24
25/*
26 * (G)MCH MMIO Config Space
27 */
28int print_mchbar(struct pci_dev *nb)
29{
30 int i, size = (16 * 1024);
31 volatile uint8_t *mchbar;
Stefan Reinauer1162f252008-12-04 15:18:20 +000032 uint64_t mchbar_phys;
Stefan Reinauer23190272008-08-20 13:41:24 +000033
34 printf("\n============= MCHBAR ============\n\n");
35
36 switch (nb->device_id) {
37 case PCI_DEVICE_ID_INTEL_82945GM:
Stefan Reinauer3d9a12f2008-11-02 11:11:40 +000038 case PCI_DEVICE_ID_INTEL_82945P:
Stefan Reinauer1162f252008-12-04 15:18:20 +000039 case PCI_DEVICE_ID_INTEL_82975X:
Stefan Reinauer23190272008-08-20 13:41:24 +000040 mchbar_phys = pci_read_long(nb, 0x44) & 0xfffffffe;
41 break;
Stefan Reinauer1162f252008-12-04 15:18:20 +000042 case PCI_DEVICE_ID_INTEL_PM965:
43 mchbar_phys = pci_read_long(nb, 0x48) & 0xfffffffe;
44 mchbar_phys |= ((uint64_t)pci_read_long(nb, 0x4c)) << 32;
45 break;
Stefan Reinauerb2aedb12009-08-29 15:45:43 +000046 case PCI_DEVICE_ID_INTEL_82810:
47 case PCI_DEVICE_ID_INTEL_82810DC:
Stefan Reinauer23190272008-08-20 13:41:24 +000048 printf("This northbrigde does not have MCHBAR.\n");
49 return 1;
50 default:
51 printf("Error: Dumping MCHBAR on this northbridge is not (yet) supported.\n");
52 return 1;
53 }
54
Stefan Reinauer1162f252008-12-04 15:18:20 +000055 mchbar = map_physical(mchbar_phys, size);
Stefan Reinauer23190272008-08-20 13:41:24 +000056
Stefan Reinauer1162f252008-12-04 15:18:20 +000057 if (mchbar == NULL) {
Stefan Reinauer23190272008-08-20 13:41:24 +000058 perror("Error mapping MCHBAR");
59 exit(1);
60 }
61
Stefan Reinauer1162f252008-12-04 15:18:20 +000062 printf("MCHBAR = 0x%08llx (MEM)\n\n", mchbar_phys);
Stefan Reinauer23190272008-08-20 13:41:24 +000063
64 for (i = 0; i < size; i += 4) {
65 if (*(uint32_t *)(mchbar + i))
66 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(mchbar+i));
67 }
68
Stefan Reinauer1162f252008-12-04 15:18:20 +000069 unmap_physical((void *)mchbar, size);
Stefan Reinauer23190272008-08-20 13:41:24 +000070 return 0;
71}
72
73