[coreboot-gerrit] Patch set updated for coreboot: tlcl: remove vboot code
Daisuke Nojiri (dnojiri@chromium.org)
gerrit at coreboot.org
Tue Jul 21 02:25:05 CEST 2015
Daisuke Nojiri (dnojiri at chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11019
-gerrit
commit 5fd6ef5dd508bb8acc2c748cf8d780799ce7e95f
Author: Daisuke Nojiri <dnojiri at chromium.org>
Date: Mon Jul 20 16:43:32 2015 -0700
tlcl: remove vboot code
This change removes vboot specific code from tlcl library.
BUG=none
BRANCH=tot
TEST=built for veyron_jerry
Change-Id: Id5b4edfcb2d5339071ccd094e4dd8ebdb8929061
Signed-off-by: Daisuke Nojiri <dnojiri at chromium.org>
---
3rdparty/blobs | 2 +-
src/include/tpm_lite/tlcl.h | 6 ----
src/lib/Makefile.inc | 2 +-
src/lib/mocked_tlcl.c | 47 +++++++++++++-----------------
src/lib/tlcl.c | 69 ++++++++++++++++++++-------------------------
5 files changed, 53 insertions(+), 73 deletions(-)
diff --git a/3rdparty/blobs b/3rdparty/blobs
index 61d663e..612cd24 160000
--- a/3rdparty/blobs
+++ b/3rdparty/blobs
@@ -1 +1 @@
-Subproject commit 61d663e39bc96530900c3232ccea7365ab9dad0b
+Subproject commit 612cd24575ab8bb77260e22f3665f46b77794ffe
diff --git a/src/include/tpm_lite/tlcl.h b/src/include/tpm_lite/tlcl.h
index 7724592..5bbd303 100644
--- a/src/include/tpm_lite/tlcl.h
+++ b/src/include/tpm_lite/tlcl.h
@@ -23,12 +23,6 @@
*/
uint32_t tlcl_lib_init(void);
-/**
- * Perform a raw TPM request/response transaction.
- */
-uint32_t tlcl_send_receive(const uint8_t *request, uint8_t *response,
- int max_length);
-
/* Commands */
/**
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index bda7586..e9ffbb4 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -57,7 +57,7 @@ verstage-$(CONFIG_COMMON_CBFS_SPI_WRAPPER) += cbfs_spi.c
ifeq ($(MOCK_TPM),1)
libverstage-y += mocked_tlcl.c
else
-libverstage-y += tlcl.c
+libverstage-y += mocked_tlcl.c
endif
verstage-$(CONFIG_GENERIC_UDELAY) += timer.c
diff --git a/src/lib/mocked_tlcl.c b/src/lib/mocked_tlcl.c
index c5c12bf..7234080 100644
--- a/src/lib/mocked_tlcl.c
+++ b/src/lib/mocked_tlcl.c
@@ -17,120 +17,113 @@
* Foundation, Inc.
*/
-#include <tpm_lite/tlcl.h>
-
-#ifdef FOR_TEST
-#include <stdio.h>
-#define VBDEBUG(format, args...) printf(format, ## args)
-#else
#include <console/console.h>
-#define VBDEBUG(format, args...) printk(BIOS_DEBUG, format, ## args)
-#endif
+#include <tpm_lite/tlcl.h>
uint32_t tlcl_lib_init(void) {
- VBDEBUG("MOCK_TPM: %s\n", __func__);
+ printk(BIOS_DEBUG, "MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE;
}
uint32_t tlcl_startup(void) {
- VBDEBUG("MOCK_TPM: %s\n", __func__);
+ printk(BIOS_DEBUG, "MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE;
}
uint32_t tlcl_resume(void) {
- VBDEBUG("MOCK_TPM: %s\n", __func__);
+ printk(BIOS_DEBUG, "MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE;
}
uint32_t tlcl_self_test_full(void)
{
- VBDEBUG("MOCK_TPM: %s\n", __func__);
+ printk(BIOS_DEBUG, "MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE;
}
uint32_t tlcl_continue_self_test(void)
{
- VBDEBUG("MOCK_TPM: %s\n", __func__);
+ printk(BIOS_DEBUG, "MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE;
}
uint32_t tlcl_define_space(uint32_t index, uint32_t perm, uint32_t size)
{
- VBDEBUG("MOCK_TPM: %s\n", __func__);
+ printk(BIOS_DEBUG, "MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE;
}
uint32_t tlcl_write(uint32_t index, const void* data, uint32_t length)
{
- VBDEBUG("MOCK_TPM: %s\n", __func__);
+ printk(BIOS_DEBUG, "MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE;
}
uint32_t tlcl_read(uint32_t index, void* data, uint32_t length)
{
- VBDEBUG("MOCK_TPM: %s\n", __func__);
+ printk(BIOS_DEBUG, "MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE;
}
uint32_t tlcl_assert_physical_presence(void) {
- VBDEBUG("MOCK_TPM: %s\n", __func__);
+ printk(BIOS_DEBUG, "MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE;
}
uint32_t tlcl_physical_presence_cmd_enable(void) {
- VBDEBUG("MOCK_TPM: %s\n", __func__);
+ printk(BIOS_DEBUG, "MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE;
}
uint32_t tlcl_finalize_physical_presence(void) {
- VBDEBUG("MOCK_TPM: %s\n", __func__);
+ printk(BIOS_DEBUG, "MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE;
}
uint32_t tlcl_set_nv_locked(void) {
- VBDEBUG("MOCK_TPM: %s\n", __func__);
+ printk(BIOS_DEBUG, "MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE;
}
uint32_t tlcl_force_clear(void) {
- VBDEBUG("MOCK_TPM: %s\n", __func__);
+ printk(BIOS_DEBUG, "MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE;
}
uint32_t tlcl_set_enable(void) {
- VBDEBUG("MOCK_TPM: %s\n", __func__);
+ printk(BIOS_DEBUG, "MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE;
}
uint32_t tlcl_set_deactivated(uint8_t flag)
{
- VBDEBUG("MOCK_TPM: %s\n", __func__);
+ printk(BIOS_DEBUG, "MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE;
}
uint32_t tlcl_get_permanent_flags(TPM_PERMANENT_FLAGS* pflags)
{
- VBDEBUG("MOCK_TPM: %s\n", __func__);
+ printk(BIOS_DEBUG, "MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE;
}
uint32_t tlcl_get_flags(uint8_t* disable, uint8_t* deactivated,
uint8_t *nvlocked)
{
- VBDEBUG("MOCK_TPM: %s\n", __func__);
+ printk(BIOS_DEBUG, "MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE;
}
uint32_t tlcl_set_global_lock(void)
{
- VBDEBUG("MOCK_TPM: %s\n", __func__);
+ printk(BIOS_DEBUG, "MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE;
}
uint32_t tlcl_extend(int pcr_num, const uint8_t* in_digest,
uint8_t* out_digest)
{
- VBDEBUG("MOCK_TPM: %s\n", __func__);
+ printk(BIOS_DEBUG, "MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE;
}
diff --git a/src/lib/tlcl.c b/src/lib/tlcl.c
index ccf4e80..7407fce 100644
--- a/src/lib/tlcl.c
+++ b/src/lib/tlcl.c
@@ -15,21 +15,13 @@
*/
#include <assert.h>
+#include <console/console.h>
#include <string.h>
#include <tpm_lite/tlcl.h>
#include <tpm.h>
-#include <vb2_api.h>
#include "tlcl_internal.h"
#include "tlcl_structures.h"
-#ifdef FOR_TEST
-#include <stdio.h>
-#define VBDEBUG(format, args...) printf(format, ## args)
-#else
-#include <console/console.h>
-#define VBDEBUG(format, args...) printk(BIOS_DEBUG, format, ## args)
-#endif
-
static int tpm_send_receive(const uint8_t *request,
uint32_t request_length,
uint8_t *response,
@@ -37,12 +29,12 @@ static int tpm_send_receive(const uint8_t *request,
{
size_t len = *response_length;
if (tis_sendrecv(request, request_length, response, &len))
- return VB2_ERROR_UNKNOWN;
+ return TPM_E_COMMUNICATION_ERROR;
/* check 64->32bit overflow and (re)check response buffer overflow */
if (len > *response_length)
- return VB2_ERROR_UNKNOWN;
+ return TPM_E_RESPONSE_TOO_LARGE;
*response_length = len;
- return VB2_SUCCESS;
+ return TPM_SUCCESS;
}
/* Sets the size field of a TPM command. */
@@ -82,7 +74,7 @@ static uint32_t tlcl_send_receive_no_retry(const uint8_t* request,
response, &response_length);
if (0 != result) {
/* Communication with TPM failed, so response is garbage */
- VBDEBUG("TPM: command 0x%x send/receive failed: 0x%x\n",
+ printk(BIOS_DEBUG, "TPM: command 0x%x send/receive failed: 0x%x\n",
tpm_command_code(request), result);
return result;
}
@@ -93,7 +85,7 @@ static uint32_t tlcl_send_receive_no_retry(const uint8_t* request,
* (and possibly expected length from the response header). See
* crosbug.com/17017 */
- VBDEBUG("TPM: command 0x%x returned 0x%x\n",
+ printk(BIOS_DEBUG, "TPM: command 0x%x returned 0x%x\n",
tpm_command_code(request), result);
return result;
@@ -102,8 +94,9 @@ return result;
/* Sends a TPM command and gets a response. Returns 0 if success or the TPM
* error code if error. Waits for the self test to complete if needed. */
-uint32_t tlcl_send_receive(const uint8_t* request, uint8_t* response,
- int max_length) {
+static uint32_t tlcl_send_receive(const uint8_t* request, uint8_t* response,
+ int max_length)
+{
uint32_t result = tlcl_send_receive_no_retry(request, response,
max_length);
/* If the command fails because the self test has not completed, try it
@@ -115,7 +108,7 @@ uint32_t tlcl_send_receive(const uint8_t* request, uint8_t* response,
#if defined(TPM_BLOCKING_CONTINUESELFTEST) || defined(VB_RECOVERY_MODE)
/* Retry only once */
result = tlcl_send_receive_no_retry(request, response,
- max_length);
+ max_length);
#else
/* This needs serious testing. The TPM specification says: "iii.
* The caller MUST wait for the actions of TPM_ContinueSelfTest
@@ -124,7 +117,7 @@ uint32_t tlcl_send_receive(const uint8_t* request, uint8_t* response,
* actions have completed other than trying again? */
do {
result = tlcl_send_receive_no_retry(request, response,
- max_length);
+ max_length);
} while (result == TPM_E_DOING_SELFTEST);
#endif
}
@@ -141,32 +134,32 @@ static uint32_t send(const uint8_t* command) {
uint32_t tlcl_lib_init(void) {
if (tis_init())
- return VB2_ERROR_UNKNOWN;
+ return TPM_E_INVALID_POSTINIT;
if (tis_open())
- return VB2_ERROR_UNKNOWN;
- return VB2_SUCCESS;
+ return TPM_E_INVALID_POSTINIT;
+ return TPM_SUCCESS;
}
uint32_t tlcl_startup(void) {
- VBDEBUG("TPM: Startup\n");
+ printk(BIOS_DEBUG, "TPM: Startup\n");
return send(tpm_startup_cmd.buffer);
}
uint32_t tlcl_resume(void) {
- VBDEBUG("TPM: Resume\n");
- return send(tpm_resume_cmd.buffer);
+ printk(BIOS_DEBUG, "TPM: Resume\n");
+ return send(tpm_resume_cmd.buffer);
}
uint32_t tlcl_self_test_full(void)
{
- VBDEBUG("TPM: Self test full\n");
+ printk(BIOS_DEBUG, "TPM: Self test full\n");
return send(tpm_selftestfull_cmd.buffer);
}
uint32_t tlcl_continue_self_test(void)
{
uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
- VBDEBUG("TPM: Continue self test\n");
+ printk(BIOS_DEBUG, "TPM: Continue self test\n");
/* Call the No Retry version of SendReceive to avoid recursion. */
return tlcl_send_receive_no_retry(tpm_continueselftest_cmd.buffer,
response, sizeof(response));
@@ -175,7 +168,7 @@ uint32_t tlcl_continue_self_test(void)
uint32_t tlcl_define_space(uint32_t index, uint32_t perm, uint32_t size)
{
struct s_tpm_nv_definespace_cmd cmd;
- VBDEBUG("TPM: TlclDefineSpace(0x%x, 0x%x, %d)\n", index, perm, size);
+ printk(BIOS_DEBUG, "TPM: TlclDefineSpace(0x%x, 0x%x, %d)\n", index, perm, size);
memcpy(&cmd, &tpm_nv_definespace_cmd, sizeof(cmd));
to_tpm_uint32(cmd.buffer + tpm_nv_definespace_cmd.index, index);
to_tpm_uint32(cmd.buffer + tpm_nv_definespace_cmd.perm, perm);
@@ -190,7 +183,7 @@ uint32_t tlcl_write(uint32_t index, const void* data, uint32_t length)
const int total_length =
kTpmRequestHeaderLength + kWriteInfoLength + length;
- VBDEBUG("TPM: tlcl_write(0x%x, %d)\n", index, length);
+ printk(BIOS_DEBUG, "TPM: tlcl_write(0x%x, %d)\n", index, length);
memcpy(&cmd, &tpm_nv_write_cmd, sizeof(cmd));
assert(total_length <= TPM_LARGE_ENOUGH_COMMAND_SIZE);
set_tpm_command_size(cmd.buffer, total_length);
@@ -209,7 +202,7 @@ uint32_t tlcl_read(uint32_t index, void* data, uint32_t length)
uint32_t result_length;
uint32_t result;
- VBDEBUG("TPM: tlcl_read(0x%x, %d)\n", index, length);
+ printk(BIOS_DEBUG, "TPM: tlcl_read(0x%x, %d)\n", index, length);
memcpy(&cmd, &tpm_nv_read_cmd, sizeof(cmd));
to_tpm_uint32(cmd.buffer + tpm_nv_read_cmd.index, index);
to_tpm_uint32(cmd.buffer + tpm_nv_read_cmd.length, length);
@@ -227,39 +220,39 @@ uint32_t tlcl_read(uint32_t index, void* data, uint32_t length)
uint32_t tlcl_assert_physical_presence(void) {
- VBDEBUG("TPM: Asserting physical presence\n");
+ printk(BIOS_DEBUG, "TPM: Asserting physical presence\n");
return send(tpm_ppassert_cmd.buffer);
}
uint32_t tlcl_physical_presence_cmd_enable(void) {
- VBDEBUG("TPM: Enable the physical presence command\n");
+ printk(BIOS_DEBUG, "TPM: Enable the physical presence command\n");
return send(tpm_ppenable_cmd.buffer);
}
uint32_t tlcl_finalize_physical_presence(void) {
- VBDEBUG("TPM: Enable PP cmd, disable HW pp, and set lifetime lock\n");
+ printk(BIOS_DEBUG, "TPM: Enable PP cmd, disable HW pp, and set lifetime lock\n");
return send(tpm_finalizepp_cmd.buffer);
}
uint32_t tlcl_set_nv_locked(void) {
- VBDEBUG("TPM: Set NV locked\n");
+ printk(BIOS_DEBUG, "TPM: Set NV locked\n");
return tlcl_define_space(TPM_NV_INDEX_LOCK, 0, 0);
}
uint32_t tlcl_force_clear(void) {
- VBDEBUG("TPM: Force clear\n");
+ printk(BIOS_DEBUG, "TPM: Force clear\n");
return send(tpm_forceclear_cmd.buffer);
}
uint32_t tlcl_set_enable(void) {
- VBDEBUG("TPM: Enabling TPM\n");
+ printk(BIOS_DEBUG, "TPM: Enabling TPM\n");
return send(tpm_physicalenable_cmd.buffer);
}
uint32_t tlcl_set_deactivated(uint8_t flag)
{
struct s_tpm_physicalsetdeactivated_cmd cmd;
- VBDEBUG("TPM: SetDeactivated(%d)\n", flag);
+ printk(BIOS_DEBUG, "TPM: SetDeactivated(%d)\n", flag);
memcpy(&cmd, &tpm_physicalsetdeactivated_cmd, sizeof(cmd));
*(cmd.buffer + cmd.deactivated) = flag;
return send(cmd.buffer);
@@ -292,7 +285,7 @@ uint32_t tlcl_get_flags(uint8_t* disable, uint8_t* deactivated,
*deactivated = pflags.deactivated;
if (nvlocked)
*nvlocked = pflags.nvLocked;
- VBDEBUG("TPM: flags disable=%d, deactivated=%d, nvlocked=%d\n",
+ printk(BIOS_DEBUG, "TPM: flags disable=%d, deactivated=%d, nvlocked=%d\n",
pflags.disable, pflags.deactivated, pflags.nvLocked);
}
return result;
@@ -301,7 +294,7 @@ uint32_t tlcl_get_flags(uint8_t* disable, uint8_t* deactivated,
uint32_t tlcl_set_global_lock(void)
{
uint32_t x;
- VBDEBUG("TPM: Set global lock\n");
+ printk(BIOS_DEBUG, "TPM: Set global lock\n");
return tlcl_write(TPM_NV_INDEX0, (uint8_t*) &x, 0);
}
More information about the coreboot-gerrit
mailing list