diff options
author | Sergii Dmytruk <sergii.dmytruk@3mdeb.com> | 2022-10-29 20:42:28 +0300 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2023-11-13 14:17:38 +0000 |
commit | 963f7b9e5ec4713eb45dfb656659d2c9cf5d9f83 (patch) | |
tree | 514b17f5c5395dac6e9030d518459bf363bcebc6 /src/drivers/pc80 | |
parent | bf0b06d9bd71b9e188e2a1c509f7b90ca395e164 (diff) |
security/tpm/: turn tis_{init,open} into tis_probe
init() was always followed by open() and after successful initialization
we only need send-receive function which is now returned by tis_probe()
on success, thus further reducing number of functions to export from
drivers.
This also removes check for opening TIS twice that seems to have no
value.
Change-Id: I52ad8d69d50d449f031c36b15bf70ef07986946c
Ticket: https://ticket.coreboot.org/issues/433
Signed-off-by: Sergii Dmytruk <sergii.dmytruk@3mdeb.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/76954
Reviewed-by: Julius Werner <jwerner@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/drivers/pc80')
-rw-r--r-- | src/drivers/pc80/tpm/tis.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/drivers/pc80/tpm/tis.c b/src/drivers/pc80/tpm/tis.c index 3f2d6bd7a2..019e4a1fe9 100644 --- a/src/drivers/pc80/tpm/tis.c +++ b/src/drivers/pc80/tpm/tis.c @@ -356,14 +356,14 @@ static tpm_result_t tis_command_ready(u8 locality) } /* - * tis_init() + * pc80_tis_probe() * * Probe the TPM device and try determining its manufacturer/device name. * * Returns TPM_SUCCESS on success (the device is found or was found during * an earlier invocation) or TPM_CB_FAIL if the device is not found. */ -tpm_result_t tis_init(void) +static tpm_result_t pc80_tis_probe(void) { const char *device_name = "unknown"; const char *vendor_name = device_name; @@ -607,13 +607,13 @@ static tpm_result_t tis_readresponse(u8 *buffer, size_t *len) } /* - * tis_open() + * pc80_tis_open() * * Requests access to locality 0 for the caller. * * Returns TPM_SUCCESS on success, TSS Error on failure. */ -tpm_result_t tis_open(void) +static tpm_result_t pc80_tis_open(void) { u8 locality = 0; /* we use locality zero for everything */ tpm_result_t rc = TPM_SUCCESS; @@ -650,8 +650,8 @@ tpm_result_t tis_open(void) * Returns TPM_SUCCESS on success (and places the number of response bytes * at recv_len) or TPM_CB_FAIL on failure. */ -tpm_result_t tis_sendrecv(const uint8_t *sendbuf, size_t send_size, - uint8_t *recvbuf, size_t *recv_len) +static tpm_result_t pc80_tpm_sendrecv(const uint8_t *sendbuf, size_t send_size, + uint8_t *recvbuf, size_t *recv_len) { tpm_result_t rc = tis_senddata(sendbuf, send_size); if (rc) { @@ -664,6 +664,23 @@ tpm_result_t tis_sendrecv(const uint8_t *sendbuf, size_t send_size, } /* + * tis_probe() + * + * Probe for the TPM device and set it up for use within locality 0. Returns + * pointer to send-receive function on success or NULL on failure. + */ +tis_sendrecv_fn tis_probe(void) +{ + if (pc80_tis_probe()) + return NULL; + + if (pc80_tis_open()) + return NULL; + + return &pc80_tpm_sendrecv; +} + +/* * tis_setup_interrupt() * * Set up the interrupt vector and polarity for locality 0 and |