vbe: Support selecting operations by SPL phase
[platform/kernel/u-boot.git] / include / vbe.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Verified Boot for Embedded (VBE) support
4  * See doc/develop/vbe.rst
5  *
6  * Copyright 2022 Google LLC
7  * Written by Simon Glass <sjg@chromium.org>
8  */
9
10 #ifndef __VBE_H
11 #define __VBE_H
12
13 /**
14  * enum vbe_phase_t - current phase of VBE
15  *
16  * VBE operates in two distinct phases. In VPL it has to choose which firmware
17  * to run (SPL, U-Boot, OP-TEE, etc.). It then carries on running until it gets
18  * to U-Boot, where it decides which OS to run
19  *
20  * @VBE_PHASE_FIRMWARE: Selecting the firmware to run
21  * @VBE_PHASE_OS: Selecting the Operating System to run
22  */
23 enum vbe_phase_t {
24         VBE_PHASE_FIRMWARE,
25         VBE_PHASE_OS,
26 };
27
28 /**
29  * vbe_phase() - get current VBE phase
30  *
31  * Returns: Current VBE phase
32  */
33 static inline enum vbe_phase_t vbe_phase(void)
34 {
35         if (IS_ENABLED(CONFIG_SPL_BUILD))
36                 return VBE_PHASE_FIRMWARE;
37
38         return VBE_PHASE_OS;
39 }
40
41 /**
42  * vbe_list() - List the VBE bootmeths
43  *
44  * This shows a list of the VBE bootmeth devices
45  *
46  * @return 0 (always)
47  */
48 int vbe_list(void);
49
50 /**
51  * vbe_find_by_any() - Find a VBE bootmeth by name or sequence
52  *
53  * @name: name (e.g. "vbe-simple"), or sequence ("2") to find
54  * @devp: returns the device found, on success
55  * Return: 0 if OK, -ve on error
56  */
57 int vbe_find_by_any(const char *name, struct udevice **devp);
58
59 /**
60  * vbe_find_first_device() - Find the first VBE bootmeth
61  *
62  * @devp: Returns first available VBE bootmeth, or NULL if none
63  * Returns: 0 (always)
64  */
65 int vbe_find_first_device(struct udevice **devp);
66
67 /**
68  * vbe_find_next_device() - Find the next available VBE bootmeth
69  *
70  * @devp: Previous device to start from. Returns next available VBE bootmeth,
71  * or NULL if none
72  * Returns: 0 (always)
73  */
74 int vbe_find_next_device(struct udevice **devp);
75
76 #endif