1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-07-01 22:21:16 +02:00

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>
This commit is contained in:
Nico Huber
2012-12-10 13:34:10 +00:00
committed by David Hendricks
parent 7af0e79b44
commit 454f613382
5 changed files with 723 additions and 7 deletions

11
flash.h
View File

@ -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