blob: f95f4e4ae15e3cacfed3c8004d88d61ee35b83c1 [file] [log] [blame]
Alex Kiernand5aa57c2018-05-29 15:30:53 +00001// SPDX-License-Identifier: BSD-2-Clause
2/*
3 * Copyright (C) 2016 The Android Open Source Project
4 */
5
6#include <common.h>
Simon Glassadaaa482019-11-14 12:57:43 -07007#include <command.h>
Ion Agorria1c387032024-01-05 09:22:06 +02008#include <console.h>
Simon Glass313112a2019-08-01 09:46:46 -06009#include <env.h>
Alex Kiernand5aa57c2018-05-29 15:30:53 +000010#include <fastboot.h>
11#include <fastboot-internal.h>
12#include <fb_mmc.h>
13#include <fb_nand.h>
14#include <part.h>
15#include <stdlib.h>
Simon Glassbdd5f812023-09-14 18:21:46 -060016#include <linux/printk.h>
Alex Kiernand5aa57c2018-05-29 15:30:53 +000017
18/**
19 * image_size - final fastboot image size
20 */
21static u32 image_size;
22
23/**
24 * fastboot_bytes_received - number of bytes received in the current download
25 */
26static u32 fastboot_bytes_received;
27
28/**
29 * fastboot_bytes_expected - number of bytes expected in the current download
30 */
31static u32 fastboot_bytes_expected;
32
33static void okay(char *, char *);
34static void getvar(char *, char *);
35static void download(char *, char *);
Alex Kiernand5aa57c2018-05-29 15:30:53 +000036static void flash(char *, char *);
37static void erase(char *, char *);
Alex Kiernand5aa57c2018-05-29 15:30:53 +000038static void reboot_bootloader(char *, char *);
Roman Kovalivskyib30b97b2020-07-28 23:35:33 +030039static void reboot_fastbootd(char *, char *);
40static void reboot_recovery(char *, char *);
Alex Kiernanc86cde92018-05-29 15:30:54 +000041static void oem_format(char *, char *);
Patrick Delaunay61687702021-01-27 14:46:48 +010042static void oem_partconf(char *, char *);
Patrick Delaunay67af29a2021-01-27 14:46:49 +010043static void oem_bootbus(char *, char *);
Ion Agorriae64262d2024-01-05 09:22:11 +020044static void oem_console(char *, char *);
Heiko Schocher3a994482021-02-10 09:29:03 +010045static void run_ucmd(char *, char *);
46static void run_acmd(char *, char *);
Heiko Schocher3a994482021-02-10 09:29:03 +010047
Alex Kiernand5aa57c2018-05-29 15:30:53 +000048static const struct {
49 const char *command;
50 void (*dispatch)(char *cmd_parameter, char *response);
51} commands[FASTBOOT_COMMAND_COUNT] = {
52 [FASTBOOT_COMMAND_GETVAR] = {
53 .command = "getvar",
54 .dispatch = getvar
55 },
56 [FASTBOOT_COMMAND_DOWNLOAD] = {
57 .command = "download",
58 .dispatch = download
59 },
Alex Kiernand5aa57c2018-05-29 15:30:53 +000060 [FASTBOOT_COMMAND_FLASH] = {
61 .command = "flash",
Patrick Delaunayf82f9e42022-12-15 10:15:50 +010062 .dispatch = CONFIG_IS_ENABLED(FASTBOOT_FLASH, (flash), (NULL))
Alex Kiernand5aa57c2018-05-29 15:30:53 +000063 },
64 [FASTBOOT_COMMAND_ERASE] = {
65 .command = "erase",
Patrick Delaunayf82f9e42022-12-15 10:15:50 +010066 .dispatch = CONFIG_IS_ENABLED(FASTBOOT_FLASH, (erase), (NULL))
Alex Kiernand5aa57c2018-05-29 15:30:53 +000067 },
Alex Kiernand5aa57c2018-05-29 15:30:53 +000068 [FASTBOOT_COMMAND_BOOT] = {
69 .command = "boot",
70 .dispatch = okay
71 },
72 [FASTBOOT_COMMAND_CONTINUE] = {
73 .command = "continue",
74 .dispatch = okay
75 },
76 [FASTBOOT_COMMAND_REBOOT] = {
77 .command = "reboot",
78 .dispatch = okay
79 },
80 [FASTBOOT_COMMAND_REBOOT_BOOTLOADER] = {
81 .command = "reboot-bootloader",
82 .dispatch = reboot_bootloader
83 },
Roman Kovalivskyib30b97b2020-07-28 23:35:33 +030084 [FASTBOOT_COMMAND_REBOOT_FASTBOOTD] = {
85 .command = "reboot-fastboot",
86 .dispatch = reboot_fastbootd
87 },
88 [FASTBOOT_COMMAND_REBOOT_RECOVERY] = {
89 .command = "reboot-recovery",
90 .dispatch = reboot_recovery
91 },
Alex Kiernand5aa57c2018-05-29 15:30:53 +000092 [FASTBOOT_COMMAND_SET_ACTIVE] = {
93 .command = "set_active",
94 .dispatch = okay
95 },
Alex Kiernanc86cde92018-05-29 15:30:54 +000096 [FASTBOOT_COMMAND_OEM_FORMAT] = {
97 .command = "oem format",
Patrick Delaunayf82f9e42022-12-15 10:15:50 +010098 .dispatch = CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT, (oem_format), (NULL))
Alex Kiernanc86cde92018-05-29 15:30:54 +000099 },
Patrick Delaunay61687702021-01-27 14:46:48 +0100100 [FASTBOOT_COMMAND_OEM_PARTCONF] = {
101 .command = "oem partconf",
Patrick Delaunayf82f9e42022-12-15 10:15:50 +0100102 .dispatch = CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_PARTCONF, (oem_partconf), (NULL))
Patrick Delaunay61687702021-01-27 14:46:48 +0100103 },
Patrick Delaunay67af29a2021-01-27 14:46:49 +0100104 [FASTBOOT_COMMAND_OEM_BOOTBUS] = {
105 .command = "oem bootbus",
Patrick Delaunayf82f9e42022-12-15 10:15:50 +0100106 .dispatch = CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_BOOTBUS, (oem_bootbus), (NULL))
Patrick Delaunay67af29a2021-01-27 14:46:49 +0100107 },
Sean Anderson421bec02022-12-16 13:20:16 -0500108 [FASTBOOT_COMMAND_OEM_RUN] = {
109 .command = "oem run",
110 .dispatch = CONFIG_IS_ENABLED(FASTBOOT_OEM_RUN, (run_ucmd), (NULL))
111 },
Ion Agorriae64262d2024-01-05 09:22:11 +0200112 [FASTBOOT_COMMAND_OEM_CONSOLE] = {
113 .command = "oem console",
114 .dispatch = CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_CONSOLE, (oem_console), (NULL))
115 },
Heiko Schocher3a994482021-02-10 09:29:03 +0100116 [FASTBOOT_COMMAND_UCMD] = {
117 .command = "UCmd",
Patrick Delaunayf82f9e42022-12-15 10:15:50 +0100118 .dispatch = CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT, (run_ucmd), (NULL))
Heiko Schocher3a994482021-02-10 09:29:03 +0100119 },
120 [FASTBOOT_COMMAND_ACMD] = {
121 .command = "ACmd",
Patrick Delaunayf82f9e42022-12-15 10:15:50 +0100122 .dispatch = CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT, (run_acmd), (NULL))
Heiko Schocher3a994482021-02-10 09:29:03 +0100123 },
Alex Kiernand5aa57c2018-05-29 15:30:53 +0000124};
125
126/**
127 * fastboot_handle_command - Handle fastboot command
128 *
129 * @cmd_string: Pointer to command string
130 * @response: Pointer to fastboot response buffer
131 *
132 * Return: Executed command, or -1 if not recognized
133 */
134int fastboot_handle_command(char *cmd_string, char *response)
135{
136 int i;
137 char *cmd_parameter;
138
139 cmd_parameter = cmd_string;
140 strsep(&cmd_parameter, ":");
141
142 for (i = 0; i < FASTBOOT_COMMAND_COUNT; i++) {
143 if (!strcmp(commands[i].command, cmd_string)) {
144 if (commands[i].dispatch) {
145 commands[i].dispatch(cmd_parameter,
146 response);
147 return i;
148 } else {
Patrick Delaunayf82f9e42022-12-15 10:15:50 +0100149 pr_err("command %s not supported.\n", cmd_string);
150 fastboot_fail("Unsupported command", response);
151 return -1;
Alex Kiernand5aa57c2018-05-29 15:30:53 +0000152 }
153 }
154 }
155
156 pr_err("command %s not recognized.\n", cmd_string);
157 fastboot_fail("unrecognized command", response);
158 return -1;
159}
160
Ion Agorria1c387032024-01-05 09:22:06 +0200161void fastboot_multiresponse(int cmd, char *response)
162{
163 switch (cmd) {
Ion Agorria99fc6452024-01-05 09:22:07 +0200164 case FASTBOOT_COMMAND_GETVAR:
165 fastboot_getvar_all(response);
166 break;
Ion Agorriae64262d2024-01-05 09:22:11 +0200167 case FASTBOOT_COMMAND_OEM_CONSOLE:
168 if (CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_CONSOLE)) {
169 char buf[FASTBOOT_RESPONSE_LEN] = { 0 };
170
171 if (console_record_isempty()) {
172 console_record_reset();
173 fastboot_okay(NULL, response);
174 } else {
175 int ret = console_record_readline(buf, sizeof(buf) - 5);
176
177 if (ret < 0)
178 fastboot_fail("Error reading console", response);
179 else
180 fastboot_response("INFO", response, "%s", buf);
181 }
182 break;
183 }
Ion Agorria1c387032024-01-05 09:22:06 +0200184 default:
185 fastboot_fail("Unknown multiresponse command", response);
186 break;
187 }
188}
189
Alex Kiernand5aa57c2018-05-29 15:30:53 +0000190/**
191 * okay() - Send bare OKAY response
192 *
193 * @cmd_parameter: Pointer to command parameter
194 * @response: Pointer to fastboot response buffer
195 *
196 * Send a bare OKAY fastboot response. This is used where the command is
197 * valid, but all the work is done after the response has been sent (e.g.
198 * boot, reboot etc.)
199 */
200static void okay(char *cmd_parameter, char *response)
201{
202 fastboot_okay(NULL, response);
203}
204
205/**
206 * getvar() - Read a config/version variable
207 *
208 * @cmd_parameter: Pointer to command parameter
209 * @response: Pointer to fastboot response buffer
210 */
211static void getvar(char *cmd_parameter, char *response)
212{
213 fastboot_getvar(cmd_parameter, response);
214}
215
216/**
217 * fastboot_download() - Start a download transfer from the client
218 *
219 * @cmd_parameter: Pointer to command parameter
220 * @response: Pointer to fastboot response buffer
221 */
222static void download(char *cmd_parameter, char *response)
223{
224 char *tmp;
225
226 if (!cmd_parameter) {
227 fastboot_fail("Expected command parameter", response);
228 return;
229 }
230 fastboot_bytes_received = 0;
Simon Glass3ff49ec2021-07-24 09:03:29 -0600231 fastboot_bytes_expected = hextoul(cmd_parameter, &tmp);
Alex Kiernand5aa57c2018-05-29 15:30:53 +0000232 if (fastboot_bytes_expected == 0) {
233 fastboot_fail("Expected nonzero image size", response);
234 return;
235 }
236 /*
237 * Nothing to download yet. Response is of the form:
238 * [DATA|FAIL]$cmd_parameter
239 *
240 * where cmd_parameter is an 8 digit hexadecimal number
241 */
242 if (fastboot_bytes_expected > fastboot_buf_size) {
243 fastboot_fail(cmd_parameter, response);
244 } else {
245 printf("Starting download of %d bytes\n",
246 fastboot_bytes_expected);
247 fastboot_response("DATA", response, "%s", cmd_parameter);
248 }
249}
250
251/**
252 * fastboot_data_remaining() - return bytes remaining in current transfer
253 *
254 * Return: Number of bytes left in the current download
255 */
256u32 fastboot_data_remaining(void)
257{
258 return fastboot_bytes_expected - fastboot_bytes_received;
259}
260
261/**
262 * fastboot_data_download() - Copy image data to fastboot_buf_addr.
263 *
264 * @fastboot_data: Pointer to received fastboot data
265 * @fastboot_data_len: Length of received fastboot data
266 * @response: Pointer to fastboot response buffer
267 *
268 * Copies image data from fastboot_data to fastboot_buf_addr. Writes to
269 * response. fastboot_bytes_received is updated to indicate the number
270 * of bytes that have been transferred.
271 *
272 * On completion sets image_size and ${filesize} to the total size of the
273 * downloaded image.
274 */
275void fastboot_data_download(const void *fastboot_data,
276 unsigned int fastboot_data_len,
277 char *response)
278{
279#define BYTES_PER_DOT 0x20000
280 u32 pre_dot_num, now_dot_num;
281
282 if (fastboot_data_len == 0 ||
283 (fastboot_bytes_received + fastboot_data_len) >
284 fastboot_bytes_expected) {
285 fastboot_fail("Received invalid data length",
286 response);
287 return;
288 }
289 /* Download data to fastboot_buf_addr */
290 memcpy(fastboot_buf_addr + fastboot_bytes_received,
291 fastboot_data, fastboot_data_len);
292
293 pre_dot_num = fastboot_bytes_received / BYTES_PER_DOT;
294 fastboot_bytes_received += fastboot_data_len;
295 now_dot_num = fastboot_bytes_received / BYTES_PER_DOT;
296
297 if (pre_dot_num != now_dot_num) {
298 putc('.');
299 if (!(now_dot_num % 74))
300 putc('\n');
301 }
302 *response = '\0';
303}
304
305/**
306 * fastboot_data_complete() - Mark current transfer complete
307 *
308 * @response: Pointer to fastboot response buffer
309 *
310 * Set image_size and ${filesize} to the total size of the downloaded image.
311 */
312void fastboot_data_complete(char *response)
313{
314 /* Download complete. Respond with "OKAY" */
315 fastboot_okay(NULL, response);
316 printf("\ndownloading of %d bytes finished\n", fastboot_bytes_received);
317 image_size = fastboot_bytes_received;
318 env_set_hex("filesize", image_size);
319 fastboot_bytes_expected = 0;
320 fastboot_bytes_received = 0;
321}
322
Alex Kiernand5aa57c2018-05-29 15:30:53 +0000323/**
324 * flash() - write the downloaded image to the indicated partition.
325 *
326 * @cmd_parameter: Pointer to partition name
327 * @response: Pointer to fastboot response buffer
328 *
329 * Writes the previously downloaded image to the partition indicated by
330 * cmd_parameter. Writes to response.
331 */
Patrick Delaunayf82f9e42022-12-15 10:15:50 +0100332static void __maybe_unused flash(char *cmd_parameter, char *response)
Alex Kiernand5aa57c2018-05-29 15:30:53 +0000333{
Simon Glass091a0712023-02-05 17:54:12 -0700334 if (IS_ENABLED(CONFIG_FASTBOOT_FLASH_MMC))
Patrick Delaunayf82f9e42022-12-15 10:15:50 +0100335 fastboot_mmc_flash_write(cmd_parameter, fastboot_buf_addr,
336 image_size, response);
337
Simon Glass067995932023-02-05 17:54:13 -0700338 if (IS_ENABLED(CONFIG_FASTBOOT_FLASH_NAND))
Patrick Delaunayf82f9e42022-12-15 10:15:50 +0100339 fastboot_nand_flash_write(cmd_parameter, fastboot_buf_addr,
340 image_size, response);
Alex Kiernand5aa57c2018-05-29 15:30:53 +0000341}
342
343/**
344 * erase() - erase the indicated partition.
345 *
346 * @cmd_parameter: Pointer to partition name
347 * @response: Pointer to fastboot response buffer
348 *
349 * Erases the partition indicated by cmd_parameter (clear to 0x00s). Writes
350 * to response.
351 */
Patrick Delaunayf82f9e42022-12-15 10:15:50 +0100352static void __maybe_unused erase(char *cmd_parameter, char *response)
Alex Kiernand5aa57c2018-05-29 15:30:53 +0000353{
Simon Glass091a0712023-02-05 17:54:12 -0700354 if (IS_ENABLED(CONFIG_FASTBOOT_FLASH_MMC))
Patrick Delaunayf82f9e42022-12-15 10:15:50 +0100355 fastboot_mmc_erase(cmd_parameter, response);
356
Simon Glass067995932023-02-05 17:54:13 -0700357 if (IS_ENABLED(CONFIG_FASTBOOT_FLASH_NAND))
Patrick Delaunayf82f9e42022-12-15 10:15:50 +0100358 fastboot_nand_erase(cmd_parameter, response);
Alex Kiernand5aa57c2018-05-29 15:30:53 +0000359}
Alex Kiernand5aa57c2018-05-29 15:30:53 +0000360
Heiko Schocher3a994482021-02-10 09:29:03 +0100361/**
362 * run_ucmd() - Execute the UCmd command
363 *
364 * @cmd_parameter: Pointer to command parameter
365 * @response: Pointer to fastboot response buffer
366 */
Patrick Delaunayf82f9e42022-12-15 10:15:50 +0100367static void __maybe_unused run_ucmd(char *cmd_parameter, char *response)
Heiko Schocher3a994482021-02-10 09:29:03 +0100368{
369 if (!cmd_parameter) {
370 pr_err("missing slot suffix\n");
371 fastboot_fail("missing command", response);
372 return;
373 }
374
375 if (run_command(cmd_parameter, 0))
376 fastboot_fail("", response);
377 else
378 fastboot_okay(NULL, response);
379}
380
381static char g_a_cmd_buff[64];
382
383void fastboot_acmd_complete(void)
384{
385 run_command(g_a_cmd_buff, 0);
386}
387
388/**
389 * run_acmd() - Execute the ACmd command
390 *
391 * @cmd_parameter: Pointer to command parameter
392 * @response: Pointer to fastboot response buffer
393 */
Patrick Delaunayf82f9e42022-12-15 10:15:50 +0100394static void __maybe_unused run_acmd(char *cmd_parameter, char *response)
Heiko Schocher3a994482021-02-10 09:29:03 +0100395{
396 if (!cmd_parameter) {
397 pr_err("missing slot suffix\n");
398 fastboot_fail("missing command", response);
399 return;
400 }
401
402 if (strlen(cmd_parameter) > sizeof(g_a_cmd_buff)) {
403 pr_err("too long command\n");
404 fastboot_fail("too long command", response);
405 return;
406 }
407
408 strcpy(g_a_cmd_buff, cmd_parameter);
409 fastboot_okay(NULL, response);
410}
Heiko Schocher3a994482021-02-10 09:29:03 +0100411
Alex Kiernand5aa57c2018-05-29 15:30:53 +0000412/**
413 * reboot_bootloader() - Sets reboot bootloader flag.
414 *
415 * @cmd_parameter: Pointer to command parameter
416 * @response: Pointer to fastboot response buffer
417 */
418static void reboot_bootloader(char *cmd_parameter, char *response)
419{
Roman Kovalivskyi1bb13422020-07-28 23:35:32 +0300420 if (fastboot_set_reboot_flag(FASTBOOT_REBOOT_REASON_BOOTLOADER))
Alex Kiernand5aa57c2018-05-29 15:30:53 +0000421 fastboot_fail("Cannot set reboot flag", response);
422 else
423 fastboot_okay(NULL, response);
424}
Alex Kiernanc86cde92018-05-29 15:30:54 +0000425
Roman Kovalivskyib30b97b2020-07-28 23:35:33 +0300426/**
427 * reboot_fastbootd() - Sets reboot fastboot flag.
428 *
429 * @cmd_parameter: Pointer to command parameter
430 * @response: Pointer to fastboot response buffer
431 */
432static void reboot_fastbootd(char *cmd_parameter, char *response)
433{
434 if (fastboot_set_reboot_flag(FASTBOOT_REBOOT_REASON_FASTBOOTD))
435 fastboot_fail("Cannot set fastboot flag", response);
436 else
437 fastboot_okay(NULL, response);
438}
439
440/**
441 * reboot_recovery() - Sets reboot recovery flag.
442 *
443 * @cmd_parameter: Pointer to command parameter
444 * @response: Pointer to fastboot response buffer
445 */
446static void reboot_recovery(char *cmd_parameter, char *response)
447{
448 if (fastboot_set_reboot_flag(FASTBOOT_REBOOT_REASON_RECOVERY))
449 fastboot_fail("Cannot set recovery flag", response);
450 else
451 fastboot_okay(NULL, response);
452}
453
Alex Kiernanc86cde92018-05-29 15:30:54 +0000454/**
455 * oem_format() - Execute the OEM format command
456 *
457 * @cmd_parameter: Pointer to command parameter
458 * @response: Pointer to fastboot response buffer
459 */
Patrick Delaunayf82f9e42022-12-15 10:15:50 +0100460static void __maybe_unused oem_format(char *cmd_parameter, char *response)
Alex Kiernanc86cde92018-05-29 15:30:54 +0000461{
462 char cmdbuf[32];
Patrick Delaunayf82f9e42022-12-15 10:15:50 +0100463 const int mmc_dev = config_opt_enabled(CONFIG_FASTBOOT_FLASH_MMC,
464 CONFIG_FASTBOOT_FLASH_MMC_DEV, -1);
Alex Kiernanc86cde92018-05-29 15:30:54 +0000465
466 if (!env_get("partitions")) {
467 fastboot_fail("partitions not set", response);
468 } else {
Patrick Delaunayf82f9e42022-12-15 10:15:50 +0100469 sprintf(cmdbuf, "gpt write mmc %x $partitions", mmc_dev);
Alex Kiernanc86cde92018-05-29 15:30:54 +0000470 if (run_command(cmdbuf, 0))
471 fastboot_fail("", response);
472 else
473 fastboot_okay(NULL, response);
474 }
475}
Patrick Delaunay61687702021-01-27 14:46:48 +0100476
Patrick Delaunay61687702021-01-27 14:46:48 +0100477/**
478 * oem_partconf() - Execute the OEM partconf command
479 *
480 * @cmd_parameter: Pointer to command parameter
481 * @response: Pointer to fastboot response buffer
482 */
Patrick Delaunayf82f9e42022-12-15 10:15:50 +0100483static void __maybe_unused oem_partconf(char *cmd_parameter, char *response)
Patrick Delaunay61687702021-01-27 14:46:48 +0100484{
485 char cmdbuf[32];
Patrick Delaunayf82f9e42022-12-15 10:15:50 +0100486 const int mmc_dev = config_opt_enabled(CONFIG_FASTBOOT_FLASH_MMC,
487 CONFIG_FASTBOOT_FLASH_MMC_DEV, -1);
Patrick Delaunay61687702021-01-27 14:46:48 +0100488
489 if (!cmd_parameter) {
490 fastboot_fail("Expected command parameter", response);
491 return;
492 }
493
494 /* execute 'mmc partconfg' command with cmd_parameter arguments*/
Patrick Delaunayf82f9e42022-12-15 10:15:50 +0100495 snprintf(cmdbuf, sizeof(cmdbuf), "mmc partconf %x %s 0", mmc_dev, cmd_parameter);
Patrick Delaunay61687702021-01-27 14:46:48 +0100496 printf("Execute: %s\n", cmdbuf);
497 if (run_command(cmdbuf, 0))
498 fastboot_fail("Cannot set oem partconf", response);
499 else
500 fastboot_okay(NULL, response);
501}
Patrick Delaunay67af29a2021-01-27 14:46:49 +0100502
Patrick Delaunay67af29a2021-01-27 14:46:49 +0100503/**
504 * oem_bootbus() - Execute the OEM bootbus command
505 *
506 * @cmd_parameter: Pointer to command parameter
507 * @response: Pointer to fastboot response buffer
508 */
Patrick Delaunayf82f9e42022-12-15 10:15:50 +0100509static void __maybe_unused oem_bootbus(char *cmd_parameter, char *response)
Patrick Delaunay67af29a2021-01-27 14:46:49 +0100510{
511 char cmdbuf[32];
Patrick Delaunayf82f9e42022-12-15 10:15:50 +0100512 const int mmc_dev = config_opt_enabled(CONFIG_FASTBOOT_FLASH_MMC,
513 CONFIG_FASTBOOT_FLASH_MMC_DEV, -1);
Patrick Delaunay67af29a2021-01-27 14:46:49 +0100514
515 if (!cmd_parameter) {
516 fastboot_fail("Expected command parameter", response);
517 return;
518 }
519
520 /* execute 'mmc bootbus' command with cmd_parameter arguments*/
Patrick Delaunayf82f9e42022-12-15 10:15:50 +0100521 snprintf(cmdbuf, sizeof(cmdbuf), "mmc bootbus %x %s", mmc_dev, cmd_parameter);
Patrick Delaunay67af29a2021-01-27 14:46:49 +0100522 printf("Execute: %s\n", cmdbuf);
523 if (run_command(cmdbuf, 0))
524 fastboot_fail("Cannot set oem bootbus", response);
525 else
526 fastboot_okay(NULL, response);
527}
Ion Agorriae64262d2024-01-05 09:22:11 +0200528
529/**
530 * oem_console() - Execute the OEM console command
531 *
532 * @cmd_parameter: Pointer to command parameter
533 * @response: Pointer to fastboot response buffer
534 */
535static void __maybe_unused oem_console(char *cmd_parameter, char *response)
536{
537 if (cmd_parameter)
538 console_in_puts(cmd_parameter);
539
540 if (console_record_isempty())
541 fastboot_fail("Empty console", response);
542 else
543 fastboot_response(FASTBOOT_MULTIRESPONSE_START, response, NULL);
544}