]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - cmd/bootmeth.c
1 // SPDX-License-Identifier: GPL-2.0+
5 * Copyright 2021 Google LLC
6 * Written by Simon Glass <sjg@chromium.org>
16 #include <dm/uclass-internal.h>
18 static int do_bootmeth_list(struct cmd_tbl
*cmdtp
, int flag
, int argc
,
21 struct bootstd_priv
*std
;
28 if (argc
> 1 && *argv
[1] == '-') {
29 all
= strchr(argv
[1], 'a');
34 ret
= bootstd_get_priv(&std
);
36 printf("Cannot get bootstd (err=%d)\n", ret
);
37 return CMD_RET_FAILURE
;
40 printf("Order Seq Name Description\n");
41 printf("----- --- ------------------ ------------------\n");
44 * Use the ordering if we have one, so long as we are not trying to list
47 use_order
= std
->bootmeth_count
&& !all
;
49 dev
= std
->bootmeth_order
[0];
51 ret
= uclass_find_first_device(UCLASS_BOOTMETH
, &dev
);
54 struct bootmeth_uc_plat
*ucp
= dev_get_uclass_plat(dev
);
58 * With the -a flag we may list bootdevs that are not in the
59 * ordering. Find their place in the order
61 if (all
&& std
->bootmeth_count
) {
64 /* Find the position of this bootmeth in the order */
66 for (j
= 0; j
< std
->bootmeth_count
; j
++) {
67 if (std
->bootmeth_order
[j
] == dev
)
72 if (ucp
->flags
& BOOTMETHF_GLOBAL
)
73 printf("%5s", "glob");
78 printf(" %3x %-19.19s %s\n", dev_seq(dev
), dev
->name
,
82 dev
= std
->bootmeth_order
[i
];
84 uclass_find_next_device(&dev
);
86 printf("----- --- ------------------ ------------------\n");
87 printf("(%d bootmeth%s)\n", i
, i
!= 1 ? "s" : "");
92 static int do_bootmeth_order(struct cmd_tbl
*cmdtp
, int flag
, int argc
,
97 ret
= bootmeth_set_order(argv
[1]);
99 printf("Failed (err=%d)\n", ret
);
100 return CMD_RET_FAILURE
;
102 env_set("bootmeths", argv
[1]);
107 #ifdef CONFIG_SYS_LONGHELP
108 static char bootmeth_help_text
[] =
109 "list [-a] - list available bootmeths (-a all)\n"
110 "bootmeth order [<bd> ...] - select bootmeth order / subset to use";
113 U_BOOT_CMD_WITH_SUBCMDS(bootmeth
, "Boot methods", bootmeth_help_text
,
114 U_BOOT_SUBCMD_MKENT(list
, 2, 1, do_bootmeth_list
),
115 U_BOOT_SUBCMD_MKENT(order
, CONFIG_SYS_MAXARGS
, 1, do_bootmeth_order
));