Commit 08c54117 authored by julien.delange's avatar julien.delange

* ocarina/src/core/common_files/utils.adb

   ocarina/src/core/common_files/utils.ads
   - Add Remove_Char function

 * ocarina/src/backends/ocarina-backends-xtratum_conf-mapping.adb
   ocarina/src/backends/ocarina-backends-xtratum_conf-partition_table.adb
   ocarina/src/backends/ocarina-backends-xtratum_conf-hardware_description.adb
   ocarina/src/backends/ocarina-backends-xtratum_conf-channels.adb
   - Fix all bugs and other glitches so that the file can now be processed
     by Xtratum specific parsing tools.



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/ocarina@2184 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 25d0cc6f
......@@ -31,6 +31,7 @@
-- --
------------------------------------------------------------------------------
with Utils; use Utils;
with Namet; use Namet;
with Ocarina.ME_AADL;
with Ocarina.ME_AADL.AADL_Instances.Nodes;
......@@ -152,6 +153,7 @@ package body Ocarina.Backends.Xtratum_Conf.Channels is
Destination_Partition : Node_Id;
Source_Partition : Node_Id;
Source_Port : Node_Id;
Associated_Data_Size : Unsigned_Long_Long;
Destination_Port : Node_Id;
Channels_Node : Node_Id;
Channel_Node : Node_Id;
......@@ -220,7 +222,7 @@ package body Ocarina.Backends.Xtratum_Conf.Channels is
if not Is_Event (Source_Port) then
Channel_Node := Make_XML_Node ("SamplingChannel");
else
Channel_Node := Make_XML_Node ("QueueingChannel");
Channel_Node := Make_XML_Node ("QueuingChannel");
Set_Str_To_Name_Buffer ("maxNoMessages");
P := Make_Defining_Identifier (Name_Find);
Get_Name_String (Source_Port_Name);
......@@ -247,15 +249,18 @@ package body Ocarina.Backends.Xtratum_Conf.Channels is
if Get_Data_Size (Corresponding_Instance
(Source_Port)) /= Null_Size then
Q := Make_Literal
(XV.New_Numeric_Value
(To_Bytes
(Get_Data_Size
(Corresponding_Instance (Source_Port))), 1, 10));
Associated_Data_Size :=
To_Bytes (Get_Data_Size
(Corresponding_Instance (Source_Port)));
else
Q := Make_Literal (XV.New_Numeric_Value (1, 1, 10));
Associated_Data_Size := 1;
end if;
Set_Str_To_Name_Buffer
(Unsigned_Long_Long'Image (Associated_Data_Size));
Add_Str_To_Name_Buffer ("B");
Q := Make_Defining_Identifier (Remove_Char (Name_Find, ' '));
Append_Node_To_List
(Make_Assignement (P, Q), XTN.Items (Channel_Node));
......
......@@ -32,6 +32,7 @@
------------------------------------------------------------------------------
with Namet; use Namet;
with Utils; use Utils;
with Ocarina.ME_AADL;
with Ocarina.ME_AADL.AADL_Tree.Nodes;
......@@ -154,6 +155,7 @@ package body Ocarina.Backends.Xtratum_Conf.Hardware_Description is
Hw_Desc_Node : Node_Id;
Processor_Node : Node_Id;
Memory_Node : Node_Id;
Device_Node : Node_Id;
U : Node_Id;
R : Node_Id;
begin
......@@ -214,6 +216,44 @@ package body Ocarina.Backends.Xtratum_Conf.Hardware_Description is
end loop;
end if;
Device_Node := Make_XML_Node ("Devices");
-- Automatically add an UART device for debugging purposes.
declare
Uart_Node : Node_Id;
P : Node_Id;
Q : Node_Id;
begin
Uart_Node := Make_XML_Node ("Uart");
Set_Str_To_Name_Buffer ("id");
P := Make_Defining_Identifier (Name_Find);
Set_Str_To_Name_Buffer ("0");
Q := Make_Defining_Identifier (Name_Find);
Append_Node_To_List
(Make_Assignement (P, Q), XTN.Items (Uart_Node));
Set_Str_To_Name_Buffer ("baudRate");
P := Make_Defining_Identifier (Name_Find);
Set_Str_To_Name_Buffer ("115200");
Q := Make_Defining_Identifier (Name_Find);
Append_Node_To_List
(Make_Assignement (P, Q), XTN.Items (Uart_Node));
Set_Str_To_Name_Buffer ("name");
P := Make_Defining_Identifier (Name_Find);
Set_Str_To_Name_Buffer ("Uart");
Q := Make_Defining_Identifier (Name_Find);
Append_Node_To_List
(Make_Assignement (P, Q), XTN.Items (Uart_Node));
Append_Node_To_List (Uart_Node,
XTN.Subitems (Device_Node));
end;
Append_Node_To_List (Device_Node,
XTN.Subitems (Hw_Desc_Node));
Pop_Entity;
Pop_Entity;
end Visit_System_Instance;
......@@ -288,7 +328,7 @@ package body Ocarina.Backends.Xtratum_Conf.Hardware_Description is
(Unsigned_Long_Long'Image
(To_Milliseconds (Get_POK_Major_Frame (E))));
Add_Str_To_Name_Buffer ("ms");
Q := Make_Defining_Identifier (Name_Find);
Q := Make_Defining_Identifier (Remove_Char (Name_Find, ' '));
Append_Node_To_List
(Make_Assignement (P, Q), XTN.Items (Plan_Node));
......@@ -329,7 +369,7 @@ package body Ocarina.Backends.Xtratum_Conf.Hardware_Description is
(Unsigned_Long_Long'Image
(To_Milliseconds (Slots (I))));
Add_Str_To_Name_Buffer ("ms");
Q := Make_Defining_Identifier (Name_Find);
Q := Make_Defining_Identifier (Remove_Char (Name_Find, ' '));
Append_Node_To_List
(Make_Assignement (P, Q), XTN.Items (Slot_Node));
......@@ -339,7 +379,7 @@ package body Ocarina.Backends.Xtratum_Conf.Hardware_Description is
Set_Str_To_Name_Buffer
(Unsigned_Long_Long'Image (Start_Time));
Add_Str_To_Name_Buffer ("ms");
Q := Make_Defining_Identifier (Name_Find);
Q := Make_Defining_Identifier (Remove_Char (Name_Find, ' '));
Append_Node_To_List
(Make_Assignement (P, Q), XTN.Items (Slot_Node));
......@@ -392,28 +432,35 @@ package body Ocarina.Backends.Xtratum_Conf.Hardware_Description is
---------------------------
procedure Visit_Memory_Instance (E : Node_Id) is
P : Node_Id;
Q : Node_Id;
Memory_Node : Node_Id;
P : Node_Id;
Q : Node_Id;
Memory_Node : Node_Id;
Base_Address_Value : Unsigned_Long_Long;
Byte_Count_Value : Unsigned_Long_Long;
begin
Memory_Node := Make_XML_Node ("Region");
-- Add the start attribute of the region node.
Base_Address_Value := Get_Integer_Property (E, "base_address");
Set_Str_To_Name_Buffer ("start");
P := Make_Defining_Identifier (Name_Find);
Q := Make_Literal
(XV.New_Numeric_Value
(Get_Integer_Property (E, "base_address"), 0, 10));
Set_Str_To_Name_Buffer ("0x");
Add_Str_To_Name_Buffer
(Unsigned_Long_Long'Image (Base_Address_Value));
Q := Make_Defining_Identifier (Remove_Char (Name_Find, ' '));
Append_Node_To_List
(Make_Assignement (P, Q), XTN.Items (Memory_Node));
-- Add the size attribute of the region node.
Byte_Count_Value := Get_Integer_Property (E, "byte_count");
Set_Str_To_Name_Buffer ("size");
P := Make_Defining_Identifier (Name_Find);
Q := Make_Literal
(XV.New_Numeric_Value
(Get_Integer_Property (E, "byte_count"), 0, 10));
Set_Str_To_Name_Buffer
(Unsigned_Long_Long'Image (Byte_Count_Value));
Add_Str_To_Name_Buffer ("B");
Q := Make_Defining_Identifier (Remove_Char (Name_Find, ' '));
Append_Node_To_List
(Make_Assignement (P, Q), XTN.Items (Memory_Node));
......
......@@ -175,7 +175,7 @@ package body Ocarina.Backends.Xtratum_Conf.Mapping is
Set_Str_To_Name_Buffer ("xmlns");
R := Make_Defining_Identifier (Name_Find);
Set_Str_To_Name_Buffer ("http://www.xtratum.org/xm-3.X");
Set_Str_To_Name_Buffer ("http://www.xtratum.org/xm-3.x");
Q := Make_Defining_Identifier (Name_Find);
Append_Node_To_List (Make_Assignement (R, Q), XTN.Items (Root));
......
......@@ -32,6 +32,7 @@
------------------------------------------------------------------------------
with Namet; use Namet;
with Utils; use Utils;
with Ocarina.ME_AADL;
with Ocarina.ME_AADL.AADL_Tree.Nodes;
......@@ -45,7 +46,6 @@ with Ocarina.Instances.Queries;
with Ocarina.Backends.Messages;
with Ocarina.Backends.Properties;
with Ocarina.Backends.XML_Values;
with Ocarina.Backends.XML_Tree.Nodes;
with Ocarina.Backends.XML_Tree.Nutils;
......@@ -60,7 +60,6 @@ package body Ocarina.Backends.Xtratum_Conf.Partition_Table is
use Ocarina.Backends.Utils;
use Ocarina.Backends.Messages;
use Ocarina.Backends.Properties;
use Ocarina.Backends.XML_Values;
use Ocarina.Backends.XML_Tree.Nutils;
package ATN renames Ocarina.ME_AADL.AADL_Tree.Nodes;
......@@ -68,7 +67,6 @@ package body Ocarina.Backends.Xtratum_Conf.Partition_Table is
package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes;
package AINU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
package XTN renames Ocarina.Backends.XML_Tree.Nodes;
package XV renames Ocarina.Backends.XML_Values;
procedure Visit_Architecture_Instance (E : Node_Id);
procedure Visit_Component_Instance (E : Node_Id);
......@@ -78,6 +76,8 @@ package body Ocarina.Backends.Xtratum_Conf.Partition_Table is
procedure Visit_Processor_Instance (E : Node_Id);
procedure Visit_Virtual_Processor_Instance (E : Node_Id);
Current_System : Node_Id := No_Node;
-----------
-- Visit --
-----------
......@@ -140,6 +140,8 @@ package body Ocarina.Backends.Xtratum_Conf.Partition_Table is
procedure Visit_Process_Instance (E : Node_Id) is
Partition_Node : Node_Id;
Base_Address_Value : Unsigned_Long_Long;
Byte_Count_Value : Unsigned_Long_Long;
Associated_Processor : Node_Id;
Associated_Module : Node_Id;
Associated_Memory : Node_Id;
......@@ -188,7 +190,7 @@ package body Ocarina.Backends.Xtratum_Conf.Partition_Table is
Partition_Node := Make_XML_Node ("Partition");
Set_Str_To_Name_Buffer ("partitionId");
Set_Str_To_Name_Buffer ("id");
P := Make_Defining_Identifier (Name_Find);
Q := Copy_Node (Backend_Node (Identifier (Associated_Processor)));
Append_Node_To_List
......@@ -221,22 +223,27 @@ package body Ocarina.Backends.Xtratum_Conf.Partition_Table is
Area_Node := Make_XML_Node ("Area");
Base_Address_Value :=
Get_Integer_Property (Associated_Memory, "base_address");
Byte_Count_Value :=
Get_Integer_Property (Associated_Memory, "byte_count");
Set_Str_To_Name_Buffer ("start");
P := Make_Defining_Identifier (Name_Find);
Q := Make_Literal
(XV.New_Numeric_Value
(Get_Integer_Property
(Associated_Memory, "base_address"), 0, 10));
Set_Str_To_Name_Buffer ("0x");
Add_Str_To_Name_Buffer
(Unsigned_Long_Long'Image (Base_Address_Value));
Q := Make_Defining_Identifier (Remove_Char (Name_Find, ' '));
Append_Node_To_List
(Make_Assignement (P, Q), XTN.Items (Area_Node));
Set_Str_To_Name_Buffer ("size");
P := Make_Defining_Identifier (Name_Find);
Q := Make_Literal
(XV.New_Numeric_Value
(Get_Integer_Property
(Associated_Memory, "byte_count"), 0, 10));
Set_Str_To_Name_Buffer
(Unsigned_Long_Long'Image (Byte_Count_Value));
Add_Str_To_Name_Buffer ("B");
Q := Make_Defining_Identifier (Remove_Char (Name_Find, ' '));
Append_Node_To_List
(Make_Assignement (P, Q), XTN.Items (Area_Node));
......@@ -256,6 +263,9 @@ package body Ocarina.Backends.Xtratum_Conf.Partition_Table is
Slots_Allocation : constant List_Id
:= Get_POK_Slots_Allocation (Associated_Module);
Duration : Unsigned_Long_Long := 0;
Major_Frame : constant Unsigned_Long_Long
:= To_Milliseconds
(Get_POK_Major_Frame (Associated_Module));
Part : Node_Id;
begin
S := ATN.First_Node (Slots_Allocation);
......@@ -271,19 +281,20 @@ package body Ocarina.Backends.Xtratum_Conf.Partition_Table is
end loop;
Set_Str_To_Name_Buffer ("duration");
P := Make_Defining_Identifier (Name_Find);
Q := Make_Literal
(XV.New_Numeric_Value
(Duration, 0, 10));
Set_Str_To_Name_Buffer
(Unsigned_Long_Long'Image (Duration));
Add_Str_To_Name_Buffer ("ms");
Q := Make_Defining_Identifier (Remove_Char (Name_Find, ' '));
Append_Node_To_List
(Make_Assignement (P, Q), XTN.Items (Temporal_Req_Node));
Set_Str_To_Name_Buffer ("period");
P := Make_Defining_Identifier (Name_Find);
Q := Make_Literal
(XV.New_Numeric_Value
(To_Milliseconds
(Get_POK_Major_Frame (Associated_Module)), 0, 10));
Set_Str_To_Name_Buffer
(Unsigned_Long_Long'Image (Major_Frame));
Add_Str_To_Name_Buffer ("ms");
Q := Make_Defining_Identifier (Remove_Char (Name_Find, ' '));
Append_Node_To_List
(Make_Assignement (P, Q), XTN.Items (Temporal_Req_Node));
......@@ -321,7 +332,7 @@ package body Ocarina.Backends.Xtratum_Conf.Partition_Table is
P := Make_Defining_Identifier (Name_Find);
Get_Name_String (Display_Name (Identifier (F)));
Q := Make_Defining_Identifier (Name_Find);
Q := Make_Defining_Identifier (To_Lower (Name_Find));
Append_Node_To_List
(Make_Assignement (P, Q), XTN.Items (Port_Node));
......@@ -331,7 +342,7 @@ package body Ocarina.Backends.Xtratum_Conf.Partition_Table is
if Is_Data (F) and then not Is_Event (F) then
Set_Str_To_Name_Buffer ("sampling");
else
Set_Str_To_Name_Buffer ("queueing");
Set_Str_To_Name_Buffer ("queuing");
end if;
Q := Make_Defining_Identifier (Name_Find);
......@@ -376,6 +387,8 @@ package body Ocarina.Backends.Xtratum_Conf.Partition_Table is
U := XTN.Unit (Backend_Node (Identifier (E)));
R := XTN.Node (Backend_Node (Identifier (E)));
Current_System := E;
Current_XML_Node := XTN.Root_Node (XTN.XML_File (U));
Push_Entity (U);
......@@ -386,8 +399,9 @@ package body Ocarina.Backends.Xtratum_Conf.Partition_Table is
while Present (S) loop
-- Visit the component instance corresponding to the
-- subcomponent S.
Visit (Corresponding_Instance (S));
if AINU.Is_Processor (Corresponding_Instance (S)) then
Visit (Corresponding_Instance (S));
end if;
S := Next_Node (S);
end loop;
end if;
......@@ -408,6 +422,9 @@ package body Ocarina.Backends.Xtratum_Conf.Partition_Table is
Partition_Table_Node := Make_XML_Node ("PartitionTable");
Append_Node_To_List (Partition_Table_Node,
XTN.Subitems (Current_XML_Node));
Current_XML_Node := Partition_Table_Node;
if not AINU.Is_Empty (Subcomponents (E)) then
......@@ -420,6 +437,7 @@ package body Ocarina.Backends.Xtratum_Conf.Partition_Table is
S := Next_Node (S);
end loop;
end if;
end Visit_Processor_Instance;
--------------------------------------
......@@ -429,6 +447,19 @@ package body Ocarina.Backends.Xtratum_Conf.Partition_Table is
procedure Visit_Virtual_Processor_Instance (E : Node_Id) is
S : Node_Id;
begin
if not AINU.Is_Empty (Subcomponents (Current_System)) then
S := First_Node (Subcomponents (Current_System));
while Present (S) loop
-- Visit the component instance corresponding to the
-- subcomponent S.
if AINU.Is_Process (Corresponding_Instance (S)) and then
Get_Bound_Processor (Corresponding_Instance (S)) = E then
Visit (Corresponding_Instance (S));
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
......
......@@ -178,6 +178,28 @@ package body Utils is
return Quoted (Get_Name_String (N), D);
end Quoted;
-----------------
-- Remove_Char --
-----------------
function Remove_Char (Name : Name_Id; O : Character)
return Name_Id is
New_Name : Name_Id := No_Name;
Initial_Name : constant String := Get_Name_String (Name);
begin
Name_Len := 0;
for Index in Initial_Name'First .. Initial_Name'Last loop
if Initial_Name (Index) /= O then
Add_Char_To_Name_Buffer (Initial_Name (Index));
end if;
end loop;
New_Name := Name_Find;
return New_Name;
end Remove_Char;
------------------
-- Replace_Char --
------------------
......
......@@ -78,6 +78,10 @@ package Utils is
return Name_Id;
-- Replace occurence of character O in the Name by character N.
function Remove_Char (Name : Name_Id; O : Character)
return Name_Id;
-- Remove occurences of character O in the Name.
function Is_Prefix (N1 : Name_Id; N2 : Name_Id) return Boolean;
-- Is N1 a prefix of N2
......
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