Blame view

include/fastboot.h 4.99 KB
83d290c56   Tom Rini   SPDX: Convert all...
1
  /* SPDX-License-Identifier: GPL-2.0+ */
3c8f98f5f   Maxime Ripard   fastboot: Move fa...
2
3
4
5
6
7
8
9
10
  /*
   * (C) Copyright 2008 - 2009
   * Windriver, <www.windriver.com>
   * Tom Rix <Tom.Rix@windriver.com>
   *
   * Copyright 2011 Sebastian Andrzej Siewior <bigeasy@linutronix.de>
   *
   * Copyright 2014 Linaro, Ltd.
   * Rob Herring <robh@kernel.org>
3c8f98f5f   Maxime Ripard   fastboot: Move fa...
11
12
13
   */
  #ifndef _FASTBOOT_H_
  #define _FASTBOOT_H_
1a28d38c3   Alex Kiernan   fastboot: Extract...
14
  #define FASTBOOT_VERSION	"0.4"
3c8f98f5f   Maxime Ripard   fastboot: Move fa...
15
  /* The 64 defined bytes plus \0 */
f73a7df98   Alex Kiernan   net: fastboot: Me...
16
  #define FASTBOOT_COMMAND_LEN	(64 + 1)
3c8f98f5f   Maxime Ripard   fastboot: Move fa...
17
  #define FASTBOOT_RESPONSE_LEN	(64 + 1)
d2df2abbc   Alex Kiernan   fastboot: Extract...
18
  /**
f73a7df98   Alex Kiernan   net: fastboot: Me...
19
20
21
22
23
24
25
26
27
28
29
30
31
32
   * 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,
3845b9065   Alex Kiernan   fastboot: Add sup...
33
34
35
  #if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
  	FASTBOOT_COMMAND_OEM_FORMAT,
  #endif
9b149c2a2   Ye Li   MLK-18591-3 andro...
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
  #if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
  	FASTBOOT_COMMAND_ACMD,
  	FASTBOOT_COMMAND_UCMD,
  #endif
  #ifdef CONFIG_FSL_FASTBOOT
  	FASTBOOT_COMMAND_UPLOAD,
  	FASTBOOT_COMMAND_GETSTAGED,
  #ifdef CONFIG_FASTBOOT_LOCK
  	FASTBOOT_COMMAND_FLASHING,
  	FASTBOOT_COMMAND_OEM,
  #endif
  #ifdef CONFIG_AVB_SUPPORT
  	FASTBOOT_COMMAND_SETACTIVE,
  #endif
  #ifdef CONFIG_AVB_ATX
  	FASTBOOT_COMMAND_STAGE,
  #endif
  #endif
f73a7df98   Alex Kiernan   net: fastboot: Me...
54
55
56
57
  	FASTBOOT_COMMAND_COUNT
  };
  
  /**
d2df2abbc   Alex Kiernan   fastboot: Extract...
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
   * fastboot_response() - Writes a response of the form "$tag$reason".
   *
   * @tag: The first part of the response
   * @response: Pointer to fastboot response buffer
   * @format: printf style format string
   */
  void fastboot_response(const char *tag, char *response,
  		       const char *format, ...)
  	__attribute__ ((format (__printf__, 3, 4)));
  
  /**
   * fastboot_fail() - Write a FAIL response of the form "FAIL$reason".
   *
   * @reason: Pointer to returned reason string
   * @response: Pointer to fastboot response buffer
   */
c4ded03ef   Alex Kiernan   fastboot: Refacto...
74
  void fastboot_fail(const char *reason, char *response);
d2df2abbc   Alex Kiernan   fastboot: Extract...
75
76
77
78
79
80
81
  
  /**
   * fastboot_okay() - Write an OKAY response of the form "OKAY$reason".
   *
   * @reason: Pointer to returned reason string, or NULL to send a bare "OKAY"
   * @response: Pointer to fastboot response buffer
   */
c4ded03ef   Alex Kiernan   fastboot: Refacto...
82
  void fastboot_okay(const char *reason, char *response);
f73a7df98   Alex Kiernan   net: fastboot: Me...
83
84
85
86
87
88
89
90
91
92
93
  
  /**
   * 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.
   */
8a65bd637   Alex Kiernan   fastboot: Rename ...
94
  int fastboot_set_reboot_flag(void);
f73a7df98   Alex Kiernan   net: fastboot: Me...
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
  
  /**
   * 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);
9b149c2a2   Ye Li   MLK-18591-3 andro...
167
168
169
170
171
172
173
  #if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
  void fastboot_acmd_complete(void);
  #endif
  
  int fastboot_tx_write_more(const char *buffer);
  
  int fastboot_tx_write(const char *buffer, unsigned int buffer_size);
3c8f98f5f   Maxime Ripard   fastboot: Move fa...
174
  #endif /* _FASTBOOT_H_ */