Commit 40075cae authored by Julien's avatar Julien
Browse files

First start of the DeOS configuration generator

parent c601a5f2
This diff is collapsed.
with Ocarina.Backends.Properties; use Ocarina.Backends.Properties;
package Ocarina.Backends.Deos_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_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_System_HM_Table (System : Node_Id) return Node_Id;
end Ocarina.Backends.Deos_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.Deos_Conf.Mapping;
package body Ocarina.Backends.Deos_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.Deos_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);
-----------
-- 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);
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;
end Ocarina.Backends.Deos_Conf.Naming;
package Ocarina.Backends.Deos_Conf.Naming is
procedure Visit (E : Node_Id);
end Ocarina.Backends.Deos_Conf.Naming;
-- 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.Deos_Conf.Mapping;
package body Ocarina.Backends.Deos_Conf.Partitions 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.Deos_Conf.Mapping;
package AINU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
package XTN renames Ocarina.Backends.XML_Tree.Nodes;
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);
-----------
-- 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
Visit (Root_System (E));
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;
------------------------------
-- 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));
Append_Node_To_List
(Map_System_HM_Table (E),
XTN.Subitems (Current_XML_Node));
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;
Pop_Entity;
Pop_Entity;
end Visit_Processor_Instance;
--------------------------------------
-- Visit_Virtual_Processor_Instance --
--------------------------------------
procedure Visit_Virtual_Processor_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_Virtual_Processor_Instance;
end Ocarina.Backends.Deos_Conf.Partitions;
package Ocarina.Backends.Deos_Conf.Partitions is
procedure Visit (E : Node_Id);
end Ocarina.Backends.Deos_Conf.Partitions;
......@@ -37,6 +37,8 @@ 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.Deos_Conf.Naming;
with Ocarina.Backends.Deos_Conf.Partitions;
with Ocarina.Backends.Utils;
with GNAT.Command_Line; use GNAT.Command_Line;
......@@ -49,6 +51,8 @@ package body Ocarina.Backends.Deos_Conf is
use Ocarina.Backends.Expander;
use Ocarina.Backends.Messages;
use Ocarina.Backends.XML_Tree.Generator;
use Ocarina.Backends.Deos_Conf.Naming;
use Ocarina.Backends.Deos_Conf.Partitions;
use Ocarina.Backends.Utils;
package XTN renames Ocarina.Backends.XML_Tree.Nodes;
......@@ -126,7 +130,7 @@ package body Ocarina.Backends.Deos_Conf is
end case;
end loop;
Register_Backend ("Deos_Conf", Generate'Access, Statistics);
Register_Backend ("Deos_Conf", Generate'Access, Deos_XML);
end Init;
-----------
......@@ -143,7 +147,6 @@ package body Ocarina.Backends.Deos_Conf is
---------------------------------
procedure Visit_Architecture_Instance (E : Node_Id) is
pragma Unreferenced (E);
begin
XML_Root := XTU.New_Node (XTN.K_HI_Distributed_Application);
Set_Str_To_Name_Buffer ("generated-code");
......@@ -153,6 +156,9 @@ package body Ocarina.Backends.Deos_Conf is
XTU.Push_Entity (XML_Root);
Deos_Conf.Naming.Visit (E);
Deos_Conf.Partitions.Visit (E);
XTU.Pop_Entity;
end Visit_Architecture_Instance;
......
......@@ -651,4 +651,19 @@ package body Ocarina.Backends.XML_Tree.Nutils is
return N;
end Make_Container;
-------------------
-- Add_Attribute --
-------------------
procedure Add_Attribute (Key : String; Value : String; N : Node_Id) is
R : Node_Id;
Q : Node_Id;
begin
Set_Str_To_Name_Buffer (Key);
R := Make_Defining_Identifier (Name_Find);
Set_Str_To_Name_Buffer (Value);
Q := Make_Defining_Identifier (Name_Find);
Append_Node_To_List (Make_Assignement (R, Q), XTN.Items (N));
end Add_Attribute;
end Ocarina.Backends.XML_Tree.Nutils;
......@@ -185,4 +185,6 @@ Tok_Slash, -- /
function Make_Assignement (Left : Node_Id; Right : Node_Id) return Node_Id;
procedure Add_Attribute (Key : String; Value : String; N : Node_Id);
end Ocarina.Backends.XML_Tree.Nutils;
......@@ -58,6 +58,7 @@ package Ocarina.Backends is
Bound_T,
Carts_XML,
Cheddar_XML,
Deos_XML,
Connection_Matrix_Analysis,
Functions_Matrix_Analysis,
MAST_Scheduling,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment