summaryrefslogtreecommitdiffstats
path: root/flash.h
diff options
context:
space:
mode:
authorStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2013-09-23 14:21:06 +0000
committerStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2013-09-23 14:21:06 +0000
commitab094de7380ebd6cf0d8335172bc9ddfd5142ad8 (patch)
tree4a5f50d844a729a5806abfed35e79169ca9fd6d2 /flash.h
parente04cd390b3c8abeb72bdd637887dfb9ec8206f26 (diff)
downloadflashrom-ab094de7380ebd6cf0d8335172bc9ddfd5142ad8.zip
flashrom-ab094de7380ebd6cf0d8335172bc9ddfd5142ad8.tar.gz
layout: Verify layout entries before building a new image using them
This fixes a SEGFAULT if a layout entry is included that addresses memory outside the current chip's address range. flashrom will only abort if the offending region(s) is/are included else it will just warn. It will print warnings for regions with negative or zero-length address ranges and bail out after checking all of them. Also, abort for non-write operations if a layout file is given because there is no layout support for other operations yet. Corresponding to flashrom svn r1751. Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Diffstat (limited to 'flash.h')
-rw-r--r--flash.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/flash.h b/flash.h
index 7b88477..e320ced 100644
--- a/flash.h
+++ b/flash.h
@@ -45,6 +45,14 @@
typedef uintptr_t chipaddr;
#define PRIxPTR_WIDTH ((int)(sizeof(uintptr_t)*2))
+/* Types and macros regarding the maximum flash space size supported by generic code. */
+typedef uint32_t chipoff_t; /* Able to store any addressable offset within a supported flash memory. */
+typedef uint32_t chipsize_t; /* Able to store the number of bytes of any supported flash memory. */
+#define FL_MAX_CHIPADDR_BITS (24)
+#define FL_MAX_CHIPADDR ((chipoff_t)(1ULL<<FL_MAX_CHIPADDR_BITS)-1)
+#define PRIxCHIPADDR "06"PRIx32
+#define PRIuCHIPSIZE PRIu32
+
int register_shutdown(int (*function) (void *data), void *data);
void *programmer_map_flash_region(const char *descr, uintptr_t phys_addr, size_t len);
void programmer_unmap_flash_region(void *virt_addr, size_t len);
@@ -319,7 +327,8 @@ __attribute__((format(printf, 2, 3)));
int register_include_arg(char *name);
int process_include_args(void);
int read_romlayout(char *name);
-int handle_romentries(const struct flashctx *flash, uint8_t *oldcontents, uint8_t *newcontents);
+int normalize_romentries(const struct flashctx *flash);
+int build_new_image(const struct flashctx *flash, uint8_t *oldcontents, uint8_t *newcontents);
void layout_cleanup(void);
/* spi.c */
OpenPOWER on IntegriCloud