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.
27 #include "inteltool.h"
30 uint16_t vendor_id, device_id;
32 } supported_chips_list[] = {
33 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82845, "i845" },
34 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82945P, "i945P" },
35 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82945GM, "i945GM" },
36 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7MDH, "ICH7-M DH" },
37 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7M, "ICH7-M" },
38 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7, "ICH7" },
39 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7DH, "ICH7DH" },
40 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH4M, "ICH4-M" },
41 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH4, "ICH4" },
42 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH2, "ICH2" },
43 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH0, "ICH0" },
44 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH, "ICH" }
49 void print_version(void)
51 printf("inteltool v%s -- ", INTELTOOL_VERSION);
52 printf("Copyright (C) 2008 coresystems GmbH\n\n");
54 "This program is free software: you can redistribute it and/or modify\n"
55 "it under the terms of the GNU General Public License as published by\n"
56 "the Free Software Foundation, version 2 of the License.\n\n"
57 "This program is distributed in the hope that it will be useful,\n"
58 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
59 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
60 "GNU General Public License for more details.\n\n"
61 "You should have received a copy of the GNU General Public License\n"
62 "along with this program. If not, see <http://www.gnu.org/licenses/>.\n\n");
65 void print_usage(const char *name)
67 printf("usage: %s [-vh?grpmedPMa]\n", name);
69 " -v | --version: print the version\n"
70 " -h | --help: print this help\n\n"
71 " -g | --gpio: dump soutbridge GPIO registers\n"
72 " -r | --rcba: dump soutbridge RCBA registers\n"
73 " -p | --pmbase: dump soutbridge Power Management registers\n\n"
74 " -m | --mchbar: dump northbridge Memory Controller registers\n"
75 " -e | --epbar: dump northbridge EPBAR registers\n"
76 " -d | --dmibar: dump northbridge DMIBAR registers\n"
77 " -P | --pciexpress: dump northbridge PCIEXBAR registers\n\n"
78 " -M | --msrs: dump CPU MSRs\n"
79 " -a | --all: dump all known registers\n"
84 int main(int argc, char *argv[])
86 struct pci_access *pacc;
87 struct pci_dev *sb, *nb;
88 int i, opt, option_index = 0;
91 char *sbname = "unknown", *nbname = "unknown";
93 int dump_gpios = 0, dump_mchbar = 0, dump_rcba = 0;
94 int dump_pmbase = 0, dump_epbar = 0, dump_dmibar = 0;
95 int dump_pciexbar = 0, dump_coremsrs = 0;
97 static struct option long_options[] = {
98 {"version", 0, 0, 'v'},
100 {"gpios", 0, 0, 'g'},
101 {"mchbar", 0, 0, 'm'},
103 {"pmbase", 0, 0, 'p'},
104 {"epbar", 0, 0, 'e'},
105 {"dmibar", 0, 0, 'd'},
106 {"pciexpress", 0, 0, 'P'},
112 while ((opt = getopt_long(argc, argv, "vh?grpmedPMa",
113 long_options, &option_index)) != EOF) {
156 print_usage(argv[0]);
163 printf("You need to be root.\n");
167 if ((fd_mem = open("/dev/mem", O_RDWR)) < 0) {
168 perror("Can not open /dev/mem");
176 /* Find the required devices */
178 sb = pci_get_dev(pacc, 0, 0, 0x1f, 0);
180 printf("No southbridge found.\n");
184 pci_fill_info(sb, PCI_FILL_IDENT|PCI_FILL_BASES|PCI_FILL_SIZES|PCI_FILL_CLASS);
186 if (sb->vendor_id != PCI_VENDOR_ID_INTEL) {
187 printf("Not an Intel(R) southbridge.\n");
191 nb = pci_get_dev(pacc, 0, 0, 0x00, 0);
193 printf("No northbridge found.\n");
197 pci_fill_info(nb, PCI_FILL_IDENT|PCI_FILL_BASES|PCI_FILL_SIZES|PCI_FILL_CLASS);
199 if (nb->vendor_id != PCI_VENDOR_ID_INTEL) {
200 printf("Not an Intel(R) northbridge.\n");
205 printf("Intel CPU: Family %x, Model %x\n",
206 (id >> 8) & 0xf, (id >> 4) & 0xf);
208 /* Determine names */
209 for (i = 0; i < ARRAY_SIZE(supported_chips_list); i++)
210 if (nb->device_id == supported_chips_list[i].device_id)
211 nbname = supported_chips_list[i].name;
212 for (i = 0; i < ARRAY_SIZE(supported_chips_list); i++)
213 if (sb->device_id == supported_chips_list[i].device_id)
214 sbname = supported_chips_list[i].name;
216 printf("Intel Northbridge: %04x:%04x (%s)\n",
217 nb->vendor_id, nb->device_id, nbname);
219 printf("Intel Southbridge: %04x:%04x (%s)\n",
220 sb->vendor_id, sb->device_id, sbname);
222 /* Now do the deed */
260 print_intel_core_msrs();