Draw struct flashchip into struct flashprog_flashctx
We used to have a reference to a dynamically allocated struct flashchip
inside the flash context. But now that we only ever allocate both in one
go, we can let go of the reference and make it a single structure.
Change-Id: I857acb1def6d133a5cbc28fc7a99b7b1a22b55e0
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/494
diff --git a/jedec.c b/jedec.c
index 1cb540a..e7bfc87 100644
--- a/jedec.c
+++ b/jedec.c
@@ -112,13 +112,13 @@
static unsigned int getaddrmask(const struct flashprog_flashctx *flash)
{
- return getaddrmask_from_features(flash->chip->feature_bits);
+ return getaddrmask_from_features(flash->chip.feature_bits);
}
static void start_program_jedec_common(const struct flashctx *flash, unsigned int mask)
{
chipaddr bios = flash->virtual_memory;
- bool shifted = (flash->chip->feature_bits & FEATURE_ADDR_SHIFTED);
+ bool shifted = (flash->chip.feature_bits & FEATURE_ADDR_SHIFTED);
chip_writeb(flash, 0xAA, bios + ((shifted ? 0x2AAA : 0x5555) & mask));
chip_writeb(flash, 0x55, bios + ((shifted ? 0x5555 : 0x2AAA) & mask));
@@ -411,10 +411,10 @@
unsigned int pagesize, unsigned int mask)
{
chipaddr bios = flash->virtual_memory;
- bool shifted = (flash->chip->feature_bits & FEATURE_ADDR_SHIFTED);
+ bool shifted = (flash->chip.feature_bits & FEATURE_ADDR_SHIFTED);
unsigned int delay_us = 0;
- if(flash->chip->probe_timing != TIMING_ZERO)
+ if(flash->chip.probe_timing != TIMING_ZERO)
delay_us = 10;
/* Issue the Sector Erase command */
@@ -443,10 +443,10 @@
unsigned int blocksize, unsigned int mask)
{
chipaddr bios = flash->virtual_memory;
- bool shifted = (flash->chip->feature_bits & FEATURE_ADDR_SHIFTED);
+ bool shifted = (flash->chip.feature_bits & FEATURE_ADDR_SHIFTED);
unsigned int delay_us = 0;
- if(flash->chip->probe_timing != TIMING_ZERO)
+ if(flash->chip.probe_timing != TIMING_ZERO)
delay_us = 10;
/* Issue the Sector Erase command */
@@ -474,10 +474,10 @@
static int erase_chip_jedec_common(struct flashctx *flash, unsigned int mask)
{
chipaddr bios = flash->virtual_memory;
- bool shifted = (flash->chip->feature_bits & FEATURE_ADDR_SHIFTED);
+ bool shifted = (flash->chip.feature_bits & FEATURE_ADDR_SHIFTED);
unsigned int delay_us = 0;
- if(flash->chip->probe_timing != TIMING_ZERO)
+ if(flash->chip.probe_timing != TIMING_ZERO)
delay_us = 10;
/* Issue the JEDEC Chip Erase command */
@@ -613,7 +613,7 @@
* write_jedec have page_size set to max_writechunk_size, so
* we're OK for now.
*/
- unsigned int page_size = flash->chip->page_size;
+ unsigned int page_size = flash->chip.page_size;
unsigned int nwrites = (start + len - 1) / page_size;
/* Warning: This loop has a very unusual condition and body.
@@ -746,7 +746,7 @@
{
// FIXME: this depends on the eraseblocks not to be filled up completely (i.e. to be null-terminated).
const struct unlockblock *unlockblocks =
- (const struct unlockblock *)flash->chip->block_erasers[0].eraseblocks;
+ (const struct unlockblock *)flash->chip.block_erasers[0].eraseblocks;
return regspace2_walk_unlockblocks(flash, unlockblocks, &printlock_regspace2_block);
}
@@ -754,7 +754,7 @@
{
// FIXME: this depends on the eraseblocks not to be filled up completely (i.e. to be null-terminated).
const struct unlockblock *unlockblocks =
- (const struct unlockblock *)flash->chip->block_erasers[1].eraseblocks;
+ (const struct unlockblock *)flash->chip.block_erasers[1].eraseblocks;
return regspace2_walk_unlockblocks(flash, unlockblocks, &printlock_regspace2_block);
}
@@ -849,7 +849,7 @@
{
// FIXME: this depends on the eraseblocks not to be filled up completely (i.e. to be null-terminated).
const struct unlockblock *unlockblocks =
- (const struct unlockblock *)flash->chip->block_erasers[0].eraseblocks;
+ (const struct unlockblock *)flash->chip.block_erasers[0].eraseblocks;
return regspace2_walk_unlockblocks(flash, unlockblocks, &unlock_regspace2_block_generic);
}
@@ -857,6 +857,6 @@
{
// FIXME: this depends on the eraseblocks not to be filled up completely (i.e. to be null-terminated).
const struct unlockblock *unlockblocks =
- (const struct unlockblock *)flash->chip->block_erasers[1].eraseblocks;
+ (const struct unlockblock *)flash->chip.block_erasers[1].eraseblocks;
return regspace2_walk_unlockblocks(flash, unlockblocks, &unlock_regspace2_block_generic);
}