summaryrefslogtreecommitdiff
path: root/futility/updater_utils.h
diff options
context:
space:
mode:
authorHung-Te Lin <hungte@chromium.org>2022-03-09 20:58:05 +0800
committerCommit Bot <commit-bot@chromium.org>2022-03-18 20:43:50 +0000
commit4cba64cfb67c0215eec140caedac3450ee837de9 (patch)
tree682edf8c4fb01657d2ea8ef26fa87e6083e5542e /futility/updater_utils.h
parent8f30263bde6636a58e1d33d7fdd007c3abb4f7ce (diff)
downloadvboot-4cba64cfb67c0215eec140caedac3450ee837de9.tar.gz
futility: updater: refactor {write,load}_system_firmware
The 'write_system_firmware' and 'load_system_firmware' have too many parameters that are already contained in the updater_config. To simplify the interfaces, we should just pass the updater_config to {write,load}_system_firmware, and merge the write_firmware_sections (only handling emulation and deciding the diff image) to the write_system_firmware. Also moved the utility functions only used by *_system_firmware (for example is_the_same_programmer and emulate_write_firmware) to the updater_utils.c. The emulate_write_firmware is also revised to handle a list of sections directly (so we don't need to handle that in write_system_firmware). BUG=None TEST=make; build and run test. BRANCH=None Change-Id: I4d123d12e8057da82d6c301899472e3773f3266e Signed-off-by: Hung-Te Lin <hungte@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/3508121 Reviewed-by: Yu-Ping Wu <yupingso@chromium.org> Commit-Queue: Yu-Ping Wu <yupingso@chromium.org>
Diffstat (limited to 'futility/updater_utils.h')
-rw-r--r--futility/updater_utils.h34
1 files changed, 26 insertions, 8 deletions
diff --git a/futility/updater_utils.h b/futility/updater_utils.h
index 3eb1d33c..0376eb36 100644
--- a/futility/updater_utils.h
+++ b/futility/updater_utils.h
@@ -8,6 +8,7 @@
#ifndef VBOOT_REFERENCE_FUTILITY_UPDATER_UTILS_H_
#define VBOOT_REFERENCE_FUTILITY_UPDATER_UTILS_H_
+#include <stdbool.h>
#include <stdio.h>
#include "fmap.h"
@@ -57,6 +58,23 @@ void remove_all_temp_files(struct tempfile *head);
/* Include definition of 'struct firmware_image;' */
#include "flashrom.h"
+/* Parameters when invoking flashrom. */
+struct flashrom_params {
+ struct firmware_image *image; /* The firmware image to read/write. */
+ const struct firmware_image *flash_contents; /* --flash-contents */
+ const char *const *regions; /* -i: only read/write <region> */
+ bool noverify; /* -n: don't auto-verify */
+ bool noverify_all; /* -N: verify included regions only */
+ int verbose; /* -V: more verbose output */
+ /* Supported by libflashrom but no exported by flashrom_drv:
+ * - force
+ * - noverify_all
+ * Not supported by libflashrom:
+ * - do_not_diff
+ * - ignore_lock
+ */
+};
+
enum {
IMAGE_LOAD_SUCCESS = 0,
IMAGE_READ_FAILURE = -1,
@@ -73,13 +91,15 @@ enum {
int load_firmware_image(struct firmware_image *image, const char *file_name,
struct archive *archive);
+/* Structure(s) declared in updater.h */
+struct updater_config;
+
/*
* Loads the active system firmware image (usually from SPI flash chip).
* Returns 0 if success, non-zero if error.
*/
-int load_system_firmware(struct firmware_image *image,
- struct tempfile *tempfiles,
- int retries, int verbosity);
+int load_system_firmware(struct updater_config *cfg,
+ struct firmware_image *image);
/* Frees the allocated resource from a firmware image object. */
void free_firmware_image(struct firmware_image *image);
@@ -98,11 +118,9 @@ const char *get_firmware_image_temp_file(const struct firmware_image *image,
* FMAP section names (and ended with a NULL).
* Returns 0 if success, non-zero if error.
*/
-int write_system_firmware(const struct firmware_image *image,
- const struct firmware_image *diff_image,
- const char * const sections[],
- struct tempfile *tempfiles,
- int do_verify, int retries, int verbosity);
+int write_system_firmware(struct updater_config *cfg,
+ const struct firmware_image *image,
+ const char * const sections[]);
struct firmware_section {
uint8_t *data;