blob: 01be249d16e9cd69a5a09d6463b8049fa5f3ba34 [file] [log] [blame]
Simon Glassef5e3892022-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
Simon Glass4c7418f2022-07-30 15:52:32 -060029 * @vbe_bootmeth: Currently selected VBE bootmeth, NULL if none
Simon Glassef5e3892022-04-24 23:31:06 -060030 */
31struct bootstd_priv {
32 const char **prefixes;
33 const char **bootdev_order;
34 struct udevice *cur_bootdev;
35 struct bootflow *cur_bootflow;
36 struct list_head glob_head;
37 int bootmeth_count;
38 struct udevice **bootmeth_order;
Simon Glass4c7418f2022-07-30 15:52:32 -060039 struct udevice *vbe_bootmeth;
Simon Glassef5e3892022-04-24 23:31:06 -060040};
41
42/**
43 * bootstd_get_bootdev_order() - Get the boot-order list
44 *
45 * This reads the boot order, e.g. {"mmc0", "mmc2", NULL}
46 *
47 * The list is alloced by the bootstd driver so should not be freed. That is the
48 * reason for all the const stuff in the function signature
49 *
50 * Return: list of string points, terminated by NULL; or NULL if no boot order
51 */
52const char *const *const bootstd_get_bootdev_order(struct udevice *dev);
53
54/**
55 * bootstd_get_prefixes() - Get the filename-prefixes list
56 *
57 * This reads the prefixes, e.g. {"/", "/bpot", NULL}
58 *
59 * The list is alloced by the bootstd driver so should not be freed. That is the
60 * reason for all the const stuff in the function signature
61 *
62 * Return: list of string points, terminated by NULL; or NULL if no boot order
63 */
64const char *const *const bootstd_get_prefixes(struct udevice *dev);
65
66/**
67 * bootstd_get_priv() - Get the (single) state for the bootstd system
68 *
69 * The state holds a global list of all bootflows that have been found.
70 *
71 * Return: 0 if OK, -ve if the uclass does not exist
72 */
73int bootstd_get_priv(struct bootstd_priv **stdp);
74
75/**
76 * bootstd_clear_glob() - Clear the global list of bootflows
77 *
78 * This removes all bootflows globally and across all bootdevs.
79 */
80void bootstd_clear_glob(void);
81
82#endif