blob: bd305094fdc2b34f14ff2f3e87ec654405b952a1 [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
Simon Glassd92bcc42023-01-06 08:52:42 -060012#include <dm/ofnode_decl.h>
13
Simon Glass08ad13e2022-04-24 23:31:06 -060014struct udevice;
15
16/**
17 * struct bootstd_priv - priv data for the bootstd driver
18 *
19 * This is attached to the (only) bootstd device, so there is only one instance
20 * of this struct. It provides overall information about bootdevs and bootflows.
21 *
22 * @prefixes: NULL-terminated list of prefixes to use for bootflow filenames,
23 * e.g. "/", "/boot/"; NULL if none
24 * @bootdev_order: Order to use for bootdevs (or NULL if none), with each item
Simon Glassa1bcafb2023-01-17 10:47:15 -070025 * being a bootdev label, e.g. "mmc2", "mmc1" (NULL terminated)
26 * @env_order: Order as specified by the boot_targets env var (or NULL if none),
27 * with each item being a bootdev label, e.g. "mmc2", "mmc1" (NULL
28 * terminated)
Simon Glass08ad13e2022-04-24 23:31:06 -060029 * @cur_bootdev: Currently selected bootdev (for commands)
30 * @cur_bootflow: Currently selected bootflow (for commands)
31 * @glob_head: Head for the global list of all bootflows across all bootdevs
32 * @bootmeth_count: Number of bootmeth devices in @bootmeth_order
33 * @bootmeth_order: List of bootmeth devices to use, in order, NULL-terminated
Simon Glass0a9f4262022-07-30 15:52:32 -060034 * @vbe_bootmeth: Currently selected VBE bootmeth, NULL if none
Simon Glassd92bcc42023-01-06 08:52:42 -060035 * @theme: Node containing the theme information
Simon Glass08ad13e2022-04-24 23:31:06 -060036 */
37struct bootstd_priv {
38 const char **prefixes;
39 const char **bootdev_order;
Simon Glassa1bcafb2023-01-17 10:47:15 -070040 const char **env_order;
Simon Glass08ad13e2022-04-24 23:31:06 -060041 struct udevice *cur_bootdev;
42 struct bootflow *cur_bootflow;
43 struct list_head glob_head;
44 int bootmeth_count;
45 struct udevice **bootmeth_order;
Simon Glass0a9f4262022-07-30 15:52:32 -060046 struct udevice *vbe_bootmeth;
Simon Glassd92bcc42023-01-06 08:52:42 -060047 ofnode theme;
Simon Glass08ad13e2022-04-24 23:31:06 -060048};
49
50/**
51 * bootstd_get_bootdev_order() - Get the boot-order list
52 *
53 * This reads the boot order, e.g. {"mmc0", "mmc2", NULL}
54 *
55 * The list is alloced by the bootstd driver so should not be freed. That is the
56 * reason for all the const stuff in the function signature
57 *
Simon Glassa1bcafb2023-01-17 10:47:15 -070058 * @dev: bootstd device
59 * @okp: returns true if OK, false if out of memory
60 * Return: list of string pointers, terminated by NULL; or NULL if no boot
61 * order. Note that this returns NULL in the case of an empty list
Simon Glass08ad13e2022-04-24 23:31:06 -060062 */
Simon Glassa1bcafb2023-01-17 10:47:15 -070063const char *const *const bootstd_get_bootdev_order(struct udevice *dev,
64 bool *okp);
Simon Glass08ad13e2022-04-24 23:31:06 -060065
66/**
67 * bootstd_get_prefixes() - Get the filename-prefixes list
68 *
69 * This reads the prefixes, e.g. {"/", "/bpot", NULL}
70 *
71 * The list is alloced by the bootstd driver so should not be freed. That is the
72 * reason for all the const stuff in the function signature
73 *
74 * Return: list of string points, terminated by NULL; or NULL if no boot order
75 */
76const char *const *const bootstd_get_prefixes(struct udevice *dev);
77
78/**
79 * bootstd_get_priv() - Get the (single) state for the bootstd system
80 *
81 * The state holds a global list of all bootflows that have been found.
82 *
83 * Return: 0 if OK, -ve if the uclass does not exist
84 */
85int bootstd_get_priv(struct bootstd_priv **stdp);
86
87/**
88 * bootstd_clear_glob() - Clear the global list of bootflows
89 *
90 * This removes all bootflows globally and across all bootdevs.
91 */
92void bootstd_clear_glob(void);
93
94#endif