summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2018-01-04 16:08:47 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-01-09 14:14:17 -0800
commit98616d79c6b60c719bc3e37f7f82028e77983d94 (patch)
tree3f060169830ac25f0c907d2c88052388805b1714 /firmware
parent79c1c6194bc45728a5043443d80506fa1d35c83b (diff)
downloadvboot-98616d79c6b60c719bc3e37f7f82028e77983d94.tar.gz
firmware: Prune down old region API
The region API was a way for firmware and kernel verification to get at various blocks of caller-provided data. In practice, we only used it internally as a way to get at parts of the GBB. Prune it down to access only the bits of GBB we still need, from the buffer we already know we have. In the long run we should use the same vb2ex_read_resource() API that vb2 firmware verification does, but that should be done in a follow-up CL since it'll need to be coordinated with support in depthcharge. No change in functionality. BUG=chromium:611535 BRANCH=none TEST=make -j runtests; build bob firmware and boot it Change-Id: I5715cb8d88274164a1a73ed4a56bbd93af46f9bf Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/852798 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
Diffstat (limited to 'firmware')
-rw-r--r--firmware/2lib/include/2struct.h5
-rw-r--r--firmware/include/gbb_access.h36
-rw-r--r--firmware/include/region.h55
-rw-r--r--firmware/include/vboot_api.h3
-rw-r--r--firmware/lib/include/vboot_display.h5
-rw-r--r--firmware/lib/include/vboot_kernel.h8
-rw-r--r--firmware/lib/region-fw.c55
-rw-r--r--firmware/lib/region-init.c100
-rw-r--r--firmware/lib/region-kernel.c89
-rw-r--r--firmware/lib/vboot_api_kernel.c24
-rw-r--r--firmware/lib/vboot_display.c14
-rw-r--r--firmware/lib/vboot_kernel.c3
-rw-r--r--firmware/lib/vboot_ui.c19
-rw-r--r--firmware/lib/vboot_ui_menu.c32
-rw-r--r--firmware/stub/vboot_api_stub_region.c18
15 files changed, 135 insertions, 331 deletions
diff --git a/firmware/2lib/include/2struct.h b/firmware/2lib/include/2struct.h
index 589e7c9b..3411de77 100644
--- a/firmware/2lib/include/2struct.h
+++ b/firmware/2lib/include/2struct.h
@@ -208,6 +208,11 @@ struct vb2_shared_data {
uint32_t workbuf_kernel_key_offset;
uint32_t workbuf_kernel_key_size;
+ /* GBB data and size */
+ struct vb2_gbb_header *gbb;
+ uint32_t gbb_size;
+
+
} __attribute__((packed));
/****************************************************************************/
diff --git a/firmware/include/gbb_access.h b/firmware/include/gbb_access.h
index 7b11dc85..9b4e0dde 100644
--- a/firmware/include/gbb_access.h
+++ b/firmware/include/gbb_access.h
@@ -10,43 +10,43 @@
#include "vboot_api.h"
-struct BmpBlockHeader;
-struct ImageInfo;
-struct GoogleBinaryBlockHeader;
-struct ScreenLayout;
+struct vb2_context;
struct VbPublicKey;
/**
- * Read the GBB header
- *
- * This accesses the GBB and reads its header.
- *
- * @param cparams Vboot common parameters
- * @param gbb Place to put GBB header
- */
-VbError_t VbGbbReadHeader_static(VbCommonParams *cparams,
- struct GoogleBinaryBlockHeader *gbb);
-
-/**
* Read the root key from the GBB
*
- * @param cparams Vboot common parameters
+ * @param ctx Vboot context
* @param keyp Returns a pointer to the key. The caller must call
* free() on the key when finished with it.
* @return VBERROR_... error, VBERROR_SUCCESS on success,
*/
-VbError_t VbGbbReadRootKey(VbCommonParams *cparams,
+VbError_t VbGbbReadRootKey(struct vb2_context *ctx,
struct VbPublicKey **keyp);
/**
* Read the recovery key from the GBB
*
+ * @param ctx Vboot context
* @param cparams Vboot common parameters
* @param keyp Returns a pointer to the key. The caller must call
* free() on the key when finished with it.
* @return VBERROR_... error, VBERROR_SUCCESS on success,
*/
-VbError_t VbGbbReadRecoveryKey(VbCommonParams *cparams,
+VbError_t VbGbbReadRecoveryKey(struct vb2_context *ctx,
struct VbPublicKey **keyp);
+/**
+ * Read the hardware ID from the GBB
+ *
+ * @param ctx Vboot context
+ * @param hwid Place to put HWID, which will be null-terminated
+ * @param max_size Maximum size of HWID including terminated null
+ * character (suggest 256). If this size is too small
+ * then VBERROR_INVALID_PARAMETER is returned.
+ * @return VBERROR_... error, VBERROR_SUCCESS on success,
+ */
+VbError_t VbGbbReadHWID(struct vb2_context *ctx, char *hwid,
+ uint32_t max_size);
+
#endif
diff --git a/firmware/include/region.h b/firmware/include/region.h
deleted file mode 100644
index 78e1dba0..00000000
--- a/firmware/include/region.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Access to portions of the firmware image, perhaps later to be expanded
- * to other devices.
- */
-
-#ifndef VBOOT_REFERENCE_REGION_H_
-#define VBOOT_REFERENCE_REGION_H_
-
-#include "bmpblk_header.h"
-#include "gbb_header.h"
-#include "vboot_api.h"
-#include "vboot_struct.h"
-
-/* The maximum length of a hardware ID */
-#define VB_REGION_HWID_LEN 256
-
-/**
- * Read data from a region
- *
- * @param cparams Vboot common parameters
- * @param region Region number to read
- * @param offset Offset within region to start reading
- * @param size Size of data to read
- * @param buf Buffer to put the data into
- * @return VBERROR_... error, VBERROR_SUCCESS on success,
- */
-VbError_t VbRegionReadData(VbCommonParams *cparams,
- enum vb_firmware_region region, uint32_t offset,
- uint32_t size, void *buf);
-
-/**
- * Check the version of the GBB and print debug information if valid
- *
- * @param cparams Vboot common parameters
- */
-void VbRegionCheckVersion(VbCommonParams *cparams);
-
-/**
- * Read the hardware ID from the GBB
- *
- * @param cparams Vboot common parameters
- * @param hwid Place to put HWID, which will be null-terminated
- * @param max_size Maximum size of HWID including terminated null
- * character (suggest VB_REGION_HWID_LEN). If this size
- * it too small then VBERROR_INVALID_PARAMETER is
- * returned.
- * @return VBERROR_... error, VBERROR_SUCCESS on success,
- */
-VbError_t VbRegionReadHWID(VbCommonParams *cparams, char *hwid,
- uint32_t max_size);
-
-#endif /* VBOOT_REFERENCE_REGION_H_ */
diff --git a/firmware/include/vboot_api.h b/firmware/include/vboot_api.h
index aa3ba2c9..5edf0a6b 100644
--- a/firmware/include/vboot_api.h
+++ b/firmware/include/vboot_api.h
@@ -193,9 +193,6 @@ typedef struct VbCommonParams {
* the stack.
*/
void *caller_context;
-
- /* For internal use of Vboot - do not examine or modify! */
- struct GoogleBinaryBlockHeader *gbb;
} VbCommonParams;
/* Flags for VbInitParams.flags */
diff --git a/firmware/lib/include/vboot_display.h b/firmware/lib/include/vboot_display.h
index 8e6a4546..20066dfa 100644
--- a/firmware/lib/include/vboot_display.h
+++ b/firmware/lib/include/vboot_display.h
@@ -14,9 +14,8 @@ VbError_t VbDisplayScreen(struct vb2_context *ctx, uint32_t screen, int force);
VbError_t VbDisplayMenu(struct vb2_context *ctx,
uint32_t screen, int force, uint32_t selected_index,
uint32_t disabled_idx_mask);
-VbError_t VbDisplayDebugInfo(struct vb2_context *ctx, VbCommonParams *cparams);
-VbError_t VbCheckDisplayKey(struct vb2_context *ctx, VbCommonParams *cparams,
- uint32_t key);
+VbError_t VbDisplayDebugInfo(struct vb2_context *ctx);
+VbError_t VbCheckDisplayKey(struct vb2_context *ctx, uint32_t key);
/**
* Return a description of the recovery reason code.
diff --git a/firmware/lib/include/vboot_kernel.h b/firmware/lib/include/vboot_kernel.h
index 2195e0cf..33981690 100644
--- a/firmware/lib/include/vboot_kernel.h
+++ b/firmware/lib/include/vboot_kernel.h
@@ -17,11 +17,6 @@
struct vb2_context;
/**
- * Exported for unit tests only - frees memory used by VbSelectAndLoadKernel()
- */
-void VbApiKernelFree(VbCommonParams *cparams);
-
-/**
* Attempt loading a kernel from the specified type(s) of disks.
*
* If successful, sets p->disk_handle to the disk for the kernel and returns
@@ -54,8 +49,7 @@ uint32_t VbTryLoadKernel(struct vb2_context *ctx, VbCommonParams *cparams,
*
* Returns: 1=yes, 0=no, -1 = shutdown.
*/
-int VbUserConfirms(struct vb2_context *ctx, VbCommonParams *cparams,
- uint32_t confirm_flags);
+int VbUserConfirms(struct vb2_context *ctx, uint32_t confirm_flags);
/**
* Handle a normal boot.
diff --git a/firmware/lib/region-fw.c b/firmware/lib/region-fw.c
deleted file mode 100644
index 2bc1a690..00000000
--- a/firmware/lib/region-fw.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * High-level firmware API for loading and verifying rewritable firmware.
- * (Firmware portion)
- */
-
-#include "sysincludes.h"
-
-#include "bmpblk_header.h"
-#include "region.h"
-#include "gbb_access.h"
-#include "gbb_header.h"
-#include "load_kernel_fw.h"
-#include "utility.h"
-#include "vboot_api.h"
-#include "vboot_struct.h"
-
-static VbError_t VbGbbReadKey(VbCommonParams *cparams, uint32_t offset,
- VbPublicKey **keyp)
-{
- VbPublicKey hdr, *key;
- VbError_t ret;
- uint32_t size;
-
- ret = VbRegionReadData(cparams, VB_REGION_GBB, offset,
- sizeof(VbPublicKey), &hdr);
- if (ret)
- return ret;
-
- /* Deal with a zero-size key (used in testing) */
- size = hdr.key_offset + hdr.key_size;
- if (size < sizeof(hdr))
- size = sizeof(hdr);
- key = malloc(size);
- ret = VbRegionReadData(cparams, VB_REGION_GBB, offset, size, key);
- if (ret) {
- free(key);
- return ret;
- }
-
- *keyp = key;
- return VBERROR_SUCCESS;
-}
-
-VbError_t VbGbbReadRootKey(VbCommonParams *cparams, VbPublicKey **keyp)
-{
- return VbGbbReadKey(cparams, cparams->gbb->rootkey_offset, keyp);
-}
-
-VbError_t VbGbbReadRecoveryKey(VbCommonParams *cparams, VbPublicKey **keyp)
-{
- return VbGbbReadKey(cparams, cparams->gbb->recovery_key_offset, keyp);
-}
diff --git a/firmware/lib/region-init.c b/firmware/lib/region-init.c
index 26602b54..5cfd4eda 100644
--- a/firmware/lib/region-init.c
+++ b/firmware/lib/region-init.c
@@ -6,10 +6,11 @@
* (Firmware portion)
*/
-#include "sysincludes.h"
+#include "2sysincludes.h"
+#include "2common.h"
+#include "2misc.h"
-#include "bmpblk_header.h"
-#include "region.h"
+#include "sysincludes.h"
#include "gbb_access.h"
#include "gbb_header.h"
#include "load_kernel_fw.h"
@@ -17,34 +18,83 @@
#include "vboot_api.h"
#include "vboot_struct.h"
-VbError_t VbRegionReadData(VbCommonParams *cparams,
- enum vb_firmware_region region, uint32_t offset,
- uint32_t size, void *buf)
+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 (region == VB_REGION_GBB && cparams->gbb_data) {
- if (offset + size > cparams->gbb_size)
- return VBERROR_INVALID_GBB;
- memcpy(buf, cparams->gbb_data + offset, size);
- } else
-#ifdef REGION_READ
- {
- VbError_t ret;
-
- ret = VbExRegionRead(cparams, region, offset, size, buf);
- if (ret)
- return ret;
+ if (!sd->gbb)
+ return VBERROR_INVALID_GBB;
+
+ if (offset + size > sd->gbb_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);
+
+ if (!max_size)
+ return VBERROR_INVALID_PARAMETER;
+ *hwid = '\0';
+ StrnAppend(hwid, "{INVALID}", max_size);
+ if (!ctx)
+ return VBERROR_INVALID_GBB;
+
+ if (0 == sd->gbb->hwid_size) {
+ VB2_DEBUG("VbHWID(): invalid hwid size\n");
+ return VBERROR_SUCCESS; /* oddly enough! */
+ }
+
+ if (sd->gbb->hwid_size > max_size) {
+ VB2_DEBUG("VbDisplayDebugInfo(): invalid hwid offset/size\n");
+ return VBERROR_INVALID_PARAMETER;
}
-#else
- return VBERROR_INVALID_GBB;
-#endif
+ return VbGbbReadData(ctx, sd->gbb->hwid_offset,
+ sd->gbb->hwid_size, hwid);
+}
+
+static VbError_t VbGbbReadKey(struct vb2_context *ctx, uint32_t offset,
+ VbPublicKey **keyp)
+{
+ VbPublicKey hdr, *key;
+ VbError_t ret;
+ uint32_t size;
+
+ ret = VbGbbReadData(ctx, offset, sizeof(VbPublicKey), &hdr);
+ if (ret)
+ return ret;
+
+ /* Deal with a zero-size key (used in testing) */
+ size = hdr.key_offset + hdr.key_size;
+ if (size < sizeof(hdr))
+ size = sizeof(hdr);
+ key = malloc(size);
+ ret = VbGbbReadData(ctx, offset, size, key);
+ if (ret) {
+ free(key);
+ return ret;
+ }
+
+ *keyp = key;
return VBERROR_SUCCESS;
}
-VbError_t VbGbbReadHeader_static(VbCommonParams *cparams,
- GoogleBinaryBlockHeader *gbb)
+VbError_t VbGbbReadRootKey(struct vb2_context *ctx, VbPublicKey **keyp)
+{
+ struct vb2_shared_data *sd = vb2_get_sd(ctx);
+
+ return VbGbbReadKey(ctx, sd->gbb->rootkey_offset, keyp);
+}
+
+VbError_t VbGbbReadRecoveryKey(struct vb2_context *ctx, VbPublicKey **keyp)
{
- return VbRegionReadData(cparams, VB_REGION_GBB, 0,
- sizeof(GoogleBinaryBlockHeader), gbb);
+ struct vb2_shared_data *sd = vb2_get_sd(ctx);
+
+ return VbGbbReadKey(ctx, sd->gbb->recovery_key_offset, keyp);
}
diff --git a/firmware/lib/region-kernel.c b/firmware/lib/region-kernel.c
deleted file mode 100644
index 404c189d..00000000
--- a/firmware/lib/region-kernel.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * High-level firmware API for loading and verifying rewritable firmware.
- * (Firmware portion)
- */
-
-#include "2sysincludes.h"
-#include "2common.h"
-
-#include "sysincludes.h"
-#include "bmpblk_header.h"
-#include "region.h"
-#include "gbb_access.h"
-#include "gbb_header.h"
-#include "load_kernel_fw.h"
-#include "utility.h"
-#include "vboot_api.h"
-#include "vboot_struct.h"
-
-static VbError_t VbRegionReadGbb(VbCommonParams *cparams, uint32_t offset,
- uint32_t size, void *buf)
-{
- return VbRegionReadData(cparams, VB_REGION_GBB, offset, size, buf);
-}
-
-VbError_t VbRegionReadHWID(VbCommonParams *cparams, char *hwid,
- uint32_t max_size)
-{
- GoogleBinaryBlockHeader *gbb;
- VbError_t ret;
-
- if (!max_size)
- return VBERROR_INVALID_PARAMETER;
- *hwid = '\0';
- StrnAppend(hwid, "{INVALID}", max_size);
- if (!cparams)
- return VBERROR_INVALID_GBB;
-
- gbb = cparams->gbb;
-
- if (0 == gbb->hwid_size) {
- VB2_DEBUG("VbHWID(): invalid hwid size\n");
- return VBERROR_SUCCESS; /* oddly enough! */
- }
-
- if (gbb->hwid_size > max_size) {
- VB2_DEBUG("VbDisplayDebugInfo(): invalid hwid offset/size\n");
- return VBERROR_INVALID_PARAMETER;
- }
- ret = VbRegionReadGbb(cparams, gbb->hwid_offset, gbb->hwid_size, hwid);
- if (ret)
- return ret;
-
- return VBERROR_SUCCESS;
-}
-
-#define OUTBUF_LEN 128
-
-void VbRegionCheckVersion(VbCommonParams *cparams)
-{
- GoogleBinaryBlockHeader *gbb;
-
- if (!cparams)
- return;
-
- gbb = cparams->gbb;
-
- /*
- * If GBB flags is nonzero, complain because that's something that the
- * factory MUST fix before shipping. We only have to do this here,
- * because it's obvious that something is wrong if we're not displaying
- * screens from the GBB.
- */
- if (gbb->major_version == GBB_MAJOR_VER && gbb->minor_version >= 1 &&
- (gbb->flags != 0)) {
- uint32_t used = 0;
- char outbuf[OUTBUF_LEN];
-
- *outbuf = '\0';
- used += StrnAppend(outbuf + used, "gbb.flags is nonzero: 0x",
- OUTBUF_LEN - used);
- used += Uint64ToString(outbuf + used, OUTBUF_LEN - used,
- gbb->flags, 16, 8);
- used += StrnAppend(outbuf + used, "\n", OUTBUF_LEN - used);
- (void)VbExDisplayDebugInfo(outbuf);
- }
-}
diff --git a/firmware/lib/vboot_api_kernel.c b/firmware/lib/vboot_api_kernel.c
index 5bda94f9..7976170d 100644
--- a/firmware/lib/vboot_api_kernel.c
+++ b/firmware/lib/vboot_api_kernel.c
@@ -16,7 +16,6 @@
#include "gbb_access.h"
#include "gbb_header.h"
#include "load_kernel_fw.h"
-#include "region.h"
#include "rollback_index.h"
#include "utility.h"
#include "vb2_common.h"
@@ -234,16 +233,6 @@ VbError_t VbBootNormal(struct vb2_context *ctx, VbCommonParams *cparams)
return rv;
}
-/* This function is also used by tests */
-void VbApiKernelFree(VbCommonParams *cparams)
-{
- /* VbSelectAndLoadKernel() always allocates this, tests don't */
- if (cparams->gbb) {
- free(cparams->gbb);
- cparams->gbb = NULL;
- }
-}
-
static VbError_t vb2_kernel_setup(VbCommonParams *cparams,
VbSelectAndLoadKernelParams *kparams)
{
@@ -345,12 +334,10 @@ static VbError_t vb2_kernel_setup(VbCommonParams *cparams,
kparams->flags = 0;
memset(kparams->partition_guid, 0, sizeof(kparams->partition_guid));
- /* Read GBB header, since we'll needs flags from it */
- cparams->gbb = malloc(sizeof(*cparams->gbb));
- uint32_t retval = VbGbbReadHeader_static(cparams, cparams->gbb);
- if (retval)
- return retval;
- sd->gbb_flags = cparams->gbb->flags;
+ /* 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)) {
@@ -421,7 +408,6 @@ static void vb2_kernel_cleanup(struct vb2_context *ctx, VbCommonParams *cparams)
/* Free buffers */
free(unaligned_workbuf);
- VbApiKernelFree(cparams);
vb2_nv_commit(ctx);
@@ -530,7 +516,7 @@ VbError_t VbVerifyMemoryBootImage(VbCommonParams *cparams,
hash_only = 1;
} else {
/* Get recovery key. */
- retval = VbGbbReadRecoveryKey(cparams, &kernel_subkey);
+ retval = VbGbbReadRecoveryKey(&ctx, &kernel_subkey);
if (VBERROR_SUCCESS != retval) {
VB2_DEBUG("Gbb Read Recovery key failed.\n");
goto fail;
diff --git a/firmware/lib/vboot_display.c b/firmware/lib/vboot_display.c
index d3e3a6a2..ea36c1f1 100644
--- a/firmware/lib/vboot_display.c
+++ b/firmware/lib/vboot_display.c
@@ -15,7 +15,6 @@
#include "bmpblk_font.h"
#include "gbb_access.h"
#include "gbb_header.h"
-#include "region.h"
#include "utility.h"
#include "vboot_api.h"
#include "vboot_common.h"
@@ -274,7 +273,7 @@ const char *RecoveryReasonString(uint8_t code)
#define DEBUG_INFO_SIZE 512
-VbError_t VbDisplayDebugInfo(struct vb2_context *ctx, VbCommonParams *cparams)
+VbError_t VbDisplayDebugInfo(struct vb2_context *ctx)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
VbSharedDataHeader *shared = sd->vbsd;
@@ -296,7 +295,7 @@ VbError_t VbDisplayDebugInfo(struct vb2_context *ctx, VbCommonParams *cparams)
disp_current_index, disp_disabled_idx_mask);
/* Add hardware ID */
- VbRegionReadHWID(cparams, hwid, sizeof(hwid));
+ VbGbbReadHWID(ctx, hwid, sizeof(hwid));
used += StrnAppend(buf + used, "HWID: ", DEBUG_INFO_SIZE - used);
used += StrnAppend(buf + used, hwid, DEBUG_INFO_SIZE - used);
@@ -371,7 +370,7 @@ VbError_t VbDisplayDebugInfo(struct vb2_context *ctx, VbCommonParams *cparams)
sd->gbb_flags, 16, 8);
/* Add sha1sum for Root & Recovery keys */
- ret = VbGbbReadRootKey(cparams, &key);
+ ret = VbGbbReadRootKey(ctx, &key);
if (!ret) {
FillInSha1Sum(sha1sum, key);
free(key);
@@ -381,7 +380,7 @@ VbError_t VbDisplayDebugInfo(struct vb2_context *ctx, VbCommonParams *cparams)
DEBUG_INFO_SIZE - used);
}
- ret = VbGbbReadRecoveryKey(cparams, &key);
+ ret = VbGbbReadRecoveryKey(ctx, &key);
if (!ret) {
FillInSha1Sum(sha1sum, key);
free(key);
@@ -413,8 +412,7 @@ VbError_t VbDisplayDebugInfo(struct vb2_context *ctx, VbCommonParams *cparams)
#define MAGIC_WORD "xyzzy"
static uint8_t MagicBuffer[MAGIC_WORD_LEN];
-VbError_t VbCheckDisplayKey(struct vb2_context *ctx, VbCommonParams *cparams,
- uint32_t key)
+VbError_t VbCheckDisplayKey(struct vb2_context *ctx, uint32_t key)
{
int i;
@@ -426,7 +424,7 @@ VbError_t VbCheckDisplayKey(struct vb2_context *ctx, VbCommonParams *cparams,
if ('\t' == key) {
/* Tab = display debug info */
- return VbDisplayDebugInfo(ctx, cparams);
+ return VbDisplayDebugInfo(ctx);
} else if (VB_KEY_LEFT == key || VB_KEY_RIGHT == key ||
VB_KEY_DOWN == key || VB_KEY_UP == key) {
/* Arrow keys = change localization */
diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c
index d298e68d..0200dccf 100644
--- a/firmware/lib/vboot_kernel.c
+++ b/firmware/lib/vboot_kernel.c
@@ -16,7 +16,6 @@
#include "2sha.h"
#include "cgptlib.h"
#include "cgptlib_internal.h"
-#include "region.h"
#include "gbb_access.h"
#include "gbb_header.h"
#include "gpt_misc.h"
@@ -464,7 +463,7 @@ VbError_t LoadKernel(struct vb2_context *ctx, LoadKernelParams *params,
struct vb2_packed_key *kernel_subkey;
if (kBootRecovery == shcall->boot_mode) {
/* Use the recovery key to verify the kernel */
- retval = VbGbbReadRecoveryKey(cparams,
+ retval = VbGbbReadRecoveryKey(ctx,
(VbPublicKey **)&recovery_key);
if (VBERROR_SUCCESS != retval)
goto load_kernel_exit;
diff --git a/firmware/lib/vboot_ui.c b/firmware/lib/vboot_ui.c
index 36c7cdf1..93bdf65a 100644
--- a/firmware/lib/vboot_ui.c
+++ b/firmware/lib/vboot_ui.c
@@ -16,7 +16,6 @@
#include "gbb_access.h"
#include "gbb_header.h"
#include "load_kernel_fw.h"
-#include "region.h"
#include "rollback_index.h"
#include "utility.h"
#include "vb2_common.h"
@@ -91,8 +90,7 @@ uint32_t VbTryUsb(struct vb2_context *ctx, VbCommonParams *cparams)
#define CONFIRM_KEY_DELAY 20 /* Check confirm screen keys every 20ms */
-int VbUserConfirms(struct vb2_context *ctx, VbCommonParams *cparams,
- uint32_t confirm_flags)
+int VbUserConfirms(struct vb2_context *ctx, uint32_t confirm_flags)
{
struct vb2_shared_data *sd = vb2_get_sd(ctx);
VbSharedDataHeader *shared = sd->vbsd;
@@ -146,7 +144,7 @@ int VbUserConfirms(struct vb2_context *ctx, VbCommonParams *cparams,
return 1;
}
}
- VbCheckDisplayKey(ctx, cparams, key);
+ VbCheckDisplayKey(ctx, key);
}
VbExSleepMs(CONFIRM_KEY_DELAY);
}
@@ -216,7 +214,7 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
VbExDisplayDebugInfo(dev_disable_msg);
/* Ignore space in VbUserConfirms()... */
- switch (VbUserConfirms(ctx, cparams, 0)) {
+ switch (VbUserConfirms(ctx, 0)) {
case 1:
VB2_DEBUG("leaving dev-mode\n");
vb2_nv_set(ctx, VB2_NV_DISABLE_DEV_REQUEST, 1);
@@ -278,7 +276,7 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
VbDisplayScreen(ctx,
VB_SCREEN_DEVELOPER_TO_NORM, 0);
/* Ignore space in VbUserConfirms()... */
- switch (VbUserConfirms(ctx, cparams, 0)) {
+ switch (VbUserConfirms(ctx, 0)) {
case 1:
VB2_DEBUG("leaving dev-mode\n");
vb2_nv_set(ctx, VB2_NV_DISABLE_DEV_REQUEST,
@@ -360,7 +358,7 @@ VbError_t vb2_developer_ui(struct vb2_context *ctx, VbCommonParams *cparams)
break;
default:
VB2_DEBUG("VbBootDeveloper() - pressed key %d\n", key);
- VbCheckDisplayKey(ctx, cparams, key);
+ VbCheckDisplayKey(ctx, key);
break;
}
} while(vb2_audio_looping());
@@ -429,7 +427,7 @@ static VbError_t recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
VB2_DEBUG("VbBootRecovery() waiting for manual recovery\n");
while (1) {
key = VbExKeyboardRead();
- VbCheckDisplayKey(ctx, cparams, key);
+ VbCheckDisplayKey(ctx, key);
if (VbWantShutdown(ctx, key))
return VBERROR_SHUTDOWN_REQUESTED;
VbExSleepMs(REC_KEY_DELAY);
@@ -499,8 +497,7 @@ static VbError_t recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
uint32_t vbc_flags =
VB_CONFIRM_SPACE_MEANS_NO |
VB_CONFIRM_MUST_TRUST_KEYBOARD;
- switch (VbUserConfirms(ctx, cparams,
- vbc_flags)) {
+ switch (VbUserConfirms(ctx, vbc_flags)) {
case 1:
VB2_DEBUG("Enabling dev-mode...\n");
if (TPM_SUCCESS != SetVirtualDevMode(1))
@@ -524,7 +521,7 @@ static VbError_t recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
break;
}
} else {
- VbCheckDisplayKey(ctx, cparams, key);
+ VbCheckDisplayKey(ctx, key);
}
if (VbWantShutdown(ctx, key))
return VBERROR_SHUTDOWN_REQUESTED;
diff --git a/firmware/lib/vboot_ui_menu.c b/firmware/lib/vboot_ui_menu.c
index a8247a2c..6ca602a7 100644
--- a/firmware/lib/vboot_ui_menu.c
+++ b/firmware/lib/vboot_ui_menu.c
@@ -14,7 +14,6 @@
#include "gbb_access.h"
#include "gbb_header.h"
#include "load_kernel_fw.h"
-#include "region.h"
#include "rollback_index.h"
#include "utility.h"
#include "vb2_common.h"
@@ -245,8 +244,7 @@ static const uint32_t VB_MENU_TO_SCREEN_MAP[] = {
VB_SCREEN_TO_NORM_CONFIRMED,
};
-VbError_t vb2_draw_current_screen(struct vb2_context *ctx,
- VbCommonParams *cparams) {
+VbError_t vb2_draw_current_screen(struct vb2_context *ctx) {
uint32_t screen;
if (current_menu < VB_MENU_COUNT)
screen = VB_MENU_TO_SCREEN_MAP[current_menu];
@@ -645,7 +643,7 @@ VbError_t vb2_developer_menu(struct vb2_context *ctx, VbCommonParams *cparams)
vb2_set_disabled_idx_mask(shared->flags);
/* Show the dev mode warning screen */
- vb2_draw_current_screen(ctx, cparams);
+ vb2_draw_current_screen(ctx);
/* Get audio/delay context */
vb2_audio_start(ctx);
@@ -710,21 +708,21 @@ VbError_t vb2_developer_menu(struct vb2_context *ctx, VbCommonParams *cparams)
return VBERROR_SUCCESS;
} else {
/* Show dev mode warning screen again */
- vb2_draw_current_screen(ctx, cparams);
+ vb2_draw_current_screen(ctx);
}
}
break;
case VB_BUTTON_VOL_UP_SHORT_PRESS:
case VB_KEY_UP:
vb2_update_selection(key);
- vb2_draw_current_screen(ctx, cparams);
+ vb2_draw_current_screen(ctx);
/* reset 30 second timer */
vb2_audio_start(ctx);
break;
case VB_BUTTON_VOL_DOWN_SHORT_PRESS:
case VB_KEY_DOWN:
vb2_update_selection(key);
- vb2_draw_current_screen(ctx, cparams);
+ vb2_draw_current_screen(ctx);
/* reset 30 second timer */
vb2_audio_start(ctx);
break;
@@ -740,7 +738,7 @@ VbError_t vb2_developer_menu(struct vb2_context *ctx, VbCommonParams *cparams)
ret = vb2_update_menu(ctx);
vb2_set_disabled_idx_mask(shared->flags);
- vb2_draw_current_screen(ctx, cparams);
+ vb2_draw_current_screen(ctx);
/* Probably shutting down */
if (ret != VBERROR_SUCCESS) {
@@ -757,7 +755,7 @@ VbError_t vb2_developer_menu(struct vb2_context *ctx, VbCommonParams *cparams)
/* Display debug information */
if (current_menu == VB_MENU_DEV_WARNING &&
current_menu_idx == VB_WARN_DBG_INFO) {
- VbDisplayDebugInfo(ctx, cparams);
+ VbDisplayDebugInfo(ctx);
}
/* Boot Legacy mode */
@@ -797,8 +795,7 @@ VbError_t vb2_developer_menu(struct vb2_context *ctx, VbCommonParams *cparams)
* Show dev mode warning screen
* again
*/
- vb2_draw_current_screen(ctx,
- cparams);
+ vb2_draw_current_screen(ctx);
}
}
@@ -933,7 +930,7 @@ static VbError_t recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
if (key == VB_BUTTON_POWER_SHORT_PRESS)
return VBERROR_SHUTDOWN_REQUESTED;
else {
- VbCheckDisplayKey(ctx, cparams, key);
+ VbCheckDisplayKey(ctx, key);
if (VbWantShutdownMenu(ctx))
return VBERROR_SHUTDOWN_REQUESTED;
}
@@ -970,7 +967,7 @@ static VbError_t recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
if (current_menu != VB_MENU_RECOVERY ||
current_menu_idx != VB_RECOVERY_DBG_INFO) {
if (retval == VBERROR_NO_DISK_FOUND)
- vb2_draw_current_screen(ctx, cparams);
+ vb2_draw_current_screen(ctx);
else {
VbDisplayScreen(ctx,
VB_SCREEN_RECOVERY_NO_GOOD, 0);
@@ -1005,7 +1002,7 @@ static VbError_t recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
}
vb2_update_selection(key);
- vb2_draw_current_screen(ctx, cparams);
+ vb2_draw_current_screen(ctx);
break;
case VB_BUTTON_VOL_UP_DOWN_COMBO_PRESS:
/*
@@ -1018,7 +1015,7 @@ static VbError_t recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
if (ret != VBERROR_SUCCESS)
return ret;
vb2_set_disabled_idx_mask(shared->flags);
- vb2_draw_current_screen(ctx, cparams);
+ vb2_draw_current_screen(ctx);
}
break;
case VB_BUTTON_POWER_SHORT_PRESS:
@@ -1056,8 +1053,7 @@ static VbError_t recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
* printed.
*/
if (retval == VBERROR_NO_DISK_FOUND)
- vb2_draw_current_screen(ctx,
- cparams);
+ vb2_draw_current_screen(ctx);
else {
VbDisplayScreen(ctx,
VB_SCREEN_RECOVERY_NO_GOOD, 0);
@@ -1078,7 +1074,7 @@ static VbError_t recovery_ui(struct vb2_context *ctx, VbCommonParams *cparams)
/* Display debug information */
if (current_menu == VB_MENU_RECOVERY &&
current_menu_idx == VB_RECOVERY_DBG_INFO) {
- VbDisplayDebugInfo(ctx, cparams);
+ VbDisplayDebugInfo(ctx);
}
/* Confirm going into developer mode */
diff --git a/firmware/stub/vboot_api_stub_region.c b/firmware/stub/vboot_api_stub_region.c
deleted file mode 100644
index f462fe4e..00000000
--- a/firmware/stub/vboot_api_stub_region.c
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Stub implementations of region API function.
- */
-
-#include <stdint.h>
-#include <stdlib.h>
-
-#include "vboot_api.h"
-
-VbError_t VbExRegionRead(VbCommonParams *cparams,
- enum vb_firmware_region region, uint32_t offset,
- uint32_t size, void *buf)
-{
- return VBERROR_SUCCESS;
-}