1/*
2 * Copyright 2017, Data61
3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4 * ABN 41 687 119 230.
5 *
6 * This software may be distributed and modified according to the terms of
7 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
8 * See "LICENSE_BSD2.txt" for details.
9 *
10 * @TAG(DATA61_BSD)
11 */
12
13/*- if configuration[me.instance.name].get('environment', 'c').lower() == 'c' -*/
14
15/*- from 'rpc-connector.c' import establish_recv_rpc, recv_first_rpc, complete_recv, begin_recv, begin_reply, complete_reply, reply_recv with context -*/
16
17#include <camkes/dataport.h>
18
19/*? macros.show_includes(me.instance.type.includes) ?*/
20/*? macros.show_includes(me.interface.type.includes) ?*/
21
22/*- set connector = namespace() -*/
23
24/*- set buffer = configuration[me.parent.name].get('buffer') -*/
25/*- if buffer is none -*/
26  /*? establish_recv_rpc(connector, me.interface.name) ?*/
27/*- else -*/
28  /*- if not isinstance(buffer, six.string_types) -*/
29    /*? raise(TemplateError('invalid non-string setting for userspace buffer to back RPC connection', me.parent)) ?*/
30  /*- endif -*/
31  /*- if len(me.parent.from_ends) != 1 or len(me.parent.to_ends) != 1 -*/
32    /*? raise(TemplateError('invalid use of userspace buffer to back RPC connection that is not 1-to-1', me.parent)) ?*/
33  /*- endif -*/
34  /*- set c = list(filter(lambda('x: x.name == \'%s\'' % buffer), composition.connections)) -*/
35  /*- if len(c) == 0 -*/
36    /*? raise(TemplateError('invalid setting to non-existent connection for userspace buffer to back RPC connection', me.parent)) ?*/
37  /*- endif -*/
38  /*- if len(c[0].from_ends) != 1 or len(c[0].to_ends) != 1 -*/
39    /*? raise(TemplateError('invalid use of userspace buffer that is not 1-to-1 to back RPC connection', me.parent)) ?*/
40  /*- endif -*/
41  /*- if not isinstance(c[0].to_end.interface, camkes.ast.Dataport) -*/
42    /*? raise(TemplateError('invalid use of non-dataport to back RPC connection', me.parent)) ?*/
43  /*- endif -*/
44  extern /*? macros.dataport_type(c[0].to_end.interface.type) ?*/ * /*? c[0].to_end.interface.name ?*/;
45  /*? establish_recv_rpc(connector, me.interface.name, buffer=('((void*)%s)' % c[0].to_end.interface.name, macros.dataport_size(c[0].to_end.interface.type))) ?*/
46/*- endif -*/
47
48/*- include 'rpc-connector-common-to.c' -*/
49
50/*- endif -*/
51