Thomas Heijligen has uploaded this change for review.
dummyflasher: move struct declaration & probe_variable_size to spi.(h|c)
This is needed to build flashrom without the internal programmer
Change-Id: Ic93c8b9ba7b9f7ce5fe49326c8de34070ca83a2e
Signed-off-by: Thomas Heijligen <thomas.heijligen@secunet.com>
---
M chipdrivers.h
M dummyflasher.c
M spi.c
M spi.h
4 files changed, 79 insertions(+), 80 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/31/63831/1
diff --git a/chipdrivers.h b/chipdrivers.h
index 0695993..d6755be 100644
--- a/chipdrivers.h
+++ b/chipdrivers.h
@@ -201,7 +201,7 @@
int probe_en29lv640b(struct flashctx *flash);
int write_en29lv640b(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
-/* dummyflasher.c */
+/* spi.c */
int probe_variable_size(struct flashctx *flash);
/* edi.c */
diff --git a/dummyflasher.c b/dummyflasher.c
index 2311576..600cf58 100644
--- a/dummyflasher.c
+++ b/dummyflasher.c
@@ -26,42 +26,6 @@
#include "flashchips.h"
#include "spi.h"
-enum emu_chip {
- EMULATE_NONE,
- EMULATE_ST_M25P10_RES,
- EMULATE_SST_SST25VF040_REMS,
- EMULATE_SST_SST25VF032B,
- EMULATE_MACRONIX_MX25L6436,
- EMULATE_WINBOND_W25Q128FV,
- EMULATE_VARIABLE_SIZE,
-};
-
-struct emu_data {
- enum emu_chip emu_chip;
- char *emu_persistent_image;
- unsigned int emu_chip_size;
- int erase_to_zero;
- int emu_modified; /* is the image modified since reading it? */
- uint8_t emu_status;
- /* If "freq" parameter is passed in from command line, commands will delay
- * for this period before returning. */
- unsigned long int delay_us;
- unsigned int emu_max_byteprogram_size;
- unsigned int emu_max_aai_size;
- unsigned int emu_jedec_se_size;
- unsigned int emu_jedec_be_52_size;
- unsigned int emu_jedec_be_d8_size;
- unsigned int emu_jedec_ce_60_size;
- unsigned int emu_jedec_ce_c7_size;
- unsigned char spi_blacklist[256];
- unsigned char spi_ignorelist[256];
- unsigned int spi_blacklist_size;
- unsigned int spi_ignorelist_size;
-
- unsigned int spi_write_256_chunksize;
- uint8_t *flashchip_contents;
-};
-
/* A legit complete SFDP table based on the MX25L6436E (rev. 1.8) datasheet. */
static const uint8_t sfdp_table[] = {
0x53, 0x46, 0x44, 0x50, // @0x00: SFDP signature
@@ -1015,49 +979,6 @@
return 0;
}
-int probe_variable_size(struct flashctx *flash)
-{
- unsigned int i;
- const struct emu_data *emu_data = flash->mst->spi.data;
-
- /* Skip the probing if we don't emulate this chip. */
- if (!emu_data || emu_data->emu_chip != EMULATE_VARIABLE_SIZE)
- return 0;
-
- /*
- * This will break if one day flashctx becomes read-only.
- * Once that happens, we need to have special hacks in functions:
- *
- * erase_and_write_flash() in flashrom.c
- * read_flash_to_file()
- * handle_romentries()
- * ...
- *
- * Search "total_size * 1024" in code.
- */
- flash->chip->total_size = emu_data->emu_chip_size / 1024;
- msg_cdbg("%s: set flash->total_size to %dK bytes.\n", __func__,
- flash->chip->total_size);
-
- if (emu_data->erase_to_zero)
- flash->chip->feature_bits |= FEATURE_ERASED_ZERO;
-
- /* Update the first count of each of the block_erasers. */
- for (i = 0; i < NUM_ERASEFUNCTIONS; i++) {
- struct block_eraser *eraser = &flash->chip->block_erasers[i];
- if (!eraser->block_erase)
- break;
-
- eraser->eraseblocks[0].count = 1;
- eraser->eraseblocks[0].size = emu_data->emu_chip_size;
- msg_cdbg("%s: eraser.size=%d, .count=%d\n",
- __func__, eraser->eraseblocks[0].size,
- eraser->eraseblocks[0].count);
- }
-
- return 1;
-}
-
const struct programmer_entry programmer_dummy = {
.name = "dummy",
.type = OTHER,
diff --git a/spi.c b/spi.c
index f2e91c4..1a557ab 100644
--- a/spi.c
+++ b/spi.c
@@ -130,6 +130,48 @@
{
return flash->mst->spi.write_aai(flash, buf, start, len);
}
+int probe_variable_size(struct flashctx *flash)
+{
+ unsigned int i;
+ const struct emu_data *emu_data = flash->mst->spi.data;
+
+ /* Skip the probing if we don't emulate this chip. */
+ if (!emu_data || emu_data->emu_chip != EMULATE_VARIABLE_SIZE)
+ return 0;
+
+ /*
+ * This will break if one day flashctx becomes read-only.
+ * Once that happens, we need to have special hacks in functions:
+ *
+ * erase_and_write_flash() in flashrom.c
+ * read_flash_to_file()
+ * handle_romentries()
+ * ...
+ *
+ * Search "total_size * 1024" in code.
+ */
+ flash->chip->total_size = emu_data->emu_chip_size / 1024;
+ msg_cdbg("%s: set flash->total_size to %dK bytes.\n", __func__,
+ flash->chip->total_size);
+
+ if (emu_data->erase_to_zero)
+ flash->chip->feature_bits |= FEATURE_ERASED_ZERO;
+
+ /* Update the first count of each of the block_erasers. */
+ for (i = 0; i < NUM_ERASEFUNCTIONS; i++) {
+ struct block_eraser *eraser = &flash->chip->block_erasers[i];
+ if (!eraser->block_erase)
+ break;
+
+ eraser->eraseblocks[0].count = 1;
+ eraser->eraseblocks[0].size = emu_data->emu_chip_size;
+ msg_cdbg("%s: eraser.size=%d, .count=%d\n",
+ __func__, eraser->eraseblocks[0].size,
+ eraser->eraseblocks[0].count);
+ }
+
+ return 1;
+}
int register_spi_master(const struct spi_master *mst, void *data)
{
diff --git a/spi.h b/spi.h
index 845b6c2..1b43a7d 100644
--- a/spi.h
+++ b/spi.h
@@ -209,6 +209,42 @@
#define SPI_FLASHROM_BUG -5
#define SPI_PROGRAMMER_ERROR -6
+enum emu_chip {
+ EMULATE_NONE,
+ EMULATE_ST_M25P10_RES,
+ EMULATE_SST_SST25VF040_REMS,
+ EMULATE_SST_SST25VF032B,
+ EMULATE_MACRONIX_MX25L6436,
+ EMULATE_WINBOND_W25Q128FV,
+ EMULATE_VARIABLE_SIZE,
+};
+
+struct emu_data {
+ enum emu_chip emu_chip;
+ char *emu_persistent_image;
+ unsigned int emu_chip_size;
+ int erase_to_zero;
+ int emu_modified; /* is the image modified since reading it? */
+ uint8_t emu_status;
+ /* If "freq" parameter is passed in from command line, commands will delay
+ * for this period before returning. */
+ unsigned long int delay_us;
+ unsigned int emu_max_byteprogram_size;
+ unsigned int emu_max_aai_size;
+ unsigned int emu_jedec_se_size;
+ unsigned int emu_jedec_be_52_size;
+ unsigned int emu_jedec_be_d8_size;
+ unsigned int emu_jedec_ce_60_size;
+ unsigned int emu_jedec_ce_c7_size;
+ unsigned char spi_blacklist[256];
+ unsigned char spi_ignorelist[256];
+ unsigned int spi_blacklist_size;
+ unsigned int spi_ignorelist_size;
+
+ unsigned int spi_write_256_chunksize;
+ uint8_t *flashchip_contents;
+};
+
void clear_spi_id_cache(void);
#endif /* !__SPI_H__ */
To view, visit change 63831. To unsubscribe, or for help writing mail filters, visit settings.