Add infrastructure to probe per bus
Add some infrastructure around per-bus probing functions. Each function
is provided a private parameter, e.g. the expected length of an ID. This
will allow us to implement probing functions that are only called as of-
ten as necessary. The results will be stored in the `registered_master`
structure, to be compared to database entries later.
The probe_buses() wrapper can be used for chip entries, and allows us to
transition the existing probing functions one by one. Once all functions
have been ported, probe_flash() can be adapted as well and the wrapper
will become obsolete.
Change-Id: I6e82b6d61df50234096ac39acab58a4014203933
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/74899
diff --git a/include/flash.h b/include/flash.h
index 60e35d0..c4d9040 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -243,7 +243,8 @@
PREPARE_FULL,
};
-struct flashchip {
+#define flashchip flashprog_chip
+struct flashprog_chip {
const char *vendor;
const char *name;
@@ -505,6 +506,7 @@
void print_supported_wiki(void);
/* helpers.c */
+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 *);
uint32_t address_to_bits(uint32_t addr);
unsigned int bitcount(unsigned long a);