Edward O'Callaghan has uploaded this change for review.
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>
---
M dummyflasher.c
1 file changed, 18 insertions(+), 14 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/21/54721/1
diff --git a/dummyflasher.c b/dummyflasher.c
index 127c632..5581d0b 100644
--- a/dummyflasher.c
+++ b/dummyflasher.c
@@ -69,6 +69,8 @@
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 @@
#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 @@
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 @@
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,8 @@
}
data->emu_chip = EMULATE_NONE;
data->delay_us = 0;
+ data->spi_write_256_chunksize = 256;
+
par_master_dummyflasher.data = data;
msg_pspew("%s\n", __func__);
@@ -708,9 +712,9 @@
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;
}
To view, visit change 54721. To unsubscribe, or for help writing mail filters, visit settings.