msrtool: CS5536: The most important interrupt MSRs and some DIVIL MSRs.
[coreboot.git] / util / msrtool / msrtool.c
index 6f0b3a01095959739a37208fb4cc0f88efb3eb99..2bb8ded8ba51fa7bea946ab4e68d6800fbdcf742 100644 (file)
@@ -25,6 +25,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <pci/pci.h>
 
 #include "msrtool.h"
 
@@ -36,9 +37,12 @@ const struct targetdef **targets = NULL;
 const struct sysdef *sys = NULL;
 uint8_t reserved = 0, verbose = 0, quiet = 0;
 
+struct pci_access *pacc = NULL;
+
 static struct targetdef alltargets[] = {
        { "geodelx", "AMD Geode(tm) LX", geodelx_probe, geodelx_msrs },
        { "cs5536", "AMD Geode(tm) CS5536", cs5536_probe, cs5536_msrs },
+       { "K8", "AMD K8 Family", k8_probe, k8_msrs },
        { TARGET_EOT }
 };
 
@@ -275,7 +279,7 @@ int main(int argc, char *argv[]) {
                        break;
                case 'i':
                        input = 1;
-                       addr = strtoul(optarg, NULL, 16);
+                       addr = msraddrbyname(optarg);
                        optarg = strchr(optarg, '=');
                        if (NULL == optarg) {
                                fprintf(stderr, "missing value in -i argument!\n");
@@ -296,6 +300,14 @@ int main(int argc, char *argv[]) {
 
        printf_quiet("msrtool %s\n", VERSION);
 
+       pacc = pci_alloc();
+       if (NULL == pacc) {
+               fprintf(stderr, "Could not initialize PCI library! pci_alloc() failed.\n");
+               return 1;
+       }
+       pci_init(pacc);
+       pci_scan_bus(pacc);
+
        if (!sys && !input && !listknown)
                for (sys = allsystems; !SYSTEM_ISEOT(*sys); sys++) {
                        printf_verbose("Probing for system %s: %s\n", sys->name, sys->prettyname);
@@ -338,6 +350,7 @@ int main(int argc, char *argv[]) {
 
        if (sys && !sys->name) {
                fprintf(stderr, "Unable to detect the current operating system!\n");
+               fprintf(stderr, "On Linux, please do 'modprobe msr' and retry.\n");
                fprintf(stderr, "Please send a report or patch to coreboot@coreboot.org. Thanks for your help!\n");
                fprintf(stderr, "\n");
        }
@@ -387,7 +400,7 @@ int main(int argc, char *argv[]) {
        }
 
        for (; optind < argc; optind++) {
-               addr = strtoul(argv[optind], NULL, 16);
+               addr = msraddrbyname(argv[optind]);
                if (!sys->rdmsr(cpu, addr, &msrval))
                        break;
                decodemsr(cpu, addr, msrval);