Test: Add integration of the eRPC system
- PSA Client API IDL file
- Client and server init and API wrappers
- Example client application
Signed-off-by: Kevin Peng <kevin.peng@arm.com>
Signed-off-by: Jamie Fox <jamie.fox@arm.com>
Signed-off-by: Summer Qin <summer.qin@arm.com>
Change-Id: If6180fd3e596c9daabd31262fb10ae0a1583bc9b
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index 19ccca7..449cbc5 100755
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2020-2022, Arm Limited. All rights reserved.
+# Copyright (c) 2020-2023, Arm Limited. All rights reserved.
# Copyright (c) 2022-2023 Cypress Semiconductor Corporation (an Infineon company)
# or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
#
@@ -250,16 +250,27 @@
############################# Test integration #################################
+if (CONFIG_TFM_ERPC_TEST_FRAMEWORK)
+ set(CONFIG_ENABLE_NS_UART_TX_RX_CONTROL ON CACHE BOOL "Whether to enable UART TX RX")
+ set(ERPC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../erpc)
+ add_subdirectory(${ERPC_DIR}/server ${CMAKE_CURRENT_BINARY_DIR}/erpc/server)
+endif()
+
add_library(tfm_test_app STATIC EXCLUDE_FROM_ALL)
target_sources(tfm_test_app
PRIVATE
- test_app.c
+ $<$<NOT:$<BOOL:${CONFIG_TFM_ERPC_TEST_FRAMEWORK}>>:test_app.c>
+ $<$<BOOL:${CONFIG_TFM_ERPC_TEST_FRAMEWORK}>:erpc_app.c>
+ $<$<BOOL:${CONFIG_TFM_ERPC_TEST_FRAMEWORK}>:${ERPC_REPO_PATH}/erpc_c/setup/erpc_setup_uart_cmsis.cpp>
+ $<$<BOOL:${CONFIG_TFM_ERPC_TEST_FRAMEWORK}>:${ERPC_REPO_PATH}/erpc_c/transports/erpc_uart_cmsis_transport.cpp>
)
target_include_directories(tfm_test_app
PUBLIC
.
+ $<$<BOOL:${CONFIG_TFM_ERPC_TEST_FRAMEWORK}>:${ERPC_DIR}/server>
+ $<$<BOOL:${CONFIG_TFM_ERPC_TEST_FRAMEWORK}>:${ERPC_REPO_PATH}/erpc_c/transports>
)
target_link_libraries(tfm_test_app
@@ -268,6 +279,7 @@
$<$<BOOL:${TEST_PSA_API}>:val_nspe>
$<$<BOOL:${TEST_PSA_API}>:pal_nspe>
$<$<BOOL:${TEST_PSA_API}>:test_combine>
+ $<$<BOOL:${CONFIG_TFM_ERPC_TEST_FRAMEWORK}>:erpc_server>
tfm_api_ns
tfm_log
)
diff --git a/app/erpc_app.c b/app/erpc_app.c
new file mode 100644
index 0000000..af87f94
--- /dev/null
+++ b/app/erpc_app.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2017-2023, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include "test_app.h"
+#include "tfm_log.h"
+#include "erpc_server_start.h"
+#include "target_cfg.h"
+
+#include "Driver_USART.h"
+#ifdef ERPC_UART
+extern ARM_DRIVER_USART ERPC_UART;
+#else
+#error "ERPC_UART is not provided!"
+#endif
+
+__attribute__((noreturn))
+void test_app(void *argument)
+{
+ UNUSED_VARIABLE(argument);
+
+ erpc_transport_t transport;
+
+ transport = erpc_transport_cmsis_uart_init((void *)&ERPC_UART);
+ if (!transport) {
+ LOG_MSG("eRPC transport init failed!\r\n");
+ }
+
+ erpc_server_start(transport);
+
+ for (;;) {
+ }
+}
diff --git a/erpc/client/CMakeLists.txt b/erpc/client/CMakeLists.txt
new file mode 100644
index 0000000..61a561d
--- /dev/null
+++ b/erpc/client/CMakeLists.txt
@@ -0,0 +1,68 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+cmake_minimum_required(VERSION 3.15)
+
+if (NOT DEFINED TFM_INSTALL_PATH)
+ if (DEFINED ENV{TFM_INSTALL_PATH})
+ set(TFM_INSTALL_PATH $ENV{TFM_INSTALL_PATH})
+ else()
+ message(FATAL_ERROR "TFM_INSTALL_PATH not found. Please set TFM_INSTALL_PATH environment variable or pass -DTFM_INSTALL_PATH flag.")
+ endif()
+endif()
+
+if (NOT DEFINED ERPC_REPO_PATH)
+ if (DEFINED ENV{ERPC_REPO_PATH})
+ set(ERPC_REPO_PATH $ENV{ERPC_REPO_PATH})
+ else()
+ message(FATAL_ERROR "ERPC_REPO_PATH not found. Please set ERPC_REPO_PATH environment variable or pass -DERPC_REPO_PATH flag.")
+ endif()
+endif()
+
+# Set eRPC config file. Need to provide config file with an absolute path.
+if (ERPC_CONFIG_FILE)
+ if (NOT EXISTS ${ERPC_CONFIG_FILE})
+ message(FATAL_ERROR "ERPC_CONFIG_FILE does not exist. Please provide it with an absolute path.")
+ endif()
+ # Get the path of the customized eRPC config file
+ get_filename_component(ERPC_CONFIG_FILE_PATH ${ERPC_CONFIG_FILE} DIRECTORY)
+else()
+ # Use default one
+ set(ERPC_CONFIG_FILE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/config")
+endif()
+
+add_library(erpc_client STATIC)
+
+target_sources(erpc_client
+ PRIVATE
+ erpc_client_wrapper.c
+ erpc_client_start.c
+ # eRPC files
+ ${ERPC_REPO_PATH}/erpc_c/infra/erpc_basic_codec.cpp
+ ${ERPC_REPO_PATH}/erpc_c/infra/erpc_client_manager.cpp
+ ${ERPC_REPO_PATH}/erpc_c/infra/erpc_crc16.cpp
+ ${ERPC_REPO_PATH}/erpc_c/infra/erpc_framed_transport.cpp
+ ${ERPC_REPO_PATH}/erpc_c/infra/erpc_message_buffer.cpp
+ ${ERPC_REPO_PATH}/erpc_c/port/erpc_serial.cpp
+ ${ERPC_REPO_PATH}/erpc_c/setup/erpc_client_setup.cpp
+ ${ERPC_REPO_PATH}/erpc_c/setup/erpc_setup_mbf_dynamic.cpp
+ # Generated files
+ ${CMAKE_CURRENT_SOURCE_DIR}/../generated_files/tfm_erpc_psa_client_api_client.cpp
+ $<$<BOOL:${CONFIG_TFM_CONNECTION_BASED_SERVICE_API}>:${CMAKE_CURRENT_SOURCE_DIR}/../generated_files/tfm_erpc_psa_connection_api_client.cpp>
+)
+
+target_include_directories(erpc_client
+ PUBLIC
+ ${ERPC_REPO_PATH}/erpc_c/port
+ ${ERPC_REPO_PATH}/erpc_c/infra
+ ${ERPC_REPO_PATH}/erpc_c/transports
+ ${ERPC_REPO_PATH}/erpc_c/setup
+ ${CMAKE_CURRENT_SOURCE_DIR}/
+ ${CMAKE_CURRENT_SOURCE_DIR}/../generated_files
+ ${TFM_INSTALL_PATH}/interface/include
+ ${ERPC_CONFIG_FILE_PATH}/
+)
diff --git a/erpc/client/config/erpc_config.h b/erpc/client/config/erpc_config.h
new file mode 100644
index 0000000..11aada4
--- /dev/null
+++ b/erpc/client/config/erpc_config.h
@@ -0,0 +1,212 @@
+/*
+ * Copyright (c) 2016, Freescale Semiconductor, Inc.
+ * Copyright 2016-2020 NXP
+ * Copyright 2020-2021 ACRIOS Systems s.r.o.
+ * Copyright (c) 2023, Arm Limited. All rights reserved.
+ * All rights reserved.
+ *
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef _ERPC_CONFIG_H_
+#define _ERPC_CONFIG_H_
+
+/*!
+ * @addtogroup config
+ * @{
+ * @file
+ */
+
+////////////////////////////////////////////////////////////////////////////////
+// Declarations
+////////////////////////////////////////////////////////////////////////////////
+
+//! @name Threading model options
+//@{
+#define ERPC_ALLOCATION_POLICY_DYNAMIC (0U) //!< Dynamic allocation policy
+#define ERPC_ALLOCATION_POLICY_STATIC (1U) //!< Static allocation policy
+
+#define ERPC_THREADS_NONE (0U) //!< No threads.
+#define ERPC_THREADS_PTHREADS (1U) //!< POSIX pthreads.
+#define ERPC_THREADS_FREERTOS (2U) //!< FreeRTOS.
+#define ERPC_THREADS_ZEPHYR (3U) //!< ZEPHYR.
+#define ERPC_THREADS_MBED (4U) //!< Mbed OS
+#define ERPC_THREADS_WIN32 (5U) //!< WIN32
+#define ERPC_THREADS_THREADX (6U) //!< THREADX
+
+#define ERPC_NOEXCEPT_DISABLED (0U) //!< Disabling noexcept feature.
+#define ERPC_NOEXCEPT_ENABLED (1U) //!< Enabling noexcept feature.
+
+#define ERPC_NESTED_CALLS_DISABLED (0U) //!< No nested calls support.
+#define ERPC_NESTED_CALLS_ENABLED (1U) //!< Nested calls support.
+
+#define ERPC_NESTED_CALLS_DETECTION_DISABLED (0U) //!< Nested calls detection disabled.
+#define ERPC_NESTED_CALLS_DETECTION_ENABLED (1U) //!< Nested calls detection enabled.
+
+#define ERPC_MESSAGE_LOGGING_DISABLED (0U) //!< Trace functions disabled.
+#define ERPC_MESSAGE_LOGGING_ENABLED (1U) //!< Trace functions enabled.
+
+#define ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED (0U) //!< Do not use MCMGR for MU ISR management.
+#define ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED (1U) //!< Use MCMGR for MU ISR management.
+
+#define ERPC_PRE_POST_ACTION_DISABLED (0U) //!< Pre post shim callbacks functions disabled.
+#define ERPC_PRE_POST_ACTION_ENABLED (1U) //!< Pre post shim callback functions enabled.
+
+#define ERPC_PRE_POST_ACTION_DEFAULT_DISABLED (0U) //!< Pre post shim default callbacks functions disabled.
+#define ERPC_PRE_POST_ACTION_DEFAULT_ENABLED (1U) //!< Pre post shim default callback functions enabled.
+//@}
+
+//! @name Configuration options
+//@{
+
+//! @def ERPC_ALLOCATION_POLICY
+//!
+//! @brief Choose which allocation policy should be used.
+//!
+//! Set ERPC_ALLOCATION_POLICY_DYNAMIC if dynamic allocations should be used.
+//! Set ERPC_ALLOCATION_POLICY_STATIC if static allocations should be used.
+//!
+//! Default value is ERPC_ALLOCATION_POLICY_DYNAMIC or in case of FreeRTOS it can be auto-detected if __has_include() is
+//! supported by compiler. Uncomment comment bellow to use static allocation policy. In case of static implementation
+//! user need consider another values to set (ERPC_CODEC_COUNT, ERPC_MESSAGE_LOGGERS_COUNT,
+//! ERPC_CLIENTS_THREADS_AMOUNT).
+// #define ERPC_ALLOCATION_POLICY (ERPC_ALLOCATION_POLICY_STATIC)
+
+//! @def ERPC_CODEC_COUNT
+//!
+//! @brief Set amount of codecs objects used simultaneously in case of ERPC_ALLOCATION_POLICY is set to
+//! ERPC_ALLOCATION_POLICY_STATIC. For example if client or server is used in one thread then 1. If both are used in one
+//! thread per each then 2, ... Default value 2.
+// #define ERPC_CODEC_COUNT (2U)
+
+//! @def ERPC_MESSAGE_LOGGERS_COUNT
+//!
+//! @brief Set amount of message loggers objects used simultaneously in case of ERPC_ALLOCATION_POLICY is set to
+//! ERPC_ALLOCATION_POLICY_STATIC.
+//! For example if client or server is used in one thread then 1. If both are used in one thread per each then 2, ...
+//! For arbitrated client 1 is enough.
+//! Default value 0 (May not be used).
+// #define ERPC_MESSAGE_LOGGERS_COUNT (0U)
+
+//! @def ERPC_CLIENTS_THREADS_AMOUNT
+//!
+//! @brief Set amount of client threads objects used in case of ERPC_ALLOCATION_POLICY is set to
+//! ERPC_ALLOCATION_POLICY_STATIC. Default value 1 (Most of current cases).
+// #define ERPC_CLIENTS_THREADS_AMOUNT (1U)
+
+//! @def ERPC_THREADS
+//!
+//! @brief Select threading model.
+//!
+//! Set to one of the @c ERPC_THREADS_x macros to specify the threading model used by eRPC.
+//!
+//! Leave commented out to attempt to auto-detect. Auto-detection works well for pthreads.
+//! FreeRTOS can be detected when building with compilers that support __has_include().
+//! Otherwise, the default is no threading.
+//#define ERPC_THREADS (ERPC_THREADS_PTHREADS)
+
+//! @def ERPC_DEFAULT_BUFFER_SIZE
+//!
+//! Uncomment to change the size of buffers allocated by one of MessageBufferFactory.
+//! (@ref client_setup and @ref server_setup). The default size is set to 256.
+//! For RPMsg transport layer, ERPC_DEFAULT_BUFFER_SIZE must be 2^n - 16.
+//#define ERPC_DEFAULT_BUFFER_SIZE (256U)
+
+//! @def ERPC_DEFAULT_BUFFERS_COUNT
+//!
+//! Uncomment to change the count of buffers allocated by one of statically allocated messages.
+//! Default value is set to 2.
+//#define ERPC_DEFAULT_BUFFERS_COUNT (2U)
+
+//! @def ERPC_NOEXCEPT
+//!
+//! @brief Disable/enable noexcept support.
+//!
+//! Uncomment for using noexcept feature.
+//#define ERPC_NOEXCEPT (ERPC_NOEXCEPT_ENABLED)
+
+//! @def ERPC_NESTED_CALLS
+//!
+//! Default set to ERPC_NESTED_CALLS_DISABLED. Uncomment when callbacks, or other eRPC
+//! functions are called from server implementation of another eRPC call. Nested functions
+//! need to be marked as @nested in IDL.
+//#define ERPC_NESTED_CALLS (ERPC_NESTED_CALLS_ENABLED)
+
+//! @def ERPC_NESTED_CALLS_DETECTION
+//!
+//! Default set to ERPC_NESTED_CALLS_DETECTION_ENABLED when NDEBUG macro is presented.
+//! This serve for locating nested calls in code. Nested calls are calls where inside eRPC function
+//! on server side is called another eRPC function (like callbacks). Code need be a bit changed
+//! to support nested calls. See ERPC_NESTED_CALLS macro.
+//#define ERPC_NESTED_CALLS_DETECTION (ERPC_NESTED_CALLS_DETECTION_DISABLED)
+
+//! @def ERPC_MESSAGE_LOGGING
+//!
+//! Enable eRPC message logging code through the eRPC. Take look into "erpc_message_loggers.h". Can be used for base
+//! printing messages, or sending data to another system for data analysis. Default set to
+//! ERPC_MESSAGE_LOGGING_DISABLED.
+//!
+//! Uncomment for using logging feature.
+//#define ERPC_MESSAGE_LOGGING (ERPC_MESSAGE_LOGGING_ENABLED)
+
+//! @def ERPC_TRANSPORT_MU_USE_MCMGR
+//!
+//! @brief MU transport layer configuration.
+//!
+//! Set to one of the @c ERPC_TRANSPORT_MU_USE_MCMGR_x macros to configure the MCMGR usage in MU transport layer.
+//!
+//! MU transport layer could leverage the Multicore Manager (MCMGR) component for Inter-Core
+//! interrupts / MU interrupts management or the Inter-Core interrupts can be managed by itself (MUX_IRQHandler
+//! overloading). By default, ERPC_TRANSPORT_MU_USE_MCMGR is set to ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED when mcmgr.h
+//! is part of the project, otherwise the ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED option is used. This settings can be
+//! overwritten from the erpc_config.h by uncommenting the ERPC_TRANSPORT_MU_USE_MCMGR macro definition. Do not forget
+//! to add the MCMGR library into your project when ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED option is used! See the
+//! erpc_mu_transport.h for additional MU settings.
+//#define ERPC_TRANSPORT_MU_USE_MCMGR ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED
+//@}
+
+//! @def ERPC_PRE_POST_ACTION
+//!
+//! Enable eRPC pre and post callback functions shim code. Take look into "erpc_pre_post_action.h". Can be used for
+//! detection of eRPC call freeze, ... Default set to ERPC_PRE_POST_ACTION_DISABLED.
+//!
+//! Uncomment for using pre post callback feature.
+//#define ERPC_PRE_POST_ACTION (ERPC_PRE_POST_ACTION_ENABLED)
+
+//! @def ERPC_PRE_POST_ACTION_DEFAULT
+//!
+//! Enable eRPC pre and post default callback functions. Take look into "erpc_setup_extensions.h". Can be used for
+//! detection of eRPC call freeze, ... Default set to ERPC_PRE_POST_ACTION_DEFAULT_DISABLED.
+//!
+//! Uncomment for using pre post default callback feature.
+//#define ERPC_PRE_POST_ACTION_DEFAULT (ERPC_PRE_POST_ACTION_DEFAULT_ENABLED)
+
+//! @name Assert function definition
+//@{
+//! User custom asser defition. Include header file if needed before bellow line. If assert is not enabled, default will
+//! be used.
+// #define erpc_assert(condition)
+//@}
+
+//! @def ENDIANES_HEADER
+//!
+//! Include header file that controls the communication endianness
+//!
+//! Uncomment for example behaviour for endianness agnostic with:
+//! 1. communication in little endian.
+//! 2. current processor is big endian.
+//! 3. pointer size is 32 bit.
+//! 4. float+double scheme not defined, so throws assert if passes.
+//! #define ERPC_PROCESSOR_ENDIANNESS_LITTLE 0
+//! #define ERPC_COMMUNICATION_LITTLE 1
+//! #define ERPC_POINTER_SIZE_16 0
+//! #define ERPC_POINTER_SIZE_32 1
+//! #define ERPC_POINTER_SIZE_64 0
+//! #define ENDIANNESS_HEADER "erpc_endianness_agnostic_example.h"
+
+/*! @} */
+#endif // _ERPC_CONFIG_H_
+////////////////////////////////////////////////////////////////////////////////
+// EOF
+////////////////////////////////////////////////////////////////////////////////
diff --git a/erpc/client/erpc_client_start.c b/erpc/client/erpc_client_start.c
new file mode 100644
index 0000000..f66b73b
--- /dev/null
+++ b/erpc/client/erpc_client_start.c
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2023, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include "erpc_mbf_setup.h"
+#include "erpc_client_setup.h"
+#include "erpc_client_start.h"
+
+void erpc_client_start(erpc_transport_t transport)
+{
+ erpc_mbf_t message_buffer_factory;
+
+ message_buffer_factory = erpc_mbf_dynamic_init();
+ erpc_client_init(transport, message_buffer_factory);
+}
diff --git a/erpc/client/erpc_client_start.h b/erpc/client/erpc_client_start.h
new file mode 100644
index 0000000..37c056a
--- /dev/null
+++ b/erpc/client/erpc_client_start.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2023, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __ERPC_CLIENT_START_H__
+#define __ERPC_CLIENT_START_H__
+
+#include "erpc_transport_setup.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief eRPC Client initialization.
+ *
+ * \param[in] transport Transport to use.
+ */
+void erpc_client_start(erpc_transport_t transport);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ERPC_CLIENT_START_H__ */
diff --git a/erpc/client/erpc_client_wrapper.c b/erpc/client/erpc_client_wrapper.c
new file mode 100644
index 0000000..37b5f82
--- /dev/null
+++ b/erpc/client/erpc_client_wrapper.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2023, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include <stddef.h>
+#include "psa/client.h"
+#include "tfm_erpc_psa_client_api.h"
+
+psa_status_t psa_call(psa_handle_t handle, int32_t type,
+ const psa_invec *in_vec, size_t in_len,
+ psa_outvec *out_vec, size_t out_len)
+{
+ psa_status_t status;
+ size_t i;
+ binary_t in_elements[PSA_MAX_IOVEC];
+ binary_t out_elements[PSA_MAX_IOVEC];
+ list_binary_1_t erpc_in_vec = {in_elements, in_len};
+ list_binary_1_t erpc_out_vec = {out_elements, out_len};
+
+ if (in_len + out_len > PSA_MAX_IOVEC) {
+ return PSA_ERROR_PROGRAMMER_ERROR;
+ }
+
+ /* Copy PSA iovecs into RPC binary lists */
+ for (i = 0; i < in_len; ++i) {
+ in_elements[i] = (binary_t){(void *)in_vec[i].base, in_vec[i].len};
+ }
+ for (i = 0; i < out_len; ++i) {
+ out_elements[i] = (binary_t){out_vec[i].base, out_vec[i].len};
+ }
+
+ status = erpc_psa_call(handle, type, &erpc_in_vec, &erpc_out_vec);
+
+ if (status != PSA_SUCCESS) {
+ return status;
+ }
+
+ /* Copy updated out length into PSA outvec */
+ for (i = 0; i < out_len; ++i) {
+ out_vec[i].len = out_elements[i].dataLength;
+ }
+
+ return status;
+}
diff --git a/erpc/generated_files/tfm_erpc_psa_client_api.h b/erpc/generated_files/tfm_erpc_psa_client_api.h
new file mode 100644
index 0000000..6b6760e
--- /dev/null
+++ b/erpc/generated_files/tfm_erpc_psa_client_api.h
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2022, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/*
+ * Generated by erpcgen 1.9.1 on Fri Dec 16 14:51:11 2022.
+ *
+ * AUTOGENERATED - DO NOT EDIT
+ */
+
+
+#if !defined(_tfm_erpc_psa_client_api_h_)
+#define _tfm_erpc_psa_client_api_h_
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include "erpc_version.h"
+#include "psa/client.h"
+
+#if 10901 != ERPC_VERSION_NUMBER
+#error "The generated shim code version is different to the rest of eRPC code."
+#endif
+
+#if !defined(ERPC_TYPE_DEFINITIONS)
+#define ERPC_TYPE_DEFINITIONS
+
+// Aliases data types declarations
+typedef struct list_binary_1_t list_binary_1_t;
+typedef struct binary_t binary_t;
+
+// Structures/unions data types declarations
+struct list_binary_1_t
+{
+ binary_t * elements;
+ uint32_t elementsCount;
+};
+
+struct binary_t
+{
+ uint8_t * data;
+ uint32_t dataLength;
+};
+
+
+#endif // ERPC_TYPE_DEFINITIONS
+
+/*! @brief psa_client_api identifiers */
+enum _psa_client_api_ids
+{
+ kpsa_client_api_service_id = 1,
+ kpsa_client_api_psa_framework_version_id = 1,
+ kpsa_client_api_psa_version_id = 2,
+ kpsa_client_api_erpc_psa_call_id = 3,
+};
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+//! @name psa_client_api
+//@{
+uint32_t psa_framework_version(void);
+
+uint32_t psa_version(uint32_t sid);
+
+psa_status_t erpc_psa_call(psa_handle_t handle, int32_t t, const list_binary_1_t * erpc_in_vec, list_binary_1_t * erpc_out_vec);
+//@}
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif // _tfm_erpc_psa_client_api_h_
diff --git a/erpc/generated_files/tfm_erpc_psa_client_api_client.cpp b/erpc/generated_files/tfm_erpc_psa_client_api_client.cpp
new file mode 100644
index 0000000..fa7dee9
--- /dev/null
+++ b/erpc/generated_files/tfm_erpc_psa_client_api_client.cpp
@@ -0,0 +1,300 @@
+/*
+ * Copyright (c) 2022, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/*
+ * Generated by erpcgen 1.9.1 on Fri Dec 16 14:51:11 2022.
+ *
+ * AUTOGENERATED - DO NOT EDIT
+ */
+
+
+#include "erpc_client_manager.h"
+#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
+#include "erpc_port.h"
+#endif
+#include "erpc_codec.h"
+extern "C"
+{
+#include "tfm_erpc_psa_client_api.h"
+// import callbacks declaration from other groups
+#include "tfm_erpc_psa_connection_api.h"
+}
+
+#if 10901 != ERPC_VERSION_NUMBER
+#error "The generated shim code version is different to the rest of eRPC code."
+#endif
+
+using namespace erpc;
+using namespace std;
+
+extern ClientManager *g_client;
+
+//! @brief Function to write struct binary_t
+static void write_binary_t_struct(erpc::Codec * codec, const binary_t * data);
+
+//! @brief Function to write struct list_binary_1_t
+static void write_list_binary_1_t_struct(erpc::Codec * codec, const list_binary_1_t * data);
+
+
+// Write struct binary_t function implementation
+static void write_binary_t_struct(erpc::Codec * codec, const binary_t * data)
+{
+ if(NULL == data)
+ {
+ return;
+ }
+
+ codec->writeBinary(data->dataLength, data->data);
+}
+
+// Write struct list_binary_1_t function implementation
+static void write_list_binary_1_t_struct(erpc::Codec * codec, const list_binary_1_t * data)
+{
+ if(NULL == data)
+ {
+ return;
+ }
+
+ codec->startWriteList(data->elementsCount);
+ for (uint32_t listCount = 0U; listCount < data->elementsCount; ++listCount)
+ {
+ write_binary_t_struct(codec, &(data->elements[listCount]));
+ }
+}
+
+
+//! @brief Function to read struct binary_t
+static void read_binary_t_struct(erpc::Codec * codec, binary_t * data);
+
+//! @brief Function to read struct list_binary_1_t
+static void read_list_binary_1_t_struct(erpc::Codec * codec, list_binary_1_t * data);
+
+
+// Read struct binary_t function implementation
+static void read_binary_t_struct(erpc::Codec * codec, binary_t * data)
+{
+ if(NULL == data)
+ {
+ return;
+ }
+
+ uint8_t * data_local;
+ codec->readBinary(&data->dataLength, &data_local);
+ memcpy(data->data, data_local, data->dataLength);
+}
+
+// Read struct list_binary_1_t function implementation
+static void read_list_binary_1_t_struct(erpc::Codec * codec, list_binary_1_t * data)
+{
+ if(NULL == data)
+ {
+ return;
+ }
+
+ codec->startReadList(&data->elementsCount);
+ for (uint32_t listCount = 0U; listCount < data->elementsCount; ++listCount)
+ {
+ read_binary_t_struct(codec, &(data->elements[listCount]));
+ }
+}
+
+
+
+// psa_client_api interface psa_framework_version function client shim.
+uint32_t psa_framework_version(void)
+{
+ erpc_status_t err = kErpcStatus_Success;
+
+ uint32_t result;
+
+#if ERPC_PRE_POST_ACTION
+ pre_post_action_cb preCB = g_client->getPreCB();
+ if (preCB)
+ {
+ preCB();
+ }
+#endif
+
+ // Get a new request.
+ RequestContext request = g_client->createRequest(false);
+
+ // Encode the request.
+ Codec * codec = request.getCodec();
+
+ if (codec == NULL)
+ {
+ err = kErpcStatus_MemoryError;
+ }
+ else
+ {
+ codec->startWriteMessage(kInvocationMessage, kpsa_client_api_service_id, kpsa_client_api_psa_framework_version_id, request.getSequence());
+
+ // Send message to server
+ // Codec status is checked inside this function.
+ g_client->performRequest(request);
+
+ codec->read(&result);
+
+ err = codec->getStatus();
+ }
+
+ // Dispose of the request.
+ g_client->releaseRequest(request);
+
+ // Invoke error handler callback function
+ g_client->callErrorHandler(err, kpsa_client_api_psa_framework_version_id);
+
+#if ERPC_PRE_POST_ACTION
+ pre_post_action_cb postCB = g_client->getPostCB();
+ if (postCB)
+ {
+ postCB();
+ }
+#endif
+
+
+ if (err != kErpcStatus_Success)
+ {
+ result = 0xFFFFFFFFU;
+ }
+
+ return result;
+}
+
+// psa_client_api interface psa_version function client shim.
+uint32_t psa_version(uint32_t sid)
+{
+ erpc_status_t err = kErpcStatus_Success;
+
+ uint32_t result;
+
+#if ERPC_PRE_POST_ACTION
+ pre_post_action_cb preCB = g_client->getPreCB();
+ if (preCB)
+ {
+ preCB();
+ }
+#endif
+
+ // Get a new request.
+ RequestContext request = g_client->createRequest(false);
+
+ // Encode the request.
+ Codec * codec = request.getCodec();
+
+ if (codec == NULL)
+ {
+ err = kErpcStatus_MemoryError;
+ }
+ else
+ {
+ codec->startWriteMessage(kInvocationMessage, kpsa_client_api_service_id, kpsa_client_api_psa_version_id, request.getSequence());
+
+ codec->write(sid);
+
+ // Send message to server
+ // Codec status is checked inside this function.
+ g_client->performRequest(request);
+
+ codec->read(&result);
+
+ err = codec->getStatus();
+ }
+
+ // Dispose of the request.
+ g_client->releaseRequest(request);
+
+ // Invoke error handler callback function
+ g_client->callErrorHandler(err, kpsa_client_api_psa_version_id);
+
+#if ERPC_PRE_POST_ACTION
+ pre_post_action_cb postCB = g_client->getPostCB();
+ if (postCB)
+ {
+ postCB();
+ }
+#endif
+
+
+ if (err != kErpcStatus_Success)
+ {
+ result = 0xFFFFFFFFU;
+ }
+
+ return result;
+}
+
+// psa_client_api interface erpc_psa_call function client shim.
+psa_status_t erpc_psa_call(psa_handle_t handle, int32_t t, const list_binary_1_t * erpc_in_vec, list_binary_1_t * erpc_out_vec)
+{
+ erpc_status_t err = kErpcStatus_Success;
+
+ psa_status_t result;
+
+#if ERPC_PRE_POST_ACTION
+ pre_post_action_cb preCB = g_client->getPreCB();
+ if (preCB)
+ {
+ preCB();
+ }
+#endif
+
+ // Get a new request.
+ RequestContext request = g_client->createRequest(false);
+
+ // Encode the request.
+ Codec * codec = request.getCodec();
+
+ if (codec == NULL)
+ {
+ err = kErpcStatus_MemoryError;
+ }
+ else
+ {
+ codec->startWriteMessage(kInvocationMessage, kpsa_client_api_service_id, kpsa_client_api_erpc_psa_call_id, request.getSequence());
+
+ codec->write(handle);
+
+ codec->write(t);
+
+ write_list_binary_1_t_struct(codec, erpc_in_vec);
+
+ write_list_binary_1_t_struct(codec, erpc_out_vec);
+
+ // Send message to server
+ // Codec status is checked inside this function.
+ g_client->performRequest(request);
+
+ read_list_binary_1_t_struct(codec, erpc_out_vec);
+
+ codec->read(&result);
+
+ err = codec->getStatus();
+ }
+
+ // Dispose of the request.
+ g_client->releaseRequest(request);
+
+ // Invoke error handler callback function
+ g_client->callErrorHandler(err, kpsa_client_api_erpc_psa_call_id);
+
+#if ERPC_PRE_POST_ACTION
+ pre_post_action_cb postCB = g_client->getPostCB();
+ if (postCB)
+ {
+ postCB();
+ }
+#endif
+
+
+ if (err != kErpcStatus_Success)
+ {
+ result = -1;
+ }
+
+ return result;
+}
diff --git a/erpc/generated_files/tfm_erpc_psa_client_api_server.cpp b/erpc/generated_files/tfm_erpc_psa_client_api_server.cpp
new file mode 100644
index 0000000..82fb722
--- /dev/null
+++ b/erpc/generated_files/tfm_erpc_psa_client_api_server.cpp
@@ -0,0 +1,367 @@
+/*
+ * Copyright (c) 2022, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/*
+ * Generated by erpcgen 1.9.1 on Fri Dec 16 14:51:11 2022.
+ *
+ * AUTOGENERATED - DO NOT EDIT
+ */
+
+
+#include "tfm_erpc_psa_client_api_server.h"
+#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
+#include <new>
+#include "erpc_port.h"
+#endif
+#include "erpc_manually_constructed.h"
+
+#if 10901 != ERPC_VERSION_NUMBER
+#error "The generated shim code version is different to the rest of eRPC code."
+#endif
+
+using namespace erpc;
+using namespace std;
+
+#if ERPC_NESTED_CALLS_DETECTION
+extern bool nestingDetection;
+#endif
+
+ERPC_MANUALLY_CONSTRUCTED_STATIC(psa_client_api_service, s_psa_client_api_service);
+
+
+//! @brief Function to read struct binary_t
+static void read_binary_t_struct(erpc::Codec * codec, binary_t * data);
+
+//! @brief Function to read struct list_binary_1_t
+static void read_list_binary_1_t_struct(erpc::Codec * codec, list_binary_1_t * data);
+
+
+// Read struct binary_t function implementation
+static void read_binary_t_struct(erpc::Codec * codec, binary_t * data)
+{
+ if(NULL == data)
+ {
+ return;
+ }
+
+ uint8_t * data_local;
+ codec->readBinary(&data->dataLength, &data_local);
+ data->data = (uint8_t *) erpc_malloc(data->dataLength * sizeof(uint8_t));
+ if ((data->data == NULL) && (data->dataLength > 0))
+ {
+ codec->updateStatus(kErpcStatus_MemoryError);
+ }
+ else
+ {
+ memcpy(data->data, data_local, data->dataLength);
+ }
+}
+
+// Read struct list_binary_1_t function implementation
+static void read_list_binary_1_t_struct(erpc::Codec * codec, list_binary_1_t * data)
+{
+ if(NULL == data)
+ {
+ return;
+ }
+
+ codec->startReadList(&data->elementsCount);
+ data->elements = (binary_t *) erpc_malloc(data->elementsCount * sizeof(binary_t));
+ if ((data->elements == NULL) && (data->elementsCount > 0))
+ {
+ codec->updateStatus(kErpcStatus_MemoryError);
+ }
+ for (uint32_t listCount = 0U; listCount < data->elementsCount; ++listCount)
+ {
+ read_binary_t_struct(codec, &(data->elements[listCount]));
+ }
+}
+
+
+//! @brief Function to write struct binary_t
+static void write_binary_t_struct(erpc::Codec * codec, const binary_t * data);
+
+//! @brief Function to write struct list_binary_1_t
+static void write_list_binary_1_t_struct(erpc::Codec * codec, const list_binary_1_t * data);
+
+
+// Write struct binary_t function implementation
+static void write_binary_t_struct(erpc::Codec * codec, const binary_t * data)
+{
+ if(NULL == data)
+ {
+ return;
+ }
+
+ codec->writeBinary(data->dataLength, data->data);
+}
+
+// Write struct list_binary_1_t function implementation
+static void write_list_binary_1_t_struct(erpc::Codec * codec, const list_binary_1_t * data)
+{
+ if(NULL == data)
+ {
+ return;
+ }
+
+ codec->startWriteList(data->elementsCount);
+ for (uint32_t listCount = 0U; listCount < data->elementsCount; ++listCount)
+ {
+ write_binary_t_struct(codec, &(data->elements[listCount]));
+ }
+}
+
+
+//! @brief Function to free space allocated inside struct binary_t
+static void free_binary_t_struct(binary_t * data);
+
+//! @brief Function to free space allocated inside struct list_binary_1_t
+static void free_list_binary_1_t_struct(list_binary_1_t * data);
+
+
+// Free space allocated inside struct binary_t function implementation
+static void free_binary_t_struct(binary_t * data)
+{
+ erpc_free(data->data);
+}
+
+// Free space allocated inside struct list_binary_1_t function implementation
+static void free_list_binary_1_t_struct(list_binary_1_t * data)
+{
+ for (uint32_t listCount = 0; listCount < data->elementsCount; ++listCount)
+ {
+ free_binary_t_struct(&data->elements[listCount]);
+ }
+
+ erpc_free(data->elements);
+}
+
+
+
+// Call the correct server shim based on method unique ID.
+erpc_status_t psa_client_api_service::handleInvocation(uint32_t methodId, uint32_t sequence, Codec * codec, MessageBufferFactory *messageFactory)
+{
+ erpc_status_t erpcStatus;
+ switch (methodId)
+ {
+ case kpsa_client_api_psa_framework_version_id:
+ {
+ erpcStatus = psa_framework_version_shim(codec, messageFactory, sequence);
+ break;
+ }
+
+ case kpsa_client_api_psa_version_id:
+ {
+ erpcStatus = psa_version_shim(codec, messageFactory, sequence);
+ break;
+ }
+
+ case kpsa_client_api_erpc_psa_call_id:
+ {
+ erpcStatus = erpc_psa_call_shim(codec, messageFactory, sequence);
+ break;
+ }
+
+ default:
+ {
+ erpcStatus = kErpcStatus_InvalidArgument;
+ break;
+ }
+ }
+
+ return erpcStatus;
+}
+
+// Server shim for psa_framework_version of psa_client_api interface.
+erpc_status_t psa_client_api_service::psa_framework_version_shim(Codec * codec, MessageBufferFactory *messageFactory, uint32_t sequence)
+{
+ erpc_status_t err = kErpcStatus_Success;
+
+ uint32_t result;
+
+ // startReadMessage() was already called before this shim was invoked.
+
+ err = codec->getStatus();
+ if (err == kErpcStatus_Success)
+ {
+ // Invoke the actual served function.
+#if ERPC_NESTED_CALLS_DETECTION
+ nestingDetection = true;
+#endif
+ result = psa_framework_version();
+#if ERPC_NESTED_CALLS_DETECTION
+ nestingDetection = false;
+#endif
+
+ // preparing MessageBuffer for serializing data
+ err = messageFactory->prepareServerBufferForSend(codec->getBuffer());
+ }
+
+ if (err == kErpcStatus_Success)
+ {
+ // preparing codec for serializing data
+ codec->reset();
+
+ // Build response message.
+ codec->startWriteMessage(kReplyMessage, kpsa_client_api_service_id, kpsa_client_api_psa_framework_version_id, sequence);
+
+ codec->write(result);
+
+ err = codec->getStatus();
+ }
+
+ return err;
+}
+
+// Server shim for psa_version of psa_client_api interface.
+erpc_status_t psa_client_api_service::psa_version_shim(Codec * codec, MessageBufferFactory *messageFactory, uint32_t sequence)
+{
+ erpc_status_t err = kErpcStatus_Success;
+
+ uint32_t sid;
+ uint32_t result;
+
+ // startReadMessage() was already called before this shim was invoked.
+
+ codec->read(&sid);
+
+ err = codec->getStatus();
+ if (err == kErpcStatus_Success)
+ {
+ // Invoke the actual served function.
+#if ERPC_NESTED_CALLS_DETECTION
+ nestingDetection = true;
+#endif
+ result = psa_version(sid);
+#if ERPC_NESTED_CALLS_DETECTION
+ nestingDetection = false;
+#endif
+
+ // preparing MessageBuffer for serializing data
+ err = messageFactory->prepareServerBufferForSend(codec->getBuffer());
+ }
+
+ if (err == kErpcStatus_Success)
+ {
+ // preparing codec for serializing data
+ codec->reset();
+
+ // Build response message.
+ codec->startWriteMessage(kReplyMessage, kpsa_client_api_service_id, kpsa_client_api_psa_version_id, sequence);
+
+ codec->write(result);
+
+ err = codec->getStatus();
+ }
+
+ return err;
+}
+
+// Server shim for erpc_psa_call of psa_client_api interface.
+erpc_status_t psa_client_api_service::erpc_psa_call_shim(Codec * codec, MessageBufferFactory *messageFactory, uint32_t sequence)
+{
+ erpc_status_t err = kErpcStatus_Success;
+
+ psa_handle_t handle;
+ int32_t t;
+ list_binary_1_t *erpc_in_vec = NULL;
+ erpc_in_vec = (list_binary_1_t *) erpc_malloc(sizeof(list_binary_1_t));
+ if (erpc_in_vec == NULL)
+ {
+ codec->updateStatus(kErpcStatus_MemoryError);
+ }
+ list_binary_1_t *erpc_out_vec = NULL;
+ erpc_out_vec = (list_binary_1_t *) erpc_malloc(sizeof(list_binary_1_t));
+ if (erpc_out_vec == NULL)
+ {
+ codec->updateStatus(kErpcStatus_MemoryError);
+ }
+ psa_status_t result;
+
+ // startReadMessage() was already called before this shim was invoked.
+
+ codec->read(&handle);
+
+ codec->read(&t);
+
+ read_list_binary_1_t_struct(codec, erpc_in_vec);
+
+ read_list_binary_1_t_struct(codec, erpc_out_vec);
+
+ err = codec->getStatus();
+ if (err == kErpcStatus_Success)
+ {
+ // Invoke the actual served function.
+#if ERPC_NESTED_CALLS_DETECTION
+ nestingDetection = true;
+#endif
+ result = erpc_psa_call(handle, t, erpc_in_vec, erpc_out_vec);
+#if ERPC_NESTED_CALLS_DETECTION
+ nestingDetection = false;
+#endif
+
+ // preparing MessageBuffer for serializing data
+ err = messageFactory->prepareServerBufferForSend(codec->getBuffer());
+ }
+
+ if (err == kErpcStatus_Success)
+ {
+ // preparing codec for serializing data
+ codec->reset();
+
+ // Build response message.
+ codec->startWriteMessage(kReplyMessage, kpsa_client_api_service_id, kpsa_client_api_erpc_psa_call_id, sequence);
+
+ write_list_binary_1_t_struct(codec, erpc_out_vec);
+
+ codec->write(result);
+
+ err = codec->getStatus();
+ }
+
+ if (erpc_in_vec)
+ {
+ free_list_binary_1_t_struct(erpc_in_vec);
+ }
+ erpc_free(erpc_in_vec);
+
+ if (erpc_out_vec)
+ {
+ free_list_binary_1_t_struct(erpc_out_vec);
+ }
+ erpc_free(erpc_out_vec);
+
+ return err;
+}
+
+#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
+erpc_service_t create_psa_client_api_service()
+{
+ return new (nothrow) psa_client_api_service();
+}
+
+void destroy_psa_client_api_service(erpc_service_t service)
+{
+ if (service)
+ {
+ delete (psa_client_api_service *)service;
+ }
+}
+#elif ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_STATIC
+erpc_service_t create_psa_client_api_service()
+{
+ s_psa_client_api_service.construct();
+ return s_psa_client_api_service.get();
+}
+
+void destroy_psa_client_api_service()
+{
+ s_psa_client_api_service.destroy();
+}
+#else
+#warning "Unknown eRPC allocation policy!"
+#endif
diff --git a/erpc/generated_files/tfm_erpc_psa_client_api_server.h b/erpc/generated_files/tfm_erpc_psa_client_api_server.h
new file mode 100644
index 0000000..3146840
--- /dev/null
+++ b/erpc/generated_files/tfm_erpc_psa_client_api_server.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2022, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/*
+ * Generated by erpcgen 1.9.1 on Fri Dec 16 14:51:11 2022.
+ *
+ * AUTOGENERATED - DO NOT EDIT
+ */
+
+
+#if !defined(_tfm_erpc_psa_client_api_server_h_)
+#define _tfm_erpc_psa_client_api_server_h_
+
+#ifdef __cplusplus
+#include "erpc_server.h"
+#include "erpc_codec.h"
+extern "C"
+{
+#include "tfm_erpc_psa_client_api.h"
+#include <stdint.h>
+#include <stdbool.h>
+}
+
+#if 10901 != ERPC_VERSION_NUMBER
+#error "The generated shim code version is different to the rest of eRPC code."
+#endif
+
+
+/*!
+ * @brief Service subclass for psa_client_api.
+ */
+class psa_client_api_service : public erpc::Service
+{
+public:
+ psa_client_api_service() : Service(kpsa_client_api_service_id) {}
+
+ /*! @brief Call the correct server shim based on method unique ID. */
+ virtual erpc_status_t handleInvocation(uint32_t methodId, uint32_t sequence, erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory);
+
+private:
+ /*! @brief Server shim for psa_framework_version of psa_client_api interface. */
+ erpc_status_t psa_framework_version_shim(erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, uint32_t sequence);
+
+ /*! @brief Server shim for psa_version of psa_client_api interface. */
+ erpc_status_t psa_version_shim(erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, uint32_t sequence);
+
+ /*! @brief Server shim for erpc_psa_call of psa_client_api interface. */
+ erpc_status_t erpc_psa_call_shim(erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, uint32_t sequence);
+};
+
+extern "C" {
+#else
+#include "tfm_erpc_psa_client_api.h"
+#endif // __cplusplus
+
+typedef void * erpc_service_t;
+
+erpc_service_t create_psa_client_api_service(void);
+
+#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
+void destroy_psa_client_api_service(erpc_service_t service);
+#elif ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_STATIC
+void destroy_psa_client_api_service(void);
+#else
+#warning "Unknown eRPC allocation policy!"
+#endif
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+#endif // _tfm_erpc_psa_client_api_server_h_
diff --git a/erpc/generated_files/tfm_erpc_psa_connection_api.h b/erpc/generated_files/tfm_erpc_psa_connection_api.h
new file mode 100644
index 0000000..4155916
--- /dev/null
+++ b/erpc/generated_files/tfm_erpc_psa_connection_api.h
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2022, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/*
+ * Generated by erpcgen 1.9.1 on Fri Dec 16 14:51:11 2022.
+ *
+ * AUTOGENERATED - DO NOT EDIT
+ */
+
+
+#if !defined(_tfm_erpc_psa_connection_api_h_)
+#define _tfm_erpc_psa_connection_api_h_
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include "erpc_version.h"
+#include "psa/client.h"
+
+#if 10901 != ERPC_VERSION_NUMBER
+#error "The generated shim code version is different to the rest of eRPC code."
+#endif
+
+#if !defined(ERPC_TYPE_DEFINITIONS)
+#define ERPC_TYPE_DEFINITIONS
+
+// Aliases data types declarations
+typedef struct list_binary_1_t list_binary_1_t;
+typedef struct binary_t binary_t;
+
+// Structures/unions data types declarations
+struct list_binary_1_t
+{
+ binary_t * elements;
+ uint32_t elementsCount;
+};
+
+struct binary_t
+{
+ uint8_t * data;
+ uint32_t dataLength;
+};
+
+
+#endif // ERPC_TYPE_DEFINITIONS
+
+/*! @brief psa_connection_api identifiers */
+enum _psa_connection_api_ids
+{
+ kpsa_connection_api_service_id = 2,
+ kpsa_connection_api_psa_connect_id = 1,
+ kpsa_connection_api_psa_close_id = 2,
+};
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+//! @name psa_connection_api
+//@{
+psa_handle_t psa_connect(uint32_t sid, uint32_t ver);
+
+void psa_close(psa_handle_t handle);
+//@}
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif // _tfm_erpc_psa_connection_api_h_
diff --git a/erpc/generated_files/tfm_erpc_psa_connection_api_client.cpp b/erpc/generated_files/tfm_erpc_psa_connection_api_client.cpp
new file mode 100644
index 0000000..ab24967
--- /dev/null
+++ b/erpc/generated_files/tfm_erpc_psa_connection_api_client.cpp
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2022, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/*
+ * Generated by erpcgen 1.9.1 on Fri Dec 16 14:51:11 2022.
+ *
+ * AUTOGENERATED - DO NOT EDIT
+ */
+
+
+#include "erpc_client_manager.h"
+#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
+#include "erpc_port.h"
+#endif
+#include "erpc_codec.h"
+extern "C"
+{
+#include "tfm_erpc_psa_connection_api.h"
+// import callbacks declaration from other groups
+#include "tfm_erpc_psa_client_api.h"
+}
+
+#if 10901 != ERPC_VERSION_NUMBER
+#error "The generated shim code version is different to the rest of eRPC code."
+#endif
+
+using namespace erpc;
+using namespace std;
+
+extern ClientManager *g_client;
+
+
+// psa_connection_api interface psa_connect function client shim.
+psa_handle_t psa_connect(uint32_t sid, uint32_t ver)
+{
+ erpc_status_t err = kErpcStatus_Success;
+
+ psa_handle_t result;
+
+#if ERPC_PRE_POST_ACTION
+ pre_post_action_cb preCB = g_client->getPreCB();
+ if (preCB)
+ {
+ preCB();
+ }
+#endif
+
+ // Get a new request.
+ RequestContext request = g_client->createRequest(false);
+
+ // Encode the request.
+ Codec * codec = request.getCodec();
+
+ if (codec == NULL)
+ {
+ err = kErpcStatus_MemoryError;
+ }
+ else
+ {
+ codec->startWriteMessage(kInvocationMessage, kpsa_connection_api_service_id, kpsa_connection_api_psa_connect_id, request.getSequence());
+
+ codec->write(sid);
+
+ codec->write(ver);
+
+ // Send message to server
+ // Codec status is checked inside this function.
+ g_client->performRequest(request);
+
+ codec->read(&result);
+
+ err = codec->getStatus();
+ }
+
+ // Dispose of the request.
+ g_client->releaseRequest(request);
+
+ // Invoke error handler callback function
+ g_client->callErrorHandler(err, kpsa_connection_api_psa_connect_id);
+
+#if ERPC_PRE_POST_ACTION
+ pre_post_action_cb postCB = g_client->getPostCB();
+ if (postCB)
+ {
+ postCB();
+ }
+#endif
+
+
+ if (err != kErpcStatus_Success)
+ {
+ result = -1;
+ }
+
+ return result;
+}
+
+// psa_connection_api interface psa_close function client shim.
+void psa_close(psa_handle_t handle)
+{
+ erpc_status_t err = kErpcStatus_Success;
+
+
+#if ERPC_PRE_POST_ACTION
+ pre_post_action_cb preCB = g_client->getPreCB();
+ if (preCB)
+ {
+ preCB();
+ }
+#endif
+
+ // Get a new request.
+ RequestContext request = g_client->createRequest(false);
+
+ // Encode the request.
+ Codec * codec = request.getCodec();
+
+ if (codec == NULL)
+ {
+ err = kErpcStatus_MemoryError;
+ }
+ else
+ {
+ codec->startWriteMessage(kInvocationMessage, kpsa_connection_api_service_id, kpsa_connection_api_psa_close_id, request.getSequence());
+
+ codec->write(handle);
+
+ // Send message to server
+ // Codec status is checked inside this function.
+ g_client->performRequest(request);
+
+ err = codec->getStatus();
+ }
+
+ // Dispose of the request.
+ g_client->releaseRequest(request);
+
+ // Invoke error handler callback function
+ g_client->callErrorHandler(err, kpsa_connection_api_psa_close_id);
+
+#if ERPC_PRE_POST_ACTION
+ pre_post_action_cb postCB = g_client->getPostCB();
+ if (postCB)
+ {
+ postCB();
+ }
+#endif
+
+
+ return;
+}
diff --git a/erpc/generated_files/tfm_erpc_psa_connection_api_server.cpp b/erpc/generated_files/tfm_erpc_psa_connection_api_server.cpp
new file mode 100644
index 0000000..8e51d8d
--- /dev/null
+++ b/erpc/generated_files/tfm_erpc_psa_connection_api_server.cpp
@@ -0,0 +1,179 @@
+/*
+ * Copyright (c) 2022, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/*
+ * Generated by erpcgen 1.9.1 on Fri Dec 16 14:51:11 2022.
+ *
+ * AUTOGENERATED - DO NOT EDIT
+ */
+
+
+#include "tfm_erpc_psa_connection_api_server.h"
+#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
+#include <new>
+#include "erpc_port.h"
+#endif
+#include "erpc_manually_constructed.h"
+
+#if 10901 != ERPC_VERSION_NUMBER
+#error "The generated shim code version is different to the rest of eRPC code."
+#endif
+
+using namespace erpc;
+using namespace std;
+
+#if ERPC_NESTED_CALLS_DETECTION
+extern bool nestingDetection;
+#endif
+
+ERPC_MANUALLY_CONSTRUCTED_STATIC(psa_connection_api_service, s_psa_connection_api_service);
+
+
+
+// Call the correct server shim based on method unique ID.
+erpc_status_t psa_connection_api_service::handleInvocation(uint32_t methodId, uint32_t sequence, Codec * codec, MessageBufferFactory *messageFactory)
+{
+ erpc_status_t erpcStatus;
+ switch (methodId)
+ {
+ case kpsa_connection_api_psa_connect_id:
+ {
+ erpcStatus = psa_connect_shim(codec, messageFactory, sequence);
+ break;
+ }
+
+ case kpsa_connection_api_psa_close_id:
+ {
+ erpcStatus = psa_close_shim(codec, messageFactory, sequence);
+ break;
+ }
+
+ default:
+ {
+ erpcStatus = kErpcStatus_InvalidArgument;
+ break;
+ }
+ }
+
+ return erpcStatus;
+}
+
+// Server shim for psa_connect of psa_connection_api interface.
+erpc_status_t psa_connection_api_service::psa_connect_shim(Codec * codec, MessageBufferFactory *messageFactory, uint32_t sequence)
+{
+ erpc_status_t err = kErpcStatus_Success;
+
+ uint32_t sid;
+ uint32_t ver;
+ psa_handle_t result;
+
+ // startReadMessage() was already called before this shim was invoked.
+
+ codec->read(&sid);
+
+ codec->read(&ver);
+
+ err = codec->getStatus();
+ if (err == kErpcStatus_Success)
+ {
+ // Invoke the actual served function.
+#if ERPC_NESTED_CALLS_DETECTION
+ nestingDetection = true;
+#endif
+ result = psa_connect(sid, ver);
+#if ERPC_NESTED_CALLS_DETECTION
+ nestingDetection = false;
+#endif
+
+ // preparing MessageBuffer for serializing data
+ err = messageFactory->prepareServerBufferForSend(codec->getBuffer());
+ }
+
+ if (err == kErpcStatus_Success)
+ {
+ // preparing codec for serializing data
+ codec->reset();
+
+ // Build response message.
+ codec->startWriteMessage(kReplyMessage, kpsa_connection_api_service_id, kpsa_connection_api_psa_connect_id, sequence);
+
+ codec->write(result);
+
+ err = codec->getStatus();
+ }
+
+ return err;
+}
+
+// Server shim for psa_close of psa_connection_api interface.
+erpc_status_t psa_connection_api_service::psa_close_shim(Codec * codec, MessageBufferFactory *messageFactory, uint32_t sequence)
+{
+ erpc_status_t err = kErpcStatus_Success;
+
+ psa_handle_t handle;
+
+ // startReadMessage() was already called before this shim was invoked.
+
+ codec->read(&handle);
+
+ err = codec->getStatus();
+ if (err == kErpcStatus_Success)
+ {
+ // Invoke the actual served function.
+#if ERPC_NESTED_CALLS_DETECTION
+ nestingDetection = true;
+#endif
+ psa_close(handle);
+#if ERPC_NESTED_CALLS_DETECTION
+ nestingDetection = false;
+#endif
+
+ // preparing MessageBuffer for serializing data
+ err = messageFactory->prepareServerBufferForSend(codec->getBuffer());
+ }
+
+ if (err == kErpcStatus_Success)
+ {
+ // preparing codec for serializing data
+ codec->reset();
+
+ // Build response message.
+ codec->startWriteMessage(kReplyMessage, kpsa_connection_api_service_id, kpsa_connection_api_psa_close_id, sequence);
+
+ err = codec->getStatus();
+ }
+
+ return err;
+}
+
+#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
+erpc_service_t create_psa_connection_api_service()
+{
+ return new (nothrow) psa_connection_api_service();
+}
+
+void destroy_psa_connection_api_service(erpc_service_t service)
+{
+ if (service)
+ {
+ delete (psa_connection_api_service *)service;
+ }
+}
+#elif ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_STATIC
+erpc_service_t create_psa_connection_api_service()
+{
+ s_psa_connection_api_service.construct();
+ return s_psa_connection_api_service.get();
+}
+
+void destroy_psa_connection_api_service()
+{
+ s_psa_connection_api_service.destroy();
+}
+#else
+#warning "Unknown eRPC allocation policy!"
+#endif
diff --git a/erpc/generated_files/tfm_erpc_psa_connection_api_server.h b/erpc/generated_files/tfm_erpc_psa_connection_api_server.h
new file mode 100644
index 0000000..01dbc1f
--- /dev/null
+++ b/erpc/generated_files/tfm_erpc_psa_connection_api_server.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2022, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/*
+ * Generated by erpcgen 1.9.1 on Fri Dec 16 14:51:11 2022.
+ *
+ * AUTOGENERATED - DO NOT EDIT
+ */
+
+
+#if !defined(_tfm_erpc_psa_connection_api_server_h_)
+#define _tfm_erpc_psa_connection_api_server_h_
+
+#ifdef __cplusplus
+#include "erpc_server.h"
+#include "erpc_codec.h"
+extern "C"
+{
+#include "tfm_erpc_psa_connection_api.h"
+#include <stdint.h>
+#include <stdbool.h>
+}
+
+#if 10901 != ERPC_VERSION_NUMBER
+#error "The generated shim code version is different to the rest of eRPC code."
+#endif
+
+
+/*!
+ * @brief Service subclass for psa_connection_api.
+ */
+class psa_connection_api_service : public erpc::Service
+{
+public:
+ psa_connection_api_service() : Service(kpsa_connection_api_service_id) {}
+
+ /*! @brief Call the correct server shim based on method unique ID. */
+ virtual erpc_status_t handleInvocation(uint32_t methodId, uint32_t sequence, erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory);
+
+private:
+ /*! @brief Server shim for psa_connect of psa_connection_api interface. */
+ erpc_status_t psa_connect_shim(erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, uint32_t sequence);
+
+ /*! @brief Server shim for psa_close of psa_connection_api interface. */
+ erpc_status_t psa_close_shim(erpc::Codec * codec, erpc::MessageBufferFactory *messageFactory, uint32_t sequence);
+};
+
+extern "C" {
+#else
+#include "tfm_erpc_psa_connection_api.h"
+#endif // __cplusplus
+
+typedef void * erpc_service_t;
+
+erpc_service_t create_psa_connection_api_service(void);
+
+#if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_DYNAMIC
+void destroy_psa_connection_api_service(erpc_service_t service);
+#elif ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_STATIC
+void destroy_psa_connection_api_service(void);
+#else
+#warning "Unknown eRPC allocation policy!"
+#endif
+
+#ifdef __cplusplus
+}
+#endif // __cplusplus
+
+#endif // _tfm_erpc_psa_connection_api_server_h_
diff --git a/erpc/host_example/CMakeLists.txt b/erpc/host_example/CMakeLists.txt
new file mode 100644
index 0000000..3caf2b2
--- /dev/null
+++ b/erpc/host_example/CMakeLists.txt
@@ -0,0 +1,57 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+cmake_minimum_required(VERSION 3.15)
+
+project("ERPC Host" LANGUAGES CXX C)
+set(CMAKE_CXX_FLAGS "-m32")
+set(CMAKE_C_FLAGS "-m32")
+
+add_executable(erpc_main)
+
+add_subdirectory(../client client)
+
+if (NOT DEFINED ERPC_TRANSPORT)
+ message(FATAL_ERROR "Please select ERPC_TRANSPORT, currently only UART and TCP are supported!")
+endif()
+
+if (ERPC_TRANSPORT STREQUAL "UART")
+ if (NOT DEFINED PORT_NAME)
+ message(FATAL_ERROR "Please provide PORT_NAME!")
+ endif()
+elseif (ERPC_TRANSPORT STREQUAL "TCP")
+ if((NOT DEFINED ERPC_HOST) OR (NOT DEFINED ERPC_PORT))
+ message(FATAL_ERROR "Please provide ERPC_HOST and ERPC_PORT!")
+ endif()
+else()
+ message(FATAL_ERROR "Please provided supported transportation type (UART and TCP)!")
+endif()
+
+target_sources(erpc_main
+ PRIVATE
+ main.c
+ ${ERPC_REPO_PATH}/erpc_c/port/erpc_threading_pthreads.cpp
+ $<$<STREQUAL:${ERPC_TRANSPORT},UART>:${ERPC_REPO_PATH}/erpc_c/setup/erpc_setup_serial.cpp>
+ $<$<STREQUAL:${ERPC_TRANSPORT},UART>:${ERPC_REPO_PATH}/erpc_c/transports/erpc_serial_transport.cpp>
+ $<$<STREQUAL:${ERPC_TRANSPORT},TCP>:${ERPC_REPO_PATH}/erpc_c/setup/erpc_setup_tcp.cpp>
+ $<$<STREQUAL:${ERPC_TRANSPORT},TCP>:${ERPC_REPO_PATH}/erpc_c/transports/erpc_tcp_transport.cpp>
+)
+
+target_link_libraries(erpc_main
+ PRIVATE
+ erpc_client
+ pthread
+)
+
+target_compile_definitions(erpc_main
+ PRIVATE
+ $<$<STREQUAL:${ERPC_TRANSPORT},UART>:ERPC_TRANSPORT_UART>
+ $<$<STREQUAL:${ERPC_TRANSPORT},TCP>:ERPC_TRANSPORT_TCP>
+ $<$<AND:$<STREQUAL:${ERPC_TRANSPORT},UART>,$<BOOL:${PORT_NAME}>>:PORT_NAME="${PORT_NAME}">
+ $<$<AND:$<STREQUAL:${ERPC_TRANSPORT},TCP>,$<BOOL:${ERPC_HOST}>>:ERPC_HOST="${ERPC_HOST}">
+ $<$<AND:$<STREQUAL:${ERPC_TRANSPORT},TCP>,$<BOOL:${ERPC_PORT}>>:ERPC_PORT=${ERPC_PORT}>
+)
diff --git a/erpc/host_example/README.rst b/erpc/host_example/README.rst
new file mode 100644
index 0000000..a00b024
--- /dev/null
+++ b/erpc/host_example/README.rst
@@ -0,0 +1,92 @@
+*********
+eRPC Host
+*********
+
+This host example is only tested for Linux.
+
+Example: UART Transportation on Musca_S1
+========================================
+
+Build instructions on the target
+--------------------------------
+
+.. code-block:: bash
+
+ cd <TF-M base folder>
+ cmake -G"Unix Makefiles" -S . -B cmake_build -DTFM_PLATFORM=musca_s1 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DCMAKE_BUILD_TYPE=Debug -DCONFIG_TFM_ERPC_TEST_FRAMEWORK=ON ../
+ cmake --build cmake_build/ -- install -j32
+
+Build instructions on the host
+------------------------------
+
+.. code-block:: bash
+
+ cd <TF-M tests base folder>/erpc/host_example
+ cmake -S . -B build -G "Unix Makefiles" -DTFM_INSTALL_PATH=<TF-M install folder> -DERPC_REPO_PATH=<eRPC base folder> -DERPC_TRANSPORT=UART -DPORT_NAME="/dev/ttyACM0"
+ cmake --build build/
+
+Run instructions on the host
+----------------------------
+
+.. code-block:: bash
+
+ cd <TF-M tests base folder>/erpc/host_example
+ ./build/erpc_main
+
+Example: TCP Transportation on AN521 FVP
+========================================
+
+Build instructions on the target
+--------------------------------
+
+.. code-block:: bash
+
+ cd <TF-M base folder>
+ cmake -G"Unix Makefiles" -S . -B cmake_build -DTFM_PLATFORM=an521 -DTFM_TOOLCHAIN_FILE=toolchain_GNUARM.cmake -DCMAKE_BUILD_TYPE=Debug -DCONFIG_TFM_ERPC_TEST_FRAMEWORK=ON ../
+ cmake --build cmake_build/ -- install -j32
+
+Build instructions on the host
+------------------------------
+
+.. code-block:: bash
+
+ cd <TF-M tests base folder>/erpc/host_example
+ cmake -S . -B build -G "Unix Makefiles" -DTFM_INSTALL_PATH=<TF-M install folder> -DERPC_REPO_PATH=<eRPC base folder> -DERPC_TRANSPORT=TCP -DERPC_HOST="0.0.0.0" -DERPC_PORT=5001
+ cmake --build build/
+
+Run instructions on the host
+----------------------------
+
+Start the AN521 FVP:
+
+.. code-block:: bash
+
+ <DS_PATH>/sw/models/bin/FVP_MPS2_AEMv8M \
+ --parameter fvp_mps2.platform_type=2 \
+ --parameter cpu0.baseline=0 \
+ --parameter cpu0.INITVTOR_S=0x10000000 \
+ --parameter cpu0.semihosting-enable=0 \
+ --parameter fvp_mps2.DISABLE_GATING=0 \
+ --parameter fvp_mps2.telnetterminal0.start_telnet=1 \
+ --parameter fvp_mps2.telnetterminal1.start_telnet=0 \
+ --parameter fvp_mps2.telnetterminal2.start_telnet=0 \
+ --parameter fvp_mps2.telnetterminal0.quiet=0 \
+ --parameter fvp_mps2.telnetterminal1.quiet=1 \
+ --parameter fvp_mps2.telnetterminal2.quiet=1 \
+ --parameter fvp_mps2.UART0.out_file=/dev/stdout \
+ --parameter fvp_mps2.UART0.unbuffered_output=1 \
+ --parameter fvp_mps2.telnetterminal1.mode=raw \
+ --parameter fvp_mps2.UART1.unbuffered_output=1 \
+ --parameter fvp_mps2.mps2_visualisation.disable-visualisation=1 \
+ --application cpu0=<APPLICATION> \
+ --data cpu0=<DATA>@0x10080000 \
+ -M 1
+
+.. code-block:: bash
+
+ cd <TF-M tests base folder>/erpc/host_example
+ ./build/erpc_main
+
+--------------
+
+*Copyright (c) 2023, Arm Limited. All rights reserved.*
diff --git a/erpc/host_example/main.c b/erpc/host_example/main.c
new file mode 100644
index 0000000..b46ab27
--- /dev/null
+++ b/erpc/host_example/main.c
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2023, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include <stdio.h>
+#include "erpc_port.h"
+#include "erpc_client_start.h"
+#include "tfm_erpc_psa_client_api.h"
+
+int main(int argc, char *argv[])
+{
+ erpc_transport_t transport;
+
+#ifdef ERPC_TRANSPORT_UART
+ transport = erpc_transport_serial_init(PORT_NAME, 115200);
+#elif defined(ERPC_TRANSPORT_TCP)
+ transport = erpc_transport_tcp_init(ERPC_HOST, ERPC_PORT, false);
+#else
+#error "No valid transportation layer selected."
+#endif
+
+ if (!transport) {
+ printf("eRPC transport init failed!\r\n");
+ return 1;
+ }
+
+ erpc_client_start(transport);
+
+ printf("psa_framework_version: %d\r\n", psa_framework_version());
+
+ return 0;
+}
diff --git a/erpc/server/CMakeLists.txt b/erpc/server/CMakeLists.txt
new file mode 100644
index 0000000..fe61fb7
--- /dev/null
+++ b/erpc/server/CMakeLists.txt
@@ -0,0 +1,64 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+cmake_minimum_required(VERSION 3.15)
+cmake_policy(SET CMP0097 NEW)
+
+# Set eRPC config file. Need to provide config file with an absolute path.
+if (ERPC_CONFIG_FILE)
+ if (NOT EXISTS ${ERPC_CONFIG_FILE})
+ message(FATAL_ERROR "ERPC_CONFIG_FILE does not exist. Please provide it with an absolute path.")
+ endif()
+ # Get the path of the customized eRPC config file
+ get_filename_component(ERPC_CONFIG_FILE_PATH ${ERPC_CONFIG_FILE} DIRECTORY)
+else()
+ # Use default one
+ set(ERPC_CONFIG_FILE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/config")
+endif()
+
+add_library(erpc_server STATIC)
+
+target_sources(erpc_server
+ PRIVATE
+ erpc_server_start.c
+ erpc_server_wrapper.c
+ # eRPC files
+ ${ERPC_REPO_PATH}/erpc_c/infra/erpc_basic_codec.cpp
+ ${ERPC_REPO_PATH}/erpc_c/infra/erpc_crc16.cpp
+ ${ERPC_REPO_PATH}/erpc_c/infra/erpc_framed_transport.cpp
+ ${ERPC_REPO_PATH}/erpc_c/infra/erpc_message_buffer.cpp
+ ${ERPC_REPO_PATH}/erpc_c/infra/erpc_server.cpp
+ ${ERPC_REPO_PATH}/erpc_c/infra/erpc_simple_server.cpp
+ ${ERPC_REPO_PATH}/erpc_c/port/erpc_port_stdlib.cpp
+ ${ERPC_REPO_PATH}/erpc_c/setup/erpc_setup_mbf_dynamic.cpp
+ ${ERPC_REPO_PATH}/erpc_c/setup/erpc_server_setup.cpp
+ # Generated files
+ ${CMAKE_CURRENT_SOURCE_DIR}/../generated_files/tfm_erpc_psa_client_api_server.cpp
+ $<$<BOOL:${CONFIG_TFM_CONNECTION_BASED_SERVICE_API}>:${CMAKE_CURRENT_SOURCE_DIR}/../generated_files/tfm_erpc_psa_connection_api_server.cpp>
+)
+
+target_include_directories(erpc_server
+ PUBLIC
+ ${ERPC_REPO_PATH}/erpc_c/port
+ ${ERPC_REPO_PATH}/erpc_c/infra
+ ${ERPC_REPO_PATH}/erpc_c/transports
+ ${ERPC_REPO_PATH}/erpc_c/setup
+ ${CMAKE_CURRENT_SOURCE_DIR}/
+ ${CMAKE_CURRENT_SOURCE_DIR}/../generated_files
+ ${ERPC_CONFIG_FILE_PATH}/
+)
+
+target_link_libraries(erpc_server
+ PUBLIC
+ tfm_api_ns
+ platform_ns # UART driver header and target config
+)
+
+target_compile_definitions(erpc_server
+ PUBLIC
+ $<$<BOOL:${CONFIG_TFM_CONNECTION_BASED_SERVICE_API}>:CONFIG_TFM_CONNECTION_BASED_SERVICE_API=1>
+)
diff --git a/erpc/server/config/erpc_config.h b/erpc/server/config/erpc_config.h
new file mode 100644
index 0000000..9ef5f66
--- /dev/null
+++ b/erpc/server/config/erpc_config.h
@@ -0,0 +1,212 @@
+/*
+ * Copyright (c) 2016, Freescale Semiconductor, Inc.
+ * Copyright 2016-2020 NXP
+ * Copyright 2020-2021 ACRIOS Systems s.r.o.
+ * Copyright (c) 2023, Arm Limited. All rights reserved.
+ * All rights reserved.
+ *
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef _ERPC_CONFIG_H_
+#define _ERPC_CONFIG_H_
+
+/*!
+ * @addtogroup config
+ * @{
+ * @file
+ */
+
+////////////////////////////////////////////////////////////////////////////////
+// Declarations
+////////////////////////////////////////////////////////////////////////////////
+
+//! @name Threading model options
+//@{
+#define ERPC_ALLOCATION_POLICY_DYNAMIC (0U) //!< Dynamic allocation policy
+#define ERPC_ALLOCATION_POLICY_STATIC (1U) //!< Static allocation policy
+
+#define ERPC_THREADS_NONE (0U) //!< No threads.
+#define ERPC_THREADS_PTHREADS (1U) //!< POSIX pthreads.
+#define ERPC_THREADS_FREERTOS (2U) //!< FreeRTOS.
+#define ERPC_THREADS_ZEPHYR (3U) //!< ZEPHYR.
+#define ERPC_THREADS_MBED (4U) //!< Mbed OS
+#define ERPC_THREADS_WIN32 (5U) //!< WIN32
+#define ERPC_THREADS_THREADX (6U) //!< THREADX
+
+#define ERPC_NOEXCEPT_DISABLED (0U) //!< Disabling noexcept feature.
+#define ERPC_NOEXCEPT_ENABLED (1U) //!< Enabling noexcept feature.
+
+#define ERPC_NESTED_CALLS_DISABLED (0U) //!< No nested calls support.
+#define ERPC_NESTED_CALLS_ENABLED (1U) //!< Nested calls support.
+
+#define ERPC_NESTED_CALLS_DETECTION_DISABLED (0U) //!< Nested calls detection disabled.
+#define ERPC_NESTED_CALLS_DETECTION_ENABLED (1U) //!< Nested calls detection enabled.
+
+#define ERPC_MESSAGE_LOGGING_DISABLED (0U) //!< Trace functions disabled.
+#define ERPC_MESSAGE_LOGGING_ENABLED (1U) //!< Trace functions enabled.
+
+#define ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED (0U) //!< Do not use MCMGR for MU ISR management.
+#define ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED (1U) //!< Use MCMGR for MU ISR management.
+
+#define ERPC_PRE_POST_ACTION_DISABLED (0U) //!< Pre post shim callbacks functions disabled.
+#define ERPC_PRE_POST_ACTION_ENABLED (1U) //!< Pre post shim callback functions enabled.
+
+#define ERPC_PRE_POST_ACTION_DEFAULT_DISABLED (0U) //!< Pre post shim default callbacks functions disabled.
+#define ERPC_PRE_POST_ACTION_DEFAULT_ENABLED (1U) //!< Pre post shim default callback functions enabled.
+//@}
+
+//! @name Configuration options
+//@{
+
+//! @def ERPC_ALLOCATION_POLICY
+//!
+//! @brief Choose which allocation policy should be used.
+//!
+//! Set ERPC_ALLOCATION_POLICY_DYNAMIC if dynamic allocations should be used.
+//! Set ERPC_ALLOCATION_POLICY_STATIC if static allocations should be used.
+//!
+//! Default value is ERPC_ALLOCATION_POLICY_DYNAMIC or in case of FreeRTOS it can be auto-detected if __has_include() is
+//! supported by compiler. Uncomment comment bellow to use static allocation policy. In case of static implementation
+//! user need consider another values to set (ERPC_CODEC_COUNT, ERPC_MESSAGE_LOGGERS_COUNT,
+//! ERPC_CLIENTS_THREADS_AMOUNT).
+// #define ERPC_ALLOCATION_POLICY (ERPC_ALLOCATION_POLICY_STATIC)
+
+//! @def ERPC_CODEC_COUNT
+//!
+//! @brief Set amount of codecs objects used simultaneously in case of ERPC_ALLOCATION_POLICY is set to
+//! ERPC_ALLOCATION_POLICY_STATIC. For example if client or server is used in one thread then 1. If both are used in one
+//! thread per each then 2, ... Default value 2.
+// #define ERPC_CODEC_COUNT (2U)
+
+//! @def ERPC_MESSAGE_LOGGERS_COUNT
+//!
+//! @brief Set amount of message loggers objects used simultaneously in case of ERPC_ALLOCATION_POLICY is set to
+//! ERPC_ALLOCATION_POLICY_STATIC.
+//! For example if client or server is used in one thread then 1. If both are used in one thread per each then 2, ...
+//! For arbitrated client 1 is enough.
+//! Default value 0 (May not be used).
+// #define ERPC_MESSAGE_LOGGERS_COUNT (0U)
+
+//! @def ERPC_CLIENTS_THREADS_AMOUNT
+//!
+//! @brief Set amount of client threads objects used in case of ERPC_ALLOCATION_POLICY is set to
+//! ERPC_ALLOCATION_POLICY_STATIC. Default value 1 (Most of current cases).
+// #define ERPC_CLIENTS_THREADS_AMOUNT (1U)
+
+//! @def ERPC_THREADS
+//!
+//! @brief Select threading model.
+//!
+//! Set to one of the @c ERPC_THREADS_x macros to specify the threading model used by eRPC.
+//!
+//! Leave commented out to attempt to auto-detect. Auto-detection works well for pthreads.
+//! FreeRTOS can be detected when building with compilers that support __has_include().
+//! Otherwise, the default is no threading.
+#define ERPC_THREADS (ERPC_THREADS_NONE)
+
+//! @def ERPC_DEFAULT_BUFFER_SIZE
+//!
+//! Uncomment to change the size of buffers allocated by one of MessageBufferFactory.
+//! (@ref client_setup and @ref server_setup). The default size is set to 256.
+//! For RPMsg transport layer, ERPC_DEFAULT_BUFFER_SIZE must be 2^n - 16.
+//#define ERPC_DEFAULT_BUFFER_SIZE (256U)
+
+//! @def ERPC_DEFAULT_BUFFERS_COUNT
+//!
+//! Uncomment to change the count of buffers allocated by one of statically allocated messages.
+//! Default value is set to 2.
+//#define ERPC_DEFAULT_BUFFERS_COUNT (2U)
+
+//! @def ERPC_NOEXCEPT
+//!
+//! @brief Disable/enable noexcept support.
+//!
+//! Uncomment for using noexcept feature.
+//#define ERPC_NOEXCEPT (ERPC_NOEXCEPT_ENABLED)
+
+//! @def ERPC_NESTED_CALLS
+//!
+//! Default set to ERPC_NESTED_CALLS_DISABLED. Uncomment when callbacks, or other eRPC
+//! functions are called from server implementation of another eRPC call. Nested functions
+//! need to be marked as @nested in IDL.
+//#define ERPC_NESTED_CALLS (ERPC_NESTED_CALLS_ENABLED)
+
+//! @def ERPC_NESTED_CALLS_DETECTION
+//!
+//! Default set to ERPC_NESTED_CALLS_DETECTION_ENABLED when NDEBUG macro is presented.
+//! This serve for locating nested calls in code. Nested calls are calls where inside eRPC function
+//! on server side is called another eRPC function (like callbacks). Code need be a bit changed
+//! to support nested calls. See ERPC_NESTED_CALLS macro.
+//#define ERPC_NESTED_CALLS_DETECTION (ERPC_NESTED_CALLS_DETECTION_DISABLED)
+
+//! @def ERPC_MESSAGE_LOGGING
+//!
+//! Enable eRPC message logging code through the eRPC. Take look into "erpc_message_loggers.h". Can be used for base
+//! printing messages, or sending data to another system for data analysis. Default set to
+//! ERPC_MESSAGE_LOGGING_DISABLED.
+//!
+//! Uncomment for using logging feature.
+//#define ERPC_MESSAGE_LOGGING (ERPC_MESSAGE_LOGGING_ENABLED)
+
+//! @def ERPC_TRANSPORT_MU_USE_MCMGR
+//!
+//! @brief MU transport layer configuration.
+//!
+//! Set to one of the @c ERPC_TRANSPORT_MU_USE_MCMGR_x macros to configure the MCMGR usage in MU transport layer.
+//!
+//! MU transport layer could leverage the Multicore Manager (MCMGR) component for Inter-Core
+//! interrupts / MU interrupts management or the Inter-Core interrupts can be managed by itself (MUX_IRQHandler
+//! overloading). By default, ERPC_TRANSPORT_MU_USE_MCMGR is set to ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED when mcmgr.h
+//! is part of the project, otherwise the ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED option is used. This settings can be
+//! overwritten from the erpc_config.h by uncommenting the ERPC_TRANSPORT_MU_USE_MCMGR macro definition. Do not forget
+//! to add the MCMGR library into your project when ERPC_TRANSPORT_MU_USE_MCMGR_ENABLED option is used! See the
+//! erpc_mu_transport.h for additional MU settings.
+//#define ERPC_TRANSPORT_MU_USE_MCMGR ERPC_TRANSPORT_MU_USE_MCMGR_DISABLED
+//@}
+
+//! @def ERPC_PRE_POST_ACTION
+//!
+//! Enable eRPC pre and post callback functions shim code. Take look into "erpc_pre_post_action.h". Can be used for
+//! detection of eRPC call freeze, ... Default set to ERPC_PRE_POST_ACTION_DISABLED.
+//!
+//! Uncomment for using pre post callback feature.
+//#define ERPC_PRE_POST_ACTION (ERPC_PRE_POST_ACTION_ENABLED)
+
+//! @def ERPC_PRE_POST_ACTION_DEFAULT
+//!
+//! Enable eRPC pre and post default callback functions. Take look into "erpc_setup_extensions.h". Can be used for
+//! detection of eRPC call freeze, ... Default set to ERPC_PRE_POST_ACTION_DEFAULT_DISABLED.
+//!
+//! Uncomment for using pre post default callback feature.
+//#define ERPC_PRE_POST_ACTION_DEFAULT (ERPC_PRE_POST_ACTION_DEFAULT_ENABLED)
+
+//! @name Assert function definition
+//@{
+//! User custom asser defition. Include header file if needed before bellow line. If assert is not enabled, default will
+//! be used.
+// #define erpc_assert(condition)
+//@}
+
+//! @def ENDIANES_HEADER
+//!
+//! Include header file that controls the communication endianness
+//!
+//! Uncomment for example behaviour for endianness agnostic with:
+//! 1. communication in little endian.
+//! 2. current processor is big endian.
+//! 3. pointer size is 32 bit.
+//! 4. float+double scheme not defined, so throws assert if passes.
+//! #define ERPC_PROCESSOR_ENDIANNESS_LITTLE 0
+//! #define ERPC_COMMUNICATION_LITTLE 1
+//! #define ERPC_POINTER_SIZE_16 0
+//! #define ERPC_POINTER_SIZE_32 1
+//! #define ERPC_POINTER_SIZE_64 0
+//! #define ENDIANNESS_HEADER "erpc_endianness_agnostic_example.h"
+
+/*! @} */
+#endif // _ERPC_CONFIG_H_
+////////////////////////////////////////////////////////////////////////////////
+// EOF
+////////////////////////////////////////////////////////////////////////////////
diff --git a/erpc/server/erpc_server_start.c b/erpc/server/erpc_server_start.c
new file mode 100644
index 0000000..71fc26d
--- /dev/null
+++ b/erpc/server/erpc_server_start.c
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2023, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include "erpc_server_start.h"
+
+#include "erpc_mbf_setup.h"
+#include "erpc_server_setup.h"
+#include "tfm_erpc_psa_client_api_server.h"
+#if CONFIG_TFM_CONNECTION_BASED_SERVICE_API == 1
+#include "tfm_erpc_psa_connection_api_server.h"
+#endif
+
+void erpc_server_start(erpc_transport_t transport)
+{
+ erpc_server_init(transport, erpc_mbf_dynamic_init());
+ erpc_add_service_to_server(create_psa_client_api_service());
+#if CONFIG_TFM_CONNECTION_BASED_SERVICE_API == 1
+ erpc_add_service_to_server(create_psa_connection_api_service());
+#endif
+
+ erpc_server_run();
+
+ return;
+}
diff --git a/erpc/server/erpc_server_start.h b/erpc/server/erpc_server_start.h
new file mode 100644
index 0000000..3ab870e
--- /dev/null
+++ b/erpc/server/erpc_server_start.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2023, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __ERPC_SERVER_START_H__
+#define __ERPC_SERVER_START_H__
+
+#include "erpc_transport_setup.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief eRPC Server initialization.
+ *
+ * \param[in] transport Transport to use.
+ */
+void erpc_server_start(erpc_transport_t transport);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __ERPC_SERVER_START_H__ */
diff --git a/erpc/server/erpc_server_wrapper.c b/erpc/server/erpc_server_wrapper.c
new file mode 100644
index 0000000..8215c9a
--- /dev/null
+++ b/erpc/server/erpc_server_wrapper.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2023, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include <stddef.h>
+#include "psa/client.h"
+#include "tfm_erpc_psa_client_api.h"
+
+psa_status_t erpc_psa_call(psa_handle_t handle, int32_t t,
+ const list_binary_1_t *erpc_in_vec,
+ list_binary_1_t *erpc_out_vec)
+{
+ psa_status_t status;
+ psa_invec in_vec[PSA_MAX_IOVEC];
+ psa_outvec out_vec[PSA_MAX_IOVEC];
+ size_t i;
+ size_t in_len = erpc_in_vec->elementsCount;
+ size_t out_len = erpc_out_vec->elementsCount;
+
+ /* Copy RPC iovecs into PSA iovecs */
+ for (i = 0; i < in_len; ++i) {
+ in_vec[i] = (psa_invec){erpc_in_vec->elements[i].data,
+ erpc_in_vec->elements[i].dataLength};
+ }
+
+ for (i = 0; i < out_len; ++i) {
+ out_vec[i] = (psa_outvec){erpc_out_vec->elements[i].data,
+ erpc_out_vec->elements[i].dataLength};
+ }
+
+ status = psa_call(handle, t, in_vec, in_len, out_vec, out_len);
+
+ /* Copy updated PSA outvec lens into RPC outvecs */
+ for (i = 0; i < out_len; ++i) {
+ erpc_out_vec->elements[i].dataLength = out_vec[i].len;
+ }
+
+ return status;
+}
diff --git a/erpc/tfm.erpc b/erpc/tfm.erpc
new file mode 100644
index 0000000..20a7d1e
--- /dev/null
+++ b/erpc/tfm.erpc
@@ -0,0 +1,24 @@
+/*!
+ * Copyright (c) 2023, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+@c:include("psa/client.h")
+
+program tfm_erpc
+
+@external type psa_handle_t = int32
+@external type psa_status_t = int32
+
+@group(psa_client_api) interface psa_client_api {
+ psa_framework_version() -> uint32
+ psa_version(uint32 sid) -> uint32
+ erpc_psa_call(psa_handle_t handle, int32 t, list<binary> erpc_in_vec, inout list<binary> erpc_out_vec) -> psa_status_t
+}
+
+@group(psa_connection_api) interface psa_connection_api {
+ psa_connect(uint32 sid, uint32 ver) -> psa_handle_t
+ psa_close(psa_handle_t handle) -> void
+}