OLD | NEW |
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 /* TPM Lightweight Command Library. | 6 /* TPM Lightweight Command Library. |
7 * | 7 * |
8 * A low-level library for interfacing to TPM hardware or an emulator. | 8 * A low-level library for interfacing to TPM hardware or an emulator. |
9 */ | 9 */ |
10 | 10 |
11 /* FIXME(gauravsh): | |
12 * NOTE: This file is copied over from | |
13 * src/platform/tpm_lite/src/tlcl/tlcl.h | |
14 * Ideally, we want to directly include it without having two maintain | |
15 * duplicate copies in sync. But in the current model, this is hard | |
16 * to do without breaking standalone compilation. | |
17 * Eventually tpm_lite should be moved into vboot_reference. | |
18 * | |
19 * FURTHER NOTE: The subset of TPM error codes relevant to verified boot | |
20 * (TPM_SUCCESS, etc.) are in tss_constants.h. A full list of TPM error codes | |
21 * are in /usr/include/tss/tpm_error.h, from the trousers package. | |
22 */ | |
23 | |
24 #ifndef TPM_LITE_TLCL_H_ | 11 #ifndef TPM_LITE_TLCL_H_ |
25 #define TPM_LITE_TLCL_H_ | 12 #define TPM_LITE_TLCL_H_ |
26 | 13 |
27 #include "sysincludes.h" | 14 #include "sysincludes.h" |
28 | 15 |
29 /* Call this first. | 16 /*****************************************************************************/ |
30 */ | 17 /* Functions to be implemented by the stub library */ |
31 void TlclLibInit(void); | 18 |
| 19 /* Initialize the stub library */ |
| 20 void TlclStubInit(void); |
32 | 21 |
33 /* Close and open the device. This is needed for running more complex commands | 22 /* Close and open the device. This is needed for running more complex commands |
34 * at user level, such as TPM_TakeOwnership, since the TPM device can be opened | 23 * at user level, such as TPM_TakeOwnership, since the TPM device can be opened |
35 * only by one process at a time. | 24 * only by one process at a time. |
36 */ | 25 */ |
37 void TlclCloseDevice(void); | 26 void TlclCloseDevice(void); |
38 void TlclOpenDevice(void); | 27 void TlclOpenDevice(void); |
39 | 28 |
40 /* Sends a TPM_Startup(ST_CLEAR). Note that this is a no-op for the emulator, | 29 void TlclStubSendReceive(uint8_t* request, int request_length, |
41 * because it runs this command during initialization. The TPM error code is | 30 uint8_t* response, int max_length); |
42 * returned (0 for success). | 31 |
| 32 /*****************************************************************************/ |
| 33 /* Functions implemented in tlcl.c */ |
| 34 |
| 35 /* Call this first. |
| 36 */ |
| 37 void TlclLibInit(void); |
| 38 |
| 39 |
| 40 /* Logs to stdout. Arguments like printf. |
| 41 */ |
| 42 void TlclLog(char* format, ...); |
| 43 |
| 44 /* Sets the log level. 0 is quietest. |
| 45 */ |
| 46 void TlclSetLogLevel(int level); |
| 47 |
| 48 /* Sends a TPM_Startup(ST_CLEAR). The TPM error code is returned (0 |
| 49 * for success). |
43 */ | 50 */ |
44 uint32_t TlclStartup(void); | 51 uint32_t TlclStartup(void); |
45 | 52 |
46 /* Run the self test. Note---this is synchronous. To run this in parallel | 53 /* Run the self test. Note---this is synchronous. To run this in parallel |
47 * with other firmware, use ContinueSelfTest. The TPM error code is returned. | 54 * with other firmware, use ContinueSelfTest. The TPM error code is returned. |
48 */ | 55 */ |
49 uint32_t TlclSelftestfull(void); | 56 uint32_t TlclSelftestfull(void); |
50 | 57 |
51 /* Runs the self test in the background. The TPM error code is returned. | 58 /* Runs the self test in the background. |
52 */ | 59 */ |
53 uint32_t TlclContinueSelfTest(void); | 60 uint32_t TlclContinueSelfTest(void); |
54 | 61 |
55 /* Defines a space with permission [perm]. [index] is the index for the space, | 62 /* Defines a space with permission [perm]. [index] is the index for the space, |
56 * [size] the usable data size. The TPM error code is returned. | 63 * [size] the usable data size. The TPM error code is returned. |
57 */ | 64 */ |
58 uint32_t TlclDefineSpace(uint32_t index, uint32_t perm, uint32_t size); | 65 uint32_t TlclDefineSpace(uint32_t index, uint32_t perm, uint32_t size); |
59 | 66 |
| 67 /* Defines a space with permission [perm]. [index] is the index for the space, |
| 68 * [size] the usable data size. Returns the TPM error code. |
| 69 */ |
| 70 uint32_t TlclDefineSpaceResult(uint32_t index, uint32_t perm, uint32_t size); |
| 71 |
60 /* Writes [length] bytes of [data] to space at [index]. The TPM error code is | 72 /* Writes [length] bytes of [data] to space at [index]. The TPM error code is |
61 * returned. | 73 * returned. |
62 */ | 74 */ |
63 uint32_t TlclWrite(uint32_t index, uint8_t *data, uint32_t length); | 75 uint32_t TlclWrite(uint32_t index, uint8_t *data, uint32_t length); |
64 | 76 |
65 /* Reads [length] bytes from space at [index] into [data]. The TPM error code | 77 /* Reads [length] bytes from space at [index] into [data]. The TPM error code |
66 * is returned. | 78 * is returned. |
67 */ | 79 */ |
68 uint32_t TlclRead(uint32_t index, uint8_t *data, uint32_t length); | 80 uint32_t TlclRead(uint32_t index, uint8_t *data, uint32_t length); |
69 | 81 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 /* Gets flags of interest. (Add more here as needed.) The TPM error code is | 123 /* Gets flags of interest. (Add more here as needed.) The TPM error code is |
112 * returned. | 124 * returned. |
113 */ | 125 */ |
114 uint32_t TlclGetFlags(uint8_t* disable, uint8_t* deactivated); | 126 uint32_t TlclGetFlags(uint8_t* disable, uint8_t* deactivated); |
115 | 127 |
116 /* Sets the bGlobalLock flag, which only a reboot can clear. The TPM error | 128 /* Sets the bGlobalLock flag, which only a reboot can clear. The TPM error |
117 * code is returned. | 129 * code is returned. |
118 */ | 130 */ |
119 uint32_t TlclSetGlobalLock(void); | 131 uint32_t TlclSetGlobalLock(void); |
120 | 132 |
| 133 /* Performs a TPM_Extend. |
| 134 */ |
| 135 uint32_t TlclExtend(int pcr_num, uint8_t* in_digest, uint8_t* out_digest); |
| 136 |
121 /* Gets the permission bits for the NVRAM space with |index|. | 137 /* Gets the permission bits for the NVRAM space with |index|. |
122 */ | 138 */ |
123 uint32_t TlclGetPermissions(uint32_t index, uint32_t* permissions); | 139 uint32_t TlclGetPermissions(uint32_t index, uint32_t* permissions); |
124 | 140 |
125 #endif /* TPM_LITE_TLCL_H_ */ | 141 #endif /* TPM_LITE_TLCL_H_ */ |
OLD | NEW |