summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2017-12-14 15:43:17 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-01-05 21:14:11 -0800
commit5142132f44bbee683c830fdb837bbedb00bad8ba (patch)
tree699df9f59656ff30f12bfacc4331d69afb9af1e1
parent4e0939b377f65048dfc1ec8ceda6fd7c444fc8b8 (diff)
downloadvboot-5142132f44bbee683c830fdb837bbedb00bad8ba.tar.gz
firmware: use sd->gbb_flags
Vboot1 code directly referenced the GBB from cparams even though now it has access to the GBB flags via the vb2 context. Refactor all existing code to use the vb2 context, since that takes us one step closer to getting rid of the old vboot1 cparams. No change in functionality. BUG=chromium:611535 BRANCH=none TEST=make -j runtests; build bob firmware and boot it Change-Id: Ic4a5bf215b723a2eacbf0a4cf0eba8b1338155a2 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/847310 Reviewed-by: Shelley Chen <shchen@chromium.org>
-rw-r--r--firmware/2lib/include/2struct.h3
-rw-r--r--firmware/lib/ec_sync.c15
-rw-r--r--firmware/lib/vboot_api_kernel.c9
-rw-r--r--firmware/lib/vboot_display.c18
-rw-r--r--firmware/lib/vboot_ui.c29
-rw-r--r--firmware/lib/vboot_ui_menu.c24
-rw-r--r--tests/ec_sync_tests.c8
-rw-r--r--tests/vboot_api_devmode_tests.c5
-rw-r--r--tests/vboot_api_kernel2_tests.c16
-rw-r--r--tests/vboot_detach_menu_tests.c14
10 files changed, 81 insertions, 60 deletions
diff --git a/firmware/2lib/include/2struct.h b/firmware/2lib/include/2struct.h
index 0d1c6ec3..9c75ba44 100644
--- a/firmware/2lib/include/2struct.h
+++ b/firmware/2lib/include/2struct.h
@@ -287,6 +287,9 @@ enum vb2_gbb_flag {
/* Enable serial */
VB2_GBB_FLAG_ENABLE_SERIAL = (1 << 14),
+
+ /* Disable FWMP */
+ VB2_GBB_FLAG_DISABLE_FWMP = (1 << 15),
};
struct vb2_gbb_header {
diff --git a/firmware/lib/ec_sync.c b/firmware/lib/ec_sync.c
index 35fae2de..77b5741e 100644
--- a/firmware/lib/ec_sync.c
+++ b/firmware/lib/ec_sync.c
@@ -348,12 +348,12 @@ VbError_t ec_sync_phase1(struct vb2_context *ctx, VbCommonParams *cparams)
/* Reasons not to do sync at all */
if (!(shared->flags & VBSD_EC_SOFTWARE_SYNC))
return VBERROR_SUCCESS;
- if (cparams->gbb->flags & GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC)
+ if (sd->gbb_flags & VB2_GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC)
return VBERROR_SUCCESS;
#ifdef PD_SYNC
- const int do_pd_sync = !(cparams->gbb->flags &
- GBB_FLAG_DISABLE_PD_SOFTWARE_SYNC);
+ const int do_pd_sync = !(sd->gbb_flags &
+ VB2_GBB_FLAG_DISABLE_PD_SOFTWARE_SYNC);
#else
const int do_pd_sync = 0;
#endif
@@ -425,7 +425,7 @@ static int ec_sync_allowed(struct vb2_context *ctx, VbCommonParams *cparams)
/* Reasons not to do sync at all */
if (!(shared->flags & VBSD_EC_SOFTWARE_SYNC))
return 0;
- if (cparams->gbb->flags & GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC)
+ if (sd->gbb_flags & VB2_GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC)
return 0;
if (sd->recovery_reason)
return 0;
@@ -436,9 +436,11 @@ VbError_t ec_sync_check_aux_fw(struct vb2_context *ctx,
VbCommonParams *cparams,
VbAuxFwUpdateSeverity_t *severity)
{
+ struct vb2_shared_data *sd = vb2_get_sd(ctx);
+
/* If we're not updating the EC, skip aux fw syncs as well */
if (!ec_sync_allowed(ctx, cparams) ||
- (cparams->gbb->flags & GBB_FLAG_DISABLE_PD_SOFTWARE_SYNC)) {
+ (sd->gbb_flags & VB2_GBB_FLAG_DISABLE_PD_SOFTWARE_SYNC)) {
*severity = VB_AUX_FW_NO_UPDATE;
return VBERROR_SUCCESS;
}
@@ -457,7 +459,8 @@ VbError_t ec_sync_phase2(struct vb2_context *ctx, VbCommonParams *cparams)
#ifdef PD_SYNC
/* Handle updates and jumps for PD */
- if (!(cparams->gbb->flags & GBB_FLAG_DISABLE_PD_SOFTWARE_SYNC)) {
+ struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ if (!(sd->gbb_flags & VB2_GBB_FLAG_DISABLE_PD_SOFTWARE_SYNC)) {
retval = sync_one_ec(ctx, 1, cparams);
if (retval != VBERROR_SUCCESS)
return retval;
diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c
index 26d32d55..fd0556b5 100644
--- a/firmware/lib/vboot_api_kernel.c
+++ b/firmware/lib/vboot_api_kernel.c
@@ -329,6 +329,7 @@ static VbError_t vb2_kernel_setup(VbCommonParams *cparams,
uint32_t retval = VbGbbReadHeader_static(cparams, cparams->gbb);
if (retval)
return retval;
+ sd->gbb_flags = cparams->gbb->flags;
/* Read kernel version from the TPM. Ignore errors in recovery mode. */
if (RollbackKernelRead(&shared->kernel_version_tpm)) {
@@ -343,7 +344,7 @@ static VbError_t vb2_kernel_setup(VbCommonParams *cparams,
shared->kernel_version_tpm_start = shared->kernel_version_tpm;
/* Read FWMP. Ignore errors in recovery mode. */
- if (cparams->gbb->flags & GBB_FLAG_DISABLE_FWMP) {
+ if (sd->gbb_flags & VB2_GBB_FLAG_DISABLE_FWMP) {
memset(&fwmp, 0, sizeof(fwmp));
} else if (RollbackFwmpRead(&fwmp)) {
VB2_DEBUG("Unable to get FWMP from TPM\n");
@@ -480,6 +481,8 @@ VbError_t VbVerifyMemoryBootImage(VbCommonParams *cparams,
if (retval)
goto fail;
+ struct vb2_shared_data *sd = vb2_get_sd(&ctx);
+
if ((boot_image == NULL) || (image_size == 0)) {
retval = VBERROR_INVALID_PARAMETER;
goto fail;
@@ -500,8 +503,8 @@ VbError_t VbVerifyMemoryBootImage(VbCommonParams *cparams,
vb2_nv_get(&ctx, VB2_NV_DEV_BOOT_FASTBOOT_FULL_CAP);
if (0 == allow_fastboot_full_cap) {
- allow_fastboot_full_cap = !!(cparams->gbb->flags &
- GBB_FLAG_FORCE_DEV_BOOT_FASTBOOT_FULL_CAP);
+ allow_fastboot_full_cap = !!(sd->gbb_flags &
+ VB2_GBB_FLAG_FORCE_DEV_BOOT_FASTBOOT_FULL_CAP);
}
if (dev_switch && allow_fastboot_full_cap) {
diff --git a/firmware/lib/vboot_display.c b/firmware/lib/vboot_display.c
index 7bf341e1..ac6d7131 100644
--- a/firmware/lib/vboot_display.c
+++ b/firmware/lib/vboot_display.c
@@ -9,6 +9,7 @@
#include "2sysincludes.h"
#include "2common.h"
+#include "2misc.h"
#include "2nvstorage.h"
#include "2sha.h"
#include "bmpblk_font.h"
@@ -600,7 +601,7 @@ VbError_t VbDisplayDebugInfo(struct vb2_context *ctx, VbCommonParams *cparams)
{
VbSharedDataHeader *shared =
(VbSharedDataHeader *)cparams->shared_data_blob;
- GoogleBinaryBlockHeader *gbb = cparams->gbb;
+ struct vb2_shared_data *sd = vb2_get_sd(ctx);
char buf[DEBUG_INFO_SIZE] = "";
char sha1sum[VB2_SHA1_DIGEST_SIZE * 2 + 1];
char hwid[256];
@@ -679,7 +680,8 @@ VbError_t VbDisplayDebugInfo(struct vb2_context *ctx, VbCommonParams *cparams)
used += Uint64ToString(buf + used, DEBUG_INFO_SIZE - used, i, 10, 0);
/* Add TPM versions */
- used += StrnAppend(buf + used, "\nTPM: fwver=0x", DEBUG_INFO_SIZE - used);
+ used += StrnAppend(buf + used,
+ "\nTPM: fwver=0x", DEBUG_INFO_SIZE - used);
used += Uint64ToString(buf + used, DEBUG_INFO_SIZE - used,
shared->fw_version_tpm, 16, 8);
used += StrnAppend(buf + used, " kernver=0x", DEBUG_INFO_SIZE - used);
@@ -687,14 +689,10 @@ VbError_t VbDisplayDebugInfo(struct vb2_context *ctx, VbCommonParams *cparams)
shared->kernel_version_tpm, 16, 8);
/* Add GBB flags */
- used += StrnAppend(buf + used, "\ngbb.flags: 0x", DEBUG_INFO_SIZE - used);
- if (gbb->major_version == GBB_MAJOR_VER && gbb->minor_version >= 1) {
- used += Uint64ToString(buf + used, DEBUG_INFO_SIZE - used,
- gbb->flags, 16, 8);
- } else {
- used += StrnAppend(buf + used,
- "0 (default)", DEBUG_INFO_SIZE - used);
- }
+ used += StrnAppend(buf + used,
+ "\ngbb.flags: 0x", DEBUG_INFO_SIZE - used);
+ used += Uint64ToString(buf + used, DEBUG_INFO_SIZE - used,
+ sd->gbb_flags, 16, 8);
/* Add sha1sum for Root & Recovery keys */
ret = VbGbbReadRootKey(cparams, &key);
diff --git a/firmware/lib/vboot_ui.c b/firmware/lib/vboot_ui.c
index 4d913f0e..50c27e76 100644
--- a/firmware/lib/vboot_ui.c
+++ b/firmware/lib/vboot_ui.c
@@ -38,15 +38,16 @@ static void VbAllowUsbBoot(struct vb2_context *ctx)
*
* Returns true if a shutdown is required and false if no shutdown is required.
*/
-static int VbWantShutdown(uint32_t gbb_flags, uint32_t key)
+static int VbWantShutdown(struct vb2_context *ctx, uint32_t key)
{
+ struct vb2_shared_data *sd = vb2_get_sd(ctx);
uint32_t shutdown_request = VbExIsShutdownRequested();
if (key == VB_BUTTON_POWER_SHORT_PRESS)
shutdown_request |= VB_SHUTDOWN_REQUEST_POWER_BUTTON;
/* If desired, ignore shutdown request due to lid closure. */
- if (gbb_flags & GBB_FLAG_DISABLE_LID_SHUTDOWN)
+ if (sd->gbb_flags & GBB_FLAG_DISABLE_LID_SHUTDOWN)
shutdown_request &= ~VB_SHUTDOWN_REQUEST_LID_CLOSED;
return !!shutdown_request;
@@ -105,7 +106,7 @@ int VbUserConfirms(struct vb2_context *ctx, VbCommonParams *cparams,
/* Await further instructions */
while (1) {
key = VbExKeyboardReadWithFlags(&key_flags);
- if (VbWantShutdown(cparams->gbb->flags, key))
+ if (VbWantShutdown(ctx, key))
return -1;
switch (key) {
case '\r':
@@ -161,9 +162,9 @@ static const char dev_disable_msg[] =
VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
{
- GoogleBinaryBlockHeader *gbb = cparams->gbb;
VbSharedDataHeader *shared =
(VbSharedDataHeader *)cparams->shared_data_blob;
+ struct vb2_shared_data *sd = vb2_get_sd(ctx);
uint32_t disable_dev_boot = 0;
uint32_t use_usb = 0;
@@ -187,11 +188,11 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
use_legacy = 1;
/* Handle GBB flag override */
- if (gbb->flags & GBB_FLAG_FORCE_DEV_BOOT_USB)
+ if (sd->gbb_flags & VB2_GBB_FLAG_FORCE_DEV_BOOT_USB)
allow_usb = 1;
- if (gbb->flags & GBB_FLAG_FORCE_DEV_BOOT_LEGACY)
+ if (sd->gbb_flags & VB2_GBB_FLAG_FORCE_DEV_BOOT_LEGACY)
allow_legacy = 1;
- if (gbb->flags & GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY) {
+ if (sd->gbb_flags & VB2_GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY) {
use_legacy = 1;
use_usb = 0;
}
@@ -203,7 +204,7 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
if (fwmp_flags & FWMP_DEV_ENABLE_LEGACY)
allow_legacy = 1;
if (fwmp_flags & FWMP_DEV_DISABLE_BOOT) {
- if (gbb->flags & GBB_FLAG_FORCE_DEV_SWITCH_ON) {
+ if (sd->gbb_flags & VB2_GBB_FLAG_FORCE_DEV_SWITCH_ON) {
VB2_DEBUG("FWMP_DEV_DISABLE_BOOT rejected by "
"FORCE_DEV_SWITCH_ON\n");
} else {
@@ -245,7 +246,7 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
/* We'll loop until we finish the delay or are interrupted */
do {
uint32_t key = VbExKeyboardRead();
- if (VbWantShutdown(gbb->flags, key)) {
+ if (VbWantShutdown(ctx, key)) {
VB2_DEBUG("VbBootDeveloper() - shutdown requested!\n");
VbAudioClose(audio);
return VBERROR_SHUTDOWN_REQUESTED;
@@ -257,7 +258,8 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
break;
case '\r':
/* Only disable virtual dev switch if allowed by GBB */
- if (!(gbb->flags & GBB_FLAG_ENTER_TRIGGERS_TONORM))
+ if (!(sd->gbb_flags &
+ VB2_GBB_FLAG_ENTER_TRIGGERS_TONORM))
break;
case ' ':
/* See if we should disable virtual dev-mode switch. */
@@ -266,7 +268,8 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
shared->flags & VBSD_BOOT_DEV_SWITCH_ON) {
/* Stop the countdown while we go ask... */
VbAudioClose(audio);
- if (gbb->flags & GBB_FLAG_FORCE_DEV_SWITCH_ON) {
+ if (sd->gbb_flags &
+ GBB_FLAG_FORCE_DEV_SWITCH_ON) {
/*
* TONORM won't work (only for
* non-shipping devices).
@@ -446,7 +449,7 @@ static VbError_t recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
while (1) {
key = VbExKeyboardRead();
VbCheckDisplayKey(ctx, cparams, key);
- if (VbWantShutdown(cparams->gbb->flags, key))
+ if (VbWantShutdown(ctx, key))
return VBERROR_SHUTDOWN_REQUESTED;
VbExSleepMs(REC_KEY_DELAY);
}
@@ -543,7 +546,7 @@ static VbError_t recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
} else {
VbCheckDisplayKey(ctx, cparams, key);
}
- if (VbWantShutdown(cparams->gbb->flags, key))
+ if (VbWantShutdown(ctx, key))
return VBERROR_SHUTDOWN_REQUESTED;
VbExSleepMs(REC_KEY_DELAY);
}
diff --git a/firmware/lib/vboot_ui_menu.c b/firmware/lib/vboot_ui_menu.c
index fd47b551..ce0496d6 100644
--- a/firmware/lib/vboot_ui_menu.c
+++ b/firmware/lib/vboot_ui_menu.c
@@ -36,12 +36,13 @@ static void VbAllowUsbBootMenu(struct vb2_context *ctx)
*
* Returns true if a shutdown is required and false if no shutdown is required.
*/
-static int VbWantShutdownMenu(uint32_t gbb_flags)
+static int VbWantShutdownMenu(struct vb2_context *ctx)
{
+ struct vb2_shared_data *sd = vb2_get_sd(ctx);
uint32_t shutdown_request = VbExIsShutdownRequested();
/* If desired, ignore shutdown request due to lid closure. */
- if (gbb_flags & GBB_FLAG_DISABLE_LID_SHUTDOWN)
+ if (sd->gbb_flags & VB2_GBB_FLAG_DISABLE_LID_SHUTDOWN)
shutdown_request &= ~VB_SHUTDOWN_REQUEST_LID_CLOSED;
/*
@@ -589,9 +590,9 @@ void vb2_update_selection(VbCommonParams *cparams, uint32_t key) {
*/
VbError_t vb2_developer_menu(struct vb2_context *ctx, VbCommonParams *cparams)
{
- GoogleBinaryBlockHeader *gbb = cparams->gbb;
VbSharedDataHeader *shared =
(VbSharedDataHeader *)cparams->shared_data_blob;
+ struct vb2_shared_data *sd = vb2_get_sd(ctx);
uint32_t use_usb = 0;
uint32_t use_legacy = 0;
@@ -615,11 +616,11 @@ VbError_t vb2_developer_menu(struct vb2_context *ctx, VbCommonParams *cparams)
use_legacy = 1;
/* Handle GBB flag override */
- if (gbb->flags & GBB_FLAG_FORCE_DEV_BOOT_USB)
+ if (sd->gbb_flags & VB2_GBB_FLAG_FORCE_DEV_BOOT_USB)
allow_usb = 1;
- if (gbb->flags & GBB_FLAG_FORCE_DEV_BOOT_LEGACY)
+ if (sd->gbb_flags & VB2_GBB_FLAG_FORCE_DEV_BOOT_LEGACY)
allow_legacy = 1;
- if (gbb->flags & GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY) {
+ if (sd->gbb_flags & VB2_GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY) {
use_legacy = 1;
use_usb = 0;
}
@@ -631,7 +632,7 @@ VbError_t vb2_developer_menu(struct vb2_context *ctx, VbCommonParams *cparams)
if (fwmp_flags & FWMP_DEV_ENABLE_LEGACY)
allow_legacy = 1;
if (fwmp_flags & FWMP_DEV_DISABLE_BOOT) {
- if (gbb->flags & GBB_FLAG_FORCE_DEV_SWITCH_ON) {
+ if (sd->gbb_flags & VB2_GBB_FLAG_FORCE_DEV_SWITCH_ON) {
VB2_DEBUG("FWMP_DEV_DISABLE_BOOT rejected by"
"FORCE_DEV_SWITCH_ON\n");
} else {
@@ -657,7 +658,7 @@ VbError_t vb2_developer_menu(struct vb2_context *ctx, VbCommonParams *cparams)
do {
uint32_t key;
- if (VbWantShutdownMenu(gbb->flags)) {
+ if (VbWantShutdownMenu(ctx)) {
VB2_DEBUG("shutdown requested!\n");
if (audio)
VbAudioClose(audio);
@@ -825,7 +826,8 @@ VbError_t vb2_developer_menu(struct vb2_context *ctx, VbCommonParams *cparams)
/* Enabling verified boot */
if (current_menu == VB_MENU_TO_NORM &&
current_menu_idx == VB_TO_NORM_CONFIRM) {
- if (gbb->flags & GBB_FLAG_FORCE_DEV_SWITCH_ON) {
+ if (sd->gbb_flags &
+ VB2_GBB_FLAG_FORCE_DEV_SWITCH_ON) {
/*
* Throw error when user tries to
* confirm transition to normal
@@ -948,7 +950,7 @@ static VbError_t recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
return VBERROR_SHUTDOWN_REQUESTED;
else {
VbCheckDisplayKey(ctx, cparams, key);
- if (VbWantShutdownMenu(cparams->gbb->flags))
+ if (VbWantShutdownMenu(ctx))
return VBERROR_SHUTDOWN_REQUESTED;
}
VbExSleepMs(REC_KEY_DELAY);
@@ -1137,7 +1139,7 @@ static VbError_t recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
return VBERROR_REBOOT_REQUIRED;
}
}
- if (VbWantShutdownMenu(cparams->gbb->flags))
+ if (VbWantShutdownMenu(ctx))
return VBERROR_SHUTDOWN_REQUESTED;
VbExSleepMs(REC_KEY_DELAY);
}
diff --git a/tests/ec_sync_tests.c b/tests/ec_sync_tests.c
index a8c9b78c..8f09af0d 100644
--- a/tests/ec_sync_tests.c
+++ b/tests/ec_sync_tests.c
@@ -409,19 +409,19 @@ static void VbSoftwareSyncTest(void)
test_ssync(0, 0, "AP-RW shutdown requested");
ResetMocks();
- cparams.gbb->flags |= GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC;
+ sd->gbb_flags |= VB2_GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC;
ec_aux_fw_mock_severity = VB_AUX_FW_FAST_UPDATE;
test_ssync(VBERROR_SUCCESS, 0,
- "GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC"
+ "VB2_GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC"
" disables auxiliary FW update request");
TEST_EQ(ec_aux_fw_update_req, 0, " aux fw update disabled");
TEST_EQ(ec_aux_fw_protected, 1, " aux fw protected");
ResetMocks();
- cparams.gbb->flags |= GBB_FLAG_DISABLE_PD_SOFTWARE_SYNC;
+ sd->gbb_flags |= VB2_GBB_FLAG_DISABLE_PD_SOFTWARE_SYNC;
ec_aux_fw_mock_severity = VB_AUX_FW_FAST_UPDATE;
test_ssync(VBERROR_SUCCESS, 0,
- "GBB_FLAG_DISABLE_PD_SOFTWARE_SYNC"
+ "VB2_GBB_FLAG_DISABLE_PD_SOFTWARE_SYNC"
" disables auxiliary FW update request");
TEST_EQ(ec_aux_fw_update_req, 0, " aux fw update disabled");
TEST_EQ(ec_aux_fw_protected, 1, " aux fw protected");
diff --git a/tests/vboot_api_devmode_tests.c b/tests/vboot_api_devmode_tests.c
index a65fc269..5b495163 100644
--- a/tests/vboot_api_devmode_tests.c
+++ b/tests/vboot_api_devmode_tests.c
@@ -12,6 +12,7 @@
#include "2sysincludes.h"
#include "2api.h"
+#include "2misc.h"
#include "2nvstorage.h"
#include "crc32.h"
#include "gbb_header.h"
@@ -134,6 +135,7 @@ test_case_t test[] = {
/* Mock data */
static VbCommonParams cparams;
+static uint8_t workbuf[VB2_KERNEL_WORKBUF_RECOMMENDED_SIZE];
static struct vb2_context ctx;
static uint8_t shared_data[VB_SHARED_DATA_MIN_SIZE];
static VbSharedDataHeader* shared = (VbSharedDataHeader*)shared_data;
@@ -160,6 +162,9 @@ static void ResetMocks(void) {
cparams.gbb = &gbb;
memset(&ctx, 0, sizeof(ctx));
+ ctx.workbuf = workbuf;
+ ctx.workbuf_size = sizeof(workbuf);
+ vb2_init_context(&ctx);
vb2_nv_init(&ctx);
memset(&shared_data, 0, sizeof(shared_data));
diff --git a/tests/vboot_api_kernel2_tests.c b/tests/vboot_api_kernel2_tests.c
index da0af9b5..f03a8dcd 100644
--- a/tests/vboot_api_kernel2_tests.c
+++ b/tests/vboot_api_kernel2_tests.c
@@ -32,6 +32,7 @@ static GoogleBinaryBlockHeader gbb;
static LoadKernelParams lkp;
static uint8_t workbuf[VB2_KERNEL_WORKBUF_RECOMMENDED_SIZE];
static struct vb2_context ctx;
+static struct vb2_shared_data *sd;
static int shutdown_request_calls_left;
static int audio_looping_calls_left;
@@ -80,6 +81,7 @@ static void ResetMocks(void)
ctx.workbuf_size = sizeof(workbuf);
vb2_init_context(&ctx);
vb2_nv_init(&ctx);
+ sd = vb2_get_sd(&ctx);
shutdown_request_calls_left = -1;
audio_looping_calls_left = 30;
@@ -297,8 +299,8 @@ static void VbBootDevTest(void)
/* Proceed to legacy after timeout if GBB flag set */
ResetMocks();
- gbb.flags |= GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY |
- GBB_FLAG_FORCE_DEV_BOOT_LEGACY;
+ sd->gbb_flags |= VB2_GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY |
+ VB2_GBB_FLAG_FORCE_DEV_BOOT_LEGACY;
TEST_EQ(VbBootDeveloper(&ctx, &cparams), 1002, "Timeout");
TEST_EQ(vbexlegacy_called, 1, " try legacy");
@@ -410,7 +412,7 @@ static void VbBootDevTest(void)
/* Enter does if GBB flag set */
ResetMocks();
shared->flags = VBSD_HONOR_VIRT_DEV_SWITCH | VBSD_BOOT_DEV_SWITCH_ON;
- gbb.flags |= GBB_FLAG_ENTER_TRIGGERS_TONORM;
+ sd->gbb_flags |= VB2_GBB_FLAG_ENTER_TRIGGERS_TONORM;
mock_keypress[0] = '\r';
mock_keypress[1] = '\r';
TEST_EQ(VbBootDeveloper(&ctx, &cparams), VBERROR_REBOOT_REQUIRED,
@@ -419,7 +421,7 @@ static void VbBootDevTest(void)
/* Tonorm ignored if GBB forces dev switch on */
ResetMocks();
shared->flags = VBSD_HONOR_VIRT_DEV_SWITCH | VBSD_BOOT_DEV_SWITCH_ON;
- gbb.flags |= GBB_FLAG_FORCE_DEV_SWITCH_ON;
+ sd->gbb_flags |= VB2_GBB_FLAG_FORCE_DEV_SWITCH_ON;
mock_keypress[0] = ' ';
mock_keypress[1] = '\r';
TEST_EQ(VbBootDeveloper(&ctx, &cparams), 1002,
@@ -458,7 +460,7 @@ static void VbBootDevTest(void)
/* Ctrl+D doesn't boot legacy even if GBB flag is set */
ResetMocks();
mock_keypress[0] = 0x04;
- gbb.flags |= GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY;
+ sd->gbb_flags |= VB2_GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY;
TEST_EQ(VbBootDeveloper(&ctx, &cparams), 1002, "Ctrl+D");
TEST_EQ(vbexlegacy_called, 0, " not legacy");
@@ -469,7 +471,7 @@ static void VbBootDevTest(void)
TEST_EQ(vbexlegacy_called, 0, " not legacy");
ResetMocks();
- gbb.flags |= GBB_FLAG_FORCE_DEV_BOOT_LEGACY;
+ sd->gbb_flags |= VB2_GBB_FLAG_FORCE_DEV_BOOT_LEGACY;
mock_keypress[0] = 0x0c;
TEST_EQ(VbBootDeveloper(&ctx, &cparams), 1002,
"Ctrl+L force legacy");
@@ -503,7 +505,7 @@ static void VbBootDevTest(void)
/* Ctrl+U enabled via GBB */
ResetMocks();
- gbb.flags |= GBB_FLAG_FORCE_DEV_BOOT_USB;
+ sd->gbb_flags |= VB2_GBB_FLAG_FORCE_DEV_BOOT_USB;
mock_keypress[0] = 0x15;
vbtlk_retval = VBERROR_SUCCESS - VB_DISK_FLAG_REMOVABLE;
TEST_EQ(VbBootDeveloper(&ctx, &cparams), 0, "Ctrl+U force USB");
diff --git a/tests/vboot_detach_menu_tests.c b/tests/vboot_detach_menu_tests.c
index 93f13f1d..f0aa4255 100644
--- a/tests/vboot_detach_menu_tests.c
+++ b/tests/vboot_detach_menu_tests.c
@@ -34,6 +34,7 @@ static GoogleBinaryBlockHeader gbb;
static LoadKernelParams lkp;
static uint8_t workbuf[VB2_KERNEL_WORKBUF_RECOMMENDED_SIZE];
static struct vb2_context ctx;
+static struct vb2_shared_data *sd;
static int shutdown_request_calls_left;
static int audio_looping_calls_left;
@@ -82,6 +83,7 @@ static void ResetMocks(void)
ctx.workbuf_size = sizeof(workbuf);
vb2_init_context(&ctx);
vb2_nv_init(&ctx);
+ sd = vb2_get_sd(&ctx);
shutdown_request_calls_left = -1;
audio_looping_calls_left = 30;
@@ -253,7 +255,7 @@ static void VbBootDevTest(void)
/* Proceed to legacy after timeout if GBB flag set */
ResetMocks();
- gbb.flags |= GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY |
+ sd->gbb_flags |= GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY |
GBB_FLAG_FORCE_DEV_BOOT_LEGACY;
TEST_EQ(VbBootDeveloperMenu(&ctx, &cparams), 1002, "Timeout");
TEST_EQ(vbexlegacy_called, 1, " try legacy");
@@ -373,7 +375,7 @@ static void VbBootDevTest(void)
/* Enter does if GBB flag set */
ResetMocks();
shared->flags = VBSD_HONOR_VIRT_DEV_SWITCH | VBSD_BOOT_DEV_SWITCH_ON;
- gbb.flags |= GBB_FLAG_ENTER_TRIGGERS_TONORM;
+ sd->gbb_flags |= GBB_FLAG_ENTER_TRIGGERS_TONORM;
mock_keypress[0] = '\r';
mock_keypress[1] = '\r';
TEST_EQ(VbBootDeveloperMenu(&ctx, &cparams), VBERROR_REBOOT_REQUIRED,
@@ -383,7 +385,7 @@ static void VbBootDevTest(void)
/* Tonorm ignored if GBB forces dev switch on */
ResetMocks();
shared->flags = VBSD_HONOR_VIRT_DEV_SWITCH | VBSD_BOOT_DEV_SWITCH_ON;
- gbb.flags |= GBB_FLAG_FORCE_DEV_SWITCH_ON;
+ sd->gbb_flags |= GBB_FLAG_FORCE_DEV_SWITCH_ON;
mock_keypress[0] = 0x62; // volume up
mock_keypress[1] = 0x90; // power
mock_keypress[2] = 0x90; // power
@@ -426,7 +428,7 @@ static void VbBootDevTest(void)
/* Ctrl+D doesn't boot legacy even if GBB flag is set */
ResetMocks();
mock_keypress[0] = 0x04;
- gbb.flags |= GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY;
+ sd->gbb_flags |= GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY;
TEST_EQ(VbBootDeveloperMenu(&ctx, &cparams), 1002, "Ctrl+D");
TEST_EQ(vbexlegacy_called, 0, " not legacy");
@@ -438,7 +440,7 @@ static void VbBootDevTest(void)
#if 0
ResetMocks();
- gbb.flags |= GBB_FLAG_FORCE_DEV_BOOT_LEGACY;
+ sd->gbb_flags |= GBB_FLAG_FORCE_DEV_BOOT_LEGACY;
mock_keypress[0] = 0x0c;
TEST_EQ(VbBootDeveloperMenu(&ctx, &cparams), 1002,
"Ctrl+L force legacy");
@@ -473,7 +475,7 @@ static void VbBootDevTest(void)
/* Ctrl+U enabled via GBB */
ResetMocks();
- gbb.flags |= GBB_FLAG_FORCE_DEV_BOOT_USB;
+ sd->gbb_flags |= GBB_FLAG_FORCE_DEV_BOOT_USB;
mock_keypress[0] = 0x15;
vbtlk_retval = VBERROR_SUCCESS - VB_DISK_FLAG_REMOVABLE;
TEST_EQ(VbBootDeveloperMenu(&ctx, &cparams), 0, "Ctrl+U force USB");