diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2019-05-13 11:22:44 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-05-23 02:14:19 -0700 |
commit | 57aa1891be676b51fb43045a664f476d676948f1 (patch) | |
tree | 0255eb93cea8ddd8847cbc3c5b570a307501f14d /common | |
parent | 54a4479e64bb8caed335a38402af2bd46538777d (diff) | |
download | chrome-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>
Diffstat (limited to 'common')
-rw-r--r-- | common/flash_log_vc.c | 36 |
1 files changed, 35 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); |