summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWei-Ning Huang <wnhuang@google.com>2017-05-05 05:26:52 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-05-06 19:52:29 -0700
commita5a3fa2d13b4b18f1244ae408a778c5e88130a6f (patch)
tree1a7cea4384f5dc5c4be53131b71d96794bc7baec
parente7969f8245a3cde164caf1fa03cfe655c7e61d1e (diff)
downloadchrome-ec-a5a3fa2d13b4b18f1244ae408a778c5e88130a6f.tar.gz
rwsig: add host command for controlling rwsig task
Add new host command EC_CMD_RWSIG_ACTION for controlling rwsig task. This allow us to make firmware stay at RO without toggling reset pin. flashrom can use this host command and removed the need to use any out-of-band pin to toggle the reset pin (and make RWSIG stay in RO). BRANCH=none BUG=b:37584134 TEST=on eve, `ectool --name=cros_tp rwsigaction abort` should prevent EC from jumpping to RW after RWSIG check. Change-Id: Ia435e4e3ea8ed612a1250d3bf755ca50e5db9d37 Signed-off-by: Wei-Ning Huang <wnhuang@google.com> Reviewed-on: https://chromium-review.googlesource.com/497787 Commit-Ready: Wei-Ning Huang <wnhuang@chromium.org> Tested-by: Wei-Ning Huang <wnhuang@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
-rw-r--r--common/rwsig.c22
-rw-r--r--include/ec_commands.h12
-rw-r--r--util/ectool.c22
3 files changed, 56 insertions, 0 deletions
diff --git a/common/rwsig.c b/common/rwsig.c
index efc8c03ee1..31174798a2 100644
--- a/common/rwsig.c
+++ b/common/rwsig.c
@@ -272,6 +272,28 @@ exit:
while (1)
task_wait_event(-1);
}
+
+int rwsig_cmd_action(struct host_cmd_handler_args *args)
+{
+ const struct ec_params_rwsig_action *p = args->params;
+
+ switch (p->action) {
+ case RWSIG_ACTION_ABORT:
+ rwsig_abort();
+ break;
+ case RWSIG_ACTION_CONTINUE:
+ rwsig_continue();
+ break;
+ default:
+ return EC_RES_INVALID_PARAM;
+ }
+ args->response_size = 0;
+ return EC_RES_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_CMD_RWSIG_ACTION,
+ rwsig_cmd_action,
+ EC_VER_MASK(0));
+
#else /* !HAS_TASK_RWSIG */
int rwsig_cmd_check_status(struct host_cmd_handler_args *args)
{
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 92d25945e4..f8f8306af9 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -4053,6 +4053,18 @@ struct __ec_align4 ec_response_rwsig_check_status {
uint32_t status;
};
+/* For controlling RWSIG task */
+#define EC_CMD_RWSIG_ACTION 0x011D
+
+enum rwsig_action {
+ RWSIG_ACTION_ABORT = 0, /* Abort RWSIG and prevent jumping */
+ RWSIG_ACTION_CONTINUE = 1, /* Jump to RW immediately */
+};
+
+struct __ec_align4 ec_params_rwsig_action {
+ uint32_t action;
+};
+
#endif /* !__ACPI__ */
/*****************************************************************************/
diff --git a/util/ectool.c b/util/ectool.c
index b7cde903ec..71f28969fd 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -208,6 +208,8 @@ const char help_str[] =
" Set real-time clock alarm to go off in <sec> seconds\n"
" rwhashpd <dev_id> <HASH[0] ... <HASH[4]>\n"
" Set entry in PD MCU's device rw_hash table.\n"
+ " rwsigaction\n"
+ " Control the behavior of RWSIG task.\n"
" rwsigstatus\n"
" Run RW signature verification and get status.\n"
" sertest\n"
@@ -1037,6 +1039,25 @@ int cmd_rwsig_status(int argc, char *argv[])
return 0;
}
+int cmd_rwsig_action(int argc, char *argv[])
+{
+ struct ec_params_rwsig_action req;
+
+ if (argc < 2) {
+ fprintf(stderr, "Usage: %s abort | continue\n", argv[0]);
+ return -1;
+ }
+
+ if (!strcasecmp(argv[1], "abort"))
+ req.action = RWSIG_ACTION_ABORT;
+ else if (!strcasecmp(argv[1], "continue"))
+ req.action = RWSIG_ACTION_CONTINUE;
+ else
+ return -1;
+
+ return ec_command(EC_CMD_RWSIG_ACTION, 0, &req, sizeof(req), NULL, 0);
+}
+
/**
* determine if in GFU mode or not.
*
@@ -7066,6 +7087,7 @@ const struct command commands[] = {
{"rtcset", cmd_rtc_set},
{"rtcsetalarm", cmd_rtc_set_alarm},
{"rwhashpd", cmd_rw_hash_pd},
+ {"rwsigaction", cmd_rwsig_action},
{"rwsigstatus", cmd_rwsig_status},
{"sertest", cmd_serial_test},
{"port80flood", cmd_port_80_flood},