Index: layout.c |
diff --git a/layout.c b/layout.c |
index 0dbb556c64ff8b8ceb74742ecf3ab1853a3fdb4f..3e73b3f5846ea8dd4b81ada6ad0c8ec96f3f83ef 100644 |
--- a/layout.c |
+++ b/layout.c |
@@ -3,6 +3,7 @@ |
* |
* Copyright (C) 2005-2008 coresystems GmbH |
* (Written by Stefan Reinauer <stepan@coresystems.de> for coresystems GmbH) |
+ * Portions (C) 2010 Google Inc. |
* |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
@@ -24,6 +25,7 @@ |
#include <ctype.h> |
#include <limits.h> |
#include "flash.h" |
+#include "fmap.h" |
#include "programmer.h" |
#if CONFIG_INTERNAL == 1 |
@@ -185,6 +187,50 @@ int read_romlayout(char *name) |
} |
#endif |
+/* returns the number of entries added, or <0 to indicate error */ |
+static int add_fmap_entries(uint8_t *image, int size) |
+{ |
+ int i; |
+ struct fmap *fmap; |
+ long int fmap_offset; |
+ |
+ if ((fmap_offset = fmap_find(image, size)) < 0) |
+ return 0; |
+ fmap = (struct fmap *)(image + fmap_offset);; |
+ |
+ for (i = 0; i < fmap->nareas; i++) { |
+ if (romimages >= MAX_ROMLAYOUT) { |
+ msg_gerr("ROM image contains too many regions\n"); |
+ return -1; |
+ } |
+ rom_entries[romimages].start = fmap->areas[i].offset; |
+ rom_entries[romimages].end = fmap->areas[i].offset + |
+ fmap->areas[i].size - 1; |
+ memcpy(rom_entries[romimages].name, fmap->areas[i].name, |
Louis
2010/12/31 09:13:30
remember do this before copy:
memset(rom_entries[r
dhendrix
2011/03/04 00:06:17
Done.
|
+ min(sizeof(rom_entries[romimages].name), |
+ sizeof(fmap->areas[i].name))); |
+ |
+ if (fmap->areas[i].flags & FMAP_AREA_RO) |
+ rom_entries[romimages].included = 0; |
+ else |
+ rom_entries[romimages].included = 1; |
+#if 0 |
+ rom_entries[romimages].included = 0; |
+#endif |
+ |
+ msg_gdbg("%s(): added region \"%s\" as %sincluded, offset: 0x%08x, size: 0x%08x\n", |
+ __func__, |
+ rom_entries[romimages].name, |
+ rom_entries[romimages].included ? "" : "not ", |
+ rom_entries[romimages].start, |
+ rom_entries[romimages].end); |
+ romimages++; |
+ } |
+ |
+ return fmap->nareas; |
+} |
+ |
+ |
int find_romentry(char *name) |
{ |
int i; |
@@ -237,6 +283,9 @@ int handle_romentries(struct flashchip *flash, uint8_t *oldcontents, uint8_t *ne |
int entry; |
unsigned int size = flash->total_size * 1024; |
+ /* add entries for non-readonly regions specified in flashmap */ |
+ add_fmap_entries(oldcontents, size); |
+ |
/* If no layout file was specified or the layout file was empty, assume |
* that the user wants to flash the complete new image. |
*/ |