summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/flash.h5
-rw-r--r--include/libflashrom.h29
2 files changed, 33 insertions, 1 deletions
diff --git a/include/flash.h b/include/flash.h
index 27ade09b6..45533ba9b 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -350,6 +350,9 @@ struct flashrom_flashctx {
chip_restore_fn_cb_t func;
uint8_t status;
} chip_restore_fn[MAX_CHIP_RESTORE_FUNCTIONS];
+ /* Progress reporting */
+ flashrom_progress_callback *progress_callback;
+ struct flashrom_progress *progress_state;
};
/* Timing used in probe routines. ZERO is -2 to differentiate between an unset
@@ -446,6 +449,7 @@ int open_logfile(const char * const filename);
int close_logfile(void);
void start_logging(void);
int flashrom_print_cb(enum flashrom_log_level level, const char *fmt, va_list ap);
+void flashrom_progress_cb(struct flashrom_flashctx *flashctx);
/* Let gcc and clang check for correct printf-style format strings. */
int print(enum flashrom_log_level level, const char *fmt, ...)
#ifdef __MINGW32__
@@ -474,6 +478,7 @@ __attribute__((format(printf, 2, 3)));
#define msg_gspew(...) print(FLASHROM_MSG_SPEW, __VA_ARGS__) /* general debug spew */
#define msg_pspew(...) print(FLASHROM_MSG_SPEW, __VA_ARGS__) /* programmer debug spew */
#define msg_cspew(...) print(FLASHROM_MSG_SPEW, __VA_ARGS__) /* chip debug spew */
+void update_progress(struct flashctx *flash, enum flashrom_progress_stage stage, size_t current, size_t total);
/* spi.c */
struct spi_command {
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.
*