OpenAADL / ocarina
1
------------------------------------------------------------------------------
2
--                                                                          --
3
--                           OCARINA COMPONENTS                             --
4
--                                                                          --
5
--                OCARINA.BACKENDS.VXWORKS653_CONF.MAPPING                  --
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 Ocarina.ME_AADL;
37
with Ocarina.ME_AADL.AADL_Instances.Nodes;
38
with Ocarina.ME_AADL.AADL_Instances.Nutils;
39

40
with Ocarina.Backends.XML_Tree.Nodes;
41
with Ocarina.Backends.XML_Tree.Nutils;
42
with Ocarina.Backends.Properties;
43

44
package body Ocarina.Backends.Vxworks653_Conf.Mapping is
45

46
   use Ocarina.ME_AADL.AADL_Instances.Nodes;
47
   use Ocarina.Backends.Properties;
48
   use Ocarina.Backends.XML_Tree.Nodes;
49
   use Ocarina.Backends.XML_Tree.Nutils;
50

51
   package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes;
52
   package AINU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
53
   package XTN renames Ocarina.Backends.XML_Tree.Nodes;
54
   package XTU renames Ocarina.Backends.XML_Tree.Nutils;
55

56
   -----------------
57
   -- Map_HI_Node --
58
   -----------------
59

60 1
   function Map_HI_Node (E : Node_Id) return Node_Id is
61 1
      N : constant Node_Id := New_Node (XTN.K_HI_Node);
62
   begin
63
      pragma Assert
64 1
        (AINU.Is_Process (E)
65 1
         or else AINU.Is_System (E)
66 1
         or else AINU.Is_Processor (E));
67

68 1
      if AINU.Is_System (E) then
69 0
         Set_Str_To_Name_Buffer ("general");
70
      else
71 1
         Get_Name_String
72 1
           (To_XML_Name
73 1
              (AIN.Name (AIN.Identifier (AIN.Parent_Subcomponent (E)))));
74 1
         Add_Str_To_Name_Buffer ("_vxworks653");
75
      end if;
76

77 1
      XTN.Set_Name (N, Name_Find);
78

79 1
      Set_Units (N, New_List (K_List_Id));
80

81
      --  Append the partition N to the node list
82

83 1
      Append_Node_To_List (N, HI_Nodes (Current_Entity));
84 1
      Set_Distributed_Application (N, Current_Entity);
85

86 1
      return N;
87
   end Map_HI_Node;
88

89
   -----------------
90
   -- Map_HI_Unit --
91
   -----------------
92

93 1
   function Map_HI_Unit (E : Node_Id) return Node_Id is
94 1
      U            : Node_Id;
95 1
      N            : Node_Id;
96 1
      P            : Node_Id;
97 1
      Root         : Node_Id;
98 1
      Core_OS_Node : Node_Id;
99
   begin
100
      pragma Assert
101 1
        (AINU.Is_System (E)
102 1
         or else AINU.Is_Process (E)
103 1
         or else AINU.Is_Processor (E));
104

105 1
      U := New_Node (XTN.K_HI_Unit, AIN.Identifier (E));
106

107
      --  Packages that are common to all nodes
108 1
      Get_Name_String
109 1
        (To_XML_Name (Display_Name (Identifier (Parent_Subcomponent (E)))));
110 1
      Add_Str_To_Name_Buffer ("_vxworks653-conf");
111 1
      N := Make_Defining_Identifier (Name_Find);
112 1
      P := Make_XML_File (N);
113 1
      Set_Distributed_Application_Unit (P, U);
114 1
      XTN.Set_XML_File (U, P);
115

116 1
      Root := Make_XML_Node ("Module");
117

118 1
      XTU.Add_Attribute ("hmShutdownHyperstartIndex", "2", Root);
119 1
      XTU.Add_Attribute ("minimumWindowDurationInNs", "100000", Root);
120 1
      XTU.Add_Attribute ("hmShutdownRegistry", "platreg.bin", Root);
121 1
      XTU.Add_Attribute ("comment", "please insert comment", Root);
122

123 1
      XTU.Add_Attribute
124
        ("xsi:schemaLocation",
125
         "http://www.windriver.com/vxWorks653/ConfigRecord " &
126
         "../xml/cleanschena/Module.xsd",
127
         Root);
128

129 1
      XTU.Add_Attribute ("xmlns:xi", "http://www.w3.org/2001/XInclude", Root);
130

131 1
      XTU.Add_Attribute
132
        ("xmlns:xsi",
133
         "http://www.w3.org/2001/XMLSchema-instance",
134
         Root);
135

136 1
      XTU.Add_Attribute
137
        ("xmlns",
138
         "http://www.windriver.com/vxWorks653/ConfigRecord",
139
         Root);
140

141 1
      Core_OS_Node := Make_XML_Node ("CoreOS");
142 1
      Append_Node_To_List (Core_OS_Node, XTN.Subitems (Root));
143

144 1
      XTN.Set_Root_Node (P, Root);
145

146 1
      Append_Node_To_List (U, Units (Current_Entity));
147 1
      XTN.Set_Entity (U, Current_Entity);
148

149 1
      return U;
150
   end Map_HI_Unit;
151

152
   -------------------
153
   -- Map_Partition --
154
   -------------------
155

156 1
   function Map_Partition
157
     (Process              : Node_Id;
158
      Runtime              : Node_Id;
159
      Partition_Identifier : Integer;
160
      Nb_Threads           : Unsigned_Long_Long;
161
      Nb_Buffers           : Unsigned_Long_Long;
162
      Nb_Events            : Unsigned_Long_Long;
163
      Nb_Lock_Objects      : Unsigned_Long_Long;
164
      Nb_Blackboards       : Unsigned_Long_Long;
165
      Blackboards_Size     : Unsigned_Long_Long;
166
      Buffers_Size         : Unsigned_Long_Long) return Node_Id
167
   is
168
      pragma Unreferenced (Nb_Buffers);
169
      pragma Unreferenced (Nb_Events);
170
      pragma Unreferenced (Nb_Threads);
171
      pragma Unreferenced (Nb_Blackboards);
172
      pragma Unreferenced (Blackboards_Size);
173
      pragma Unreferenced (Nb_Lock_Objects);
174
      pragma Unreferenced (Buffers_Size);
175
      pragma Unreferenced (Process);
176 1
      Partition_Node             : Node_Id;
177 1
      Partition_Description_Node : Node_Id;
178 1
      Application_Node           : Node_Id;
179 1
      Shared_Library_Region_Node : Node_Id;
180 1
      Settings_Node              : Node_Id;
181
   begin
182 1
      Partition_Node             := Make_XML_Node ("Partition");
183 1
      Partition_Description_Node := Make_XML_Node ("PartitionDescription");
184 1
      Append_Node_To_List
185
        (Partition_Description_Node,
186 1
         XTN.Subitems (Partition_Node));
187

188 1
      XTU.Add_Attribute
189
        ("Name",
190 1
         Get_Name_String (Map_Partition_Name (Runtime)),
191
         Partition_Node);
192
      --
193
      --  Integer'Image adds a space in the beginning. To avoid that,
194
      --  see http://rosettacode.org/wiki/
195
      --  Strip_whitespace_from_a_string/Top_and_tail#Ada
196
      --
197 1
      XTU.Add_Attribute
198
        ("Id",
199 1
         Trim (Integer'Image (Partition_Identifier), Left),
200
         Partition_Node);
201

202
      --  Create the <Application/> sub-node.
203

204 1
      Application_Node := Make_XML_Node ("Application");
205 1
      XTU.Add_Attribute
206
        ("NameRef",
207 1
         Get_Name_String (Map_Application_Name (Runtime, True)),
208
         Application_Node);
209 1
      Append_Node_To_List
210
        (Application_Node,
211 1
         XTN.Subitems (Partition_Description_Node));
212

213
      --  Create the <SharedLibraryRegion/> sub-node.
214

215 1
      Shared_Library_Region_Node := Make_XML_Node ("SharedLibraryRegion");
216 1
      XTU.Add_Attribute ("NameRef", "vxSysLib", Shared_Library_Region_Node);
217 1
      Append_Node_To_List
218
        (Shared_Library_Region_Node,
219 1
         XTN.Subitems (Partition_Description_Node));
220

221
      --  Create the <Settings/> sub-node.
222

223 1
      Settings_Node := Make_XML_Node ("Settings");
224 1
      Append_Node_To_List
225
        (Settings_Node,
226 1
         XTN.Subitems (Partition_Description_Node));
227 1
      XTU.Add_Attribute ("RequiredMemorySize", "0x300000", Settings_Node);
228 1
      XTU.Add_Attribute
229
        ("PartitionHMTable",
230 1
         Get_Name_String (Map_Partition_Name (Runtime)) & "_hmtable",
231
         Settings_Node);
232 1
      XTU.Add_Attribute ("watchDogDuration", "0", Settings_Node);
233 1
      XTU.Add_Attribute ("allocDisable", "0", Settings_Node);
234 1
      XTU.Add_Attribute ("numWorkerTasks", "0", Settings_Node);
235 1
      XTU.Add_Attribute ("numStackGuardPages", "0xffffffff", Settings_Node);
236 1
      XTU.Add_Attribute ("isrStackSize", "0xffffffff", Settings_Node);
237 1
      XTU.Add_Attribute ("selSvrQSize", "0xffffffff", Settings_Node);
238 1
      XTU.Add_Attribute ("syscallPermissions", "0xffffffff", Settings_Node);
239 1
      XTU.Add_Attribute ("numFiles", "0xffffffff", Settings_Node);
240 1
      XTU.Add_Attribute ("numDrivers", "0xffffffff", Settings_Node);
241 1
      XTU.Add_Attribute ("numLogMsgs", "0xffffffff", Settings_Node);
242 1
      XTU.Add_Attribute ("maxGlobalFDs", "10", Settings_Node);
243 1
      XTU.Add_Attribute ("fpExcEnable", "1", Settings_Node);
244 1
      XTU.Add_Attribute
245
        ("maxEventQStallDuration",
246
         "INFINITE_TIME",
247
         Settings_Node);
248

249 1
      return Partition_Node;
250
   end Map_Partition;
251

252 1
   function Map_Partition_Name
253
     (Runtime         : Node_Id;
254
      Use_Source_Name : Boolean := True) return Name_Id
255
   is
256 1
      Result : Name_Id;
257
   begin
258 1
      Result := Get_Source_Name (Runtime);
259 1
      if Result /= No_Name and then Use_Source_Name then
260 0
         return Result;
261
      end if;
262 1
      Result := AIN.Name (Identifier (Parent_Subcomponent (Runtime)));
263 1
      return Result;
264
   end Map_Partition_Name;
265

266 1
   function Map_Application_Name
267
     (Runtime         : Node_Id;
268
      Use_Source_Name : Boolean := True) return Name_Id
269
   is
270 1
      Result : Name_Id;
271
   begin
272 1
      Result := Map_Partition_Name (Runtime, Use_Source_Name);
273 1
      Get_Name_String (Result);
274 1
      Add_Str_To_Name_Buffer ("_app");
275 1
      Result := Name_Find;
276 1
      return Result;
277
   end Map_Application_Name;
278

279
end Ocarina.Backends.Vxworks653_Conf.Mapping;

Read our documentation on viewing source code .

Loading