summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJani Nikula <jani.nikula@intel.com>2017-10-20 16:24:50 +0300
committerJani Nikula <jani.nikula@intel.com>2018-01-23 16:55:19 +0200
commit37bd27f28a868c287faf361864a16e77b8d9246f (patch)
tree0e0a76b2a14c26b012108b19fe160a7288906110 /tools
parent7c8b863d7dffd0519c11aa25a91709cdfceeef62 (diff)
tools/intel_vbt_decode: add --describe option
Print description of the form <bdb-version>-<vbt-signature> that could be used for e.g. filenames. Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/intel_vbt_decode.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/tools/intel_vbt_decode.c b/tools/intel_vbt_decode.c
index 00faca42..d7cbc436 100644
--- a/tools/intel_vbt_decode.c
+++ b/tools/intel_vbt_decode.c
@@ -25,6 +25,7 @@
*
*/
+#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
@@ -1662,6 +1663,33 @@ static bool dump_section(struct context *context, int section_id)
return true;
}
+/* print a description of the VBT of the form <bdb-version>-<vbt-signature> */
+static void print_description(struct context *context)
+{
+ const struct vbt_header *vbt = context->vbt;
+ const struct bdb_header *bdb = context->bdb;
+ char *desc = strndup((char *)vbt->signature, sizeof(vbt->signature));
+ char *p;
+
+ for (p = desc + strlen(desc) - 1; p >= desc && isspace(*p); p--)
+ *p = '\0';
+
+ for (p = desc; *p; p++) {
+ if (!isalnum(*p))
+ *p = '-';
+ else
+ *p = tolower(*p);
+ }
+
+ p = desc;
+ if (strncmp(p, "-vbt-", 5) == 0)
+ p += 5;
+
+ printf("%d-%s\n", bdb->version, p);
+
+ free (desc);
+}
+
static void dump_headers(struct context *context)
{
const struct vbt_header *vbt = context->vbt;
@@ -1725,6 +1753,7 @@ enum opt {
OPT_BLOCK,
OPT_USAGE,
OPT_HEADER,
+ OPT_DESCRIBE,
};
static void usage(const char *toolname)
@@ -1737,6 +1766,7 @@ static void usage(const char *toolname)
" [--hexdump]"
" [--block=<block_no>]"
" [--header]"
+ " [--describe]"
" [--help]\n");
}
@@ -1757,7 +1787,7 @@ int main(int argc, char **argv)
};
char *endp;
int block_number = -1;
- bool header_only = false;
+ bool header_only = false, describe = false;
static struct option options[] = {
{ "file", required_argument, NULL, OPT_FILE },
@@ -1767,6 +1797,7 @@ int main(int argc, char **argv)
{ "hexdump", no_argument, NULL, OPT_HEXDUMP },
{ "block", required_argument, NULL, OPT_BLOCK },
{ "header", no_argument, NULL, OPT_HEADER },
+ { "describe", no_argument, NULL, OPT_DESCRIBE },
{ "help", no_argument, NULL, OPT_USAGE },
{ 0 }
};
@@ -1810,6 +1841,9 @@ int main(int argc, char **argv)
case OPT_HEADER:
header_only = true;
break;
+ case OPT_DESCRIBE:
+ describe = true;
+ break;
case OPT_END:
break;
case OPT_USAGE: /* fall-through */
@@ -1913,7 +1947,9 @@ int main(int argc, char **argv)
context.panel_type = 0;
}
- if (header_only) {
+ if (describe) {
+ print_description(&context);
+ } else if (header_only) {
dump_headers(&context);
} else if (block_number != -1) {
/* dump specific section only */