Files
OpenCellular/firmware/lib/region-init.c
Randall Spangler 664096bd1a vboot: use standard memcmp, memcpy, memset
Originally, we didn't trust the firmware to provide these functions from
a standard library.  Now, with coreboot, we do.

BUG=chromium:611535
BRANCH=none
TEST=make runtests; emerge-kevin coreboot depthcharge

Change-Id: I4e624c40085f2b665275a38624340b2f6aabcf11
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/399120
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
2016-10-23 13:33:38 -07:00

51 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.
*
* 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"
VbError_t VbRegionReadData(VbCommonParams *cparams,
enum vb_firmware_region region, uint32_t offset,
uint32_t size, void *buf)
{
/* 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;
}
#else
return VBERROR_INVALID_GBB;
#endif
return VBERROR_SUCCESS;
}
VbError_t VbGbbReadHeader_static(VbCommonParams *cparams,
GoogleBinaryBlockHeader *gbb)
{
return VbRegionReadData(cparams, VB_REGION_GBB, 0,
sizeof(GoogleBinaryBlockHeader), gbb);
}