Commit b7152d58 authored by Julien's avatar Julien

Start the VxWorks653 configuration backend

parent 1a096aae
This diff is collapsed.
package Ocarina.Backends.Vxworks653_Conf.Hm is
procedure Visit (E : Node_Id);
end Ocarina.Backends.Vxworks653_Conf.Hm;
This diff is collapsed.
with Ocarina.Backends.Properties; use Ocarina.Backends.Properties;
package Ocarina.Backends.Vxworks653_Conf.Mapping is
function Map_Distributed_Application (E : Node_Id) return Node_Id;
function Map_HI_Node (E : Node_Id) return Node_Id;
function Map_HI_Unit (E : Node_Id) return Node_Id;
function Map_Port (F : Node_Id) return Node_Id;
function Map_Data (E : Node_Id) return Node_Id;
function Map_Data_Access (E : Node_Id) return Node_Id;
function Map_Bus_Access (E : Node_Id) return Node_Id;
function Map_System (E : Node_Id) return Node_Id;
function Map_Process
(E : Node_Id;
Partition_Identifier : Unsigned_Long_Long) return Node_Id;
function Map_Data_Size (T : Size_Type) return Unsigned_Long_Long;
function Map_Virtual_Processor (E : Node_Id) return Node_Id;
function Map_Processor (E : Node_Id) return Node_Id;
function Map_Partition (Process : Node_Id;
Runtime : Node_Id;
Partition_Identifier : Integer;
Nb_Threads : Unsigned_Long_Long;
Nb_Buffers : Unsigned_Long_Long;
Nb_Events : Unsigned_Long_Long;
Nb_Lock_Objects : Unsigned_Long_Long;
Nb_Blackboards : Unsigned_Long_Long;
Blackboards_Size : Unsigned_Long_Long;
Buffers_Size : Unsigned_Long_Long)
return Node_Id;
function Map_Bus (E : Node_Id) return Node_Id;
function Map_Port_Connection (E : Node_Id) return Node_Id;
function Map_Process_Memory (Process : Node_Id) return Node_Id;
procedure Map_Process_Scheduling
(Process : Node_Id;
Window_Number : in out Unsigned_Long_Long;
N : out Node_Id);
function Map_Connection
(Connection : Node_Id;
Channel_Identifier : Unsigned_Long_Long) return Node_Id;
function Map_Process_HM_Table (Process : Node_Id) return Node_Id;
function Map_Processor_HM_Table (Processor : Node_Id) return Node_Id;
function Map_Sampling_Port (Port : Node_Id) return Node_Id;
function Map_Queuing_Port (Port : Node_Id) return Node_Id;
end Ocarina.Backends.Vxworks653_Conf.Mapping;
with Locations;
with Ocarina.ME_AADL;
with Ocarina.ME_AADL.AADL_Instances.Nodes;
with Ocarina.ME_AADL.AADL_Instances.Nutils;
with Ocarina.ME_AADL.AADL_Instances.Entities;
with Ocarina.Backends.Properties;
with Ocarina.Backends.XML_Tree.Nodes;
with Ocarina.Backends.XML_Tree.Nutils;
with Ocarina.Backends.Vxworks653_Conf.Mapping;
package body Ocarina.Backends.Vxworks653_Conf.Naming is
use Locations;
use Ocarina.ME_AADL;
use Ocarina.ME_AADL.AADL_Instances.Nodes;
use Ocarina.ME_AADL.AADL_Instances.Entities;
use Ocarina.Backends.XML_Tree.Nutils;
use Ocarina.Backends.Properties;
use Ocarina.Backends.Vxworks653_Conf.Mapping;
package AINU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes;
package XTN renames Ocarina.Backends.XML_Tree.Nodes;
package XTU renames Ocarina.Backends.XML_Tree.Nutils;
procedure Visit_Component (E : Node_Id);
procedure Visit_System (E : Node_Id);
procedure Visit_Process (E : Node_Id);
procedure Visit_Processor (E : Node_Id);
procedure Visit_Virtual_Processor (E : Node_Id);
procedure Add_Applications
(AADL_Processor : Node_Id; XML_Node : Node_Id);
procedure Add_Shared_Data_Regions
(AADL_Processor : Node_Id; XML_Node : Node_Id);
procedure Add_Shared_Library_Regions
(AADL_Processor : Node_Id; XML_Node : Node_Id);
-----------
-- Visit --
-----------
procedure Visit (E : Node_Id) is
begin
case Kind (E) is
when K_Architecture_Instance =>
Visit (Root_System (E));
when K_Component_Instance =>
Visit_Component (E);
when others =>
null;
end case;
end Visit;
---------------------
-- Visit_Component --
---------------------
procedure Visit_Component (E : Node_Id) is
Category : constant Component_Category :=
Get_Category_Of_Component (E);
begin
case Category is
when CC_System =>
Visit_System (E);
when CC_Process =>
Visit_Process (E);
when CC_Device =>
Visit_Process (E);
when CC_Processor =>
Visit_Processor (E);
when CC_Virtual_Processor =>
Visit_Virtual_Processor (E);
when others =>
null;
end case;
end Visit_Component;
-------------------
-- Visit_Process --
-------------------
procedure Visit_Process (E : Node_Id) is
N : Node_Id;
Processes_List : List_Id;
begin
Processes_List :=
XTN.Processes (Backend_Node (Identifier (Get_Bound_Processor (E))));
N := XTU.Make_Container (E);
XTU.Append_Node_To_List (N, Processes_List);
end Visit_Process;
--------------------------------------
-- Visit_Virtual_Processor_Instance --
--------------------------------------
procedure Visit_Virtual_Processor (E : Node_Id) is
Processes : List_Id;
N : Node_Id;
begin
N := New_Node (XTN.K_HI_Tree_Bindings);
AIN.Set_Backend_Node (Identifier (E), N);
Processes := XTU.New_List (XTN.K_List_Id);
XTN.Set_Processes (N, Processes);
end Visit_Virtual_Processor;
---------------------
-- Visit_Processor --
---------------------
procedure Visit_Processor (E : Node_Id) is
S : Node_Id;
P : Node_Id;
U : Node_Id;
N : Node_Id;
Processes : List_Id;
begin
P := Map_HI_Node (E);
Push_Entity (P);
U := Map_HI_Unit (E);
Push_Entity (U);
if not AINU.Is_Empty (Subcomponents (E)) then
S := First_Node (Subcomponents (E));
while Present (S) loop
-- Visit the component instance corresponding to the
-- subcomponent S.
Visit (Corresponding_Instance (S));
S := Next_Node (S);
end loop;
end if;
N := New_Node (XTN.K_HI_Tree_Bindings);
Processes := AINU.New_List (K_Node_Id, No_Location);
XTN.Set_Processes (N, Processes);
XTN.Set_Unit (N, U);
XTN.Set_Node (N, P);
AIN.Set_Backend_Node (Identifier (E), N);
Add_Applications (E, XTN.Root_Node (XTN.XML_File (U)));
Add_Shared_Data_Regions (E, XTN.Root_Node (XTN.XML_File (U)));
Add_Shared_Library_Regions (E, XTN.Root_Node (XTN.XML_File (U)));
Pop_Entity;
Pop_Entity;
end Visit_Processor;
------------------
-- Visit_System --
------------------
procedure Visit_System (E : Node_Id) is
S : Node_Id;
Component_Instance : Node_Id;
begin
if not AINU.Is_Empty (Subcomponents (E)) then
S := First_Node (Subcomponents (E));
while Present (S) loop
Component_Instance := Corresponding_Instance (S);
if Get_Category_Of_Component (Component_Instance) =
CC_Processor
then
Visit_Processor (Component_Instance);
end if;
S := Next_Node (S);
end loop;
end if;
if not AINU.Is_Empty (Subcomponents (E)) then
S := First_Node (Subcomponents (E));
while Present (S) loop
-- Visit the component instance corresponding to the
-- subcomponent S.
if AINU.Is_Process_Or_Device (Corresponding_Instance (S)) then
Visit_Process (Corresponding_Instance (S));
end if;
S := Next_Node (S);
end loop;
end if;
end Visit_System;
procedure Add_Applications
(AADL_Processor : Node_Id; XML_Node : Node_Id) is
pragma Unreferenced (AADL_Processor);
Applications_Node : Node_Id;
Application_Node : Node_Id;
Application_Description_Node : Node_Id;
Memory_Size_Node : Node_Id;
Ports_Node : Node_Id;
begin
-- Applications Node first
Applications_Node := Make_XML_Node ("Applications");
Append_Node_To_List (Applications_Node, XTN.Subitems (XML_Node));
-- Application Node that is the child of Applications
Application_Node := Make_XML_Node ("Application");
XTU.Add_Attribute ("Name", "bla", Application_Node);
Append_Node_To_List (Application_Node,
XTN.Subitems (Applications_Node));
-- Application Description with MemorySize and Ports nodes
Application_Description_Node :=
Make_XML_Node ("ApplicationDescription");
Append_Node_To_List (Application_Description_Node,
XTN.Subitems (Application_Node));
Memory_Size_Node := Make_XML_Node ("MemorySize");
Append_Node_To_List (Memory_Size_Node,
XTN.Subitems (Application_Description_Node));
XTU.Add_Attribute ("MemorySizeBss", "0x10000", Memory_Size_Node);
XTU.Add_Attribute ("MemorySizeText", "0x10000", Memory_Size_Node);
XTU.Add_Attribute ("MemorySizeData", "0x10000", Memory_Size_Node);
XTU.Add_Attribute ("MemorySizeRoData", "0x10000", Memory_Size_Node);
XTU.Add_Attribute ("MemorySizePersistent", "0x10000", Memory_Size_Node);
XTU.Add_Attribute ("MemorySizePersistentBss",
"0x10000", Memory_Size_Node);
Ports_Node := Make_XML_Node ("Ports");
Append_Node_To_List (Ports_Node,
XTN.Subitems (Application_Description_Node));
end Add_Applications;
procedure Add_Shared_Data_Regions
(AADL_Processor : Node_Id; XML_Node : Node_Id) is
pragma Unreferenced (AADL_Processor);
Shared_Data_Node : Node_Id;
begin
Shared_Data_Node := Make_XML_Node ("SharedDataRegions");
Append_Node_To_List (Shared_Data_Node, XTN.Subitems (XML_Node));
end Add_Shared_Data_Regions;
procedure Add_Shared_Library_Regions
(AADL_Processor : Node_Id; XML_Node : Node_Id) is
pragma Unreferenced (AADL_Processor);
Shared_Library_Node : Node_Id;
begin
Shared_Library_Node := Make_XML_Node ("SharedLibraryRegions");
Append_Node_To_List (Shared_Library_Node, XTN.Subitems (XML_Node));
end Add_Shared_Library_Regions;
end Ocarina.Backends.Vxworks653_Conf.Naming;
package Ocarina.Backends.Vxworks653_Conf.Naming is
procedure Visit (E : Node_Id);
end Ocarina.Backends.Vxworks653_Conf.Naming;
This diff is collapsed.
package Ocarina.Backends.Vxworks653_Conf.Partitions is
procedure Visit (E : Node_Id);
end Ocarina.Backends.Vxworks653_Conf.Partitions;
-- with Locations;
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ocarina.Namet; use Ocarina.Namet;
with Ocarina.ME_AADL;
with Ocarina.ME_AADL.AADL_Instances.Nodes;
with Ocarina.ME_AADL.AADL_Instances.Nutils;
with Ocarina.ME_AADL.AADL_Instances.Entities;
with Ocarina.Instances.Queries;
with Ocarina.Backends.Properties.ARINC653;
-- with Ocarina.Backends.Properties;
with Ocarina.Backends.Utils;
with Ocarina.Backends.XML_Tree.Nodes;
with Ocarina.Backends.XML_Tree.Nutils;
-- with Ocarina.Backends.Vxworks653_Conf.Mapping;
package body Ocarina.Backends.Vxworks653_Conf.Schedule is
-- use Locations;
use Ocarina.ME_AADL;
use Ocarina.Instances.Queries;
use Ocarina.ME_AADL.AADL_Instances.Nodes;
use Ocarina.ME_AADL.AADL_Instances.Entities;
use Ocarina.Backends.XML_Tree.Nutils;
use Ocarina.Backends.Utils;
use Ocarina.Backends.Properties.ARINC653;
-- use Ocarina.Backends.Properties;
-- use Ocarina.Backends.Vxworks653_Conf.Mapping;
package AINU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
package XTN renames Ocarina.Backends.XML_Tree.Nodes;
package XTU renames Ocarina.Backends.XML_Tree.Nutils;
Root_Node : Node_Id := No_Node;
Schedule_Node : Node_Id := No_Node;
procedure Visit_Architecture_Instance (E : Node_Id);
procedure Visit_Component_Instance (E : Node_Id);
procedure Visit_System_Instance (E : Node_Id);
procedure Visit_Process_Instance (E : Node_Id);
procedure Visit_Processor_Instance (E : Node_Id);
procedure Visit_Bus_Instance (E : Node_Id);
procedure Visit_Virtual_Processor_Instance (E : Node_Id);
procedure Fill_Scheduling_Slots (Processor : Node_Id);
-----------
-- Visit --
-----------
procedure Visit (E : Node_Id) is
begin
case Kind (E) is
when K_Architecture_Instance =>
Visit_Architecture_Instance (E);
when K_Component_Instance =>
Visit_Component_Instance (E);
when others =>
null;
end case;
end Visit;
---------------------------------
-- Visit_Architecture_Instance --
---------------------------------
procedure Visit_Architecture_Instance (E : Node_Id) is
begin
Root_Node := Root_System (E);
Visit (Root_Node);
end Visit_Architecture_Instance;
------------------------------
-- Visit_Component_Instance --
------------------------------
procedure Visit_Component_Instance (E : Node_Id) is
Category : constant Component_Category := Get_Category_Of_Component (E);
begin
case Category is
when CC_System =>
Visit_System_Instance (E);
when CC_Process =>
Visit_Process_Instance (E);
when CC_Processor =>
Visit_Processor_Instance (E);
when CC_Bus =>
Visit_Bus_Instance (E);
when CC_Virtual_Processor =>
Visit_Virtual_Processor_Instance (E);
when others =>
null;
end case;
end Visit_Component_Instance;
----------------------------
-- Visit_Process_Instance --
----------------------------
procedure Visit_Process_Instance (E : Node_Id) is
S : Node_Id;
begin
if not AINU.Is_Empty (Subcomponents (E)) then
S := First_Node (Subcomponents (E));
while Present (S) loop
-- Visit the component instance corresponding to the
-- subcomponent S.
Visit (Corresponding_Instance (S));
S := Next_Node (S);
end loop;
end if;
end Visit_Process_Instance;
---------------------------
-- Visit_System_Instance --
---------------------------
procedure Visit_System_Instance (E : Node_Id) is
S : Node_Id;
begin
if not AINU.Is_Empty (Subcomponents (E)) then
S := First_Node (Subcomponents (E));
while Present (S) loop
-- Visit the component instance corresponding to the
-- subcomponent S.
if AINU.Is_Processor (Corresponding_Instance (S)) then
Visit (Corresponding_Instance (S));
end if;
S := Next_Node (S);
end loop;
end if;
end Visit_System_Instance;
------------------------
-- Visit_Bus_Instance --
------------------------
procedure Visit_Bus_Instance (E : Node_Id) is
pragma Unreferenced (E);
begin
null;
end Visit_Bus_Instance;
---------------------------
-- Fill_Scheduling_Slots --
---------------------------
procedure Fill_Scheduling_Slots (Processor : Node_Id) is
Time_Window_Node : Node_Id;
Module_Schedule : constant Schedule_Window_Record_Term_Array
:= Get_Module_Schedule_Property (Processor);
Offset : Unsigned_Long_Long;
Slot_Duration : Unsigned_Long_Long;
begin
Offset := 0;
for J in Module_Schedule'Range loop
Time_Window_Node := Make_XML_Node ("PartitionTimeWindow");
Append_Node_To_List
(Time_Window_Node,
XTN.Subitems (Schedule_Node));
-- XTU.Add_Attribute ("Duration", "6000000", Time_Window_Node);
--
-- For now, we assume the partition duration
-- is in milliseconds.
--
Slot_Duration := To_Milliseconds
(Module_Schedule (J).Duration) * 1_000_000;
XTU.Add_Attribute ("Duration",
Trim (Unsigned_Long_Long'Image
(Slot_Duration), Left),
Time_Window_Node);
XTU.Add_Attribute ("Offset",
Trim (Unsigned_Long_Long'Image
(Offset), Left),
Time_Window_Node);
XTU.Add_Attribute ("PeriodicProcessingStart",
"true", Time_Window_Node);
XTU.Add_Attribute ("RepeatWindowAtNanosecondInterval",
"PartitionPeriod", Time_Window_Node);
XTU.Add_Attribute ("InhibitEarlyCompletion",
"false", Time_Window_Node);
XTU.Add_Attribute ("PartitionNameRef",
Get_Name_String
(Module_Schedule (J).Partition),
Time_Window_Node);
Offset := Offset + Slot_Duration;
end loop;
end Fill_Scheduling_Slots;
------------------------------
-- Visit_Processor_Instance --
------------------------------
procedure Visit_Processor_Instance (E : Node_Id) is
S : Node_Id;
U : Node_Id;
P : Node_Id;
begin
U := XTN.Unit (Backend_Node (Identifier (E)));
P := XTN.Node (Backend_Node (Identifier (E)));
Push_Entity (P);
Push_Entity (U);
Current_XML_Node := XTN.Root_Node (XTN.XML_File (U));
Schedule_Node := Make_XML_Node ("Schedule");
XTU.Add_Attribute ("MajorFrameLength",
"Automatic", Schedule_Node);
Append_Node_To_List
(Schedule_Node,
XTN.Subitems (Current_XML_Node));
if Is_Defined_Property (E, "arinc653::module_schedule") then
Fill_Scheduling_Slots (E);
end if;
if not AINU.Is_Empty (Subcomponents (E)) then
S := First_Node (Subcomponents (E));
while Present (S) loop
-- Visit the component instance corresponding to the
-- subcomponent S.
if AINU.Is_Virtual_Processor (Corresponding_Instance (S)) then
Visit (Corresponding_Instance (S));
end if;
S := Next_Node (S);
end loop;
end if;
Pop_Entity;
Pop_Entity;
end Visit_Processor_Instance;
--------------------------------------
-- Visit_Virtual_Processor_Instance --
--------------------------------------
procedure Visit_Virtual_Processor_Instance (E : Node_Id) is
pragma Unreferenced (E);
begin
null;
end Visit_Virtual_Processor_Instance;
end Ocarina.Backends.Vxworks653_Conf.Schedule;
package Ocarina.Backends.Vxworks653_Conf.Schedule is
procedure Visit (E : Node_Id);
end Ocarina.Backends.Vxworks653_Conf.Schedule;
with Ocarina.Instances;
with Ocarina.Backends.Messages;
with Ocarina.Backends.Expander;
with Ocarina.Backends.XML_Tree.Nodes;
with Ocarina.Backends.XML_Tree.Nutils;
with Ocarina.Backends.XML_Tree.Generator;
with Ocarina.Backends.Vxworks653_Conf.HM;
with Ocarina.Backends.VxWorks653_Conf.Schedule;
with Ocarina.Backends.VxWorks653_Conf.Naming;
with Ocarina.Backends.Vxworks653_Conf.Partitions;
with Ocarina.Backends.Utils;
with GNAT.Command_Line; use GNAT.Command_Line;
with Ocarina.Namet; use Ocarina.Namet;
package body Ocarina.Backends.Vxworks653_Conf is
use Ocarina.Instances;
use Ocarina.Backends.Expander;
use Ocarina.Backends.Messages;
use Ocarina.Backends.XML_Tree.Generator;
use Ocarina.Backends.Vxworks653_Conf.Naming;
use Ocarina.Backends.Vxworks653_Conf.Partitions;
use Ocarina.Backends.Utils;
package XTN renames Ocarina.Backends.XML_Tree.Nodes;
package XTU renames Ocarina.Backends.XML_Tree.Nutils;
Remove_Generated_Sources : Boolean := False;
Generated_Sources_Directory : Name_Id := No_Name;
--------------
-- Generate --
--------------
procedure Generate (AADL_Root : Node_Id) is
Instance_Root : Node_Id;
begin