summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNamyoon Woo <namyoon@chromium.org>2018-12-04 13:16:42 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-12-13 06:43:35 -0800
commit8f13e78bae71940b6ad7c427611b52eddfb19287 (patch)
treee785680795894c4d4088e0d3c7d477a9a5bc4fee
parent80e6645b2d9876be58102c454cb0cf188f1d1eff (diff)
downloadchrome-ec-8f13e78bae71940b6ad7c427611b52eddfb19287.tar.gz
cr50: VENDOR_CC_IMMEDIATE_RESET may have a delay argument.
VENDOR_CC_IMMEDIATE_RESET has either uint16_t argument or none. The argument is a time delay in millisecond unit. If it has no argument, then Cr50 resets H1 immediately without any delay. BUG=b:120485010 BRANCH=cr50 TEST=none Change-Id: I33aaacbb0a0532aa84f39a8cd51d0d54fa2d281a Signed-off-by: Namyoon Woo <namyoon@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1361998 Commit-Ready: Joel Kitching <kitching@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
-rw-r--r--chip/g/post_reset.c45
-rw-r--r--include/tpm_vendor_cmds.h6
2 files changed, 45 insertions, 6 deletions
diff --git a/chip/g/post_reset.c b/chip/g/post_reset.c
index 24a98a9470..323cde05f3 100644
--- a/chip/g/post_reset.c
+++ b/chip/g/post_reset.c
@@ -7,12 +7,15 @@
#include "config.h"
#include "board.h"
#include "console.h"
+#include "endian.h"
#include "extension.h"
+#include "hooks.h"
#include "system.h"
+#include "util.h"
#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args)
-void post_reset_command_handler(void *body,
+static void post_reset_command_handler(void *body,
size_t cmd_size,
size_t *response_size)
{
@@ -20,20 +23,50 @@ void post_reset_command_handler(void *body,
((uint8_t *)body)[0] = 0;
post_reboot_request();
}
-
DECLARE_EXTENSION_COMMAND(EXTENSION_POST_RESET, post_reset_command_handler);
+static void deferred_reset(void)
+{
+ system_reset(SYSTEM_RESET_MANUALLY_TRIGGERED | SYSTEM_RESET_HARD);
+}
+DECLARE_DEFERRED(deferred_reset);
+
+#define MAX_REBOOT_TIMEOUT_MS 1000
+
static enum vendor_cmd_rc immediate_reset(enum vendor_cmd_cc code,
void *buf,
size_t input_size,
size_t *response_size)
{
- CPRINTS("%s: rebooting on host's request", __func__);
+ uint16_t timeout = 0;
+
+ *response_size = 0;
+ if (input_size) {
+ if (input_size != sizeof(uint16_t)) {
+ CPRINTS("%s: incorrect request size %d",
+ __func__, input_size);
+ return VENDOR_RC_BOGUS_ARGS;
+ }
+
+ /* Retrieve the requested timeout. */
+ memcpy(&timeout, buf, sizeof(timeout));
+ timeout = be16toh(timeout);
+
+ if (timeout > MAX_REBOOT_TIMEOUT_MS) {
+ CPRINTS("%s: incorrect timeout value %d",
+ __func__, timeout);
+ return VENDOR_RC_BOGUS_ARGS;
+ }
+ }
+
+ CPRINTS("%s: rebooting on host's request in %d ms", __func__, timeout);
cflush(); /* Let the console drain. */
- /* This will never return. */
- system_reset(SYSTEM_RESET_MANUALLY_TRIGGERED | SYSTEM_RESET_HARD);
- /* Never reached. */
+ if (timeout)
+ hook_call_deferred(&deferred_reset_data, timeout * MSEC);
+ else
+ deferred_reset();
+
return VENDOR_RC_SUCCESS;
}
DECLARE_VENDOR_COMMAND(VENDOR_CC_IMMEDIATE_RESET, immediate_reset);
diff --git a/include/tpm_vendor_cmds.h b/include/tpm_vendor_cmds.h
index 39ef3b8b57..499e2c3fa2 100644
--- a/include/tpm_vendor_cmds.h
+++ b/include/tpm_vendor_cmds.h
@@ -32,6 +32,12 @@ enum vendor_cmd_cc {
VENDOR_CC_GET_LOCK = 16,
VENDOR_CC_SET_LOCK = 17,
VENDOR_CC_SYSINFO = 18,
+ /*
+ * VENDOR_CC_IMMEDIATE_RESET may have an argument, which is a (uint16_t)
+ * time delay (in milliseconds) in doing a reset. Max value is 1000.
+ * The command may also be called without an argument, which will be
+ * regarded as zero time delay.
+ */
VENDOR_CC_IMMEDIATE_RESET = 19,
VENDOR_CC_INVALIDATE_INACTIVE_RW = 20,
VENDOR_CC_COMMIT_NVMEM = 21,