Index: lib/chromeos/tlcl_stub.c |
diff --git a/lib/chromeos/tlcl_stub.c b/lib/chromeos/tlcl_stub.c |
index c2136456a549b0de64ad5269f68de398634ea162..41769b2ae3919b00e66248c5c1d2cc31a8225b4c 100644 |
--- a/lib/chromeos/tlcl_stub.c |
+++ b/lib/chromeos/tlcl_stub.c |
@@ -1,7 +1,32 @@ |
/* |
- * Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
- * Use of this source code is governed by a BSD-style license that can be |
- * found in the LICENSE file. |
+ * 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.
|
+ * All rights reserved. |
+ * |
+ * Redistribution and use in source and binary forms, with or without |
+ * modification, are permitted provided that the following conditions are |
+ * met: |
+ * |
+ * * Redistributions of source code must retain the above copyright |
+ * notice, this list of conditions and the following disclaimer. |
+ * * Redistributions in binary form must reproduce the above |
+ * copyright notice, this list of conditions and the following disclaimer |
+ * in the documentation and/or other materials provided with the |
+ * distribution. |
+ * * Neither the name of Google Inc. nor the names of its |
+ * contributors may be used to endorse or promote products derived from |
+ * this software without specific prior written permission. |
+ * |
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* |
* Alternatively, this software may be distributed under the terms of the |
* GNU General Public License ("GPL") version 2 as published by the Free |
@@ -18,19 +43,34 @@ |
uint32_t TlclStubInit(void) |
{ |
#ifdef CONFIG_HARDWARE_TPM |
- return tpm_init(); |
-#else |
- return TPM_SUCCESS; |
+ int ret = tis_init(); |
+ if (ret) |
+ return TPM_E_IOERROR; |
+ /* tpm-lite lib doesn't call TlclOpenDevice after TlclStubInit */ |
+ ret = tis_open(); |
+ if (ret) |
+ return TPM_E_IOERROR; |
#endif |
+ return TPM_SUCCESS; |
} |
uint32_t TlclCloseDevice(void) |
{ |
+#ifdef CONFIG_HARDWARE_TPM |
+ int ret = tis_close(); |
+ if (ret) |
+ return TPM_E_IOERROR; |
+#endif |
return TPM_SUCCESS; |
} |
uint32_t TlclOpenDevice(void) |
{ |
+#ifdef CONFIG_HARDWARE_TPM |
+ int ret = tis_open(); |
+ if (ret) |
+ return TPM_E_IOERROR; |
+#endif |
return TPM_SUCCESS; |
} |
@@ -38,16 +78,12 @@ uint32_t TlclStubSendReceive(const uint8_t* request, int request_length, |
uint8_t* response, int max_length) |
{ |
#ifdef CONFIG_HARDWARE_TPM |
- int ret_code; |
- ret_code = tpm_send(request, request_length); |
- if (ret_code) |
+ int ret; |
+ size_t recv_len = (size_t) max_length; |
+ ret= tis_sendrecv(request, request_length, response, &recv_len); |
+ if (ret) |
return TPM_E_IOERROR; |
- ret_code = tpm_receive(response, max_length); |
- if (ret_code) |
- return TPM_E_IOERROR; |
- return TPM_SUCCESS; |
-#else |
- return TPM_SUCCESS; |
#endif |
+ return TPM_SUCCESS; |
} |