coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
vboot_common.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
4 #include <reset.h>
5 #include <security/vboot/misc.h>
7 #include <security/vboot/vbnv.h>
8 #include <vb2_api.h>
9 
10 #include "antirollback.h"
11 
12 void vboot_save_data(struct vb2_context *ctx)
13 {
14  if (ctx->flags & VB2_CONTEXT_SECDATA_FIRMWARE_CHANGED &&
15  (CONFIG(VBOOT_MOCK_SECDATA) || tlcl_lib_init() == VB2_SUCCESS)) {
16  printk(BIOS_INFO, "Saving secdata firmware\n");
18  ctx->flags &= ~VB2_CONTEXT_SECDATA_FIRMWARE_CHANGED;
19  }
20 
21  if (ctx->flags & VB2_CONTEXT_SECDATA_KERNEL_CHANGED &&
22  (CONFIG(VBOOT_MOCK_SECDATA) || tlcl_lib_init() == VB2_SUCCESS)) {
23  printk(BIOS_INFO, "Saving secdata kernel\n");
25  ctx->flags &= ~VB2_CONTEXT_SECDATA_KERNEL_CHANGED;
26  }
27 
28  if (ctx->flags & VB2_CONTEXT_NVDATA_CHANGED) {
29  printk(BIOS_INFO, "Saving nvdata\n");
30  save_vbnv(ctx->nvdata);
31  ctx->flags &= ~VB2_CONTEXT_NVDATA_CHANGED;
32  }
33 }
34 
35 /* Check if it is okay to enable USB Device Controller (UDC). */
37 {
38  /* Allow UDC in all vboot modes. */
39  if (!CONFIG(CHROMEOS) && CONFIG(VBOOT_ALWAYS_ALLOW_UDC))
40  return 1;
41 
42  /* Always disable if not in developer mode */
44  return 0;
45  /* Enable if GBB flag is set */
46  if (vboot_is_gbb_flag_set(VB2_GBB_FLAG_ENABLE_UDC))
47  return 1;
48  /* Enable if VBNV flag is set */
50  return 1;
51  /* Otherwise disable */
52  return 0;
53 }
54 
55 /* ============================ VBOOT REBOOT ============================== */
57 {
58 }
59 
60 void vboot_reboot(void)
61 {
62  if (CONFIG(CONSOLE_CBMEM_DUMP_TO_UART))
65  board_reset();
66 }
uint32_t antirollback_write_space_firmware(struct vb2_context *ctx)
Write may be called if the versions change.
Definition: secdata_mock.c:24
uint32_t antirollback_write_space_kernel(struct vb2_context *ctx)
Definition: secdata_mock.c:47
void cbmem_dump_console_to_uart(void)
#define printk(level,...)
Definition: stdlib.h:16
@ CONFIG
Definition: dsi_common.h:201
__noreturn void board_reset(void)
Definition: reset.c:8
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
static bool vboot_is_gbb_flag_set(enum vb2_gbb_flag flag)
Definition: misc.h:29
const struct smm_save_state_ops *legacy_ops __weak
Definition: save_state.c:8
int vboot_developer_mode_enabled(void)
Definition: bootmode.c:26
uint32_t tlcl_lib_init(void)
Call this first.
Definition: tss.c:145
int vbnv_udc_enable_flag(void)
Definition: vbnv.c:92
void save_vbnv(const uint8_t *vbnv_copy)
Definition: vbnv.c:78
void vboot_save_data(struct vb2_context *ctx)
Definition: vboot_common.c:12
void __weak vboot_platform_prepare_reboot(void)
Definition: vboot_common.c:56
int vboot_can_enable_udc(void)
Definition: vboot_common.c:36
void vboot_reboot(void)
Definition: vboot_common.c:60