From bd90b092882099afa3786829036c82d6a4241fc8 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 17 Jan 2023 10:47:33 -0700 Subject: bootstd: Add the concept of a bootdev hunter Some bootdevs must be enumerated before they appear. For example, USB bootdevs are not visible until USB is enumerated. With standard boot this needs to happen automatically, since we only want to enumerate a bus if it is needed. Add a way to define bootdev 'hunters' which can be used to hunt for bootdevs of a given type. Track which ones have been used and add a command to list them. Include a clang work-around which seems to be needed. Signed-off-by: Simon Glass --- cmd/bootdev.c | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'cmd/bootdev.c') diff --git a/cmd/bootdev.c b/cmd/bootdev.c index ecd797c0503..80bfe2812e4 100644 --- a/cmd/bootdev.c +++ b/cmd/bootdev.c @@ -107,14 +107,43 @@ static int do_bootdev_info(struct cmd_tbl *cmdtp, int flag, int argc, return 0; } +static int do_bootdev_hunt(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct bootstd_priv *priv; + const char *spec = NULL; + bool list = false; + int ret = 0; + + if (argc >= 2) { + if (!strcmp(argv[1], "-l")) + list = true; + else + spec = argv[1]; + } + + ret = bootstd_get_priv(&priv); + if (ret) + return ret; + if (list) { + bootdev_list_hunters(priv); + } else { + /* TODO: implement hunting */ + } + + return 0; +} + #ifdef CONFIG_SYS_LONGHELP static char bootdev_help_text[] = - "list [-p] - list all available bootdevs (-p to probe)\n" - "bootdev select - select a bootdev by name | label | seq\n" - "bootdev info [-p] - show information about a bootdev (-p to probe)"; + "list [-p] - list all available bootdevs (-p to probe)\n" + "bootdev hunt [-l|] - use hunt drivers to find bootdevs\n" + "bootdev select - select a bootdev by name | label | seq\n" + "bootdev info [-p] - show information about a bootdev (-p to probe)"; #endif U_BOOT_CMD_WITH_SUBCMDS(bootdev, "Boot devices", bootdev_help_text, U_BOOT_SUBCMD_MKENT(list, 2, 1, do_bootdev_list), + U_BOOT_SUBCMD_MKENT(hunt, 2, 1, do_bootdev_hunt), U_BOOT_SUBCMD_MKENT(select, 2, 1, do_bootdev_select), U_BOOT_SUBCMD_MKENT(info, 2, 1, do_bootdev_info)); -- cgit v1.2.3 From c7b63d500df707bd9c9041e0dae3a25f56098978 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 17 Jan 2023 10:47:34 -0700 Subject: bootstd: Support running bootdev hunters Add a way to run a bootdev hunter to find bootdevs of a certain type. Add this to the 'bootdev hunt' command. Test for this are added in a later patch, since a useful test needs some hunters to work with. Signed-off-by: Simon Glass --- cmd/bootdev.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'cmd/bootdev.c') diff --git a/cmd/bootdev.c b/cmd/bootdev.c index 80bfe2812e4..28866faac76 100644 --- a/cmd/bootdev.c +++ b/cmd/bootdev.c @@ -128,7 +128,12 @@ static int do_bootdev_hunt(struct cmd_tbl *cmdtp, int flag, int argc, if (list) { bootdev_list_hunters(priv); } else { - /* TODO: implement hunting */ + ret = bootdev_hunt(spec, true); + if (ret) { + printf("Failed (err=%dE)\n", ret); + + return CMD_RET_FAILURE; + } } return 0; -- cgit v1.2.3 From d9f48579dced9c897e718a8b0b84d56ac564a486 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 17 Jan 2023 10:48:05 -0700 Subject: bootstd: Treat DHCP and PXE as bootdev labels These are associated with the ethernet boot device but do not match its uclass name, so handle them as special cases. Provide a way to pass flags through with the bootdev so that we know how to process it. The flags are checked by the bootmeths, to ensure that only the selected bootmeth is used. While these both use the network device, they work quite differently. It is common to run only one of these, or to run PXE before DHCP. Provide bootflow flags to control which methods are used. Check these in the two bootmeths so that only the chosen one is used. Signed-off-by: Simon Glass --- cmd/bootdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd/bootdev.c') diff --git a/cmd/bootdev.c b/cmd/bootdev.c index 28866faac76..5b1efaaee87 100644 --- a/cmd/bootdev.c +++ b/cmd/bootdev.c @@ -57,7 +57,7 @@ static int do_bootdev_select(struct cmd_tbl *cmdtp, int flag, int argc, std->cur_bootdev = NULL; return 0; } - if (bootdev_find_by_any(argv[1], &dev)) + if (bootdev_find_by_any(argv[1], &dev, NULL)) return CMD_RET_FAILURE; std->cur_bootdev = dev; -- cgit v1.2.3