diff options
author | Nico Huber <nico.huber@secunet.com> | 2016-11-16 16:01:50 +0100 |
---|---|---|
committer | Nico Huber <nico.h@gmx.de> | 2016-12-15 23:47:09 +0100 |
commit | e70bfee425da5ba44d1c14f95fed295168f93287 (patch) | |
tree | 8e738b0bc9163e582f13f97402f6db56eb5f15db /util/ifdfake/ifdfake.c | |
parent | 50ce16354ba3bfe257c47848d855de9dee9ec798 (diff) | |
download | coreboot-e70bfee425da5ba44d1c14f95fed295168f93287.tar.xz |
util/ifdfake: Add number of regions
To make the generated descriptor compatible with latest libflashrom.
Change-Id: I005159dd24e72da9cc43119103c96c5dd5b90a55
Signed-off-by: Nico Huber <nico.huber@secunet.com>
Reviewed-on: https://review.coreboot.org/17447
Tested-by: build bot (Jenkins)
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'util/ifdfake/ifdfake.c')
-rw-r--r-- | util/ifdfake/ifdfake.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/util/ifdfake/ifdfake.c b/util/ifdfake/ifdfake.c index 74c92727ef..b549f3ad8d 100644 --- a/util/ifdfake/ifdfake.c +++ b/util/ifdfake/ifdfake.c @@ -20,6 +20,8 @@ #include <string.h> #include <getopt.h> +#define REGION_COUNT 5 + #define FDBAR_OFFSET 0x10 #define FRBA_OFFSET 0x40 @@ -56,15 +58,15 @@ static void write_image(const region_t regions[], const char *const image) } fdbar; memset(&fdbar, 0x00, sizeof(fdbar)); fdbar.flvalsig = 0x0ff0a55a; - fdbar.flmap0 = (FRBA_OFFSET >> 4) << 16; + fdbar.flmap0 = (REGION_COUNT - 1) << 24 | (FRBA_OFFSET >> 4) << 16; if (fwrite(&fdbar, sizeof(fdbar), 1, f) != 1) { fprintf(stderr, "Failed to write fdbar.\n"); exit(EXIT_FAILURE); } int i; - uint32_t frba[5]; - for (i = 0; i < 5; ++i) { + uint32_t frba[REGION_COUNT]; + for (i = 0; i < REGION_COUNT; ++i) { if (regions[i].size) frba[i] = ((regions[i].limit & 0xfff000) << (16 - 12)) | ((regions[i].base & 0xfff000) >> 12); @@ -149,7 +151,7 @@ static void print_usage(const char *name) int main(int argc, char *argv[]) { int opt, option_index = 0, idx; - region_t regions[5]; + region_t regions[REGION_COUNT]; memset(regions, 0x00, sizeof(regions)); @@ -196,7 +198,7 @@ int main(int argc, char *argv[]) regions[0].base = 0x00000000; regions[0].limit = 0x00000fff; regions[0].size = 0x00001000; - for (idx = 1; idx < 5; ++idx) { + for (idx = 1; idx < REGION_COUNT; ++idx) { if (regions[idx].size) { if (regions[idx].base & 0xfff) fprintf(stderr, "Region %d is " |