diff options
-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 }; /** |