blob: 99a57535ddff7593becca802bd71ae53df50ab11 [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>
23#include <sys/mman.h>
24
25#include "inteltool.h"
26
27/*
28 * (G)MCH MMIO Config Space
29 */
30int print_mchbar(struct pci_dev *nb)
31{
32 int i, size = (16 * 1024);
33 volatile uint8_t *mchbar;
34 uint32_t mchbar_phys;
35
36 printf("\n============= MCHBAR ============\n\n");
37
38 switch (nb->device_id) {
39 case PCI_DEVICE_ID_INTEL_82945GM:
Stefan Reinauer3d9a12f2008-11-02 11:11:40 +000040 case PCI_DEVICE_ID_INTEL_82945P:
Stefan Reinauer23190272008-08-20 13:41:24 +000041 mchbar_phys = pci_read_long(nb, 0x44) & 0xfffffffe;
42 break;
43 case 0x1234: // Dummy for non-existent functionality
44 printf("This northbrigde does not have MCHBAR.\n");
45 return 1;
46 default:
47 printf("Error: Dumping MCHBAR on this northbridge is not (yet) supported.\n");
48 return 1;
49 }
50
51 mchbar = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
52 fd_mem, (off_t) mchbar_phys);
53
54 if (mchbar == MAP_FAILED) {
55 perror("Error mapping MCHBAR");
56 exit(1);
57 }
58
59 printf("MCHBAR = 0x%08x (MEM)\n\n", mchbar_phys);
60
61 for (i = 0; i < size; i += 4) {
62 if (*(uint32_t *)(mchbar + i))
63 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(mchbar+i));
64 }
65
66 munmap((void *)mchbar, size);
67 return 0;
68}
69
70