summaryrefslogtreecommitdiff
path: root/firmware/stub
diff options
context:
space:
mode:
authormukesh agrawal <quiche@chromium.org>2011-06-27 20:00:52 -0700
committermukesh agrawal <quiche@chromium.org>2011-06-27 20:02:36 -0700
commita7b9481f343fb4a19b5a5ed44c2fda2c59547e84 (patch)
treec70974cbbe4ba8083dbd1c80e677fa32163badcb /firmware/stub
parent1c1a883bc746a6216bb634825d33d80562853020 (diff)
downloadvboot-a7b9481f343fb4a19b5a5ed44c2fda2c59547e84.tar.gz
Revert "Verified boot wrapper - replace utility functions"
This reverts commit bd81b3a7d3b7fe4ca6179ade665e565800ab17fc. Change-Id: I2be2c076a37bf0e49569248691fceac417254f0b Reviewed-on: http://gerrit.chromium.org/gerrit/3295 Reviewed-by: mukesh agrawal <quiche@chromium.org> Tested-by: mukesh agrawal <quiche@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);
+}