summaryrefslogtreecommitdiff
path: root/firmware/lib
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/lib')
-rw-r--r--firmware/lib/ec_sync.c16
-rw-r--r--firmware/lib/region-init.c28
-rw-r--r--firmware/lib/vboot_api_kernel.c11
-rw-r--r--firmware/lib/vboot_audio.c4
-rw-r--r--firmware/lib/vboot_common.c5
-rw-r--r--firmware/lib/vboot_display.c3
-rw-r--r--firmware/lib/vboot_ui.c18
-rw-r--r--firmware/lib/vboot_ui_menu.c16
8 files changed, 47 insertions, 54 deletions
diff --git a/firmware/lib/ec_sync.c b/firmware/lib/ec_sync.c
index c8491551..bcd10e71 100644
--- a/firmware/lib/ec_sync.c
+++ b/firmware/lib/ec_sync.c
@@ -341,15 +341,16 @@ static VbError_t sync_one_ec(struct vb2_context *ctx, int devidx)
VbError_t ec_sync_phase1(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
/* Reasons not to do sync at all */
if (!(ctx->flags & VB2_CONTEXT_EC_SYNC_SUPPORTED))
return VBERROR_SUCCESS;
- if (sd->gbb_flags & VB2_GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC)
+ if (gbb->flags & VB2_GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC)
return VBERROR_SUCCESS;
#ifdef PD_SYNC
- const int do_pd_sync = !(sd->gbb_flags &
+ const int do_pd_sync = !(gbb->flags &
VB2_GBB_FLAG_DISABLE_PD_SOFTWARE_SYNC);
#else
const int do_pd_sync = 0;
@@ -412,11 +413,12 @@ int ec_will_update_slowly(struct vb2_context *ctx)
static int ec_sync_allowed(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
/* Reasons not to do sync at all */
if (!(ctx->flags & VB2_CONTEXT_EC_SYNC_SUPPORTED))
return 0;
- if (sd->gbb_flags & VB2_GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC)
+ if (gbb->flags & VB2_GBB_FLAG_DISABLE_EC_SOFTWARE_SYNC)
return 0;
if (sd->recovery_reason)
return 0;
@@ -426,11 +428,11 @@ static int ec_sync_allowed(struct vb2_context *ctx)
VbError_t ec_sync_check_aux_fw(struct vb2_context *ctx,
VbAuxFwUpdateSeverity_t *severity)
{
- struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
/* If we're not updating the EC, skip aux fw syncs as well */
if (!ec_sync_allowed(ctx) ||
- (sd->gbb_flags & VB2_GBB_FLAG_DISABLE_PD_SOFTWARE_SYNC)) {
+ (gbb->flags & VB2_GBB_FLAG_DISABLE_PD_SOFTWARE_SYNC)) {
*severity = VB_AUX_FW_NO_UPDATE;
return VBERROR_SUCCESS;
}
@@ -463,8 +465,8 @@ VbError_t ec_sync_phase2(struct vb2_context *ctx)
#ifdef PD_SYNC
/* Handle updates and jumps for PD */
- struct vb2_shared_data *sd = vb2_get_sd(ctx);
- if (!(sd->gbb_flags & VB2_GBB_FLAG_DISABLE_PD_SOFTWARE_SYNC)) {
+ struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
+ if (!(gbb->flags & VB2_GBB_FLAG_DISABLE_PD_SOFTWARE_SYNC)) {
retval = sync_one_ec(ctx, 1);
if (retval != VBERROR_SUCCESS)
return retval;
diff --git a/firmware/lib/region-init.c b/firmware/lib/region-init.c
index e34a3d15..9e3c2bc3 100644
--- a/firmware/lib/region-init.c
+++ b/firmware/lib/region-init.c
@@ -20,22 +20,14 @@
static VbError_t VbGbbReadData(struct vb2_context *ctx,
uint32_t offset, uint32_t size, void *buf)
{
- struct vb2_shared_data *sd = vb2_get_sd(ctx);
-
- /* This is the old API, for backwards compatibility */
- if (!sd->gbb)
- return VBERROR_INVALID_GBB;
-
- if (offset + size > sd->gbb_size)
+ if (vb2ex_read_resource(ctx, VB2_RES_GBB, offset, buf, size))
return VBERROR_INVALID_GBB;
-
- memcpy(buf, ((uint8_t *)sd->gbb) + offset, size);
return VBERROR_SUCCESS;
}
VbError_t VbGbbReadHWID(struct vb2_context *ctx, char *hwid, uint32_t max_size)
{
- struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
if (!max_size)
return VBERROR_INVALID_PARAMETER;
@@ -44,18 +36,18 @@ VbError_t VbGbbReadHWID(struct vb2_context *ctx, char *hwid, uint32_t max_size)
if (!ctx)
return VBERROR_INVALID_GBB;
- if (0 == sd->gbb->hwid_size) {
+ if (0 == gbb->hwid_size) {
VB2_DEBUG("VbHWID(): invalid hwid size\n");
return VBERROR_SUCCESS; /* oddly enough! */
}
- if (sd->gbb->hwid_size > max_size) {
+ if (gbb->hwid_size > max_size) {
VB2_DEBUG("VbDisplayDebugInfo(): invalid hwid offset/size\n");
return VBERROR_INVALID_PARAMETER;
}
- return VbGbbReadData(ctx, sd->gbb->hwid_offset,
- sd->gbb->hwid_size, hwid);
+ return VbGbbReadData(ctx, gbb->hwid_offset,
+ gbb->hwid_size, hwid);
}
static VbError_t VbGbbReadKey(struct vb2_context *ctx, uint32_t offset,
@@ -86,14 +78,14 @@ static VbError_t VbGbbReadKey(struct vb2_context *ctx, uint32_t offset,
VbError_t VbGbbReadRootKey(struct vb2_context *ctx, VbPublicKey **keyp)
{
- struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
- return VbGbbReadKey(ctx, sd->gbb->rootkey_offset, keyp);
+ return VbGbbReadKey(ctx, gbb->rootkey_offset, keyp);
}
VbError_t VbGbbReadRecoveryKey(struct vb2_context *ctx, VbPublicKey **keyp)
{
- struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
- return VbGbbReadKey(ctx, sd->gbb->recovery_key_offset, keyp);
+ return VbGbbReadKey(ctx, gbb->recovery_key_offset, keyp);
}
diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c
index 2be3e938..5d4c7c09 100644
--- a/firmware/lib/vboot_api_kernel.c
+++ b/firmware/lib/vboot_api_kernel.c
@@ -261,6 +261,7 @@ static VbError_t vb2_kernel_setup(struct vb2_context *ctx,
vb2_nv_init(ctx);
struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
sd->recovery_reason = shared->recovery_reason;
/*
@@ -294,11 +295,6 @@ static VbError_t vb2_kernel_setup(struct vb2_context *ctx,
kparams->flags = 0;
memset(kparams->partition_guid, 0, sizeof(kparams->partition_guid));
- /* Point to GBB data from cparams */
- sd->gbb = cparams->gbb_data;
- sd->gbb_size = cparams->gbb_size;
- sd->gbb_flags = sd->gbb->flags;
-
/* Read kernel version from the TPM. Ignore errors in recovery mode. */
if (RollbackKernelRead(&shared->kernel_version_tpm)) {
VB2_DEBUG("Unable to get kernel versions from TPM\n");
@@ -311,7 +307,7 @@ static VbError_t vb2_kernel_setup(struct vb2_context *ctx,
shared->kernel_version_tpm_start = shared->kernel_version_tpm;
/* Read FWMP. Ignore errors in recovery mode. */
- if (sd->gbb_flags & VB2_GBB_FLAG_DISABLE_FWMP) {
+ if (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");
@@ -473,6 +469,7 @@ VbError_t VbVerifyMemoryBootImage(
goto fail;
struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
VbSharedDataHeader *shared = sd->vbsd;
if ((boot_image == NULL) || (image_size == 0)) {
@@ -495,7 +492,7 @@ VbError_t VbVerifyMemoryBootImage(
vb2_nv_get(ctx, VB2_NV_DEV_BOOT_FASTBOOT_FULL_CAP);
if (0 == allow_fastboot_full_cap) {
- allow_fastboot_full_cap = !!(sd->gbb_flags &
+ allow_fastboot_full_cap = !!(gbb->flags &
VB2_GBB_FLAG_FORCE_DEV_BOOT_FASTBOOT_FULL_CAP);
}
diff --git a/firmware/lib/vboot_audio.c b/firmware/lib/vboot_audio.c
index e2a2655e..ba0f98c2 100644
--- a/firmware/lib/vboot_audio.c
+++ b/firmware/lib/vboot_audio.c
@@ -25,7 +25,7 @@ static int beep_count; /* Number of beeps so far */
*/
void vb2_audio_start(struct vb2_context *ctx)
{
- struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
open_time = VbExGetTimer(); /* "zero" starts now */
beep_count = 0;
@@ -34,7 +34,7 @@ void vb2_audio_start(struct vb2_context *ctx)
* Use a short developer screen delay on the first audio if indicated
* by GBB flags.
*/
- if ((sd->gbb_flags & VB2_GBB_FLAG_DEV_SCREEN_SHORT_DELAY) &&
+ if ((gbb->flags & VB2_GBB_FLAG_DEV_SCREEN_SHORT_DELAY) &&
(audio_open_count++ == 0)) {
VB2_DEBUG("vb2_audio_start() - using short dev screen delay\n");
audio_use_short = 1;
diff --git a/firmware/lib/vboot_common.c b/firmware/lib/vboot_common.c
index f0c4ea6a..fc32917b 100644
--- a/firmware/lib/vboot_common.c
+++ b/firmware/lib/vboot_common.c
@@ -214,8 +214,9 @@ int VbSharedDataSetKernelKey(VbSharedDataHeader *header, const VbPublicKey *src)
int vb2_allow_recovery(struct vb2_context *ctx)
{
- /* GBB_FLAG_FORCE_MANUAL_RECOVERY forces this to always return true. */
- if (vb2_get_sd(ctx)->gbb_flags & VB2_GBB_FLAG_FORCE_MANUAL_RECOVERY)
+ /* VB2_GBB_FLAG_FORCE_MANUAL_RECOVERY forces this to always return
+ true. */
+ if (vb2_get_gbb(ctx)->flags & VB2_GBB_FLAG_FORCE_MANUAL_RECOVERY)
return 1;
/*
diff --git a/firmware/lib/vboot_display.c b/firmware/lib/vboot_display.c
index d735cb41..1f80a651 100644
--- a/firmware/lib/vboot_display.c
+++ b/firmware/lib/vboot_display.c
@@ -273,6 +273,7 @@ const char *RecoveryReasonString(uint8_t code)
VbError_t VbDisplayDebugInfo(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
VbSharedDataHeader *shared = sd->vbsd;
char buf[DEBUG_INFO_SIZE] = "";
char sha1sum[VB2_SHA1_DIGEST_SIZE * 2 + 1];
@@ -355,7 +356,7 @@ VbError_t VbDisplayDebugInfo(struct vb2_context *ctx)
used += StrnAppend(buf + used,
"\ngbb.flags: 0x", DEBUG_INFO_SIZE - used);
used += Uint64ToString(buf + used, DEBUG_INFO_SIZE - used,
- sd->gbb_flags, 16, 8);
+ gbb->flags, 16, 8);
/* Add sha1sum for Root & Recovery keys */
ret = VbGbbReadRootKey(ctx, &key);
diff --git a/firmware/lib/vboot_ui.c b/firmware/lib/vboot_ui.c
index 14508a63..8321fbbb 100644
--- a/firmware/lib/vboot_ui.c
+++ b/firmware/lib/vboot_ui.c
@@ -55,7 +55,7 @@ static void VbAllowUsbBoot(struct vb2_context *ctx)
*/
static int VbWantShutdown(struct vb2_context *ctx, uint32_t key)
{
- struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
uint32_t shutdown_request = VbExIsShutdownRequested();
/*
@@ -78,7 +78,7 @@ static int VbWantShutdown(struct vb2_context *ctx, uint32_t key)
shutdown_request |= VB_SHUTDOWN_REQUEST_POWER_BUTTON;
/* If desired, ignore shutdown request due to lid closure. */
- if (sd->gbb_flags & VB2_GBB_FLAG_DISABLE_LID_SHUTDOWN)
+ if (gbb->flags & VB2_GBB_FLAG_DISABLE_LID_SHUTDOWN)
shutdown_request &= ~VB_SHUTDOWN_REQUEST_LID_CLOSED;
return shutdown_request;
@@ -518,6 +518,7 @@ static const char dev_disable_msg[] =
static VbError_t vb2_developer_ui(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
VbSharedDataHeader *shared = sd->vbsd;
uint32_t disable_dev_boot = 0;
@@ -540,11 +541,11 @@ static VbError_t vb2_developer_ui(struct vb2_context *ctx)
use_legacy = 1;
/* Handle GBB flag override */
- if (sd->gbb_flags & VB2_GBB_FLAG_FORCE_DEV_BOOT_USB)
+ if (gbb->flags & VB2_GBB_FLAG_FORCE_DEV_BOOT_USB)
allow_usb = 1;
- if (sd->gbb_flags & VB2_GBB_FLAG_FORCE_DEV_BOOT_LEGACY)
+ if (gbb->flags & VB2_GBB_FLAG_FORCE_DEV_BOOT_LEGACY)
allow_legacy = 1;
- if (sd->gbb_flags & VB2_GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY) {
+ if (gbb->flags & VB2_GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY) {
use_legacy = 1;
use_usb = 0;
}
@@ -556,7 +557,7 @@ static VbError_t vb2_developer_ui(struct vb2_context *ctx)
if (fwmp_flags & FWMP_DEV_ENABLE_LEGACY)
allow_legacy = 1;
if (fwmp_flags & FWMP_DEV_DISABLE_BOOT) {
- if (sd->gbb_flags & VB2_GBB_FLAG_FORCE_DEV_SWITCH_ON) {
+ if (gbb->flags & VB2_GBB_FLAG_FORCE_DEV_SWITCH_ON) {
VB2_DEBUG("FWMP_DEV_DISABLE_BOOT rejected by "
"FORCE_DEV_SWITCH_ON\n");
} else {
@@ -609,15 +610,14 @@ static VbError_t vb2_developer_ui(struct vb2_context *ctx)
break;
case VB_KEY_ENTER:
/* Only disable virtual dev switch if allowed by GBB */
- if (!(sd->gbb_flags &
- VB2_GBB_FLAG_ENTER_TRIGGERS_TONORM))
+ if (!(gbb->flags & VB2_GBB_FLAG_ENTER_TRIGGERS_TONORM))
break;
case ' ':
/* See if we should disable virtual dev-mode switch. */
VB2_DEBUG("shared->flags=0x%x\n", shared->flags);
if (shared->flags & VBSD_BOOT_DEV_SWITCH_ON) {
/* Stop the countdown while we go ask... */
- if (sd->gbb_flags &
+ if (gbb->flags &
VB2_GBB_FLAG_FORCE_DEV_SWITCH_ON) {
/*
* TONORM won't work (only for
diff --git a/firmware/lib/vboot_ui_menu.c b/firmware/lib/vboot_ui_menu.c
index 42494772..3fdf77cb 100644
--- a/firmware/lib/vboot_ui_menu.c
+++ b/firmware/lib/vboot_ui_menu.c
@@ -45,11 +45,11 @@ static const char no_legacy[] = "Legacy boot failed. Missing BIOS?\n";
*/
static int VbWantShutdownMenu(struct vb2_context *ctx)
{
- struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
uint32_t shutdown_request = VbExIsShutdownRequested();
/* If desired, ignore shutdown request due to lid closure. */
- if (sd->gbb_flags & VB2_GBB_FLAG_DISABLE_LID_SHUTDOWN)
+ if (gbb->flags & VB2_GBB_FLAG_DISABLE_LID_SHUTDOWN)
shutdown_request &= ~VB_SHUTDOWN_REQUEST_LID_CLOSED;
/*
@@ -181,7 +181,7 @@ static VbError_t boot_usb_action(struct vb2_context *ctx)
}
if (!vb2_nv_get(ctx, VB2_NV_DEV_BOOT_USB) &&
- !(vb2_get_sd(ctx)->gbb_flags & VB2_GBB_FLAG_FORCE_DEV_BOOT_USB) &&
+ !(vb2_get_gbb(ctx)->flags & VB2_GBB_FLAG_FORCE_DEV_BOOT_USB) &&
!(vb2_get_fwmp_flags() & FWMP_DEV_ENABLE_USB)) {
vb2_flash_screen(ctx);
vb2_error_notify("WARNING: Booting from external media "
@@ -377,7 +377,7 @@ static VbError_t to_dev_action(struct vb2_context *ctx)
/* Action that disables developer mode, shows TO_NORM_CONFIRMED and reboots. */
static VbError_t to_norm_action(struct vb2_context *ctx)
{
- if (vb2_get_sd(ctx)->gbb_flags & VB2_GBB_FLAG_FORCE_DEV_SWITCH_ON) {
+ if (vb2_get_gbb(ctx)->flags & VB2_GBB_FLAG_FORCE_DEV_SWITCH_ON) {
vb2_flash_screen(ctx);
vb2_error_notify("WARNING: TONORM prohibited by "
"GBB FORCE_DEV_SWITCH_ON.\n", NULL,
@@ -741,18 +741,18 @@ static VbError_t vb2_init_menus(struct vb2_context *ctx)
*/
static VbError_t vb2_developer_menu(struct vb2_context *ctx)
{
- struct vb2_shared_data *sd = vb2_get_sd(ctx);
+ struct vb2_gbb_header *gbb = vb2_get_gbb(ctx);
VbError_t ret;
/* Check if the default is to boot using disk, usb, or legacy */
default_boot = vb2_nv_get(ctx, VB2_NV_DEV_DEFAULT_BOOT);
- if (sd->gbb_flags & VB2_GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY)
+ if (gbb->flags & VB2_GBB_FLAG_DEFAULT_DEV_BOOT_LEGACY)
default_boot = VB2_DEV_DEFAULT_BOOT_LEGACY;
/* Check if developer mode is disabled by FWMP */
disable_dev_boot = 0;
if (vb2_get_fwmp_flags() & FWMP_DEV_DISABLE_BOOT) {
- if (sd->gbb_flags & VB2_GBB_FLAG_FORCE_DEV_SWITCH_ON) {
+ if (gbb->flags & VB2_GBB_FLAG_FORCE_DEV_SWITCH_ON) {
VB2_DEBUG("FWMP_DEV_DISABLE_BOOT rejected by"
"FORCE_DEV_SWITCH_ON\n");
} else {
@@ -762,7 +762,7 @@ static VbError_t vb2_developer_menu(struct vb2_context *ctx)
}
}
altfw_allowed = vb2_nv_get(ctx, VB2_NV_DEV_BOOT_LEGACY) ||
- (vb2_get_sd(ctx)->gbb_flags & VB2_GBB_FLAG_FORCE_DEV_BOOT_LEGACY) ||
+ (gbb->flags & VB2_GBB_FLAG_FORCE_DEV_BOOT_LEGACY) ||
(vb2_get_fwmp_flags() & FWMP_DEV_ENABLE_LEGACY);
/* Show appropriate initial menu */