summaryrefslogtreecommitdiff
path: root/firmware/lib/vboot_common_init.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2013-02-26 11:03:57 -0800
committerChromeBot <chrome-bot@google.com>2013-02-26 12:59:12 -0800
commit93943266c597ad66300445a04afa01270f2b5763 (patch)
treebf7034285aa5679373a0e430945a929a819bcf9e /firmware/lib/vboot_common_init.c
parentab63d3c20b8be3f610fff454260f02ab1d7c02b6 (diff)
downloadvboot-93943266c597ad66300445a04afa01270f2b5763.tar.gz
Split off modules required for VbInit() and VbSelectFirmware()
This makes it more obvious which modules and VbEx*() functions must be implemented to call these entry points. This change only moves functions between modules and adds two link-test binaries; it doesn't change any functionality. BUG=chromium-os:39262 BRANCH=none TEST=make && make runtests Change-Id: If3edf0b1989b631f0e7ad18de7ccdad8315181b5 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/44076 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'firmware/lib/vboot_common_init.c')
-rw-r--r--firmware/lib/vboot_common_init.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/firmware/lib/vboot_common_init.c b/firmware/lib/vboot_common_init.c
new file mode 100644
index 00000000..9d6670ea
--- /dev/null
+++ b/firmware/lib/vboot_common_init.c
@@ -0,0 +1,43 @@
+/* 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.
+ *
+ * Common functions between firmware and kernel verified boot.
+ * (Firmware portion)
+ */
+
+#include "vboot_api.h"
+#include "vboot_common.h"
+#include "utility.h"
+
+int VbSharedDataInit(VbSharedDataHeader *header, uint64_t size)
+{
+ VBDEBUG(("VbSharedDataInit, %d bytes, header %d bytes\n", (int)size,
+ sizeof(VbSharedDataHeader)));
+
+ if (size < sizeof(VbSharedDataHeader)) {
+ VBDEBUG(("Not enough data for header.\n"));
+ return VBOOT_SHARED_DATA_INVALID;
+ }
+ if (size < VB_SHARED_DATA_MIN_SIZE) {
+ VBDEBUG(("Shared data buffer too small.\n"));
+ return VBOOT_SHARED_DATA_INVALID;
+ }
+
+ if (!header)
+ return VBOOT_SHARED_DATA_INVALID;
+
+ /* Zero the header */
+ Memset(header, 0, sizeof(VbSharedDataHeader));
+
+ /* Initialize fields */
+ header->magic = VB_SHARED_DATA_MAGIC;
+ header->struct_version = VB_SHARED_DATA_VERSION;
+ header->struct_size = sizeof(VbSharedDataHeader);
+ header->data_size = size;
+ header->data_used = sizeof(VbSharedDataHeader);
+ header->firmware_index = 0xFF;
+
+ /* Success */
+ return VBOOT_SUCCESS;
+}