]>
Commit | Line | Data |
---|---|---|
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 <sjg@chromium.org> | |
7 | */ | |
8 | ||
9 | #ifndef __bootstd_h | |
10 | #define __bootstd_h | |
11 | ||
e64c2952 SG |
12 | #include <dm/ofnode_decl.h> |
13 | ||
ef5e3891 SG |
14 | struct 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 | |
6a6638f0 SG |
25 | * 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) | |
ef5e3891 SG |
29 | * @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 | |
4c7418f3 | 34 | * @vbe_bootmeth: Currently selected VBE bootmeth, NULL if none |
e64c2952 | 35 | * @theme: Node containing the theme information |
bd90b092 SG |
36 | * @hunters_used: Bitmask of used hunters, indexed by their position in the |
37 | * linker list. The bit is set if the hunter has been used already | |
ef5e3891 SG |
38 | */ |
39 | struct bootstd_priv { | |
40 | const char **prefixes; | |
41 | const char **bootdev_order; | |
6a6638f0 | 42 | const char **env_order; |
ef5e3891 SG |
43 | struct udevice *cur_bootdev; |
44 | struct bootflow *cur_bootflow; | |
45 | struct list_head glob_head; | |
46 | int bootmeth_count; | |
47 | struct udevice **bootmeth_order; | |
4c7418f3 | 48 | struct udevice *vbe_bootmeth; |
e64c2952 | 49 | ofnode theme; |
bd90b092 | 50 | uint hunters_used; |
ef5e3891 SG |
51 | }; |
52 | ||
53 | /** | |
54 | * bootstd_get_bootdev_order() - Get the boot-order list | |
55 | * | |
56 | * This reads the boot order, e.g. {"mmc0", "mmc2", NULL} | |
57 | * | |
58 | * The list is alloced by the bootstd driver so should not be freed. That is the | |
59 | * reason for all the const stuff in the function signature | |
60 | * | |
6a6638f0 SG |
61 | * @dev: bootstd device |
62 | * @okp: returns true if OK, false if out of memory | |
63 | * Return: list of string pointers, terminated by NULL; or NULL if no boot | |
64 | * order. Note that this returns NULL in the case of an empty list | |
ef5e3891 | 65 | */ |
6a6638f0 SG |
66 | const char *const *const bootstd_get_bootdev_order(struct udevice *dev, |
67 | bool *okp); | |
ef5e3891 SG |
68 | |
69 | /** | |
70 | * bootstd_get_prefixes() - Get the filename-prefixes list | |
71 | * | |
2c120676 | 72 | * This reads the prefixes, e.g. {"/", "/boot", NULL} |
ef5e3891 SG |
73 | * |
74 | * The list is alloced by the bootstd driver so should not be freed. That is the | |
75 | * reason for all the const stuff in the function signature | |
76 | * | |
77 | * Return: list of string points, terminated by NULL; or NULL if no boot order | |
78 | */ | |
79 | const char *const *const bootstd_get_prefixes(struct udevice *dev); | |
80 | ||
81 | /** | |
82 | * bootstd_get_priv() - Get the (single) state for the bootstd system | |
83 | * | |
84 | * The state holds a global list of all bootflows that have been found. | |
85 | * | |
86 | * Return: 0 if OK, -ve if the uclass does not exist | |
87 | */ | |
88 | int bootstd_get_priv(struct bootstd_priv **stdp); | |
89 | ||
90 | /** | |
91 | * bootstd_clear_glob() - Clear the global list of bootflows | |
92 | * | |
93 | * This removes all bootflows globally and across all bootdevs. | |
94 | */ | |
95 | void bootstd_clear_glob(void); | |
96 | ||
1047b534 SG |
97 | /** |
98 | * bootstd_prog_boot() - Run standard boot in a fully programmatic mode | |
99 | * | |
100 | * Attempts to boot without making any use of U-Boot commands | |
101 | * | |
102 | * Returns: -ve error value (does not return except on failure to boot) | |
103 | */ | |
104 | int bootstd_prog_boot(void); | |
105 | ||
ef5e3891 | 106 | #endif |