memory_mapped: Reduce `decode_sizes` to a single `max_rom_decode`
We used to store the maximum decode size, i.e. the maximum memory-mapped
range of the flash chip, per bus type (Parallel, LPC, FWH, SPI). There
was no programmer in the tree that really made use of it, though:
* The chipset drivers usually focus on a single bus type. And even if
they advertise the whole default set (PAR, LPC, FWH), they only pro-
vide a maximum decode size for one of them. The latter is probably
wrong, should really more than one bus type be supported.
* PCI and external programmers all support only a single bus type, with
the exception of `serprog` which doesn't set a maximum decode size.
What made the distinction even less useful is that for some chips that
support multiple bus types, i.e. LPC+FWH, we can't even detect which
type it is. The existing code around this also only tried to provide
the best possible warning message at the expense of breaking the pro-
grammer abstraction.
Hence, unify the set of sizes into a single `max_rom_decode` property.
We store it inside the `registered_master` struct right away, to avoid
any more use of globals.
Change-Id: I2aaea18d5b4255eb843a625b016ee74bb145ed85
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/72531
diff --git a/board_enable.c b/board_enable.c
index 365e0c0..56498c0 100644
--- a/board_enable.c
+++ b/board_enable.c
@@ -601,8 +601,9 @@
* Suited for all boards with ITE IT8705F.
* The SIS950 Super I/O probably requires a similar flash write enable.
*/
-int it8705f_write_enable(uint8_t port)
+int it8705f_write_enable(struct flashprog_programmer *const prog, const uint8_t port)
{
+ struct internal_data *const internal = prog->data;
uint8_t tmp;
int ret = 0;
@@ -620,16 +621,16 @@
msg_pdbg("Enabling IT8705F flash ROM interface write.\n");
if (tmp & 0x02) {
/* The data sheet contradicts itself about max size. */
- max_rom_decode.parallel = 1024 * 1024;
+ internal->max_rom_decode = 1024 * 1024;
msg_pinfo("IT8705F with very unusual settings.\n"
"Please send the output of \"flashprog -V -p internal\" to\n"
"flashprog@flashprog.org with \"IT8705: your board name: flashprog -V\"\n"
"as the subject to help us finish support for your Super I/O. Thanks.\n");
ret = 1;
} else if (tmp & 0x08) {
- max_rom_decode.parallel = 512 * 1024;
+ internal->max_rom_decode = 512 * 1024;
} else {
- max_rom_decode.parallel = 256 * 1024;
+ internal->max_rom_decode = 256 * 1024;
}
/* Safety checks. The data sheet is unclear here: Segments 1+3
* overlap, no segment seems to cover top - 1MB to top - 512kB.
@@ -672,8 +673,8 @@
*/
ret = 1;
}
- msg_pdbg("Maximum IT8705F parallel flash decode size is %u.\n",
- max_rom_decode.parallel);
+ msg_pdbg("Maximum IT8705F parallel flash decode size is %zu.\n",
+ internal->max_rom_decode);
if (ret) {
msg_pinfo("Not enabling IT8705F flash write.\n");
} else {
@@ -2753,6 +2754,7 @@
int board_flash_enable(struct flashprog_programmer *const prog,
const char *vendor, const char *model, const char *cb_vendor, const char *cb_model)
{
+ struct internal_data *const internal = prog->data;
const struct board_match *board = NULL;
int ret = 0;
@@ -2782,7 +2784,7 @@
/* limit the maximum size of the parallel bus */
if (board->max_rom_decode_parallel)
- max_rom_decode.parallel = board->max_rom_decode_parallel * 1024;
+ internal->max_rom_decode = board->max_rom_decode_parallel * 1024;
if (board->enable != NULL) {
msg_pinfo("Enabling full flash access for board \"%s %s\"... ",