1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-29 07:53:44 +02:00

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>
This commit is contained in:
Edward O'Callaghan 2021-05-20 20:27:59 +10:00 committed by Edward O'Callaghan
parent 93763e4b2c
commit 653eb6977a

View File

@ -69,6 +69,8 @@ struct emu_data {
unsigned char spi_ignorelist[256]; unsigned char spi_ignorelist[256];
unsigned int spi_blacklist_size; unsigned int spi_blacklist_size;
unsigned int spi_ignorelist_size; unsigned int spi_ignorelist_size;
unsigned int spi_write_256_chunksize;
}; };
#if EMULATE_SPI_CHIP #if EMULATE_SPI_CHIP
@ -101,9 +103,18 @@ static const uint8_t sfdp_table[] = {
#endif #endif
#endif #endif
static unsigned int spi_write_256_chunksize = 256;
static enum chipbustype dummy_buses_supported = BUS_NONE; 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) 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", 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) 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, 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) 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; 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 #if EMULATE_SPI_CHIP
static int emulate_spi_chip_response(unsigned int writecnt, static int emulate_spi_chip_response(unsigned int writecnt,
unsigned int readcnt, unsigned int readcnt,
@ -674,6 +676,7 @@ int dummy_init(void)
} }
data->emu_chip = EMULATE_NONE; data->emu_chip = EMULATE_NONE;
data->delay_us = 0; data->delay_us = 0;
data->spi_write_256_chunksize = 256;
msg_pspew("%s\n", __func__); msg_pspew("%s\n", __func__);
@ -707,9 +710,9 @@ int dummy_init(void)
tmp = extract_programmer_param("spi_write_256_chunksize"); tmp = extract_programmer_param("spi_write_256_chunksize");
if (tmp) { if (tmp) {
spi_write_256_chunksize = atoi(tmp); data->spi_write_256_chunksize = atoi(tmp);
free(tmp); free(tmp);
if (spi_write_256_chunksize < 1) { if (data->spi_write_256_chunksize < 1) {
msg_perr("invalid spi_write_256_chunksize\n"); msg_perr("invalid spi_write_256_chunksize\n");
return 1; return 1;
} }