1/*
2 * SPDX-License-Identifier: BSD-3-Clause
3 * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
4 */
5/***********{{utilities.donotedit_warning}}***********/
6
7#ifndef __NS_AGENT_MAILBOX_RPC_H__
8#define __NS_AGENT_MAILBOX_RPC_H__
9
10#include <stdint.h>
11#include "psa_manifest/ns_agent_mailbox.h"
12#include "psa/service.h"
13#include "tfm_peripherals_def.h"
14
15/*
16 * It is unlikely that a mailbox IRQ number is assigned to 0 in a system.
17 * Return 0 if it fails to map a signal to a mailbox IRQ source.
18 */
19#define INVALID_MAILBOX_IRQ        0
20
21/******************************************************************/
22/* Map mailbox signals into mailbox sources                       */
23/******************************************************************/
24{% for partition in partitions %}
25    {% if partition.manifest.ns_agent %}
26        {% if partition.manifest.irqs %}
27/******** {{partition.manifest.name}} ********/
28            {% set irq_counter = partition.manifest.irqs|count %}
29            {% if irq_counter > 1 %}
30
31static inline uint32_t rpc_map_signal_to_irq(psa_signal_t signal) {
32    switch (signal) {
33                {% for irq in partition.manifest.irqs %}
34                    {% if partition.manifest.psa_framework_version == 1.0 %}
35    case {{irq.signal}}:
36                    {% else %}
37    case {{irq.name + "_SIGNAL"}}:
38                    {% endif %}
39        return {{irq.source}};
40                {% endfor %}
41    default:
42        return INVALID_MAILBOX_IRQ;
43    }
44}
45            {% else %}
46                {% for irq in partition.manifest.irqs %}
47#define rpc_map_signal_to_irq(x)    (uint32_t){{irq.source}}
48                {% endfor %}
49            {% endif %}
50        {% endif %}
51    {% endif %}
52{% endfor %}
53
54#endif /* __NS_AGENT_MAILBOX_RPC_H__ */
55