Files
OpenCellular/firmware/stub/vboot_api_stub_init.c
Randall Spangler 559a110f33 vboot: use malloc and free directly
Originally, vboot1 code used VbExMalloc() and VbExFree() since it needed
to talk to EFI firmware that didn't have standard malloc() and free().
Now, coreboot and depthcharge implement them as wrappers around those
standard calls.  vboot2 code already calls them directly, so let vboot1
code do that too.

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

Change-Id: I49ad0e32e38d278dc3589bfaf494bcf0e4b0a4bd
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/400905
2016-11-06 02:33:50 +00:00

71 lines
1.4 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.
*
* Stub implementations of firmware-provided API functions.
*/
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include "vboot_api.h"
/* U-Boot's printf uses '%L' for uint64_t. gcc uses '%l'. */
#define MAX_FMT 255
static char fmtbuf[MAX_FMT+1];
static const char *fixfmt(const char *format)
{
int i;
for(i=0; i<sizeof(fmtbuf)-1 && format[i]; i++) {
fmtbuf[i] = format[i];
if(format[i] == '%' && format[i+1] == 'L') {
fmtbuf[i+1] = 'l';
i++;
}
}
fmtbuf[i] = '\0';
return fmtbuf;
}
void VbExError(const char *format, ...)
{
va_list ap;
va_start(ap, format);
fprintf(stderr, "ERROR: ");
vfprintf(stderr, fixfmt(format), ap);
va_end(ap);
exit(1);
}
void VbExDebug(const char *format, ...)
{
va_list ap;
va_start(ap, format);
fprintf(stderr, "DEBUG: ");
vfprintf(stderr, fixfmt(format), ap);
va_end(ap);
}
uint64_t VbExGetTimer(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return (uint64_t)tv.tv_sec * 1000000 + (uint64_t)tv.tv_usec;
}
VbError_t test_mockable VbExNvStorageRead(uint8_t *buf)
{
return VBERROR_SUCCESS;
}
VbError_t VbExNvStorageWrite(const uint8_t *buf)
{
return VBERROR_SUCCESS;
}