summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
};
/**