summaryrefslogtreecommitdiff
path: root/firmware/stub
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2011-07-08 13:03:32 -0700
committerRandall Spangler <rspangler@chromium.org>2011-07-08 13:13:15 -0700
commite49e8af65fce38da7a308305566f8a14f102254a (patch)
treeb18a7166ad1b32e2ba4de53146e7f375a474ff7b /firmware/stub
parent4ae77c50cdde2fe6b469cc523bcd4377aa816c7d (diff)
downloadvboot-e49e8af65fce38da7a308305566f8a14f102254a.tar.gz
Port vboot_reference to use new wrapper API utility functions
Third time's the charm. Now that we've moved to u-boot-next, this won't break the ARM build. BUG=chromium-os:17006 TEST=make && make runtests; emerge vboot_reference; emerge-tegra2_seaboard chromeos-bootimage Change-Id: Ib4fa26c7a23868dd2ffd2b321ee8dc08c66ea322 Original-Change-Id: I771085dcdf79d9592de64f35e3b758111a80dd9f Original-Reviewed-on: http://gerrit.chromium.org/gerrit/3263 Original-Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-on: http://gerrit.chromium.org/gerrit/3803 Tested-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'firmware/stub')
-rw-r--r--firmware/stub/load_firmware_stub.c5
-rw-r--r--firmware/stub/tpm_lite_stub.c18
-rw-r--r--firmware/stub/utility_stub.c40
3 files changed, 14 insertions, 49 deletions
diff --git a/firmware/stub/load_firmware_stub.c b/firmware/stub/load_firmware_stub.c
index 26ce3d50..bdae981c 100644
--- a/firmware/stub/load_firmware_stub.c
+++ b/firmware/stub/load_firmware_stub.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2011 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.
*
@@ -9,6 +9,7 @@
#include "load_firmware_fw.h"
#include "utility.h"
+#include "vboot_api.h"
#define BOOT_FIRMWARE_A_CONTINUE 1
#define BOOT_FIRMWARE_B_CONTINUE 2
@@ -99,7 +100,7 @@ int VerifyFirmwareDriver_stub(uint8_t* gbb_data,
p.nv_context = &vnc;
/* Allocate a shared data buffer */
- p.shared_data_blob = Malloc(VB_SHARED_DATA_REC_SIZE);
+ p.shared_data_blob = VbExMalloc(VB_SHARED_DATA_REC_SIZE);
p.shared_data_size = VB_SHARED_DATA_REC_SIZE;
/* TODO: YOU NEED TO SET THE BOOT FLAGS SOMEHOW */
diff --git a/firmware/stub/tpm_lite_stub.c b/firmware/stub/tpm_lite_stub.c
index ddb5d222..0317f933 100644
--- a/firmware/stub/tpm_lite_stub.c
+++ b/firmware/stub/tpm_lite_stub.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2011 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.
*
@@ -10,6 +10,7 @@
#include "tlcl.h"
#include "tlcl_internal.h"
#include "utility.h"
+#include "vboot_api.h"
#include <errno.h>
#include <fcntl.h>
@@ -56,22 +57,22 @@ static void TpmExecute(const uint8_t *in, const uint32_t in_len,
uint8_t *out, uint32_t *pout_len) {
uint8_t response[TPM_MAX_COMMAND_SIZE];
if (in_len <= 0) {
- error("invalid command length %d for command 0x%x\n", in_len, in[9]);
+ VbExError("invalid command length %d for command 0x%x\n", in_len, in[9]);
} else if (tpm_fd < 0) {
- error("the TPM device was not opened. Forgot to call TlclLibInit?\n");
+ VbExError("the TPM device was not opened. Forgot to call TlclLibInit?\n");
} else {
int n = write(tpm_fd, in, in_len);
if (n != in_len) {
- error("write failure to TPM device: %s\n", strerror(errno));
+ VbExError("write failure to TPM device: %s\n", strerror(errno));
}
n = read(tpm_fd, response, sizeof(response));
if (n == 0) {
- error("null read from TPM device\n");
+ VbExError("null read from TPM device\n");
} else if (n < 0) {
- error("read failure from TPM device: %s\n", strerror(errno));
+ VbExError("read failure from TPM device: %s\n", strerror(errno));
} else {
if (n > *pout_len) {
- error("TPM response too long for output buffer\n");
+ VbExError("TPM response too long for output buffer\n");
} else {
*pout_len = n;
Memcpy(out, response, n);
@@ -126,7 +127,8 @@ uint32_t TlclOpenDevice(void) {
tpm_fd = open(device_path, O_RDWR);
if (tpm_fd < 0) {
- error("TPM: Cannot open TPM device %s: %s\n", device_path, strerror(errno));
+ VbExError("TPM: Cannot open TPM device %s: %s\n", device_path,
+ strerror(errno));
}
return 0;
diff --git a/firmware/stub/utility_stub.c b/firmware/stub/utility_stub.c
index 2d56f72b..489b0f72 100644
--- a/firmware/stub/utility_stub.c
+++ b/firmware/stub/utility_stub.c
@@ -15,50 +15,12 @@
#include <string.h>
#include <sys/time.h>
-void error(const char *format, ...) {
- va_list ap;
- va_start(ap, format);
- fprintf(stderr, "ERROR: ");
- vfprintf(stderr, format, ap);
- va_end(ap);
- exit(1);
-}
-
-void debug(const char *format, ...) {
- va_list ap;
- va_start(ap, format);
- fprintf(stderr, "DEBUG: ");
- vfprintf(stderr, format, ap);
- va_end(ap);
-}
-
-void* Malloc(size_t size) {
- void* p = malloc(size);
- if (!p) {
- /* Fatal Error. We must abort. */
- abort();
- }
- return p;
-}
-
-void Free(void* ptr) {
- free(ptr);
-}
int Memcmp(const void* src1, const void* src2, size_t n) {
return memcmp(src1, src2, n);
}
+
void* Memcpy(void* dest, const void* src, uint64_t n) {
return memcpy(dest, src, (size_t)n);
}
-
-uint64_t VbGetTimer(void) {
- struct timeval tv;
- gettimeofday(&tv, NULL);
- return (uint64_t)tv.tv_sec * 1000000 + (uint64_t)tv.tv_usec;
-}
-
-uint64_t VbGetTimerMaxFreq(void) {
- return UINT64_C(1000000);
-}