ocarina-backends-properties-arinc653.adb 6.14 KB
Newer Older
1
2
3
4
5
6
7
8
------------------------------------------------------------------------------
--                                                                          --
--                           OCARINA COMPONENTS                             --
--                                                                          --
--                  OCARINA.BACKENDS.PROPERTIES.ARINC653                    --
--                                                                          --
--                                 B o d y                                  --
--                                                                          --
9
--                   Copyright (C) 2014-2015 ESA & ISAE.                    --
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
--                                                                          --
-- Ocarina  is free software;  you  can  redistribute  it and/or  modify    --
-- it under terms of the GNU General Public License as published by the     --
-- Free Software Foundation; either version 2, or (at your option) any      --
-- later version. Ocarina is distributed  in  the  hope  that it will be    --
-- useful, but WITHOUT ANY WARRANTY;  without even the implied warranty of  --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details. You should have received  a copy of the --
-- GNU General Public License distributed with Ocarina; see file COPYING.   --
-- If not, write to the Free Software Foundation, 51 Franklin Street, Fifth --
-- Floor, Boston, MA 02111-1301, USA.                                       --
--                                                                          --
-- As a special exception,  if other files  instantiate  generics from this --
-- unit, or you link  this unit with other files  to produce an executable, --
-- this  unit  does not  by itself cause  the resulting  executable to be   --
-- covered  by the  GNU  General  Public  License. This exception does not  --
-- however invalidate  any other reasons why the executable file might be   --
-- covered by the GNU Public License.                                       --
--                                                                          --
--                 Ocarina is maintained by the TASTE project               --
--                      (taste-users@lists.tuxfamily.org)                   --
--                                                                          --
------------------------------------------------------------------------------

with Ocarina.Namet; use Ocarina.Namet;
with Ocarina.Instances.Queries; use Ocarina.Instances.Queries;

with Ocarina.ME_AADL.AADL_Tree.Nutils;
with Ocarina.ME_AADL.AADL_Instances.Nutils;

with Ocarina.AADL_Values;
use Ocarina.AADL_Values;

with Ocarina.ME_AADL.AADL_Tree.Nodes;
use Ocarina.ME_AADL.AADL_Tree.Nodes;

package body Ocarina.Backends.Properties.ARINC653 is

   package ATNU renames Ocarina.ME_AADL.AADL_Tree.Nutils;
   package AINU renames Ocarina.ME_AADL.AADL_Instances.Nutils;

   Is_Initialized : Boolean := False;

   --  ARINC653::Schedule_Window
   --   Schedule_Window_Name : Name_Id;

   --  ARINC653::Schedule_Window associated anonymous record element term
   Partition_Name : Name_Id;
   Duration_Name : Name_Id;
   Periodic_Processing_Start_Name : Name_Id;

   --  ARINC653::Module_Schedule
   Module_Schedule_Name : Name_Id;

   procedure Init;

   ----------
   -- Init --
   ----------

   procedure Init is
   begin
--        Schedule_Window_Name := Get_String_Name
--          ("arinc::schedule_window");

      Module_Schedule_Name := Get_String_Name
        ("arinc653::module_schedule");

      Partition_Name := Get_String_Name ("partition");
      Duration_Name := Get_String_Name ("duration");
      Periodic_Processing_Start_Name
        := Get_String_Name ("periodic_processing_start");
      Is_Initialized := True;
   end Init;

   ----------------------------------
   -- Get_Module_Schedule_Property --
   ----------------------------------

   function Get_Module_Schedule_Property
     (E : Node_Id)
     return Schedule_Window_Record_Term_Array
   is
      pragma Assert (True or else
                     AINU.Is_Processor (E) or else
                       AINU.Is_Virtual_Processor (E));

      Property_Value : List_Id;

   begin
      if not Is_Initialized then
         Init;
      end if;

104
105
106
107
      if not Is_Defined_List_Property (E, Module_Schedule_Name) then
         return Empty_Schedule_Window_Record_Term_Array;
      end if;

108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
      Property_Value := Get_List_Property (E, Module_Schedule_Name);

      declare
         Result : Schedule_Window_Record_Term_Array
           (1 .. ATNU.Length (Property_Value));
         A : Node_Id := First_Node (Property_Value);
         J : Integer := Result'First;
      begin
         while Present (A) loop
            declare
               L : Node_Id := First_Node (List_Items (A));
               V : Ocarina.AADL_Values.Value_Type;

            begin
               while Present (L) loop
                  if Name (Identifier (L)) = Partition_Name then
124
                     --  Partition is a component reference
125
126

                     Result (J).Partition :=
127
128
                       Entity
                       (Reference_Term (Property_Expression (L)));
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161

                  elsif Name (Identifier (L)) = Duration_Name then
                     Result (J).Duration := Convert_Value_To_Time_Type
                       (Property_Expression (L));

                  elsif Name (Identifier (L))
                    = Periodic_Processing_Start_Name
                  then
                     --  Periodic_Processing_Start is an aadlboolean,
                     --  the corresponding Property_expression is thus
                     --  an AADL value

                     V := Get_Value_Type (Value (Property_Expression (L)));
                     Result (J).Periodic_Processing_Start := V.BVal;

                  else
                     raise Program_Error;
                  end if;

                  L := Next_Node (L);

               end loop;
            end;

            A := Next_Node (A);
            J := J + 1;
         end loop;

         return Result;
      end;
   end Get_Module_Schedule_Property;

end Ocarina.Backends.Properties.ARINC653;