Revert "util/cbfstool: Port elogtool to libflashrom"

This reverts commit d74b8d9c99.

This change breaks the 'make all' build of the cbfstool tools
from the util/cbfstool directory unless libflashrom-dev is
installed, complaining that flashrom is not installed.

Even with libflashrom-dev installed, it breaks building
elogtool with the public version of libflashrom-dev.

Signed-off-by: Martin Roth <martin@coreboot.org>
Change-Id: I572daa0c0f3998e20a8ed76df21228fdbb384baf
Reviewed-on: https://review.coreboot.org/c/coreboot/+/62404
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: ron minnich <rminnich@gmail.com>
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Martin Roth
2022-02-25 17:28:04 -07:00
committed by Nico Huber
parent b4156412db
commit e3e965b13d
4 changed files with 11 additions and 254 deletions

View File

@ -11,9 +11,9 @@
#include <common.h>
#include <commonlib/bsd/elog.h>
#include <flashrom.h>
#include "eventlog.h"
#include "uflashrom.h"
/* Only refers to the data max size. The "-1" is the checksum byte */
#define ELOG_MAX_EVENT_DATA_SIZE (ELOG_MAX_EVENT_SIZE - sizeof(struct event_header) - 1)
@ -78,18 +78,16 @@ static void usage(char *invoked_as)
*/
static int elog_read(struct buffer *buffer, const char *filename)
{
struct firmware_programmer image = {
.programmer = FLASHROM_PROGRAMMER_INTERNAL_AP,
.data = NULL,
.size = 0,
};
if (filename == NULL) {
if (flashrom_read(&image, ELOG_RW_REGION_NAME) != 0) {
uint8_t *buf;
uint32_t buf_size;
if (flashrom_read(FLASHROM_PROGRAMMER_INTERNAL_AP, ELOG_RW_REGION_NAME,
&buf, &buf_size) != VB2_SUCCESS) {
fprintf(stderr, "Could not read RW_ELOG region using flashrom\n");
return ELOGTOOL_EXIT_READ_ERROR;
}
buffer_init(buffer, NULL, image.data, image.size);
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;
@ -110,14 +108,9 @@ static int elog_read(struct buffer *buffer, const char *filename)
*/
static int elog_write(struct buffer *buf, const char *filename)
{
struct firmware_programmer image = {
.programmer = FLASHROM_PROGRAMMER_INTERNAL_AP,
.data = buffer_get(buf),
.size = buffer_size(buf),
};
if (filename == NULL) {
if (flashrom_write(&image, ELOG_RW_REGION_NAME) != 0) {
if (flashrom_write(FLASHROM_PROGRAMMER_INTERNAL_AP, ELOG_RW_REGION_NAME,
buffer_get(buf), buffer_size(buf)) != VB2_SUCCESS) {
fprintf(stderr,
"Failed to write to RW_ELOG region using flashrom\n");
return ELOGTOOL_EXIT_WRITE_ERROR;