libflashprog: Start a new API for chip enumeration
For now, allow to query all chips, their vendor, name and size.
There's a tricky optimization coming up: We don't want to allocate
additional memory when enumerating the chip database. But, we also
want to use the same API interface to access information about de-
tected chips, which requires dynamic memory. So we have to handle
these distinct cases explicitly. Where `struct flashprog_chips *`
is used, we set it to the special value `FLASHCHIPS_DB` to denote
the flash database. For `struct flashprog_chip *` pointers, we add
chip_from_db(), which tells us whether the given pointer is within
the database range.
Change-Id: I7ecc12e1b74ca11f2be1b3472d6e470da44bfef1
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/481
diff --git a/meson.build b/meson.build
index 9e996e9..2b40d52 100644
--- a/meson.build
+++ b/meson.build
@@ -60,6 +60,7 @@
'jedec.c',
'layout.c',
'libflashprog.c',
+ 'libflashprog/chips.c',
'm28f.c',
'memory_bus.c',
'opaque.c',