diff options
author | Tom Hughes <tomhughes@chromium.org> | 2019-02-12 09:49:00 -0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-09-28 04:28:20 +0000 |
commit | ab71261010629016885601b6f7553c5ba0c08560 (patch) | |
tree | fc353b54ac8f5fd61e74427a4cb87c1d10b1802f /common/fpsensor | |
parent | 476ce6df63da54684da2727b1d1a8ffcc818388e (diff) | |
download | chrome-ec-ab71261010629016885601b6f7553c5ba0c08560.tar.gz |
fpsensor: Build fpsensor source file with C++
Note that this change also removes abs() since this change makes the
fingerprint firmware link against the toolchain's C standard library,
which already provides an implementation. 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
LOW_COVERAGE_REASON=legacy code
Force-Relevant-Builds: all
Cq-Depend: chromium:3894586
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I2c7947d21e7020b51f7b5b3d87ef64545de867c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3893045
Reviewed-by: Andrea Grandi <agrandi@google.com>
Reviewed-by: Bobby Casey <bobbycasey@google.com>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Diffstat (limited to 'common/fpsensor')
-rw-r--r-- | common/fpsensor/fpsensor.cc (renamed from common/fpsensor/fpsensor.c) | 29 | ||||
-rw-r--r-- | common/fpsensor/fpsensor_private.h | 8 |
2 files changed, 26 insertions, 11 deletions
diff --git a/common/fpsensor/fpsensor.c b/common/fpsensor/fpsensor.cc index bd09ed5c3a..0c194419c9 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); diff --git a/common/fpsensor/fpsensor_private.h b/common/fpsensor/fpsensor_private.h index 919c523273..5c076a0808 100644 --- a/common/fpsensor/fpsensor_private.h +++ b/common/fpsensor/fpsensor_private.h @@ -13,7 +13,11 @@ #define CPRINTF(format, args...) cprintf(CC_FP, format, ##args) #define CPRINTS(format, args...) cprints(CC_FP, format, ##args) -int validate_fp_buffer_offset(uint32_t buffer_size, uint32_t offset, - uint32_t size); +#ifdef __cplusplus +extern "C" +#endif + int + validate_fp_buffer_offset(uint32_t buffer_size, uint32_t offset, + uint32_t size); #endif /* __CROS_EC_FPSENSOR_PRIVATE_H */ |