coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
bootmode.c
Go to the documentation of this file.
1
/* SPDX-License-Identifier: GPL-2.0-only */
2
3
#include <
assert.h
>
4
#include <
bootmode.h
>
5
#include <
bootstate.h
>
6
#include <vb2_api.h>
7
#include <
security/vboot/misc.h
>
8
#include <
security/vboot/vbnv.h
>
9
#include <
security/vboot/vboot_common.h
>
10
11
/*
12
* Functions which check vboot information should only be called after verstage
13
* has run. Otherwise, they will hit the assertion in vboot_get_context().
14
*/
15
16
int
vboot_check_recovery_request
(
void
)
17
{
18
return
vb2api_get_recovery_reason(
vboot_get_context
());
19
}
20
21
int
vboot_recovery_mode_enabled
(
void
)
22
{
23
return
vboot_get_context
()->flags & VB2_CONTEXT_RECOVERY_MODE;
24
}
25
26
int
vboot_developer_mode_enabled
(
void
)
27
{
28
return
vboot_get_context
()->flags & VB2_CONTEXT_DEVELOPER_MODE;
29
}
30
31
int
__weak
clear_recovery_mode_switch
(
void
)
32
{
33
return
0;
34
}
35
36
static
void
do_clear_recovery_mode_switch
(
void
*unused)
37
{
38
if
(
vboot_get_context
()->flags & VB2_CONTEXT_FORCE_RECOVERY_MODE)
39
clear_recovery_mode_switch
();
40
}
41
/*
42
* The recovery mode switch (typically backed by EC) is not cleared until
43
* BS_WRITE_TABLES for two reasons:
44
*
45
* (1) On some platforms, FSP initialization may cause a reboot. Push clearing
46
* the recovery mode switch until after FSP code runs, so that a manual recovery
47
* request (three-finger salute) will function correctly under this condition.
48
*
49
* (2) To give the implementation of clear_recovery_mode_switch a chance to
50
* add an event to elog. See the function in chromeec/switches.c.
51
*/
52
BOOT_STATE_INIT_ENTRY
(
BS_WRITE_TABLES
,
BS_ON_ENTRY
,
53
do_clear_recovery_mode_switch
,
NULL
);
54
55
int
__weak
get_recovery_mode_retrain_switch
(
void
)
56
{
57
return
0;
58
}
59
60
int
__weak
get_ec_is_trusted
(
void
)
61
{
62
/*
63
* If board doesn't override this, by default we always assume EC is in
64
* RW and untrusted. However, newer platforms are supposed to use cr50
65
* BOOT_MODE to report this and won't need to override this anymore.
66
*/
67
return
0;
68
}
69
70
#if CONFIG(VBOOT_NO_BOARD_SUPPORT)
71
/**
72
* TODO: Create flash protection interface which implements get_write_protect_state.
73
* get_recovery_mode_switch should be implemented as default function.
74
*/
75
int
__weak
get_write_protect_state
(
void
)
76
{
77
return
0;
78
}
79
80
int
__weak
get_recovery_mode_switch
(
void
)
81
{
82
return
0;
83
}
84
85
void
__weak
fill_lb_gpios
(
struct
lb_gpios
*gpios)
86
{
87
}
88
89
#endif
assert.h
bootmode.h
bootstate.h
BS_WRITE_TABLES
@ BS_WRITE_TABLES
Definition:
bootstate.h:87
BS_ON_ENTRY
@ BS_ON_ENTRY
Definition:
bootstate.h:95
get_write_protect_state
int get_write_protect_state(void)
Only used if CONFIG(CHROMEOS) is set.
Definition:
vboot.c:39
fill_lb_gpios
void fill_lb_gpios(struct lb_gpios *gpios)
Definition:
chromeos.c:9
get_recovery_mode_switch
int get_recovery_mode_switch(void)
HACK: Use Fn-Key as recovery mode switch.
Definition:
bootmode.c:11
misc.h
__weak
const struct smm_save_state_ops *legacy_ops __weak
Definition:
save_state.c:8
vboot_check_recovery_request
int vboot_check_recovery_request(void)
Definition:
bootmode.c:16
do_clear_recovery_mode_switch
static void do_clear_recovery_mode_switch(void *unused)
Definition:
bootmode.c:36
get_recovery_mode_retrain_switch
int __weak get_recovery_mode_retrain_switch(void)
Definition:
bootmode.c:55
vboot_recovery_mode_enabled
int vboot_recovery_mode_enabled(void)
Definition:
bootmode.c:21
get_ec_is_trusted
int __weak get_ec_is_trusted(void)
Definition:
bootmode.c:60
vboot_developer_mode_enabled
int vboot_developer_mode_enabled(void)
Definition:
bootmode.c:26
clear_recovery_mode_switch
int __weak clear_recovery_mode_switch(void)
Definition:
bootmode.c:31
BOOT_STATE_INIT_ENTRY
BOOT_STATE_INIT_ENTRY(BS_WRITE_TABLES, BS_ON_ENTRY, do_clear_recovery_mode_switch, NULL)
vboot_get_context
struct vb2_context * vboot_get_context(void)
Definition:
common.c:28
NULL
#define NULL
Definition:
stddef.h:19
lb_gpios
Definition:
coreboot_tables.h:302
vbnv.h
vboot_common.h
src
security
vboot
bootmode.c
Generated by
1.9.1