Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * inteltool - dump all registers on an Intel CPU + chipset based system. |
| 3 | * |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 4 | * Copyright (C) 2008-2010 by coresystems GmbH |
| 5 | * written by Stefan Reinauer <stepan@coresystems.de> |
| 6 | * |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 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. |
| 10 | * |
| 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. |
| 15 | * |
| 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. |
| 19 | */ |
| 20 | |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 21 | #include <stdio.h> |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 22 | #include <stdlib.h> |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 23 | #include <getopt.h> |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 24 | #include <fcntl.h> |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 25 | #include <sys/mman.h> |
Stefan Reinauer | 2319027 | 2008-08-20 13:41:24 +0000 | [diff] [blame] | 26 | #include "inteltool.h" |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 27 | |
Stefan Reinauer | 9f7af6e | 2008-05-14 14:22:59 +0000 | [diff] [blame] | 28 | static const struct { |
| 29 | uint16_t vendor_id, device_id; |
Uwe Hermann | 9a6b6b5 | 2008-05-14 21:20:55 +0000 | [diff] [blame] | 30 | char *name; |
Stefan Reinauer | 9f7af6e | 2008-05-14 14:22:59 +0000 | [diff] [blame] | 31 | } supported_chips_list[] = { |
Maciej Pijanka | 90d1740 | 2009-09-30 17:05:46 +0000 | [diff] [blame] | 32 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443LX, "82443LX" }, |
| 33 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443BX, "82443BX" }, |
| 34 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82443BX_NO_AGP, "82443BX without AGP" }, |
Stefan Reinauer | b2aedb1 | 2009-08-29 15:45:43 +0000 | [diff] [blame] | 35 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82810, "i810" }, |
| 36 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82810DC, "i810-DC100" }, |
Joseph Smith | e10757e | 2010-06-16 22:21:19 +0000 | [diff] [blame] | 37 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82810E_MC, "i810E DC-133" }, |
Stefan Reinauer | 0484481 | 2010-02-22 11:26:06 +0000 | [diff] [blame] | 38 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82830M, "i830M" }, |
Uwe Hermann | 710e8b1 | 2008-05-17 21:33:35 +0000 | [diff] [blame] | 39 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82845, "i845" }, |
Pat Erley | ca3548e | 2010-04-21 06:23:19 +0000 | [diff] [blame] | 40 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82915, "82915G/P/GV/GL/PL/910GL" }, |
Stefan Reinauer | 3d9a12f | 2008-11-02 11:11:40 +0000 | [diff] [blame] | 41 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82945P, "i945P" }, |
Stefan Reinauer | 9f7af6e | 2008-05-14 14:22:59 +0000 | [diff] [blame] | 42 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82945GM, "i945GM" }, |
Björn Busse | 2d33dc4 | 2010-08-01 15:33:30 +0000 | [diff] [blame] | 43 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82945GSE, "i945GSE" }, |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 44 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_PM965, "PM965" }, |
Corey Osgood | 23d98c7 | 2010-07-29 19:25:31 +0000 | [diff] [blame] | 45 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_Q965, "Q963/965" }, |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 46 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82975X, "i975X" }, |
Loïc Grenié | 8429de7 | 2009-11-02 15:01:49 +0000 | [diff] [blame] | 47 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82Q35, "Q35" }, |
| 48 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82G33, "P35/G33/G31/P31" }, |
| 49 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82Q33, "Q33" }, |
Warren Turkal | 9702b6b | 2009-06-30 14:11:42 +0000 | [diff] [blame] | 50 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_X58, "X58" }, |
Stefan Reinauer | 74cd5698 | 2010-06-01 10:04:28 +0000 | [diff] [blame] | 51 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_GS45, "GS45ME" }, |
Corey Osgood | 23d98c7 | 2010-07-29 19:25:31 +0000 | [diff] [blame] | 52 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ATOM_DXXX, "Atom D400/500 Series" }, |
| 53 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ATOM_NXXX, "Atom N400 Series" }, |
Stefan Reinauer | 74cd5698 | 2010-06-01 10:04:28 +0000 | [diff] [blame] | 54 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_POULSBO, "SCH Poulsbo" }, |
| 55 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_POULSBO_LPC, "SCH Poulsbo" }, |
Warren Turkal | 9702b6b | 2009-06-30 14:11:42 +0000 | [diff] [blame] | 56 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH10R, "ICH10R" }, |
Anton Kochkov | da0b456 | 2010-05-30 12:33:12 +0000 | [diff] [blame] | 57 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9DH, "ICH9DH" }, |
| 58 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9DO, "ICH9DO" }, |
| 59 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9R, "ICH9R" }, |
| 60 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9, "ICH9" }, |
| 61 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9M, "ICH9M" }, |
| 62 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9ME, "ICH9M-E" }, |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 63 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8M, "ICH8-M" }, |
Corey Osgood | f366ce0 | 2010-08-17 08:33:44 +0000 | [diff] [blame^] | 64 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8, "ICH8" }, |
| 65 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_NM10, "NM10" }, |
Stefan Reinauer | 9f7af6e | 2008-05-14 14:22:59 +0000 | [diff] [blame] | 66 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7MDH, "ICH7-M DH" }, |
Stefan Reinauer | f9b9945 | 2008-05-14 20:05:00 +0000 | [diff] [blame] | 67 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7M, "ICH7-M" }, |
Stefan Reinauer | 9f7af6e | 2008-05-14 14:22:59 +0000 | [diff] [blame] | 68 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7, "ICH7" }, |
Stefan Reinauer | f9b9945 | 2008-05-14 20:05:00 +0000 | [diff] [blame] | 69 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7DH, "ICH7DH" }, |
Pat Erley | ca3548e | 2010-04-21 06:23:19 +0000 | [diff] [blame] | 70 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6, "ICH6" }, |
Stefan Reinauer | 9f7af6e | 2008-05-14 14:22:59 +0000 | [diff] [blame] | 71 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH4M, "ICH4-M" }, |
| 72 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH4, "ICH4" }, |
Uwe Hermann | 710e8b1 | 2008-05-17 21:33:35 +0000 | [diff] [blame] | 73 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH2, "ICH2" }, |
Stefan Reinauer | 9f7af6e | 2008-05-14 14:22:59 +0000 | [diff] [blame] | 74 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH0, "ICH0" }, |
Maciej Pijanka | 90d1740 | 2009-09-30 17:05:46 +0000 | [diff] [blame] | 75 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH, "ICH" }, |
| 76 | { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371XX, "82371AB/EB/MB" }, |
Stefan Reinauer | 9f7af6e | 2008-05-14 14:22:59 +0000 | [diff] [blame] | 77 | }; |
| 78 | |
Stefan Reinauer | f7f2f25 | 2009-09-01 09:52:14 +0000 | [diff] [blame] | 79 | #ifndef __DARWIN__ |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 80 | static int fd_mem; |
| 81 | |
Stefan Reinauer | f7f2f25 | 2009-09-01 09:52:14 +0000 | [diff] [blame] | 82 | void *map_physical(unsigned long phys_addr, size_t len) |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 83 | { |
| 84 | void *virt_addr; |
| 85 | |
| 86 | virt_addr = mmap(0, len, PROT_WRITE | PROT_READ, MAP_SHARED, |
| 87 | fd_mem, (off_t) phys_addr); |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 88 | |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 89 | if (virt_addr == MAP_FAILED) { |
Stefan Reinauer | f182456 | 2009-04-22 23:17:44 +0000 | [diff] [blame] | 90 | printf("Error mapping physical memory 0x%08lx[0x%x]\n", phys_addr, len); |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 91 | return NULL; |
| 92 | } |
| 93 | |
| 94 | return virt_addr; |
| 95 | } |
| 96 | |
Stefan Reinauer | f7f2f25 | 2009-09-01 09:52:14 +0000 | [diff] [blame] | 97 | void unmap_physical(void *virt_addr, size_t len) |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 98 | { |
| 99 | munmap(virt_addr, len); |
| 100 | } |
| 101 | #endif |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 102 | |
| 103 | void print_version(void) |
| 104 | { |
| 105 | printf("inteltool v%s -- ", INTELTOOL_VERSION); |
| 106 | printf("Copyright (C) 2008 coresystems GmbH\n\n"); |
| 107 | printf( |
| 108 | "This program is free software: you can redistribute it and/or modify\n" |
| 109 | "it under the terms of the GNU General Public License as published by\n" |
| 110 | "the Free Software Foundation, version 2 of the License.\n\n" |
| 111 | "This program is distributed in the hope that it will be useful,\n" |
| 112 | "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" |
| 113 | "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" |
| 114 | "GNU General Public License for more details.\n\n" |
| 115 | "You should have received a copy of the GNU General Public License\n" |
| 116 | "along with this program. If not, see <http://www.gnu.org/licenses/>.\n\n"); |
| 117 | } |
| 118 | |
| 119 | void print_usage(const char *name) |
| 120 | { |
Stefan Reinauer | d466e6a | 2008-05-14 13:52:50 +0000 | [diff] [blame] | 121 | printf("usage: %s [-vh?grpmedPMa]\n", name); |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 122 | printf("\n" |
| 123 | " -v | --version: print the version\n" |
| 124 | " -h | --help: print this help\n\n" |
| 125 | " -g | --gpio: dump soutbridge GPIO registers\n" |
| 126 | " -r | --rcba: dump soutbridge RCBA registers\n" |
| 127 | " -p | --pmbase: dump soutbridge Power Management registers\n\n" |
| 128 | " -m | --mchbar: dump northbridge Memory Controller registers\n" |
| 129 | " -e | --epbar: dump northbridge EPBAR registers\n" |
| 130 | " -d | --dmibar: dump northbridge DMIBAR registers\n" |
| 131 | " -P | --pciexpress: dump northbridge PCIEXBAR registers\n\n" |
| 132 | " -M | --msrs: dump CPU MSRs\n" |
Stefan Reinauer | d466e6a | 2008-05-14 13:52:50 +0000 | [diff] [blame] | 133 | " -a | --all: dump all known registers\n" |
Uwe Hermann | 9a6b6b5 | 2008-05-14 21:20:55 +0000 | [diff] [blame] | 134 | "\n"); |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 135 | exit(1); |
| 136 | } |
| 137 | |
| 138 | int main(int argc, char *argv[]) |
| 139 | { |
| 140 | struct pci_access *pacc; |
Maciej Pijanka | 90d1740 | 2009-09-30 17:05:46 +0000 | [diff] [blame] | 141 | struct pci_dev *sb = NULL, *nb, *dev; |
Uwe Hermann | 9a6b6b5 | 2008-05-14 21:20:55 +0000 | [diff] [blame] | 142 | int i, opt, option_index = 0; |
Stefan Reinauer | 26ba091 | 2008-08-18 10:58:09 +0000 | [diff] [blame] | 143 | unsigned int id; |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 144 | |
Uwe Hermann | 9a6b6b5 | 2008-05-14 21:20:55 +0000 | [diff] [blame] | 145 | char *sbname = "unknown", *nbname = "unknown"; |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 146 | |
Uwe Hermann | 9a6b6b5 | 2008-05-14 21:20:55 +0000 | [diff] [blame] | 147 | int dump_gpios = 0, dump_mchbar = 0, dump_rcba = 0; |
| 148 | int dump_pmbase = 0, dump_epbar = 0, dump_dmibar = 0; |
| 149 | int dump_pciexbar = 0, dump_coremsrs = 0; |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 150 | |
| 151 | static struct option long_options[] = { |
| 152 | {"version", 0, 0, 'v'}, |
| 153 | {"help", 0, 0, 'h'}, |
| 154 | {"gpios", 0, 0, 'g'}, |
| 155 | {"mchbar", 0, 0, 'm'}, |
| 156 | {"rcba", 0, 0, 'r'}, |
| 157 | {"pmbase", 0, 0, 'p'}, |
| 158 | {"epbar", 0, 0, 'e'}, |
| 159 | {"dmibar", 0, 0, 'd'}, |
| 160 | {"pciexpress", 0, 0, 'P'}, |
| 161 | {"msrs", 0, 0, 'M'}, |
| 162 | {"all", 0, 0, 'a'}, |
| 163 | {0, 0, 0, 0} |
| 164 | }; |
| 165 | |
Stefan Reinauer | d466e6a | 2008-05-14 13:52:50 +0000 | [diff] [blame] | 166 | while ((opt = getopt_long(argc, argv, "vh?grpmedPMa", |
Uwe Hermann | 9a6b6b5 | 2008-05-14 21:20:55 +0000 | [diff] [blame] | 167 | long_options, &option_index)) != EOF) { |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 168 | switch (opt) { |
| 169 | case 'v': |
| 170 | print_version(); |
| 171 | exit(0); |
| 172 | break; |
| 173 | case 'g': |
| 174 | dump_gpios = 1; |
| 175 | break; |
| 176 | case 'm': |
| 177 | dump_mchbar = 1; |
| 178 | break; |
| 179 | case 'r': |
| 180 | dump_rcba = 1; |
| 181 | break; |
| 182 | case 'p': |
| 183 | dump_pmbase = 1; |
| 184 | break; |
| 185 | case 'e': |
| 186 | dump_epbar = 1; |
| 187 | break; |
| 188 | case 'd': |
| 189 | dump_dmibar = 1; |
| 190 | break; |
| 191 | case 'P': |
| 192 | dump_pciexbar = 1; |
| 193 | break; |
| 194 | case 'M': |
| 195 | dump_coremsrs = 1; |
| 196 | break; |
| 197 | case 'a': |
| 198 | dump_gpios = 1; |
| 199 | dump_mchbar = 1; |
| 200 | dump_rcba = 1; |
| 201 | dump_pmbase = 1; |
| 202 | dump_epbar = 1; |
| 203 | dump_dmibar = 1; |
| 204 | dump_pciexbar = 1; |
| 205 | dump_coremsrs = 1; |
| 206 | break; |
| 207 | case 'h': |
| 208 | case '?': |
| 209 | default: |
| 210 | print_usage(argv[0]); |
| 211 | exit(0); |
| 212 | break; |
| 213 | } |
| 214 | } |
| 215 | |
Uwe Hermann | 9a6b6b5 | 2008-05-14 21:20:55 +0000 | [diff] [blame] | 216 | if (iopl(3)) { |
| 217 | printf("You need to be root.\n"); |
| 218 | exit(1); |
| 219 | } |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 220 | |
Stefan Reinauer | f7f2f25 | 2009-09-01 09:52:14 +0000 | [diff] [blame] | 221 | #ifndef __DARWIN__ |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 222 | if ((fd_mem = open("/dev/mem", O_RDWR)) < 0) { |
| 223 | perror("Can not open /dev/mem"); |
| 224 | exit(1); |
| 225 | } |
Stefan Reinauer | 1162f25 | 2008-12-04 15:18:20 +0000 | [diff] [blame] | 226 | #endif |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 227 | |
| 228 | pacc = pci_alloc(); |
| 229 | pci_init(pacc); |
| 230 | pci_scan_bus(pacc); |
| 231 | |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 232 | /* Find the required devices */ |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 233 | for (dev = pacc->devices; dev; dev = dev->next) { |
Maciej Pijanka | 90d1740 | 2009-09-30 17:05:46 +0000 | [diff] [blame] | 234 | pci_fill_info(dev, PCI_FILL_CLASS); |
| 235 | /* The ISA/LPC bridge can be 0x1f, 0x07, or 0x04 so we probe. */ |
| 236 | if (dev->device_class == 0x0601) { /* ISA/LPC bridge */ |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 237 | if (sb == NULL) |
Maciej Pijanka | 90d1740 | 2009-09-30 17:05:46 +0000 | [diff] [blame] | 238 | sb = dev; |
| 239 | else |
| 240 | fprintf(stderr, "Multiple devices with class ID" |
| 241 | " 0x0601, using %02x%02x:%02x.%02x\n", |
| 242 | dev->domain, dev->bus, dev->dev, |
| 243 | dev->func); |
| 244 | } |
| 245 | } |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 246 | |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 247 | if (!sb) { |
| 248 | printf("No southbridge found.\n"); |
| 249 | exit(1); |
| 250 | } |
| 251 | |
| 252 | pci_fill_info(sb, PCI_FILL_IDENT|PCI_FILL_BASES|PCI_FILL_SIZES|PCI_FILL_CLASS); |
| 253 | |
| 254 | if (sb->vendor_id != PCI_VENDOR_ID_INTEL) { |
| 255 | printf("Not an Intel(R) southbridge.\n"); |
| 256 | exit(1); |
| 257 | } |
| 258 | |
| 259 | nb = pci_get_dev(pacc, 0, 0, 0x00, 0); |
| 260 | if (!nb) { |
| 261 | printf("No northbridge found.\n"); |
| 262 | exit(1); |
| 263 | } |
| 264 | |
| 265 | pci_fill_info(nb, PCI_FILL_IDENT|PCI_FILL_BASES|PCI_FILL_SIZES|PCI_FILL_CLASS); |
| 266 | |
| 267 | if (nb->vendor_id != PCI_VENDOR_ID_INTEL) { |
| 268 | printf("Not an Intel(R) northbridge.\n"); |
| 269 | exit(1); |
| 270 | } |
| 271 | |
Stefan Reinauer | 26ba091 | 2008-08-18 10:58:09 +0000 | [diff] [blame] | 272 | id = cpuid(1); |
Stefan Reinauer | 74cd5698 | 2010-06-01 10:04:28 +0000 | [diff] [blame] | 273 | |
| 274 | /* Intel has suggested applications to display the family of a CPU as |
| 275 | * the sum of the "Family" and the "Extended Family" fields shown |
| 276 | * above, and the model as the sum of the "Model" and the 4-bit |
| 277 | * left-shifted "Extended Model" fields. |
| 278 | * http://download.intel.com/design/processor/applnots/24161832.pdf |
| 279 | */ |
| 280 | printf("Intel CPU: Processor Type: %x, Family %x, Model %x, Stepping %x\n", |
| 281 | (id >> 12) & 0x3, ((id >> 8) & 0xf) + ((id >> 20) & 0xff), |
| 282 | ((id >> 12) & 0xf0) + ((id >> 4) & 0xf), (id & 0xf)); |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 283 | |
| 284 | /* Determine names */ |
Uwe Hermann | 9a6b6b5 | 2008-05-14 21:20:55 +0000 | [diff] [blame] | 285 | for (i = 0; i < ARRAY_SIZE(supported_chips_list); i++) |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 286 | if (nb->device_id == supported_chips_list[i].device_id) |
| 287 | nbname = supported_chips_list[i].name; |
Uwe Hermann | 9a6b6b5 | 2008-05-14 21:20:55 +0000 | [diff] [blame] | 288 | for (i = 0; i < ARRAY_SIZE(supported_chips_list); i++) |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 289 | if (sb->device_id == supported_chips_list[i].device_id) |
| 290 | sbname = supported_chips_list[i].name; |
| 291 | |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 292 | printf("Intel Northbridge: %04x:%04x (%s)\n", |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 293 | nb->vendor_id, nb->device_id, nbname); |
| 294 | |
Stefan Reinauer | 14e2277 | 2010-04-27 06:56:47 +0000 | [diff] [blame] | 295 | printf("Intel Southbridge: %04x:%04x (%s)\n", |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 296 | sb->vendor_id, sb->device_id, sbname); |
| 297 | |
| 298 | /* Now do the deed */ |
| 299 | |
| 300 | if (dump_gpios) { |
| 301 | print_gpios(sb); |
| 302 | printf("\n\n"); |
| 303 | } |
| 304 | |
| 305 | if (dump_rcba) { |
| 306 | print_rcba(sb); |
| 307 | printf("\n\n"); |
| 308 | } |
| 309 | |
| 310 | if (dump_pmbase) { |
| 311 | print_pmbase(sb); |
| 312 | printf("\n\n"); |
| 313 | } |
| 314 | |
| 315 | if (dump_mchbar) { |
| 316 | print_mchbar(nb); |
| 317 | printf("\n\n"); |
| 318 | } |
| 319 | |
| 320 | if (dump_epbar) { |
| 321 | print_epbar(nb); |
| 322 | printf("\n\n"); |
| 323 | } |
| 324 | |
| 325 | if (dump_dmibar) { |
| 326 | print_dmibar(nb); |
| 327 | printf("\n\n"); |
| 328 | } |
| 329 | |
| 330 | if (dump_pciexbar) { |
| 331 | print_pciexbar(nb); |
| 332 | printf("\n\n"); |
| 333 | } |
| 334 | |
| 335 | if (dump_coremsrs) { |
| 336 | print_intel_core_msrs(); |
| 337 | printf("\n\n"); |
| 338 | } |
| 339 | |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 340 | /* Clean up */ |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 341 | pci_free_dev(nb); |
Uwe Hermann | e23e372 | 2009-09-30 17:14:24 +0000 | [diff] [blame] | 342 | // pci_free_dev(sb); // TODO: glibc detected "double free or corruption" |
Stefan Reinauer | 03646be | 2008-05-13 22:14:21 +0000 | [diff] [blame] | 343 | pci_cleanup(pacc); |
| 344 | |
| 345 | return 0; |
| 346 | } |