diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2018-01-10 11:34:31 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2018-12-05 00:46:02 +0000 |
commit | b1f35b5ca4bdf0b3e230313fb0e0e39dc6a6e77c (patch) | |
tree | 2c73877fafc7321c87d5b8569a4fce240964fb0c | |
parent | bc6c5982347e2d2fd0626af204e732175de5295b (diff) | |
download | chrome-ec-b1f35b5ca4bdf0b3e230313fb0e0e39dc6a6e77c.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>
Reviewed-on: https://chromium-review.googlesource.com/c/1221369
Reviewed-by: Marco Chen <marcochen@chromium.org>
Commit-Queue: Marco Chen <marcochen@chromium.org>
Tested-by: Marco Chen <marcochen@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/1359945
Reviewed-by: Chia-Hsiu Chang <chia-hsiu.chang@quanta.corp-partner.google.com>
Tested-by: Chia-Hsiu Chang <chia-hsiu.chang@quanta.corp-partner.google.com>
Commit-Queue: Chia-Hsiu Chang <chia-hsiu.chang@quanta.corp-partner.google.com>
-rw-r--r-- | common/ccd_config.c | 69 | ||||
-rw-r--r-- | include/ccd_config.h | 9 |
2 files changed, 78 insertions, 0 deletions
diff --git a/common/ccd_config.c b/common/ccd_config.c index 2a5650233c..17b64f2432 100644 --- a/common/ccd_config.c +++ b/common/ccd_config.c @@ -1363,6 +1363,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. @@ -1401,6 +1462,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 07171724b5..c7243ecbb8 100644 --- a/include/ccd_config.h +++ b/include/ccd_config.h @@ -110,6 +110,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 }; /** |