helpers: Export size-detection logic from amd_rom3read
Export our logic to detect the size of a memory-mapped chip by looking
for repetitive reads. This can be useful for other cases as well, for
instance when we don't know for sure how many address lines are connec-
ted to a parallel flash chip.
Change-Id: Iccbe3aa882959baf496a04340dbfc7f552e4ef71
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/555
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/include/flash.h b/include/flash.h
index 5ada550..75c0250 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -522,6 +522,8 @@
bool flashprog_no_data(const void *raw_data, size_t);
int flashprog_read_chunked(struct flashctx *, uint8_t *dst, unsigned int start, unsigned int len, unsigned int chunksize, readfunc_t *);
int flashprog_limit_chip(struct flashctx *);
+int compare_sparse(const void *s1, const void *s2, size_t n);
+size_t estimate_addressable_size(const void *base, size_t len);
uint32_t address_to_bits(uint32_t addr);
unsigned int bitcount(unsigned long a);
#undef MIN