summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--flashrom.c2
-rw-r--r--programmer.h1
-rw-r--r--serprog.c16
3 files changed, 18 insertions, 1 deletions
diff --git a/flashrom.c b/flashrom.c
index a389cb2..d51a44c 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -212,7 +212,7 @@ const struct programmer_entry programmer_table[] = {
/* FIXME */
.devs.note = "All programmer devices speaking the serprog protocol\n",
.init = serprog_init,
- .map_flash_region = fallback_map,
+ .map_flash_region = serprog_map,
.unmap_flash_region = fallback_unmap,
.delay = serprog_delay,
},
diff --git a/programmer.h b/programmer.h
index 913522b..3bf292d 100644
--- a/programmer.h
+++ b/programmer.h
@@ -706,6 +706,7 @@ int register_master(const struct registered_master *mst);
#if CONFIG_SERPROG == 1
int serprog_init(void);
void serprog_delay(unsigned int usecs);
+void *serprog_map(const char *descr, uintptr_t phys_addr, size_t len);
#endif
/* serial.c */
diff --git a/serprog.c b/serprog.c
index 3de0182..a2a3fe0 100644
--- a/serprog.c
+++ b/serprog.c
@@ -943,3 +943,19 @@ static int serprog_spi_read(struct flashctx *flash, uint8_t *buf,
}
return 0;
}
+
+void *serprog_map(const char *descr, uintptr_t phys_addr, size_t len)
+{
+ /* Serprog transmits 24 bits only and assumes the underlying implementation handles any remaining bits
+ * correctly (usually setting them to one either in software (for FWH/LPC) or relying on the fact that
+ * the hardware observes a subset of the address bits only). Combined with the standard mapping of
+ * flashrom this creates a 16 MB-wide window just below the 4 GB boundary where serprog can operate (as
+ * needed for non-SPI chips). Below we make sure that the requested range is within this window. */
+ if ((phys_addr & 0xFF000000) == 0xFF000000) {
+ return (void*)phys_addr;
+ } else {
+ msg_pwarn(MSGHEADER "requested mapping %s is incompatible: 0x%zx bytes at 0x%0*" PRIxPTR ".\n",
+ descr, len, PRIxPTR_WIDTH, phys_addr);
+ return NULL;
+ }
+}
OpenPOWER on IntegriCloud