diff options
author | Bill Richardson <wfrichar@chromium.org> | 2012-03-01 11:05:29 -0800 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-03-02 09:44:30 -0800 |
commit | e7e8ecd3e2c232d1695fe5b7243bc396e6774440 (patch) | |
tree | 0422d1b59e9dd0cb310bf9402cd6f52cbbf911f7 | |
parent | f0605cbdc36f58829a908a3333e438c565c8c7af (diff) | |
download | vboot-e7e8ecd3e2c232d1695fe5b7243bc396e6774440.tar.gz |
Specify the sections you want dump_fmap to dump, if not all
BUG=none
TEST=manual
Compare
dump_fmap -f bios.bin
with
dump_fmap -f bios.bin FW_MAIN_A FW_MAIN_B GBB
Change-Id: Id567113ab5e7121422b89f00d9eb8c0b27942259
Reviewed-on: https://gerrit.chromium.org/gerrit/17179
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Tested-by: Bill Richardson <wfrichar@chromium.org>
Commit-Ready: Bill Richardson <wfrichar@chromium.org>
-rw-r--r-- | utility/dump_fmap.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/utility/dump_fmap.c b/utility/dump_fmap.c index 0b88029b..daffdf3b 100644 --- a/utility/dump_fmap.c +++ b/utility/dump_fmap.c @@ -27,8 +27,8 @@ static void* base_of_rom; /* Return 0 if successful */ -static int dump_fmap(const void* ptr) { - int i,retval = 0; +static int dump_fmap(const void* ptr, int argc, char *argv[]) { + int i,j,retval = 0; char buf[80]; // DWR: magic number const FmapHeader* fmh = (const FmapHeader*) ptr; const FmapAreaHeader* ah = (const FmapAreaHeader*) (ptr + sizeof(FmapHeader)); @@ -45,8 +45,21 @@ static int dump_fmap(const void* ptr) { printf("fmap_nareas: %d\n", fmh->fmap_nareas); } - for (i=0; i<fmh->fmap_nareas; i++) { + for (i=0; i<fmh->fmap_nareas; i++, ah++) { snprintf(buf, FMAP_NAMELEN+1, "%s", ah->area_name); + + if (argc) { + int j, found=0; + for (j=0; j<argc; j++) + if (!strcmp(argv[j], buf)) { + found = 1; + break; + } + if (!found) { + continue; + } + } + switch(opt_format) { case FMT_PRETTY: @@ -87,8 +100,6 @@ static int dump_fmap(const void* ptr) { fclose(fp); } } - - ah++; } return retval; @@ -140,10 +151,12 @@ int main(int argc, char* argv[]) { if (errorcnt || optind >= argc) { fprintf(stderr, - "\nUsage: %s [-x] [-p|-f] FLASHIMAGE\n\n" + "\nUsage: %s [-x] [-p|-f] FLASHIMAGE [NAME...]\n\n" "Display (and extract with -x) the FMAP components from a BIOS image.\n" "The -p option makes the output easier to parse by scripts.\n" - "The -f option emits the FMAP in the format used by flashrom\n" + "The -f option emits the FMAP in the format used by flashrom.\n" + "\n" + "Specify one or more NAMEs to only print sections that exactly match.\n" "\n", progname); return 1; @@ -183,7 +196,7 @@ int main(int argc, char* argv[]) { if (fmap) { if (FMT_NORMAL == opt_format) printf("hit at 0x%08x\n", (uint32_t) (fmap - (char*) base_of_rom)); - retval = dump_fmap(fmap); + retval = dump_fmap(fmap, argc-optind-1, argv+optind+1); } if (0 != munmap(base_of_rom, sb.st_size)) { |