summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2019-05-13 11:22:44 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-05-23 02:14:19 -0700
commit57aa1891be676b51fb43045a664f476d676948f1 (patch)
tree0255eb93cea8ddd8847cbc3c5b570a307501f14d
parent54a4479e64bb8caed335a38402af2bd46538777d (diff)
downloadchrome-ec-57aa1891be676b51fb43045a664f476d676948f1.tar.gz
flash_log: add vendor command, timestamp base accessor
The new vendor command allows to get and increase the flash log timestamp base. BRANCH=cr50, cr50-mp BUG=b:132287488 TEST=verified in the next patch in the series. Change-Id: Idc76012b7e7894b95cd70eeffeb50562a91b9656 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1610720 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Andrey Pronin <apronin@chromium.org> Reviewed-by: Namyoon Woo <namyoon@chromium.org>
-rw-r--r--common/flash_log_vc.c36
-rw-r--r--include/tpm_vendor_cmds.h2
2 files changed, 37 insertions, 1 deletions
diff --git a/common/flash_log_vc.c b/common/flash_log_vc.c
index 6f2ec6dd67..8ed85a57d4 100644
--- a/common/flash_log_vc.c
+++ b/common/flash_log_vc.c
@@ -5,6 +5,7 @@
#include "console.h"
#include "extension.h"
+#include "endian.h"
#include "flash_log.h"
#include "util.h"
@@ -17,7 +18,7 @@ static enum vendor_cmd_rc vc_pop_log_entry(enum vendor_cmd_cc code, void *buf,
*response_size = 0; /* In case there is an error. */
- if (input_size != sizeof(uint32_t))
+ if (input_size != sizeof(prev_timestamp))
return VENDOR_RC_BOGUS_ARGS;
memcpy(&prev_timestamp, buf, sizeof(prev_timestamp));
@@ -38,3 +39,36 @@ static enum vendor_cmd_rc vc_pop_log_entry(enum vendor_cmd_cc code, void *buf,
return VENDOR_RC_ERR;
}
DECLARE_VENDOR_COMMAND(VENDOR_CC_POP_LOG_ENTRY, vc_pop_log_entry);
+
+static enum vendor_cmd_rc vc_flog_tstamp(enum vendor_cmd_cc code, void *buf,
+ size_t input_size,
+ size_t *response_size)
+{
+ uint32_t tstamp;
+ enum ec_error_list rv;
+
+ if (!input_size) {
+ /* This is a request to report current flash log time. */
+ tstamp = htobe32(flash_log_get_tstamp());
+ memcpy(buf, &tstamp, sizeof(tstamp));
+ *response_size = sizeof(tstamp);
+ return VENDOR_RC_SUCCESS;
+ }
+
+ if (input_size != sizeof(tstamp))
+ return VENDOR_RC_BOGUS_ARGS;
+
+ memcpy(&tstamp, buf, sizeof(tstamp));
+ tstamp = be32toh(tstamp);
+ rv = flash_log_set_tstamp(tstamp);
+
+ if (rv == EC_SUCCESS) {
+ *response_size = 0;
+ return VENDOR_RC_SUCCESS;
+ }
+
+ *response_size = 1;
+ *((uint8_t *)buf) = (uint8_t)rv;
+ return VENDOR_RC_BOGUS_ARGS;
+}
+DECLARE_VENDOR_COMMAND(VENDOR_CC_FLOG_TIMESTAMP, vc_flog_tstamp);
diff --git a/include/tpm_vendor_cmds.h b/include/tpm_vendor_cmds.h
index 62db64e82a..0e17d9d53b 100644
--- a/include/tpm_vendor_cmds.h
+++ b/include/tpm_vendor_cmds.h
@@ -131,6 +131,8 @@ enum vendor_cmd_cc {
VENDOR_CC_U2F_SIGN = 45,
VENDOR_CC_U2F_ATTEST = 46,
+ VENDOR_CC_FLOG_TIMESTAMP = 47,
+
LAST_VENDOR_COMMAND = 65535,
};