aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJonathon Hall <jonathon.hall@puri.sm>2022-09-16 17:05:20 -0400
committerAngel Pons <th3fanbus@gmail.com>2022-10-08 18:45:03 +0000
commit5afd4aeecec3793e62f9b5af363ee300bc879167 (patch)
tree2c4d8fc92e772deba6c861991395841d6de1fe7d /include
parent67d50156170b17e5bca460ab6e5648e2b11f061c (diff)
downloadflashrom-5afd4aeecec3793e62f9b5af363ee300bc879167.tar.gz
flashrom-5afd4aeecec3793e62f9b5af363ee300bc879167.tar.bz2
flashrom-5afd4aeecec3793e62f9b5af363ee300bc879167.zip
drivers: Move (un)map_flash_region to par/spi/opaque_master
Move (un)map_flash_region function pointers from programmer_entry to par_master, spi_master, and opaque_master. This enables programmers to specify a different mapper per bus, which is needed for the internal programmer. Mapping is closely tied to the way the memory is accessed using the other functions in the bus master structs. Validate that FWH/LPC programmers provide specialized mapping in register_par_master(); this is needed for chips with FEATURE_REGISTERMAP, which only exist on FWH or LPC buses. programmer.c: Update comment in fallback_map(), NULL return is the desired behavior. Test: Read firmware on SB600 Promontory mainboard (requires physmap) Test: Read firmware externally with ft2232_spi Test: Read firmware on ICH hwseq, verify physmap still occurs Change-Id: I9c3df6ae260bcdb246dfb0cd8e043919609b014b Signed-off-by: Jonathon Hall <jonathon.hall@puri.sm> Co-Authored-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/67695 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'include')
-rw-r--r--include/flash.h7
-rw-r--r--include/programmer.h9
2 files changed, 11 insertions, 5 deletions
diff --git a/include/flash.h b/include/flash.h
index 79aaa64a..c696f64e 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -55,8 +55,11 @@ typedef uintptr_t chipaddr;
#define PRIxPTR_WIDTH ((int)(sizeof(uintptr_t)*2))
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);
+struct registered_master;
+void *master_map_flash_region(const struct registered_master *mast,
+ const char *descr, uintptr_t phys_addr, size_t len);
+void master_unmap_flash_region(const struct registered_master *mast,
+ void *virt_addr, size_t len);
void programmer_delay(unsigned int usecs);
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
diff --git a/include/programmer.h b/include/programmer.h
index 17abfd22..4b5bf92a 100644
--- a/include/programmer.h
+++ b/include/programmer.h
@@ -50,9 +50,6 @@ struct programmer_entry {
int (*init) (const struct programmer_cfg *cfg);
- void *(*map_flash_region) (const char *descr, uintptr_t phys_addr, size_t len);
- void (*unmap_flash_region) (void *virt_addr, size_t len);
-
void (*delay) (unsigned int usecs);
};
@@ -309,6 +306,8 @@ struct spi_master {
int (*multicommand)(const struct flashctx *flash, struct spi_command *cmds);
/* Optimized functions for this master */
+ void *(*map_flash_region) (const char *descr, uintptr_t phys_addr, size_t len);
+ void (*unmap_flash_region) (void *virt_addr, size_t len);
int (*read)(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
int (*write_256)(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
int (*write_aai)(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
@@ -399,6 +398,8 @@ int wbsio_check_for_spi(void);
/* opaque.c */
struct opaque_master {
+ void *(*map_flash_region) (const char *descr, uintptr_t phys_addr, size_t len);
+ void (*unmap_flash_region) (void *virt_addr, size_t len);
int max_data_read;
int max_data_write;
/* Specific functions for this master */
@@ -424,6 +425,8 @@ int register_opaque_master(const struct opaque_master *mst, void *data);
/* parallel.c */
struct par_master {
+ void *(*map_flash_region) (const char *descr, uintptr_t phys_addr, size_t len);
+ void (*unmap_flash_region) (void *virt_addr, size_t len);
void (*chip_writeb) (const struct flashctx *flash, uint8_t val, chipaddr addr);
void (*chip_writew) (const struct flashctx *flash, uint16_t val, chipaddr addr);
void (*chip_writel) (const struct flashctx *flash, uint32_t val, chipaddr addr);