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

Unified Diff: layout.c

Issue 6025013: Add flashmap (fmap) support to Flashrom (Closed) Base URL: svn://coreboot.org/flashrom/trunk
Patch Set: fix a stupid typo 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
« fmap.c ('K') | « 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 31c99f73b521ac37efd715ab76f8bb6009ace04e..33ebb95d5985377a0853b445ec282688ed870503 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
@@ -195,6 +197,55 @@ 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;
+
Louis 2011/03/04 11:01:13 strcpy(rom_entries[romimages].file, "");
dhendrix 2011/03/04 21:46:33 Done.
+ msg_gdbg("%s(): added region \"%s\" as %sincluded, offset: 0x%08x, "
Louis 2011/03/04 11:01:13 nit: exceed 80 columns.
dhendrix 2011/03/04 21:46:33 fixed. thanks for catching that.
+ "size: 0x%08x\n", __func__,
+ rom_entries[romimages].name,
Louis 2011/03/04 11:01:13 add [].file?
dhendrix 2011/03/04 21:46:33 Done. I also updated this debug string to omit th
+ rom_entries[romimages].included ? "" : "not ",
+ rom_entries[romimages].start,
+ rom_entries[romimages].end);
+ romimages++;
+ }
+
+ return fmap->nareas;
+}
+
+
int find_romentry(char *name)
{
int i;
@@ -282,6 +333,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 11:01:13 Why do we limit to "non-readonly" regions?
dhendrix 2011/03/04 21:46:33 I believe that is an obsolete comment, so I have r
+ 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.
*/
« fmap.c ('K') | « fmap.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698