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

Side by Side Diff: firmware/lib/tpm_lite/tlcl.c

Issue 3007036: Enable TPM in developer mode again. (Closed) Base URL: ssh://gitrw.chromium.org/vboot_reference.git
Patch Set: Fix unused var Created 10 years, 4 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
OLDNEW
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 */ 4 */
5 5
6 /* A lightweight TPM command library. 6 /* A lightweight TPM command library.
7 * 7 *
8 * The general idea is that TPM commands are array of bytes whose 8 * The general idea is that TPM commands are array of bytes whose
9 * fields are mostly compile-time constant. The goal is to build much 9 * fields are mostly compile-time constant. The goal is to build much
10 * of the commands at compile time (or build time) and change some of 10 * of the commands at compile time (or build time) and change some of
11 * the fields at run time as needed. The code in 11 * the fields at run time as needed. The code in
12 * utility/tlcl_generator.c builds structures containing the commands, 12 * utility/tlcl_generator.c builds structures containing the commands,
13 * as well as the offsets of the fields that need to be set at run 13 * as well as the offsets of the fields that need to be set at run
14 * time. 14 * time.
15 */ 15 */
16 16
17 #include "sysincludes.h" 17 #include "sysincludes.h"
18 #include "tlcl.h" 18 #include "tlcl.h"
19 #include "tlcl_internal.h" 19 #include "tlcl_internal.h"
20 #include "tlcl_structures.h" 20 #include "tlcl_structures.h"
21 #include "tss_constants.h" 21 #include "tss_constants.h"
22 #include "utility.h" 22 #include "utility.h"
23 23
24 #define EXTRA_LOGGING 0
25
26 #if EXTRA_LOGGING
27 #include <stdio.h>
28 #endif
29
30 /* Sets the size field of a TPM command. */ 24 /* Sets the size field of a TPM command. */
31 static INLINE void SetTpmCommandSize(uint8_t* buffer, uint32_t size) { 25 static INLINE void SetTpmCommandSize(uint8_t* buffer, uint32_t size) {
32 ToTpmUint32(buffer + sizeof(uint16_t), size); 26 ToTpmUint32(buffer + sizeof(uint16_t), size);
33 } 27 }
34 28
35 /* Gets the size field of a TPM command. */ 29 /* Gets the size field of a TPM command. */
36 POSSIBLY_UNUSED static INLINE int TpmCommandSize(const uint8_t* buffer) { 30 POSSIBLY_UNUSED static INLINE int TpmCommandSize(const uint8_t* buffer) {
37 uint32_t size; 31 uint32_t size;
38 FromTpmUint32(buffer + sizeof(uint16_t), &size); 32 FromTpmUint32(buffer + sizeof(uint16_t), &size);
39 return (int) size; 33 return (int) size;
(...skipping 20 matching lines...) Expand all
60 VBDEBUG(("TPM: command 0x%x failed: 0x%x\n", command, result)); 54 VBDEBUG(("TPM: command 0x%x failed: 0x%x\n", command, result));
61 else 55 else
62 error("TPM: command 0x%x failed: 0x%x\n", command, result); 56 error("TPM: command 0x%x failed: 0x%x\n", command, result);
63 } 57 }
64 } 58 }
65 59
66 /* Sends a TPM command and gets a response. */ 60 /* Sends a TPM command and gets a response. */
67 static void TlclSendReceive(uint8_t* request, uint8_t* response, 61 static void TlclSendReceive(uint8_t* request, uint8_t* response,
68 int max_length) { 62 int max_length) {
69 63
70 #if EXTRA_LOGGING 64 #ifdef EXTRA_LOGGING
semenzato 2010/08/05 19:50:53 We should do something about VBDEBUG when compilin
71 printf("command: %x%x %x%x%x%x %x%x%x%x\n", 65 VBDEBUG(("TPM: command: %x%x %x%x%x%x %x%x%x%x\n",
72 request[0], request[1], 66 request[0], request[1],
73 request[2], request[3], request[4], request[5], 67 request[2], request[3], request[4], request[5],
74 request[6], request[7], request[8], request[9]); 68 request[6], request[7], request[8], request[9]));
75 #endif 69 #endif
70
76 TlclStubSendReceive(request, TpmCommandSize(request), 71 TlclStubSendReceive(request, TpmCommandSize(request),
77 response, max_length); 72 response, max_length);
78 #if EXTRA_LOGGING 73
79 printf("response: %x%x %x%x%x%x %x%x%x%x\n", 74 #ifdef EXTRA_LOGGING
80 response[0], response[1], 75 VBDEBUG(("TPM: response: %x%x %x%x%x%x %x%x%x%x\n",
81 response[2], response[3], response[4], response[5], 76 response[0], response[1],
82 response[6], response[7], response[8], response[9]); 77 response[2], response[3], response[4], response[5],
78 response[6], response[7], response[8], response[9]));
83 #endif 79 #endif
84 80
85 #ifdef VBOOT_DEBUG 81 #ifdef VBOOT_DEBUG
86 { 82 {
87 int command = TpmCommandCode(request); 83 int command = TpmCommandCode(request);
88 int result = TpmReturnCode(response); 84 int result = TpmReturnCode(response);
89 VBDEBUG(("TPM: command 0x%x returned 0x%x\n", command, result)); 85 VBDEBUG(("TPM: command 0x%x returned 0x%x\n", command, result));
90 } 86 }
91 #endif 87 #endif
92 } 88 }
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 ToTpmUint32(cmd.buffer + tpm_getpermissions_cmd.index, index); 288 ToTpmUint32(cmd.buffer + tpm_getpermissions_cmd.index, index);
293 TlclSendReceive(cmd.buffer, response, sizeof(response)); 289 TlclSendReceive(cmd.buffer, response, sizeof(response));
294 result = TpmReturnCode(response); 290 result = TpmReturnCode(response);
295 if (result != TPM_SUCCESS) { 291 if (result != TPM_SUCCESS) {
296 return result; 292 return result;
297 } 293 }
298 nvdata = response + kTpmResponseHeaderLength + sizeof(size); 294 nvdata = response + kTpmResponseHeaderLength + sizeof(size);
299 FromTpmUint32(nvdata + kNvDataPublicPermissionsOffset, permissions); 295 FromTpmUint32(nvdata + kNvDataPublicPermissionsOffset, permissions);
300 return result; 296 return result;
301 } 297 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698