Simon Glass | 08ad13e | 2022-04-24 23:31:06 -0600 | [diff] [blame] | 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 | |
Simon Glass | d92bcc4 | 2023-01-06 08:52:42 -0600 | [diff] [blame^] | 12 | #include <dm/ofnode_decl.h> |
| 13 | |
Simon Glass | 08ad13e | 2022-04-24 23:31:06 -0600 | [diff] [blame] | 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 |
| 25 | * being a bootdev label, e.g. "mmc2", "mmc1"; |
| 26 | * @cur_bootdev: Currently selected bootdev (for commands) |
| 27 | * @cur_bootflow: Currently selected bootflow (for commands) |
| 28 | * @glob_head: Head for the global list of all bootflows across all bootdevs |
| 29 | * @bootmeth_count: Number of bootmeth devices in @bootmeth_order |
| 30 | * @bootmeth_order: List of bootmeth devices to use, in order, NULL-terminated |
Simon Glass | 0a9f426 | 2022-07-30 15:52:32 -0600 | [diff] [blame] | 31 | * @vbe_bootmeth: Currently selected VBE bootmeth, NULL if none |
Simon Glass | d92bcc4 | 2023-01-06 08:52:42 -0600 | [diff] [blame^] | 32 | * @theme: Node containing the theme information |
Simon Glass | 08ad13e | 2022-04-24 23:31:06 -0600 | [diff] [blame] | 33 | */ |
| 34 | struct bootstd_priv { |
| 35 | const char **prefixes; |
| 36 | const char **bootdev_order; |
| 37 | struct udevice *cur_bootdev; |
| 38 | struct bootflow *cur_bootflow; |
| 39 | struct list_head glob_head; |
| 40 | int bootmeth_count; |
| 41 | struct udevice **bootmeth_order; |
Simon Glass | 0a9f426 | 2022-07-30 15:52:32 -0600 | [diff] [blame] | 42 | struct udevice *vbe_bootmeth; |
Simon Glass | d92bcc4 | 2023-01-06 08:52:42 -0600 | [diff] [blame^] | 43 | ofnode theme; |
Simon Glass | 08ad13e | 2022-04-24 23:31:06 -0600 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | /** |
| 47 | * bootstd_get_bootdev_order() - Get the boot-order list |
| 48 | * |
| 49 | * This reads the boot order, e.g. {"mmc0", "mmc2", NULL} |
| 50 | * |
| 51 | * The list is alloced by the bootstd driver so should not be freed. That is the |
| 52 | * reason for all the const stuff in the function signature |
| 53 | * |
| 54 | * Return: list of string points, terminated by NULL; or NULL if no boot order |
| 55 | */ |
| 56 | const char *const *const bootstd_get_bootdev_order(struct udevice *dev); |
| 57 | |
| 58 | /** |
| 59 | * bootstd_get_prefixes() - Get the filename-prefixes list |
| 60 | * |
| 61 | * This reads the prefixes, e.g. {"/", "/bpot", NULL} |
| 62 | * |
| 63 | * The list is alloced by the bootstd driver so should not be freed. That is the |
| 64 | * reason for all the const stuff in the function signature |
| 65 | * |
| 66 | * Return: list of string points, terminated by NULL; or NULL if no boot order |
| 67 | */ |
| 68 | const char *const *const bootstd_get_prefixes(struct udevice *dev); |
| 69 | |
| 70 | /** |
| 71 | * bootstd_get_priv() - Get the (single) state for the bootstd system |
| 72 | * |
| 73 | * The state holds a global list of all bootflows that have been found. |
| 74 | * |
| 75 | * Return: 0 if OK, -ve if the uclass does not exist |
| 76 | */ |
| 77 | int bootstd_get_priv(struct bootstd_priv **stdp); |
| 78 | |
| 79 | /** |
| 80 | * bootstd_clear_glob() - Clear the global list of bootflows |
| 81 | * |
| 82 | * This removes all bootflows globally and across all bootdevs. |
| 83 | */ |
| 84 | void bootstd_clear_glob(void); |
| 85 | |
| 86 | #endif |