summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2018-01-10 11:34:31 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2018-02-01 00:48:19 +0000
commit7e35f6e9579e57bc0c100c7fe1979220356795aa (patch)
tree79bed93f4c21990d4a8ca22560fda63bca5804f7
parenta51551f4da4aeb4c7daf780c522afe3294697592 (diff)
downloadchrome-ec-7e35f6e9579e57bc0c100c7fe1979220356795aa.tar.gz
ccd: 'pp polling' vendor command option
When implementing 'ccd open' and 'ccd unlock' through gsctool, we need to be able to pass to the host the state of the physical presences state machine regarding the expected user action (pressing the PP button). Two new VENDOR_CC_CCD subcommands are being added: CCDV_PP_POLL_OPEN and CCDV_PP_UNLOCK. In response to these commands, the Cr50 always returns VENDOR_RC_SUCCESS return code and a single byte payload showing the CCD and PP state: - CCDPP_CLOSED - PP process is not running, CCD closed. Maybe user missed a button press deadline. - CCDPP_AWAITING_PRESS (self explanatory) - CCDPP_BETWEEN_PRESSES (self explanatory) - CCDPP_PP_DONE - CCD is opened/unlocked (as per user request), PP process succeeded. BRANCH=cr50 BUG=b:62537474 TEST=with the upcoming change to gsctool verified that PP states are properly conveyed to the user. Change-Id: I97b1fef4440eea93c5c5ac01b7c60bfce9a4595c Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/861001 Reviewed-by: Randall Spangler <rspangler@chromium.org> (cherry picked from commit 8347907c46df8186d339c10dcca1b1c5f8f641ed) Reviewed-on: https://chromium-review.googlesource.com/896783
-rw-r--r--common/ccd_config.c69
-rw-r--r--include/ccd_config.h9
2 files changed, 78 insertions, 0 deletions
diff --git a/common/ccd_config.c b/common/ccd_config.c
index 12885926dd..01d8c8ae6f 100644
--- a/common/ccd_config.c
+++ b/common/ccd_config.c
@@ -1367,6 +1367,67 @@ static enum vendor_cmd_rc ccd_password(void *buf,
return VENDOR_RC_SUCCESS;
}
+static enum vendor_cmd_rc ccd_pp_poll(void *buf,
+ size_t input_size,
+ size_t *response_size)
+{
+ char *buffer = buf;
+
+ if ((ccd_state == CCD_STATE_OPENED) ||
+ (ccd_state == CCD_STATE_UNLOCKED)) {
+ buffer[0] = CCD_PP_DONE;
+ } else {
+ switch (physical_presense_fsm_state()) {
+ case PP_AWAITING_PRESS:
+ buffer[0] = CCD_PP_AWAITING_PRESS;
+ break;
+ case PP_BETWEEN_PRESSES:
+ buffer[0] = CCD_PP_BETWEEN_PRESSES;
+ break;
+ default:
+ buffer[0] = CCD_PP_CLOSED;
+ break;
+ }
+ }
+ *response_size = 1;
+ return VENDOR_RC_SUCCESS;
+}
+
+static enum vendor_cmd_rc ccd_pp_poll_unlock(void *buf,
+ size_t input_size,
+ size_t *response_size)
+{
+ char *buffer;
+
+ if ((ccd_state != CCD_STATE_OPENED) &&
+ (ccd_state != CCD_STATE_UNLOCKED))
+ return ccd_pp_poll(buf, input_size, response_size);
+
+
+ buffer = buf;
+ *response_size = 1;
+ buffer[0] = CCD_PP_DONE;
+
+ return VENDOR_RC_SUCCESS;
+}
+
+static enum vendor_cmd_rc ccd_pp_poll_open(void *buf,
+ size_t input_size,
+ size_t *response_size)
+{
+ char *buffer;
+
+ if (ccd_state != CCD_STATE_OPENED)
+ return ccd_pp_poll(buf, input_size, response_size);
+
+
+ buffer = buf;
+ *response_size = 1;
+ buffer[0] = CCD_PP_DONE;
+
+ return VENDOR_RC_SUCCESS;
+}
+
/*
* Common TPM Vendor command handler used to demultiplex various CCD commands
* which need to be available both throuh CLI and over /dev/tpm0.
@@ -1405,6 +1466,14 @@ static enum vendor_cmd_rc ccd_vendor(enum vendor_cmd_cc code,
handler = ccd_lock;
break;
+ case CCDV_PP_POLL_UNLOCK:
+ handler = ccd_pp_poll_unlock;
+ break;
+
+ case CCDV_PP_POLL_OPEN:
+ handler = ccd_pp_poll_open;
+ break;
+
default:
CPRINTS("%s:%d - unknown subcommand\n", __func__, __LINE__);
break;
diff --git a/include/ccd_config.h b/include/ccd_config.h
index 5a1cb5add9..76d54ac103 100644
--- a/include/ccd_config.h
+++ b/include/ccd_config.h
@@ -107,6 +107,15 @@ enum ccd_vendor_subcommands {
CCDV_OPEN = 1,
CCDV_UNLOCK = 2,
CCDV_LOCK = 3,
+ CCDV_PP_POLL_UNLOCK = 4,
+ CCDV_PP_POLL_OPEN = 5,
+};
+
+enum ccd_pp_state {
+ CCD_PP_CLOSED = 0,
+ CCD_PP_AWAITING_PRESS = 1,
+ CCD_PP_BETWEEN_PRESSES = 2,
+ CCD_PP_DONE = 3
};
/**