summaryrefslogtreecommitdiffstats
path: root/flash.h
diff options
context:
space:
mode:
authorStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2014-08-30 23:39:51 +0000
committerStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2014-08-30 23:39:51 +0000
commit4e32ec19b124a7431d1e3fd9f7e75196b7495a7e (patch)
tree5ca7051747f8161639957c37d984cbe8f878271a /flash.h
parent583ea32911f67641daef9d05b3e65176b6923f94 (diff)
downloadast2050-flashrom-4e32ec19b124a7431d1e3fd9f7e75196b7495a7e.zip
ast2050-flashrom-4e32ec19b124a7431d1e3fd9f7e75196b7495a7e.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. Corresponding to flashrom svn r1847. 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.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);
OpenPOWER on IntegriCloud