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

Side by Side Diff: lib/chromeos/tlcl_stub.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
« drivers/tpm/slb9635_i2c/ifx_v03.c ('K') | « include/tpm.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 2 * Copyright 2010, Google Inc.
Che-Liang Chiou 2011/03/14 08:49:54 Please use "chromium os authors..." copyright head
rongchang 2011/03/23 11:44:57 Done.
3 * Use of this source code is governed by a BSD-style license that can be 3 * All rights reserved.
4 * found in the LICENSE file. 4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5 * 30 *
6 * Alternatively, this software may be distributed under the terms of the 31 * Alternatively, this software may be distributed under the terms of the
7 * GNU General Public License ("GPL") version 2 as published by the Free 32 * GNU General Public License ("GPL") version 2 as published by the Free
8 * Software Foundation. 33 * Software Foundation.
9 */ 34 */
10 35
11 #include <config.h> 36 #include <config.h>
12 #include <common.h> 37 #include <common.h>
13 #include <tlcl_stub.h> 38 #include <tlcl_stub.h>
14 #include <tpm.h> 39 #include <tpm.h>
15 40
16 /* A simple TPM library implementation for now */ 41 /* A simple TPM library implementation for now */
17 42
18 uint32_t TlclStubInit(void) 43 uint32_t TlclStubInit(void)
19 { 44 {
20 #ifdef CONFIG_HARDWARE_TPM 45 #ifdef CONFIG_HARDWARE_TPM
21 » return tpm_init(); 46 » int ret = tis_init();
22 #else 47 » if (ret)
48 » » return TPM_E_IOERROR;
49 » /* tpm-lite lib doesn't call TlclOpenDevice after TlclStubInit */
50 » ret = tis_open();
51 » if (ret)
52 » » return TPM_E_IOERROR;
53 #endif
23 return TPM_SUCCESS; 54 return TPM_SUCCESS;
24 #endif
25 } 55 }
26 56
27 uint32_t TlclCloseDevice(void) 57 uint32_t TlclCloseDevice(void)
28 { 58 {
59 #ifdef CONFIG_HARDWARE_TPM
60 int ret = tis_close();
61 if (ret)
62 return TPM_E_IOERROR;
63 #endif
29 return TPM_SUCCESS; 64 return TPM_SUCCESS;
30 } 65 }
31 66
32 uint32_t TlclOpenDevice(void) 67 uint32_t TlclOpenDevice(void)
33 { 68 {
69 #ifdef CONFIG_HARDWARE_TPM
70 int ret = tis_open();
71 if (ret)
72 return TPM_E_IOERROR;
73 #endif
34 return TPM_SUCCESS; 74 return TPM_SUCCESS;
35 } 75 }
36 76
37 uint32_t TlclStubSendReceive(const uint8_t* request, int request_length, 77 uint32_t TlclStubSendReceive(const uint8_t* request, int request_length,
38 uint8_t* response, int max_length) 78 uint8_t* response, int max_length)
39 { 79 {
40 #ifdef CONFIG_HARDWARE_TPM 80 #ifdef CONFIG_HARDWARE_TPM
41 » int ret_code; 81 » int ret;
42 » ret_code = tpm_send(request, request_length); 82 » size_t recv_len = (size_t) max_length;
43 » if (ret_code) 83 » ret= tis_sendrecv(request, request_length, response, &recv_len);
84 » if (ret)
44 return TPM_E_IOERROR; 85 return TPM_E_IOERROR;
45 » ret_code = tpm_receive(response, max_length); 86 #endif
46 » if (ret_code)
47 » » return TPM_E_IOERROR;
48 return TPM_SUCCESS; 87 return TPM_SUCCESS;
49 #else
50 return TPM_SUCCESS;
51 #endif
52 } 88 }
53 89
OLDNEW
« drivers/tpm/slb9635_i2c/ifx_v03.c ('K') | « include/tpm.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698