OpenAADL / ocarina
1
------------------------------------------------------------------------------
2
--                                                                          --
3
--                           OCARINA COMPONENTS                             --
4
--                                                                          --
5
--               OCARINA.BACKENDS.VXWORKS653_CONF.PARTITIONS                --
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 Ocarina.Backends.Messages;
33
with Ocarina.ME_AADL;
34
with Ocarina.ME_AADL.AADL_Instances.Nodes;
35
with Ocarina.ME_AADL.AADL_Instances.Nutils;
36
with Ocarina.ME_AADL.AADL_Instances.Entities;
37

38
with Ocarina.Backends.Utils;
39
with Ocarina.Backends.Properties;
40
with Ocarina.Backends.XML_Tree.Nodes;
41
with Ocarina.Backends.XML_Tree.Nutils;
42
with Ocarina.Backends.Vxworks653_Conf.Mapping;
43

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

46
   use Ocarina.ME_AADL;
47

48
   use Ocarina.Backends.Utils;
49
   use Ocarina.Backends.Messages;
50
   use Ocarina.ME_AADL.AADL_Instances.Nodes;
51
   use Ocarina.ME_AADL.AADL_Instances.Entities;
52
   use Ocarina.Backends.XML_Tree.Nutils;
53
   use Ocarina.Backends.Properties;
54
   use Ocarina.Backends.Vxworks653_Conf.Mapping;
55

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

60
   Root_Node                : Node_Id            := No_Node;
61
   Partitions_Node          : Node_Id            := No_Node;
62
   Partition_Identifier     : Integer            := 1;
63
   Process_Nb_Threads       : Unsigned_Long_Long := 0;
64
   Process_Nb_Buffers       : Unsigned_Long_Long := 0;
65
   Process_Nb_Events        : Unsigned_Long_Long := 0;
66
   Process_Nb_Lock_Objects  : Unsigned_Long_Long := 0;
67
   Process_Nb_Blackboards   : Unsigned_Long_Long := 0;
68
   Process_Blackboards_Size : Unsigned_Long_Long := 0;
69
   Process_Buffers_Size     : Unsigned_Long_Long := 0;
70

71
   procedure Visit_Architecture_Instance (E : Node_Id);
72
   procedure Visit_Component_Instance (E : Node_Id);
73
   procedure Visit_System_Instance (E : Node_Id);
74
   procedure Visit_Process_Instance (E : Node_Id);
75
   procedure Visit_Thread_Instance (E : Node_Id);
76
   procedure Visit_Processor_Instance (E : Node_Id);
77
   procedure Visit_Bus_Instance (E : Node_Id);
78
   procedure Visit_Virtual_Processor_Instance (E : Node_Id);
79
   procedure Visit_Subcomponents_Of is new Visit_Subcomponents_Of_G (Visit);
80

81
   -----------
82
   -- Visit --
83
   -----------
84

85 1
   procedure Visit (E : Node_Id) is
86
   begin
87 1
      case Kind (E) is
88 1
         when K_Architecture_Instance =>
89 1
            Visit_Architecture_Instance (E);
90

91 1
         when K_Component_Instance =>
92 1
            Visit_Component_Instance (E);
93

94 0
         when others =>
95 0
            null;
96 1
      end case;
97 1
   end Visit;
98

99
   ---------------------------------
100
   -- Visit_Architecture_Instance --
101
   ---------------------------------
102

103 1
   procedure Visit_Architecture_Instance (E : Node_Id) is
104
   begin
105 1
      Root_Node := Root_System (E);
106 1
      Visit (Root_Node);
107 1
   end Visit_Architecture_Instance;
108

109
   ------------------------------
110
   -- Visit_Component_Instance --
111
   ------------------------------
112

113 1
   procedure Visit_Component_Instance (E : Node_Id) is
114 1
      Category : constant Component_Category := Get_Category_Of_Component (E);
115
   begin
116 1
      case Category is
117 1
         when CC_System =>
118 1
            Visit_System_Instance (E);
119

120 1
         when CC_Process =>
121 1
            Visit_Process_Instance (E);
122

123 1
         when CC_Thread =>
124 1
            Visit_Thread_Instance (E);
125

126 1
         when CC_Processor =>
127 1
            Visit_Processor_Instance (E);
128

129 0
         when CC_Bus =>
130 0
            Visit_Bus_Instance (E);
131

132 1
         when CC_Virtual_Processor =>
133 1
            Visit_Virtual_Processor_Instance (E);
134

135 0
         when others =>
136 0
            null;
137 1
      end case;
138 1
   end Visit_Component_Instance;
139

140
   ---------------------------
141
   -- Visit_Thread_Instance --
142
   ---------------------------
143

144 1
   procedure Visit_Thread_Instance (E : Node_Id) is
145 1
      F : Node_Id;
146
   begin
147 1
      Process_Nb_Threads := Process_Nb_Threads + 1;
148

149 1
      if not AINU.Is_Empty (Features (E)) then
150 1
         F := First_Node (Features (E));
151

152 1
         while Present (F) loop
153 1
            if Kind (F) = K_Port_Spec_Instance then
154 1
               if Get_Connection_Pattern (F) = Intra_Process
155 1
                 and then Is_In (F)
156
               then
157 1
                  if AIN.Is_Data (F) and then not AIN.Is_Event (F) then
158 1
                     Process_Nb_Blackboards   := Process_Nb_Blackboards + 1;
159 1
                     Process_Blackboards_Size :=
160 1
                       Process_Blackboards_Size +
161 1
                       To_Bytes (Get_Data_Size (Corresponding_Instance (F)));
162 1
                  elsif AIN.Is_Data (F) and then AIN.Is_Event (F) then
163 1
                     Process_Nb_Buffers := Process_Nb_Buffers + 1;
164 0
                  elsif AIN.Is_Event (F) and then not AIN.Is_Data (F) then
165 0
                     Process_Nb_Events := Process_Nb_Events + 1;
166
                  else
167 0
                     Display_Error
168
                       ("Communication Pattern not handled",
169
                        Fatal => True);
170
                  end if;
171

172 1
                  Process_Nb_Lock_Objects := Process_Nb_Lock_Objects + 1;
173
               end if;
174
            end if;
175 1
            F := Next_Node (F);
176 1
         end loop;
177
      end if;
178

179 1
   end Visit_Thread_Instance;
180

181
   ----------------------------
182
   -- Visit_Process_Instance --
183
   ----------------------------
184

185 1
   procedure Visit_Process_Instance (E : Node_Id) is
186
   begin
187 1
      Visit_Subcomponents_Of (E);
188 1
   end Visit_Process_Instance;
189

190
   ---------------------------
191
   -- Visit_System_Instance --
192
   ---------------------------
193

194 1
   procedure Visit_System_Instance (E : Node_Id) is
195 1
      S : Node_Id;
196
   begin
197 1
      if not AINU.Is_Empty (Subcomponents (E)) then
198 1
         S := First_Node (Subcomponents (E));
199 1
         while Present (S) loop
200
            --  Visit processor subcomponents
201

202 1
            if AINU.Is_Processor (Corresponding_Instance (S)) then
203 1
               Visit (Corresponding_Instance (S));
204
            end if;
205 1
            S := Next_Node (S);
206 1
         end loop;
207
      end if;
208 1
   end Visit_System_Instance;
209

210
   ------------------------
211
   -- Visit_Bus_Instance --
212
   ------------------------
213

214 0
   procedure Visit_Bus_Instance (E : Node_Id) is
215
      pragma Unreferenced (E);
216
   begin
217 0
      null;
218 0
   end Visit_Bus_Instance;
219

220
   ------------------------------
221
   -- Visit_Processor_Instance --
222
   ------------------------------
223

224 1
   procedure Visit_Processor_Instance (E : Node_Id) is
225 1
      S : Node_Id;
226 1
      U : Node_Id;
227 1
      P : Node_Id;
228
   begin
229 1
      U := XTN.Unit (Backend_Node (Identifier (E)));
230 1
      P := XTN.Node (Backend_Node (Identifier (E)));
231

232 1
      Push_Entity (P);
233 1
      Push_Entity (U);
234

235 1
      Partition_Identifier := 1;
236

237 1
      Current_XML_Node := XTN.Root_Node (XTN.XML_File (U));
238

239
      --  First, make the <Partition/> nodes
240

241 1
      Partitions_Node := Make_XML_Node ("Partitions");
242 1
      Append_Node_To_List (Partitions_Node, XTN.Subitems (Current_XML_Node));
243

244 1
      if not AINU.Is_Empty (Subcomponents (E)) then
245 1
         S := First_Node (Subcomponents (E));
246 1
         while Present (S) loop
247
            --  Visit virtual processor subcomponents
248

249 1
            if AINU.Is_Virtual_Processor (Corresponding_Instance (S)) then
250 1
               Visit (Corresponding_Instance (S));
251
            end if;
252 1
            S := Next_Node (S);
253 1
         end loop;
254
      end if;
255

256 1
      Pop_Entity;
257 1
      Pop_Entity;
258 1
   end Visit_Processor_Instance;
259

260
   --------------------------------------
261
   -- Visit_Virtual_Processor_Instance --
262
   --------------------------------------
263

264 1
   procedure Visit_Virtual_Processor_Instance (E : Node_Id) is
265 1
      S                     : Node_Id;
266 1
      Corresponding_Process : Node_Id := No_Node;
267 1
      Partition_Node        : Node_Id;
268
   begin
269 1
      Corresponding_Process := Find_Associated_Process (E);
270

271 1
      if Corresponding_Process /= No_Node then
272

273 1
         Process_Nb_Threads       := 0;
274 1
         Process_Nb_Buffers       := 0;
275 1
         Process_Nb_Events        := 0;
276 1
         Process_Nb_Lock_Objects  := 0;
277 1
         Process_Nb_Blackboards   := 0;
278 1
         Process_Blackboards_Size := 0;
279 1
         Process_Buffers_Size     := 0;
280

281 1
         Visit (Corresponding_Process);
282

283
         --
284
         --  First, we create the description of the partition.
285
         --
286
         Partition_Node :=
287 1
           Map_Partition
288
             (Corresponding_Process,
289
              E,
290
              Partition_Identifier,
291
              Process_Nb_Threads,
292
              Process_Nb_Buffers,
293
              Process_Nb_Events,
294
              Process_Nb_Lock_Objects,
295
              Process_Nb_Blackboards,
296
              Process_Blackboards_Size,
297
              Process_Buffers_Size);
298 1
         Append_Node_To_List (Partition_Node, XTN.Subitems (Partitions_Node));
299

300 1
         Partition_Identifier := Partition_Identifier + 1;
301
      end if;
302

303 1
      if not AINU.Is_Empty (Subcomponents (E)) then
304 0
         S := First_Node (Subcomponents (E));
305 0
         while Present (S) loop
306

307 0
            Visit (Corresponding_Instance (S));
308 0
            S := Next_Node (S);
309 0
         end loop;
310
      end if;
311 1
   end Visit_Virtual_Processor_Instance;
312

313
end Ocarina.Backends.Vxworks653_Conf.Partitions;

Read our documentation on viewing source code .

Loading