Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: tests/tpm_lite/writelimit.c

Issue 3041005: Add lots of debugging to TPM library. (Closed) Base URL: ssh://gitrw.chromium.org/vboot_reference.git
Patch Set: Fix TPM unit tests Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/tpm_lite/redefine.c ('k') | utility/load_kernel_test.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 recovery when we hit the NVRAM write limit for an unowned TPM. 6 /* Test of recovery when we hit the NVRAM write limit for an unowned TPM.
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 #include <tss/tcs.h> 12 #include <tss/tcs.h>
13 13
14 #include "tlcl.h" 14 #include "tlcl.h"
15 #include "utility.h" 15 #include "utility.h"
16 16
17 #define INDEX0 0xda70 17 #define INDEX0 0xda70
18 #define TPM_MAX_NV_WRITES_NOOWNER 64 18 #define TPM_MAX_NV_WRITES_NOOWNER 64
19 19
20 int main(int argc, char** argv) { 20 int main(int argc, char** argv) {
21 int i; 21 int i;
22 uint32_t result; 22 uint32_t result;
23 uint8_t disable, deactivated; /* the TPM specs use these exact names */ 23 uint8_t disable, deactivated; /* the TPM specs use these exact names */
24 24
25 TlclLibInit(); 25 TlclLibInit();
26 26
27 TlclStartup(); 27 TlclStartup();
28 TlclSelftestfull(); 28 TlclSelfTestFull();
29 29
30 TlclAssertPhysicalPresence(); 30 TlclAssertPhysicalPresence();
31 31
32 result = TlclGetFlags(&disable, &deactivated); 32 result = TlclGetFlags(&disable, &deactivated, NULL);
33 printf("disable is %d, deactivated is %d\n", disable, deactivated); 33 printf("disable is %d, deactivated is %d\n", disable, deactivated);
34 34
35 if (disable || deactivated) { 35 if (disable || deactivated) {
36 TlclSetEnable(); 36 TlclSetEnable();
37 (void) TlclSetDeactivated(0); 37 (void) TlclSetDeactivated(0);
38 printf("TPM will be active after next reboot\n"); 38 printf("TPM will be active after next reboot\n");
39 exit(0); 39 exit(0);
40 } 40 }
41 41
42 for (i = 0; i < TPM_MAX_NV_WRITES_NOOWNER + 2; i++) { 42 for (i = 0; i < TPM_MAX_NV_WRITES_NOOWNER + 2; i++) {
43 printf("writing %d\n", i); 43 printf("writing %d\n", i);
44 if ((result = TlclWrite(INDEX0, (uint8_t*)&i, sizeof(i))) != TPM_SUCCESS) { 44 if ((result = TlclWrite(INDEX0, (uint8_t*)&i, sizeof(i))) != TPM_SUCCESS) {
45 switch (result) { 45 switch (result) {
46 case TPM_E_MAXNVWRITES: 46 case TPM_E_MAXNVWRITES:
47 printf("Max NV writes exceeded - forcing clear\n"); 47 printf("Max NV writes exceeded - forcing clear\n");
48 TlclForceClear(); 48 TlclForceClear();
49 printf("Please reboot and run this program again\n"); 49 printf("Please reboot and run this program again\n");
50 exit(0); 50 exit(0);
51 default: 51 default:
52 error("unexpected error code %d (0x%x)\n"); 52 error("unexpected error code %d (0x%x)\n");
53 } 53 }
54 } 54 }
55 } 55 }
56 56
57 /* Done for now. 57 /* Done for now.
58 */ 58 */
59 printf("Test completed successfully\n"); 59 printf("Test completed successfully\n");
60 exit(0); 60 exit(0);
61 } 61 }
OLDNEW
« no previous file with comments | « tests/tpm_lite/redefine.c ('k') | utility/load_kernel_test.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698