summaryrefslogtreecommitdiff
path: root/cmd/bootstd.c
blob: e1d82744eb532a1c9e08fed0a4fed9ddae1d7748 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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));