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

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: Fix nits 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
« no previous file with comments | « drivers/tpm/slb9635_i2c/tddl.h ('k') | drivers/tpm/slb9635_i2c/tpm.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2011 Infineon Technologies
3 *
4 * Authors:
5 * Peter Huewe <huewe.external@infineon.com>
6 *
7 * description: Infineon_TPM-I2C - TDDL supporting FW 2010.
8 *
9 * See file CREDITS for list of people who contributed to this
10 * project.
11 *
12 * Version: 2.1.1
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 * MA 02111-1307 USA
28 */
29 #include <exports.h>
30
31 #include "tddl.h"
32 #include "tpm.h"
33
34 /* buffer supporting tpm_transmit */
35 uint8_t tmpbuf[TPM_BUFSIZE];
36
37 /* Open connection to TPM */
38 TDDL_RESULT TDDL_Open(uint32_t dev_addr)
39 {
40 int rc;
41 dbg_printf("INFO: initialising TPM\n");
42 rc = tpm_open(dev_addr);
43 if (rc < 0) {
44 switch (rc) {
45 case -EBUSY: return TDDL_E_ALREADY_OPENED;
46 case -ENODEV: return TDDL_E_COMPONENT_NOT_FOUND;
47 };
48 return TDDL_E_FAIL;
49 }
50 return TDDL_SUCCESS;
51 }
52
53 /* Disconnect from the TPM */
54 TDDL_RESULT TDDL_Close(void)
55 {
56 tpm_close();
57 return TDDL_SUCCESS;
58 }
59
60 /* Send the TPM Application Protocol Data Unit (APDU) to the TPM and
61 * return the response APDU */
62 TDDL_RESULT TDDL_TransmitData(uint8_t *pbTransmitBuf, uint32_t dwTransmitBufLen,
63 uint8_t *pbReceiveBuf, uint32_t *pdwReceiveBufLen)
64 {
65 int len;
66 uint32_t i;
67 TDDL_RESULT rc = TDDL_E_FAIL;
68
69 dbg_printf("--> xTDDL_TransmitData()\n");
70
71 dbg_printf("pbTransmitBuf = ");
72 for (i = 0; i < dwTransmitBufLen; i++)
73 dbg_printf("%02x ", pbTransmitBuf[i]);
74 dbg_printf("\n");
75
76 /* copy buffer to make sure transmit data may be overwritten */
77 memcpy(tmpbuf, pbTransmitBuf, dwTransmitBufLen);
78
79 /* do transmission */
80 len = tpm_transmit(tmpbuf, dwTransmitBufLen);
81
82 if (len >= 10) {
83 memcpy(pbReceiveBuf, tmpbuf, len);
84 dbg_printf("INFO: copied %d bytes into pbReceiveBuf\n", len);
85 *pdwReceiveBufLen = len;
86 rc = TDDL_SUCCESS;
87 } else {
88 dbg_printf("ERROR: tpm_transmit() returned %d\n", len);
89 *pdwReceiveBufLen = 0;
90 }
91
92 dbg_printf("pbReceiveBuf = ");
93 for (i = 0; i < (*pdwReceiveBufLen); i++)
94 dbg_printf("%02x ", pbReceiveBuf[i]);
95 dbg_printf("\n");
96
97 dbg_printf("<-- xTDDL_TransmitData()\n");
98
99 return rc;
100 }
OLDNEW
« no previous file with comments | « drivers/tpm/slb9635_i2c/tddl.h ('k') | drivers/tpm/slb9635_i2c/tpm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698