xref: /aosp_15_r20/external/vboot_reference/tests/tpm_lite/tpmtest_enable.c (revision 8617a60d3594060b7ecbd21bc622a7c14f3cf2bc)
1 /* Copyright 2011 The ChromiumOS Authors
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: ownership testing code, ForceClear, and nvram write limit.
7  */
8 
9 #include <stdio.h>
10 
11 #include "2common.h"
12 #include "host_common.h"
13 #include "tlcl.h"
14 #include "tlcl_tests.h"
15 
16 
main(int argc,char ** argv)17 int main(int argc, char** argv) {
18 	uint8_t disable, deactivated;
19 
20 	TlclLibInit();
21 	TPM_CHECK(TlclStartupIfNeeded());
22 	TPM_CHECK(TlclSelfTestFull());
23 	TPM_CHECK(TlclAssertPhysicalPresence());
24 	TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
25 	printf("disable is %d, deactivated is %d\n", disable, deactivated);
26 	TPM_CHECK(TlclSetEnable());
27 	TPM_CHECK(TlclSetDeactivated(0));
28 	TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL));
29 	printf("disable is %d, deactivated is %d\n", disable, deactivated);
30 	if (disable == 1 || deactivated == 1) {
31 		VB2_DEBUG("failed to enable or activate");
32 		return 1;
33 	}
34 	printf("TEST SUCCEEDED\n");
35 	return 0;
36 }
37