diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2018-01-26 09:58:56 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-02-09 10:26:38 +0100 |
commit | ed1dded0898faa1f917309172f2065014756c59f (patch) | |
tree | a6d6faf2dae2e4464de07c2db55c52c228b696d2 /include | |
parent | e5098495d4be465d6a93b4bbd9a59257c48ce068 (diff) | |
download | barebox-ed1dded0898faa1f917309172f2065014756c59f.tar.gz barebox-ed1dded0898faa1f917309172f2065014756c59f.tar.xz |
usb: gadget: fastboot: Add external command execution support
Custom projects may need vendor specific expansions to the fastboot
command execution. Allow these to be implemented without messing in
the fastboot code directly.
We have a hook for all commands and also one for the "flash" command.
Each hook can decide if the generic command parser is executed
afterwards (return value FASTBOOT_CMD_FALLTHROUGH) or if the generic
parser shall be skipped (return value 0 or negative error code).
This allows board code to implement vendor specific "oem" commands
or to handle the downloaded image in a special way (i.e. do signature
checks on them)
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/usb/fastboot.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/include/usb/fastboot.h b/include/usb/fastboot.h index ced890c9ab..00c9d00df5 100644 --- a/include/usb/fastboot.h +++ b/include/usb/fastboot.h @@ -5,6 +5,8 @@ #include <file-list.h> #include <usb/composite.h> +struct f_fastboot; + /** * struct f_fastboot_opts - options to configure the fastboot gadget * @func_inst: The USB function instance to register on @@ -15,6 +17,21 @@ struct f_fastboot_opts { 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 + +int fastboot_tx_print(struct f_fastboot *f_fb, const char *fmt, ...); + #endif /* _USB_FASTBOOT_H */ |