ri.tmplt 3.83 KB
Newer Older
1
2
@@-- The following tags are available in this template:
@@--
3
4
5
6
@@-- @_Name_@                   : The name of the interface
@@-- @_Direction_@              : "PI" or "RI"
@@-- @_Kind_@                   : The RCM Kind
@@-- @_Parent_Function_@        : The name of the function
7
@@-- @_Partition_Name_@         : Partition name for parent function
8
9
10
11
12
@@-- @_Param_Names_@            : List of parameter names
@@-- @_Param_Types_@            :   |_ Corresponding parameter types
@@-- @_Param_Directions_@       :   |_ Corresponding direction
@@-- @_Remote_Function_Names_@  : List of callees
@@-- @_Remote_Interface_Names_@ :   |_ callee's interface name
13
@@-- @_Calling_Threads_@        : Calling threads of the containing block
14
// Required interface @_Name_@ in function @_Parent_Function_@
15
16
17
@@IF@@ @_Param_Names'Length_@ = 0
void vm_@_LOWER:Parent_Function_@_@_LOWER:Name_@(void)
@@ELSE@@
18
19
20
21
22
23
24
25
26
27
void vm_@_LOWER:Parent_Function_@_@_LOWER:Name_@
@@INLINE(        \()(,\n         )(\)\n)@@
   @@TABLE@@
      @@IF@@ @_Param_Directions_@ = "PARAM_IN"
         void *IN_buf_@_LOWER:Param_Names_@, size_t size_IN_buf_@_LOWER:Param_Names_@
      @@ELSE@@
         void *OUT_buf_@_LOWER:Param_Names_@, size_t *size_OUT_buf_@_LOWER:Param_Names_@
      @@END_IF@@
   @@END_TABLE@@
@@END_INLINE@@
28
@@END_IF@@
29
30
{
@@IF@@ @_Kind_@ = SPORADIC_OPERATION
31
32
33
34
   __po_hi_task_id current_task = __po_hi_get_task_id();
@@TABLE@@
   // @_Calling_Threads_@ calling thread
   if (@_LOWER:Partition_Name_@_@_LOWER:Calling_Threads_@_k == current_task) {
35
      // puts("[TASTE] Sporadic call of @_Name_@ from thread @_LOWER:Partition_Name_@_@_LOWER:Calling_Threads_@");
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
@@IF@@ @_Param_Names'Length_@ > 0
@@INLINE(      )( \n      )(\n)@@
   __po_hi_request_t request;
   __po_hi_copy_array(&(request.vars.@_LOWER:Calling_Threads_@_global_outport_@_LOWER:Name_@.@_LOWER:Calling_Threads_@_global_outport_@_LOWER:Name_@.buffer),
@@TABLE@@
 IN_buf_@_LOWER:Param_Names_@, size_IN_buf_@_LOWER:Param_Names_@);
@@END_TABLE@@
   request.vars.@_LOWER:Calling_Threads_@_global_outport_@_LOWER:Name_@.@_LOWER:Calling_Threads_@_global_outport_@_LOWER:Name_@.length = 
@@TABLE@@
size_IN_buf_@_LOWER:Param_Names_@;
@@END_TABLE@@
   request.port = @_LOWER:Calling_Threads_@_global_outport_@_LOWER:Name_@;
   __po_hi_gqueue_store_out(@_LOWER:Partition_Name_@_@_LOWER:Calling_Threads_@_k, @_LOWER:Calling_Threads_@_local_outport_@_LOWER:Name_@, &request);
   __po_hi_send_output(@_LOWER:Partition_Name_@_@_LOWER:Calling_Threads_@_k, @_LOWER:Calling_Threads_@_global_outport_@_LOWER:Name_@);
@@END_INLINE@@
51
52
@@ELSE@@ @@-- No params
   __po_hi_send_output(@_LOWER:Partition_Name_@_@_LOWER:Calling_Threads_@_k, @_LOWER:Calling_Threads_@_global_outport_@_LOWER:Name_@);
53
54
55
56
57
@@END_IF@@
      return;
   }
@@END_TABLE@@
   // calling threads: @_Calling_Threads_@ partition: @_Partition_Name_@
58
@@ELSIF@@ @_Kind_@ = UNPROTECTED_OPERATION
Maxime Perrotin's avatar
Maxime Perrotin committed
59
   // Unprotected call
60
@@TABLE@@
Maxime Perrotin's avatar
Maxime Perrotin committed
61
62
63
@@IF@@ not @_EXIST:Param_Names_@
   @_LOWER:Remote_Function_Names_@_@_LOWER:Remote_Interface_Names_@();
@@ELSE@@
64
65
66
67
68
69
70
71
72
73
   @_LOWER:Remote_Function_Names_@_@_LOWER:Remote_Interface_Names_@
@@INLINE(        \()(,\n         )(\);\n)@@
   @@TABLE@@
      @@IF@@ @_Param_Directions_@ = "PARAM_IN"
         IN_buf_@_LOWER:Param_Names_@, size_IN_buf_@_LOWER:Param_Names_@
      @@ELSE@@
         OUT_buf_@_LOWER:Param_Names_@, size_OUT_buf_@_LOWER:Param_Names_@
      @@END_IF@@
   @@END_TABLE@@
@@END_INLINE@@
Maxime Perrotin's avatar
Maxime Perrotin committed
74
@@END_IF@@
75
76
@@END_TABLE@@
@@ELSE@@ @@-- Protected call
77
   // puts("[TASTE] Protected call of @_Name_@");
78
79
80
81
82
83
84
85
86
87
88
89
@@TABLE@@
   pro_@_LOWER:Remote_Function_Names_@_@_LOWER:Remote_Interface_Names_@
@@INLINE(        \()(,\n         )(\);\n)@@
   @@TABLE@@
      @@IF@@ @_Param_Directions_@ = "PARAM_IN"
         IN_buf_@_LOWER:Param_Names_@, size_IN_buf_@_LOWER:Param_Names_@
      @@ELSE@@
         OUT_buf_@_LOWER:Param_Names_@, size_OUT_buf_@_LOWER:Param_Names_@
      @@END_IF@@
   @@END_TABLE@@
@@END_INLINE@@
@@END_TABLE@@
90
91
@@END_IF@@
}
92