summaryrefslogtreecommitdiffstats
path: root/include/libflashrom.h
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2021-01-15 09:48:12 +0000
committerEdward O'Callaghan <quasisec@chromium.org>2022-05-25 08:08:13 +0000
commit40892b0c08fbc8029921e91511dd3f91fc956f90 (patch)
tree56b6fccd5c99c00649369fcf097c4555313b753c /include/libflashrom.h
parentb86ae179adfb4acb4190ef2abe2ee8905c44f26a (diff)
downloadflashrom-40892b0c08fbc8029921e91511dd3f91fc956f90.tar.gz
flashrom-40892b0c08fbc8029921e91511dd3f91fc956f90.tar.bz2
flashrom-40892b0c08fbc8029921e91511dd3f91fc956f90.zip
libflashrom: Return progress state to the library user
Projects using libflashrom like fwupd expect the user to wait for the operation to complete. To avoid the user thinking the process has "hung" or "got stuck" report back the progress complete of the erase, write and read operations. Add a new --progress flag to the CLI to report progress of operations. Include a test for the dummy spi25 device. TEST=./test_build.sh; ./flashrom -p lspcon_i2c_spi:bus=7 -r /dev/null --progress Change-Id: I7197572bb7f19e3bdb2bde855d70a0f50fd3854c Signed-off-by: Richard Hughes <richard@hughsie.com> Signed-off-by: Daniel Campello <campello@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/49643 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-by: Thomas Heijligen <src@posteo.de>
Diffstat (limited to 'include/libflashrom.h')
-rw-r--r--include/libflashrom.h29
1 files changed, 28 insertions, 1 deletions
diff --git a/include/libflashrom.h b/include/libflashrom.h
index cf1f46234..21a5785f3 100644
--- a/include/libflashrom.h
+++ b/include/libflashrom.h
@@ -69,6 +69,34 @@ typedef int(flashrom_log_callback)(enum flashrom_log_level, const char *format,
*/
void flashrom_set_log_callback(flashrom_log_callback *log_callback);
+enum flashrom_progress_stage {
+ FLASHROM_PROGRESS_READ,
+ FLASHROM_PROGRESS_WRITE,
+ FLASHROM_PROGRESS_ERASE,
+ FLASHROM_PROGRESS_NR,
+};
+struct flashrom_progress {
+ enum flashrom_progress_stage stage;
+ size_t current;
+ size_t total;
+ void *user_data;
+};
+struct flashrom_flashctx;
+typedef void(flashrom_progress_callback)(struct flashrom_flashctx *flashctx);
+/**
+ * @brief Set the progress callback function.
+ *
+ * Set a callback function which will be invoked whenever libflashrom wants
+ * to indicate the progress has changed. This allows frontends to do whatever
+ * they see fit with such values, e.g. update a progress bar in a GUI tool.
+ *
+ * @param progress_callback Pointer to the new progress callback function.
+ * @param progress_state Pointer to progress state to include with the progress
+ * callback.
+ */
+void flashrom_set_progress_callback(struct flashrom_flashctx *const flashctx,
+ flashrom_progress_callback *progress_callback, struct flashrom_progress *progress_state);
+
/** @} */ /* end flashrom-general */
/**
@@ -174,7 +202,6 @@ int flashrom_programmer_shutdown(struct flashrom_programmer *flashprog);
* @{
*/
-struct flashrom_flashctx;
/**
* @brief Probe for a flash chip.
*