Platform: Create platform service for pin functions
This patch creates new platform service API for
alternate functions, default input and pin mode setting.
The functions are implemented only for Musca B1,
not needed on Musca A, AN519 and AN521
Change-Id: Ic6d6dbeafe059aadc4f57a066513281afa8aa61b
Signed-off-by: Tamas Kaman <tamas.kaman@arm.com>
diff --git a/secure_fw/ns_callable/tfm_veneers.c b/secure_fw/ns_callable/tfm_veneers.c
index a2ef738..ba432c8 100644
--- a/secure_fw/ns_callable/tfm_veneers.c
+++ b/secure_fw/ns_callable/tfm_veneers.c
@@ -59,6 +59,7 @@
/******** TFM_SP_PLATFORM ********/
psa_status_t platform_sp_system_reset(psa_invec *, size_t, psa_outvec *, size_t);
+psa_status_t platform_sp_pin_service(psa_invec *, size_t, psa_outvec *, size_t);
/******** TFM_SP_INITIAL_ATTESTATION ********/
psa_status_t initial_attest_get_token(psa_invec *, size_t, psa_outvec *, size_t);
@@ -154,6 +155,7 @@
/******** TFM_SP_PLATFORM ********/
TFM_VENEER_FUNCTION(TFM_SP_PLATFORM, platform_sp_system_reset)
+TFM_VENEER_FUNCTION(TFM_SP_PLATFORM, platform_sp_pin_service)
/******** TFM_SP_INITIAL_ATTESTATION ********/
TFM_VENEER_FUNCTION(TFM_SP_INITIAL_ATTESTATION, initial_attest_get_token)
diff --git a/secure_fw/services/platform/manifest.yaml b/secure_fw/services/platform/manifest.yaml
index e66b54e..283802e 100644
--- a/secure_fw/services/platform/manifest.yaml
+++ b/secure_fw/services/platform/manifest.yaml
@@ -21,7 +21,15 @@
"non_secure_clients": true,
"minor_version": 1,
"minor_policy": "strict"
- }
+ },
+ {
+ "sfid": "TFM_SP_PLATFORM_PIN_SERVICE_SFID",
+ "signal": "TFM_SP_PLATFORM_PIN_SERVICE",
+ "tfm_symbol": "platform_sp_pin_service",
+ "non_secure_clients": true,
+ "minor_version": 1,
+ "minor_policy": "strict"
+ }
],
"source_files": [
"platform_sp.c",
diff --git a/secure_fw/services/platform/platform_sp.c b/secure_fw/services/platform/platform_sp.c
index e5c22b5..59fa186 100644
--- a/secure_fw/services/platform/platform_sp.c
+++ b/secure_fw/services/platform/platform_sp.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -39,3 +39,15 @@
return TFM_PLATFORM_ERR_SUCCESS;
}
+
+enum tfm_platform_err_t
+platform_sp_pin_service(const psa_invec *in_vec, uint32_t num_invec,
+ const psa_outvec *out_vec, uint32_t num_outvec)
+{
+ enum tfm_plat_err_t ret = tfm_platform_hal_pin_service(in_vec, num_invec,
+ out_vec, num_outvec);
+
+ return ((ret == TFM_PLAT_ERR_SUCCESS) ? TFM_PLATFORM_ERR_SUCCESS :
+ TFM_PLATFORM_ERR_SYSTEM_ERROR);
+}
+
diff --git a/secure_fw/services/platform/platform_sp.h b/secure_fw/services/platform/platform_sp.h
index 118eb08..44332dc 100644
--- a/secure_fw/services/platform/platform_sp.h
+++ b/secure_fw/services/platform/platform_sp.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -28,6 +28,22 @@
*/
enum tfm_platform_err_t platform_sp_system_reset(void);
+/*!
+ * \brief Performs pin services of the platform
+ *
+ * \param[in] in_vec Pointer to in_vec array, which contains input
+ * arguments for the pin service
+ * \param[in] num_invec Number of elements in in_vec array
+ * \param[in,out] out_vec Pointer out_vec array, which contains output data
+ * of the pin service
+ * \param[in] num_outvec Number of elements in out_vec array
+ *
+ * \return Returns values as specified by the \ref tfm_platform_err_t
+ */
+enum tfm_platform_err_t
+platform_sp_pin_service(const psa_invec *in_vec, uint32_t num_invec,
+ const psa_outvec *out_vec, uint32_t num_outvec);
+
#ifdef __cplusplus
}
#endif
diff --git a/secure_fw/services/platform/tfm_platform_secure_api.c b/secure_fw/services/platform/tfm_platform_secure_api.c
index 4fa31f0..dccd3ce 100644
--- a/secure_fw/services/platform/tfm_platform_secure_api.c
+++ b/secure_fw/services/platform/tfm_platform_secure_api.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -7,9 +7,112 @@
#include "tfm_platform_api.h"
#include "tfm_platform_veneers.h"
+#include "tfm_platform_defs.h"
+#include "tfm_veneers.h"
__attribute__((section("SFN")))
enum tfm_platform_err_t tfm_platform_system_reset(void)
{
return tfm_platform_veneer_system_reset();
}
+
+__attribute__((section("SFN")))
+enum tfm_platform_err_t
+tfm_platform_set_pin_alt_func(uint32_t alt_func, uint64_t pin_mask,
+ uint32_t *result)
+{
+ psa_status_t ret;
+ psa_invec in_vec;
+ psa_outvec out_vec;
+ struct tfm_pin_service_args_t args;
+
+ if (result == NULL) {
+ return TFM_PLATFORM_ERR_INVALID_PARAM;
+ }
+
+ args.type = TFM_PIN_SERVICE_TYPE_SET_ALTFUNC;
+ args.u.set_altfunc.alt_func = alt_func;
+ args.u.set_altfunc.pin_mask = pin_mask;
+
+ in_vec.base = (const void *)&args;
+ in_vec.len = sizeof(args);
+
+ out_vec.base = (void *)result;
+ out_vec.len = sizeof(*result);
+
+ ret = tfm_platform_sp_pin_service_veneer(&in_vec, 1, &out_vec, 1);
+
+ if (ret != PSA_SUCCESS) {
+ return TFM_PLATFORM_ERR_SYSTEM_ERROR;
+ }
+
+ return TFM_PLATFORM_ERR_SUCCESS;
+}
+
+__attribute__((section("SFN")))
+enum tfm_platform_err_t
+tfm_platform_set_pin_default_in(uint32_t alt_func, uint32_t pin_value,
+ bool default_in_value, uint32_t *result)
+{
+ psa_status_t ret;
+ psa_invec in_vec;
+ psa_outvec out_vec;
+ struct tfm_pin_service_args_t args;
+
+ if (result == NULL) {
+ return TFM_PLATFORM_ERR_INVALID_PARAM;
+ }
+
+ args.type = TFM_PIN_SERVICE_TYPE_SET_DEFAULT_IN;
+ args.u.set_default_in.alt_func = alt_func;
+ args.u.set_default_in.pin_value = pin_value;
+ args.u.set_default_in.default_in_value = default_in_value;
+
+ in_vec.base = (const void *)&args;
+ in_vec.len = sizeof(args);
+
+ out_vec.base = (void *)result;
+ out_vec.len = sizeof(*result);
+
+ ret = tfm_platform_sp_pin_service_veneer(&in_vec, 1, &out_vec, 1);
+
+ if (ret != PSA_SUCCESS) {
+ return TFM_PLATFORM_ERR_SYSTEM_ERROR;
+ }
+
+ return TFM_PLATFORM_ERR_SUCCESS;
+}
+
+__attribute__((section("SFN")))
+enum tfm_platform_err_t
+tfm_platform_set_pin_mode(uint64_t pin_mask, uint32_t pin_mode,
+ uint32_t *result)
+{
+ psa_status_t ret;
+ psa_invec in_vec;
+ psa_outvec out_vec;
+ struct tfm_pin_service_args_t args;
+
+ if (result == NULL) {
+ return TFM_PLATFORM_ERR_INVALID_PARAM;
+ }
+
+ args.type = TFM_PIN_SERVICE_TYPE_SET_PIN_MODE;
+ args.u.set_pin_mode.pin_mask = pin_mask;
+ args.u.set_pin_mode.pin_mode = pin_mode;
+
+ in_vec.base = (const void *)&args;
+ in_vec.len = sizeof(args);
+
+ out_vec.base = (void *)result;
+ out_vec.len = sizeof(*result);
+
+ ret = tfm_platform_sp_pin_service_veneer(&in_vec, 1, &out_vec, 1);
+
+ if (ret != PSA_SUCCESS) {
+ return TFM_PLATFORM_ERR_SYSTEM_ERROR;
+ }
+
+ return TFM_PLATFORM_ERR_SUCCESS;
+}
+