summaryrefslogtreecommitdiff
path: root/utility
diff options
context:
space:
mode:
authorMattias Nissler <mnissler@chromium.org>2017-07-10 13:46:20 +0200
committerchrome-bot <chrome-bot@chromium.org>2017-07-18 00:32:48 -0700
commit2a7e9b84ac69c374112a13fd16fbf7cb996b78bf (patch)
tree3a3ddc06183f57bc31262fbc2456142f66cd4dae /utility
parent68466c6d0a6cf629b77972773f523118b9cbb7be (diff)
downloadvboot-2a7e9b84ac69c374112a13fd16fbf7cb996b78bf.tar.gz
Implement tpmc getversion command.stabilize-9756.B
This command exposes the vendor and TPM firmware version. BRANCH=none BUG=chromium:728130 TEST=Builds and tpmc getversion prints plausible results. Change-Id: Iec556a298e025e10bda00121b40a25d8dc3839d1 Reviewed-on: https://chromium-review.googlesource.com/565287 Commit-Ready: Mattias Nissler <mnissler@chromium.org> Tested-by: Mattias Nissler <mnissler@chromium.org> Reviewed-by: Jorge Lucangeli Obes <jorgelo@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org>
Diffstat (limited to 'utility')
-rw-r--r--utility/tlcl_generator.c16
-rw-r--r--utility/tpmc.c14
2 files changed, 30 insertions, 0 deletions
diff --git a/utility/tlcl_generator.c b/utility/tlcl_generator.c
index 7ed1d6c3..70ce5fd9 100644
--- a/utility/tlcl_generator.c
+++ b/utility/tlcl_generator.c
@@ -389,6 +389,21 @@ Command* BuildGetRandomCommand(void) {
return cmd;
}
+Command* BuildGetVersionValCommand(void) {
+ int size = (kTpmRequestHeaderLength +
+ sizeof(TPM_CAPABILITY_AREA) + /* capArea */
+ sizeof(uint32_t)); /* subCapSize */
+
+ Command* cmd = newCommand(TPM_ORD_GetCapability, size);
+ cmd->name = "tpm_getversionval_cmd";
+ AddInitializedField(cmd, kTpmRequestHeaderLength,
+ sizeof(TPM_CAPABILITY_AREA), TPM_CAP_GET_VERSION_VAL);
+ AddInitializedField(cmd, kTpmRequestHeaderLength +
+ sizeof(TPM_CAPABILITY_AREA),
+ sizeof(uint32_t), 0);
+ return cmd;
+}
+
/* Output the fields of a structure.
*/
void OutputFields(Field* fld) {
@@ -510,6 +525,7 @@ Command* (*builders[])(void) = {
BuildGetOwnershipCommand,
BuildGetRandomCommand,
BuildExtendCommand,
+ BuildGetVersionValCommand,
};
static void FreeFields(Field* fld) {
diff --git a/utility/tpmc.c b/utility/tpmc.c
index 1e4e3026..ae45ca1c 100644
--- a/utility/tpmc.c
+++ b/utility/tpmc.c
@@ -9,6 +9,7 @@
* for other errors.
*/
+#include <inttypes.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
@@ -456,6 +457,17 @@ static uint32_t HandlerSendRaw(void) {
return result;
}
+static uint32_t HandlerGetVersion(void) {
+ uint32_t vendor;
+ uint64_t firmware_version;
+ uint32_t result = TlclGetVersion(&vendor, &firmware_version);
+ if (result == 0) {
+ printf("vendor %08x\nfirmware_version %016" PRIx64 "\n",
+ vendor, firmware_version);
+ }
+ return result;
+}
+
#ifdef TPM2_MODE
static uint32_t HandlerDoNothingForTPM2(void) {
return 0;
@@ -534,6 +546,8 @@ command_record command_table[] = {
{ "savestate", "save", "execute TPM_SaveState", TlclSaveState },
{ "sendraw", "raw", "send a raw request and print raw response",
HandlerSendRaw },
+ { "getversion", "getver", "get TPM vendor and firmware version",
+ HandlerGetVersion },
};
static int n_commands = sizeof(command_table) / sizeof(command_table[0]);