Chromium Code Reviews| Index: layout.c |
| diff --git a/layout.c b/layout.c |
| index c917274a1aeb1fdb4fa98efe56cfb0f7c486ea31..5159793e46b47d626204d1c2d3c6b1626f6e777e 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 |
| @@ -193,6 +195,46 @@ 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; |
| + 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; |
| + |
| + msg_gdbg("%s(): added region \"%s\" as %sincluded, offset: 0x%08x, size: 0x%08x\n", |
|
Louis
2011/03/04 00:40:59
nit: exceeds 80 columns.
dhendrix
2011/03/04 08:04:46
good catch -- fixed.
|
| + __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; |
| @@ -245,6 +287,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); |
|
Louis
2011/03/04 00:40:59
I thought add_fmap_entries() should be called arou
dhendrix
2011/03/04 08:04:46
When responding to this comment, I realized that w
|
| + |
| /* If no layout file was specified or the layout file was empty, assume |
| * that the user wants to flash the complete new image. |
| */ |