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_ICH2 0x2440
40 #define PCI_DEVICE_ID_INTEL_ICH4 0x24c0
41 #define PCI_DEVICE_ID_INTEL_ICH4M 0x24cc
42 #define PCI_DEVICE_ID_INTEL_ICH7DH 0x27b0
43 #define PCI_DEVICE_ID_INTEL_ICH7 0x27b8
44 #define PCI_DEVICE_ID_INTEL_ICH7M 0x27b9
45 #define PCI_DEVICE_ID_INTEL_ICH7MDH 0x27bd
47 #define PCI_DEVICE_ID_INTEL_82845 0x1a30
48 #define PCI_DEVICE_ID_INTEL_82945GM 0x27a0
51 uint16_t vendor_id, device_id;
53 } supported_chips_list[] = {
54 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82845, "i845" },
55 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82945GM, "i945GM" },
56 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7MDH, "ICH7-M DH" },
57 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7M, "ICH7-M" },
58 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7, "ICH7" },
59 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7DH, "ICH7DH" },
60 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH4M, "ICH4-M" },
61 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH4, "ICH4" },
62 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH2, "ICH2" },
63 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH0, "ICH0" },
64 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH, "ICH" }
67 #define ARRAY_SIZE(a) ((int)(sizeof(a) / sizeof((a)[0])))
72 typedef struct { uint32_t hi, lo; } msr_t;
73 typedef struct { uint16_t addr; int size; char *name; } io_register_t;
75 static const io_register_t ich0_gpio_registers[] = {
76 { 0x00, 4, "GPIO_USE_SEL" },
77 { 0x04, 4, "GP_IO_SEL" },
78 { 0x08, 4, "RESERVED" },
79 { 0x0c, 4, "GP_LVL" },
80 { 0x10, 4, "RESERVED" },
81 { 0x14, 4, "GPO_TTL" },
82 { 0x18, 4, "GPO_BLINK" },
83 { 0x1c, 4, "RESERVED" },
84 { 0x20, 4, "RESERVED" },
85 { 0x24, 4, "RESERVED" },
86 { 0x28, 4, "RESERVED" },
87 { 0x2c, 4, "GPI_INV" },
88 { 0x30, 4, "RESERVED" },
89 { 0x34, 4, "RESERVED" },
90 { 0x38, 4, "RESERVED" },
91 { 0x3C, 4, "RESERVED" }
94 static const io_register_t ich4_gpio_registers[] = {
95 { 0x00, 4, "GPIO_USE_SEL" },
96 { 0x04, 4, "GP_IO_SEL" },
97 { 0x08, 4, "RESERVED" },
98 { 0x0c, 4, "GP_LVL" },
99 { 0x10, 4, "RESERVED" },
100 { 0x14, 4, "GPO_TTL" },
101 { 0x18, 4, "GPO_BLINK" },
102 { 0x1c, 4, "RESERVED" },
103 { 0x20, 4, "RESERVED" },
104 { 0x24, 4, "RESERVED" },
105 { 0x28, 4, "RESERVED" },
106 { 0x2c, 4, "GPI_INV" },
107 { 0x30, 4, "GPIO_USE_SEL2" },
108 { 0x34, 4, "GP_IO_SEL2" },
109 { 0x38, 4, "GP_LVL2" },
110 { 0x3C, 4, "RESERVED" }
113 static const io_register_t ich7_gpio_registers[] = {
114 { 0x00, 4, "GPIO_USE_SEL" },
115 { 0x04, 4, "GP_IO_SEL" },
116 { 0x08, 4, "RESERVED" },
117 { 0x0c, 4, "GP_LVL" },
118 { 0x10, 4, "RESERVED" },
119 { 0x14, 4, "RESERVED" },
120 { 0x18, 4, "GPO_BLINK" },
121 { 0x1c, 4, "RESERVED" },
122 { 0x20, 4, "RESERVED" },
123 { 0x24, 4, "RESERVED" },
124 { 0x28, 4, "RESERVED" },
125 { 0x2c, 4, "GPI_INV" },
126 { 0x30, 4, "GPIO_USE_SEL2" },
127 { 0x34, 4, "GP_IO_SEL2" },
128 { 0x38, 4, "GP_LVL2" },
129 { 0x3C, 4, "RESERVED" }
132 int print_gpios(struct pci_dev *sb)
136 const io_register_t *gpio_registers;
138 printf("\n============= GPIOS =============\n\n");
140 switch (sb->device_id) {
141 case PCI_DEVICE_ID_INTEL_ICH7:
142 case PCI_DEVICE_ID_INTEL_ICH7M:
143 case PCI_DEVICE_ID_INTEL_ICH7DH:
144 case PCI_DEVICE_ID_INTEL_ICH7MDH:
145 gpiobase = pci_read_word(sb, 0x48) & 0xfffc;
146 gpio_registers = ich7_gpio_registers;
147 size = ARRAY_SIZE(ich7_gpio_registers);
149 case PCI_DEVICE_ID_INTEL_ICH4:
150 case PCI_DEVICE_ID_INTEL_ICH4M:
151 gpiobase = pci_read_word(sb, 0x58) & 0xfffc;
152 gpio_registers = ich4_gpio_registers;
153 size = ARRAY_SIZE(ich4_gpio_registers);
155 case PCI_DEVICE_ID_INTEL_ICH:
156 case PCI_DEVICE_ID_INTEL_ICH0:
157 gpiobase = pci_read_word(sb, 0x58) & 0xfffc;
158 gpio_registers = ich0_gpio_registers;
159 size = ARRAY_SIZE(ich0_gpio_registers);
161 case 0x1234: // Dummy for non-existent functionality
162 printf("This southbridge does not have GPIOBASE.\n");
165 printf("Error: Dumping GPIOs on this southbridge is not (yet) supported.\n");
169 printf("GPIOBASE = 0x%04x (IO)\n\n", gpiobase);
171 for (i = 0; i < size; i++) {
172 switch (gpio_registers[i].size) {
174 printf("gpiobase+0x%04x: 0x%08x (%s)\n",
175 gpio_registers[i].addr,
176 inl(gpiobase+gpio_registers[i].addr),
177 gpio_registers[i].name);
180 printf("gpiobase+0x%04x: 0x%04x (%s)\n",
181 gpio_registers[i].addr,
182 inw(gpiobase+gpio_registers[i].addr),
183 gpio_registers[i].name);
186 printf("gpiobase+0x%04x: 0x%02x (%s)\n",
187 gpio_registers[i].addr,
188 inb(gpiobase+gpio_registers[i].addr),
189 gpio_registers[i].name);
197 int print_rcba(struct pci_dev *sb)
199 int i, size = 0x4000;
200 volatile uint8_t *rcba;
203 printf("\n============= RCBA ==============\n\n");
205 switch (sb->device_id) {
206 case PCI_DEVICE_ID_INTEL_ICH7:
207 case PCI_DEVICE_ID_INTEL_ICH7M:
208 case PCI_DEVICE_ID_INTEL_ICH7DH:
209 case PCI_DEVICE_ID_INTEL_ICH7MDH:
210 rcba_phys = pci_read_long(sb, 0xf0) & 0xfffffffe;
212 case PCI_DEVICE_ID_INTEL_ICH:
213 case PCI_DEVICE_ID_INTEL_ICH0:
214 case PCI_DEVICE_ID_INTEL_ICH4:
215 case PCI_DEVICE_ID_INTEL_ICH4M:
216 printf("This southbridge does not have RCBA.\n");
219 printf("Error: Dumping RCBA on this southbridge is not (yet) supported.\n");
223 rcba = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
224 fd_mem, (off_t) rcba_phys);
226 if (rcba == MAP_FAILED) {
227 perror("Error mapping RCBA");
231 printf("RCBA = 0x%08x (MEM)\n\n", rcba_phys);
233 for (i = 0; i < size; i += 4) {
234 if (*(uint32_t *)(rcba + i))
235 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(rcba + i));
238 munmap((void *)rcba, size);
242 int print_pmbase(struct pci_dev *sb)
247 printf("\n============= PMBASE ============\n\n");
249 switch (sb->device_id) {
250 case PCI_DEVICE_ID_INTEL_ICH7:
251 case PCI_DEVICE_ID_INTEL_ICH7M:
252 case PCI_DEVICE_ID_INTEL_ICH7DH:
253 case PCI_DEVICE_ID_INTEL_ICH7MDH:
254 pmbase = pci_read_word(sb, 0x40) & 0xfffc;
256 case 0x1234: // Dummy for non-existent functionality
257 printf("This southbridge does not have PMBASE.\n");
260 printf("Error: Dumping PMBASE on this southbridge is not (yet) supported.\n");
264 printf("PMBASE = 0x%04x (IO)\n\n", pmbase);
266 for (i = 0; i < size; i += 4) {
267 printf("pmbase+0x%04x: 0x%08x\n", i, inl(pmbase + i));
274 * (G)MCH MMIO Config Space
276 int print_mchbar(struct pci_dev *nb)
278 int i, size = (16 * 1024);
279 volatile uint8_t *mchbar;
280 uint32_t mchbar_phys;
282 printf("\n============= MCHBAR ============\n\n");
284 switch (nb->device_id) {
285 case PCI_DEVICE_ID_INTEL_82945GM:
286 mchbar_phys = pci_read_long(nb, 0x44) & 0xfffffffe;
288 case 0x1234: // Dummy for non-existent functionality
289 printf("This northbrigde does not have MCHBAR.\n");
292 printf("Error: Dumping MCHBAR on this northbridge is not (yet) supported.\n");
296 mchbar = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
297 fd_mem, (off_t) mchbar_phys);
299 if (mchbar == MAP_FAILED) {
300 perror("Error mapping MCHBAR");
304 printf("MCHBAR = 0x%08x (MEM)\n\n", mchbar_phys);
306 for (i = 0; i < size; i += 4) {
307 if (*(uint32_t *)(mchbar + i))
308 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(mchbar+i));
311 munmap((void *)mchbar, size);
316 * Egress Port Root Complex MMIO configuration space
318 int print_epbar(struct pci_dev *nb)
320 int i, size = (4 * 1024);
321 volatile uint8_t *epbar;
324 printf("\n============= EPBAR =============\n\n");
326 switch (nb->device_id) {
327 case PCI_DEVICE_ID_INTEL_82945GM:
328 epbar_phys = pci_read_long(nb, 0x40) & 0xfffffffe;
330 case 0x1234: // Dummy for non-existent functionality
331 printf("This northbrigde does not have EPBAR.\n");
334 printf("Error: Dumping EPBAR on this northbridge is not (yet) supported.\n");
338 epbar = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
339 fd_mem, (off_t) epbar_phys);
341 if (epbar == MAP_FAILED) {
342 perror("Error mapping EPBAR");
346 printf("EPBAR = 0x%08x (MEM)\n\n", epbar_phys);
347 for (i = 0; i < size; i += 4) {
348 if (*(uint32_t *)(epbar + i))
349 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(epbar+i));
352 munmap((void *)epbar, size);
357 * MCH-ICH Serial Interconnect Ingress Root Complex MMIO configuration space
359 int print_dmibar(struct pci_dev *nb)
361 int i, size = (4 * 1024);
362 volatile uint8_t *dmibar;
363 uint32_t dmibar_phys;
365 printf("\n============= DMIBAR ============\n\n");
367 switch (nb->device_id) {
368 case PCI_DEVICE_ID_INTEL_82945GM:
369 dmibar_phys = pci_read_long(nb, 0x4c) & 0xfffffffe;
371 case 0x1234: // Dummy for non-existent functionality
372 printf("This northbrigde does not have DMIBAR.\n");
375 printf("Error: Dumping DMIBAR on this northbridge is not (yet) supported.\n");
379 dmibar = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
380 fd_mem, (off_t) dmibar_phys);
382 if (dmibar == MAP_FAILED) {
383 perror("Error mapping DMIBAR");
387 printf("DMIBAR = 0x%08x (MEM)\n\n", dmibar_phys);
388 for (i = 0; i < size; i += 4) {
389 if (*(uint32_t *)(dmibar + i))
390 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(dmibar+i));
393 munmap((void *)dmibar, size);
398 * PCIe MMIO configuration space
400 int print_pciexbar(struct pci_dev *nb)
402 uint32_t pciexbar_reg;
403 uint32_t pciexbar_phys;
404 volatile uint8_t *pciexbar;
405 int max_busses, devbase, i;
408 printf("========= PCIEXBAR ========\n\n");
410 switch (nb->device_id) {
411 case PCI_DEVICE_ID_INTEL_82945GM:
412 pciexbar_reg = pci_read_long(nb, 0x48);
414 case 0x1234: // Dummy for non-existent functionality
415 printf("Error: This northbrigde does not have PCIEXBAR.\n");
418 printf("Error: Dumping PCIEXBAR on this northbridge is not (yet) supported.\n");
422 if (!(pciexbar_reg & (1 << 0))) {
423 printf("PCIEXBAR register is disabled.\n");
427 switch ((pciexbar_reg >> 1) & 3) {
429 pciexbar_phys = pciexbar_reg & ((1 << 31)|(1 << 30)|(1 << 29)|(1 << 28));
433 pciexbar_phys = pciexbar_reg & ((1 << 31)|(1 << 30)|(1 << 29)|(1 << 28)|(1 << 27));
437 pciexbar_phys = pciexbar_reg & ((1 << 31)|(1 << 30)|(1 << 29)|(1 << 28)|(1 << 27)|(1 << 26));
441 printf("Undefined address base. Bailing out.\n");
445 printf("PCIEXBAR: 0x%08x\n", pciexbar_phys);
447 pciexbar = mmap(0, (max_busses * 1024 * 1024), PROT_WRITE | PROT_READ,
448 MAP_SHARED, fd_mem, (off_t) pciexbar_phys);
450 if (pciexbar == MAP_FAILED) {
451 perror("Error mapping PCIEXBAR");
455 for (bus = 0; bus < max_busses; bus++) {
456 for (dev = 0; dev < 32; dev++) {
457 for (fn = 0; fn < 8; fn++) {
458 devbase = (bus * 1024 * 1024) + (dev * 32 * 1024) + (fn * 4 * 1024);
460 if (*(uint16_t *)(pciexbar + devbase) == 0xffff)
463 /* This is a heuristics. Anyone got a better check? */
464 if( (*(uint32_t *)(pciexbar + devbase + 256) == 0xffffffff) &&
465 (*(uint32_t *)(pciexbar + devbase + 512) == 0xffffffff) ) {
467 printf("Skipped non-PCIe device %02x:%02x.%01x\n", bus, dev, fn);
472 printf("\nPCIe %02x:%02x.%01x extended config space:", bus, dev, fn);
473 for (i = 0; i < 4096; i++) {
475 printf("\n%04x:", i);
476 printf(" %02x", *(pciexbar+devbase+i));
483 munmap((void *)pciexbar, (max_busses * 1024 * 1024));
488 int msr_readerror = 0;
490 msr_t rdmsr(int addr)
493 msr_t msr = { 0xffffffff, 0xffffffff };
495 if (lseek(fd_msr, (off_t) addr, SEEK_SET) == -1) {
496 perror("Could not lseek() to MSR");
501 if (read(fd_msr, buf, 8) == 8) {
502 msr.lo = *(uint32_t *)buf;
503 msr.hi = *(uint32_t *)(buf + 4);
509 printf(" (*)"); // Not all bits of the MSR could be read
513 perror("Could not read() MSR");
521 int print_intel_core_msrs(void)
523 unsigned int i, core;
526 #define IA32_PLATFORM_ID 0x0017
527 #define EBL_CR_POWERON 0x002a
528 #define FSB_CLK_STS 0x00cd
529 #define IA32_TIME_STAMP_COUNTER 0x0010
530 #define IA32_APIC_BASE 0x001b
537 msr_entry_t global_msrs[] = {
538 { 0x0017, "IA32_PLATFORM_ID" },
539 { 0x002a, "EBL_CR_POWERON" },
540 { 0x00cd, "FSB_CLOCK_STS" },
541 { 0x00ce, "FSB_CLOCK_VCC" },
542 { 0x00e2, "CLOCK_CST_CONFIG_CONTROL" },
543 { 0x00e3, "PMG_IO_BASE_ADDR" },
544 { 0x00e4, "PMG_IO_CAPTURE_ADDR" },
545 { 0x00ee, "EXT_CONFIG" },
546 { 0x011e, "BBL_CR_CTL3" },
547 { 0x0194, "CLOCK_FLEX_MAX" },
548 { 0x0198, "IA32_PERF_STATUS" },
549 { 0x01a0, "IA32_MISC_ENABLES" },
550 { 0x01aa, "PIC_SENS_CFG" },
551 { 0x0400, "IA32_MC0_CTL" },
552 { 0x0401, "IA32_MC0_STATUS" },
553 { 0x0402, "IA32_MC0_ADDR" },
554 //{ 0x0403, "IA32_MC0_MISC" }, // Seems to be RO
555 { 0x040c, "IA32_MC4_CTL" },
556 { 0x040d, "IA32_MC4_STATUS" },
557 { 0x040e, "IA32_MC4_ADDR" },
558 //{ 0x040f, "IA32_MC4_MISC" } // Seems to be RO
561 msr_entry_t per_core_msrs[] = {
562 { 0x0010, "IA32_TIME_STAMP_COUNTER" },
563 { 0x001b, "IA32_APIC_BASE" },
564 { 0x003a, "IA32_FEATURE_CONTROL" },
565 { 0x003f, "IA32_TEMPERATURE_OFFSET" },
566 //{ 0x0079, "IA32_BIOS_UPDT_TRIG" }, // Seems to be RO
567 { 0x008b, "IA32_BIOS_SIGN_ID" },
568 { 0x00e7, "IA32_MPERF" },
569 { 0x00e8, "IA32_APERF" },
570 { 0x00fe, "IA32_MTRRCAP" },
571 { 0x015f, "DTS_CAL_CTRL" },
572 { 0x0179, "IA32_MCG_CAP" },
573 { 0x017a, "IA32_MCG_STATUS" },
574 { 0x0199, "IA32_PERF_CONTROL" },
575 { 0x019a, "IA32_CLOCK_MODULATION" },
576 { 0x019b, "IA32_THERM_INTERRUPT" },
577 { 0x019c, "IA32_THERM_STATUS" },
578 { 0x019d, "GV_THERM" },
579 { 0x01d9, "IA32_DEBUGCTL" },
580 { 0x0200, "IA32_MTRR_PHYSBASE0" },
581 { 0x0201, "IA32_MTRR_PHYSMASK0" },
582 { 0x0202, "IA32_MTRR_PHYSBASE1" },
583 { 0x0203, "IA32_MTRR_PHYSMASK1" },
584 { 0x0204, "IA32_MTRR_PHYSBASE2" },
585 { 0x0205, "IA32_MTRR_PHYSMASK2" },
586 { 0x0206, "IA32_MTRR_PHYSBASE3" },
587 { 0x0207, "IA32_MTRR_PHYSMASK3" },
588 { 0x0208, "IA32_MTRR_PHYSBASE4" },
589 { 0x0209, "IA32_MTRR_PHYSMASK4" },
590 { 0x020a, "IA32_MTRR_PHYSBASE5" },
591 { 0x020b, "IA32_MTRR_PHYSMASK5" },
592 { 0x020c, "IA32_MTRR_PHYSBASE6" },
593 { 0x020d, "IA32_MTRR_PHYSMASK6" },
594 { 0x020e, "IA32_MTRR_PHYSBASE7" },
595 { 0x020f, "IA32_MTRR_PHYSMASK7" },
596 { 0x0250, "IA32_MTRR_FIX64K_00000" },
597 { 0x0258, "IA32_MTRR_FIX16K_80000" },
598 { 0x0259, "IA32_MTRR_FIX16K_A0000" },
599 { 0x0268, "IA32_MTRR_FIX4K_C0000" },
600 { 0x0269, "IA32_MTRR_FIX4K_C8000" },
601 { 0x026a, "IA32_MTRR_FIX4K_D0000" },
602 { 0x026b, "IA32_MTRR_FIX4K_D8000" },
603 { 0x026c, "IA32_MTRR_FIX4K_E0000" },
604 { 0x026d, "IA32_MTRR_FIX4K_E8000" },
605 { 0x026e, "IA32_MTRR_FIX4K_F0000" },
606 { 0x026f, "IA32_MTRR_FIX4K_F8000" },
607 { 0x02ff, "IA32_MTRR_DEF_TYPE" },
608 //{ 0x00c000080, "IA32_CR_EFER" }, // Seems to be RO
611 fd_msr = open("/dev/cpu/0/msr", O_RDWR);
613 perror("Error while opening /dev/cpu/0/msr");
614 printf("Did you run 'modprobe msr'?\n");
618 printf("\n===================== SHARED MSRs (All Cores) =====================\n");
620 for (i = 0; i < ARRAY_SIZE(global_msrs); i++) {
621 msr = rdmsr(global_msrs[i].number);
622 printf(" MSR 0x%08X = 0x%08X:0x%08X (%s)\n",
623 global_msrs[i].number, msr.hi, msr.lo,
624 global_msrs[i].name);
629 for (core = 0; core < 8; core++) {
630 char msrfilename[64];
631 memset(msrfilename, 0, 64);
632 sprintf(msrfilename, "/dev/cpu/%d/msr", core);
634 fd_msr = open(msrfilename, O_RDWR);
636 /* If the file is not there, we're probably through. No error,
637 * since we successfully opened /dev/cpu/0/msr before.
642 printf("\n====================== UNIQUE MSRs (core %d) ======================\n", core);
644 for (i = 0; i < ARRAY_SIZE(per_core_msrs); i++) {
645 msr = rdmsr(per_core_msrs[i].number);
646 printf(" MSR 0x%08X = 0x%08X:0x%08X (%s)\n",
647 per_core_msrs[i].number, msr.hi, msr.lo,
648 per_core_msrs[i].name);
655 printf("\n(*) Some MSRs could not be read. The marked values are unreliable.\n");
660 void print_version(void)
662 printf("inteltool v%s -- ", INTELTOOL_VERSION);
663 printf("Copyright (C) 2008 coresystems GmbH\n\n");
665 "This program is free software: you can redistribute it and/or modify\n"
666 "it under the terms of the GNU General Public License as published by\n"
667 "the Free Software Foundation, version 2 of the License.\n\n"
668 "This program is distributed in the hope that it will be useful,\n"
669 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
670 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
671 "GNU General Public License for more details.\n\n"
672 "You should have received a copy of the GNU General Public License\n"
673 "along with this program. If not, see <http://www.gnu.org/licenses/>.\n\n");
676 void print_usage(const char *name)
678 printf("usage: %s [-vh?grpmedPMa]\n", name);
680 " -v | --version: print the version\n"
681 " -h | --help: print this help\n\n"
682 " -g | --gpio: dump soutbridge GPIO registers\n"
683 " -r | --rcba: dump soutbridge RCBA registers\n"
684 " -p | --pmbase: dump soutbridge Power Management registers\n\n"
685 " -m | --mchbar: dump northbridge Memory Controller registers\n"
686 " -e | --epbar: dump northbridge EPBAR registers\n"
687 " -d | --dmibar: dump northbridge DMIBAR registers\n"
688 " -P | --pciexpress: dump northbridge PCIEXBAR registers\n\n"
689 " -M | --msrs: dump CPU MSRs\n"
690 " -a | --all: dump all known registers\n"
695 int main(int argc, char *argv[])
697 struct pci_access *pacc;
698 struct pci_dev *sb, *nb;
699 int i, opt, option_index = 0;
701 char *sbname = "unknown", *nbname = "unknown";
703 int dump_gpios = 0, dump_mchbar = 0, dump_rcba = 0;
704 int dump_pmbase = 0, dump_epbar = 0, dump_dmibar = 0;
705 int dump_pciexbar = 0, dump_coremsrs = 0;
707 static struct option long_options[] = {
708 {"version", 0, 0, 'v'},
710 {"gpios", 0, 0, 'g'},
711 {"mchbar", 0, 0, 'm'},
713 {"pmbase", 0, 0, 'p'},
714 {"epbar", 0, 0, 'e'},
715 {"dmibar", 0, 0, 'd'},
716 {"pciexpress", 0, 0, 'P'},
722 while ((opt = getopt_long(argc, argv, "vh?grpmedPMa",
723 long_options, &option_index)) != EOF) {
766 print_usage(argv[0]);
773 printf("You need to be root.\n");
777 if ((fd_mem = open("/dev/mem", O_RDWR)) < 0) {
778 perror("Can not open /dev/mem");
786 /* Find the required devices */
788 sb = pci_get_dev(pacc, 0, 0, 0x1f, 0);
790 printf("No southbridge found.\n");
794 pci_fill_info(sb, PCI_FILL_IDENT|PCI_FILL_BASES|PCI_FILL_SIZES|PCI_FILL_CLASS);
796 if (sb->vendor_id != PCI_VENDOR_ID_INTEL) {
797 printf("Not an Intel(R) southbridge.\n");
801 nb = pci_get_dev(pacc, 0, 0, 0x00, 0);
803 printf("No northbridge found.\n");
807 pci_fill_info(nb, PCI_FILL_IDENT|PCI_FILL_BASES|PCI_FILL_SIZES|PCI_FILL_CLASS);
809 if (nb->vendor_id != PCI_VENDOR_ID_INTEL) {
810 printf("Not an Intel(R) northbridge.\n");
814 /* TODO check cpuid, too */
816 /* Determine names */
817 for (i = 0; i < ARRAY_SIZE(supported_chips_list); i++)
818 if (nb->device_id == supported_chips_list[i].device_id)
819 nbname = supported_chips_list[i].name;
820 for (i = 0; i < ARRAY_SIZE(supported_chips_list); i++)
821 if (sb->device_id == supported_chips_list[i].device_id)
822 sbname = supported_chips_list[i].name;
824 printf("Intel Northbridge: %04x:%04x (%s)\n",
825 nb->vendor_id, nb->device_id, nbname);
827 printf("Intel Southbridge: %04x:%04x (%s)\n",
828 sb->vendor_id, sb->device_id, sbname);
830 /* Now do the deed */
868 print_intel_core_msrs();