summaryrefslogtreecommitdiff
path: root/cmd/bootstd.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2025-01-15 17:34:26 -0600
committerTom Rini <trini@konsulko.com>2025-01-15 19:27:14 -0600
commit178f6ecb21fe12ada74a9a1a08093c812b15eea5 (patch)
tree60dee6152b33cbd13f311875ce2fc8e9350a8c3d /cmd/bootstd.c
parente26a9ac4c6900cac2fa043ac50a3a3c038f4505d (diff)
parenta3d0fadca6b14f57477a4143334993daf52f89dc (diff)
Merge patch series "bootstd: Support recording images"
Simon Glass <sjg@chromium.org> says: This series provides a way to keep track of the images used in bootstd, including the type of each image. At present this is sort-of handled by struct bootflow but in quite an ad-hoc way. The structure has become quite large and is hard to query. Future work will be able to reduce its size. Ultimately the 'bootflow info' command may change to also show images as a list, but that is left for later, as this series is already fairly long. So for now, just introduce the concept and adjust bootstd to use it, with a simple command to list the images. This series includes various alist enhancements, to make use of this new data structure a little easier. [trini: Drop patch 18 and 19 for now due to size considerations] Link: https://lore.kernel.org/r/20241115231926.211999-1-sjg@chromium.org
Diffstat (limited to 'cmd/bootstd.c')
-rw-r--r--cmd/bootstd.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/cmd/bootstd.c b/cmd/bootstd.c
new file mode 100644
index 00000000000..e1d82744eb5
--- /dev/null
+++ b/cmd/bootstd.c
@@ -0,0 +1,65 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * 'bootstd' command
+ *
+ * Copyright 2024 Google LLC
+ * Written by Simon Glass <sjg@chromium.org>
+ */
+
+#include <bootdev.h>
+#include <bootflow.h>
+#include <bootmeth.h>
+#include <bootstd.h>
+#include <command.h>
+#include <dm.h>
+#include <malloc.h>
+#include <dm/uclass-internal.h>
+
+static int do_bootstd_images(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ const struct bootflow *bflow;
+ struct bootstd_priv *std;
+ int ret, i;
+
+ ret = bootstd_get_priv(&std);
+ if (ret) {
+ printf("Cannot get bootstd (err=%d)\n", ret);
+ return CMD_RET_FAILURE;
+ }
+
+ printf("Seq Bootflow Type At Size Filename\n");
+ printf("--- ------------------- -------------- -------- -------- ----------------\n");
+
+ /*
+ * Use the ordering if we have one, so long as we are not trying to list
+ * all bootmethds
+ */
+ i = 0;
+ alist_for_each(bflow, &std->bootflows) {
+ const struct bootflow_img *img;
+
+ alist_for_each(img, &bflow->images) {
+ printf("%3d %-20.20s %-15.15s ",
+ bootflow_get_seq(bflow), bflow->name,
+ bootflow_img_type_name(img->type));
+ if (img->addr)
+ printf("%8lx", img->addr);
+ else
+ printf("%8s", "-");
+ printf(" %8lx %s\n", img->size, img->fname);
+ i++;
+ }
+ }
+
+ printf("--- ------------------- -------------- -------- -------- ----------------\n");
+ printf("(%d image%s)\n", i, i != 1 ? "s" : "");
+
+ return 0;
+}
+
+U_BOOT_LONGHELP(bootstd,
+ "images - list loaded images");
+
+U_BOOT_CMD_WITH_SUBCMDS(bootstd, "Standard-boot operation", bootstd_help_text,
+ U_BOOT_SUBCMD_MKENT(images, 1, 1, do_bootstd_images));