blob: 56bff63362f2c89c56d02b8967b6f1b98fe833de [file] [log] [blame]
Simon Glass0a9f4262022-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 Glassa72641c2022-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 Glass9d0042e2022-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 Glassa72641c2022-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{
Simon Glass209ae762024-09-29 19:49:49 -060044 if (IS_ENABLED(CONFIG_XPL_BUILD))
Simon Glassa72641c2022-10-20 18:23:09 -060045 return VBE_PHASE_FIRMWARE;
46
47 return VBE_PHASE_OS;
48}
49
50/**
Simon Glass0a9f4262022-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