aboutsummaryrefslogtreecommitdiff
path: root/futility
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2014-08-27 15:42:24 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-08-29 21:56:17 +0000
commitc0777be638d0cb69caa4e6a8d1573c78435f1865 (patch)
tree11f39f3e11b7847636204637b77010820eb1a2df /futility
parentf16ed878799cc7cf11545c36d6f332c76d612260 (diff)
downloadvboot_reference-c0777be638d0cb69caa4e6a8d1573c78435f1865.tar.gz
cleanup: add some easier-to-use FMAP parsing functions.
The functions that look for the FMAP and its entries should return more useful values. BUG=none BRANCH=ToT TEST=make runtests No functional changes. Change-Id: I4b62ea0de972bceb3d58f4ee8eb82ad065ddcbae Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/214630 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'futility')
-rw-r--r--futility/cmd_dump_fmap.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/futility/cmd_dump_fmap.c b/futility/cmd_dump_fmap.c
index 14bedac6..d1c962cc 100644
--- a/futility/cmd_dump_fmap.c
+++ b/futility/cmd_dump_fmap.c
@@ -30,13 +30,12 @@ static size_t size_of_rom;
static int opt_gaps = 0;
/* Return 0 if successful */
-static int dump_fmap(const void *ptr, int argc, char *argv[])
+static int dump_fmap(const FmapHeader *fmh, int argc, char *argv[])
{
int i, retval = 0;
char buf[80]; /* DWR: magic number */
- const FmapHeader *fmh = (const FmapHeader *)ptr;
- const FmapAreaHeader *ah =
- (const FmapAreaHeader *)(ptr + sizeof(FmapHeader));
+ const FmapAreaHeader *ah;
+ ah = (const FmapAreaHeader *) (fmh + 1);
if (FMT_NORMAL == opt_format) {
snprintf(buf, FMAP_SIGNATURE_SIZE + 1, "%s",
@@ -260,14 +259,12 @@ static void add_child(node_t * p, int n)
}
}
-static int human_fmap(void *p)
+static int human_fmap(const FmapHeader *fmh)
{
- FmapHeader *fmh;
FmapAreaHeader *ah;
int i, j, errorcnt = 0;
int numnodes;
- fmh = (FmapHeader *) p;
ah = (FmapAreaHeader *) (fmh + 1);
/* The challenge here is to generate a directed graph from the
@@ -384,7 +381,7 @@ static int do_dump_fmap(int argc, char *argv[])
int errorcnt = 0;
struct stat sb;
int fd;
- const char *fmap;
+ const FmapHeader *fmap;
int retval = 1;
progname = strrchr(argv[0], '/');
@@ -457,15 +454,15 @@ static int do_dump_fmap(int argc, char *argv[])
close(fd); /* done with this now */
size_of_rom = sb.st_size;
- fmap = FmapFind((char *)base_of_rom, size_of_rom);
+ fmap = fmap_find(base_of_rom, size_of_rom);
if (fmap) {
switch (opt_format) {
case FMT_HUMAN:
- retval = human_fmap((void *)fmap);
+ retval = human_fmap(fmap);
break;
case FMT_NORMAL:
printf("hit at 0x%08x\n",
- (uint32_t) (fmap - (char *)base_of_rom));
+ (uint32_t) ((char *)fmap - (char *)base_of_rom));
/* fallthrough */
default:
retval =