mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-25 10:45:02 +00:00
The original VBDEBUG macro used doubly-nested parens to work with MSVC, which didn't support varargs in macros. We now only use more modern compilers, so replace it with the VB2_DEBUG macro and get rid of the ugly and fragile double parens. BUG=chromium:611535 BRANCH=none TEST=make runtests; build_packages --board=reef chromeos-firmware Change-Id: Ifc0cb0733b14daaa1fde095fab7da4215a538c77 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/425133 Reviewed-by: Shelley Chen <shchen@chromium.org>
48 lines
1.2 KiB
C
48 lines
1.2 KiB
C
/* 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 "2sysincludes.h"
|
|
#include "2common.h"
|
|
|
|
#include "sysincludes.h"
|
|
#include "vboot_api.h"
|
|
#include "vboot_common.h"
|
|
#include "utility.h"
|
|
|
|
int VbSharedDataInit(VbSharedDataHeader *header, uint64_t size)
|
|
{
|
|
VB2_DEBUG("VbSharedDataInit, %d bytes, header %d bytes\n", (int)size,
|
|
(int)sizeof(VbSharedDataHeader));
|
|
|
|
if (size < sizeof(VbSharedDataHeader)) {
|
|
VB2_DEBUG("Not enough data for header.\n");
|
|
return VBOOT_SHARED_DATA_INVALID;
|
|
}
|
|
if (size < VB_SHARED_DATA_MIN_SIZE) {
|
|
VB2_DEBUG("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;
|
|
}
|