From 556ec4fd6089cc54dc06902d9c4e1831609332a5 Mon Sep 17 00:00:00 2001 From: Hung-Te Lin Date: Thu, 20 Jun 2013 10:32:48 +0800 Subject: dump_fmap: Find correct FMAP structure by checking version. Firmware images reading its own FMAP structure may have FMAP signature in code and cause dump_fmap to parse incorrectly. Since currently there is only one major version for FMAP (and the structure defined in fmap.h also applies only to current version), we can improve that by checking major version number to skip signatures in firmware code. BUG=chromium:236347 TEST=emerge vboot_reference; dump_fmap /build/daisy/firmware/image.bin # success BRANCH=none Change-Id: I1d8f49bb88357e7a3a945fbdba9d9a7c4e177ac4 Reviewed-on: https://gerrit.chromium.org/gerrit/59362 Reviewed-by: Bill Richardson Reviewed-by: David Hendricks Tested-by: Hung-Te Lin Commit-Queue: Gabe Black --- host/lib/fmap.c | 11 ++++++++--- host/lib/include/fmap.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/host/lib/fmap.c b/host/lib/fmap.c index 3c3f340b..014c97b2 100644 --- a/host/lib/fmap.c +++ b/host/lib/fmap.c @@ -12,10 +12,15 @@ const char* FmapFind(const char* ptr, size_t size) { size_t i; - for (i=0; ifmap_ver_major == FMAP_VER_MAJOR) return ptr; - ptr += FMAP_SEARCH_STRIDE; } return NULL; } diff --git a/host/lib/include/fmap.h b/host/lib/include/fmap.h index 7da2dd90..92d74fd3 100644 --- a/host/lib/include/fmap.h +++ b/host/lib/include/fmap.h @@ -15,6 +15,7 @@ #define FMAP_SIGNATURE "__FMAP__" #define FMAP_SIGNATURE_SIZE 8 #define FMAP_SEARCH_STRIDE 4 +#define FMAP_VER_MAJOR 1 typedef struct _FmapHeader { char fmap_signature[FMAP_SIGNATURE_SIZE]; /* avoiding endian issues */ uint8_t fmap_ver_major; -- cgit v1.2.1