Add -D / --dump-readable option which prints the Super I/O register
authorUwe Hermann <uwe@hermann-uwe.de>
Thu, 20 Sep 2007 23:57:44 +0000 (23:57 +0000)
committerUwe Hermann <uwe@hermann-uwe.de>
Thu, 20 Sep 2007 23:57:44 +0000 (23:57 +0000)
contents in human-readable form (e.g. "COM1 enabled" etc.) instead
of the hex-table format from -d / --dump.

Signed-off-by: Uwe Hermann <uwe@hermann-uwe.de>
Acked-by: Uwe Hermann <uwe@hermann-uwe.de>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@2795 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1

util/superiotool/README
util/superiotool/fintek.c
util/superiotool/ite.c
util/superiotool/nsc.c
util/superiotool/smsc.c
util/superiotool/superiotool.c
util/superiotool/superiotool.h
util/superiotool/winbond.c

index f0294d41cc9a8a77c6234b18693d805b55c951db..9fef6306ccf02cb6bc5a8d0ce56f4d5b01c6c7d1 100644 (file)
@@ -28,12 +28,13 @@ Installation
 Usage
 -----
 
 $ superiotool [-d] [-V] [-v] [-h]
$ superiotool [-d] [-D] [-V] [-v] [-h]
 
-  -d | --dump      Dump Super I/O registers
-  -V | --verbose   Verbose mode
-  -v | --version   Show the superiotool version
-  -h | --help      Show a short help text
+ -d | --dump            Dump Super I/O registers
+ -D | --dump-readable   Dump Super I/O registers in human-readable format
+ -V | --verbose         Verbose mode
+ -v | --version         Show the superiotool version
+ -h | --help            Show a short help text
 
 Per default (no options) superiotool will just probe for a Super I/O
 and print its vendor, name, ID, version, and config port.
@@ -44,10 +45,14 @@ Typical usage of superiotool:
 
    $ superiotool
 
- - Detailed register dump of the Super I/O (if detected):
+ - Register dump as table of hex-values of the Super I/O (if detected):
 
    $ superiotool -d
 
+ - Detailed register dump in human-readable format:
+
+   $ superiotool -D
+
 
 Supported Super I/O Chips
 -------------------------
index a95a38354f5387b77f141eb2ecb384d10d779a08..f7f0a7c5c8b53f326554b4f2a9f09131bb78e679 100644 (file)
@@ -33,8 +33,11 @@ const static struct superio_registers reg_table[] = {
        {EOT}
 };
 
-void dump_fintek(uint16_t port, uint16_t did)
+static void dump_readable_fintek(uint16_t port, uint16_t did)
 {
+       if (!dump_readable)
+               return;
+
        switch (did) {
        case 0x0604:
                printf("Fintek F71805\n");
@@ -124,9 +127,7 @@ void probe_idregs_fintek(uint16_t port)
                       get_superio_name(reg_table, did), vid, did, port);
 
        dump_superio("Fintek", reg_table, port, did);
-
-       /* TODO: Revive this as --dump-human-readable output. */
-       /* dump_fintek(port, did); */
+       dump_readable_fintek(port, did);
 
        exit_conf_mode_winbond_fintek_ite_8787(port);
 }
index 1a65e2cff28ad432ba5cf447ce5b51ae7c1a4579..fbda547801210fbca61a0d6eb3b2d8b790e155ca 100644 (file)
@@ -194,12 +194,6 @@ const static struct superio_registers reg_table[] = {
        {EOT}
 };
 
-/* TODO: Drop this function later. */
-void dump_ite(uint16_t port, uint16_t id)
-{
-       dump_superio("ITE", reg_table, port, id);
-}
-
 /**
  * Enable configuration sequence (ITE uses this for newer IT87[012]xF).
  *
@@ -244,6 +238,7 @@ static void probe_idregs_ite_helper(uint16_t port)
               get_superio_name(reg_table, id), id, chipver, port);
 
        dump_superio("ITE", reg_table, port, id);
+       dump_superio_readable(port); /* TODO */
 }
 
 void probe_idregs_ite(uint16_t port)
index ec9b326192b74b85f67feb77f08b9c5b49d031be..797f3d4c4d750950277dd8e70cfa4ad9f309e542 100644 (file)
@@ -25,8 +25,11 @@ static const char *familyid[] = {
        [0xf1] = "PC8374 (Winbond/NatSemi)"
 };
 
-void dump_ns8374(uint16_t port)
+static void dump_readable_ns8374(uint16_t port)
 {
+       if (!dump_readable)
+               return;
+
        printf("Enables: 21=%02x, 22=%02x, 23=%02x, 24=%02x, 26=%02x\n",
               regval(port, 0x21), regval(port, 0x22), regval(port, 0x23),
               regval(port, 0x24), regval(port, 0x26));
@@ -79,7 +82,7 @@ void probe_idregs_simple(uint16_t port)
 
        switch (id) {
        case 0xf1:
-               dump_ns8374(port);
+               dump_readable_ns8374(port);
                break;
        default:
                printf("No dump for 0x%02x\n", id);
index 13ad4a7221b8fa7569f139342f1466e3aadbec58..cd612e87f1f01c27fa352c9d7b4ba6c9921a4d28 100644 (file)
@@ -69,6 +69,7 @@ void probe_idregs_smsc(uint16_t port)
               get_superio_name(reg_table, id), id, rev, port);
 
        dump_superio("SMSC", reg_table, port, id);
+       dump_superio_readable(port); /* TODO */
 
        exit_conf_mode_smsc(port);
 }
index 0a253ad6239185210391d5db3e1997d838988d3f..13e55556d5f976612f8d06a59a1345a5ef87e6fb 100644 (file)
@@ -23,7 +23,7 @@
 #include "superiotool.h"
 
 /* Command line options. */
-int dump = 0, verbose = 0;
+int dump = 0, dump_readable = 0, verbose = 0;
 
 uint8_t regval(uint16_t port, uint8_t reg)
 {
@@ -147,6 +147,13 @@ void dump_superio(const char *vendor,
        }
 }
 
+void dump_superio_readable(uint16_t port)
+{
+       /* TODO */
+       if (dump_readable)
+               printf("No human-readable dump available for this Super I/O\n");
+}
+
 void no_superio_found(uint16_t port)
 {
        if (!verbose)
@@ -164,19 +171,23 @@ int main(int argc, char *argv[])
        int i, j, opt, option_index;
 
        const static struct option long_options[] = {
-               {"dump",        no_argument, NULL, 'd'},
-               {"verbose",     no_argument, NULL, 'V'},
-               {"version",     no_argument, NULL, 'v'},
-               {"help",        no_argument, NULL, 'h'},
+               {"dump",                no_argument, NULL, 'd'},
+               {"dump-readable",       no_argument, NULL, 'D'},
+               {"verbose",             no_argument, NULL, 'V'},
+               {"version",             no_argument, NULL, 'v'},
+               {"help",                no_argument, NULL, 'h'},
                {0, 0, 0, 0}
        };
 
-       while ((opt = getopt_long(argc, argv, "dVvh",
+       while ((opt = getopt_long(argc, argv, "dDVvh",
                                  long_options, &option_index)) != EOF) {
                switch (opt) {
                case 'd':
                        dump = 1;
                        break;
+               case 'D':
+                       dump_readable = 1;
+                       break;
                case 'V':
                        verbose = 1;
                        break;
index 9b82b4cf9d755aadf0eb007c39d2c7db66853466..493c841058c1fee059217ff9a914695070b8b331 100644 (file)
 
 #define SUPERIOTOOL_VERSION "0.1"
 
-#define USAGE "Usage: superiotool [-d] [-V] [-v] [-h]\n\n\
-  -d | --dump      Dump Super I/O registers\n\
-  -V | --verbose   Verbose mode\n\
-  -v | --version   Show the superiotool version\n\
-  -h | --help      Show a short help text\n\n\
+#define USAGE "Usage: superiotool [-d] [-D] [-V] [-v] [-h]\n\n\
+  -d | --dump            Dump Super I/O registers\n\
+  -D | --dump-readable   Dump Super I/O registers in human-readable format\n\
+  -V | --verbose         Verbose mode\n\
+  -v | --version         Show the superiotool version\n\
+  -h | --help            Show a short help text\n\n\
 Per default (no options) superiotool will just probe for a Super I/O\n\
 and print its vendor, name, ID, version, and config port.\n"
 
@@ -54,14 +55,14 @@ and print its vendor, name, ID, version, and config port.\n"
 #define MAXNUMPORTS    (2 + 1)         /* Maximum number of Super I/O ports */
 
 /* Command line parameters. */
-extern int dump, verbose;
+extern int dump, dump_readable, verbose;
 
 struct superio_registers {
-       int32_t superio_id; /* Signed, as we need EOT. */
-       const char name[MAXNAMELEN];
+       int32_t superio_id;             /* Signed, as we need EOT. */
+       const char name[MAXNAMELEN];    /* Super I/O name */
        struct {
                int ldn;
-               const char *name;
+               const char *name;       /* LDN name */
                int idx[IDXSIZE];
                int def[IDXSIZE];
        } ldn[LDNSIZE];
@@ -77,18 +78,16 @@ const char *get_superio_name(const struct superio_registers reg_table[],
                             uint16_t id);
 void dump_superio(const char *name, const struct superio_registers reg_table[],
                  uint16_t port, uint16_t id);
+void dump_superio_readable(uint16_t port);
 void no_superio_found(uint16_t port);
 
 /* fintek.c */
-void dump_fintek(uint16_t port, uint16_t did);
 void probe_idregs_fintek(uint16_t port);
 
 /* ite.c */
-void dump_ite(uint16_t port, uint16_t id);
 void probe_idregs_ite(uint16_t port);
 
 /* nsc.c */
-void dump_ns8374(uint16_t port);
 void probe_idregs_simple(uint16_t port);
 
 /* smsc.c */
index 0e8f2b86f8b7db518338dfc0741d5cf034e5de3e..9dbaba80d58cddba2d75a44cab606e606b5d2956 100644 (file)
@@ -150,6 +150,7 @@ void probe_idregs_winbond(uint16_t port)
 
        /* TODO: Special notes in dump output for the MISC entries. */
        dump_superio("Winbond", reg_table, port, id);
+       dump_superio_readable(port); /* TODO */
 
        exit_conf_mode_winbond_fintek_ite_8787(port);
 }