aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorIon Agorria <ion@agorria.com>2024-01-05 09:22:06 +0200
committerMattijs Korpershoek <mkorpershoek@baylibre.com>2024-01-09 14:58:33 +0100
commit85fcd69dc2c03025648a1b1b511c1f10abf87c1e (patch)
tree5028e73fe98e012861dcc95d2627bc95d54bf4b7 /net
parentc5e461fbf7cc72f0c1c8a79226b6a5170e56cb4d (diff)
downloadu-boot-85fcd69dc2c03025648a1b1b511c1f10abf87c1e.zip
u-boot-85fcd69dc2c03025648a1b1b511c1f10abf87c1e.tar.gz
u-boot-85fcd69dc2c03025648a1b1b511c1f10abf87c1e.tar.bz2
fastboot: multiresponse support
Currently u-boot fastboot can only send one message back to host, so if there is a need to print more than one line messages must be kept sending until all the required data is obtained. This behavior can be adjusted using multiresponce ability (getting multiple lines of response) proposed in this patch. Signed-off-by: Ion Agorria <ion@agorria.com> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> Link: https://lore.kernel.org/r/20240105072212.6615-2-clamor95@gmail.com Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Diffstat (limited to 'net')
-rw-r--r--net/fastboot_udp.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/net/fastboot_udp.c b/net/fastboot_udp.c
index d690787..6fee441 100644
--- a/net/fastboot_udp.c
+++ b/net/fastboot_udp.c
@@ -42,16 +42,15 @@ static int fastboot_remote_port;
static int fastboot_our_port;
/**
- * fastboot_udp_send_info() - Send an INFO packet during long commands.
+ * fastboot_udp_send_response() - Send an response into UDP
*
- * @msg: String describing the reason for waiting
+ * @response: Response to send
*/
-static void fastboot_udp_send_info(const char *msg)
+static void fastboot_udp_send_response(const char *response)
{
uchar *packet;
uchar *packet_base;
int len = 0;
- char response[FASTBOOT_RESPONSE_LEN] = {0};
struct fastboot_header response_header = {
.id = FASTBOOT_FASTBOOT,
@@ -66,7 +65,6 @@ static void fastboot_udp_send_info(const char *msg)
memcpy(packet, &response_header, sizeof(response_header));
packet += sizeof(response_header);
/* Write response */
- fastboot_response("INFO", response, "%s", msg);
memcpy(packet, response, strlen(response));
packet += strlen(response);
@@ -91,6 +89,7 @@ static void fastboot_udp_send_info(const char *msg)
static void fastboot_timed_send_info(const char *msg)
{
static ulong start;
+ char response[FASTBOOT_RESPONSE_LEN] = {0};
/* Initialize timer */
if (start == 0)
@@ -99,7 +98,8 @@ static void fastboot_timed_send_info(const char *msg)
/* Send INFO packet to host every 30 seconds */
if (time >= 30000) {
start = get_timer(0);
- fastboot_udp_send_info(msg);
+ fastboot_response("INFO", response, "%s", msg);
+ fastboot_udp_send_response(response);
}
}
@@ -180,6 +180,23 @@ static void fastboot_send(struct fastboot_header header, char *fastboot_data,
} else {
cmd = fastboot_handle_command(command, response);
pending_command = false;
+
+ if (!strncmp(FASTBOOT_MULTIRESPONSE_START, response, 4)) {
+ while (1) {
+ /* Call handler to obtain next response */
+ fastboot_multiresponse(cmd, response);
+
+ /*
+ * Send more responses or break to send
+ * final OKAY/FAIL response
+ */
+ if (strncmp("OKAY", response, 4) &&
+ strncmp("FAIL", response, 4))
+ fastboot_udp_send_response(response);
+ else
+ break;
+ }
+ }
}
/*
* Sent some INFO packets, need to update sequence number in