memory_bus: Move (un)map_flash_region into par master
Now that the map/unmap_flash functions are only called from memory-
mapped chip drivers, we can safely move the hooks into the parallel
masters.
This also allows us to move the code away from the globals in
`flashprog.c` into a new `memory_bus.c`.
Change-Id: Ic476cf4d96200232900537b997e1d07bb4e8b809
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/72522
Reviewed-by: Riku Viitanen <riku.viitanen@protonmail.com>
diff --git a/serprog.c b/serprog.c
index 3525df7..458fa91 100644
--- a/serprog.c
+++ b/serprog.c
@@ -343,6 +343,7 @@
const chipaddr addr);
static void serprog_chip_readn(const struct flashctx *flash, uint8_t *buf,
const chipaddr addr, size_t len);
+static void *serprog_map(const char *descr, uintptr_t phys_addr, size_t len);
static const struct par_master par_master_serprog = {
.chip_readb = serprog_chip_readb,
.chip_readw = fallback_chip_readw,
@@ -352,6 +353,7 @@
.chip_writew = fallback_chip_writew,
.chip_writel = fallback_chip_writel,
.chip_writen = fallback_chip_writen,
+ .map_flash = serprog_map,
};
static enum chipbustype serprog_buses_supported = BUS_NONE;
@@ -1007,6 +1009,5 @@
/* FIXME */
.devs.note = "All programmer devices speaking the serprog protocol\n",
.init = serprog_init,
- .map_flash_region = serprog_map,
.delay = serprog_delay,
};