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

Unified Diff: layout.c

Issue 6025013: Add flashmap (fmap) support to Flashrom (Closed) Base URL: svn://coreboot.org/flashrom/trunk
Patch Set: respond to comments 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
« no previous file with comments | « fmap.c ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: layout.c
diff --git a/layout.c b/layout.c
index d7e835915c5d0954deb658d5ff9755a67cc0fe52..8e880fdc10765345e321740e9b2e21ae13f536f7 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
@@ -201,6 +203,56 @@ 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;
+
+ /*
+ * Flashrom rom entries use absolute addresses. So for non-zero
+ * length entries, we need to subtract 1 from offset + size to
+ * determine the end address.
+ */
+ rom_entries[romimages].end = fmap->areas[i].offset +
+ fmap->areas[i].size;
+ if (fmap->areas[i].size)
+ rom_entries[romimages].end--;
+
+ memset(rom_entries[romimages].name, 0,
+ sizeof(rom_entries[romimages].name));
+ memcpy(rom_entries[romimages].name, fmap->areas[i].name,
+ min(sizeof(rom_entries[romimages].name),
+ sizeof(fmap->areas[i].name)));
+
+ rom_entries[romimages].included = 0;
+ strcpy(rom_entries[romimages].file, "");
+
+ msg_gdbg("added fmap region \"%s\" (file=\"%s\") as %sincluded,"
+ " offset: 0x%08x, size: 0x%08x\n",
+ rom_entries[romimages].name,
+ rom_entries[romimages].file,
+ rom_entries[romimages].included ? "" : "not ",
+ rom_entries[romimages].start,
+ rom_entries[romimages].end);
+ romimages++;
+ }
+
+ return fmap->nareas;
+}
+
/* register an include argument (-i) for later processing */
int register_include_arg(char *name)
{
@@ -329,6 +381,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 */
Louis 2011/03/04 23:33:16 Oooops. I guess you forgot to remove this comment.
dhendrix 2011/03/05 00:25:30 Fixed (note: this call and the updated comment are
+ 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.
*/
« no previous file with comments | « fmap.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698