summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Benn <evanbenn@chromium.org>2023-01-18 19:02:29 +1100
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-01-27 10:13:53 +0000
commit4bdc8e9c0a6db487acb5f5eb60635016710cb438 (patch)
treee69e05286894756a76d8dc9311ac11fb3fc483e0
parent0b426134a5c36866738a1a344670481d088ef6ee (diff)
downloadvboot-4bdc8e9c0a6db487acb5f5eb60635016710cb438.tar.gz
host: Add region parameter to flashrom_read_image
Allow flashrom_read_image to take a parameter to read only a region. BUG=b:265861606 BRANCH=None TEST=unit Change-Id: I835ca341c00b21286721f65c3e009a76753b6628 Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4170146 Tested-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
-rw-r--r--futility/updater_utils.c2
-rw-r--r--host/lib/flashrom_drv.c6
-rw-r--r--host/lib/include/flashrom.h9
3 files changed, 12 insertions, 5 deletions
diff --git a/futility/updater_utils.c b/futility/updater_utils.c
index cb7ac604..904b6b4e 100644
--- a/futility/updater_utils.c
+++ b/futility/updater_utils.c
@@ -682,7 +682,7 @@ static int read_flash(struct flashrom_params *params,
if (get_config_quirk(QUIRK_EXTERNAL_FLASHROM, cfg))
return external_flashrom(FLASH_READ, params, &cfg->tempfiles);
- return flashrom_read_image(params->image, params->verbose);
+ return flashrom_read_image(params->image, NULL, params->verbose);
}
static int write_flash(struct flashrom_params *params,
diff --git a/host/lib/flashrom_drv.c b/host/lib/flashrom_drv.c
index 880a0fc9..6f0057aa 100644
--- a/host/lib/flashrom_drv.c
+++ b/host/lib/flashrom_drv.c
@@ -119,9 +119,11 @@ err_init:
return r;
}
-int flashrom_read_image(struct firmware_image *image, int verbosity)
+int flashrom_read_image(struct firmware_image *image, const char *region,
+ int verbosity)
{
- return flashrom_read_image_impl(image, NULL, NULL, NULL, verbosity);
+ unsigned int start, len;
+ return flashrom_read_image_impl(image, region, &start, &len, verbosity);
}
int flashrom_read_region(struct firmware_image *image, const char *region,
diff --git a/host/lib/include/flashrom.h b/host/lib/include/flashrom.h
index 81d6ba98..e7eda28a 100644
--- a/host/lib/include/flashrom.h
+++ b/host/lib/include/flashrom.h
@@ -30,7 +30,11 @@ struct firmware_image {
};
/**
- * Read using flashrom into an allocated buffer.
+ * Read using flashrom into an allocated buffer. flashrom_read subprocesses the
+ * flashrom binary and returns a buffer truncated to the region.
+ * flashrom_read_image will read the return a full sized buffer with only the
+ * region filled with data. flashrom_read_region will return the buffer
+ * truncated to the region.
*
* @param image The parameter that contains the programmer, buffer and
* size to use in the read operation.
@@ -40,7 +44,8 @@ struct firmware_image {
* @return VB2_SUCCESS on success, or a relevant error.
*/
vb2_error_t flashrom_read(struct firmware_image *image, const char *region);
-int flashrom_read_image(struct firmware_image *image, int verbosity);
+int flashrom_read_image(struct firmware_image *image, const char *region,
+ int verbosity);
int flashrom_read_region(struct firmware_image *image, const char *region,
int verbosity);