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_82945GM, "i945GM" },
35 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7MDH, "ICH7-M DH" },
36 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7M, "ICH7-M" },
37 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7, "ICH7" },
38 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7DH, "ICH7DH" },
39 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH4M, "ICH4-M" },
40 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH4, "ICH4" },
41 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH2, "ICH2" },
42 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH0, "ICH0" },
43 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH, "ICH" }
48 void print_version(void)
50 printf("inteltool v%s -- ", INTELTOOL_VERSION);
51 printf("Copyright (C) 2008 coresystems GmbH\n\n");
53 "This program is free software: you can redistribute it and/or modify\n"
54 "it under the terms of the GNU General Public License as published by\n"
55 "the Free Software Foundation, version 2 of the License.\n\n"
56 "This program is distributed in the hope that it will be useful,\n"
57 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
58 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
59 "GNU General Public License for more details.\n\n"
60 "You should have received a copy of the GNU General Public License\n"
61 "along with this program. If not, see <http://www.gnu.org/licenses/>.\n\n");
64 void print_usage(const char *name)
66 printf("usage: %s [-vh?grpmedPMa]\n", name);
68 " -v | --version: print the version\n"
69 " -h | --help: print this help\n\n"
70 " -g | --gpio: dump soutbridge GPIO registers\n"
71 " -r | --rcba: dump soutbridge RCBA registers\n"
72 " -p | --pmbase: dump soutbridge Power Management registers\n\n"
73 " -m | --mchbar: dump northbridge Memory Controller registers\n"
74 " -e | --epbar: dump northbridge EPBAR registers\n"
75 " -d | --dmibar: dump northbridge DMIBAR registers\n"
76 " -P | --pciexpress: dump northbridge PCIEXBAR registers\n\n"
77 " -M | --msrs: dump CPU MSRs\n"
78 " -a | --all: dump all known registers\n"
83 int main(int argc, char *argv[])
85 struct pci_access *pacc;
86 struct pci_dev *sb, *nb;
87 int i, opt, option_index = 0;
90 char *sbname = "unknown", *nbname = "unknown";
92 int dump_gpios = 0, dump_mchbar = 0, dump_rcba = 0;
93 int dump_pmbase = 0, dump_epbar = 0, dump_dmibar = 0;
94 int dump_pciexbar = 0, dump_coremsrs = 0;
96 static struct option long_options[] = {
97 {"version", 0, 0, 'v'},
100 {"mchbar", 0, 0, 'm'},
102 {"pmbase", 0, 0, 'p'},
103 {"epbar", 0, 0, 'e'},
104 {"dmibar", 0, 0, 'd'},
105 {"pciexpress", 0, 0, 'P'},
111 while ((opt = getopt_long(argc, argv, "vh?grpmedPMa",
112 long_options, &option_index)) != EOF) {
155 print_usage(argv[0]);
162 printf("You need to be root.\n");
166 if ((fd_mem = open("/dev/mem", O_RDWR)) < 0) {
167 perror("Can not open /dev/mem");
175 /* Find the required devices */
177 sb = pci_get_dev(pacc, 0, 0, 0x1f, 0);
179 printf("No southbridge found.\n");
183 pci_fill_info(sb, PCI_FILL_IDENT|PCI_FILL_BASES|PCI_FILL_SIZES|PCI_FILL_CLASS);
185 if (sb->vendor_id != PCI_VENDOR_ID_INTEL) {
186 printf("Not an Intel(R) southbridge.\n");
190 nb = pci_get_dev(pacc, 0, 0, 0x00, 0);
192 printf("No northbridge found.\n");
196 pci_fill_info(nb, PCI_FILL_IDENT|PCI_FILL_BASES|PCI_FILL_SIZES|PCI_FILL_CLASS);
198 if (nb->vendor_id != PCI_VENDOR_ID_INTEL) {
199 printf("Not an Intel(R) northbridge.\n");
204 printf("Intel CPU: Family %x, Model %x\n",
205 (id >> 8) & 0xf, (id >> 4) & 0xf);
207 /* Determine names */
208 for (i = 0; i < ARRAY_SIZE(supported_chips_list); i++)
209 if (nb->device_id == supported_chips_list[i].device_id)
210 nbname = supported_chips_list[i].name;
211 for (i = 0; i < ARRAY_SIZE(supported_chips_list); i++)
212 if (sb->device_id == supported_chips_list[i].device_id)
213 sbname = supported_chips_list[i].name;
215 printf("Intel Northbridge: %04x:%04x (%s)\n",
216 nb->vendor_id, nb->device_id, nbname);
218 printf("Intel Southbridge: %04x:%04x (%s)\n",
219 sb->vendor_id, sb->device_id, sbname);
221 /* Now do the deed */
259 print_intel_core_msrs();