blob: 46d7b0fb7354e90cb0af97048912a1b9d322c943 [file] [log] [blame]
Julian Halla6b3e1c2021-06-25 10:15:01 +01001/*
2 * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef RPC_DEMUX_H
8#define RPC_DEMUX_H
9
10#include <rpc/common/endpoint/rpc_interface.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16/*
17 * The default maximum number of output interfaces. May be
18 * overridden to meet needs of deployment if necessary.
19 */
20#ifndef RPC_DEMUX_MAX_OUTPUTS
21#define RPC_DEMUX_MAX_OUTPUTS (8)
22#endif
23
24/** \brief RPC demux
25 *
26 * An rpc_demux is an rpc_interface that demultiplexes incoming call requests
27 * to 1..* output interfaces. Use an rpc_demux when multiple service
28 * providers are co-located and associated with a single RPC endpoint.
29 */
30struct rpc_demux
31{
32 struct rpc_interface input;
33 struct rpc_interface *outputs[RPC_DEMUX_MAX_OUTPUTS];
34};
35
36/**
37 * \brief Initialize an rpc_demux
38 *
39 * After initialization, the required number of output interfaces need
40 * to be attached,
41 *
42 * \param[in] context The instance to initialize
43 *
44 * \return The input rpc_interface
45 */
46struct rpc_interface *rpc_demux_init(struct rpc_demux *context);
47
48/**
49 * \brief Cleans up when the instance is no longer needed
50 *
51 * \param[in] context The instance to de-initialize
52 */
53void rpc_demux_deinit(struct rpc_demux *context);
54
55/**
56 * \brief Attach an output interface
57 *
58 * \param[in] context The rpc_demux instance
59 * \param[in] iface_id The interface id (small integer)
60 * \param[in] output The interface to attach
61 */
62void rpc_demux_attach(struct rpc_demux *context,
63 unsigned int iface_id, struct rpc_interface *output);
64
65/**
66 * \brief Dettach an output interface
67 *
68 * \param[in] context The rpc_demux instance
69 * \param[in] iface_id The interface id (small integer)
70 */
71void rpc_demux_dettach(struct rpc_demux *context,
72 unsigned int iface_id);
73
74#ifdef __cplusplus
75}
76#endif
77
78#endif /* RPC_DEMUX_H */