summaryrefslogtreecommitdiff
path: root/firmware/stub
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2011-07-01 15:35:43 -0700
committerRandall Spangler <rspangler@chromium.org>2011-07-01 15:36:42 -0700
commitcfd841d3c2c8bb91e7024c62d0acc8668c5041b3 (patch)
tree23707ff082b864894634860d19b85af9cf5fd51f /firmware/stub
parentf8c65491595a8e849cf61b600b2371357ec75ff4 (diff)
downloadvboot-cfd841d3c2c8bb91e7024c62d0acc8668c5041b3.tar.gz
Revert "Verified boot wrapper - replace utility functions"
This reverts commit 0184886c8cb35e8e01d610622df448a7cb063e06 (This works with uboot-next, but not uboot, which doesn't implement its half of the new wrapper API. So rolling back to leave uboot working. Change-Id: I1f9e3c63e5bbdb20b9195cd68787bef89f24afee Reviewed-on: http://gerrit.chromium.org/gerrit/3588 Reviewed-by: Randall Spangler <rspangler@chromium.org> Tested-by: Randall Spangler <rspangler@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, 49 insertions, 14 deletions
diff --git a/firmware/stub/load_firmware_stub.c b/firmware/stub/load_firmware_stub.c
index bdae981c..26ce3d50 100644
--- a/firmware/stub/load_firmware_stub.c
+++ b/firmware/stub/load_firmware_stub.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2010 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,7 +9,6 @@
#include "load_firmware_fw.h"
#include "utility.h"
-#include "vboot_api.h"
#define BOOT_FIRMWARE_A_CONTINUE 1
#define BOOT_FIRMWARE_B_CONTINUE 2
@@ -100,7 +99,7 @@ int VerifyFirmwareDriver_stub(uint8_t* gbb_data,
p.nv_context = &vnc;
/* Allocate a shared data buffer */
- p.shared_data_blob = VbExMalloc(VB_SHARED_DATA_REC_SIZE);
+ p.shared_data_blob = Malloc(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 0317f933..ddb5d222 100644
--- a/firmware/stub/tpm_lite_stub.c
+++ b/firmware/stub/tpm_lite_stub.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+/* Copyright (c) 2010 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,7 +10,6 @@
#include "tlcl.h"
#include "tlcl_internal.h"
#include "utility.h"
-#include "vboot_api.h"
#include <errno.h>
#include <fcntl.h>
@@ -57,22 +56,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) {
- VbExError("invalid command length %d for command 0x%x\n", in_len, in[9]);
+ error("invalid command length %d for command 0x%x\n", in_len, in[9]);
} else if (tpm_fd < 0) {
- VbExError("the TPM device was not opened. Forgot to call TlclLibInit?\n");
+ error("the TPM device was not opened. Forgot to call TlclLibInit?\n");
} else {
int n = write(tpm_fd, in, in_len);
if (n != in_len) {
- VbExError("write failure to TPM device: %s\n", strerror(errno));
+ error("write failure to TPM device: %s\n", strerror(errno));
}
n = read(tpm_fd, response, sizeof(response));
if (n == 0) {
- VbExError("null read from TPM device\n");
+ error("null read from TPM device\n");
} else if (n < 0) {
- VbExError("read failure from TPM device: %s\n", strerror(errno));
+ error("read failure from TPM device: %s\n", strerror(errno));
} else {
if (n > *pout_len) {
- VbExError("TPM response too long for output buffer\n");
+ error("TPM response too long for output buffer\n");
} else {
*pout_len = n;
Memcpy(out, response, n);
@@ -127,8 +126,7 @@ uint32_t TlclOpenDevice(void) {
tpm_fd = open(device_path, O_RDWR);
if (tpm_fd < 0) {
- VbExError("TPM: Cannot open TPM device %s: %s\n", device_path,
- strerror(errno));
+ error("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 489b0f72..2d56f72b 100644
--- a/firmware/stub/utility_stub.c
+++ b/firmware/stub/utility_stub.c
@@ -15,12 +15,50 @@
#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);
+}