1 /*
2  * Copyright (c) 2019-2024, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef __TFM_MULTI_CORE_H__
9 #define __TFM_MULTI_CORE_H__
10 
11 #include <stdint.h>
12 #include "load/interrupt_defs.h"
13 
14 #define CLIENT_ID_OWNER_MAGIC           (void *)0xFFFFFFFF
15 
16 /**
17  * \brief Initialization of the multi core communication.
18  *
19  * \retval 0                    Operation succeeded.
20  * \retval Other return code    Operation failed with an error code.
21  */
22 int32_t tfm_inter_core_comm_init(void);
23 
24 /**
25  * \brief Register a non-secure client ID range.
26  *
27  * \details This function looks for a pre-defined client ID range in
28  *          ns_mailbox_client_id_info[] according to \p irq_source value.
29  *          If matched, it links this non-secure client ID range to the
30  *          \p owner.
31  *
32  * \note    Each client ID range shall be registered only once.
33  *
34  * \param[in] owner           Identifier of the non-secure client.
35  * \param[in] irq_source      The mailbox interrupt source of the target
36  *                            non-secure client ID range
37  *
38  * \return SPM_SUCCESS if the registration is successful.
39  *         SPM_ERROR_BAD_PARAMETERS if owner is null.
40  *         SPM_ERROR_GENERIC otherwise.
41  */
42 int32_t tfm_multi_core_register_client_id_range(void *owner,
43                                                 uint32_t irq_source);
44 
45 /**
46  * \brief Translate a non-secure client ID range.
47  *
48  * \param[in]  owner         Identifier of the non-secure client.
49  * \param[in]  client_id_in  The input client ID.
50  * \param[out] client_id_out The translated client ID. Undefined if
51  *                           SPM_ERROR_GENERIC is returned by the function
52  *
53  * \return SPM_SUCCESS if the translation is successful.
54  *         SPM_ERROR_BAD_PARAMETERS if a parameter is invalid.
55  *         SPM_ERROR_GENERIC otherwise.
56  */
57 int32_t tfm_multi_core_hal_client_id_translate(void *owner,
58                                                int32_t client_id_in,
59                                                int32_t *client_id_out);
60 
61 /**
62  * \brief Record a mailbox interrupt that will be completed later on.
63  *
64  * \param[in] p_ildi       The irq_load_info_t struct of the interrupt to record
65  */
66 void tfm_multi_core_set_mbox_irq(const struct irq_load_info_t *p_ildi);
67 
68 /**
69  * \brief Clear all the mailbox interrupts that are to be processed.
70  *
71  */
72 void tfm_multi_core_clear_mbox_irq(void);
73 
74 #endif /* __TFM_MULTI_CORE_H__ */
75