OpenAADL / ocarina
1
------------------------------------------------------------------------------
2
--                                                                          --
3
--                           OCARINA COMPONENTS                             --
4
--                                                                          --
5
--   O C A R I N A . B A C K E N D S . D E O S _ C O N F . M A P P I N G    --
6
--                                                                          --
7
--                                 B o d y                                  --
8
--                                                                          --
9
--         Copyright (C) 2015-2019 ESA & ISAE, 2019-2020 OpenAADL           --
10
--                                                                          --
11
-- Ocarina  is free software; you can redistribute it and/or modify under   --
12
-- terms of the  GNU General Public License as published  by the Free Soft- --
13
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
14
-- sion. Ocarina is distributed in the hope that it will be useful, but     --
15
-- WITHOUT ANY WARRANTY; without even the implied warranty of               --
16
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     --
17
--                                                                          --
18
-- As a special exception under Section 7 of GPL version 3, you are granted --
19
-- additional permissions described in the GCC Runtime Library Exception,   --
20
-- version 3.1, as published by the Free Software Foundation.               --
21
--                                                                          --
22
-- You should have received a copy of the GNU General Public License and    --
23
-- a copy of the GCC Runtime Library Exception along with this program;     --
24
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
25
-- <http://www.gnu.org/licenses/>.                                          --
26
--                                                                          --
27
--                    Ocarina is maintained by OpenAADL team                --
28
--                              (info@openaadl.org)                         --
29
--                                                                          --
30
------------------------------------------------------------------------------
31

32
with Ada.Strings;       use Ada.Strings;
33
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
34
with Ocarina.Namet;     use Ocarina.Namet;
35

36
with Utils; use Utils;
37
with Ocarina.ME_AADL;
38
with Ocarina.ME_AADL.AADL_Instances.Nodes;
39
with Ocarina.ME_AADL.AADL_Instances.Nutils;
40

41
with Ocarina.Backends.Properties;
42
with Ocarina.Backends.Utils;
43
with Ocarina.Backends.XML_Common;
44
with Ocarina.Backends.XML_Tree.Nodes;
45
with Ocarina.Backends.XML_Tree.Nutils;
46

47
package body Ocarina.Backends.Deos_Conf.Mapping is
48

49
   use Ocarina.ME_AADL.AADL_Instances.Nodes;
50
   use Ocarina.Backends.Properties;
51
   use Ocarina.Backends.Utils;
52
   use Ocarina.Backends.XML_Tree.Nodes;
53
   use Ocarina.Backends.XML_Tree.Nutils;
54

55
   package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes;
56
   package AINU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
57
   package XTN renames Ocarina.Backends.XML_Tree.Nodes;
58
   package XTU renames Ocarina.Backends.XML_Tree.Nutils;
59

60
   -----------------
61
   -- Map_HI_Node --
62
   -----------------
63

64 1
   function Map_HI_Node (E : Node_Id) return Node_Id is
65 1
      N : constant Node_Id := New_Node (XTN.K_HI_Node);
66
   begin
67
      pragma Assert
68 1
        (AINU.Is_Process (E)
69 1
         or else AINU.Is_System (E)
70 1
         or else AINU.Is_Processor (E));
71

72 1
      if AINU.Is_System (E) then
73 0
         Set_Str_To_Name_Buffer ("general");
74
      else
75 1
         Get_Name_String
76 1
           (To_XML_Name
77 1
              (AIN.Name (AIN.Identifier (AIN.Parent_Subcomponent (E)))));
78 1
         Add_Str_To_Name_Buffer ("_deos");
79
      end if;
80

81 1
      XTN.Set_Name (N, Name_Find);
82

83 1
      Set_Units (N, New_List (K_List_Id));
84

85
      --  Append the partition N to the node list
86

87 1
      Append_Node_To_List (N, HI_Nodes (Current_Entity));
88 1
      Set_Distributed_Application (N, Current_Entity);
89

90 1
      return N;
91
   end Map_HI_Node;
92

93
   -----------------
94
   -- Map_HI_Unit --
95
   -----------------
96

97 1
   function Map_HI_Unit (E : Node_Id) return Node_Id is
98 1
      U    : Node_Id;
99 1
      N    : Node_Id;
100 1
      P    : Node_Id;
101 1
      Q    : Node_Id;
102 1
      R    : Node_Id;
103 1
      Root : Node_Id;
104
   begin
105
      pragma Assert
106 1
        (AINU.Is_System (E)
107 1
         or else AINU.Is_Process (E)
108 1
         or else AINU.Is_Processor (E));
109

110 1
      U := New_Node (XTN.K_HI_Unit, AIN.Identifier (E));
111

112
      --  Packages that are common to all nodes
113 1
      Get_Name_String
114 1
        (To_XML_Name (Display_Name (Identifier (Parent_Subcomponent (E)))));
115 1
      Add_Str_To_Name_Buffer ("_deos-conf");
116 1
      N := Make_Defining_Identifier (Name_Find);
117 1
      P := Make_XML_File (N);
118 1
      Set_Distributed_Application_Unit (P, U);
119 1
      XTN.Set_XML_File (U, P);
120

121 1
      Root := Make_XML_Node ("Deos653Config");
122

123 1
      XTU.Add_Attribute ("validityKey", "0000", Root);
124 1
      XTU.Add_Attribute ("toolVersion", "1.10.2", Root);
125 1
      XTU.Add_Attribute ("hmShutdownHyperstartIndex", "2", Root);
126 1
      XTU.Add_Attribute ("minimumWindowDurationInNs", "100000", Root);
127 1
      XTU.Add_Attribute ("hmShutdownRegistry", "platreg.bin", Root);
128 1
      XTU.Add_Attribute ("xsi:schemaLocation", "deos653.xsd", Root);
129 1
      XTU.Add_Attribute ("comment", "please insert comment", Root);
130 1
      XTU.Add_Attribute
131
        ("xmlns:xsi",
132
         "http://www.w3.org/2001/XMLSchema-instance",
133
         Root);
134 1
      XTU.Add_Attribute ("xmlns", "http://ddci.com/ARINC653", Root);
135

136 1
      Set_Str_To_Name_Buffer ("name");
137 1
      R := Make_Defining_Identifier (Name_Find);
138 1
      Get_Name_String (To_XML_Name (Display_Name (Identifier (E))));
139 1
      Q := Make_Defining_Identifier (Name_Find);
140 1
      Append_Node_To_List (Make_Assignement (R, Q), XTN.Items (Root));
141

142 1
      XTN.Set_Root_Node (P, Root);
143

144 1
      Append_Node_To_List (U, Units (Current_Entity));
145 1
      XTN.Set_Entity (U, Current_Entity);
146

147 1
      return U;
148
   end Map_HI_Unit;
149

150
   -----------------------
151
   -- Map_Sampling_Port --
152
   -----------------------
153

154 1
   function Map_Sampling_Port (Port : Node_Id) return Node_Id is
155 1
      Sampling_Port  : Node_Id;
156 1
      Size           : Unsigned_Long_Long;
157 1
      Source_Port    : Node_Id;
158 1
      Source_Process : Node_Id;
159 1
      Source_Runtime : Node_Id;
160
   begin
161 1
      Sampling_Port := Make_XML_Node ("SamplingPort");
162 1
      Size := To_Bytes (Get_Data_Size (Corresponding_Instance (Port)));
163

164 1
      XTU.Add_Attribute
165
        ("Name",
166 1
         Get_Name_String (Map_Port_Name (Port)),
167
         Sampling_Port);
168 1
      XTU.Add_Attribute
169
        ("MaxMessageSize",
170 1
         Trim (Unsigned_Long_Long'Image (Size), Left),
171
         Sampling_Port);
172

173 1
      if Is_In (Port) then
174 1
         XTU.Add_Attribute ("Direction", "DESTINATION", Sampling_Port);
175 1
      elsif Is_Out (Port) then
176 1
         XTU.Add_Attribute ("Direction", "SOURCE", Sampling_Port);
177
      end if;
178

179 1
      if Is_In (Port) then
180 1
         Source_Port    := Item (AIN.First_Node (Sources (Port)));
181 1
         Source_Process := Parent_Component (Source_Port);
182
         Source_Runtime :=
183 1
           Parent_Subcomponent (Get_Partition_Runtime (Source_Process));
184 1
         XTU.Add_Attribute
185
           ("SourcePortName",
186 1
            Get_Name_String (Map_Port_Name (Source_Port)),
187
            Sampling_Port);
188 1
         XTU.Add_Attribute
189
           ("SourcePartitionName",
190 1
            Get_Name_String (Display_Name (Identifier (Source_Runtime))),
191
            Sampling_Port);
192
      else
193 1
         XTU.Add_Attribute ("SourcePartitionName", "", Sampling_Port);
194 1
         XTU.Add_Attribute ("SourcePortName", "", Sampling_Port);
195
      end if;
196

197 1
      XTU.Add_Attribute ("CustomIOFunction", "", Sampling_Port);
198 1
      XTU.Add_Attribute ("AccessRateInNanoseconds", "12500000", Sampling_Port);
199 1
      return Sampling_Port;
200
   end Map_Sampling_Port;
201

202
   ----------------------
203
   -- Map_Queuing_Port --
204
   ----------------------
205

206 1
   function Map_Queuing_Port (Port : Node_Id) return Node_Id is
207 1
      Queuing_Port   : Node_Id;
208 1
      Size           : Unsigned_Long_Long;
209 1
      Queue_Size     : Long_Long;
210 1
      Source_Port    : Node_Id;
211 1
      Source_Process : Node_Id;
212 1
      Source_Runtime : Node_Id;
213
   begin
214 1
      Queuing_Port := Make_XML_Node ("QueuingPort");
215 1
      Size         := To_Bytes (Get_Data_Size (Corresponding_Instance (Port)));
216 1
      Queue_Size   := Get_Queue_Size (Port);
217

218 1
      if Queue_Size = -1 then
219 1
         Queue_Size := 1;
220
      end if;
221

222 1
      XTU.Add_Attribute
223
        ("Name",
224 1
         Get_Name_String (Map_Port_Name (Port)),
225
         Queuing_Port);
226 1
      XTU.Add_Attribute
227
        ("MaxMessageSize",
228 1
         Trim (Unsigned_Long_Long'Image (Size), Left),
229
         Queuing_Port);
230

231 1
      XTU.Add_Attribute
232
        ("MaxNbMessage",
233 1
         Trim (Long_Long'Image (Queue_Size), Left),
234
         Queuing_Port);
235

236 1
      if Is_In (Port) then
237 1
         XTU.Add_Attribute ("Direction", "DESTINATION", Queuing_Port);
238 1
      elsif Is_Out (Port) then
239 1
         XTU.Add_Attribute ("Direction", "SOURCE", Queuing_Port);
240
      end if;
241

242 1
      if Is_In (Port) then
243 1
         Source_Port    := Item (AIN.First_Node (Sources (Port)));
244 1
         Source_Process := Parent_Component (Source_Port);
245
         Source_Runtime :=
246 1
           Parent_Subcomponent (Get_Partition_Runtime (Source_Process));
247 1
         XTU.Add_Attribute
248
           ("SourcePortName",
249 1
            Get_Name_String (Map_Port_Name (Source_Port)),
250
            Queuing_Port);
251 1
         XTU.Add_Attribute
252
           ("SourcePartitionName",
253 1
            Get_Name_String (Display_Name (Identifier (Source_Runtime))),
254
            Queuing_Port);
255
      else
256 1
         XTU.Add_Attribute ("SourcePartitionName", "", Queuing_Port);
257 1
         XTU.Add_Attribute ("SourcePortName", "", Queuing_Port);
258
      end if;
259

260 1
      XTU.Add_Attribute ("CustomIOFunction", "", Queuing_Port);
261 1
      return Queuing_Port;
262
   end Map_Queuing_Port;
263

264
   -------------------
265
   -- Map_Partition --
266
   -------------------
267

268 1
   function Map_Partition
269
     (Process              : Node_Id;
270
      Runtime              : Node_Id;
271
      Partition_Identifier : Integer;
272
      Nb_Threads           : Unsigned_Long_Long;
273
      Nb_Buffers           : Unsigned_Long_Long;
274
      Nb_Events            : Unsigned_Long_Long;
275
      Nb_Lock_Objects      : Unsigned_Long_Long;
276
      Nb_Blackboards       : Unsigned_Long_Long;
277
      Blackboards_Size     : Unsigned_Long_Long;
278
      Buffers_Size         : Unsigned_Long_Long) return Node_Id
279
   is
280
      pragma Unreferenced (Nb_Buffers);
281
      pragma Unreferenced (Nb_Events);
282
      pragma Unreferenced (Nb_Lock_Objects);
283
      pragma Unreferenced (Buffers_Size);
284
      pragma Unreferenced (Process);
285 1
      Partition_Node     : Node_Id;
286 1
      Partition_Period   : Time_Type;
287 1
      Partition_Duration : Time_Type;
288 1
      Period_Ns          : Unsigned_Long_Long;
289 1
      Duration_Ns        : Unsigned_Long_Long;
290
   begin
291 1
      Partition_Period   := Get_Period (Runtime);
292 1
      Partition_Duration := Get_Execution_Time (Runtime);
293

294 1
      if Partition_Period = Null_Time then
295 1
         Period_Ns := 0;
296
      else
297 0
         Period_Ns := To_Nanoseconds (Partition_Period);
298
      end if;
299

300 1
      if Partition_Duration = Null_Time then
301 1
         Duration_Ns := 0;
302
      else
303 0
         Duration_Ns := To_Nanoseconds (Partition_Duration);
304
      end if;
305

306 1
      Partition_Node := Make_XML_Node ("Partition");
307

308 1
      XTU.Add_Attribute
309
        ("Name",
310 1
         Get_Name_String
311 1
           (AIN.Name (Identifier (Parent_Subcomponent (Runtime)))),
312
         Partition_Node);
313
      --
314
      --  Integer'Image adds a space in the beginning. To avoid that,
315
      --  see http://rosettacode.org/wiki/
316
      --  Strip_whitespace_from_a_string/Top_and_tail#Ada
317
      --
318 1
      XTU.Add_Attribute
319
        ("Identifier",
320 1
         Trim (Integer'Image (Partition_Identifier), Left),
321
         Partition_Node);
322

323 1
      XTU.Add_Attribute
324
        ("Period",
325 1
         Trim (Unsigned_Long_Long'Image (Period_Ns), Left),
326
         Partition_Node);
327

328 1
      XTU.Add_Attribute
329
        ("Duration",
330 1
         Trim (Unsigned_Long_Long'Image (Duration_Ns), Left),
331
         Partition_Node);
332

333 1
      if Get_Source_Name (Runtime) = No_Name then
334 1
         XTU.Add_Attribute
335
           ("ExecutableImageName",
336 1
            Get_Name_String
337 1
              (AIN.Name (Identifier (Parent_Subcomponent (Runtime)))) &
338
            ".exe",
339
            Partition_Node);
340
      else
341 0
         XTU.Add_Attribute
342
           ("ExecutableImageName",
343 0
            Get_Name_String (Get_Source_Name (Runtime)),
344
            Partition_Node);
345
      end if;
346 1
      XTU.Add_Attribute ("MainProcessStackSizeInPages", "1", Partition_Node);
347 1
      XTU.Add_Attribute ("BreakAtStartup", "no", Partition_Node);
348 1
      XTU.Add_Attribute ("InDebugSet", "no", Partition_Node);
349 1
      XTU.Add_Attribute ("MapConfigurationFileTo", "RAM", Partition_Node);
350 1
      XTU.Add_Attribute ("ExecuteFrom", "RAM", Partition_Node);
351 1
      XTU.Add_Attribute ("PartitionUsesFPU", "no", Partition_Node);
352 1
      XTU.Add_Attribute ("ProcessStackSpaceInPages", "6", Partition_Node);
353 1
      XTU.Add_Attribute
354
        ("MinimumProcessStackSizeInBytes",
355
         "512",
356
         Partition_Node);
357 1
      XTU.Add_Attribute
358
        ("ProcessQuota",
359 1
         Trim (Unsigned_Long_Long'Image (Nb_Threads + 2), Left),
360
         Partition_Node);
361 1
      XTU.Add_Attribute
362
        ("BlackboardQuota",
363 1
         Trim (Unsigned_Long_Long'Image (Nb_Blackboards), Left),
364
         Partition_Node);
365

366 1
      XTU.Add_Attribute
367
        ("BlackboardMessageSpaceInBytes",
368 1
         Trim (Unsigned_Long_Long'Image (Blackboards_Size), Left),
369
         Partition_Node);
370 1
      XTU.Add_Attribute ("BufferQuota", "0", Partition_Node);
371 1
      XTU.Add_Attribute ("BufferMessageSpaceInBytes", "0", Partition_Node);
372 1
      XTU.Add_Attribute ("SemaphoreQuota", "0", Partition_Node);
373 1
      XTU.Add_Attribute ("EventQuota", "1", Partition_Node);
374 1
      XTU.Add_Attribute ("MaximumPartitionLockLevel", "16", Partition_Node);
375 1
      XTU.Add_Attribute ("MinimumProcessPriority", "1", Partition_Node);
376 1
      XTU.Add_Attribute ("MaximumProcessPriority", "239", Partition_Node);
377 1
      XTU.Add_Attribute ("LoggingFunction", "", Partition_Node);
378 1
      XTU.Add_Attribute ("DeosKernelAttributeAccess", "no", Partition_Node);
379 1
      XTU.Add_Attribute ("ProcessStackGapSizeInDwords", "0", Partition_Node);
380 1
      XTU.Add_Attribute
381
        ("ProcessStackTagIntervalInDwords",
382
         "0",
383
         Partition_Node);
384 1
      XTU.Add_Attribute
385
        ("SourcePortSharedMemoryType",
386
         "DeosSharedMemory",
387
         Partition_Node);
388 1
      XTU.Add_Attribute
389
        ("PlatformResourcePhysicalAddress",
390
         "0x0",
391
         Partition_Node);
392 1
      XTU.Add_Attribute ("PlatformResourceSizeInPages", "0", Partition_Node);
393 1
      XTU.Add_Attribute ("PlatformResourceCachePolicy", "off", Partition_Node);
394 1
      XTU.Add_Attribute ("HealthMonitorEventLogSize", "30", Partition_Node);
395 1
      XTU.Add_Attribute ("EventLoggingEnabled", "yes", Partition_Node);
396 1
      return Partition_Node;
397 1
   end Map_Partition;
398

399
   -------------------
400
   -- Map_Port_Name --
401
   -------------------
402

403 1
   function Map_Port_Name (E : Node_Id) return Name_Id is
404 1
      N : Name_Id;
405
   begin
406 1
      Get_Name_String (Display_Name (Identifier (E)));
407

408 1
      N := Name_Find;
409 1
      return (To_Lower (N));
410
   end Map_Port_Name;
411

412
end Ocarina.Backends.Deos_Conf.Mapping;

Read our documentation on viewing source code .

Loading