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" }
65 #define ARRAY_SIZE(a) ((int)(sizeof(a) / sizeof((a)[0])))
70 typedef struct { uint32_t hi, lo; } msr_t;
71 typedef struct { uint16_t addr; int size; char *name; } io_register_t;
74 static const io_register_t ich0_gpio_registers[] = {
75 { 0x00, 4, "GPIO_USE_SEL" },
76 { 0x04, 4, "GP_IO_SEL" },
77 { 0x08, 4, "RESERVED" },
78 { 0x0c, 4, "GP_LVL" },
79 { 0x10, 4, "RESERVED" },
80 { 0x14, 4, "GPO_TTL" },
81 { 0x18, 4, "GPO_BLINK" },
82 { 0x1c, 4, "RESERVED" },
83 { 0x20, 4, "RESERVED" },
84 { 0x24, 4, "RESERVED" },
85 { 0x28, 4, "RESERVED" },
86 { 0x2c, 4, "GPI_INV" },
87 { 0x30, 4, "RESERVED" },
88 { 0x34, 4, "RESERVED" },
89 { 0x38, 4, "RESERVED" },
90 { 0x3C, 4, "RESERVED" }
93 static const io_register_t ich4_gpio_registers[] = {
94 { 0x00, 4, "GPIO_USE_SEL" },
95 { 0x04, 4, "GP_IO_SEL" },
96 { 0x08, 4, "RESERVED" },
97 { 0x0c, 4, "GP_LVL" },
98 { 0x10, 4, "RESERVED" },
99 { 0x14, 4, "GPO_TTL" },
100 { 0x18, 4, "GPO_BLINK" },
101 { 0x1c, 4, "RESERVED" },
102 { 0x20, 4, "RESERVED" },
103 { 0x24, 4, "RESERVED" },
104 { 0x28, 4, "RESERVED" },
105 { 0x2c, 4, "GPI_INV" },
106 { 0x30, 4, "GPIO_USE_SEL2" },
107 { 0x34, 4, "GP_IO_SEL2" },
108 { 0x38, 4, "GP_LVL2" },
109 { 0x3C, 4, "RESERVED" }
112 static const io_register_t ich7_gpio_registers[] = {
113 { 0x00, 4, "GPIO_USE_SEL" },
114 { 0x04, 4, "GP_IO_SEL" },
115 { 0x08, 4, "RESERVED" },
116 { 0x0c, 4, "GP_LVL" },
117 { 0x10, 4, "RESERVED" },
118 { 0x14, 4, "RESERVED" },
119 { 0x18, 4, "GPO_BLINK" },
120 { 0x1c, 4, "RESERVED" },
121 { 0x20, 4, "RESERVED" },
122 { 0x24, 4, "RESERVED" },
123 { 0x28, 4, "RESERVED" },
124 { 0x2c, 4, "GPI_INV" },
125 { 0x30, 4, "GPIO_USE_SEL2" },
126 { 0x34, 4, "GP_IO_SEL2" },
127 { 0x38, 4, "GP_LVL2" },
128 { 0x3C, 4, "RESERVED" }
131 int print_gpios(struct pci_dev *sb)
135 const io_register_t *gpio_registers;
137 printf("\n============= GPIOS =============\n\n");
139 switch (sb->device_id) {
140 case PCI_DEVICE_ID_INTEL_ICH7:
141 case PCI_DEVICE_ID_INTEL_ICH7M:
142 case PCI_DEVICE_ID_INTEL_ICH7DH:
143 case PCI_DEVICE_ID_INTEL_ICH7MDH:
144 gpiobase = pci_read_word(sb, 0x48) & 0xfffc;
145 gpio_registers = ich7_gpio_registers;
146 size = ARRAY_SIZE(ich7_gpio_registers);
148 case PCI_DEVICE_ID_INTEL_ICH4:
149 case PCI_DEVICE_ID_INTEL_ICH4M:
150 gpiobase = pci_read_word(sb, 0x58) & 0xfffc;
151 gpio_registers = ich4_gpio_registers;
152 size = ARRAY_SIZE(ich4_gpio_registers);
154 case PCI_DEVICE_ID_INTEL_ICH:
155 case PCI_DEVICE_ID_INTEL_ICH0:
156 gpiobase = pci_read_word(sb, 0x58) & 0xfffc;
157 gpio_registers = ich0_gpio_registers;
158 size = ARRAY_SIZE(ich0_gpio_registers);
160 case 0x1234: // Dummy for non-existent functionality
161 printf("This southbridge does not have GPIOBASE.\n");
164 printf("Error: Dumping GPIOs on this southbridge is not (yet) supported.\n");
168 printf("GPIOBASE = 0x%04x (IO)\n\n", gpiobase);
170 for (i=0; i<size; i++) {
171 switch (gpio_registers[i].size) {
173 printf("gpiobase+0x%04x: 0x%08x (%s)\n",
174 gpio_registers[i].addr,
175 inl(gpiobase+gpio_registers[i].addr),
176 gpio_registers[i].name);
179 printf("gpiobase+0x%04x: 0x%04x (%s)\n",
180 gpio_registers[i].addr,
181 inw(gpiobase+gpio_registers[i].addr),
182 gpio_registers[i].name);
185 printf("gpiobase+0x%04x: 0x%02x (%s)\n",
186 gpio_registers[i].addr,
187 inb(gpiobase+gpio_registers[i].addr),
188 gpio_registers[i].name);
196 int print_rcba(struct pci_dev *sb)
199 volatile uint8_t *rcba;
202 printf("\n============= RCBA ==============\n\n");
204 switch (sb->device_id) {
205 case PCI_DEVICE_ID_INTEL_ICH7:
206 case PCI_DEVICE_ID_INTEL_ICH7M:
207 case PCI_DEVICE_ID_INTEL_ICH7DH:
208 case PCI_DEVICE_ID_INTEL_ICH7MDH:
209 rcba_phys = pci_read_long(sb, 0xf0) & 0xfffffffe;
211 case PCI_DEVICE_ID_INTEL_ICH:
212 case PCI_DEVICE_ID_INTEL_ICH0:
213 case PCI_DEVICE_ID_INTEL_ICH4:
214 case PCI_DEVICE_ID_INTEL_ICH4M:
215 printf("This southbridge does not have RCBA.\n");
218 printf("Error: Dumping RCBA on this southbridge is not (yet) supported.\n");
222 rcba = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
223 fd_mem, (off_t) rcba_phys);
225 if (rcba == MAP_FAILED) {
226 perror("Error mapping RCBA");
230 printf("RCBA = 0x%08x (MEM)\n\n", rcba_phys);
232 for (i=0; i<size; i+=4) {
233 if(*(uint32_t *)(rcba+i))
234 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(rcba+i));
237 munmap((void *) rcba, size);
241 int print_pmbase(struct pci_dev *sb)
246 printf("\n============= PMBASE ============\n\n");
248 switch (sb->device_id) {
249 case PCI_DEVICE_ID_INTEL_ICH7:
250 case PCI_DEVICE_ID_INTEL_ICH7M:
251 case PCI_DEVICE_ID_INTEL_ICH7DH:
252 case PCI_DEVICE_ID_INTEL_ICH7MDH:
253 pmbase = pci_read_word(sb, 0x40) & 0xfffc;
255 case 0x1234: // Dummy for non-existent functionality
256 printf("This southbridge does not have PMBASE.\n");
259 printf("Error: Dumping PMBASE on this southbridge is not (yet) supported.\n");
263 printf("PMBASE = 0x%04x (IO)\n\n", pmbase);
265 for (i=0; i<size; i+=4) {
266 printf("pmbase+0x%04x: 0x%08x\n", i, inl(pmbase+i));
273 * (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)
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);
358 * MCH-ICH Serial Interconnect Ingress Root Complex MMIO configuration space
360 int print_dmibar(struct pci_dev *nb)
363 volatile uint8_t *dmibar;
364 uint32_t dmibar_phys;
366 printf("\n============= DMIBAR ============\n\n");
368 switch (nb->device_id) {
369 case PCI_DEVICE_ID_INTEL_82945GM:
370 dmibar_phys = pci_read_long(nb, 0x4c) & 0xfffffffe;
372 case 0x1234: // Dummy for non-existent functionality
373 printf("This northbrigde does not have DMIBAR.\n");
376 printf("Error: Dumping DMIBAR on this northbridge is not (yet) supported.\n");
380 dmibar = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
381 fd_mem, (off_t) dmibar_phys );
383 if (dmibar == MAP_FAILED) {
384 perror("Error mapping DMIBAR");
388 printf("DMIBAR = 0x%08x (MEM)\n\n", dmibar_phys);
389 for (i=0; i<size; i+=4) {
390 if(*(uint32_t *)(dmibar+i))
391 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(dmibar+i));
394 munmap((void *) dmibar, size);
399 * PCIe MMIO configuration space
401 int print_pciexbar(struct pci_dev *nb)
403 uint32_t pciexbar_reg;
404 uint32_t pciexbar_phys;
405 volatile uint8_t *pciexbar;
406 int max_busses, devbase, i;
409 printf("========= PCIEXBAR ========\n\n");
411 switch (nb->device_id) {
412 case PCI_DEVICE_ID_INTEL_82945GM:
413 pciexbar_reg = pci_read_long(nb, 0x48);
415 case 0x1234: // Dummy for non-existent functionality
416 printf("Error: This northbrigde does not have PCIEXBAR.\n");
419 printf("Error: Dumping PCIEXBAR on this northbridge is not (yet) supported.\n");
423 if( !(pciexbar_reg & (1 << 0))) {
424 printf("PCIEXBAR register is disabled.\n");
428 switch ((pciexbar_reg >> 1) & 3) {
430 pciexbar_phys = pciexbar_reg & ((1 << 31)|(1 << 30)|(1 << 29)|(1 << 28));
434 pciexbar_phys = pciexbar_reg & ((1 << 31)|(1 << 30)|(1 << 29)|(1 << 28)|(1 << 27));
438 pciexbar_phys = pciexbar_reg & ((1 << 31)|(1 << 30)|(1 << 29)|(1 << 28)|(1 << 27)|(1 << 26));
442 printf("Undefined Address base. Bailing out\n");
446 printf("PCIEXBAR: 0x%08x\n", pciexbar_phys);
448 pciexbar = mmap(0, (max_busses * 1024 * 1024), PROT_WRITE | PROT_READ, MAP_SHARED,
449 fd_mem, (off_t) pciexbar_phys );
451 if (pciexbar == MAP_FAILED) {
452 perror("Error mapping PCIEXBAR");
456 for (bus = 0; bus < max_busses; bus++) {
457 for (dev = 0; dev < 32; dev++) {
458 for (fn = 0; fn < 8; fn++) {
459 devbase = (bus * 1024 * 1024) + (dev * 32 * 1024) + (fn * 4 * 1024);
461 if (*(uint16_t *)(pciexbar + devbase) == 0xffff)
464 /* This is a heuristics. Anyone got a better check? */
465 if( (*(uint32_t *)(pciexbar + devbase + 256) == 0xffffffff) &&
466 (*(uint32_t *)(pciexbar + devbase + 512) == 0xffffffff) ) {
468 printf("Skipped non-PCIe device %02x:%02x.%01x\n", bus, dev, fn);
473 printf("\nPCIe %02x:%02x.%01x extended config space:", bus, dev, fn);
474 for (i=0; i<4096; i++) {
476 printf("\n%04x:", i);
477 printf(" %02x", *(pciexbar+devbase+i));
484 munmap((void *) pciexbar, (max_busses * 1024 * 1024));
489 int msr_readerror = 0;
491 msr_t rdmsr(int addr)
493 unsigned char buf[8];
494 msr_t msr = { 0xffffffff, 0xffffffff };
496 if (lseek(fd_msr, (off_t) addr, SEEK_SET) == -1) {
497 perror("Could not lseek() to MSR");
502 if (read(fd_msr, buf, 8) == 8) {
503 msr.lo = *(uint32_t *)buf;
504 msr.hi = *(uint32_t *)(buf+4);
510 printf(" (*)"); // Not all bits of the MSR could be read
514 perror("Could not read() MSR");
522 int print_intel_core_msrs(void)
524 unsigned int i, core;
528 #define IA32_PLATFORM_ID 0x0017
529 #define EBL_CR_POWERON 0x002a
530 #define FSB_CLK_STS 0x00cd
531 #define IA32_TIME_STAMP_COUNTER 0x0010
532 #define IA32_APIC_BASE 0x001b
539 msr_entry_t global_msrs[] = {
540 { 0x0017, "IA32_PLATFORM_ID" },
541 { 0x002a, "EBL_CR_POWERON" },
542 { 0x00cd, "FSB_CLOCK_STS" },
543 { 0x00ce, "FSB_CLOCK_VCC" },
544 { 0x00e2, "CLOCK_CST_CONFIG_CONTROL" },
545 { 0x00e3, "PMG_IO_BASE_ADDR" },
546 { 0x00e4, "PMG_IO_CAPTURE_ADDR" },
547 { 0x00ee, "EXT_CONFIG" },
548 { 0x011e, "BBL_CR_CTL3" },
549 { 0x0194, "CLOCK_FLEX_MAX" },
550 { 0x0198, "IA32_PERF_STATUS" },
551 { 0x01a0, "IA32_MISC_ENABLES" },
552 { 0x01aa, "PIC_SENS_CFG" },
553 { 0x0400, "IA32_MC0_CTL" },
554 { 0x0401, "IA32_MC0_STATUS" },
555 { 0x0402, "IA32_MC0_ADDR" },
556 //{ 0x0403, "IA32_MC0_MISC" }, // Seems to be RO
557 { 0x040c, "IA32_MC4_CTL" },
558 { 0x040d, "IA32_MC4_STATUS" },
559 { 0x040e, "IA32_MC4_ADDR" },
560 //{ 0x040f, "IA32_MC4_MISC" } // Seems to be RO
563 msr_entry_t per_core_msrs[] = {
564 { 0x0010, "IA32_TIME_STAMP_COUNTER" },
565 { 0x001b, "IA32_APIC_BASE" },
566 { 0x003a, "IA32_FEATURE_CONTROL" },
567 { 0x003f, "IA32_TEMPERATURE_OFFSET" },
568 //{ 0x0079, "IA32_BIOS_UPDT_TRIG" }, // Seems to be RO
569 { 0x008b, "IA32_BIOS_SIGN_ID" },
570 { 0x00e7, "IA32_MPERF" },
571 { 0x00e8, "IA32_APERF" },
572 { 0x00fe, "IA32_MTRRCAP" },
573 { 0x015f, "DTS_CAL_CTRL" },
574 { 0x0179, "IA32_MCG_CAP" },
575 { 0x017a, "IA32_MCG_STATUS" },
576 { 0x0199, "IA32_PERF_CONTROL" },
577 { 0x019a, "IA32_CLOCK_MODULATION" },
578 { 0x019b, "IA32_THERM_INTERRUPT" },
579 { 0x019c, "IA32_THERM_STATUS" },
580 { 0x019d, "GV_THERM" },
581 { 0x01d9, "IA32_DEBUGCTL" },
582 { 0x0200, "IA32_MTRR_PHYSBASE0" },
583 { 0x0201, "IA32_MTRR_PHYSMASK0" },
584 { 0x0202, "IA32_MTRR_PHYSBASE1" },
585 { 0x0203, "IA32_MTRR_PHYSMASK1" },
586 { 0x0204, "IA32_MTRR_PHYSBASE2" },
587 { 0x0205, "IA32_MTRR_PHYSMASK2" },
588 { 0x0206, "IA32_MTRR_PHYSBASE3" },
589 { 0x0207, "IA32_MTRR_PHYSMASK3" },
590 { 0x0208, "IA32_MTRR_PHYSBASE4" },
591 { 0x0209, "IA32_MTRR_PHYSMASK4" },
592 { 0x020a, "IA32_MTRR_PHYSBASE5" },
593 { 0x020b, "IA32_MTRR_PHYSMASK5" },
594 { 0x020c, "IA32_MTRR_PHYSBASE6" },
595 { 0x020d, "IA32_MTRR_PHYSMASK6" },
596 { 0x020e, "IA32_MTRR_PHYSBASE7" },
597 { 0x020f, "IA32_MTRR_PHYSMASK7" },
598 { 0x0250, "IA32_MTRR_FIX64K_00000" },
599 { 0x0258, "IA32_MTRR_FIX16K_80000" },
600 { 0x0259, "IA32_MTRR_FIX16K_A0000" },
601 { 0x0268, "IA32_MTRR_FIX4K_C0000" },
602 { 0x0269, "IA32_MTRR_FIX4K_C8000" },
603 { 0x026a, "IA32_MTRR_FIX4K_D0000" },
604 { 0x026b, "IA32_MTRR_FIX4K_D8000" },
605 { 0x026c, "IA32_MTRR_FIX4K_E0000" },
606 { 0x026d, "IA32_MTRR_FIX4K_E8000" },
607 { 0x026e, "IA32_MTRR_FIX4K_F0000" },
608 { 0x026f, "IA32_MTRR_FIX4K_F8000" },
609 { 0x02ff, "IA32_MTRR_DEF_TYPE" },
610 //{ 0x00c000080, "IA32_CR_EFER" }, // Seems to be RO
613 fd_msr = open("/dev/cpu/0/msr", O_RDWR);
615 perror("Error while opening /dev/cpu/0/msr");
616 printf("Did you run 'modprobe msr'?\n");
620 printf("\n===================== SHARED MSRs (All Cores) =====================\n");
622 for (i = 0; i < ARRAY_SIZE(global_msrs); i++) {
623 msr = rdmsr(global_msrs[i].number);
624 printf(" MSR 0x%08X = 0x%08X:0x%08X (%s)\n",
625 global_msrs[i].number, msr.hi, msr.lo, global_msrs[i].name);
631 for (core=0; core < 8; core++) {
632 char msrfilename[64];
633 memset(msrfilename, 0, 64);
634 sprintf(msrfilename, "/dev/cpu/%d/msr", core);
636 fd_msr = open(msrfilename, O_RDWR);
638 /* If the file is not there, we're probably through.
639 * No error, since we successfully opened /dev/cpu/0/msr before
644 printf("\n====================== UNIQUE MSRs (core %d) ======================\n", core);
646 for (i = 0; i < ARRAY_SIZE(per_core_msrs); i++) {
647 msr = rdmsr(per_core_msrs[i].number);
648 printf(" MSR 0x%08X = 0x%08X:0x%08X (%s)\n",
649 per_core_msrs[i].number, msr.hi, msr.lo, per_core_msrs[i].name);
656 printf("\n(*) Some MSRs could not be read. The marked values are unreliable.\n");
661 void print_version(void)
663 printf("inteltool v%s -- ", INTELTOOL_VERSION);
664 printf("Copyright (C) 2008 coresystems GmbH\n\n");
666 "This program is free software: you can redistribute it and/or modify\n"
667 "it under the terms of the GNU General Public License as published by\n"
668 "the Free Software Foundation, version 2 of the License.\n\n"
669 "This program is distributed in the hope that it will be useful,\n"
670 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
671 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
672 "GNU General Public License for more details.\n\n"
673 "You should have received a copy of the GNU General Public License\n"
674 "along with this program. If not, see <http://www.gnu.org/licenses/>.\n\n");
677 void print_usage(const char *name)
679 printf("usage: %s [-vh?grpmedPMa]\n", name);
681 " -v | --version: print the version\n"
682 " -h | --help: print this help\n\n"
683 " -g | --gpio: dump soutbridge GPIO registers\n"
684 " -r | --rcba: dump soutbridge RCBA registers\n"
685 " -p | --pmbase: dump soutbridge Power Management registers\n\n"
686 " -m | --mchbar: dump northbridge Memory Controller registers\n"
687 " -e | --epbar: dump northbridge EPBAR registers\n"
688 " -d | --dmibar: dump northbridge DMIBAR registers\n"
689 " -P | --pciexpress: dump northbridge PCIEXBAR registers\n\n"
690 " -M | --msrs: dump CPU MSRs\n"
691 " -a | --all: dump all known registers\n"
696 int main(int argc, char *argv[])
698 struct pci_access *pacc;
699 struct pci_dev *sb, *nb;
701 int option_index = 0;
704 char *sbname="unknown", *nbname="unknown";
706 int dump_gpios=0, dump_mchbar=0, dump_rcba=0;
707 int dump_pmbase=0, dump_epbar=0, dump_dmibar=0;
708 int dump_pciexbar=0, dump_coremsrs=0;
710 static struct option long_options[] = {
711 {"version", 0, 0, 'v'},
713 {"gpios", 0, 0, 'g'},
714 {"mchbar", 0, 0, 'm'},
716 {"pmbase", 0, 0, 'p'},
717 {"epbar", 0, 0, 'e'},
718 {"dmibar", 0, 0, 'd'},
719 {"pciexpress", 0, 0, 'P'},
725 while ((opt = getopt_long(argc, argv, "vh?grpmedPMa",
726 long_options, &option_index)) != EOF) {
769 print_usage(argv[0]);
775 if (iopl(3)) { printf("You need to be root.\n"); exit(1); }
777 if ((fd_mem = open("/dev/mem", O_RDWR)) < 0) {
778 perror("Can not open /dev/mem");
787 /* Find the required devices */
789 sb = pci_get_dev(pacc, 0, 0, 0x1f, 0);
791 printf("No southbridge found.\n");
795 pci_fill_info(sb, PCI_FILL_IDENT|PCI_FILL_BASES|PCI_FILL_SIZES|PCI_FILL_CLASS);
797 if (sb->vendor_id != PCI_VENDOR_ID_INTEL) {
798 printf("Not an Intel(R) southbridge.\n");
802 nb = pci_get_dev(pacc, 0, 0, 0x00, 0);
804 printf("No northbridge found.\n");
808 pci_fill_info(nb, PCI_FILL_IDENT|PCI_FILL_BASES|PCI_FILL_SIZES|PCI_FILL_CLASS);
810 if (nb->vendor_id != PCI_VENDOR_ID_INTEL) {
811 printf("Not an Intel(R) northbridge.\n");
815 /* TODO check cpuid, too */
817 /* Determine names */
818 for (i=0; i<ARRAY_SIZE(supported_chips_list); i++)
819 if (nb->device_id == supported_chips_list[i].device_id)
820 nbname = supported_chips_list[i].name;
821 for (i=0; i<ARRAY_SIZE(supported_chips_list); i++)
822 if (sb->device_id == supported_chips_list[i].device_id)
823 sbname = supported_chips_list[i].name;
825 printf("Intel Northbridge: %04x:%04x (%s)\n",
826 nb->vendor_id, nb->device_id, nbname);
828 printf("Intel Southbridge: %04x:%04x (%s)\n",
829 sb->vendor_id, sb->device_id, sbname);
831 /* Now do the deed */
869 print_intel_core_msrs();