summaryrefslogtreecommitdiff
path: root/include/fpsensor_state.h
diff options
context:
space:
mode:
authorYicheng Li <yichengli@chromium.org>2019-05-20 15:20:27 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-05-28 21:11:20 -0700
commit325d65d3b08903e7bd3c70d14875cc1dfbf1686d (patch)
tree17b15c01f43f40a658c947602efd742bdbdcc5a2 /include/fpsensor_state.h
parent0d73e46eb36455652eafcf7583f4dd8112472b92 (diff)
downloadchrome-ec-325d65d3b08903e7bd3c70d14875cc1dfbf1686d.tar.gz
fpsensor: move hardware-independent code to fpsensor_state.c
Split common/fpsensor.c so that it contains only hardware-dependent code, and put hardware-independent code to common/fpsensor_state.c. This facilitates unit testing of hardware-independent code. BRANCH=nocturne BUG=chromium:952275 TEST=ran unittests Change-Id: I0c050c7affa83e7cb935e2b657b2823cafe4c35f Signed-off-by: Yicheng Li <yichengli@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1625774 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Nicolas Norvez <norvez@chromium.org>
Diffstat (limited to 'include/fpsensor_state.h')
-rw-r--r--include/fpsensor_state.h96
1 files changed, 96 insertions, 0 deletions
diff --git a/include/fpsensor_state.h b/include/fpsensor_state.h
new file mode 100644
index 0000000000..3033ec19b4
--- /dev/null
+++ b/include/fpsensor_state.h
@@ -0,0 +1,96 @@
+/* Copyright 2017 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Fingerprint sensor interface */
+
+#ifndef __CROS_EC_FPSENSOR_STATE_H
+#define __CROS_EC_FPSENSOR_STATE_H
+
+#include <stdint.h>
+#include "common.h"
+#include "ec_commands.h"
+#include "link_defs.h"
+
+/* if no special memory regions are defined, fallback on regular SRAM */
+#ifndef FP_FRAME_SECTION
+#define FP_FRAME_SECTION
+#endif
+#ifndef FP_TEMPLATE_SECTION
+#define FP_TEMPLATE_SECTION
+#endif
+
+#if defined(HAVE_PRIVATE) && !defined(TEST_BUILD)
+#define HAVE_FP_PRIVATE_DRIVER
+#define PRIV_HEADER(header) STRINGIFY(header)
+#include PRIV_HEADER(FP_SENSOR_PRIVATE)
+#else
+#define FP_SENSOR_IMAGE_SIZE 0
+#define FP_SENSOR_RES_X 0
+#define FP_SENSOR_RES_Y 0
+#define FP_ALGORITHM_TEMPLATE_SIZE 0
+#define FP_MAX_FINGER_COUNT 0
+#endif
+#define SBP_ENC_KEY_LEN 16
+#define FP_ALGORITHM_ENCRYPTED_TEMPLATE_SIZE \
+ (FP_ALGORITHM_TEMPLATE_SIZE + \
+ sizeof(struct ec_fp_template_encryption_metadata))
+
+/* Events for the FPSENSOR task */
+#define TASK_EVENT_SENSOR_IRQ TASK_EVENT_CUSTOM_BIT(0)
+#define TASK_EVENT_UPDATE_CONFIG TASK_EVENT_CUSTOM_BIT(1)
+
+/* --- Global variables defined in fpsensor_state.c --- */
+
+/* Last acquired frame (aligned as it is used by arbitrary binary libraries) */
+extern uint8_t fp_buffer[FP_SENSOR_IMAGE_SIZE];
+/* Fingers templates for the current user */
+extern uint8_t fp_template[FP_MAX_FINGER_COUNT][FP_ALGORITHM_TEMPLATE_SIZE];
+/* Encryption/decryption buffer */
+/* TODO: On-the-fly encryption/decryption without a dedicated buffer */
+/*
+ * Store the encryption metadata at the beginning of the buffer containing the
+ * ciphered data.
+ */
+extern uint8_t fp_enc_buffer[FP_ALGORITHM_ENCRYPTED_TEMPLATE_SIZE];
+/* Number of used templates */
+extern uint32_t templ_valid;
+/* Bitmap of the templates with local modifications */
+extern uint32_t templ_dirty;
+/* Current user ID */
+extern uint32_t user_id[FP_CONTEXT_USERID_WORDS];
+/* Part of the IKM used to derive encryption keys received from the TPM. */
+extern uint8_t tpm_seed[FP_CONTEXT_TPM_BYTES];
+
+extern uint32_t fp_events;
+
+extern uint32_t sensor_mode;
+
+/*
+ * Clear one fingerprint template.
+ *
+ * @param idx the index of the template to clear.
+ */
+void fp_clear_finger_context(int idx);
+
+/*
+ * Clear all fingerprint templates associated with the current user id.
+ */
+void fp_clear_context(void);
+
+/*
+ * Get the next FP event.
+ *
+ * @param out the pointer to the output event.
+ */
+int fp_get_next_event(uint8_t *out);
+
+/*
+ * Check if FP TPM seed has been set.
+ *
+ * @return 1 if the seed has been set, 0 otherwise.
+ */
+int fp_tpm_seed_is_set(void);
+
+#endif /* __CROS_EC_FPSENSOR_STATE_H */