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 #ifndef TPM_LITE_TLCL_H_ | 11 #ifndef TPM_LITE_TLCL_H_ |
12 #define TPM_LITE_TLCL_H_ | 12 #define TPM_LITE_TLCL_H_ |
13 | 13 |
| 14 #include <stdarg.h> |
14 #include <stdint.h> | 15 #include <stdint.h> |
| 16 #include <stdio.h> |
| 17 #include <stdlib.h> |
| 18 |
| 19 #define POSSIBLY_UNUSED __attribute__((unused)) |
| 20 |
| 21 #ifdef __STRICT_ANSI__ |
| 22 #define INLINE |
| 23 #else |
| 24 #define INLINE inline |
| 25 #endif |
| 26 |
| 27 /* Outputs an error message and quits the program. |
| 28 */ |
| 29 static void error(const char *format, ...) { |
| 30 va_list ap; |
| 31 va_start(ap, format); |
| 32 fprintf(stderr, "ERROR: "); |
| 33 vfprintf(stderr, format, ap); |
| 34 va_end(ap); |
| 35 exit(1); |
| 36 } |
| 37 |
| 38 /* Outputs a warning and continues. |
| 39 */ |
| 40 POSSIBLY_UNUSED |
| 41 static void warning(const char *format, ...) { |
| 42 va_list ap; |
| 43 va_start(ap, format); |
| 44 fprintf(stderr, "WARNING: "); |
| 45 vfprintf(stderr, format, ap); |
| 46 va_end(ap); |
| 47 } |
| 48 |
| 49 #define assert(expr) do { if (!(expr)) { \ |
| 50 error("assert fail: %s at %s:%d\n", \ |
| 51 #expr, __FILE__, __LINE__); }} while(0) |
15 | 52 |
16 /* Call this first. | 53 /* Call this first. |
17 */ | 54 */ |
18 void TlclLibinit(void); | 55 void TlclLibinit(void); |
19 | 56 |
20 /* Sends a TPM_Startup(ST_CLEAR). Note that this is a no-op for the emulator, | 57 /* Sends a TPM_Startup(ST_CLEAR). Note that this is a no-op for the emulator, |
21 * because it runs this command during initialization. | 58 * because it runs this command during initialization. |
22 */ | 59 */ |
23 void TlclStartup(void); | 60 void TlclStartup(void); |
24 | 61 |
(...skipping 26 matching lines...) Expand all Loading... |
51 void TlclReadLock(uint32_t index); | 88 void TlclReadLock(uint32_t index); |
52 | 89 |
53 /* Asserts physical presence in software. | 90 /* Asserts physical presence in software. |
54 */ | 91 */ |
55 void TlclAssertPhysicalPresence(void); | 92 void TlclAssertPhysicalPresence(void); |
56 | 93 |
57 /* Sets the nvLocked bit. | 94 /* Sets the nvLocked bit. |
58 */ | 95 */ |
59 void TlclSetNvLocked(void); | 96 void TlclSetNvLocked(void); |
60 | 97 |
| 98 /* Returns 1 if the TPM is owned, 0 otherwise. |
| 99 */ |
| 100 int TlclIsOwned(void); |
| 101 |
61 #endif /* TPM_LITE_TLCL_H_ */ | 102 #endif /* TPM_LITE_TLCL_H_ */ |
OLD | NEW |