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