diff options
author | Sergii Dmytruk <sergii.dmytruk@3mdeb.com> | 2022-10-29 20:42:28 +0300 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2022-12-21 14:48:00 +0000 |
commit | d43154486d27323f64334203e9bc8baf08af6845 (patch) | |
tree | 0f232ce82fc77c1aa7ed5aba2303283fe7a5e78c /src/security/tpm/tss/tcg-1.2 | |
parent | 86f845ad0d864f44c21db964f0fdb213c41a152c (diff) |
security/tpm/: turn tis_{init,open} into tis_probe
Init was always followed by open and after successful initialization we
need only send-receive function, which is now returned by tis_probe on
success further reducing number of functions to export from drivers.
Change-Id: Ib4ce35ada24e3959ea1a518c29d431b4ae123809
Ticket: https://ticket.coreboot.org/issues/433
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/68991
Reviewed-by: Julius Werner <jwerner@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/security/tpm/tss/tcg-1.2')
-rw-r--r-- | src/security/tpm/tss/tcg-1.2/tss.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/security/tpm/tss/tcg-1.2/tss.c b/src/security/tpm/tss/tcg-1.2/tss.c index 39c44eca9f..7f0607ba82 100644 --- a/src/security/tpm/tss/tcg-1.2/tss.c +++ b/src/security/tpm/tss/tcg-1.2/tss.c @@ -24,12 +24,18 @@ #include <console/console.h> #define VBDEBUG(format, args...) printk(BIOS_DEBUG, format, ## args) +static tis_sendrecv_fn tis_sendrecv; + static int tpm_send_receive(const uint8_t *request, uint32_t request_length, uint8_t *response, uint32_t *response_length) { size_t len = *response_length; + + if (tis_sendrecv == NULL) + die("TSS 1.2 wasn't initialized\n"); + if (tis_sendrecv(request, request_length, response, &len)) return VB2_ERROR_UNKNOWN; /* check 64->32bit overflow and (re)check response buffer overflow */ @@ -140,20 +146,15 @@ static uint32_t send(const uint8_t *command) /* Exported functions. */ -static uint8_t tlcl_init_done; - uint32_t tlcl_lib_init(void) { - if (tlcl_init_done) + if (tis_sendrecv != NULL) return VB2_SUCCESS; - if (tis_init()) - return VB2_ERROR_UNKNOWN; - if (tis_open()) + tis_sendrecv = tis_probe(); + if (tis_sendrecv == NULL) return VB2_ERROR_UNKNOWN; - tlcl_init_done = 1; - return VB2_SUCCESS; } |