Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: drivers/tpm/slb9635_i2c/tddl.c

Issue 6683023: Add Infineon v05 TPM driver (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/u-boot-next.git@chromeos-v2010.09
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 /*******************************************************************************
2 **
3 ** FILENAME: $Id: i2c_tddl.c 59 2010-10-20 10:04:48Z hkr $
4 ** COPYRIGHT: Infineon Technologies
5 ** DESCRIPTION: Infineon_TPM-I2C - TDD supporting FW 2010.
6 ** CREATION DATE: 2010/11/10
7 ** LAST CHANGE: $Date: 2010-10-20 12:04:48 +0200 (Wed, 20 Oct 2010) $
8 ** $Author$
9 ** VERSION: $Revision: 59 $
10 **
11 ******************************************************************************/
12 #include <exports.h>
13
14 #include "tddl.h"
15 #include "compatibility.h"
16 #include "tpm.h"
17
18 /* buffer supporting tpm_transmit */
19 #define TDDL_BUFSIZE 4096
20 uint8_t tmpbuf[TDDL_BUFSIZE];
21
22 /* Open connection to TPM */
23 TDDL_RESULT TDDL_Open(void)
24 {
25 dbg_printf("INFO: initialising I2C bus TDDL\n");
26 if (tpm_open() < 0)
27 return TDDL_E_FAIL;
28 else
29 return TDDL_SUCCESS;
30 }
31
32 /* Disconnect from the TPM */
33 TDDL_RESULT TDDL_Close(void)
34 {
35 tpm_close();
36 return TDDL_SUCCESS;
37 }
38
39 /* Send the TPM Application Protocol Data Unit (APDU) to the TPM and
40 * return the response APDU */
41 TDDL_RESULT TDDL_TransmitData(uint8_t *pbTransmitBuf, uint32_t dwTransmitBufLen,
42 uint8_t *pbReceiveBuf, uint32_t *pdwReceiveBufLen)
43 {
44 int len;
45 uint32_t i;
46 TDDL_RESULT rc = TDDL_E_FAIL;
47
48 dbg_printf("--> xTDDL_TransmitData()\n");
49
50 dbg_printf("pbTransmitBuf = ");
51 for (i = 0; i < dwTransmitBufLen; i++)
52 dbg_printf("%02x ", pbTransmitBuf[i]);
53 dbg_printf("\n");
54
55 /* copy buffer to make sure transmit data may be overwritten */
56 memcpy(tmpbuf, pbTransmitBuf, dwTransmitBufLen);
57
58 /* do transmission */
59 len = tpm_transmit(tmpbuf, TDDL_BUFSIZE);
60
61 if (len >= 10) {
62 memcpy(pbReceiveBuf, tmpbuf, len);
63 dbg_printf("INFO: copied %d bytes into pbReceiveBuf\n", len);
64 rc = switch_endian32(&tmpbuf[TPM_RSP_RC_BYTE]);
65 *pdwReceiveBufLen = len;
66 } else {
67 dbg_printf("ERROR: tpm_transmit() returned %d\n", len);
68 *pdwReceiveBufLen = 0;
69 }
70
71 dbg_printf("pbReceiveBuf = ");
72 for (i = 0; i < (*pdwReceiveBufLen); i++)
73 dbg_printf("%02x ", pbReceiveBuf[i]);
74 dbg_printf("\n");
75
76 dbg_printf("<-- xTDDL_TransmitData()\n");
77
78 return rc;
79 }
80
81 /* Return the requested capability of the TPM or the driver */
82 TDDL_RESULT TDDL_GetCapability(uint32_t dwCapArea, uint32_t dwSubCap,
83 uint8_t *pbReceiveBuf, uint32_t *pdwReceiveBufLen)
84 {
85 return TDDL_E_FAIL;
86 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698