summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2019-02-12 09:49:00 -0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-09-08 22:50:12 +0000
commitc8d03607237fbc8ad189ee112f5f3dabfc5bd270 (patch)
treeda049d52b624aeb6b86046d24c4cf93f4ed4aea0 /common
parentbc113abd53c02caa0e121bc0518fcfaba01929e9 (diff)
downloadchrome-ec-c8d03607237fbc8ad189ee112f5f3dabfc5bd270.tar.gz
fpsensor: Build fpsensor source file with C++
This change removes abs() since this change also makes the fingerprint firmware link against the toolchain's C standard library, which already provides an implementation. Note that abs() is not actually used by the FPC matching algorithm even though it links against it. BRANCH=none BUG=b:236025198, b:234181908 TEST=On dragonclaw v0.2 with servo_micro and J-Trace attached: ./util/flash_jlink.py -b bloonchipper -i ./build/bloonchipper/ec.bin > fpenroll > fpmatch TEST=On dragonclaw v0.2 with servo_micro and J-Trace attached: ./test/run_device_tests.py --board bloonchipper Test "aes": PASSED Test "cec": PASSED Test "cortexm_fpu": PASSED Test "crc": PASSED Test "flash_physical": PASSED Test "flash_write_protect": PASSED Test "fpsensor_hw": PASSED Test "fpsensor_spi_ro": PASSED Test "fpsensor_spi_rw": PASSED Test "fpsensor_uart_ro": PASSED Test "fpsensor_uart_rw": PASSED Test "mpu_ro": PASSED Test "mpu_rw": PASSED Test "mutex": PASSED Test "pingpong": PASSED Test "printf": PASSED Test "queue": PASSED Test "rollback_region0": PASSED Test "rollback_region1": PASSED Test "rollback_entropy": PASSED Test "rtc": PASSED Test "sha256": PASSED Test "sha256_unrolled": PASSED Test "static_if": PASSED Test "stdlib": PASSED Test "system_is_locked_wp_on": PASSED Test "system_is_locked_wp_off": PASSED Test "timer_dos": PASSED Test "utils": PASSED Test "utils_str": PASSED Test "stm32f_rtc": PASSED Test "panic_data_bloonchipper_v2.0.4277": PASSED Test "panic_data_bloonchipper_v2.0.5938": PASSED TEST=On icetower v0.1 with servo_micro and J-Trace attached: ./util/flash_jlink.py -b dartmonkey -i ./build/dartmonkey/ec.bin > fpenroll > fpmatch TEST=On icetower v0.1 with servo_micro and J-Trace attached: ./test/run_device_tests.py --board dartmonkey Test "aes": PASSED Test "cec": PASSED Test "cortexm_fpu": PASSED Test "crc": PASSED Test "flash_physical": PASSED Test "flash_write_protect": PASSED Test "fpsensor_hw": PASSED Test "fpsensor_spi_ro": PASSED Test "fpsensor_spi_rw": PASSED Test "fpsensor_uart_ro": PASSED Test "fpsensor_uart_rw": PASSED Test "mpu_ro": PASSED Test "mpu_rw": PASSED Test "mutex": PASSED Test "pingpong": PASSED Test "printf": PASSED Test "queue": PASSED Test "rollback_region0": PASSED Test "rollback_region1": PASSED Test "rollback_entropy": PASSED Test "rtc": PASSED Test "sha256": PASSED Test "sha256_unrolled": PASSED Test "static_if": PASSED Test "stdlib": PASSED Test "system_is_locked_wp_on": PASSED Test "system_is_locked_wp_off": PASSED Test "timer_dos": PASSED Test "utils": PASSED Test "utils_str": PASSED Test "panic_data_dartmonkey_v2.0.2887": PASSED Test "panic_data_nocturne_fp_v2.2.64": PASSED Test "panic_data_nami_fp_v2.2.144": PASSED Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: Iab0de3355cbe928c7b7132263ea6d32c1e9f3a6e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3551682 Reviewed-by: Bobby Casey <bobbycasey@google.com> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com> Reviewed-by: Andrea Grandi <agrandi@google.com>
Diffstat (limited to 'common')
-rw-r--r--common/fpsensor/fpsensor.cc (renamed from common/fpsensor/fpsensor.c)29
1 files changed, 20 insertions, 9 deletions
diff --git a/common/fpsensor/fpsensor.c b/common/fpsensor/fpsensor.cc
index 3e97741705..a4a6eefaa9 100644
--- a/common/fpsensor/fpsensor.c
+++ b/common/fpsensor/fpsensor.cc
@@ -3,6 +3,9 @@
* found in the LICENSE file.
*/
+#include "compile_time_macros.h"
+
+extern "C" {
#include "atomic.h"
#include "clock.h"
#include "common.h"
@@ -25,6 +28,7 @@
#include "trng.h"
#include "util.h"
#include "watchdog.h"
+}
#if !defined(CONFIG_RNG)
#error "fpsensor requires RNG"
@@ -231,7 +235,7 @@ static void fp_process_finger(void)
}
#endif /* HAVE_FP_PRIVATE_DRIVER */
-void fp_task(void)
+extern "C" void fp_task(void)
{
int timeout_us = -1;
@@ -336,8 +340,9 @@ void fp_task(void)
static enum ec_status fp_command_passthru(struct host_cmd_handler_args *args)
{
- const struct ec_params_fp_passthru *params = args->params;
- void *out = args->response;
+ const struct ec_params_fp_passthru *params =
+ static_cast<const ec_params_fp_passthru *>(args->params);
+ uint8_t *out = static_cast<uint8_t *>(args->response);
int rc;
enum ec_status ret = EC_RES_SUCCESS;
@@ -369,7 +374,8 @@ DECLARE_HOST_COMMAND(EC_CMD_FP_PASSTHRU, fp_command_passthru, EC_VER_MASK(0));
static enum ec_status fp_command_info(struct host_cmd_handler_args *args)
{
- struct ec_response_fp_info *r = args->response;
+ struct ec_response_fp_info *r =
+ static_cast<ec_response_fp_info *>(args->response);
#ifdef HAVE_FP_PRIVATE_DRIVER
if (fp_sensor_get_info(r) < 0)
@@ -409,7 +415,8 @@ int validate_fp_buffer_offset(const uint32_t buffer_size, const uint32_t offset,
static enum ec_status fp_command_frame(struct host_cmd_handler_args *args)
{
- const struct ec_params_fp_frame *params = args->params;
+ const struct ec_params_fp_frame *params =
+ static_cast<const struct ec_params_fp_frame *>(args->params);
void *out = args->response;
uint32_t idx = FP_FRAME_GET_BUFFER_INDEX(params->offset);
uint32_t offset = params->offset & FP_FRAME_OFFSET_MASK;
@@ -473,7 +480,8 @@ static enum ec_status fp_command_frame(struct host_cmd_handler_args *args)
* The beginning of the buffer contains nonce, encryption_salt
* and tag.
*/
- enc_info = (void *)fp_enc_buffer;
+ enc_info = (struct ec_fp_template_encryption_metadata
+ *)(fp_enc_buffer);
enc_info->struct_version = FP_TEMPLATE_FORMAT_VERSION;
trng_init();
trng_rand_bytes(enc_info->nonce, FP_CONTEXT_NONCE_BYTES);
@@ -534,7 +542,8 @@ DECLARE_HOST_COMMAND(EC_CMD_FP_FRAME, fp_command_frame, EC_VER_MASK(0));
static enum ec_status fp_command_stats(struct host_cmd_handler_args *args)
{
- struct ec_response_fp_stats *r = args->response;
+ struct ec_response_fp_stats *r =
+ static_cast<struct ec_response_fp_stats *>(args->response);
r->capture_time_us = capture_time_us;
r->matching_time_us = matching_time_us;
@@ -575,7 +584,8 @@ validate_template_format(struct ec_fp_template_encryption_metadata *enc_info)
static enum ec_status fp_command_template(struct host_cmd_handler_args *args)
{
- const struct ec_params_fp_template *params = args->params;
+ const struct ec_params_fp_template *params =
+ static_cast<const struct ec_params_fp_template *>(args->params);
uint32_t size = params->size & ~FP_TEMPLATE_COMMIT;
int xfer_complete = params->size & FP_TEMPLATE_COMMIT;
uint32_t offset = params->offset;
@@ -614,7 +624,8 @@ static enum ec_status fp_command_template(struct host_cmd_handler_args *args)
* The beginning of the buffer contains nonce, encryption_salt
* and tag.
*/
- enc_info = (void *)fp_enc_buffer;
+ enc_info = (struct ec_fp_template_encryption_metadata *)
+ fp_enc_buffer;
ret = validate_template_format(enc_info);
if (ret != EC_RES_SUCCESS) {
CPRINTS("fgr%d: Template format not supported", idx);