superiotool: Add an alternative dump format

Add new dump format to superiotool that prints each register on a
separate line. This should be more suitable for diff'ing dumps of
multiple superiotool runs.

Change-Id: I226ee82b903bf77e760d3396d02fa50688adb9f2
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: https://review.coreboot.org/17003
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
Nico Huber 2016-10-12 12:12:51 +02:00 committed by Nico Huber
parent 8a9b7b59e3
commit 3812a72907
2 changed files with 57 additions and 28 deletions

View File

@ -25,7 +25,7 @@
#endif #endif
/* Command line options. */ /* Command line options. */
int dump = 0, verbose = 0, extra_dump = 0; int dump = 0, verbose = 0, extra_dump = 0, alternate_dump = 0;
/* Global flag which indicates whether a chip was detected at all. */ /* Global flag which indicates whether a chip was detected at all. */
int chip_found = 0; int chip_found = 0;
@ -105,7 +105,7 @@ static void dump_regs(const struct superio_registers reg_table[],
int i, int j, uint16_t port, uint8_t ldn_sel) int i, int j, uint16_t port, uint8_t ldn_sel)
{ {
int k; int k;
const int16_t *idx; const int16_t *idx, *def;
if (reg_table[i].ldn[j].ldn != NOLDN) { if (reg_table[i].ldn[j].ldn != NOLDN) {
printf("LDN 0x%02x", reg_table[i].ldn[j].ldn); printf("LDN 0x%02x", reg_table[i].ldn[j].ldn);
@ -120,7 +120,31 @@ static void dump_regs(const struct superio_registers reg_table[],
} }
idx = reg_table[i].ldn[j].idx; idx = reg_table[i].ldn[j].idx;
def = reg_table[i].ldn[j].def;
if (alternate_dump) {
int skip_def = 0;
printf("\nidx val def\n");
for (k = 0; idx[k] != EOT; k++) {
printf("0x%02x: 0x%02x", idx[k], regval(port, idx[k]));
if (skip_def || def[k] == EOT) {
skip_def = 1;
printf("\n");
continue;
}
if (def[k] == NANA)
printf(" (NA)\n");
else if (def[k] == RSVD)
printf(" (RR)\n");
else if (def[k] == MISC)
printf(" (MM)\n");
else
printf(" (0x%02x)\n", def[k]);
}
} else {
printf("\nidx"); printf("\nidx");
for (k = 0; idx[k] != EOT; k++) { for (k = 0; idx[k] != EOT; k++) {
if (k && !(k % 8)) if (k && !(k % 8))
@ -136,18 +160,18 @@ static void dump_regs(const struct superio_registers reg_table[],
} }
printf("\ndef"); printf("\ndef");
idx = reg_table[i].ldn[j].def; for (k = 0; def[k] != EOT; k++) {
for (k = 0; idx[k] != EOT; k++) {
if (k && !(k % 8)) if (k && !(k % 8))
putchar(' '); putchar(' ');
if (idx[k] == NANA) if (def[k] == NANA)
printf(" NA"); printf(" NA");
else if (idx[k] == RSVD) else if (def[k] == RSVD)
printf(" RR"); printf(" RR");
else if (idx[k] == MISC) else if (def[k] == MISC)
printf(" MM"); printf(" MM");
else else
printf(" %02x", idx[k]); printf(" %02x", def[k]);
}
} }
printf("\n"); printf("\n");
} }
@ -270,6 +294,7 @@ int main(int argc, char *argv[])
static const struct option long_options[] = { static const struct option long_options[] = {
{"dump", no_argument, NULL, 'd'}, {"dump", no_argument, NULL, 'd'},
{"extra-dump", no_argument, NULL, 'e'}, {"extra-dump", no_argument, NULL, 'e'},
{"alternate-dump", no_argument, NULL, 'a'},
{"list-supported", no_argument, NULL, 'l'}, {"list-supported", no_argument, NULL, 'l'},
{"verbose", no_argument, NULL, 'V'}, {"verbose", no_argument, NULL, 'V'},
{"version", no_argument, NULL, 'v'}, {"version", no_argument, NULL, 'v'},
@ -277,7 +302,7 @@ int main(int argc, char *argv[])
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
while ((opt = getopt_long(argc, argv, "delVvh", while ((opt = getopt_long(argc, argv, "dealVvh",
long_options, &option_index)) != EOF) { long_options, &option_index)) != EOF) {
switch (opt) { switch (opt) {
case 'd': case 'd':
@ -286,6 +311,9 @@ int main(int argc, char *argv[])
case 'e': case 'e':
extra_dump = 1; extra_dump = 1;
break; break;
case 'a':
alternate_dump = 1;
break;
case 'l': case 'l':
print_list_of_supported_chips(); print_list_of_supported_chips();
exit(0); exit(0);

View File

@ -108,9 +108,10 @@ static __inline__ uint32_t inl(uint16_t port)
} }
#endif #endif
#define USAGE "Usage: superiotool [-d] [-e] [-l] [-V] [-v] [-h]\n\n\ #define USAGE "Usage: superiotool [-d] [-e] [-a] [-l] [-V] [-v] [-h]\n\n\
-d | --dump Dump Super I/O register contents\n\ -d | --dump Dump Super I/O register contents\n\
-e | --extra-dump Dump secondary registers too (e.g. EC registers)\n\ -e | --extra-dump Dump secondary registers too (e.g. EC registers)\n\
-a | --alternate-dump Use alternative dump format, more suitable for diff\n\
-l | --list-supported Show the list of supported Super I/O chips\n\ -l | --list-supported Show the list of supported Super I/O chips\n\
-V | --verbose Verbose mode\n\ -V | --verbose Verbose mode\n\
-v | --version Show the superiotool version\n\ -v | --version Show the superiotool version\n\