aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2015-12-30 12:51:27 -0500
committerKevin O'Connor <kevin@koconnor.net>2016-01-05 15:05:14 -0500
commitb8631eaeb3b2216371de028c76abf17186ac84ab (patch)
tree9a39662a3c9039c68b00abace00c77dc414d8f72
parent9ddea3b018fcb2e0d8d49a7e6c3c36763d4e93e0 (diff)
downloadseabios-hppa-b8631eaeb3b2216371de028c76abf17186ac84ab.zip
seabios-hppa-b8631eaeb3b2216371de028c76abf17186ac84ab.tar.gz
seabios-hppa-b8631eaeb3b2216371de028c76abf17186ac84ab.tar.bz2
tpm: Don't use 16bit BIOS return codes in tpmhw_* functions
Don't use the return codes from the 16bit BIOS spec in the internal tpmhw functions. Only the 16bit BIOS interface code should need to handle the details of that spec. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--src/hw/tpm_drivers.c20
-rw-r--r--src/hw/tpm_drivers.h2
-rw-r--r--src/tcgbios.c24
3 files changed, 24 insertions, 22 deletions
diff --git a/src/hw/tpm_drivers.c b/src/hw/tpm_drivers.c
index be0a4eb..08fd101 100644
--- a/src/hw/tpm_drivers.c
+++ b/src/hw/tpm_drivers.c
@@ -10,7 +10,7 @@
#include "byteorder.h" // be32_to_cpu
#include "config.h" // CONFIG_TPM_TIS_SHA1THRESHOLD
#include "hw/tpm_drivers.h" // struct tpm_driver
-#include "std/tcg.h" // TCG_NO_RESPONSE
+#include "std/tcg.h" // TCG_RESPONSE_TIMEOUT
#include "output.h" // warn_timeout
#include "stacks.h" // yield
#include "string.h" // memcpy
@@ -280,7 +280,7 @@ static u32 tis_waitdatavalid(void)
u32 timeout_c = tpm_drivers[TIS_DRIVER_IDX].timeouts[TIS_TIMEOUT_TYPE_C];
if (tis_wait_sts(locty, timeout_c, TIS_STS_VALID, TIS_STS_VALID) != 0)
- rc = TCG_NO_RESPONSE;
+ rc = 1;
return rc;
}
@@ -298,7 +298,7 @@ static u32 tis_waitrespready(enum tpmDurationType to_t)
if (tis_wait_sts(locty, timeout,
TIS_STS_DATA_AVAILABLE, TIS_STS_DATA_AVAILABLE) != 0)
- rc = TCG_NO_RESPONSE;
+ rc = 1;
return rc;
}
@@ -344,37 +344,37 @@ tpmhw_is_present(void)
return TPMHW_driver_to_use != TPM_INVALID_DRIVER;
}
-u32
+int
tpmhw_transmit(u8 locty, struct tpm_req_header *req,
void *respbuffer, u32 *respbufferlen,
enum tpmDurationType to_t)
{
if (TPMHW_driver_to_use == TPM_INVALID_DRIVER)
- return TCG_FATAL_COM_ERROR;
+ return -1;
struct tpm_driver *td = &tpm_drivers[TPMHW_driver_to_use];
u32 irc = td->activate(locty);
if (irc != 0) {
/* tpm could not be activated */
- return TCG_FATAL_COM_ERROR;
+ return -1;
}
irc = td->senddata((void*)req, be32_to_cpu(req->totlen));
if (irc != 0)
- return TCG_FATAL_COM_ERROR;
+ return -1;
irc = td->waitdatavalid();
if (irc != 0)
- return TCG_FATAL_COM_ERROR;
+ return -1;
irc = td->waitrespready(to_t);
if (irc != 0)
- return TCG_FATAL_COM_ERROR;
+ return -1;
irc = td->readresp(respbuffer, respbufferlen);
if (irc != 0)
- return TCG_FATAL_COM_ERROR;
+ return -1;
td->ready();
diff --git a/src/hw/tpm_drivers.h b/src/hw/tpm_drivers.h
index 7a87beb..15a60af 100644
--- a/src/hw/tpm_drivers.h
+++ b/src/hw/tpm_drivers.h
@@ -13,7 +13,7 @@ enum tpmDurationType {
int tpmhw_probe(void);
int tpmhw_is_present(void);
struct tpm_req_header;
-u32 tpmhw_transmit(u8 locty, struct tpm_req_header *req,
+int tpmhw_transmit(u8 locty, struct tpm_req_header *req,
void *respbuffer, u32 *respbufferlen,
enum tpmDurationType to_t);
void tpmhw_set_timeouts(u32 timeouts[4], u32 durations[3]);
diff --git a/src/tcgbios.c b/src/tcgbios.c
index 5e8fa63..641b2d6 100644
--- a/src/tcgbios.c
+++ b/src/tcgbios.c
@@ -193,8 +193,8 @@ build_and_send_cmd(u8 locty, u32 ordinal, const u8 *append, u32 append_size,
if (append_size)
memcpy(req.cmd, append, append_size);
- u32 rc = tpmhw_transmit(locty, &req.trqh, obuffer, &obuffer_len, to_t);
- int ret = rc ? -1 : be32_to_cpu(trsh->errcode);
+ int ret = tpmhw_transmit(locty, &req.trqh, obuffer, &obuffer_len, to_t);
+ ret = ret ? -1 : be32_to_cpu(trsh->errcode);
dprintf(DEBUG_tcg, "Return from build_and_send_cmd(%x, %x %x) = %x\n",
ordinal, req.cmd[0], req.cmd[1], ret);
return ret;
@@ -232,9 +232,9 @@ tpm_get_capability(u32 cap, u32 subcap, struct tpm_rsp_header *rsp, u32 rsize)
.subCap = cpu_to_be32(subcap)
};
u32 resp_size = rsize;
- u32 rc = tpmhw_transmit(0, &trgc.hdr, rsp, &resp_size,
- TPM_DURATION_TYPE_SHORT);
- int ret = (rc || resp_size != rsize) ? -1 : be32_to_cpu(rsp->errcode);
+ int ret = tpmhw_transmit(0, &trgc.hdr, rsp, &resp_size,
+ TPM_DURATION_TYPE_SHORT);
+ ret = (ret || resp_size != rsize) ? -1 : be32_to_cpu(rsp->errcode);
dprintf(DEBUG_tcg, "TCGBIOS: Return code from TPM_GetCapability(%d, %d)"
" = %x\n", cap, subcap, ret);
if (ret) {
@@ -298,9 +298,9 @@ tpm_log_extend_event(struct pcpes *pcpes, const void *event)
struct tpm_rsp_extend rsp;
u32 resp_length = sizeof(rsp);
- u32 rc = tpmhw_transmit(0, &tre.hdr, &rsp, &resp_length,
- TPM_DURATION_TYPE_SHORT);
- if (rc || resp_length != sizeof(rsp) || rsp.hdr.errcode)
+ int ret = tpmhw_transmit(0, &tre.hdr, &rsp, &resp_length,
+ TPM_DURATION_TYPE_SHORT);
+ if (ret || resp_length != sizeof(rsp) || rsp.hdr.errcode)
return -1;
return tpm_log_event(pcpes, event);
@@ -684,10 +684,12 @@ pass_through_to_tpm_int(struct pttti *pttti, struct pttto *pttto)
}
u32 resbuflen = pttti->opblength - offsetof(struct pttto, tpmopout);
- rc = tpmhw_transmit(0, trh, pttto->tpmopout, &resbuflen,
- TPM_DURATION_TYPE_LONG /* worst case */);
- if (rc)
+ int ret = tpmhw_transmit(0, trh, pttto->tpmopout, &resbuflen,
+ TPM_DURATION_TYPE_LONG /* worst case */);
+ if (ret) {
+ rc = TCG_FATAL_COM_ERROR;
goto err_exit;
+ }
pttto->opblength = offsetof(struct pttto, tpmopout) + resbuflen;
pttto->reserved = 0;