aboutsummaryrefslogtreecommitdiffstats
path: root/dummyflasher.c
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2021-05-20 20:27:59 +1000
committerEdward O'Callaghan <quasisec@chromium.org>2021-05-24 14:15:22 +0000
commit653eb6977a9342c41d204724151d9369a9c6ff39 (patch)
treecbe038103754bf0d76b9d6e003ad82fa9b9640ca /dummyflasher.c
parent93763e4b2ca97df337bdeb9ad8db66d0d19548e5 (diff)
downloadflashrom-653eb6977a9342c41d204724151d9369a9c6ff39.tar.gz
flashrom-653eb6977a9342c41d204724151d9369a9c6ff39.tar.bz2
flashrom-653eb6977a9342c41d204724151d9369a9c6ff39.zip
dummyflasher.c: Move 'spi_write_256_chunksize' into emu_data
Move 'spi_write_256_chunksize' out of global scope and into the emu_data reentrent struct. BUG=none BRANCH=none TEST=builds Change-Id: I633f4df4bd47e661cd69801f21910b667899d505 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/54721 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Diffstat (limited to 'dummyflasher.c')
-rw-r--r--dummyflasher.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/dummyflasher.c b/dummyflasher.c
index cd46f2c4..2657efb5 100644
--- a/dummyflasher.c
+++ b/dummyflasher.c
@@ -69,6 +69,8 @@ struct emu_data {
unsigned char spi_ignorelist[256];
unsigned int spi_blacklist_size;
unsigned int spi_ignorelist_size;
+
+ unsigned int spi_write_256_chunksize;
};
#if EMULATE_SPI_CHIP
@@ -101,9 +103,18 @@ static const uint8_t sfdp_table[] = {
#endif
#endif
-static unsigned int spi_write_256_chunksize = 256;
static enum chipbustype dummy_buses_supported = BUS_NONE;
+static struct emu_data* get_data_from_context(const struct flashctx *flash)
+{
+ if (dummy_buses_supported & BUS_NONSPI)
+ return (struct emu_data *)flash->mst->par.data;
+ else if (dummy_buses_supported & BUS_SPI)
+ return (struct emu_data *)flash->mst->spi.data;
+
+ return NULL; /* buses was set to BUS_NONE. */
+}
+
void *dummy_map(const char *descr, uintptr_t phys_addr, size_t len)
{
msg_pspew("%s: Mapping %s, 0x%zx bytes at 0x%0*" PRIxPTR "\n",
@@ -118,8 +129,9 @@ void dummy_unmap(void *virt_addr, size_t len)
static int dummy_spi_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len)
{
+ struct emu_data *emu_data = get_data_from_context(flash);
return spi_write_chunked(flash, buf, start, len,
- spi_write_256_chunksize);
+ emu_data->spi_write_256_chunksize);
}
static void dummy_chip_writeb(const struct flashctx *flash, uint8_t val, chipaddr addr)
@@ -173,16 +185,6 @@ static void dummy_chip_readn(const struct flashctx *flash, uint8_t *buf, const c
return;
}
-static struct emu_data* get_data_from_context(const struct flashctx *flash)
-{
- if (dummy_buses_supported & BUS_NONSPI)
- return (struct emu_data *)flash->mst->par.data;
- else if (dummy_buses_supported & BUS_SPI)
- return (struct emu_data *)flash->mst->spi.data;
-
- return NULL; /* buses was set to BUS_NONE. */
-}
-
#if EMULATE_SPI_CHIP
static int emulate_spi_chip_response(unsigned int writecnt,
unsigned int readcnt,
@@ -674,6 +676,7 @@ int dummy_init(void)
}
data->emu_chip = EMULATE_NONE;
data->delay_us = 0;
+ data->spi_write_256_chunksize = 256;
msg_pspew("%s\n", __func__);
@@ -707,9 +710,9 @@ int dummy_init(void)
tmp = extract_programmer_param("spi_write_256_chunksize");
if (tmp) {
- spi_write_256_chunksize = atoi(tmp);
+ data->spi_write_256_chunksize = atoi(tmp);
free(tmp);
- if (spi_write_256_chunksize < 1) {
+ if (data->spi_write_256_chunksize < 1) {
msg_perr("invalid spi_write_256_chunksize\n");
return 1;
}