summaryrefslogtreecommitdiff
path: root/flash.h
diff options
context:
space:
mode:
authorstefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2014-08-30 23:39:51 +0000
committerstefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2014-08-30 23:39:51 +0000
commite218311a53921ae44e7d23263c5f25b0e728e5bf (patch)
tree5ca7051747f8161639957c37d984cbe8f878271a /flash.h
parentc7f893affc0116d2081da4ac4545e31dfebe56ed (diff)
downloadflashrom-e218311a53921ae44e7d23263c5f25b0e728e5bf.tar.gz
Refine physical address mapping of flash chips.
- Create distinct functions for mapping and unmapping for flash chips. - Map only when needed: map before probing and unmap immediately after it. Map again when a single chip was probed successfully before taking any actual actions and clean up afterwards. - Map special function chip registers centrally together with flash space instead of within (some) probing methods after successful probes. - Save the used base addresses of the mappings in struct flashctx as well. - Do not try to (un)map the zero-sized chip definitions that are merely hacks. This also fixes the printing of wrong warnings for these chip definitions introduced in r1765. Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1847 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'flash.h')
-rw-r--r--flash.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/flash.h b/flash.h
index 301eb7a..a5d3a55 100644
--- a/flash.h
+++ b/flash.h
@@ -48,9 +48,9 @@ typedef uintptr_t chipaddr;
/* 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 FL_MAX_CHIPOFF_BITS (24)
+#define FL_MAX_CHIPOFF ((chipoff_t)(1ULL<<FL_MAX_CHIPOFF_BITS)-1)
+#define PRIxCHIPOFF "06"PRIx32
#define PRIuCHIPSIZE PRIu32
int register_shutdown(int (*function) (void *data), void *data);
@@ -209,8 +209,14 @@ struct flashchip {
struct flashctx {
struct flashchip *chip;
+ /* FIXME: The memory mappings should be saved in a more structured way. */
+ /* The physical_* fields store the respective addresses in the physical address space of the CPU. */
+ uintptr_t physical_memory;
+ /* The virtual_* fields store where the respective physical address is mapped into flashrom's address
+ * space. A value equivalent to (chipaddr)ERROR_PTR indicates an invalid mapping (or none at all). */
chipaddr virtual_memory;
- /* Some flash devices have an additional register space. */
+ /* Some flash devices have an additional register space; semantics are like above. */
+ uintptr_t physical_registers;
chipaddr virtual_registers;
struct registered_master *mst;
};
@@ -252,7 +258,8 @@ void tolower_string(char *str);
/* flashrom.c */
extern const char flashrom_version[];
extern const char *chip_to_probe;
-void map_flash_registers(struct flashctx *flash);
+int map_flash(struct flashctx *flash);
+void unmap_flash(struct flashctx *flash);
int read_memmapped(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
int erase_flash(struct flashctx *flash);
int probe_flash(struct registered_master *mst, int startchip, struct flashctx *fill_flash, int force);