blob: f3b92564d10bb0040b208ccbc1dcd9991d46c35d [file] [log] [blame]
Eugeniu Rosca35c34be2019-05-23 17:32:22 +02001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2019 Eugeniu Rosca <rosca.eugeniu@gmail.com>
4 *
5 * Command to read/modify/write Android BCB fields
6 */
7
8#include <android_bootloader_message.h>
Eugeniu Rosca54a55482020-10-23 11:52:22 +03009#include <bcb.h>
Eugeniu Rosca35c34be2019-05-23 17:32:22 +020010#include <command.h>
Tom Riniabb9a042024-05-18 20:20:43 -060011#include <common.h>
Simon Glass1ab16922022-07-31 12:28:48 -060012#include <display_options.h>
Simon Glass0f2af882020-05-10 11:40:05 -060013#include <log.h>
Simon Glass655306c2020-05-10 11:39:58 -060014#include <part.h>
Eugeniu Rosca6005e932020-10-23 11:52:23 +030015#include <malloc.h>
Gary Bissonf3f2c7b2022-01-11 18:06:06 +010016#include <memalign.h>
Mattijs Korpershoekcb254102022-10-13 14:25:59 +020017#include <linux/err.h>
Eugeniu Rosca35c34be2019-05-23 17:32:22 +020018
19enum bcb_cmd {
20 BCB_CMD_LOAD,
21 BCB_CMD_FIELD_SET,
22 BCB_CMD_FIELD_CLEAR,
23 BCB_CMD_FIELD_TEST,
24 BCB_CMD_FIELD_DUMP,
25 BCB_CMD_STORE,
26};
27
Dmitrii Merkurevacb22812023-11-10 05:59:55 +000028static const char * const fields[] = {
29 "command",
30 "status",
31 "recovery",
32 "stage"
33};
34
Gary Bissonf3f2c7b2022-01-11 18:06:06 +010035static struct bootloader_message bcb __aligned(ARCH_DMA_MINALIGN) = { { 0 } };
Dmitrii Merkurevacb22812023-11-10 05:59:55 +000036static struct disk_partition partition_data;
37
38static struct blk_desc *block;
39static struct disk_partition *partition = &partition_data;
Eugeniu Rosca35c34be2019-05-23 17:32:22 +020040
41static int bcb_cmd_get(char *cmd)
42{
Eugeniu Rosca9bb62832019-07-19 23:26:13 +020043 if (!strcmp(cmd, "load"))
Eugeniu Rosca35c34be2019-05-23 17:32:22 +020044 return BCB_CMD_LOAD;
Eugeniu Rosca9bb62832019-07-19 23:26:13 +020045 if (!strcmp(cmd, "set"))
Eugeniu Rosca35c34be2019-05-23 17:32:22 +020046 return BCB_CMD_FIELD_SET;
Eugeniu Rosca9bb62832019-07-19 23:26:13 +020047 if (!strcmp(cmd, "clear"))
Eugeniu Rosca35c34be2019-05-23 17:32:22 +020048 return BCB_CMD_FIELD_CLEAR;
Eugeniu Rosca9bb62832019-07-19 23:26:13 +020049 if (!strcmp(cmd, "test"))
Eugeniu Rosca35c34be2019-05-23 17:32:22 +020050 return BCB_CMD_FIELD_TEST;
Eugeniu Rosca9bb62832019-07-19 23:26:13 +020051 if (!strcmp(cmd, "store"))
Eugeniu Rosca35c34be2019-05-23 17:32:22 +020052 return BCB_CMD_STORE;
Eugeniu Rosca9bb62832019-07-19 23:26:13 +020053 if (!strcmp(cmd, "dump"))
Eugeniu Rosca35c34be2019-05-23 17:32:22 +020054 return BCB_CMD_FIELD_DUMP;
55 else
56 return -1;
57}
58
59static int bcb_is_misused(int argc, char *const argv[])
60{
61 int cmd = bcb_cmd_get(argv[0]);
62
63 switch (cmd) {
64 case BCB_CMD_LOAD:
Dmitrii Merkurev927e2102023-11-10 05:59:54 +000065 if (argc != 3 && argc != 4)
66 goto err;
67 break;
Eugeniu Rosca35c34be2019-05-23 17:32:22 +020068 case BCB_CMD_FIELD_SET:
69 if (argc != 3)
70 goto err;
71 break;
72 case BCB_CMD_FIELD_TEST:
73 if (argc != 4)
74 goto err;
75 break;
76 case BCB_CMD_FIELD_CLEAR:
77 if (argc != 1 && argc != 2)
78 goto err;
79 break;
80 case BCB_CMD_STORE:
81 if (argc != 1)
82 goto err;
83 break;
84 case BCB_CMD_FIELD_DUMP:
85 if (argc != 2)
86 goto err;
87 break;
88 default:
89 printf("Error: 'bcb %s' not supported\n", argv[0]);
90 return -1;
91 }
92
Dmitrii Merkurevacb22812023-11-10 05:59:55 +000093 if (cmd != BCB_CMD_LOAD && !block) {
Eugeniu Rosca35c34be2019-05-23 17:32:22 +020094 printf("Error: Please, load BCB first!\n");
95 return -1;
96 }
97
98 return 0;
99err:
100 printf("Error: Bad usage of 'bcb %s'\n", argv[0]);
101
102 return -1;
103}
104
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000105static int bcb_field_get(const char *name, char **fieldp, int *sizep)
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200106{
Eugeniu Rosca9bb62832019-07-19 23:26:13 +0200107 if (!strcmp(name, "command")) {
Eugeniu Roscacb10fc92019-07-19 23:26:14 +0200108 *fieldp = bcb.command;
109 *sizep = sizeof(bcb.command);
Eugeniu Rosca9bb62832019-07-19 23:26:13 +0200110 } else if (!strcmp(name, "status")) {
Eugeniu Roscacb10fc92019-07-19 23:26:14 +0200111 *fieldp = bcb.status;
112 *sizep = sizeof(bcb.status);
Eugeniu Rosca9bb62832019-07-19 23:26:13 +0200113 } else if (!strcmp(name, "recovery")) {
Eugeniu Roscacb10fc92019-07-19 23:26:14 +0200114 *fieldp = bcb.recovery;
115 *sizep = sizeof(bcb.recovery);
Eugeniu Rosca9bb62832019-07-19 23:26:13 +0200116 } else if (!strcmp(name, "stage")) {
Eugeniu Roscacb10fc92019-07-19 23:26:14 +0200117 *fieldp = bcb.stage;
118 *sizep = sizeof(bcb.stage);
Eugeniu Rosca9bb62832019-07-19 23:26:13 +0200119 } else if (!strcmp(name, "reserved")) {
Eugeniu Roscacb10fc92019-07-19 23:26:14 +0200120 *fieldp = bcb.reserved;
121 *sizep = sizeof(bcb.reserved);
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200122 } else {
123 printf("Error: Unknown bcb field '%s'\n", name);
124 return -1;
125 }
126
127 return 0;
128}
129
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000130static void __bcb_reset(void)
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200131{
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000132 block = NULL;
133 partition = &partition_data;
134 memset(&partition_data, 0, sizeof(struct disk_partition));
135 memset(&bcb, 0, sizeof(struct bootloader_message));
136}
137
138static int __bcb_initialize(const char *iface, int devnum, const char *partp)
139{
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200140 char *endp;
141 int part, ret;
142
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000143 block = blk_get_dev(iface, devnum);
144 if (!block) {
Eugeniu Roscaf308af52020-10-23 11:52:19 +0300145 ret = -ENODEV;
Eugeniu Roscacb10fc92019-07-19 23:26:14 +0200146 goto err_read_fail;
Eugeniu Roscaf308af52020-10-23 11:52:19 +0300147 }
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200148
Mattijs Korpershoekcb254102022-10-13 14:25:59 +0200149 /*
Dmitrii Merkurev927e2102023-11-10 05:59:54 +0000150 * always select the first hwpart in case another
Mattijs Korpershoekcb254102022-10-13 14:25:59 +0200151 * blk operation selected a different hwpart
152 */
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000153 ret = blk_dselect_hwpart(block, 0);
Mattijs Korpershoekcb254102022-10-13 14:25:59 +0200154 if (IS_ERR_VALUE(ret)) {
155 ret = -ENODEV;
156 goto err_read_fail;
157 }
158
Eugeniu Roscaf308af52020-10-23 11:52:19 +0300159 part = simple_strtoul(partp, &endp, 0);
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200160 if (*endp == '\0') {
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000161 ret = part_get_info(block, part, partition);
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200162 if (ret)
Eugeniu Roscacb10fc92019-07-19 23:26:14 +0200163 goto err_read_fail;
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200164 } else {
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000165 part = part_get_info_by_name(block, partp, partition);
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200166 if (part < 0) {
167 ret = part;
Eugeniu Roscacb10fc92019-07-19 23:26:14 +0200168 goto err_read_fail;
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200169 }
170 }
171
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000172 return CMD_RET_SUCCESS;
173
174err_read_fail:
175 printf("Error: %d %d:%s read failed (%d)\n", block->uclass_id,
176 block->devnum, partition->name, ret);
177 __bcb_reset();
178 return CMD_RET_FAILURE;
179}
180
181static int __bcb_load(void)
182{
183 u64 cnt;
184 int ret;
185
186 cnt = DIV_ROUND_UP(sizeof(struct bootloader_message), partition->blksz);
187 if (cnt > partition->size)
Eugeniu Roscacb10fc92019-07-19 23:26:14 +0200188 goto err_too_small;
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200189
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000190 if (blk_dread(block, partition->start, cnt, &bcb) != cnt) {
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200191 ret = -EIO;
Eugeniu Roscacb10fc92019-07-19 23:26:14 +0200192 goto err_read_fail;
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200193 }
194
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000195 debug("%s: Loaded from %d %d:%s\n", __func__, block->uclass_id,
196 block->devnum, partition->name);
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200197
198 return CMD_RET_SUCCESS;
Eugeniu Roscacb10fc92019-07-19 23:26:14 +0200199err_read_fail:
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000200 printf("Error: %d %d:%s read failed (%d)\n", block->uclass_id,
201 block->devnum, partition->name, ret);
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200202 goto err;
Eugeniu Roscacb10fc92019-07-19 23:26:14 +0200203err_too_small:
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000204 printf("Error: %d %d:%s too small!", block->uclass_id,
205 block->devnum, partition->name);
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200206err:
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000207 __bcb_reset();
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200208 return CMD_RET_FAILURE;
209}
210
Eugeniu Roscaf308af52020-10-23 11:52:19 +0300211static int do_bcb_load(struct cmd_tbl *cmdtp, int flag, int argc,
212 char * const argv[])
213{
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000214 int ret;
Dmitrii Merkurev927e2102023-11-10 05:59:54 +0000215 int devnum;
Eugeniu Roscaf308af52020-10-23 11:52:19 +0300216 char *endp;
Dmitrii Merkurev927e2102023-11-10 05:59:54 +0000217 char *iface = "mmc";
Eugeniu Roscaf308af52020-10-23 11:52:19 +0300218
Dmitrii Merkurev927e2102023-11-10 05:59:54 +0000219 if (argc == 4) {
220 iface = argv[1];
221 argc--;
222 argv++;
223 }
224
225 devnum = simple_strtoul(argv[1], &endp, 0);
Eugeniu Roscaf308af52020-10-23 11:52:19 +0300226 if (*endp != '\0') {
227 printf("Error: Device id '%s' not a number\n", argv[1]);
228 return CMD_RET_FAILURE;
229 }
230
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000231 ret = __bcb_initialize(iface, devnum, argv[2]);
232 if (ret != CMD_RET_SUCCESS)
233 return ret;
234
235 return __bcb_load();
Eugeniu Roscaf308af52020-10-23 11:52:19 +0300236}
237
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000238static int __bcb_set(const char *fieldp, const char *valp)
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200239{
240 int size, len;
Eugeniu Rosca6005e932020-10-23 11:52:23 +0300241 char *field, *str, *found, *tmp;
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200242
Eugeniu Rosca92be5442020-10-23 11:52:20 +0300243 if (bcb_field_get(fieldp, &field, &size))
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200244 return CMD_RET_FAILURE;
245
Eugeniu Rosca92be5442020-10-23 11:52:20 +0300246 len = strlen(valp);
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200247 if (len >= size) {
248 printf("Error: sizeof('%s') = %d >= %d = sizeof(bcb.%s)\n",
Eugeniu Rosca92be5442020-10-23 11:52:20 +0300249 valp, len, size, fieldp);
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200250 return CMD_RET_FAILURE;
251 }
Eugeniu Rosca6005e932020-10-23 11:52:23 +0300252 str = strdup(valp);
253 if (!str) {
254 printf("Error: Out of memory while strdup\n");
255 return CMD_RET_FAILURE;
256 }
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200257
Eugeniu Rosca6005e932020-10-23 11:52:23 +0300258 tmp = str;
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200259 field[0] = '\0';
Eugeniu Rosca6005e932020-10-23 11:52:23 +0300260 while ((found = strsep(&tmp, ":"))) {
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200261 if (field[0] != '\0')
262 strcat(field, "\n");
263 strcat(field, found);
264 }
Eugeniu Rosca6005e932020-10-23 11:52:23 +0300265 free(str);
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200266
267 return CMD_RET_SUCCESS;
268}
269
Eugeniu Rosca92be5442020-10-23 11:52:20 +0300270static int do_bcb_set(struct cmd_tbl *cmdtp, int flag, int argc,
271 char * const argv[])
272{
273 return __bcb_set(argv[1], argv[2]);
274}
275
Simon Glassed38aef2020-05-10 11:40:03 -0600276static int do_bcb_clear(struct cmd_tbl *cmdtp, int flag, int argc,
277 char *const argv[])
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200278{
279 int size;
280 char *field;
281
282 if (argc == 1) {
283 memset(&bcb, 0, sizeof(bcb));
284 return CMD_RET_SUCCESS;
285 }
286
287 if (bcb_field_get(argv[1], &field, &size))
288 return CMD_RET_FAILURE;
289
290 memset(field, 0, size);
291
292 return CMD_RET_SUCCESS;
293}
294
Simon Glassed38aef2020-05-10 11:40:03 -0600295static int do_bcb_test(struct cmd_tbl *cmdtp, int flag, int argc,
296 char *const argv[])
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200297{
298 int size;
299 char *field;
300 char *op = argv[2];
301
302 if (bcb_field_get(argv[1], &field, &size))
303 return CMD_RET_FAILURE;
304
305 if (*op == '=' && *(op + 1) == '\0') {
306 if (!strncmp(argv[3], field, size))
307 return CMD_RET_SUCCESS;
308 else
309 return CMD_RET_FAILURE;
310 } else if (*op == '~' && *(op + 1) == '\0') {
311 if (!strstr(field, argv[3]))
312 return CMD_RET_FAILURE;
313 else
314 return CMD_RET_SUCCESS;
315 } else {
316 printf("Error: Unknown operator '%s'\n", op);
317 }
318
319 return CMD_RET_FAILURE;
320}
321
Simon Glassed38aef2020-05-10 11:40:03 -0600322static int do_bcb_dump(struct cmd_tbl *cmdtp, int flag, int argc,
323 char *const argv[])
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200324{
325 int size;
326 char *field;
327
328 if (bcb_field_get(argv[1], &field, &size))
329 return CMD_RET_FAILURE;
330
331 print_buffer((ulong)field - (ulong)&bcb, (void *)field, 1, size, 16);
332
333 return CMD_RET_SUCCESS;
334}
335
Eugeniu Roscaf6155bd2020-10-23 11:52:21 +0300336static int __bcb_store(void)
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200337{
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200338 u64 cnt;
339 int ret;
340
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000341 cnt = DIV_ROUND_UP(sizeof(struct bootloader_message), partition->blksz);
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200342
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000343 if (blk_dwrite(block, partition->start, cnt, &bcb) != cnt) {
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200344 ret = -EIO;
345 goto err;
346 }
347
348 return CMD_RET_SUCCESS;
349err:
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000350 printf("Error: %d %d:%s write failed (%d)\n", block->uclass_id,
351 block->devnum, partition->name, ret);
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200352
353 return CMD_RET_FAILURE;
354}
355
Eugeniu Roscaf6155bd2020-10-23 11:52:21 +0300356static int do_bcb_store(struct cmd_tbl *cmdtp, int flag, int argc,
357 char * const argv[])
358{
359 return __bcb_store();
360}
361
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000362int bcb_find_partition_and_load(const char *iface, int devnum, char *partp)
Eugeniu Rosca54a55482020-10-23 11:52:22 +0300363{
364 int ret;
365
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000366 __bcb_reset();
Eugeniu Rosca54a55482020-10-23 11:52:22 +0300367
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000368 ret = __bcb_initialize(iface, devnum, partp);
Eugeniu Rosca54a55482020-10-23 11:52:22 +0300369 if (ret != CMD_RET_SUCCESS)
370 return ret;
371
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000372 return __bcb_load();
373}
Eugeniu Rosca54a55482020-10-23 11:52:22 +0300374
Dmitrii Merkurevacb22812023-11-10 05:59:55 +0000375int bcb_load(struct blk_desc *block_description, struct disk_partition *disk_partition)
376{
377 __bcb_reset();
378
379 block = block_description;
380 partition = disk_partition;
381
382 return __bcb_load();
383}
384
385int bcb_set(enum bcb_field field, const char *value)
386{
387 if (field > BCB_FIELD_STAGE)
388 return CMD_RET_FAILURE;
389 return __bcb_set(fields[field], value);
390}
391
392int bcb_get(enum bcb_field field, char *value_out, size_t value_size)
393{
394 int size;
395 char *field_value;
396
397 if (field > BCB_FIELD_STAGE)
398 return CMD_RET_FAILURE;
399 if (bcb_field_get(fields[field], &field_value, &size))
400 return CMD_RET_FAILURE;
401
402 strlcpy(value_out, field_value, value_size);
403
404 return CMD_RET_SUCCESS;
405}
406
407int bcb_store(void)
408{
409 return __bcb_store();
410}
411
412void bcb_reset(void)
413{
414 __bcb_reset();
Eugeniu Rosca54a55482020-10-23 11:52:22 +0300415}
416
Simon Glassed38aef2020-05-10 11:40:03 -0600417static struct cmd_tbl cmd_bcb_sub[] = {
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200418 U_BOOT_CMD_MKENT(load, CONFIG_SYS_MAXARGS, 1, do_bcb_load, "", ""),
419 U_BOOT_CMD_MKENT(set, CONFIG_SYS_MAXARGS, 1, do_bcb_set, "", ""),
420 U_BOOT_CMD_MKENT(clear, CONFIG_SYS_MAXARGS, 1, do_bcb_clear, "", ""),
421 U_BOOT_CMD_MKENT(test, CONFIG_SYS_MAXARGS, 1, do_bcb_test, "", ""),
422 U_BOOT_CMD_MKENT(dump, CONFIG_SYS_MAXARGS, 1, do_bcb_dump, "", ""),
423 U_BOOT_CMD_MKENT(store, CONFIG_SYS_MAXARGS, 1, do_bcb_store, "", ""),
424};
425
Simon Glassed38aef2020-05-10 11:40:03 -0600426static int do_bcb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200427{
Simon Glassed38aef2020-05-10 11:40:03 -0600428 struct cmd_tbl *c;
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200429
430 if (argc < 2)
431 return CMD_RET_USAGE;
432
433 argc--;
434 argv++;
435
436 c = find_cmd_tbl(argv[0], cmd_bcb_sub, ARRAY_SIZE(cmd_bcb_sub));
437 if (!c)
438 return CMD_RET_USAGE;
439
440 if (bcb_is_misused(argc, argv)) {
Eugeniu Roscacb10fc92019-07-19 23:26:14 +0200441 /*
442 * We try to improve the user experience by reporting the
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200443 * root-cause of misusage, so don't return CMD_RET_USAGE,
444 * since the latter prints out the full-blown help text
445 */
446 return CMD_RET_FAILURE;
447 }
448
449 return c->cmd(cmdtp, flag, argc, argv);
450}
451
452U_BOOT_CMD(
453 bcb, CONFIG_SYS_MAXARGS, 1, do_bcb,
454 "Load/set/clear/test/dump/store Android BCB fields",
Dmitrii Merkurev927e2102023-11-10 05:59:54 +0000455 "load <interface> <dev> <part> - load BCB from <interface> <dev>:<part>\n"
456 "load <dev> <part> - load BCB from mmc <dev>:<part>\n"
457 "bcb set <field> <val> - set BCB <field> to <val>\n"
458 "bcb clear [<field>] - clear BCB <field> or all fields\n"
459 "bcb test <field> <op> <val> - test BCB <field> against <val>\n"
460 "bcb dump <field> - dump BCB <field>\n"
461 "bcb store - store BCB back to <interface>\n"
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200462 "\n"
463 "Legend:\n"
Dmitrii Merkurev927e2102023-11-10 05:59:54 +0000464 "<interface> - storage device interface (virtio, mmc, etc)\n"
465 "<dev> - storage device index containing the BCB partition\n"
466 "<part> - partition index or name containing the BCB\n"
467 "<field> - one of {command,status,recovery,stage,reserved}\n"
468 "<op> - the binary operator used in 'bcb test':\n"
469 " '=' returns true if <val> matches the string stored in <field>\n"
470 " '~' returns true if <val> matches a subset of <field>'s string\n"
471 "<val> - string/text provided as input to bcb {set,test}\n"
472 " NOTE: any ':' character in <val> will be replaced by line feed\n"
473 " during 'bcb set' and used as separator by upper layers\n"
Eugeniu Rosca35c34be2019-05-23 17:32:22 +0200474);