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): | 11 /* FIXME(gauravsh): |
12 * NOTE: This file is copied over from | 12 * NOTE: This file is copied over from |
13 * src/platform/tpm_lite/src/tlcl/tlcl.h | 13 * src/platform/tpm_lite/src/tlcl/tlcl.h |
14 * Ideally, we want to directly include it without having two maintain | 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 | 15 * duplicate copies in sync. But in the current model, this is hard |
16 * to do without breaking standalone compilation. | 16 * to do without breaking standalone compilation. |
17 * Eventually tpm_lite should be moved into vboot_reference. | 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. |
18 */ | 22 */ |
19 | 23 |
20 #ifndef TPM_LITE_TLCL_H_ | 24 #ifndef TPM_LITE_TLCL_H_ |
21 #define TPM_LITE_TLCL_H_ | 25 #define TPM_LITE_TLCL_H_ |
22 | 26 |
23 #include <stdarg.h> | 27 #include <stdarg.h> |
24 #include <stdint.h> | 28 #include <stdint.h> |
25 #include <stdio.h> | 29 #include <stdio.h> |
26 #include <stdlib.h> | 30 #include <stdlib.h> |
27 | 31 |
28 /* Call this first. | 32 /* Call this first. |
29 */ | 33 */ |
30 void TlclLibinit(void); | 34 void TlclLibInit(void); |
31 | 35 |
32 /* Sends a TPM_Startup(ST_CLEAR). Note that this is a no-op for the emulator, | 36 /* Sends a TPM_Startup(ST_CLEAR). Note that this is a no-op for the emulator, |
33 * because it runs this command during initialization. | 37 * because it runs this command during initialization. The TPM error code is |
| 38 * returned (0 for success). |
34 */ | 39 */ |
35 void TlclStartup(void); | 40 uint32_t TlclStartup(void); |
36 | 41 |
37 /* Run the self test. Note---this is synchronous. To run this in parallel | 42 /* Run the self test. Note---this is synchronous. To run this in parallel |
38 * with other firmware, use ContinueSelfTest. | 43 * with other firmware, use ContinueSelfTest. The TPM error code is returned. |
39 */ | 44 */ |
40 void TlclSelftestfull(void); | 45 uint32_t TlclSelftestfull(void); |
| 46 |
| 47 /* Runs the self test in the background. The TPM error code is returned. |
| 48 */ |
| 49 uint32_t TlclContinueSelfTest(void); |
41 | 50 |
42 /* Defines a space with permission [perm]. [index] is the index for the space, | 51 /* Defines a space with permission [perm]. [index] is the index for the space, |
43 * [size] the usable data size. Errors are ignored. | 52 * [size] the usable data size. The TPM error code is returned. |
44 */ | 53 */ |
45 void TlclDefineSpace(uint32_t index, uint32_t perm, uint32_t size); | 54 uint32_t TlclDefineSpace(uint32_t index, uint32_t perm, uint32_t size); |
46 | 55 |
47 /* Writes [length] bytes of [data] to space at [index]. The TPM error code is | 56 /* Writes [length] bytes of [data] to space at [index]. The TPM error code is |
48 * returned (0 for success). | 57 * returned. |
49 */ | 58 */ |
50 uint32_t TlclWrite(uint32_t index, uint8_t *data, uint32_t length); | 59 uint32_t TlclWrite(uint32_t index, uint8_t *data, uint32_t length); |
51 | 60 |
52 /* Reads [length] bytes from space at [index] into [data]. The TPM error code | 61 /* Reads [length] bytes from space at [index] into [data]. The TPM error code |
53 * is returned (0 for success). | 62 * is returned. |
54 */ | 63 */ |
55 uint32_t TlclRead(uint32_t index, uint8_t *data, uint32_t length); | 64 uint32_t TlclRead(uint32_t index, uint8_t *data, uint32_t length); |
56 | 65 |
57 /* Write-locks space at [index]. | 66 /* Write-locks space at [index]. The TPM error code is returned. |
58 */ | 67 */ |
59 void TlclWriteLock(uint32_t index); | 68 uint32_t TlclWriteLock(uint32_t index); |
60 | 69 |
61 /* Read-locks space at [index]. | 70 /* Read-locks space at [index]. The TPM error code is returned. |
62 */ | 71 */ |
63 void TlclReadLock(uint32_t index); | 72 uint32_t TlclReadLock(uint32_t index); |
64 | 73 |
65 /* Asserts physical presence in software. | 74 /* Asserts physical presence in software. The TPM error code is returned. |
66 */ | 75 */ |
67 void TlclAssertPhysicalPresence(void); | 76 uint32_t TlclAssertPhysicalPresence(void); |
68 | 77 |
69 /* Turns off physical presence and locks it off until next reboot. | 78 /* Turns off physical presence and locks it off until next reboot. The TPM |
| 79 * error code is returned. |
70 */ | 80 */ |
71 uint32_t TlclLockPhysicalPresence(void); | 81 uint32_t TlclLockPhysicalPresence(void); |
72 | 82 |
73 /* Sets the nvLocked bit. | 83 /* Sets the nvLocked bit. The TPM error code is returned. |
74 */ | 84 */ |
75 void TlclSetNvLocked(void); | 85 uint32_t TlclSetNvLocked(void); |
76 | 86 |
77 /* Returns 1 if the TPM is owned, 0 otherwise. | 87 /* Returns 1 if the TPM is owned, 0 otherwise. |
78 */ | 88 */ |
79 int TlclIsOwned(void); | 89 int TlclIsOwned(void); |
80 | 90 |
81 /* Issues a ForceClear. | 91 /* Issues a ForceClear. The TPM error code is returned. |
82 */ | 92 */ |
83 void TlclForceClear(void); | 93 uint32_t TlclForceClear(void); |
84 | 94 |
85 /* Issues a SetEnable. | 95 /* Issues a SetEnable. The TPM error code is returned. |
86 */ | 96 */ |
87 void TlclSetEnable(void); | 97 uint32_t TlclSetEnable(void); |
88 | 98 |
89 /* Issues a SetDeactivated. Pass 0 to activate. Returns result code. | 99 /* Issues a SetDeactivated. Pass 0 to activate. Returns result code. |
90 */ | 100 */ |
91 int TlclSetDeactivated(uint8_t flag); | 101 uint32_t TlclSetDeactivated(uint8_t flag); |
92 | 102 |
93 /* Gets some permanent flags of interest. (Add more here as needed.) | 103 /* Gets flags of interest. (Add more here as needed.) The TPM error code is |
| 104 * returned. |
94 */ | 105 */ |
95 int TlclGetFlags(uint8_t* disable, uint8_t* deactivated); | 106 uint32_t TlclGetFlags(uint8_t* disable, uint8_t* deactivated); |
96 | 107 |
97 /* Sets the bGlobalLock flag, which only a reboot can clear. | 108 /* Sets the bGlobalLock flag, which only a reboot can clear. The TPM error |
| 109 * code is returned. |
98 */ | 110 */ |
99 uint32_t TlclSetGlobalLock(void); | 111 uint32_t TlclSetGlobalLock(void); |
100 | 112 |
101 #endif /* TPM_LITE_TLCL_H_ */ | 113 #endif /* TPM_LITE_TLCL_H_ */ |
OLD | NEW |