1 /* Copyright 2010 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 /* Create two spaces for uses in tests. OK if they already exist.
7 */
8
9 #include <stdio.h>
10 #include <stdint.h>
11 #include <stdlib.h>
12
13 #include "tlcl.h"
14 #include "tlcl_tests.h"
15
main(int argc,char ** argv)16 int main(int argc, char** argv) {
17 uint32_t perm;
18 uint32_t result;
19 uint32_t x;
20
21 TlclLibInit();
22
23 TPM_CHECK(TlclStartupIfNeeded());
24 TPM_CHECK(TlclSelfTestFull());
25 TPM_CHECK(TlclAssertPhysicalPresence());
26 TPM_CHECK(TlclForceClear());
27 TPM_CHECK(TlclSetEnable());
28 TPM_CHECK(TlclSetDeactivated(0));
29
30 result = TlclRead(INDEX0, (uint8_t*) &x, sizeof(x));
31 if (result == TPM_E_BADINDEX) {
32 perm = TPM_NV_PER_PPWRITE | TPM_NV_PER_GLOBALLOCK;
33 TPM_CHECK(TlclDefineSpace(INDEX0, perm, sizeof(uint32_t)));
34 }
35
36 result = TlclRead(INDEX1, (uint8_t*) &x, sizeof(x));
37 if (result == TPM_E_BADINDEX) {
38 perm = TPM_NV_PER_PPWRITE;
39 TPM_CHECK(TlclDefineSpace(INDEX1, perm, sizeof(uint32_t)));
40 }
41
42 printf("TEST SUCCEEDED\n");
43 exit(0);
44 }
45