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

Unified Diff: tests/tpm_lite/writelimit.c

Issue 2919010: Add tpm lite to vboot reference (Closed) Base URL: ssh://gitrw.chromium.org/vboot_reference.git
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/tpm_lite/spaceperm.c ('k') | utility/Makefile » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/tpm_lite/writelimit.c
diff --git a/tests/tpm_lite/writelimit.c b/tests/tpm_lite/writelimit.c
new file mode 100644
index 0000000000000000000000000000000000000000..5daef76b63cb86d3e44c73b39117099bf0a9fae2
--- /dev/null
+++ b/tests/tpm_lite/writelimit.c
@@ -0,0 +1,61 @@
+/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Test of recovery when we hit the NVRAM write limit for an unowned TPM.
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <tss/tcs.h>
+
+#include "tlcl.h"
+#include "utility.h"
+
+#define INDEX0 0xda70
+#define TPM_MAX_NV_WRITES_NOOWNER 64
+
+int main(int argc, char** argv) {
+ int i;
+ uint32_t result;
+ uint8_t disable, deactivated; /* the TPM specs use these exact names */
+
+ TlclLibInit();
+
+ TlclStartup();
+ TlclSelftestfull();
+
+ TlclAssertPhysicalPresence();
+
+ result = TlclGetFlags(&disable, &deactivated);
+ printf("disable is %d, deactivated is %d\n", disable, deactivated);
+
+ if (disable || deactivated) {
+ TlclSetEnable();
+ (void) TlclSetDeactivated(0);
+ printf("TPM will be active after next reboot\n");
+ exit(0);
+ }
+
+ for (i = 0; i < TPM_MAX_NV_WRITES_NOOWNER + 2; i++) {
+ printf("writing %d\n", i);
+ if ((result = TlclWrite(INDEX0, (uint8_t*)&i, sizeof(i))) != TPM_SUCCESS) {
+ switch (result) {
+ case TPM_E_MAXNVWRITES:
+ printf("Max NV writes exceeded - forcing clear\n");
+ TlclForceClear();
+ printf("Please reboot and run this program again\n");
+ exit(0);
+ default:
+ error("unexpected error code %d (0x%x)\n");
+ }
+ }
+ }
+
+ /* Done for now.
+ */
+ printf("Test completed successfully\n");
+ exit(0);
+}
« no previous file with comments | « tests/tpm_lite/spaceperm.c ('k') | utility/Makefile » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698