Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1394)

Unified Diff: utility/dump_fmap.c

Issue 6465018: Add load_firmware_test utility program (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: utility/dump_fmap.c
diff --git a/utility/dump_fmap.c b/utility/dump_fmap.c
index ab92b82a28d463e00bdb6813f362273ae4e5ca2e..566fa8dfac7be10203c9d1b238884c62bab64adf 100644
--- a/utility/dump_fmap.c
+++ b/utility/dump_fmap.c
@@ -15,32 +15,13 @@
#include <sys/types.h>
#include <unistd.h>
+#include "fmap.h"
+
/* global variables */
static int opt_extract = 0;
static char *progname;
static void *base_of_rom;
-/* FMAP structs. See http://code.google.com/p/flashmap/wiki/FmapSpec */
-#define FMAP_SIGLEN 8
-#define FMAP_NAMELEN 32
-#define FMAP_SEARCH_STRIDE 4
-typedef struct _FmapHeader {
- char fmap_signature[FMAP_SIGLEN]; /* avoiding endian issues */
- uint8_t fmap_ver_major;
- uint8_t fmap_ver_minor;
- uint64_t fmap_base;
- uint32_t fmap_size;
- char fmap_name[FMAP_NAMELEN];
- uint16_t fmap_nareas;
-} __attribute__((packed)) FmapHeader;
-
-typedef struct _AreaHeader {
- uint32_t area_offset;
- uint32_t area_size;
- char area_name[FMAP_NAMELEN];
- uint16_t area_flags;
-} __attribute__((packed)) AreaHeader;
-
/* Return 0 if successful */
static int dump_fmap(void *ptr) {
@@ -100,7 +81,6 @@ int main(int argc, char *argv[]) {
struct stat sb;
int fd;
char *s;
- size_t i;
int retval = 1;
progname = strrchr(argv[0], '/');
@@ -170,14 +150,10 @@ int main(int argc, char *argv[]) {
}
close(fd); /* done with this now */
- s = (char *)base_of_rom;
- for (i=0; i<sb.st_size; i += FMAP_SEARCH_STRIDE) {
- if (0 == strncmp(s, "__FMAP__", 8)) {
- printf("hit at 0x%08x\n", (uint32_t)i);
- retval = dump_fmap(s);
- break;
- }
- s += FMAP_SEARCH_STRIDE;
+ s = find_fmap((char *) base_of_rom, sb.st_size);
gauravsh 2011/02/09 19:58:22 change variable name 's' to something more informa
Che-Liang Chiou 2011/02/10 09:11:03 Done.
+ if (s) {
+ printf("hit at 0x%08x\n", (uint32_t) (s - (char *) base_of_rom));
+ retval = dump_fmap(s);
}
if (0 != munmap(base_of_rom, sb.st_size)) {

Powered by Google App Engine
This is Rietveld 408576698