"Das U-Boot" Source Tree
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#include <linux/types.h>
14
15/**
16 * enum vbe_phase_t - current phase of VBE
17 *
18 * VBE operates in two distinct phases. In VPL it has to choose which firmware
19 * to run (SPL, U-Boot, OP-TEE, etc.). It then carries on running until it gets
20 * to U-Boot, where it decides which OS to run
21 *
22 * @VBE_PHASE_FIRMWARE: Selecting the firmware to run
23 * @VBE_PHASE_OS: Selecting the Operating System to run
24 */
25enum vbe_phase_t {
26 VBE_PHASE_FIRMWARE,
27 VBE_PHASE_OS,
28};
29
30/**
31 * enum vbe_pick_t - indicates which firmware is picked
32 *
33 * @VBEFT_A: Firmware A
34 * @VBEFT_B: Firmware B
35 * @VBEFT_RECOVERY: Recovery firmware
36 */
37enum vbe_pick_t {
38 VBEP_A,
39 VBEP_B,
40 VBEP_RECOVERY,
41};
42
43/**
44 * struct vbe_handoff - information about VBE progress
45 *
46 * @offset: Offset of the FIT to use for SPL onwards
47 * @size: Size of the area containing the FIT
48 * @phases: Indicates which phases used the VBE bootmeth (1 << PHASE_...)
49 * @pick: Indicates which firmware pick was used (enum vbe_pick_t)
50 */
51struct vbe_handoff {
52 ulong offset;
53 ulong size;
54 u8 phases;
55 u8 pick;
56};
57
58/**
59 * vbe_phase() - get current VBE phase
60 *
61 * Returns: Current VBE phase
62 */
63static inline enum vbe_phase_t vbe_phase(void)
64{
65 if (IS_ENABLED(CONFIG_XPL_BUILD))
66 return VBE_PHASE_FIRMWARE;
67
68 return VBE_PHASE_OS;
69}
70
71/**
72 * vbe_list() - List the VBE bootmeths
73 *
74 * This shows a list of the VBE bootmeth devices
75 *
76 * @return 0 (always)
77 */
78int vbe_list(void);
79
80/**
81 * vbe_find_by_any() - Find a VBE bootmeth by name or sequence
82 *
83 * @name: name (e.g. "vbe-simple"), or sequence ("2") to find
84 * @devp: returns the device found, on success
85 * Return: 0 if OK, -ve on error
86 */
87int vbe_find_by_any(const char *name, struct udevice **devp);
88
89/**
90 * vbe_find_first_device() - Find the first VBE bootmeth
91 *
92 * @devp: Returns first available VBE bootmeth, or NULL if none
93 * Returns: 0 (always)
94 */
95int vbe_find_first_device(struct udevice **devp);
96
97/**
98 * vbe_find_next_device() - Find the next available VBE bootmeth
99 *
100 * @devp: Previous device to start from. Returns next available VBE bootmeth,
101 * or NULL if none
102 * Returns: 0 (always)
103 */
104int vbe_find_next_device(struct udevice **devp);
105
106#endif