3
* Licensed Materials - Property of IBM
5
* trousers - An open source TCG Software Stack
7
* (C) Copyright International Business Machines Corp. 2004-2006
21
#include "trousers/tss.h"
22
#include "trousers_types.h"
24
#include "tcs_utils.h"
25
#include "tcsd_wrap.h"
31
static struct tpm_req_mgr *trm;
38
req_mgr_submit_req(BYTE *blob)
41
BYTE loc_buf[TSS_TPM_TXBLOB_SIZE];
42
UINT32 size = TSS_TPM_TXBLOB_SIZE;
43
UINT32 retry = TSS_REQ_MGR_MAX_RETRIES;
44
UINT32 blob_size = Decode_UINT32(&blob[2]);
46
if (blob_size > TSS_TPM_TXBLOB_SIZE) {
47
LogDebugFn("TPM blob is too large! (%u bytes)", blob_size);
48
return TCSERR(TSS_E_INTERNAL_ERROR);
51
pthread_mutex_lock(&(trm->queue_lock));
54
LogBlobData("To TPM:", blob_size, blob);
58
result = Tddli_TransmitData(blob, blob_size, loc_buf, &size);
59
} while (!result && (Decode_UINT32(&loc_buf[6]) == TCPA_E_RETRY) && --retry);
62
memcpy(blob, loc_buf, Decode_UINT32(&loc_buf[2]));
65
LogBlobData("From TPM:", size, loc_buf);
68
pthread_mutex_unlock(&(trm->queue_lock));
76
if ((trm = calloc(1, sizeof(struct tpm_req_mgr))) == NULL) {
77
LogError("malloc of %zd bytes failed.", sizeof(struct tpm_req_mgr));
78
return TSS_E_OUTOFMEMORY;
81
pthread_mutex_init(&(trm->queue_lock), NULL);