From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Tom Rini <trini@konsulko.com>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Heinrich Schuchardt <xypron.glpk@gmx.de>,
Simon Glass <sjg@chromium.org>, Bin Meng <bmeng.cn@gmail.com>,
Eddie James <eajames@linux.ibm.com>,
Ivan Mikhaylov <fr0st61te@gmail.com>
Subject: [PATCH 05/29] bootstd: Introduce programmable boot
Date: Sat, 11 Nov 2023 17:08:50 -0700 [thread overview]
Message-ID: <20231112000923.73568-6-sjg@chromium.org> (raw)
In-Reply-To: <20231112000923.73568-1-sjg@chromium.org>
At present bootstd requires CONFIG_CMDLINE to operate. Add a new
'programmable' boot which can be used when no command line is available.
For now it does almost nothing, since most bootmeths require the
command line.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
boot/Kconfig | 11 ++++++++++
boot/Makefile | 2 ++
boot/prog_boot.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++
common/main.c | 9 +++++++++
include/bootstd.h | 9 +++++++++
5 files changed, 82 insertions(+)
create mode 100644 boot/prog_boot.c
diff --git a/boot/Kconfig b/boot/Kconfig
index ef71883a5026..586d7a69fab3 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -459,6 +459,17 @@ config BOOTSTD_BOOTCOMMAND
standard boot does not support all of the features of distro boot
yet.
+config BOOTSTD_PROG
+ bool "Use programmatic boot"
+ depends on !CMDLINE
+ default y
+ help
+ Enable this to provide a board_run_command() function which can boot
+ a systen without using commands.
+
+ Note: This currently has many limitations and is not a useful booting
+ solution. Future work will eventually make this a viable option.
+
config BOOTMETH_GLOBAL
bool
help
diff --git a/boot/Makefile b/boot/Makefile
index 3fd048bb41ab..de0eafed14b1 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -25,6 +25,8 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootflow.o
obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootmeth-uclass.o
obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootstd-uclass.o
+obj-$(CONFIG_$(SPL_TPL_)BOOTSTD_PROG) += prog_boot.o
+
obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EXTLINUX) += bootmeth_extlinux.o
obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EXTLINUX_PXE) += bootmeth_pxe.o
obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EFILOADER) += bootmeth_efi.o
diff --git a/boot/prog_boot.c b/boot/prog_boot.c
new file mode 100644
index 000000000000..045554b93db0
--- /dev/null
+++ b/boot/prog_boot.c
@@ -0,0 +1,51 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2021 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#define LOG_CATEGORY UCLASS_BOOTSTD
+
+#include <bootflow.h>
+#include <bootstd.h>
+#include <command.h>
+#include <dm.h>
+
+/*
+ * show_bootmeths() - List available bootmeths
+ *
+ * We could refactor this to use do_bootmeth_list() if more detail (or ordering)
+ * are needed
+ */
+static void show_bootmeths(void)
+{
+ struct udevice *dev;
+ struct uclass *uc;
+
+ printf("Bootmeths: ");
+ uclass_id_foreach_dev(UCLASS_BOOTMETH, dev, uc)
+ printf(" %s", dev->name);
+ printf("\n");
+}
+
+int bootstd_prog_boot(void)
+{
+ struct bootflow_iter iter;
+ struct bootflow bflow;
+ int ret, flags, i;
+
+ printf("Programmatic boot starting\n");
+ show_bootmeths();
+ flags = BOOTFLOWIF_HUNT | BOOTFLOWIF_SHOW | BOOTFLOWIF_SKIP_GLOBAL;
+
+ bootstd_clear_glob();
+ for (i = 0, ret = bootflow_scan_first(NULL, NULL, &iter, flags, &bflow);
+ i < 1000 && ret != -ENODEV;
+ i++, ret = bootflow_scan_next(&iter, &bflow)) {
+ if (!bflow.err)
+ bootflow_run_boot(&iter, &bflow);
+ bootflow_free(&bflow);
+ }
+
+ return -EFAULT;
+}
diff --git a/common/main.c b/common/main.c
index 7c70de2e59a8..2668f3bb1637 100644
--- a/common/main.c
+++ b/common/main.c
@@ -9,6 +9,7 @@
#include <common.h>
#include <autoboot.h>
#include <bootstage.h>
+#include <bootstd.h>
#include <cli.h>
#include <command.h>
#include <console.h>
@@ -67,6 +68,14 @@ void main_loop(void)
autoboot_command(s);
+ if (IS_ENABLED(CONFIG_BOOTSTD_PROG)) {
+ int ret;
+
+ ret = bootstd_prog_boot();
+ printf("Standard boot failed (err=%dE)\n", ret);
+ }
+
cli_loop();
+
panic("No CLI available");
}
diff --git a/include/bootstd.h b/include/bootstd.h
index 7802564bcc63..99ce7b64e7c5 100644
--- a/include/bootstd.h
+++ b/include/bootstd.h
@@ -94,4 +94,13 @@ int bootstd_get_priv(struct bootstd_priv **stdp);
*/
void bootstd_clear_glob(void);
+/**
+ * bootstd_prog_boot() - Run standard boot in a fully programmatic mode
+ *
+ * Attempts to boot without making any use of U-Boot commands
+ *
+ * Returns: -ve error value (does not return except on failure to boot)
+ */
+int bootstd_prog_boot(void);
+
#endif
--
2.42.0.869.gea05f2083d-goog
next prev parent reply other threads:[~2023-11-12 0:14 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-12 0:08 [PATCH 00/29] bootm: Refactoring to reduce reliance on CMDLINE (part A) Simon Glass
2023-11-12 0:08 ` [PATCH 01/29] arm: x86: Drop discarding of command linker-lists Simon Glass
2023-11-15 19:55 ` Tom Rini
2023-11-12 0:08 ` [PATCH 02/29] mmc: env: Unify the U_BOOT_ENV_LOCATION conditions Simon Glass
2023-11-15 10:02 ` Heinrich Schuchardt
2023-11-19 14:49 ` Simon Glass
2023-11-21 18:12 ` Tom Rini
2023-11-12 0:08 ` [PATCH 03/29] treewide: Tidy up semicolon after command macros Simon Glass
2023-11-15 19:58 ` Tom Rini
2023-11-12 0:08 ` [PATCH 04/29] bootstd: Add missing header file from bootdev.h Simon Glass
2023-11-12 0:08 ` Simon Glass [this message]
2023-11-12 0:08 ` [PATCH 06/29] bootm: Drop arguments from bootm_start() Simon Glass
2023-11-15 22:36 ` Tom Rini
2023-11-12 0:08 ` [PATCH 07/29] bootm: Simplify arguments for bootm_pre_load() Simon Glass
2023-11-15 22:36 ` Tom Rini
2023-11-12 0:08 ` [PATCH 08/29] bootm: Move boot_get_kernel() higher in the file Simon Glass
2023-11-15 22:36 ` Tom Rini
2023-11-12 0:08 ` [PATCH 09/29] image: Tidy up genimg_get_kernel_addr_fit() Simon Glass
2023-11-15 22:36 ` Tom Rini
2023-11-12 0:08 ` [PATCH 10/29] bootm: Reduce arguments to boot_get_kernel() Simon Glass
2023-11-15 22:36 ` Tom Rini
2023-11-12 0:08 ` [PATCH 11/29] image: Document error codes from fit_image_load() Simon Glass
2023-11-15 22:36 ` Tom Rini
2023-11-12 0:08 ` [PATCH 12/29] bootm: Adjust boot_get_kernel() to return an error Simon Glass
2023-11-15 22:36 ` Tom Rini
2023-11-12 0:08 ` [PATCH 13/29] bootm: Use the error return from boot_get_kernel() Simon Glass
2023-11-15 22:36 ` Tom Rini
2023-11-12 0:08 ` [PATCH 14/29] bootstage: Drop BOOTSTAGE_ID_FIT_KERNEL_INFO Simon Glass
2023-11-15 22:37 ` Tom Rini
2023-11-12 0:09 ` [PATCH 15/29] bootm: Move error printing out of boot_get_kernel() Simon Glass
2023-11-15 22:37 ` Tom Rini
2023-11-12 0:09 ` [PATCH 16/29] bootm: Reduce arguments to boot_find_os() Simon Glass
2023-11-15 22:37 ` Tom Rini
2023-11-12 0:09 ` [PATCH 17/29] bootm: Reduce arguments to boot_get_ramdisk() Simon Glass
2023-11-15 22:37 ` Tom Rini
2023-11-12 0:09 ` [PATCH 18/29] fdt: Allow use of fdt_support inside if() statements Simon Glass
2023-11-15 22:37 ` Tom Rini
2023-11-12 0:09 ` [PATCH 19/29] bootm: Drop #ifdef in bootm_find_images() Simon Glass
2023-11-12 0:09 ` [PATCH 20/29] bootm: Pass image buffer to boot_get_fdt() Simon Glass
2023-11-12 0:09 ` [PATCH 21/29] bootm: Reduce arguments " Simon Glass
2023-11-15 22:37 ` Tom Rini
2023-11-12 0:09 ` [PATCH 22/29] bootm: Reduce arguments to boot_get_fpga() Simon Glass
2023-11-15 22:37 ` Tom Rini
2023-11-12 0:09 ` [PATCH 23/29] bootm: Reduce arguments to boot_get_loadables() Simon Glass
2023-11-15 22:37 ` Tom Rini
2023-11-12 0:09 ` [PATCH 24/29] bootm: Simplify Android ramdisk addr in bootm_find_images() Simon Glass
2023-11-15 22:37 ` Tom Rini
2023-11-12 0:09 ` [PATCH 25/29] bootm: efi: Drop special call to bootm_find_other() Simon Glass
2023-11-12 0:09 ` [PATCH 26/29] bootm: optee: " Simon Glass
2023-11-12 0:09 ` [PATCH 27/29] bootm: Adjust the parameters of bootm_find_images() Simon Glass
2023-11-15 22:38 ` Tom Rini
2023-11-16 1:42 ` Simon Glass
2023-11-16 1:47 ` Tom Rini
2023-11-16 1:56 ` Simon Glass
2023-11-16 2:07 ` Tom Rini
2023-11-16 2:35 ` Simon Glass
2023-11-12 0:09 ` [PATCH 28/29] bootm: Add a function to check overlap Simon Glass
2023-11-15 22:38 ` Tom Rini
2023-11-12 0:09 ` [PATCH 29/29] bootm: Reduce arguments to bootm_find_other() Simon Glass
2023-11-15 22:38 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231112000923.73568-6-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=bmeng.cn@gmail.com \
--cc=eajames@linux.ibm.com \
--cc=fr0st61te@gmail.com \
--cc=ilias.apalodimas@linaro.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox