summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/fastboot.h66
-rw-r--r--include/usb/fastboot.h34
-rw-r--r--include/usb/gadget-multi.h2
3 files changed, 70 insertions, 32 deletions
diff --git a/include/fastboot.h b/include/fastboot.h
new file mode 100644
index 0000000000..3b6cae8a58
--- /dev/null
+++ b/include/fastboot.h
@@ -0,0 +1,66 @@
+#ifndef __FASTBOOT__
+#define __FASTBOOT__
+
+#include <common.h>
+#include <file-list.h>
+#include <net.h>
+
+/*
+ * Return codes for the exec_cmd callback above:
+ *
+ * FASTBOOT_CMD_FALLTHROUGH - Not handled by the external command dispatcher,
+ * handle it with internal dispatcher
+ * Other than these negative error codes mean errors handling the command and
+ * zero means the command has been successfully handled.
+ */
+#define FASTBOOT_CMD_FALLTHROUGH 1
+
+struct fastboot {
+ int (*write)(struct fastboot *fb, const char *buf, unsigned int n);
+ void (*start_download)(struct fastboot *fb);
+
+ struct file_list *files;
+ int (*cmd_exec)(struct fastboot *fb, const char *cmd);
+ int (*cmd_flash)(struct fastboot *fb, struct file_list_entry *entry,
+ const char *filename, const void *buf, size_t len);
+ int download_fd;
+ void *buf;
+
+ bool active;
+
+ size_t download_bytes;
+ size_t download_size;
+ struct list_head variables;
+};
+
+/**
+ * struct fastboot_opts - options to configure fastboot
+ * @files: A file_list containing the files (partitions) to export via fastboot
+ * @export_bbu: Automatically include the partitions provided by barebox update (bbu)
+ */
+struct fastboot_opts {
+ struct file_list *files;
+ bool export_bbu;
+ int (*cmd_exec)(struct fastboot *fb, const char *cmd);
+ int (*cmd_flash)(struct fastboot *fb, struct file_list_entry *entry,
+ const char *filename, const void *buf, size_t len);
+};
+
+enum fastboot_msg_type {
+ FASTBOOT_MSG_OKAY,
+ FASTBOOT_MSG_FAIL,
+ FASTBOOT_MSG_INFO,
+ FASTBOOT_MSG_DATA,
+};
+
+int fastboot_generic_init(struct fastboot *fb, bool export_bbu);
+void fastboot_generic_close(struct fastboot *fb);
+void fastboot_generic_free(struct fastboot *fb);
+int fastboot_handle_download_data(struct fastboot *fb, const void *buffer,
+ unsigned int len);
+int fastboot_tx_print(struct fastboot *fb, enum fastboot_msg_type type,
+ const char *fmt, ...);
+void fastboot_start_download_generic(struct fastboot *fb);
+void fastboot_download_finished(struct fastboot *fb);
+void fastboot_exec_cmd(struct fastboot *fb, const char *cmdbuf);
+#endif
diff --git a/include/usb/fastboot.h b/include/usb/fastboot.h
index c0775c67dd..a3609ba5db 100644
--- a/include/usb/fastboot.h
+++ b/include/usb/fastboot.h
@@ -1,45 +1,17 @@
#ifndef _USB_FASTBOOT_H
#define _USB_FASTBOOT_H
-#include <linux/types.h>
-#include <file-list.h>
#include <usb/composite.h>
-
-struct f_fastboot;
+#include <fastboot.h>
/**
* struct f_fastboot_opts - options to configure the fastboot gadget
+ * @common: Options common to all fastboot protocol variants
* @func_inst: The USB function instance to register on
- * @files: A file_list containing the files (partitions) to export via fastboot
- * @export_bbu: Automatically include the partitions provided by barebox update (bbu)
*/
struct f_fastboot_opts {
+ struct fastboot_opts common;
struct usb_function_instance func_inst;
- struct file_list *files;
- bool export_bbu;
- int (*cmd_exec)(struct f_fastboot *, const char *cmd);
- int (*cmd_flash)(struct f_fastboot *, struct file_list_entry *entry,
- const char *filename, const void *buf, size_t len);
-};
-
-/*
- * Return codes for the exec_cmd callback above:
- *
- * FASTBOOT_CMD_FALLTHROUGH - Not handled by the external command dispatcher,
- * handle it with internal dispatcher
- * Other than these negative error codes mean errors handling the command and
- * zero means the command has been successfully handled.
- */
-#define FASTBOOT_CMD_FALLTHROUGH 1
-
-enum fastboot_msg_type {
- FASTBOOT_MSG_OKAY,
- FASTBOOT_MSG_FAIL,
- FASTBOOT_MSG_INFO,
- FASTBOOT_MSG_DATA,
};
-int fastboot_tx_print(struct f_fastboot *f_fb, enum fastboot_msg_type type,
- const char *fmt, ...);
-
#endif /* _USB_FASTBOOT_H */
diff --git a/include/usb/gadget-multi.h b/include/usb/gadget-multi.h
index 030e604fe7..9bb6c889f3 100644
--- a/include/usb/gadget-multi.h
+++ b/include/usb/gadget-multi.h
@@ -6,7 +6,7 @@
#include <usb/usbserial.h>
struct f_multi_opts {
- struct f_fastboot_opts fastboot_opts;
+ struct fastboot_opts fastboot_opts;
struct f_dfu_opts dfu_opts;
int create_acm;
void (*release)(struct f_multi_opts *opts);