]> Git Repo - u-boot.git/blame - include/bootstd.h
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sh
[u-boot.git] / include / bootstd.h
CommitLineData
ef5e3891
SG
1/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Standard U-Boot boot framework
4 *
5 * Copyright 2021 Google LLC
6 * Written by Simon Glass <[email protected]>
7 */
8
9#ifndef __bootstd_h
10#define __bootstd_h
11
49867e80 12#include <alist.h>
e64c2952 13#include <dm/ofnode_decl.h>
03de305e
TR
14#include <linux/list.h>
15#include <linux/types.h>
e64c2952 16
ef5e3891
SG
17struct udevice;
18
19/**
20 * struct bootstd_priv - priv data for the bootstd driver
21 *
22 * This is attached to the (only) bootstd device, so there is only one instance
23 * of this struct. It provides overall information about bootdevs and bootflows.
24 *
25 * @prefixes: NULL-terminated list of prefixes to use for bootflow filenames,
26 * e.g. "/", "/boot/"; NULL if none
27 * @bootdev_order: Order to use for bootdevs (or NULL if none), with each item
6a6638f0
SG
28 * being a bootdev label, e.g. "mmc2", "mmc1" (NULL terminated)
29 * @env_order: Order as specified by the boot_targets env var (or NULL if none),
30 * with each item being a bootdev label, e.g. "mmc2", "mmc1" (NULL
31 * terminated)
ef5e3891
SG
32 * @cur_bootdev: Currently selected bootdev (for commands)
33 * @cur_bootflow: Currently selected bootflow (for commands)
49867e80
SG
34 * @bootflows: (struct bootflow) Global list of all bootflows across all
35 * bootdevs
ef5e3891
SG
36 * @bootmeth_count: Number of bootmeth devices in @bootmeth_order
37 * @bootmeth_order: List of bootmeth devices to use, in order, NULL-terminated
4c7418f3 38 * @vbe_bootmeth: Currently selected VBE bootmeth, NULL if none
e64c2952 39 * @theme: Node containing the theme information
bd90b092
SG
40 * @hunters_used: Bitmask of used hunters, indexed by their position in the
41 * linker list. The bit is set if the hunter has been used already
ef5e3891
SG
42 */
43struct bootstd_priv {
44 const char **prefixes;
45 const char **bootdev_order;
6a6638f0 46 const char **env_order;
ef5e3891
SG
47 struct udevice *cur_bootdev;
48 struct bootflow *cur_bootflow;
49867e80 49 struct alist bootflows;
ef5e3891
SG
50 int bootmeth_count;
51 struct udevice **bootmeth_order;
4c7418f3 52 struct udevice *vbe_bootmeth;
e64c2952 53 ofnode theme;
bd90b092 54 uint hunters_used;
ef5e3891
SG
55};
56
57/**
58 * bootstd_get_bootdev_order() - Get the boot-order list
59 *
60 * This reads the boot order, e.g. {"mmc0", "mmc2", NULL}
61 *
62 * The list is alloced by the bootstd driver so should not be freed. That is the
63 * reason for all the const stuff in the function signature
64 *
6a6638f0
SG
65 * @dev: bootstd device
66 * @okp: returns true if OK, false if out of memory
67 * Return: list of string pointers, terminated by NULL; or NULL if no boot
68 * order. Note that this returns NULL in the case of an empty list
ef5e3891 69 */
6a6638f0
SG
70const char *const *const bootstd_get_bootdev_order(struct udevice *dev,
71 bool *okp);
ef5e3891
SG
72
73/**
74 * bootstd_get_prefixes() - Get the filename-prefixes list
75 *
2c120676 76 * This reads the prefixes, e.g. {"/", "/boot", NULL}
ef5e3891
SG
77 *
78 * The list is alloced by the bootstd driver so should not be freed. That is the
79 * reason for all the const stuff in the function signature
80 *
81 * Return: list of string points, terminated by NULL; or NULL if no boot order
82 */
83const char *const *const bootstd_get_prefixes(struct udevice *dev);
84
85/**
86 * bootstd_get_priv() - Get the (single) state for the bootstd system
87 *
88 * The state holds a global list of all bootflows that have been found.
89 *
90 * Return: 0 if OK, -ve if the uclass does not exist
91 */
92int bootstd_get_priv(struct bootstd_priv **stdp);
93
529f9267
SG
94/**
95 * bootstd_try_priv() - Try to get the (single) state for the bootstd system
96 *
97 * The state holds a global list of all bootflows that have been found. This
98 * function returns the state if available, but takes care not to create the
99 * device (or uclass) if it doesn't exist.
100 *
101 * This function is safe to use in the 'unbind' path. It will always return NULL
102 * unless the bootstd device is probed and ready, e.g. bootstd_get_priv() has
103 * previously been called.
104 *
105 * TODO([email protected]): Consider adding a bootstd pointer to global_data
106 *
107 * Return: pointer if the device exists, else NULL
108 */
109struct bootstd_priv *bootstd_try_priv(void);
110
ef5e3891
SG
111/**
112 * bootstd_clear_glob() - Clear the global list of bootflows
113 *
114 * This removes all bootflows globally and across all bootdevs.
115 */
116void bootstd_clear_glob(void);
117
1047b534
SG
118/**
119 * bootstd_prog_boot() - Run standard boot in a fully programmatic mode
120 *
121 * Attempts to boot without making any use of U-Boot commands
122 *
123 * Returns: -ve error value (does not return except on failure to boot)
124 */
125int bootstd_prog_boot(void);
126
47903aac 127/**
6a3eb84b 128 * bootstd_add_bootflow() - Add a bootflow to the global list
47903aac
SG
129 *
130 * All fields in @bflow must be set up. Note that @bflow->dev is used to add the
131 * bootflow to that device.
132 *
133 * The bootflow is also added to the global list of all bootflows
134 *
135 * @dev: Bootdev device to add to
136 * @bflow: Bootflow to add. Note that fields within bflow must be allocated
137 * since this function takes over ownership of these. This functions makes
138 * a copy of @bflow itself (without allocating its fields again), so the
139 * caller must dispose of the memory used by the @bflow pointer itself
49867e80 140 * Return: element number in the list, if OK, -ENOMEM if out of memory
47903aac
SG
141 */
142int bootstd_add_bootflow(struct bootflow *bflow);
143
92182257
SG
144/**
145 * bootstd_clear_bootflows_for_bootdev() - Clear bootflows from a bootdev
146 *
147 * Each bootdev maintains a list of discovered bootflows. This provides a
148 * way to clear it. These bootflows are removed from the global list too.
149 *
150 * @dev: bootdev device to update
151 */
152int bootstd_clear_bootflows_for_bootdev(struct udevice *dev);
153
ef5e3891 154#endif
This page took 0.146238 seconds and 4 git commands to generate.