summaryrefslogtreecommitdiff
path: root/include/fastboot.h
diff options
context:
space:
mode:
authorAlex Kiernan <alex.kiernan@gmail.com>2018-05-29 15:30:53 +0000
committerMarek Vasut <marex@denx.de>2018-05-30 11:59:21 +0200
commitf73a7df984a9820d9beb829b32ccb5c3d55dc152 (patch)
tree8a9513b9aadb40cde8e02ca93124a40532166256 /include/fastboot.h
parentc232d14d11e29c88f2c6149d2c152f496caa5889 (diff)
net: fastboot: Merge AOSP UDP fastboot
Merge UDP fastboot support from AOSP: https://android.googlesource.com/platform/external/u-boot/+/android-o-mr1-iot-preview-8 Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com> Signed-off-by: Alex Deymo <deymo@google.com> Signed-off-by: Jocelyn Bohr <bohr@google.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/fastboot.h')
-rw-r--r--include/fastboot.h104
1 files changed, 104 insertions, 0 deletions
diff --git a/include/fastboot.h b/include/fastboot.h
index bf3d9e2f67..9a3d5ba693 100644
--- a/include/fastboot.h
+++ b/include/fastboot.h
@@ -15,9 +15,29 @@
#define FASTBOOT_VERSION "0.4"
/* The 64 defined bytes plus \0 */
+#define FASTBOOT_COMMAND_LEN (64 + 1)
#define FASTBOOT_RESPONSE_LEN (64 + 1)
/**
+ * All known commands to fastboot
+ */
+enum {
+ FASTBOOT_COMMAND_GETVAR = 0,
+ FASTBOOT_COMMAND_DOWNLOAD,
+#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
+ FASTBOOT_COMMAND_FLASH,
+ FASTBOOT_COMMAND_ERASE,
+#endif
+ FASTBOOT_COMMAND_BOOT,
+ FASTBOOT_COMMAND_CONTINUE,
+ FASTBOOT_COMMAND_REBOOT,
+ FASTBOOT_COMMAND_REBOOT_BOOTLOADER,
+ FASTBOOT_COMMAND_SET_ACTIVE,
+
+ FASTBOOT_COMMAND_COUNT
+};
+
+/**
* fastboot_response() - Writes a response of the form "$tag$reason".
*
* @tag: The first part of the response
@@ -43,5 +63,89 @@ void fastboot_fail(const char *reason, char *response);
* @response: Pointer to fastboot response buffer
*/
void fastboot_okay(const char *reason, char *response);
+
+/**
+ * fastboot_set_reboot_flag() - Set flag to indicate reboot-bootloader
+ *
+ * Set flag which indicates that we should reboot into the bootloader
+ * following the reboot that fastboot executes after this function.
+ *
+ * This function should be overridden in your board file with one
+ * which sets whatever flag your board specific Android bootloader flow
+ * requires in order to re-enter the bootloader.
+ */
int fastboot_set_reboot_flag(void);
+
+/**
+ * fastboot_set_progress_callback() - set progress callback
+ *
+ * @progress: Pointer to progress callback
+ *
+ * Set a callback which is invoked periodically during long running operations
+ * (flash and erase). This can be used (for example) by the UDP transport to
+ * send INFO responses to keep the client alive whilst those commands are
+ * executing.
+ */
+void fastboot_set_progress_callback(void (*progress)(const char *msg));
+
+/*
+ * fastboot_init() - initialise new fastboot protocol session
+ *
+ * @buf_addr: Pointer to download buffer, or NULL for default
+ * @buf_size: Size of download buffer, or zero for default
+ */
+void fastboot_init(void *buf_addr, u32 buf_size);
+
+/**
+ * fastboot_boot() - Execute fastboot boot command
+ *
+ * If ${fastboot_bootcmd} is set, run that command to execute the boot
+ * process, if that returns, then exit the fastboot server and return
+ * control to the caller.
+ *
+ * Otherwise execute "bootm <fastboot_buf_addr>", if that fails, reset
+ * the board.
+ */
+void fastboot_boot(void);
+
+/**
+ * fastboot_handle_command() - Handle fastboot command
+ *
+ * @cmd_string: Pointer to command string
+ * @response: Pointer to fastboot response buffer
+ *
+ * Return: Executed command, or -1 if not recognized
+ */
+int fastboot_handle_command(char *cmd_string, char *response);
+
+/**
+ * fastboot_data_remaining() - return bytes remaining in current transfer
+ *
+ * Return: Number of bytes left in the current download
+ */
+u32 fastboot_data_remaining(void);
+
+/**
+ * fastboot_data_download() - Copy image data to fastboot_buf_addr.
+ *
+ * @fastboot_data: Pointer to received fastboot data
+ * @fastboot_data_len: Length of received fastboot data
+ * @response: Pointer to fastboot response buffer
+ *
+ * Copies image data from fastboot_data to fastboot_buf_addr. Writes to
+ * response. fastboot_bytes_received is updated to indicate the number
+ * of bytes that have been transferred.
+ */
+void fastboot_data_download(const void *fastboot_data,
+ unsigned int fastboot_data_len, char *response);
+
+/**
+ * fastboot_data_complete() - Mark current transfer complete
+ *
+ * @response: Pointer to fastboot response buffer
+ *
+ * Set image_size and ${filesize} to the total size of the downloaded image.
+ */
+void fastboot_data_complete(char *response);
+
#endif /* _FASTBOOT_H_ */