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/docs/user_guides/services/tfm_platform_integration_guide.md b/docs/user_guides/services/tfm_platform_integration_guide.md
index b6630ec..bc9a4e1 100644
--- a/docs/user_guides/services/tfm_platform_integration_guide.md
+++ b/docs/user_guides/services/tfm_platform_integration_guide.md
@@ -51,6 +51,19 @@
The API **must** be implemented by the system integrators for their targets.
+## Platform pin service
+
+This service is designed to perform secure pin services of the platform
+(e.g alternate function setting, pin mode setting, etc).
+The veneer implementation follows IOVEC API implementation, which allows
+the NS application to pack many pin service requests into one service call
+to reduce the overhead of the Secure-Non-Secure context switch.
+Since packing many service requests into one call is application and use-case
+specific, the API implementations in tfm_platform_api.c and
+tfm_platform_secure_api.c follow the one service in one veneer call design but
+the service implementation in tfm_platform_system.c is prepared to serve packed
+requests.
+
## Current Service Limitations
The system reset functionality is only supported in isolation level 1.
diff --git a/interface/include/tfm_platform_api.h b/interface/include/tfm_platform_api.h
index 1c3069e..7cc57ab 100644
--- a/interface/include/tfm_platform_api.h
+++ b/interface/include/tfm_platform_api.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
*
@@ -9,6 +9,7 @@
#define __TFM_PLATFORM_API__
#include <limits.h>
+#include <stdbool.h>
#include "tfm_api.h"
#ifdef __cplusplus
@@ -19,7 +20,7 @@
* \brief TFM secure partition platform API version
*/
#define TFM_PLATFORM_API_VERSION_MAJOR (0)
-#define TFM_PLATFORM_API_VERSION_MINOR (1)
+#define TFM_PLATFORM_API_VERSION_MINOR (2)
/* The return value is shared with the TF-M partition status value.
* The Platform return codes shouldn't overlap with predefined TFM status
@@ -36,6 +37,7 @@
enum tfm_platform_err_t {
TFM_PLATFORM_ERR_SUCCESS = 0,
TFM_PLATFORM_ERR_SYSTEM_ERROR = TFM_PLATFORM_ERR_OFFSET,
+ TFM_PLATFORM_ERR_INVALID_PARAM,
/* Following entry is only to ensure the error code of int size */
TFM_PLATFORM_ERR_FORCE_INT_SIZE = INT_MAX
@@ -48,6 +50,50 @@
*/
enum tfm_platform_err_t tfm_platform_system_reset(void);
+/*!
+ * \brief Sets pin alternate function for the given pins
+ *
+ * \param[in] alt_func Alternate function to set (allowed values vary
+ * based on the platform)
+ * \param[in] pin_mask Pin mask of the selected pins
+ * \param[out] result Return error value
+ *
+ * \return Returns values as specified by the \ref tfm_platform_err_t
+ */
+enum tfm_platform_err_t
+tfm_platform_set_pin_alt_func(uint32_t alt_func, uint64_t pin_mask,
+ uint32_t *result);
+
+/*!
+ * \brief Sets default in value to use when the alternate function is not
+ * selected for the pin
+ *
+ * \param[in] alt_func Alternate function to use (allowed values vary
+ * based on the platform)
+ * \param[in] pin_value Pin value to use
+ * \param[in] default_in_value Default in value to set
+ * \param[out] result Return error value
+ *
+ * \return Returns values as specified by the \ref tfm_platform_err_t
+ */
+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);
+
+/*!
+ * \brief Sets pin mode for the selected pins
+ *
+ * \param[in] pin_mask Pin mask of the selected pins
+ * \param[in] pin_mode Pin mode to set for the selected pins
+ * \param[out] result Return error value
+ *
+ * \return Returns values as specified by the \ref tfm_platform_err_t
+ */
+enum tfm_platform_err_t
+tfm_platform_set_pin_mode(uint64_t pin_mask, uint32_t pin_mode,
+ uint32_t *result);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/interface/include/tfm_platform_defs.h b/interface/include/tfm_platform_defs.h
new file mode 100644
index 0000000..23fe4e0
--- /dev/null
+++ b/interface/include/tfm_platform_defs.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __TFM_PLATFORM_DEFS__
+#define __TFM_PLATFORM_DEFS__
+
+#include <stdint.h>
+#include <limits.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*!
+ * \enum tfm_pin_service_type_t
+ *
+ * \brief Pin service types (supported types may vary based on the platform)
+ */
+enum tfm_pin_service_type_t {
+ TFM_PIN_SERVICE_TYPE_SET_ALTFUNC = 0, /*!< Set alternate function type */
+ TFM_PIN_SERVICE_TYPE_SET_DEFAULT_IN, /*!< Set default in function type */
+ TFM_PIN_SERVICE_TYPE_SET_PIN_MODE, /*!< Set pin mode function type */
+ TFM_PIN_SERVICE_TYPE_MAX = INT_MAX /*!< Max to force enum max size */
+};
+
+/*!
+ * \struct tfm_pin_service_args_t
+ *
+ * \brief Argument list for each platform pin service
+ */
+struct tfm_pin_service_args_t {
+ enum tfm_pin_service_type_t type;
+ union {
+ struct set_altfunc { /*!< TFM_PIN_SERVICE_TYPE_SET_ALTFUNC */
+ uint32_t alt_func;
+ uint64_t pin_mask;
+ } set_altfunc;
+ struct set_default_in { /*!< TFM_PIN_SERVICE_TYPE_SET_DEFAULT_IN */
+ uint32_t alt_func;
+ uint32_t pin_value;
+ bool default_in_value;
+ } set_default_in;
+ struct set_pin_mode { /*!< TFM_PIN_SERVICE_TYPE_SET_PIN_MODE */
+ uint64_t pin_mask;
+ uint32_t pin_mode;
+ } set_pin_mode;
+ } u;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TFM_PLATFORM_DEFS__ */
diff --git a/interface/include/tfm_veneers.h b/interface/include/tfm_veneers.h
index 787aa87..69b0a76 100644
--- a/interface/include/tfm_veneers.h
+++ b/interface/include/tfm_veneers.h
@@ -65,6 +65,7 @@
/******** TFM_SP_PLATFORM ********/
psa_status_t tfm_platform_sp_system_reset_veneer(psa_invec *in_vec, size_t in_len, psa_outvec *out_vec, size_t out_len);
+psa_status_t tfm_platform_sp_pin_service_veneer(psa_invec *in_vec, size_t in_len, psa_outvec *out_vec, size_t out_len);
/******** TFM_SP_INITIAL_ATTESTATION ********/
psa_status_t tfm_initial_attest_get_token_veneer(psa_invec *in_vec, size_t in_len, psa_outvec *out_vec, size_t out_len);
diff --git a/interface/src/tfm_platform_api.c b/interface/src/tfm_platform_api.c
index b4e1162..9b6f787 100644
--- a/interface/src/tfm_platform_api.c
+++ b/interface/src/tfm_platform_api.c
@@ -1,13 +1,16 @@
/*
- * Copyright (c) 2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
+#include <stdbool.h>
#include "tfm_platform_api.h"
#include "tfm_platform_veneers.h"
#include "tfm_ns_lock.h"
+#include "tfm_platform_defs.h"
+#include "tfm_veneers.h"
enum tfm_platform_err_t tfm_platform_system_reset(void)
{
@@ -17,3 +20,95 @@
0,
0);
}
+
+enum tfm_platform_err_t
+tfm_platform_set_pin_alt_func(uint32_t alt_func, uint64_t pin_mask,
+ uint32_t *result)
+{
+ enum tfm_platform_err_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_ns_lock_dispatch((veneer_fn)tfm_platform_sp_pin_service_veneer,
+ (uint32_t)&in_vec, 1,
+ (uint32_t)&out_vec, 1);
+
+ return ret;
+}
+
+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)
+{
+ enum tfm_platform_err_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_ns_lock_dispatch((veneer_fn)tfm_platform_sp_pin_service_veneer,
+ (uint32_t)&in_vec, 1,
+ (uint32_t)&out_vec, 1);
+
+ return ret;
+}
+
+enum tfm_platform_err_t
+tfm_platform_set_pin_mode(uint64_t pin_mask, uint32_t pin_mode,
+ uint32_t *result)
+{
+ enum tfm_platform_err_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_ns_lock_dispatch((veneer_fn)tfm_platform_sp_pin_service_veneer,
+ (uint32_t)&in_vec, 1,
+ (uint32_t)&out_vec, 1);
+
+ return ret;
+}
+
diff --git a/platform/ext/target/mps2/an519/tfm_platform_system.c b/platform/ext/target/mps2/an519/tfm_platform_system.c
index 1e8a9ab..26c2a73 100644
--- a/platform/ext/target/mps2/an519/tfm_platform_system.c
+++ b/platform/ext/target/mps2/an519/tfm_platform_system.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
*
@@ -14,3 +14,15 @@
NVIC_SystemReset();
}
+enum tfm_plat_err_t
+tfm_platform_hal_pin_service(const psa_invec *in_vec, uint32_t num_invec,
+ const psa_outvec *out_vec, uint32_t num_outvec)
+{
+ (void)in_vec;
+ (void)num_invec;
+ (void)out_vec;
+ (void)num_outvec;
+ /* Not needed for this platform */
+ return TFM_PLAT_ERR_SUCCESS;
+}
+
diff --git a/platform/ext/target/mps2/an521/tfm_platform_system.c b/platform/ext/target/mps2/an521/tfm_platform_system.c
index 1e8a9ab..26c2a73 100644
--- a/platform/ext/target/mps2/an521/tfm_platform_system.c
+++ b/platform/ext/target/mps2/an521/tfm_platform_system.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
*
@@ -14,3 +14,15 @@
NVIC_SystemReset();
}
+enum tfm_plat_err_t
+tfm_platform_hal_pin_service(const psa_invec *in_vec, uint32_t num_invec,
+ const psa_outvec *out_vec, uint32_t num_outvec)
+{
+ (void)in_vec;
+ (void)num_invec;
+ (void)out_vec;
+ (void)num_outvec;
+ /* Not needed for this platform */
+ return TFM_PLAT_ERR_SUCCESS;
+}
+
diff --git a/platform/ext/target/musca_a/tfm_platform_system.c b/platform/ext/target/musca_a/tfm_platform_system.c
index 7cd0c84..cc21804 100644
--- a/platform/ext/target/musca_a/tfm_platform_system.c
+++ b/platform/ext/target/musca_a/tfm_platform_system.c
@@ -14,3 +14,17 @@
NVIC_SystemReset();
}
+enum tfm_plat_err_t
+tfm_platform_hal_pin_service(const psa_invec *in_vec, uint32_t num_invec,
+ const psa_outvec *out_vec, uint32_t num_outvec)
+{
+ (void)in_vec;
+ (void)num_invec;
+ (void)out_vec;
+ (void)num_outvec;
+ /* SCC is configured as non-secure through PPC,
+ * so this function is not needed on this platform
+ */
+ return TFM_PLAT_ERR_SUCCESS;
+}
+
diff --git a/platform/ext/target/musca_b1/tfm_platform_system.c b/platform/ext/target/musca_b1/tfm_platform_system.c
index c4d544d..2fb9657 100644
--- a/platform/ext/target/musca_b1/tfm_platform_system.c
+++ b/platform/ext/target/musca_b1/tfm_platform_system.c
@@ -5,9 +5,39 @@
*
*/
+#include <stdbool.h>
#include "platform/include/tfm_platform_system.h"
#include "platform_description.h"
#include "target_cfg.h"
+#include "device_definition.h"
+#include "psa_client.h"
+#include "tfm_platform_defs.h"
+#include "tfm_secure_api.h"
+
+/*!
+ * \brief Verify access rights for memory addresses sent in io vectors
+ *
+ * \param[in] in_vec Pointer to in_vec array, which contains pointer
+ * to input arguments for the service
+ * \param[in] out_vec Pointer out_vec array, which contains pointer to
+ * output data of the pin service
+ *
+ * \return Returns true if memory is accessible by the service
+ */
+static bool memory_addr_check(const psa_invec *in_vec,
+ const psa_outvec *out_vec)
+{
+ if ((in_vec->base != NULL) &&
+ (tfm_core_memory_permission_check((void *)in_vec->base, in_vec->len,
+ TFM_MEMORY_ACCESS_RO) == TFM_SUCCESS) &&
+ (out_vec->base != NULL) &&
+ (tfm_core_memory_permission_check((void *)out_vec->base, out_vec->len,
+ TFM_MEMORY_ACCESS_RW) == TFM_SUCCESS)) {
+ return true;
+ } else {
+ return false;
+ }
+}
void tfm_platform_hal_system_reset(void)
{
@@ -26,3 +56,55 @@
NVIC_SystemReset();
}
+enum tfm_plat_err_t
+tfm_platform_hal_pin_service(const psa_invec *in_vec, uint32_t num_invec,
+ const psa_outvec *out_vec, uint32_t num_outvec)
+{
+ struct tfm_pin_service_args_t *args;
+ uint32_t *result;
+ enum gpio_altfunc_t altfunc;
+ enum pinmode_select_t pin_mode;
+
+ while (num_invec && num_outvec) {
+ if (memory_addr_check(in_vec, out_vec) == false) {
+ return TFM_PLAT_ERR_SYSTEM_ERR;
+ }
+ if (in_vec->len != sizeof(struct tfm_pin_service_args_t) ||
+ out_vec->len != sizeof(uint32_t)) {
+ return TFM_PLAT_ERR_SYSTEM_ERR;
+ }
+
+ args = (struct tfm_pin_service_args_t *)in_vec->base;
+ result = (uint32_t *)out_vec->base;
+ switch (args->type) {
+ case TFM_PIN_SERVICE_TYPE_SET_ALTFUNC:
+ altfunc = (enum gpio_altfunc_t)args->u.set_altfunc.alt_func;
+ *result = musca_b1_scc_set_alt_func(&MUSCA_B1_SCC_DEV_S, altfunc,
+ args->u.set_altfunc.pin_mask);
+ break;
+ case TFM_PIN_SERVICE_TYPE_SET_DEFAULT_IN:
+ altfunc = (enum gpio_altfunc_t)args->u.set_altfunc.alt_func;
+ *result = musca_b1_scc_set_default_in(&MUSCA_B1_SCC_DEV_S, altfunc,
+ args->u.set_default_in.pin_value,
+ args->u.set_default_in.default_in_value);
+ break;
+ case TFM_PIN_SERVICE_TYPE_SET_PIN_MODE:
+ pin_mode = (enum pinmode_select_t)args->u.set_pin_mode.pin_mode;
+ *result = musca_b1_scc_set_pinmode(&MUSCA_B1_SCC_DEV_S,
+ args->u.set_pin_mode.pin_mask,
+ pin_mode);
+ break;
+ default:
+ *result = SCC_INVALID_ARG;
+ break;
+ }
+
+ num_invec--;
+ num_outvec--;
+ in_vec++;
+ out_vec++;
+ }
+
+ return TFM_PLAT_ERR_SUCCESS;
+}
+
diff --git a/platform/include/tfm_platform_system.h b/platform/include/tfm_platform_system.h
index d0e5683..411be49 100644
--- a/platform/include/tfm_platform_system.h
+++ b/platform/include/tfm_platform_system.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
*
@@ -13,6 +13,8 @@
*/
#include "tfm_plat_defs.h"
+#include "psa_client.h"
+#include "tfm_plat_defs.h"
#ifdef __cplusplus
extern "C" {
@@ -26,6 +28,23 @@
TFM_LINK_SET_OBJECT_IN_PARTITION_SECTION("TFM_SP_PLATFORM")
void tfm_platform_hal_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_plat_err_t
+ */
+TFM_LINK_SET_OBJECT_IN_PARTITION_SECTION("TFM_SP_PLATFORM")
+enum tfm_plat_err_t
+tfm_platform_hal_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/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;
+}
+