OLD | NEW |
(Empty) | |
| 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 |
| 3 * found in the LICENSE file. |
| 4 */ |
| 5 |
| 6 /* Test of early writing to the NVRAM. |
| 7 */ |
| 8 |
| 9 #include <stdio.h> |
| 10 #include <stdint.h> |
| 11 #include <stdlib.h> |
| 12 #include <tss/tcs.h> |
| 13 |
| 14 #include "tlcl.h" |
| 15 #include "utility.h" |
| 16 |
| 17 #define INDEX0 0xcafe |
| 18 |
| 19 int main(int argc, char** argv) { |
| 20 uint32_t perm; |
| 21 uint32_t result; |
| 22 uint32_t x; |
| 23 |
| 24 TlclLibInit(); |
| 25 TlclStartup(); |
| 26 TlclContinueSelfTest(); |
| 27 |
| 28 do { |
| 29 result = TlclAssertPhysicalPresence(); |
| 30 printf("result of AssertPP = %d\n", result); |
| 31 } while (result == TPM_E_DOING_SELFTEST || |
| 32 result == TPM_E_NEEDS_SELFTEST); |
| 33 |
| 34 if (result != TPM_SUCCESS) { |
| 35 error("AssertPP failed with error %d\n", result); |
| 36 } |
| 37 |
| 38 do { |
| 39 result = TlclRead(INDEX0, (uint8_t*) &x, sizeof(x)); |
| 40 printf("result of ReadValue = %d\n", result); |
| 41 } while (result == TPM_E_DOING_SELFTEST || |
| 42 result == TPM_E_NEEDS_SELFTEST); |
| 43 |
| 44 if (result == TPM_E_BADINDEX) { |
| 45 VBDEBUG(("creating INDEX0\n")); |
| 46 perm = TPM_NV_PER_PPWRITE; |
| 47 TlclDefineSpace(INDEX0, perm, sizeof(uint32_t)); |
| 48 } else if (result != TPM_SUCCESS) { |
| 49 error("Read failed with result %d\n", result); |
| 50 } |
| 51 |
| 52 printf("Test completed successfully\n"); |
| 53 exit(0); |
| 54 } |
OLD | NEW |