summaryrefslogtreecommitdiff
path: root/src/security/tpm/tss/tcg-1.2/tss.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/security/tpm/tss/tcg-1.2/tss.c')
-rw-r--r--src/security/tpm/tss/tcg-1.2/tss.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/security/tpm/tss/tcg-1.2/tss.c b/src/security/tpm/tss/tcg-1.2/tss.c
index e73db388e8..f0d28dfe3f 100644
--- a/src/security/tpm/tss/tcg-1.2/tss.c
+++ b/src/security/tpm/tss/tcg-1.2/tss.c
@@ -24,13 +24,22 @@
#include <console/console.h>
#define VBDEBUG(format, args...) printk(BIOS_DEBUG, format, ## args)
+static tis_sendrecv_fn tis_sendrecv;
+
static tpm_result_t tpm_send_receive(const uint8_t *request,
- uint32_t request_length,
- uint8_t *response,
- uint32_t *response_length)
+ uint32_t request_length,
+ uint8_t *response,
+ uint32_t *response_length)
{
size_t len = *response_length;
- tpm_result_t rc = tis_sendrecv(request, request_length, response, &len);
+ tpm_result_t rc;
+
+ if (tis_sendrecv == NULL) {
+ printk(BIOS_ERR, "Attempted use of uninitialized TSS 1.2 stack\n");
+ return TPM_FAIL;
+ }
+
+ rc = tis_sendrecv(request, request_length, response, &len);
if (rc)
return rc;
/* check 64->32bit overflow and (re)check response buffer overflow */
@@ -142,23 +151,16 @@ static tpm_result_t send(const uint8_t *command)
/* Exported functions. */
-static uint8_t tlcl_init_done;
-
tpm_result_t tlcl_lib_init(void)
{
- tpm_result_t rc = TPM_SUCCESS;
- if (tlcl_init_done)
- return rc;
- rc = tis_init();
- if (rc)
- return rc;
- rc = tis_open();
- if (rc)
- return rc;
+ if (tis_sendrecv != NULL)
+ return TPM_SUCCESS;
- tlcl_init_done = 1;
+ tis_sendrecv = tis_probe();
+ if (tis_sendrecv == NULL)
+ return TPM_CB_NO_DEVICE;
- return rc;
+ return TPM_SUCCESS;
}
tpm_result_t tlcl_startup(void)