blob: b002365f4f039959c4061820945c00ccc1f8b0c2 [file] [log] [blame]
Simon Glass08ad13e2022-04-24 23:31:06 -06001/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Standard U-Boot boot framework
4 *
5 * Copyright 2021 Google LLC
6 * Written by Simon Glass <sjg@chromium.org>
7 */
8
9#ifndef __bootstd_h
10#define __bootstd_h
11
12struct udevice;
13
14/**
15 * struct bootstd_priv - priv data for the bootstd driver
16 *
17 * This is attached to the (only) bootstd device, so there is only one instance
18 * of this struct. It provides overall information about bootdevs and bootflows.
19 *
20 * @prefixes: NULL-terminated list of prefixes to use for bootflow filenames,
21 * e.g. "/", "/boot/"; NULL if none
22 * @bootdev_order: Order to use for bootdevs (or NULL if none), with each item
23 * being a bootdev label, e.g. "mmc2", "mmc1";
24 * @cur_bootdev: Currently selected bootdev (for commands)
25 * @cur_bootflow: Currently selected bootflow (for commands)
26 * @glob_head: Head for the global list of all bootflows across all bootdevs
27 * @bootmeth_count: Number of bootmeth devices in @bootmeth_order
28 * @bootmeth_order: List of bootmeth devices to use, in order, NULL-terminated
29 */
30struct bootstd_priv {
31 const char **prefixes;
32 const char **bootdev_order;
33 struct udevice *cur_bootdev;
34 struct bootflow *cur_bootflow;
35 struct list_head glob_head;
36 int bootmeth_count;
37 struct udevice **bootmeth_order;
38};
39
40/**
41 * bootstd_get_bootdev_order() - Get the boot-order list
42 *
43 * This reads the boot order, e.g. {"mmc0", "mmc2", NULL}
44 *
45 * The list is alloced by the bootstd driver so should not be freed. That is the
46 * reason for all the const stuff in the function signature
47 *
48 * Return: list of string points, terminated by NULL; or NULL if no boot order
49 */
50const char *const *const bootstd_get_bootdev_order(struct udevice *dev);
51
52/**
53 * bootstd_get_prefixes() - Get the filename-prefixes list
54 *
55 * This reads the prefixes, e.g. {"/", "/bpot", NULL}
56 *
57 * The list is alloced by the bootstd driver so should not be freed. That is the
58 * reason for all the const stuff in the function signature
59 *
60 * Return: list of string points, terminated by NULL; or NULL if no boot order
61 */
62const char *const *const bootstd_get_prefixes(struct udevice *dev);
63
64/**
65 * bootstd_get_priv() - Get the (single) state for the bootstd system
66 *
67 * The state holds a global list of all bootflows that have been found.
68 *
69 * Return: 0 if OK, -ve if the uclass does not exist
70 */
71int bootstd_get_priv(struct bootstd_priv **stdp);
72
73/**
74 * bootstd_clear_glob() - Clear the global list of bootflows
75 *
76 * This removes all bootflows globally and across all bootdevs.
77 */
78void bootstd_clear_glob(void);
79
80#endif