blob: 5ede8181b982a0d9aaa1742d77058c5965364f4e [file] [log] [blame]
Simon Glass4c7418f2022-07-30 15:52:32 -06001/* 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/**
Simon Glass70b26e42022-10-20 18:23:09 -060014 * 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 */
23enum vbe_phase_t {
24 VBE_PHASE_FIRMWARE,
25 VBE_PHASE_OS,
26};
27
28/**
Simon Glassd8b7c342022-10-20 18:23:18 -060029 * struct vbe_handoff - information about VBE progress
30 *
31 * @phases: Indicates which phases used the VBE bootmeth (1 << PHASE_...)
32 */
33struct vbe_handoff {
34 u8 phases;
35};
36
37/**
Simon Glass70b26e42022-10-20 18:23:09 -060038 * vbe_phase() - get current VBE phase
39 *
40 * Returns: Current VBE phase
41 */
42static inline enum vbe_phase_t vbe_phase(void)
43{
44 if (IS_ENABLED(CONFIG_SPL_BUILD))
45 return VBE_PHASE_FIRMWARE;
46
47 return VBE_PHASE_OS;
48}
49
50/**
Simon Glass4c7418f2022-07-30 15:52:32 -060051 * vbe_list() - List the VBE bootmeths
52 *
53 * This shows a list of the VBE bootmeth devices
54 *
55 * @return 0 (always)
56 */
57int vbe_list(void);
58
59/**
60 * vbe_find_by_any() - Find a VBE bootmeth by name or sequence
61 *
62 * @name: name (e.g. "vbe-simple"), or sequence ("2") to find
63 * @devp: returns the device found, on success
64 * Return: 0 if OK, -ve on error
65 */
66int vbe_find_by_any(const char *name, struct udevice **devp);
67
68/**
69 * vbe_find_first_device() - Find the first VBE bootmeth
70 *
71 * @devp: Returns first available VBE bootmeth, or NULL if none
72 * Returns: 0 (always)
73 */
74int vbe_find_first_device(struct udevice **devp);
75
76/**
77 * vbe_find_next_device() - Find the next available VBE bootmeth
78 *
79 * @devp: Previous device to start from. Returns next available VBE bootmeth,
80 * or NULL if none
81 * Returns: 0 (always)
82 */
83int vbe_find_next_device(struct udevice **devp);
84
85#endif