1 /* Copyright (c) 2011 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 /* Testing: ForceClear and behavior of disable and permanent deactivated flags.
7 *
8 * ForceClear sets the permanent disable and deactivated flags to their default
9 * value of TRUE. The specs say nothing about STCLEAR flags, so they should be
10 * left alone. This test checks that both flags may be reset without a reboot,
11 * resulting in a fully enabled and activated TPM. (We know that because
12 * ForceClear requires that the TPM be enabled and activated to run.)
13 */
14
15 #include <stdio.h>
16
17 #include "host_common.h"
18 #include "tlcl.h"
19 #include "tlcl_tests.h"
20
main(int argc,char ** argv)21 int main(int argc, char** argv) {
22 uint8_t disable, deactivated;
23 int i;
24
25 TlclLibInit();
26 TPM_CHECK(TlclStartupIfNeeded());
27 TPM_CHECK(TlclSelfTestFull());
28 TPM_CHECK(TlclAssertPhysicalPresence());
29 TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
30 printf("disable is %d, deactivated is %d\n", disable, deactivated);
31
32 for (i = 0; i < 2; i++) {
33 TPM_CHECK(TlclForceClear());
34 TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
35 printf("disable is %d, deactivated is %d\n", disable, deactivated);
36 VbAssert(disable == 1 && deactivated == 1);
37 TPM_CHECK(TlclSetEnable());
38 TPM_CHECK(TlclSetDeactivated(0));
39 TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
40 printf("disable is %d, deactivated is %d\n", disable, deactivated);
41 VbAssert(disable == 0 && deactivated == 0);
42 }
43
44 printf("TEST SUCCEEDED\n");
45 return 0;
46 }
47