summaryrefslogtreecommitdiff
path: root/util/cbfstool/elogtool.c
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2022-06-06 20:01:04 +1000
committerJulius Werner <jwerner@chromium.org>2022-06-16 20:38:41 +0000
commit774dcffc369989b70595e27dc96ee191bd48e34f (patch)
treecadb68514cd6abc693b091a99e06fb11c8269127 /util/cbfstool/elogtool.c
parentc1d7d89d48c536773b4f7f5e84da907fe635a256 (diff)
util/cbfstool: Decouple elogtool from vboot_ref flashrom code
Currently elogtool sub-proccesses flashrom as calling libflashrom requires a missing function from the previous flashrom release. Pending a new release of flashrom we must continue to use subprocess. However the current subprocess wrapper implementation lives in vboot_reference which is a git sub-module of coreboot. This causes all sorts of grief keeping a subprocess ABI stable from vboot_reference when the rest of vboot_reference builds of HEAD of the flashrom tree (i.e., using unreleased libflashrom functions). In order to not keep finding ourseleves in a bind between the two separately moving trees with different build environments, decouple elogtool with its own mini copy of flashrom subprocess wrapping logic. Squash in, util/cbfstool/elogtool.c: Convert args into struct in flashrom helper vboot signatures for flashrom r/w helpers changed in the upstream commit bd2971326ee94fc5. Reflect the change here to allow vboot ref and coreboot to realign. BUG=b:207808292,b:231152447 TEST=builds with vboot_ref uprev. Change-Id: I04925e4d9a44b52e4a6fb6f9cec332cab2c7c725 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/65055 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'util/cbfstool/elogtool.c')
-rw-r--r--util/cbfstool/elogtool.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/util/cbfstool/elogtool.c b/util/cbfstool/elogtool.c
index 253e2ee95a..1e9b6605f9 100644
--- a/util/cbfstool/elogtool.c
+++ b/util/cbfstool/elogtool.c
@@ -79,15 +79,10 @@ static void usage(char *invoked_as)
static int elog_read(struct buffer *buffer, const char *filename)
{
if (filename == NULL) {
- uint8_t *buf;
- uint32_t buf_size;
-
- if (flashrom_read(FLASHROM_PROGRAMMER_INTERNAL_AP, ELOG_RW_REGION_NAME,
- &buf, &buf_size) != VB2_SUCCESS) {
+ if (flashrom_host_read(buffer, ELOG_RW_REGION_NAME) != 0) {
fprintf(stderr, "Could not read RW_ELOG region using flashrom\n");
return ELOGTOOL_EXIT_READ_ERROR;
}
- buffer_init(buffer, NULL, buf, buf_size);
} else if (buffer_from_file(buffer, filename) != 0) {
fprintf(stderr, "Could not read input file: %s\n", filename);
return ELOGTOOL_EXIT_READ_ERROR;
@@ -106,11 +101,10 @@ static int elog_read(struct buffer *buffer, const char *filename)
* If filename is NULL, it saves the buffer using flashrom.
* Otherwise, it saves the buffer in the given filename.
*/
-static int elog_write(struct buffer *buf, const char *filename)
+static int elog_write(struct buffer *buffer, const char *filename)
{
if (filename == NULL) {
- if (flashrom_write(FLASHROM_PROGRAMMER_INTERNAL_AP, ELOG_RW_REGION_NAME,
- buffer_get(buf), buffer_size(buf)) != VB2_SUCCESS) {
+ if (flashrom_host_write(buffer, ELOG_RW_REGION_NAME) != 0) {
fprintf(stderr,
"Failed to write to RW_ELOG region using flashrom\n");
return ELOGTOOL_EXIT_WRITE_ERROR;
@@ -118,7 +112,7 @@ static int elog_write(struct buffer *buf, const char *filename)
return ELOGTOOL_EXIT_SUCCESS;
}
- if (buffer_write_file(buf, filename) != 0) {
+ if (buffer_write_file(buffer, filename) != 0) {
fprintf(stderr, "Failed to write to file %s\n", filename);
return ELOGTOOL_EXIT_WRITE_ERROR;
}