2 * inteltool - dump all registers on an Intel CPU + chipset based system.
4 * Copyright (C) 2008 by coresystems GmbH
5 * written by Stefan Reinauer <stepan@coresystems.de>
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.
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.
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.
26 #include "inteltool.h"
29 uint16_t vendor_id, device_id;
31 } supported_chips_list[] = {
32 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82810, "i810" },
33 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82810DC, "i810-DC100" },
34 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82845, "i845" },
35 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82945P, "i945P" },
36 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82945GM, "i945GM" },
37 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PM965, "PM965" },
38 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82975X, "i975X" },
39 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_X58, "X58" },
40 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH10R, "ICH10R" },
41 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8M, "ICH8-M" },
42 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7MDH, "ICH7-M DH" },
43 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7M, "ICH7-M" },
44 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7, "ICH7" },
45 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7DH, "ICH7DH" },
46 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH4M, "ICH4-M" },
47 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH4, "ICH4" },
48 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH2, "ICH2" },
49 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH0, "ICH0" },
50 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH, "ICH" }
56 void *map_physical(unsigned long phys_addr, int len)
60 virt_addr = mmap(0, len, PROT_WRITE | PROT_READ, MAP_SHARED,
61 fd_mem, (off_t) phys_addr);
63 if (virt_addr == MAP_FAILED) {
64 printf("Error mapping physical memory 0x%08lx[0x%x]\n", phys_addr, len);
71 void unmap_physical(void *virt_addr, int len)
73 munmap(virt_addr, len);
77 void print_version(void)
79 printf("inteltool v%s -- ", INTELTOOL_VERSION);
80 printf("Copyright (C) 2008 coresystems GmbH\n\n");
82 "This program is free software: you can redistribute it and/or modify\n"
83 "it under the terms of the GNU General Public License as published by\n"
84 "the Free Software Foundation, version 2 of the License.\n\n"
85 "This program is distributed in the hope that it will be useful,\n"
86 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
87 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
88 "GNU General Public License for more details.\n\n"
89 "You should have received a copy of the GNU General Public License\n"
90 "along with this program. If not, see <http://www.gnu.org/licenses/>.\n\n");
93 void print_usage(const char *name)
95 printf("usage: %s [-vh?grpmedPMa]\n", name);
97 " -v | --version: print the version\n"
98 " -h | --help: print this help\n\n"
99 " -g | --gpio: dump soutbridge GPIO registers\n"
100 " -r | --rcba: dump soutbridge RCBA registers\n"
101 " -p | --pmbase: dump soutbridge Power Management registers\n\n"
102 " -m | --mchbar: dump northbridge Memory Controller registers\n"
103 " -e | --epbar: dump northbridge EPBAR registers\n"
104 " -d | --dmibar: dump northbridge DMIBAR registers\n"
105 " -P | --pciexpress: dump northbridge PCIEXBAR registers\n\n"
106 " -M | --msrs: dump CPU MSRs\n"
107 " -a | --all: dump all known registers\n"
112 int main(int argc, char *argv[])
114 struct pci_access *pacc;
115 struct pci_dev *sb, *nb;
116 int i, opt, option_index = 0;
119 char *sbname = "unknown", *nbname = "unknown";
121 int dump_gpios = 0, dump_mchbar = 0, dump_rcba = 0;
122 int dump_pmbase = 0, dump_epbar = 0, dump_dmibar = 0;
123 int dump_pciexbar = 0, dump_coremsrs = 0;
125 static struct option long_options[] = {
126 {"version", 0, 0, 'v'},
128 {"gpios", 0, 0, 'g'},
129 {"mchbar", 0, 0, 'm'},
131 {"pmbase", 0, 0, 'p'},
132 {"epbar", 0, 0, 'e'},
133 {"dmibar", 0, 0, 'd'},
134 {"pciexpress", 0, 0, 'P'},
140 while ((opt = getopt_long(argc, argv, "vh?grpmedPMa",
141 long_options, &option_index)) != EOF) {
184 print_usage(argv[0]);
191 printf("You need to be root.\n");
196 if ((fd_mem = open("/dev/mem", O_RDWR)) < 0) {
197 perror("Can not open /dev/mem");
206 /* Find the required devices */
208 sb = pci_get_dev(pacc, 0, 0, 0x1f, 0);
210 printf("No southbridge found.\n");
214 pci_fill_info(sb, PCI_FILL_IDENT|PCI_FILL_BASES|PCI_FILL_SIZES|PCI_FILL_CLASS);
216 if (sb->vendor_id != PCI_VENDOR_ID_INTEL) {
217 printf("Not an Intel(R) southbridge.\n");
221 nb = pci_get_dev(pacc, 0, 0, 0x00, 0);
223 printf("No northbridge found.\n");
227 pci_fill_info(nb, PCI_FILL_IDENT|PCI_FILL_BASES|PCI_FILL_SIZES|PCI_FILL_CLASS);
229 if (nb->vendor_id != PCI_VENDOR_ID_INTEL) {
230 printf("Not an Intel(R) northbridge.\n");
235 printf("Intel CPU: Family %x, Model %x\n",
236 (id >> 8) & 0xf, (id >> 4) & 0xf);
238 /* Determine names */
239 for (i = 0; i < ARRAY_SIZE(supported_chips_list); i++)
240 if (nb->device_id == supported_chips_list[i].device_id)
241 nbname = supported_chips_list[i].name;
242 for (i = 0; i < ARRAY_SIZE(supported_chips_list); i++)
243 if (sb->device_id == supported_chips_list[i].device_id)
244 sbname = supported_chips_list[i].name;
246 printf("Intel Northbridge: %04x:%04x (%s)\n",
247 nb->vendor_id, nb->device_id, nbname);
249 printf("Intel Southbridge: %04x:%04x (%s)\n",
250 sb->vendor_id, sb->device_id, sbname);
252 /* Now do the deed */
290 print_intel_core_msrs();