blob: 045554b93db075e273ae17734faeed5ffb5da78f [file] [log] [blame]
Simon Glass1047b532023-11-18 14:05:19 -07001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2021 Google LLC
4 * Written by Simon Glass <sjg@chromium.org>
5 */
6
7#define LOG_CATEGORY UCLASS_BOOTSTD
8
9#include <bootflow.h>
10#include <bootstd.h>
11#include <command.h>
12#include <dm.h>
13
14/*
15 * show_bootmeths() - List available bootmeths
16 *
17 * We could refactor this to use do_bootmeth_list() if more detail (or ordering)
18 * are needed
19 */
20static void show_bootmeths(void)
21{
22 struct udevice *dev;
23 struct uclass *uc;
24
25 printf("Bootmeths: ");
26 uclass_id_foreach_dev(UCLASS_BOOTMETH, dev, uc)
27 printf(" %s", dev->name);
28 printf("\n");
29}
30
31int bootstd_prog_boot(void)
32{
33 struct bootflow_iter iter;
34 struct bootflow bflow;
35 int ret, flags, i;
36
37 printf("Programmatic boot starting\n");
38 show_bootmeths();
39 flags = BOOTFLOWIF_HUNT | BOOTFLOWIF_SHOW | BOOTFLOWIF_SKIP_GLOBAL;
40
41 bootstd_clear_glob();
42 for (i = 0, ret = bootflow_scan_first(NULL, NULL, &iter, flags, &bflow);
43 i < 1000 && ret != -ENODEV;
44 i++, ret = bootflow_scan_next(&iter, &bflow)) {
45 if (!bflow.err)
46 bootflow_run_boot(&iter, &bflow);
47 bootflow_free(&bflow);
48 }
49
50 return -EFAULT;
51}