| 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 * Temporary fix for running the TPM selftest and other essential | 5 * Temporary fix for running the TPM selftest and other essential |
| 6 * intializations that we forgot to put in the BIOS. | 6 * intializations that we forgot to put in the BIOS. |
| 7 * | 7 * |
| 8 * This works in a very specific situation: we assume TPM_Startup has been | 8 * This works in a very specific situation: we assume TPM_Startup has been |
| 9 * executed, but we don't know if the self test has run. On a ST TPM version | 9 * executed, but we don't know if the self test has run. On a ST TPM version |
| 10 * 1.2.7.0, GetCapabilities fails before the self test has run, so we use that | 10 * 1.2.7.0, GetCapabilities fails before the self test has run, so we use that |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 #include "tlcl.h" | 23 #include "tlcl.h" |
| 24 | 24 |
| 25 int main(int argc, char* argv[]) { | 25 int main(int argc, char* argv[]) { |
| 26 uint32_t result; | 26 uint32_t result; |
| 27 uint8_t disable, deactivated; | 27 uint8_t disable, deactivated; |
| 28 int pri = LOG_USER | LOG_ERR; | 28 int pri = LOG_USER | LOG_ERR; |
| 29 | 29 |
| 30 TlclLibInit(); | 30 TlclLibInit(); |
| 31 TlclStartup(); /* ignore result */ | 31 TlclStartup(); /* ignore result */ |
| 32 |
| 33 /* On the dogfood device, GetFlags causes an assertion failure because the |
| 34 * device uses an older TPM which is not compatible with the current spec. |
| 35 * We take advantage of this to cause the program to exit and not run the |
| 36 * self test again (which takes 1 second). |
| 37 */ |
| 32 result = TlclGetFlags(NULL, NULL, NULL); | 38 result = TlclGetFlags(NULL, NULL, NULL); |
| 39 |
| 40 result = TlclSelfTestFull(); |
| 33 if (result != 0) { | 41 if (result != 0) { |
| 34 result = TlclSelfTestFull(); | 42 syslog(pri, "TPM selftest failed with code 0x%x\n", result); |
| 35 if (result != 0) { | 43 printf("fail\n"); |
| 36 syslog(pri, "TPM selftest failed with code 0x%x\n", result); | 44 return 0; |
| 37 printf("fail\n"); | |
| 38 return 0; | |
| 39 } | |
| 40 } | 45 } |
| 46 |
| 41 /* Optional one-time enabling of TPM. */ | 47 /* Optional one-time enabling of TPM. */ |
| 42 result = TlclAssertPhysicalPresence(); | 48 result = TlclAssertPhysicalPresence(); |
| 43 if (result != 0) { | 49 if (result != 0) { |
| 44 syslog(pri, "TPM assertpp failed with code 0x%x\n", result); | 50 syslog(pri, "TPM assertpp failed with code 0x%x\n", result); |
| 45 printf("fail\n"); | 51 printf("fail\n"); |
| 46 return 0; | 52 return 0; |
| 47 } | 53 } |
| 48 result = TlclGetFlags(&disable, &deactivated, NULL); | 54 result = TlclGetFlags(&disable, &deactivated, NULL); |
| 49 if (result != 0) { | 55 if (result != 0) { |
| 50 syslog(pri, "TPM getflags failed with code 0x%x\n", result); | 56 syslog(pri, "TPM getflags failed with code 0x%x\n", result); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 65 syslog(pri, "TPM physical activate failed with code 0x%x\n", result); | 71 syslog(pri, "TPM physical activate failed with code 0x%x\n", result); |
| 66 printf("fail\n"); | 72 printf("fail\n"); |
| 67 } else { | 73 } else { |
| 68 printf("reboot\n"); | 74 printf("reboot\n"); |
| 69 } | 75 } |
| 70 return 0; /* needs reboot */ | 76 return 0; /* needs reboot */ |
| 71 } | 77 } |
| 72 printf("success\n"); | 78 printf("success\n"); |
| 73 return 0; | 79 return 0; |
| 74 } | 80 } |
| OLD | NEW |