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.
33 #define INTELTOOL_VERSION "1.0"
35 /* Tested chipsets: */
36 #define PCI_VENDOR_ID_INTEL 0x8086
37 #define PCI_DEVICE_ID_INTEL_ICH 0x2410
38 #define PCI_DEVICE_ID_INTEL_ICH0 0x2420
39 #define PCI_DEVICE_ID_INTEL_ICH4 0x24c0
40 #define PCI_DEVICE_ID_INTEL_ICH4M 0x24cc
41 #define PCI_DEVICE_ID_INTEL_ICH7DH 0x27b0
42 #define PCI_DEVICE_ID_INTEL_ICH7 0x27b8
43 #define PCI_DEVICE_ID_INTEL_ICH7M 0x27b9
44 #define PCI_DEVICE_ID_INTEL_ICH7MDH 0x27bd
45 #define PCI_DEVICE_ID_INTEL_82945GM 0x27a0
48 uint16_t vendor_id, device_id;
50 } supported_chips_list[] = {
51 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82945GM, "i945GM" },
52 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7MDH, "ICH7-M DH" },
53 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7M, "ICH7-M" },
54 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7, "ICH7" },
55 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7DH, "ICH7DH" },
56 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH4M, "ICH4-M" },
57 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH4, "ICH4" },
58 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH0, "ICH0" },
59 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH, "ICH" }
62 #define ARRAY_SIZE(a) ((int)(sizeof(a) / sizeof((a)[0])))
67 typedef struct { uint32_t hi, lo; } msr_t;
68 typedef struct { uint16_t addr; int size; char *name; } io_register_t;
70 static const io_register_t ich0_gpio_registers[] = {
71 { 0x00, 4, "GPIO_USE_SEL" },
72 { 0x04, 4, "GP_IO_SEL" },
73 { 0x08, 4, "RESERVED" },
74 { 0x0c, 4, "GP_LVL" },
75 { 0x10, 4, "RESERVED" },
76 { 0x14, 4, "GPO_TTL" },
77 { 0x18, 4, "GPO_BLINK" },
78 { 0x1c, 4, "RESERVED" },
79 { 0x20, 4, "RESERVED" },
80 { 0x24, 4, "RESERVED" },
81 { 0x28, 4, "RESERVED" },
82 { 0x2c, 4, "GPI_INV" },
83 { 0x30, 4, "RESERVED" },
84 { 0x34, 4, "RESERVED" },
85 { 0x38, 4, "RESERVED" },
86 { 0x3C, 4, "RESERVED" }
89 static const io_register_t ich4_gpio_registers[] = {
90 { 0x00, 4, "GPIO_USE_SEL" },
91 { 0x04, 4, "GP_IO_SEL" },
92 { 0x08, 4, "RESERVED" },
93 { 0x0c, 4, "GP_LVL" },
94 { 0x10, 4, "RESERVED" },
95 { 0x14, 4, "GPO_TTL" },
96 { 0x18, 4, "GPO_BLINK" },
97 { 0x1c, 4, "RESERVED" },
98 { 0x20, 4, "RESERVED" },
99 { 0x24, 4, "RESERVED" },
100 { 0x28, 4, "RESERVED" },
101 { 0x2c, 4, "GPI_INV" },
102 { 0x30, 4, "GPIO_USE_SEL2" },
103 { 0x34, 4, "GP_IO_SEL2" },
104 { 0x38, 4, "GP_LVL2" },
105 { 0x3C, 4, "RESERVED" }
108 static const io_register_t ich7_gpio_registers[] = {
109 { 0x00, 4, "GPIO_USE_SEL" },
110 { 0x04, 4, "GP_IO_SEL" },
111 { 0x08, 4, "RESERVED" },
112 { 0x0c, 4, "GP_LVL" },
113 { 0x10, 4, "RESERVED" },
114 { 0x14, 4, "RESERVED" },
115 { 0x18, 4, "GPO_BLINK" },
116 { 0x1c, 4, "RESERVED" },
117 { 0x20, 4, "RESERVED" },
118 { 0x24, 4, "RESERVED" },
119 { 0x28, 4, "RESERVED" },
120 { 0x2c, 4, "GPI_INV" },
121 { 0x30, 4, "GPIO_USE_SEL2" },
122 { 0x34, 4, "GP_IO_SEL2" },
123 { 0x38, 4, "GP_LVL2" },
124 { 0x3C, 4, "RESERVED" }
127 int print_gpios(struct pci_dev *sb)
131 const io_register_t *gpio_registers;
133 printf("\n============= GPIOS =============\n\n");
135 switch (sb->device_id) {
136 case PCI_DEVICE_ID_INTEL_ICH7:
137 case PCI_DEVICE_ID_INTEL_ICH7M:
138 case PCI_DEVICE_ID_INTEL_ICH7DH:
139 case PCI_DEVICE_ID_INTEL_ICH7MDH:
140 gpiobase = pci_read_word(sb, 0x48) & 0xfffc;
141 gpio_registers = ich7_gpio_registers;
142 size = ARRAY_SIZE(ich7_gpio_registers);
144 case PCI_DEVICE_ID_INTEL_ICH4:
145 case PCI_DEVICE_ID_INTEL_ICH4M:
146 gpiobase = pci_read_word(sb, 0x58) & 0xfffc;
147 gpio_registers = ich4_gpio_registers;
148 size = ARRAY_SIZE(ich4_gpio_registers);
150 case PCI_DEVICE_ID_INTEL_ICH:
151 case PCI_DEVICE_ID_INTEL_ICH0:
152 gpiobase = pci_read_word(sb, 0x58) & 0xfffc;
153 gpio_registers = ich0_gpio_registers;
154 size = ARRAY_SIZE(ich0_gpio_registers);
156 case 0x1234: // Dummy for non-existent functionality
157 printf("This southbridge does not have GPIOBASE.\n");
160 printf("Error: Dumping GPIOs on this southbridge is not (yet) supported.\n");
164 printf("GPIOBASE = 0x%04x (IO)\n\n", gpiobase);
166 for (i = 0; i < size; i++) {
167 switch (gpio_registers[i].size) {
169 printf("gpiobase+0x%04x: 0x%08x (%s)\n",
170 gpio_registers[i].addr,
171 inl(gpiobase+gpio_registers[i].addr),
172 gpio_registers[i].name);
175 printf("gpiobase+0x%04x: 0x%04x (%s)\n",
176 gpio_registers[i].addr,
177 inw(gpiobase+gpio_registers[i].addr),
178 gpio_registers[i].name);
181 printf("gpiobase+0x%04x: 0x%02x (%s)\n",
182 gpio_registers[i].addr,
183 inb(gpiobase+gpio_registers[i].addr),
184 gpio_registers[i].name);
192 int print_rcba(struct pci_dev *sb)
194 int i, size = 0x4000;
195 volatile uint8_t *rcba;
198 printf("\n============= RCBA ==============\n\n");
200 switch (sb->device_id) {
201 case PCI_DEVICE_ID_INTEL_ICH7:
202 case PCI_DEVICE_ID_INTEL_ICH7M:
203 case PCI_DEVICE_ID_INTEL_ICH7DH:
204 case PCI_DEVICE_ID_INTEL_ICH7MDH:
205 rcba_phys = pci_read_long(sb, 0xf0) & 0xfffffffe;
207 case PCI_DEVICE_ID_INTEL_ICH:
208 case PCI_DEVICE_ID_INTEL_ICH0:
209 case PCI_DEVICE_ID_INTEL_ICH4:
210 case PCI_DEVICE_ID_INTEL_ICH4M:
211 printf("This southbridge does not have RCBA.\n");
214 printf("Error: Dumping RCBA on this southbridge is not (yet) supported.\n");
218 rcba = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
219 fd_mem, (off_t) rcba_phys);
221 if (rcba == MAP_FAILED) {
222 perror("Error mapping RCBA");
226 printf("RCBA = 0x%08x (MEM)\n\n", rcba_phys);
228 for (i = 0; i < size; i += 4) {
229 if (*(uint32_t *)(rcba + i))
230 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(rcba + i));
233 munmap((void *)rcba, size);
237 int print_pmbase(struct pci_dev *sb)
242 printf("\n============= PMBASE ============\n\n");
244 switch (sb->device_id) {
245 case PCI_DEVICE_ID_INTEL_ICH7:
246 case PCI_DEVICE_ID_INTEL_ICH7M:
247 case PCI_DEVICE_ID_INTEL_ICH7DH:
248 case PCI_DEVICE_ID_INTEL_ICH7MDH:
249 pmbase = pci_read_word(sb, 0x40) & 0xfffc;
251 case 0x1234: // Dummy for non-existent functionality
252 printf("This southbridge does not have PMBASE.\n");
255 printf("Error: Dumping PMBASE on this southbridge is not (yet) supported.\n");
259 printf("PMBASE = 0x%04x (IO)\n\n", pmbase);
261 for (i = 0; i < size; i += 4) {
262 printf("pmbase+0x%04x: 0x%08x\n", i, inl(pmbase + i));
269 * (G)MCH MMIO Config Space
271 int print_mchbar(struct pci_dev *nb)
273 int i, size = (16 * 1024);
274 volatile uint8_t *mchbar;
275 uint32_t mchbar_phys;
277 printf("\n============= MCHBAR ============\n\n");
279 switch (nb->device_id) {
280 case PCI_DEVICE_ID_INTEL_82945GM:
281 mchbar_phys = pci_read_long(nb, 0x44) & 0xfffffffe;
283 case 0x1234: // Dummy for non-existent functionality
284 printf("This northbrigde does not have MCHBAR.\n");
287 printf("Error: Dumping MCHBAR on this northbridge is not (yet) supported.\n");
291 mchbar = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
292 fd_mem, (off_t) mchbar_phys);
294 if (mchbar == MAP_FAILED) {
295 perror("Error mapping MCHBAR");
299 printf("MCHBAR = 0x%08x (MEM)\n\n", mchbar_phys);
301 for (i = 0; i < size; i += 4) {
302 if (*(uint32_t *)(mchbar + i))
303 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(mchbar+i));
306 munmap((void *)mchbar, size);
311 * Egress Port Root Complex MMIO configuration space
313 int print_epbar(struct pci_dev *nb)
315 int i, size = (4 * 1024);
316 volatile uint8_t *epbar;
319 printf("\n============= EPBAR =============\n\n");
321 switch (nb->device_id) {
322 case PCI_DEVICE_ID_INTEL_82945GM:
323 epbar_phys = pci_read_long(nb, 0x40) & 0xfffffffe;
325 case 0x1234: // Dummy for non-existent functionality
326 printf("This northbrigde does not have EPBAR.\n");
329 printf("Error: Dumping EPBAR on this northbridge is not (yet) supported.\n");
333 epbar = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
334 fd_mem, (off_t) epbar_phys);
336 if (epbar == MAP_FAILED) {
337 perror("Error mapping EPBAR");
341 printf("EPBAR = 0x%08x (MEM)\n\n", epbar_phys);
342 for (i = 0; i < size; i += 4) {
343 if (*(uint32_t *)(epbar + i))
344 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(epbar+i));
347 munmap((void *)epbar, size);
352 * MCH-ICH Serial Interconnect Ingress Root Complex MMIO configuration space
354 int print_dmibar(struct pci_dev *nb)
356 int i, size = (4 * 1024);
357 volatile uint8_t *dmibar;
358 uint32_t dmibar_phys;
360 printf("\n============= DMIBAR ============\n\n");
362 switch (nb->device_id) {
363 case PCI_DEVICE_ID_INTEL_82945GM:
364 dmibar_phys = pci_read_long(nb, 0x4c) & 0xfffffffe;
366 case 0x1234: // Dummy for non-existent functionality
367 printf("This northbrigde does not have DMIBAR.\n");
370 printf("Error: Dumping DMIBAR on this northbridge is not (yet) supported.\n");
374 dmibar = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
375 fd_mem, (off_t) dmibar_phys);
377 if (dmibar == MAP_FAILED) {
378 perror("Error mapping DMIBAR");
382 printf("DMIBAR = 0x%08x (MEM)\n\n", dmibar_phys);
383 for (i = 0; i < size; i += 4) {
384 if (*(uint32_t *)(dmibar + i))
385 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(dmibar+i));
388 munmap((void *)dmibar, size);
393 * PCIe MMIO configuration space
395 int print_pciexbar(struct pci_dev *nb)
397 uint32_t pciexbar_reg;
398 uint32_t pciexbar_phys;
399 volatile uint8_t *pciexbar;
400 int max_busses, devbase, i;
403 printf("========= PCIEXBAR ========\n\n");
405 switch (nb->device_id) {
406 case PCI_DEVICE_ID_INTEL_82945GM:
407 pciexbar_reg = pci_read_long(nb, 0x48);
409 case 0x1234: // Dummy for non-existent functionality
410 printf("Error: This northbrigde does not have PCIEXBAR.\n");
413 printf("Error: Dumping PCIEXBAR on this northbridge is not (yet) supported.\n");
417 if (!(pciexbar_reg & (1 << 0))) {
418 printf("PCIEXBAR register is disabled.\n");
422 switch ((pciexbar_reg >> 1) & 3) {
424 pciexbar_phys = pciexbar_reg & ((1 << 31)|(1 << 30)|(1 << 29)|(1 << 28));
428 pciexbar_phys = pciexbar_reg & ((1 << 31)|(1 << 30)|(1 << 29)|(1 << 28)|(1 << 27));
432 pciexbar_phys = pciexbar_reg & ((1 << 31)|(1 << 30)|(1 << 29)|(1 << 28)|(1 << 27)|(1 << 26));
436 printf("Undefined address base. Bailing out.\n");
440 printf("PCIEXBAR: 0x%08x\n", pciexbar_phys);
442 pciexbar = mmap(0, (max_busses * 1024 * 1024), PROT_WRITE | PROT_READ,
443 MAP_SHARED, fd_mem, (off_t) pciexbar_phys);
445 if (pciexbar == MAP_FAILED) {
446 perror("Error mapping PCIEXBAR");
450 for (bus = 0; bus < max_busses; bus++) {
451 for (dev = 0; dev < 32; dev++) {
452 for (fn = 0; fn < 8; fn++) {
453 devbase = (bus * 1024 * 1024) + (dev * 32 * 1024) + (fn * 4 * 1024);
455 if (*(uint16_t *)(pciexbar + devbase) == 0xffff)
458 /* This is a heuristics. Anyone got a better check? */
459 if( (*(uint32_t *)(pciexbar + devbase + 256) == 0xffffffff) &&
460 (*(uint32_t *)(pciexbar + devbase + 512) == 0xffffffff) ) {
462 printf("Skipped non-PCIe device %02x:%02x.%01x\n", bus, dev, fn);
467 printf("\nPCIe %02x:%02x.%01x extended config space:", bus, dev, fn);
468 for (i = 0; i < 4096; i++) {
470 printf("\n%04x:", i);
471 printf(" %02x", *(pciexbar+devbase+i));
478 munmap((void *)pciexbar, (max_busses * 1024 * 1024));
483 int msr_readerror = 0;
485 msr_t rdmsr(int addr)
488 msr_t msr = { 0xffffffff, 0xffffffff };
490 if (lseek(fd_msr, (off_t) addr, SEEK_SET) == -1) {
491 perror("Could not lseek() to MSR");
496 if (read(fd_msr, buf, 8) == 8) {
497 msr.lo = *(uint32_t *)buf;
498 msr.hi = *(uint32_t *)(buf + 4);
504 printf(" (*)"); // Not all bits of the MSR could be read
508 perror("Could not read() MSR");
516 int print_intel_core_msrs(void)
518 unsigned int i, core;
521 #define IA32_PLATFORM_ID 0x0017
522 #define EBL_CR_POWERON 0x002a
523 #define FSB_CLK_STS 0x00cd
524 #define IA32_TIME_STAMP_COUNTER 0x0010
525 #define IA32_APIC_BASE 0x001b
532 msr_entry_t global_msrs[] = {
533 { 0x0017, "IA32_PLATFORM_ID" },
534 { 0x002a, "EBL_CR_POWERON" },
535 { 0x00cd, "FSB_CLOCK_STS" },
536 { 0x00ce, "FSB_CLOCK_VCC" },
537 { 0x00e2, "CLOCK_CST_CONFIG_CONTROL" },
538 { 0x00e3, "PMG_IO_BASE_ADDR" },
539 { 0x00e4, "PMG_IO_CAPTURE_ADDR" },
540 { 0x00ee, "EXT_CONFIG" },
541 { 0x011e, "BBL_CR_CTL3" },
542 { 0x0194, "CLOCK_FLEX_MAX" },
543 { 0x0198, "IA32_PERF_STATUS" },
544 { 0x01a0, "IA32_MISC_ENABLES" },
545 { 0x01aa, "PIC_SENS_CFG" },
546 { 0x0400, "IA32_MC0_CTL" },
547 { 0x0401, "IA32_MC0_STATUS" },
548 { 0x0402, "IA32_MC0_ADDR" },
549 //{ 0x0403, "IA32_MC0_MISC" }, // Seems to be RO
550 { 0x040c, "IA32_MC4_CTL" },
551 { 0x040d, "IA32_MC4_STATUS" },
552 { 0x040e, "IA32_MC4_ADDR" },
553 //{ 0x040f, "IA32_MC4_MISC" } // Seems to be RO
556 msr_entry_t per_core_msrs[] = {
557 { 0x0010, "IA32_TIME_STAMP_COUNTER" },
558 { 0x001b, "IA32_APIC_BASE" },
559 { 0x003a, "IA32_FEATURE_CONTROL" },
560 { 0x003f, "IA32_TEMPERATURE_OFFSET" },
561 //{ 0x0079, "IA32_BIOS_UPDT_TRIG" }, // Seems to be RO
562 { 0x008b, "IA32_BIOS_SIGN_ID" },
563 { 0x00e7, "IA32_MPERF" },
564 { 0x00e8, "IA32_APERF" },
565 { 0x00fe, "IA32_MTRRCAP" },
566 { 0x015f, "DTS_CAL_CTRL" },
567 { 0x0179, "IA32_MCG_CAP" },
568 { 0x017a, "IA32_MCG_STATUS" },
569 { 0x0199, "IA32_PERF_CONTROL" },
570 { 0x019a, "IA32_CLOCK_MODULATION" },
571 { 0x019b, "IA32_THERM_INTERRUPT" },
572 { 0x019c, "IA32_THERM_STATUS" },
573 { 0x019d, "GV_THERM" },
574 { 0x01d9, "IA32_DEBUGCTL" },
575 { 0x0200, "IA32_MTRR_PHYSBASE0" },
576 { 0x0201, "IA32_MTRR_PHYSMASK0" },
577 { 0x0202, "IA32_MTRR_PHYSBASE1" },
578 { 0x0203, "IA32_MTRR_PHYSMASK1" },
579 { 0x0204, "IA32_MTRR_PHYSBASE2" },
580 { 0x0205, "IA32_MTRR_PHYSMASK2" },
581 { 0x0206, "IA32_MTRR_PHYSBASE3" },
582 { 0x0207, "IA32_MTRR_PHYSMASK3" },
583 { 0x0208, "IA32_MTRR_PHYSBASE4" },
584 { 0x0209, "IA32_MTRR_PHYSMASK4" },
585 { 0x020a, "IA32_MTRR_PHYSBASE5" },
586 { 0x020b, "IA32_MTRR_PHYSMASK5" },
587 { 0x020c, "IA32_MTRR_PHYSBASE6" },
588 { 0x020d, "IA32_MTRR_PHYSMASK6" },
589 { 0x020e, "IA32_MTRR_PHYSBASE7" },
590 { 0x020f, "IA32_MTRR_PHYSMASK7" },
591 { 0x0250, "IA32_MTRR_FIX64K_00000" },
592 { 0x0258, "IA32_MTRR_FIX16K_80000" },
593 { 0x0259, "IA32_MTRR_FIX16K_A0000" },
594 { 0x0268, "IA32_MTRR_FIX4K_C0000" },
595 { 0x0269, "IA32_MTRR_FIX4K_C8000" },
596 { 0x026a, "IA32_MTRR_FIX4K_D0000" },
597 { 0x026b, "IA32_MTRR_FIX4K_D8000" },
598 { 0x026c, "IA32_MTRR_FIX4K_E0000" },
599 { 0x026d, "IA32_MTRR_FIX4K_E8000" },
600 { 0x026e, "IA32_MTRR_FIX4K_F0000" },
601 { 0x026f, "IA32_MTRR_FIX4K_F8000" },
602 { 0x02ff, "IA32_MTRR_DEF_TYPE" },
603 //{ 0x00c000080, "IA32_CR_EFER" }, // Seems to be RO
606 fd_msr = open("/dev/cpu/0/msr", O_RDWR);
608 perror("Error while opening /dev/cpu/0/msr");
609 printf("Did you run 'modprobe msr'?\n");
613 printf("\n===================== SHARED MSRs (All Cores) =====================\n");
615 for (i = 0; i < ARRAY_SIZE(global_msrs); i++) {
616 msr = rdmsr(global_msrs[i].number);
617 printf(" MSR 0x%08X = 0x%08X:0x%08X (%s)\n",
618 global_msrs[i].number, msr.hi, msr.lo,
619 global_msrs[i].name);
624 for (core = 0; core < 8; core++) {
625 char msrfilename[64];
626 memset(msrfilename, 0, 64);
627 sprintf(msrfilename, "/dev/cpu/%d/msr", core);
629 fd_msr = open(msrfilename, O_RDWR);
631 /* If the file is not there, we're probably through. No error,
632 * since we successfully opened /dev/cpu/0/msr before.
637 printf("\n====================== UNIQUE MSRs (core %d) ======================\n", core);
639 for (i = 0; i < ARRAY_SIZE(per_core_msrs); i++) {
640 msr = rdmsr(per_core_msrs[i].number);
641 printf(" MSR 0x%08X = 0x%08X:0x%08X (%s)\n",
642 per_core_msrs[i].number, msr.hi, msr.lo,
643 per_core_msrs[i].name);
650 printf("\n(*) Some MSRs could not be read. The marked values are unreliable.\n");
655 void print_version(void)
657 printf("inteltool v%s -- ", INTELTOOL_VERSION);
658 printf("Copyright (C) 2008 coresystems GmbH\n\n");
660 "This program is free software: you can redistribute it and/or modify\n"
661 "it under the terms of the GNU General Public License as published by\n"
662 "the Free Software Foundation, version 2 of the License.\n\n"
663 "This program is distributed in the hope that it will be useful,\n"
664 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
665 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
666 "GNU General Public License for more details.\n\n"
667 "You should have received a copy of the GNU General Public License\n"
668 "along with this program. If not, see <http://www.gnu.org/licenses/>.\n\n");
671 void print_usage(const char *name)
673 printf("usage: %s [-vh?grpmedPMa]\n", name);
675 " -v | --version: print the version\n"
676 " -h | --help: print this help\n\n"
677 " -g | --gpio: dump soutbridge GPIO registers\n"
678 " -r | --rcba: dump soutbridge RCBA registers\n"
679 " -p | --pmbase: dump soutbridge Power Management registers\n\n"
680 " -m | --mchbar: dump northbridge Memory Controller registers\n"
681 " -e | --epbar: dump northbridge EPBAR registers\n"
682 " -d | --dmibar: dump northbridge DMIBAR registers\n"
683 " -P | --pciexpress: dump northbridge PCIEXBAR registers\n\n"
684 " -M | --msrs: dump CPU MSRs\n"
685 " -a | --all: dump all known registers\n"
690 int main(int argc, char *argv[])
692 struct pci_access *pacc;
693 struct pci_dev *sb, *nb;
694 int i, opt, option_index = 0;
696 char *sbname = "unknown", *nbname = "unknown";
698 int dump_gpios = 0, dump_mchbar = 0, dump_rcba = 0;
699 int dump_pmbase = 0, dump_epbar = 0, dump_dmibar = 0;
700 int dump_pciexbar = 0, dump_coremsrs = 0;
702 static struct option long_options[] = {
703 {"version", 0, 0, 'v'},
705 {"gpios", 0, 0, 'g'},
706 {"mchbar", 0, 0, 'm'},
708 {"pmbase", 0, 0, 'p'},
709 {"epbar", 0, 0, 'e'},
710 {"dmibar", 0, 0, 'd'},
711 {"pciexpress", 0, 0, 'P'},
717 while ((opt = getopt_long(argc, argv, "vh?grpmedPMa",
718 long_options, &option_index)) != EOF) {
761 print_usage(argv[0]);
768 printf("You need to be root.\n");
772 if ((fd_mem = open("/dev/mem", O_RDWR)) < 0) {
773 perror("Can not open /dev/mem");
781 /* Find the required devices */
783 sb = pci_get_dev(pacc, 0, 0, 0x1f, 0);
785 printf("No southbridge found.\n");
789 pci_fill_info(sb, PCI_FILL_IDENT|PCI_FILL_BASES|PCI_FILL_SIZES|PCI_FILL_CLASS);
791 if (sb->vendor_id != PCI_VENDOR_ID_INTEL) {
792 printf("Not an Intel(R) southbridge.\n");
796 nb = pci_get_dev(pacc, 0, 0, 0x00, 0);
798 printf("No northbridge found.\n");
802 pci_fill_info(nb, PCI_FILL_IDENT|PCI_FILL_BASES|PCI_FILL_SIZES|PCI_FILL_CLASS);
804 if (nb->vendor_id != PCI_VENDOR_ID_INTEL) {
805 printf("Not an Intel(R) northbridge.\n");
809 /* TODO check cpuid, too */
811 /* Determine names */
812 for (i = 0; i < ARRAY_SIZE(supported_chips_list); i++)
813 if (nb->device_id == supported_chips_list[i].device_id)
814 nbname = supported_chips_list[i].name;
815 for (i = 0; i < ARRAY_SIZE(supported_chips_list); i++)
816 if (sb->device_id == supported_chips_list[i].device_id)
817 sbname = supported_chips_list[i].name;
819 printf("Intel Northbridge: %04x:%04x (%s)\n",
820 nb->vendor_id, nb->device_id, nbname);
822 printf("Intel Southbridge: %04x:%04x (%s)\n",
823 sb->vendor_id, sb->device_id, sbname);
825 /* Now do the deed */
863 print_intel_core_msrs();