xref: /OK3568_Linux_fs/u-boot/common/fb_common.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6 
7 #include <common.h>
8 #include <fastboot.h>
9 #ifdef CONFIG_UDP_FUNCTION_FASTBOOT
10 #include <net/fastboot.h>
11 #endif
12 
fastboot_fail(const char * reason,char * response)13 void fastboot_fail(const char *reason, char *response)
14 {
15 	const char *fail_str = "FAIL";
16 	strncpy(response, fail_str, FASTBOOT_RESPONSE_LEN);
17 	strncat(response, reason, FASTBOOT_RESPONSE_LEN - strlen(fail_str) - 1);
18 }
19 
fastboot_okay(const char * reason,char * response)20 void fastboot_okay(const char *reason, char *response)
21 {
22 	const char *okay_str = "OKAY";
23 	strncpy(response, okay_str, FASTBOOT_RESPONSE_LEN);
24 	strncat(response, reason, FASTBOOT_RESPONSE_LEN - strlen(okay_str) - 1);
25 }
26 
timed_send_info(ulong * start,const char * msg)27 void timed_send_info(ulong *start, const char *msg)
28 {
29 #ifdef CONFIG_UDP_FUNCTION_FASTBOOT
30 	/* Initialize timer */
31 	if (*start == 0) {
32 		*start = get_timer(0);
33 	}
34 	ulong time = get_timer(*start);
35 	/* Send INFO packet to host every 30 seconds */
36 	if (time >= 30000) {
37 		*start = get_timer(0);
38 		fastboot_send_info(msg);
39 	}
40 #endif
41 }
42