1
------------------------------------------------------------------------------
2
--                                                                          --
3
--                           OCARINA COMPONENTS                             --
4
--                                                                          --
5
--        O C A R I N A . B A C K E N D S . X T R A T U M _ C O N F         --
6
--                                                                          --
7
--                                 B o d y                                  --
8
--                                                                          --
9
--         Copyright (C) 2011-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.Instances;
33
with Ocarina.Backends.Messages;
34
with Ocarina.Backends.Expander;
35
with Ocarina.ME_AADL.AADL_Instances.Nodes;
36
with Ocarina.Backends.XML_Tree.Nodes;
37
with Ocarina.Backends.XML_Tree.Nutils;
38
with Ocarina.Backends.XML_Tree.Generator;
39
with Ocarina.Backends.Utils;
40
with Ocarina.Backends.Xtratum_Conf.System_Description;
41
with Ocarina.Backends.Xtratum_Conf.Hardware_Description;
42
with Ocarina.Backends.Xtratum_Conf.Xm_Hypervisor;
43
with Ocarina.Backends.Xtratum_Conf.Resident_Sw;
44
with Ocarina.Backends.Xtratum_Conf.Partition_Table;
45
with Ocarina.Backends.Xtratum_Conf.Channels;
46

47
with Ocarina.Namet; use Ocarina.Namet;
48

49
package body Ocarina.Backends.Xtratum_Conf is
50

51
   use Ocarina.Instances;
52
   use Ocarina.ME_AADL.AADL_Instances.Nodes;
53
   use Ocarina.Backends.Expander;
54
   use Ocarina.Backends.Messages;
55
   use Ocarina.Backends.Utils;
56

57
   package XTN renames Ocarina.Backends.XML_Tree.Nodes;
58
   package XTU renames Ocarina.Backends.XML_Tree.Nutils;
59

60
   package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes;
61

62
   --------------
63
   -- Generate --
64
   --------------
65

66 1
   procedure Generate (AADL_Root : Node_Id) is
67 1
      Instance_Root : Node_Id;
68
   begin
69

70 1
      Instance_Root := Instantiate_Model (AADL_Root);
71

72 1
      Expand (Instance_Root);
73

74 1
      Visit_Architecture_Instance (Instance_Root);
75
      --  Abort if the construction of the tree failed
76

77 1
      if No (XML_Root) then
78 0
         Display_Error
79
           ("Xtratum configuration generation failed",
80
            Fatal => True);
81
      end if;
82

83
      --  At this point, we have a valid tree, we can begin the XML
84
      --  file generation.
85

86
      --  Enter the output directory
87

88 1
      Enter_Directory (Generated_Sources_Directory);
89

90 1
      if not Remove_Generated_Sources then
91
         --  Create the source files
92

93 1
         XML_Tree.Generator.Generate (XML_Root);
94

95
      end if;
96

97
      --  Leave the output directory
98 1
      Leave_Directory;
99 1
   end Generate;
100

101
   ----------
102
   -- Init --
103
   ----------
104

105 1
   procedure Init is
106
   begin
107 1
      Register_Backend
108
        ("Xtratum_Configuration",
109
         Generate'Access,
110
         Xtratum_Configuration);
111 1
   end Init;
112

113
   -----------
114
   -- Reset --
115
   -----------
116

117 1
   procedure Reset is
118
   begin
119 1
      null;
120 1
   end Reset;
121

122
   ---------------------------------
123
   -- Visit_Architecture_Instance --
124
   ---------------------------------
125

126 1
   procedure Visit_Architecture_Instance (E : Node_Id) is
127
   begin
128 1
      XML_Root := XTU.New_Node (XTN.K_HI_Distributed_Application);
129 1
      Get_Name_String
130 1
        (Normalize_Name (AIN.Name (AIN.Identifier (Root_System (E)))));
131 1
      XTN.Set_Name (XML_Root, Name_Find);
132 1
      XTN.Set_Units (XML_Root, XTU.New_List (XTN.K_List_Id));
133 1
      XTN.Set_HI_Nodes (XML_Root, XTU.New_List (XTN.K_List_Id));
134

135 1
      XTU.Push_Entity (XML_Root);
136

137 1
      System_Description.Visit (E);
138 1
      Hardware_Description.Visit (E);
139 1
      Xm_Hypervisor.Visit (E);
140 1
      Resident_Sw.Visit (E);
141 1
      Partition_Table.Visit (E);
142 1
      Channels.Visit (E);
143

144 1
      XTU.Pop_Entity;
145 1
   end Visit_Architecture_Instance;
146

147
   ------------------
148
   -- Get_XML_Root --
149
   ------------------
150

151 0
   function Get_XML_Root return Node_Id is
152
   begin
153 0
      return XML_Root;
154
   end Get_XML_Root;
155

156
end Ocarina.Backends.Xtratum_Conf;

Read our documentation on viewing source code .

Loading