summaryrefslogtreecommitdiff
path: root/utility
diff options
context:
space:
mode:
authorAndrey Pronin <apronin@chromium.org>2016-11-11 19:49:50 -0800
committerchrome-bot <chrome-bot@chromium.org>2016-11-15 17:42:28 -0800
commit2a77e0389598adf98783d16ff7f92013c190f27e (patch)
tree81e2dcb316000f0b78e36269f54aed431e5aba21 /utility
parent4ad42032f45c1a0e069e403adee62f6cc9abd309 (diff)
downloadvboot-2a77e0389598adf98783d16ff7f92013c190f27e.tar.gz
Add command for printing TPM version: 1.2 or 2.0. The command works even when trunksd/tcsd is running and /dev/tpm0 is busy, so it can be used to first determine which TPM we are dealing with, and then select the right name of the daemon to stop based on that. BUG=none BRANCH=none TEST=run 'tpmc tpmver' Change-Id: Ib8db81ff2af6dc6b0d5aecf30e2688a908b5c3d3 Reviewed-on: https://chromium-review.googlesource.com/410703 Commit-Ready: Andrey Pronin <apronin@chromium.org> Tested-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
Diffstat (limited to 'utility')
-rw-r--r--utility/tpmc.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/utility/tpmc.c b/utility/tpmc.c
index baddee65..1e4e3026 100644
--- a/utility/tpmc.c
+++ b/utility/tpmc.c
@@ -129,6 +129,11 @@ uint8_t ErrorCheck(uint32_t result, const char* cmd) {
/* Handler functions. These wouldn't exist if C had closures.
*/
+static uint32_t HandlerTpmVersion(void) {
+ puts(TPM_MODE_STRING);
+ return 0;
+}
+
/* TODO(apronin): stub for selected flags for TPM2 */
#ifdef TPM2_MODE
static uint32_t HandlerGetFlags(void) {
@@ -465,6 +470,8 @@ static uint32_t HandlerNotImplementedForTPM2(void) {
/* Table of TPM commands.
*/
command_record command_table[] = {
+ { "tpmversion", "tpmver", "print TPM version: 1.2 or 2.0",
+ HandlerTpmVersion },
{ "getflags", "getf", "read and print the value of selected flags",
HandlerGetFlags },
{ "startup", "sta", "issue a Startup command", TlclStartup },
@@ -559,6 +566,9 @@ int main(int argc, char* argv[]) {
}
return 0;
}
+ if (!strcmp(cmd, "tpmversion") || !strcmp(cmd, "tpmver")) {
+ return HandlerTpmVersion();
+ }
result = TlclLibInit();
if (result) {