Index: layout.c |
diff --git a/layout.c b/layout.c |
index 0dbb556c64ff8b8ceb74742ecf3ab1853a3fdb4f..ae4ef5752a625e8d78f3b1b7d91bbb89f565a9b8 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,31 @@ int read_romlayout(char *name) |
} |
#endif |
+/* returns the number of entries added */ |
+static int add_fmap_entries(uint8_t *image, int size) |
+{ |
+ int i; |
+ struct fmap *fmap; |
+ long int fmap_offset; |
+ |
+ fmap_offset = fmap_find(image, size); |
Louis
2010/12/30 02:57:08
hm... shall we check the return value for fmap_fin
dhendrix
2010/12/31 00:47:02
Yes, definitely! I had only tested using BIOSes wi
|
+ fmap = (struct fmap *)(image + fmap_offset);; |
+ |
+ for (i = 0; i < fmap->nareas; i++) { |
+ rom_entries[romimages].start = fmap->areas[i].offset; |
+ rom_entries[romimages].end = fmap->areas[i].offset + |
+ fmap->areas[i].size; |
Louis
2010/12/30 02:57:08
should be .offset + .size "- 1" since .end is the
dhendrix
2010/12/31 00:47:02
yes
|
+ if (fmap->areas[i].flags & FMAP_AREA_RO) |
Louis
2010/12/30 02:57:08
hm... does this imply we CANNOT update the whole i
dhendrix
2010/12/31 00:47:02
Correct. Using this approach, the way to override
Louis
2010/12/31 09:13:30
This changes the behavior too much and becomes mor
dhendrix
2011/03/04 00:06:17
Agreed.
|
+ rom_entries[romimages].included = 0; |
+ else |
+ rom_entries[romimages].included = 1; |
+ romimages++; |
Louis
2010/12/30 02:57:08
Shall we check the romimages if bigger than size o
dhendrix
2010/12/31 00:47:02
Yes. I added a check near the top of this loop.
b
|
+ } |
+ |
+ return fmap->nareas; |
+} |
+ |
+ |
int find_romentry(char *name) |
{ |
int i; |
@@ -237,6 +264,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. |
*/ |