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>
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 
17 {
18  return vb2api_get_recovery_reason(vboot_get_context());
19 }
20 
22 {
23  return vboot_get_context()->flags & VB2_CONTEXT_RECOVERY_MODE;
24 }
25 
27 {
28  return vboot_get_context()->flags & VB2_CONTEXT_DEVELOPER_MODE;
29 }
30 
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)
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  */
54 
56 {
57  return 0;
58 }
59 
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  */
76 {
77  return 0;
78 }
79 
81 {
82  return 0;
83 }
84 
85 void __weak fill_lb_gpios(struct lb_gpios *gpios)
86 {
87 }
88 
89 #endif
@ BS_WRITE_TABLES
Definition: bootstate.h:87
@ BS_ON_ENTRY
Definition: bootstate.h:95
int get_write_protect_state(void)
Only used if CONFIG(CHROMEOS) is set.
Definition: vboot.c:39
void fill_lb_gpios(struct lb_gpios *gpios)
Definition: chromeos.c:9
int get_recovery_mode_switch(void)
HACK: Use Fn-Key as recovery mode switch.
Definition: bootmode.c:11
const struct smm_save_state_ops *legacy_ops __weak
Definition: save_state.c:8
int vboot_check_recovery_request(void)
Definition: bootmode.c:16
static void do_clear_recovery_mode_switch(void *unused)
Definition: bootmode.c:36
int __weak get_recovery_mode_retrain_switch(void)
Definition: bootmode.c:55
int vboot_recovery_mode_enabled(void)
Definition: bootmode.c:21
int __weak get_ec_is_trusted(void)
Definition: bootmode.c:60
int vboot_developer_mode_enabled(void)
Definition: bootmode.c:26
int __weak clear_recovery_mode_switch(void)
Definition: bootmode.c:31
BOOT_STATE_INIT_ENTRY(BS_WRITE_TABLES, BS_ON_ENTRY, do_clear_recovery_mode_switch, NULL)
struct vb2_context * vboot_get_context(void)
Definition: common.c:28
#define NULL
Definition: stddef.h:19