1 /*
2  * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 #ifndef __PSA_API_BROKER_H__
8 #define __PSA_API_BROKER_H__
9 
10 #include <stdbool.h>
11 #include <stddef.h>
12 #include <stdint.h>
13 
14 #include "client.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #if defined(TFM_HYBRID_PLATFORM_API_BROKER)
21 
22 enum tfm_hybrid_plat_api_broker_pe_exec_t {
23     TFM_HYBRID_PLATFORM_API_BROKER_LOCAL_NSPE = 0,
24     TFM_HYBRID_PLATFORM_API_BROKER_REMOTE_NSPE = 1,
25     TFM_HYBRID_PLATFORM_API_BROKER_TYPE_COUNT,
26 
27     _TFM_HYBRID_PLATFORM_API_BROKER_TYPE_MAX = UINT8_MAX,
28 };
29 
30 /**
31  * \brief Set the running Processing Element execution target
32  *
33  * \return Returns 0 when successful, -1 otherwise
34  */
35 int32_t tfm_hybrid_plat_api_broker_set_exec_target(
36     enum tfm_hybrid_plat_api_broker_pe_exec_t exec_target);
37 #endif /* TFM_HYBRID_PLATFORM_API_BROKER */
38 
39 
40 /*
41  **** API functions for Multi Core and TrusZone Interfaces ***
42  *
43  * This client API is renamed to either:
44  * - appending 'multicore/tz' when the API broker is chosen, to allow redirection
45  * or
46  * - standard name when no API broker is required
47  *
48  * The client always calls the APIs with the standard names.
49  */
50 
51 #if defined(TFM_HYBRID_PLATFORM_API_BROKER)
52 #define PSA_CLOSE_TZ                        psa_close_tz
53 #define PSA_CONNECT_TZ                      psa_connect_tz
54 #define PSA_CALL_TZ                         psa_call_tz
55 #define PSA_FRAMEWORK_VERSION_TZ            psa_framework_version_tz
56 #define PSA_VERSION_TZ                      psa_version_tz
57 
58 #define PSA_CLOSE_MULTICORE                 psa_close_multicore
59 #define PSA_CONNECT_MULTICORE               psa_connect_multicore
60 #define PSA_CALL_MULTICORE                  psa_call_multicore
61 #define PSA_FRAMEWORK_VERSION_MULTICORE     psa_framework_version_multicore
62 #define PSA_VERSION_MULTICORE               psa_version_multicore
63 
64 #else
65 #define PSA_CLOSE_TZ                        psa_close
66 #define PSA_CONNECT_TZ                      psa_connect
67 #define PSA_CALL_TZ                         psa_call
68 #define PSA_FRAMEWORK_VERSION_TZ            psa_framework_version
69 #define PSA_VERSION_TZ                      psa_version
70 
71 #define PSA_CLOSE_MULTICORE                 psa_close
72 #define PSA_CONNECT_MULTICORE               psa_connect
73 #define PSA_CALL_MULTICORE                  psa_call
74 #define PSA_FRAMEWORK_VERSION_MULTICORE     psa_framework_version
75 #define PSA_VERSION_MULTICORE               psa_version
76 #endif
77 
78 #ifdef __cplusplus
79 }
80 #endif
81 
82 #endif /* __PSA_API_BROKER_H__ */
83