aboutsummaryrefslogtreecommitdiffstats
path: root/flash.h
diff options
context:
space:
mode:
authorNico Huber <nico.huber@secunet.com>2012-12-10 13:34:10 +0000
committerDavid Hendricks <david.hendricks@gmail.com>2017-06-03 20:13:06 +0200
commit454f61338213f73ca74fda54c0bf86afb01947de (patch)
tree5c981a1a181c130467d3c37b99cdeaf686ff49c8 /flash.h
parent7af0e79b44bdc86497a992a90855f284e74d73f1 (diff)
downloadflashrom-454f61338213f73ca74fda54c0bf86afb01947de.tar.gz
flashrom-454f61338213f73ca74fda54c0bf86afb01947de.tar.bz2
flashrom-454f61338213f73ca74fda54c0bf86afb01947de.zip
Add a convenient libflashrom interface
This adds a minimal libflashrom interface based on the draft in the wiki. While the glue code in libflashrom.c is build on top of the existing code instead on overhauling it, the interface in libflashrom.h is supposed to be stable. So we can keep the interface and adapt internals later if favoured, without breaking clients. A new make target, libinstall, is also added. It installs libflashrom.a and libflashrom.h in lib/ and include/ dirs respectively. Hooking this into the build would break linking of the CLI and is post- poned until that got fixed. v2: Rebase and fixes by Anton Kochkov. v3: o fl_image_*() rewritten with layout support (touch only included regions). o Moved read/erase/write/verify operations to flashrom.c. o Added layout pointer and flags to the flash context. v4: Removed libflashrom.o from LIB_OBJS until CLI is adapted. v5: o Incorporated David's comments. o Added `fl_flashprog_t` as dummy parameter to hide the fact that we have global state all around, and for future-proofness ofc. v6: o Change namespace prefix to flashrom_. o Remove typedefs. Change-Id: I00f169990830aa17b7dfae5eb74010d40c476181 Signed-off-by: Nico Huber <nico.huber@secunet.com> Reviewed-on: https://review.coreboot.org/17946 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: David Hendricks <david.hendricks@gmail.com>
Diffstat (limited to 'flash.h')
-rw-r--r--flash.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/flash.h b/flash.h
index b383edaf..1da7e412 100644
--- a/flash.h
+++ b/flash.h
@@ -138,7 +138,8 @@ enum test_state {
#define TEST_BAD_PRE (struct tested){ .probe = BAD, .read = BAD, .erase = BAD, .write = NT }
#define TEST_BAD_PREW (struct tested){ .probe = BAD, .read = BAD, .erase = BAD, .write = BAD }
-struct flashctx;
+struct flashrom_flashctx;
+#define flashctx flashrom_flashctx /* TODO: Agree on a name and convert all occurences. */
typedef int (erasefunc_t)(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
struct flashchip {
@@ -204,7 +205,7 @@ struct flashchip {
enum write_granularity gran;
};
-struct flashctx {
+struct flashrom_flashctx {
struct flashchip *chip;
/* FIXME: The memory mappings should be saved in a more structured way. */
/* The physical_* fields store the respective addresses in the physical address space of the CPU. */
@@ -218,6 +219,12 @@ struct flashctx {
struct registered_master *mst;
const struct flashrom_layout *layout;
struct single_layout fallback_layout;
+ struct {
+ bool force;
+ bool force_boardmismatch;
+ bool verify_after_write;
+ bool verify_whole_chip;
+ } flags;
};
/* Timing used in probe routines. ZERO is -2 to differentiate between an unset