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_ICH7 0x27b8
42 #define PCI_DEVICE_ID_INTEL_ICH7MDH 0x27bd
43 #define PCI_DEVICE_ID_INTEL_82945GM 0x27a0
46 uint16_t vendor_id, device_id;
48 } supported_chips_list[] = {
49 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82945GM, "i945GM" },
50 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7MDH, "ICH7-M DH" },
51 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7, "ICH7" },
52 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH4M, "ICH4-M" },
53 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH4, "ICH4" },
54 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH0, "ICH0" },
55 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH, "ICH" }
61 #define ARRAY_SIZE(a) ((int)(sizeof(a) / sizeof((a)[0])))
66 typedef struct { uint32_t hi, lo; } msr_t;
67 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_ICH7MDH:
138 gpiobase = pci_read_word(sb, 0x48) & 0xfffc;
139 gpio_registers = ich7_gpio_registers;
140 size = ARRAY_SIZE(ich7_gpio_registers);
142 case PCI_DEVICE_ID_INTEL_ICH4:
143 case PCI_DEVICE_ID_INTEL_ICH4M:
144 gpiobase = pci_read_word(sb, 0x58) & 0xfffc;
145 gpio_registers = ich4_gpio_registers;
146 size = ARRAY_SIZE(ich4_gpio_registers);
148 case PCI_DEVICE_ID_INTEL_ICH:
149 case PCI_DEVICE_ID_INTEL_ICH0:
150 gpiobase = pci_read_word(sb, 0x58) & 0xfffc;
151 gpio_registers = ich0_gpio_registers;
152 size = ARRAY_SIZE(ich0_gpio_registers);
154 case 0x1234: // Dummy for non-existent functionality
155 printf("This southbridge does not have GPIOBASE.\n");
158 printf("Error: Dumping GPIOs on this southbridge is not (yet) supported.\n");
162 printf("GPIOBASE = 0x%04x (IO)\n\n", gpiobase);
164 for (i=0; i<size; i++) {
165 switch (gpio_registers[i].size) {
167 printf("gpiobase+0x%04x: 0x%08x (%s)\n",
168 gpio_registers[i].addr,
169 inl(gpiobase+gpio_registers[i].addr),
170 gpio_registers[i].name);
173 printf("gpiobase+0x%04x: 0x%04x (%s)\n",
174 gpio_registers[i].addr,
175 inw(gpiobase+gpio_registers[i].addr),
176 gpio_registers[i].name);
179 printf("gpiobase+0x%04x: 0x%02x (%s)\n",
180 gpio_registers[i].addr,
181 inb(gpiobase+gpio_registers[i].addr),
182 gpio_registers[i].name);
190 int print_rcba(struct pci_dev *sb)
193 volatile uint8_t *rcba;
196 printf("\n============= RCBA ==============\n\n");
198 switch (sb->device_id) {
199 case PCI_DEVICE_ID_INTEL_ICH7:
200 case PCI_DEVICE_ID_INTEL_ICH7MDH:
201 rcba_phys = pci_read_long(sb, 0xf0) & 0xfffffffe;
203 case PCI_DEVICE_ID_INTEL_ICH:
204 case PCI_DEVICE_ID_INTEL_ICH0:
205 case PCI_DEVICE_ID_INTEL_ICH4:
206 case PCI_DEVICE_ID_INTEL_ICH4M:
207 printf("This southbridge does not have RCBA.\n");
210 printf("Error: Dumping RCBA on this southbridge is not (yet) supported.\n");
214 rcba = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
215 fd_mem, (off_t) rcba_phys);
217 if (rcba == MAP_FAILED) {
218 perror("Error mapping RCBA");
222 printf("RCBA = 0x%08x (MEM)\n\n", rcba_phys);
224 for (i=0; i<size; i+=4) {
225 if(*(uint32_t *)(rcba+i))
226 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(rcba+i));
229 munmap((void *) rcba, size);
233 int print_pmbase(struct pci_dev *sb)
238 printf("\n============= PMBASE ============\n\n");
240 switch (sb->device_id) {
241 case PCI_DEVICE_ID_INTEL_ICH7:
242 case PCI_DEVICE_ID_INTEL_ICH7MDH:
243 pmbase = pci_read_word(sb, 0x40) & 0xfffc;
245 case 0x1234: // Dummy for non-existent functionality
246 printf("This southbridge does not have PMBASE.\n");
249 printf("Error: Dumping PMBASE on this southbridge is not (yet) supported.\n");
253 printf("PMBASE = 0x%04x (IO)\n\n", pmbase);
255 for (i=0; i<size; i+=4) {
256 printf("pmbase+0x%04x: 0x%08x\n", i, inl(pmbase+i));
263 * (G)MCH MMIO Config Space
266 int print_mchbar(struct pci_dev *nb)
268 int i, size=(16*1024);
269 volatile uint8_t *mchbar;
270 uint32_t mchbar_phys;
272 printf("\n============= MCHBAR ============\n\n");
274 switch (nb->device_id) {
275 case PCI_DEVICE_ID_INTEL_82945GM:
276 mchbar_phys = pci_read_long(nb, 0x44) & 0xfffffffe;
278 case 0x1234: // Dummy for non-existent functionality
279 printf("This northbrigde does not have MCHBAR.\n");
282 printf("Error: Dumping MCHBAR on this northbridge is not (yet) supported.\n");
286 mchbar = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
287 fd_mem, (off_t) mchbar_phys );
289 if (mchbar == MAP_FAILED) {
290 perror("Error mapping MCHBAR");
294 printf("MCHBAR = 0x%08x (MEM)\n\n", mchbar_phys);
296 for (i=0; i<size; i+=4) {
297 if(*(uint32_t *)(mchbar+i))
298 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(mchbar+i));
301 munmap((void *) mchbar, size);
306 * Egress Port Root Complex MMIO configuration space
308 int print_epbar(struct pci_dev *nb)
311 volatile uint8_t *epbar;
314 printf("\n============= EPBAR =============\n\n");
316 switch (nb->device_id) {
317 case PCI_DEVICE_ID_INTEL_82945GM:
318 epbar_phys = pci_read_long(nb, 0x40) & 0xfffffffe;
320 case 0x1234: // Dummy for non-existent functionality
321 printf("This northbrigde does not have EPBAR.\n");
324 printf("Error: Dumping EPBAR on this northbridge is not (yet) supported.\n");
328 epbar = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
329 fd_mem, (off_t) epbar_phys );
331 if (epbar == MAP_FAILED) {
332 perror("Error mapping EPBAR");
336 printf("EPBAR = 0x%08x (MEM)\n\n", epbar_phys);
337 for (i=0; i<size; i+=4) {
338 if(*(uint32_t *)(epbar+i))
339 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(epbar+i));
342 munmap((void *) epbar, size);
348 * MCH-ICH Serial Interconnect Ingress Root Complex MMIO configuration space
350 int print_dmibar(struct pci_dev *nb)
353 volatile uint8_t *dmibar;
354 uint32_t dmibar_phys;
356 printf("\n============= DMIBAR ============\n\n");
358 switch (nb->device_id) {
359 case PCI_DEVICE_ID_INTEL_82945GM:
360 dmibar_phys = pci_read_long(nb, 0x4c) & 0xfffffffe;
362 case 0x1234: // Dummy for non-existent functionality
363 printf("This northbrigde does not have DMIBAR.\n");
366 printf("Error: Dumping DMIBAR on this northbridge is not (yet) supported.\n");
370 dmibar = mmap(0, size, PROT_WRITE | PROT_READ, MAP_SHARED,
371 fd_mem, (off_t) dmibar_phys );
373 if (dmibar == MAP_FAILED) {
374 perror("Error mapping DMIBAR");
378 printf("DMIBAR = 0x%08x (MEM)\n\n", dmibar_phys);
379 for (i=0; i<size; i+=4) {
380 if(*(uint32_t *)(dmibar+i))
381 printf("0x%04x: 0x%08x\n", i, *(uint32_t *)(dmibar+i));
384 munmap((void *) dmibar, size);
389 * PCIe MMIO configuration space
391 int print_pciexbar(struct pci_dev *nb)
393 uint32_t pciexbar_reg;
394 uint32_t pciexbar_phys;
395 volatile uint8_t *pciexbar;
396 int max_busses, devbase, i;
399 printf("========= PCIEXBAR ========\n\n");
401 switch (nb->device_id) {
402 case PCI_DEVICE_ID_INTEL_82945GM:
403 pciexbar_reg = pci_read_long(nb, 0x48);
405 case 0x1234: // Dummy for non-existent functionality
406 printf("Error: This northbrigde does not have PCIEXBAR.\n");
409 printf("Error: Dumping PCIEXBAR on this northbridge is not (yet) supported.\n");
413 if( !(pciexbar_reg & (1 << 0))) {
414 printf("PCIEXBAR register is disabled.\n");
418 switch ((pciexbar_reg >> 1) & 3) {
420 pciexbar_phys = pciexbar_reg & ((1 << 31)|(1 << 30)|(1 << 29)|(1 << 28));
424 pciexbar_phys = pciexbar_reg & ((1 << 31)|(1 << 30)|(1 << 29)|(1 << 28)|(1 << 27));
428 pciexbar_phys = pciexbar_reg & ((1 << 31)|(1 << 30)|(1 << 29)|(1 << 28)|(1 << 27)|(1 << 26));
432 printf("Undefined Address base. Bailing out\n");
436 printf("PCIEXBAR: 0x%08x\n", pciexbar_phys);
438 pciexbar = mmap(0, (max_busses * 1024 * 1024), PROT_WRITE | PROT_READ, MAP_SHARED,
439 fd_mem, (off_t) pciexbar_phys );
441 if (pciexbar == MAP_FAILED) {
442 perror("Error mapping PCIEXBAR");
446 for (bus = 0; bus < max_busses; bus++) {
447 for (dev = 0; dev < 32; dev++) {
448 for (fn = 0; fn < 8; fn++) {
449 devbase = (bus * 1024 * 1024) + (dev * 32 * 1024) + (fn * 4 * 1024);
451 if (*(uint16_t *)(pciexbar + devbase) == 0xffff)
454 /* This is a heuristics. Anyone got a better check? */
455 if( (*(uint32_t *)(pciexbar + devbase + 256) == 0xffffffff) &&
456 (*(uint32_t *)(pciexbar + devbase + 512) == 0xffffffff) ) {
458 printf("Skipped non-PCIe device %02x:%02x.%01x\n", bus, dev, fn);
463 printf("\nPCIe %02x:%02x.%01x extended config space:", bus, dev, fn);
464 for (i=0; i<4096; i++) {
466 printf("\n%04x:", i);
467 printf(" %02x", *(pciexbar+devbase+i));
474 munmap((void *) pciexbar, (max_busses * 1024 * 1024));
479 int msr_readerror = 0;
481 msr_t rdmsr(int addr)
483 unsigned char buf[8];
484 msr_t msr = { 0xffffffff, 0xffffffff };
486 if (lseek(fd_msr, (off_t) addr, SEEK_SET) == -1) {
487 perror("Could not lseek() to MSR");
492 if (read(fd_msr, buf, 8) == 8) {
493 msr.lo = *(uint32_t *)buf;
494 msr.hi = *(uint32_t *)(buf+4);
500 printf(" (*)"); // Not all bits of the MSR could be read
504 perror("Could not read() MSR");
512 int print_intel_core_msrs(void)
514 unsigned int i, core;
518 #define IA32_PLATFORM_ID 0x0017
519 #define EBL_CR_POWERON 0x002a
520 #define FSB_CLK_STS 0x00cd
521 #define IA32_TIME_STAMP_COUNTER 0x0010
522 #define IA32_APIC_BASE 0x001b
529 msr_entry_t global_msrs[] = {
530 { 0x0017, "IA32_PLATFORM_ID" },
531 { 0x002a, "EBL_CR_POWERON" },
532 { 0x00cd, "FSB_CLOCK_STS" },
533 { 0x00ce, "FSB_CLOCK_VCC" },
534 { 0x00e2, "CLOCK_CST_CONFIG_CONTROL" },
535 { 0x00e3, "PMG_IO_BASE_ADDR" },
536 { 0x00e4, "PMG_IO_CAPTURE_ADDR" },
537 { 0x00ee, "EXT_CONFIG" },
538 { 0x011e, "BBL_CR_CTL3" },
539 { 0x0194, "CLOCK_FLEX_MAX" },
540 { 0x0198, "IA32_PERF_STATUS" },
541 { 0x01a0, "IA32_MISC_ENABLES" },
542 { 0x01aa, "PIC_SENS_CFG" },
543 { 0x0400, "IA32_MC0_CTL" },
544 { 0x0401, "IA32_MC0_STATUS" },
545 { 0x0402, "IA32_MC0_ADDR" },
546 //{ 0x0403, "IA32_MC0_MISC" }, // Seems to be RO
547 { 0x040c, "IA32_MC4_CTL" },
548 { 0x040d, "IA32_MC4_STATUS" },
549 { 0x040e, "IA32_MC4_ADDR" },
550 //{ 0x040f, "IA32_MC4_MISC" } // Seems to be RO
553 msr_entry_t per_core_msrs[] = {
554 { 0x0010, "IA32_TIME_STAMP_COUNTER" },
555 { 0x001b, "IA32_APIC_BASE" },
556 { 0x003a, "IA32_FEATURE_CONTROL" },
557 { 0x003f, "IA32_TEMPERATURE_OFFSET" },
558 //{ 0x0079, "IA32_BIOS_UPDT_TRIG" }, // Seems to be RO
559 { 0x008b, "IA32_BIOS_SIGN_ID" },
560 { 0x00e7, "IA32_MPERF" },
561 { 0x00e8, "IA32_APERF" },
562 { 0x00fe, "IA32_MTRRCAP" },
563 { 0x015f, "DTS_CAL_CTRL" },
564 { 0x0179, "IA32_MCG_CAP" },
565 { 0x017a, "IA32_MCG_STATUS" },
566 { 0x0199, "IA32_PERF_CONTROL" },
567 { 0x019a, "IA32_CLOCK_MODULATION" },
568 { 0x019b, "IA32_THERM_INTERRUPT" },
569 { 0x019c, "IA32_THERM_STATUS" },
570 { 0x019d, "GV_THERM" },
571 { 0x01d9, "IA32_DEBUGCTL" },
572 { 0x0200, "IA32_MTRR_PHYSBASE0" },
573 { 0x0201, "IA32_MTRR_PHYSMASK0" },
574 { 0x0202, "IA32_MTRR_PHYSBASE1" },
575 { 0x0203, "IA32_MTRR_PHYSMASK1" },
576 { 0x0204, "IA32_MTRR_PHYSBASE2" },
577 { 0x0205, "IA32_MTRR_PHYSMASK2" },
578 { 0x0206, "IA32_MTRR_PHYSBASE3" },
579 { 0x0207, "IA32_MTRR_PHYSMASK3" },
580 { 0x0208, "IA32_MTRR_PHYSBASE4" },
581 { 0x0209, "IA32_MTRR_PHYSMASK4" },
582 { 0x020a, "IA32_MTRR_PHYSBASE5" },
583 { 0x020b, "IA32_MTRR_PHYSMASK5" },
584 { 0x020c, "IA32_MTRR_PHYSBASE6" },
585 { 0x020d, "IA32_MTRR_PHYSMASK6" },
586 { 0x020e, "IA32_MTRR_PHYSBASE7" },
587 { 0x020f, "IA32_MTRR_PHYSMASK7" },
588 { 0x0250, "IA32_MTRR_FIX64K_00000" },
589 { 0x0258, "IA32_MTRR_FIX16K_80000" },
590 { 0x0259, "IA32_MTRR_FIX16K_A0000" },
591 { 0x0268, "IA32_MTRR_FIX4K_C0000" },
592 { 0x0269, "IA32_MTRR_FIX4K_C8000" },
593 { 0x026a, "IA32_MTRR_FIX4K_D0000" },
594 { 0x026b, "IA32_MTRR_FIX4K_D8000" },
595 { 0x026c, "IA32_MTRR_FIX4K_E0000" },
596 { 0x026d, "IA32_MTRR_FIX4K_E8000" },
597 { 0x026e, "IA32_MTRR_FIX4K_F0000" },
598 { 0x026f, "IA32_MTRR_FIX4K_F8000" },
599 { 0x02ff, "IA32_MTRR_DEF_TYPE" },
600 //{ 0x00c000080, "IA32_CR_EFER" }, // Seems to be RO
603 fd_msr = open("/dev/cpu/0/msr", O_RDWR);
605 perror("Error while opening /dev/cpu/0/msr");
606 printf("Did you run 'modprobe msr'?\n");
610 printf("\n===================== SHARED MSRs (All Cores) =====================\n");
612 for (i = 0; i < ARRAY_SIZE(global_msrs); i++) {
613 msr = rdmsr(global_msrs[i].number);
614 printf(" MSR 0x%08X = 0x%08X:0x%08X (%s)\n",
615 global_msrs[i].number, msr.hi, msr.lo, global_msrs[i].name);
621 for (core=0; core < 8; core++) {
622 char msrfilename[64];
623 memset(msrfilename, 0, 64);
624 sprintf(msrfilename, "/dev/cpu/%d/msr", core);
626 fd_msr = open(msrfilename, O_RDWR);
628 /* If the file is not there, we're probably through.
629 * No error, since we successfully opened /dev/cpu/0/msr before
634 printf("\n====================== UNIQUE MSRs (core %d) ======================\n", core);
636 for (i = 0; i < ARRAY_SIZE(per_core_msrs); i++) {
637 msr = rdmsr(per_core_msrs[i].number);
638 printf(" MSR 0x%08X = 0x%08X:0x%08X (%s)\n",
639 per_core_msrs[i].number, msr.hi, msr.lo, per_core_msrs[i].name);
646 printf("\n(*) Some MSRs could not be read. The marked values are unreliable.\n");
651 void print_version(void)
653 printf("inteltool v%s -- ", INTELTOOL_VERSION);
654 printf("Copyright (C) 2008 coresystems GmbH\n\n");
656 "This program is free software: you can redistribute it and/or modify\n"
657 "it under the terms of the GNU General Public License as published by\n"
658 "the Free Software Foundation, version 2 of the License.\n\n"
659 "This program is distributed in the hope that it will be useful,\n"
660 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
661 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
662 "GNU General Public License for more details.\n\n"
663 "You should have received a copy of the GNU General Public License\n"
664 "along with this program. If not, see <http://www.gnu.org/licenses/>.\n\n");
667 void print_usage(const char *name)
669 printf("usage: %s [-vh?grpmedPMa]\n", name);
671 " -v | --version: print the version\n"
672 " -h | --help: print this help\n\n"
673 " -g | --gpio: dump soutbridge GPIO registers\n"
674 " -r | --rcba: dump soutbridge RCBA registers\n"
675 " -p | --pmbase: dump soutbridge Power Management registers\n\n"
676 " -m | --mchbar: dump northbridge Memory Controller registers\n"
677 " -e | --epbar: dump northbridge EPBAR registers\n"
678 " -d | --dmibar: dump northbridge DMIBAR registers\n"
679 " -P | --pciexpress: dump northbridge PCIEXBAR registers\n\n"
680 " -M | --msrs: dump CPU MSRs\n"
681 " -a | --all: dump all known registers\n"
686 int main(int argc, char *argv[])
688 struct pci_access *pacc;
689 struct pci_dev *sb, *nb;
691 int option_index = 0;
694 char *sbname="unknown", *nbname="unknown";
696 int dump_gpios=0, dump_mchbar=0, dump_rcba=0;
697 int dump_pmbase=0, dump_epbar=0, dump_dmibar=0;
698 int dump_pciexbar=0, dump_coremsrs=0;
700 static struct option long_options[] = {
701 {"version", 0, 0, 'v'},
703 {"gpios", 0, 0, 'g'},
704 {"mchbar", 0, 0, 'm'},
706 {"pmbase", 0, 0, 'p'},
707 {"epbar", 0, 0, 'e'},
708 {"dmibar", 0, 0, 'd'},
709 {"pciexpress", 0, 0, 'P'},
715 while ((opt = getopt_long(argc, argv, "vh?grpmedPMa",
716 long_options, &option_index)) != EOF) {
759 print_usage(argv[0]);
765 if (iopl(3)) { printf("You need to be root.\n"); exit(1); }
767 if ((fd_mem = open("/dev/mem", O_RDWR)) < 0) {
768 perror("Can not open /dev/mem");
777 /* Find the required devices */
779 sb = pci_get_dev(pacc, 0, 0, 0x1f, 0);
781 printf("No southbridge found.\n");
785 pci_fill_info(sb, PCI_FILL_IDENT|PCI_FILL_BASES|PCI_FILL_SIZES|PCI_FILL_CLASS);
787 if (sb->vendor_id != PCI_VENDOR_ID_INTEL) {
788 printf("Not an Intel(R) southbridge.\n");
792 nb = pci_get_dev(pacc, 0, 0, 0x00, 0);
794 printf("No northbridge found.\n");
798 pci_fill_info(nb, PCI_FILL_IDENT|PCI_FILL_BASES|PCI_FILL_SIZES|PCI_FILL_CLASS);
800 if (nb->vendor_id != PCI_VENDOR_ID_INTEL) {
801 printf("Not an Intel(R) northbridge.\n");
805 /* TODO check cpuid, too */
807 /* Determine names */
808 for (i=0; i<ARRAY_SIZE(supported_chips_list); i++)
809 if (nb->device_id == supported_chips_list[i].device_id)
810 nbname = supported_chips_list[i].name;
811 for (i=0; i<ARRAY_SIZE(supported_chips_list); i++)
812 if (sb->device_id == supported_chips_list[i].device_id)
813 sbname = supported_chips_list[i].name;
815 printf("Intel Northbridge: %04x:%04x (%s)\n",
816 nb->vendor_id, nb->device_id, nbname);
818 printf("Intel Southbridge: %04x:%04x (%s)\n",
819 sb->vendor_id, sb->device_id, sbname);
821 /* Now do the deed */
859 print_intel_core_msrs();