| 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 <stdarg.h> |
| 15 #include <stdint.h> | 15 #include <stdint.h> |
| 16 #include <stdio.h> | 16 #include <stdio.h> |
| 17 #include <stdlib.h> | 17 #include <stdlib.h> |
| 18 | 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 POSSIBLY_UNUSED | |
| 30 static void error(const char *format, ...) { | |
| 31 va_list ap; | |
| 32 va_start(ap, format); | |
| 33 fprintf(stderr, "ERROR: "); | |
| 34 vfprintf(stderr, format, ap); | |
| 35 va_end(ap); | |
| 36 exit(1); | |
| 37 } | |
| 38 | |
| 39 /* Outputs a warning and continues. | |
| 40 */ | |
| 41 POSSIBLY_UNUSED | |
| 42 static void warning(const char *format, ...) { | |
| 43 va_list ap; | |
| 44 va_start(ap, format); | |
| 45 fprintf(stderr, "WARNING: "); | |
| 46 vfprintf(stderr, format, ap); | |
| 47 va_end(ap); | |
| 48 } | |
| 49 | |
| 50 #define assert(expr) do { if (!(expr)) { \ | |
| 51 error("assert fail: %s at %s:%d\n", \ | |
| 52 #expr, __FILE__, __LINE__); }} while(0) | |
| 53 | |
| 54 /* Call this first. | 19 /* Call this first. |
| 55 */ | 20 */ |
| 56 void TlclLibinit(void); | 21 void TlclLibinit(void); |
| 57 | 22 |
| 58 /* Sends a TPM_Startup(ST_CLEAR). Note that this is a no-op for the emulator, | 23 /* Sends a TPM_Startup(ST_CLEAR). Note that this is a no-op for the emulator, |
| 59 * because it runs this command during initialization. | 24 * because it runs this command during initialization. |
| 60 */ | 25 */ |
| 61 void TlclStartup(void); | 26 void TlclStartup(void); |
| 62 | 27 |
| 63 /* Run the self test. Note---this is synchronous. To run this in parallel | 28 /* Run the self test. Note---this is synchronous. To run this in parallel |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 75 |
| 111 /* Issues a PhysicalSetDeactivated. Pass 0 to activate. Returns result code. | 76 /* Issues a PhysicalSetDeactivated. Pass 0 to activate. Returns result code. |
| 112 */ | 77 */ |
| 113 int TlclPhysicalSetDeactivated(uint8_t flag); | 78 int TlclPhysicalSetDeactivated(uint8_t flag); |
| 114 | 79 |
| 115 /* Gets some permanent flags of interest. (Add more here as needed.) | 80 /* Gets some permanent flags of interest. (Add more here as needed.) |
| 116 */ | 81 */ |
| 117 int TlclGetFlags(uint8_t* disable, uint8_t* deactivated); | 82 int TlclGetFlags(uint8_t* disable, uint8_t* deactivated); |
| 118 | 83 |
| 119 #endif /* TPM_LITE_TLCL_H_ */ | 84 #endif /* TPM_LITE_TLCL_H_ */ |
| OLD | NEW |