1
------------------------------------------------------------------------------
2
--                                                                          --
3
--                           OCARINA COMPONENTS                             --
4
--                                                                          --
5
--               OCARINA.BACKENDS.XTRATUM_CONF.XM_HYPERVISOR                --
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.Namet; use Ocarina.Namet;
33

34
with Ocarina.ME_AADL;
35
with Ocarina.ME_AADL.AADL_Instances.Nodes;
36
with Ocarina.ME_AADL.AADL_Instances.Entities;
37

38
with Ocarina.Backends.Utils;
39
with Ocarina.Backends.XML_Tree.Nodes;
40
with Ocarina.Backends.XML_Tree.Nutils;
41

42
package body Ocarina.Backends.Xtratum_Conf.Xm_Hypervisor is
43

44
   use Ocarina.ME_AADL;
45
   use Ocarina.ME_AADL.AADL_Instances.Nodes;
46
   use Ocarina.ME_AADL.AADL_Instances.Entities;
47

48
   use Ocarina.Backends.Utils;
49
   use Ocarina.Backends.XML_Tree.Nutils;
50

51
   package XTN renames Ocarina.Backends.XML_Tree.Nodes;
52

53
   procedure Visit_Architecture_Instance (E : Node_Id);
54
   procedure Visit_Component_Instance (E : Node_Id);
55
   procedure Visit_System_Instance (E : Node_Id);
56
   procedure Visit_Processor_Instance (E : Node_Id);
57
   procedure Visit_Virtual_Processor_Instance (E : Node_Id);
58
   procedure Visit_Subcomponents_Of is new Visit_Subcomponents_Of_G (Visit);
59

60
   -----------
61
   -- Visit --
62
   -----------
63

64 1
   procedure Visit (E : Node_Id) is
65
   begin
66
      case Kind (E) is
67 1
         when K_Architecture_Instance =>
68 1
            Visit_Architecture_Instance (E);
69

70 1
         when K_Component_Instance =>
71 1
            Visit_Component_Instance (E);
72

73 0
         when others =>
74 0
            null;
75
      end case;
76 1
   end Visit;
77

78
   ---------------------------------
79
   -- Visit_Architecture_Instance --
80
   ---------------------------------
81

82 1
   procedure Visit_Architecture_Instance (E : Node_Id) is
83
   begin
84 1
      Visit (Root_System (E));
85 1
   end Visit_Architecture_Instance;
86

87
   ------------------------------
88
   -- Visit_Component_Instance --
89
   ------------------------------
90

91 1
   procedure Visit_Component_Instance (E : Node_Id) is
92 1
      Category : constant Component_Category := Get_Category_Of_Component (E);
93
   begin
94
      case Category is
95 1
         when CC_System =>
96 1
            Visit_System_Instance (E);
97

98 1
         when CC_Processor =>
99 1
            Visit_Processor_Instance (E);
100

101 1
         when CC_Virtual_Processor =>
102 1
            Visit_Virtual_Processor_Instance (E);
103

104 1
         when others =>
105 1
            null;
106 1
      end case;
107 1
   end Visit_Component_Instance;
108

109
   ---------------------------
110
   -- Visit_System_Instance --
111
   ---------------------------
112

113 1
   procedure Visit_System_Instance (E : Node_Id) is
114 1
      U : Node_Id;
115 1
      R : Node_Id;
116
   begin
117 1
      U := XTN.Unit (Backend_Node (Identifier (E)));
118 1
      R := XTN.Node (Backend_Node (Identifier (E)));
119

120 1
      Current_XML_Node := XTN.Root_Node (XTN.XML_File (U));
121

122 1
      Push_Entity (U);
123 1
      Push_Entity (R);
124

125 1
      Visit_Subcomponents_Of (E);
126

127 1
      Pop_Entity;
128 1
      Pop_Entity;
129 1
   end Visit_System_Instance;
130

131
   ------------------------------
132
   -- Visit_Processor_Instance --
133
   ------------------------------
134

135 1
   procedure Visit_Processor_Instance (E : Node_Id) is
136 1
      Xm_Hypervisor_Node : Node_Id;
137 1
      Memory_Area_Node   : Node_Id;
138 1
      P : Node_Id;
139 1
      Q : Node_Id;
140
   begin
141
      --  Create the main XMHypervisor node.
142

143 1
      Xm_Hypervisor_Node := Make_XML_Node ("XMHypervisor");
144

145 1
      Set_Str_To_Name_Buffer ("console");
146 1
      P := Make_Defining_Identifier (Name_Find);
147 1
      Set_Str_To_Name_Buffer ("Uart");
148 1
      Q := Make_Defining_Identifier (Name_Find);
149

150 1
      Append_Node_To_List
151 1
        (Make_Assignement (P, Q),
152 1
         XTN.Items (Xm_Hypervisor_Node));
153

154
      --  Create the PhysicalMemoryArea node associated
155
      --  to the XMHypervisor node.
156 1
      Memory_Area_Node := Make_XML_Node ("PhysicalMemoryArea");
157

158 1
      Append_Node_To_List
159
        (Memory_Area_Node,
160 1
         XTN.Subitems (Xm_Hypervisor_Node));
161

162 1
      Set_Str_To_Name_Buffer ("size");
163 1
      P := Make_Defining_Identifier (Name_Find);
164 1
      Set_Str_To_Name_Buffer ("512KB");
165 1
      Q := Make_Defining_Identifier (Name_Find);
166

167 1
      Append_Node_To_List
168 1
        (Make_Assignement (P, Q),
169 1
         XTN.Items (Memory_Area_Node));
170

171 1
      Append_Node_To_List
172
        (Xm_Hypervisor_Node,
173 1
         XTN.Subitems (Current_XML_Node));
174

175 1
      Visit_Subcomponents_Of (E);
176 1
   end Visit_Processor_Instance;
177

178
   --------------------------------------
179
   -- Visit_Virtual_Processor_Instance --
180
   --------------------------------------
181

182 1
   procedure Visit_Virtual_Processor_Instance (E : Node_Id) is
183
   begin
184 1
      Visit_Subcomponents_Of (E);
185 1
   end Visit_Virtual_Processor_Instance;
186

187
end Ocarina.Backends.Xtratum_Conf.Xm_Hypervisor;

Read our documentation on viewing source code .

Loading