~funderscore blog cgit wiki get in touch
aboutsummaryrefslogtreecommitdiff
blob: 5ede8181b982a0d9aaa1742d77058c5965364f4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * Verified Boot for Embedded (VBE) support
 * See doc/develop/vbe.rst
 *
 * Copyright 2022 Google LLC
 * Written by Simon Glass <sjg@chromium.org>
 */

#ifndef __VBE_H
#define __VBE_H

/**
 * enum vbe_phase_t - current phase of VBE
 *
 * VBE operates in two distinct phases. In VPL it has to choose which firmware
 * to run (SPL, U-Boot, OP-TEE, etc.). It then carries on running until it gets
 * to U-Boot, where it decides which OS to run
 *
 * @VBE_PHASE_FIRMWARE: Selecting the firmware to run
 * @VBE_PHASE_OS: Selecting the Operating System to run
 */
enum vbe_phase_t {
	VBE_PHASE_FIRMWARE,
	VBE_PHASE_OS,
};

/**
 * struct vbe_handoff - information about VBE progress
 *
 * @phases: Indicates which phases used the VBE bootmeth (1 << PHASE_...)
 */
struct vbe_handoff {
	u8 phases;
};

/**
 * vbe_phase() - get current VBE phase
 *
 * Returns: Current VBE phase
 */
static inline enum vbe_phase_t vbe_phase(void)
{
	if (IS_ENABLED(CONFIG_SPL_BUILD))
		return VBE_PHASE_FIRMWARE;

	return VBE_PHASE_OS;
}

/**
 * vbe_list() - List the VBE bootmeths
 *
 * This shows a list of the VBE bootmeth devices
 *
 * @return 0 (always)
 */
int vbe_list(void);

/**
 * vbe_find_by_any() - Find a VBE bootmeth by name or sequence
 *
 * @name: name (e.g. "vbe-simple"), or sequence ("2") to find
 * @devp: returns the device found, on success
 * Return: 0 if OK, -ve on error
 */
int vbe_find_by_any(const char *name, struct udevice **devp);

/**
 * vbe_find_first_device() - Find the first VBE bootmeth
 *
 * @devp: Returns first available VBE bootmeth, or NULL if none
 * Returns: 0 (always)
 */
int vbe_find_first_device(struct udevice **devp);

/**
 * vbe_find_next_device() - Find the next available VBE bootmeth
 *
 * @devp: Previous device to start from. Returns next available VBE bootmeth,
 * or NULL if none
 * Returns: 0 (always)
 */
int vbe_find_next_device(struct udevice **devp);

#endif