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/atavia.c b/atavia.c
index e96c808..34d7b73 100644
--- a/atavia.c
+++ b/atavia.c
@@ -56,6 +56,7 @@
static void atavia_chip_writeb(const struct flashctx *flash, uint8_t val, chipaddr addr);
static uint8_t atavia_chip_readb(const struct flashctx *flash, const chipaddr addr);
+static void *atavia_map(const char *descr, uintptr_t phys_addr, size_t len);
static const struct par_master lpc_master_atavia = {
.chip_readb = atavia_chip_readb,
.chip_readw = fallback_chip_readw,
@@ -65,6 +66,7 @@
.chip_writew = fallback_chip_writew,
.chip_writel = fallback_chip_writel,
.chip_writen = fallback_chip_writen,
+ .map_flash = atavia_map,
};
static void *atavia_offset = NULL;
@@ -191,5 +193,4 @@
.type = PCI,
.devs.dev = ata_via,
.init = atavia_init,
- .map_flash_region = atavia_map,
};