Commit 7e553172 authored by jdelange's avatar jdelange
Browse files

* Main goal

   - Introduce the ability to use two instances
     of the same driver.
   - Impact: poller are expected to take a mandatory
     argument that has the type __po_hi_device_id

 * ocarina/src/backends/ocarina-backends-po_hi_c-activity.adb
 * ocarina/src/backends/ocarina-backends-c_tree-nutils.adb
   ocarina/src/backends/ocarina-backends-c_tree-nutils.ads
   - Also adapt the call sequence of a subprogram and a thread
     when we generate the call sequence

 * ocarina/src/backends/ocarina-backends-c_common-subprograms.adb
   - Also consider the device if the subprogram
     is part of a device implementation, map the correct
     arguments when mapping the spec of the subprogram
     and its call sequence.

 * ocarina/src/backends/ocarina-backends-c_common-mapping.adb
   ocarina/src/backends/ocarina-backends-c_common-mapping.ads
   - Add the __po_hi_device_id to the subprogram signatures
     that correspond to functions defined for the implementation
     of a driver



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/ocarina@2701 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 35561083
......@@ -854,10 +854,32 @@ package body Ocarina.Backends.C_Common.Mapping is
-- Map_Task_Job_Identifier --
-----------------------------
function Map_Task_Job_Identifier (E : Node_Id) return Node_Id is
function Map_Task_Job_Identifier
(E : Node_Id; Prefix_Component : Node_Id := No_Node)
return Node_Id is
Name : Name_Id;
C1 : Name_Id := No_Name;
C2 : Name_Id := No_Name;
begin
Get_Name_String (To_C_Name (AIN.Display_Name (Identifier (E))));
if Prefix_Component /= No_Node then
Get_Name_String
(To_C_Name
(AIN.Display_Name
(Identifier (Prefix_Component))));
C1 := Name_Find;
end if;
Get_Name_String
(To_C_Name (AIN.Display_Name (Identifier (E))));
C2 := Name_Find;
Set_Str_To_Name_Buffer ("");
if C1 /= No_Name then
Get_Name_String (C1);
Add_Str_To_Name_Buffer ("_");
end if;
Get_Name_String_And_Append (C2);
Add_Str_To_Name_Buffer ("_job");
Name := Name_Find;
Name := To_Lower (Name);
......@@ -1890,7 +1912,8 @@ package body Ocarina.Backends.C_Common.Mapping is
-- Map_C_Subprogram_Spec --
---------------------------
function Map_C_Subprogram_Spec (S : Node_Id) return Node_Id is
function Map_C_Subprogram_Spec
(S : Node_Id; Containing_Device : Node_Id := No_Node) return Node_Id is
Profile : constant List_Id := CTU.New_List (CTN.K_Parameter_Profile);
Param : Node_Id;
Mode : Mode_Id;
......@@ -1901,6 +1924,15 @@ package body Ocarina.Backends.C_Common.Mapping is
begin
pragma Assert (AINU.Is_Subprogram (S));
if Containing_Device /= No_Node then
Param := CTU.Make_Parameter_Specification
(Defining_Identifier =>
Make_Defining_Identifier (VN (V_Dev_Id)),
Parameter_Type =>
(RE (RE_Device_Id)));
CTU.Append_Node_To_List (Param, Profile);
end if;
-- We build the parameter profile of the subprogram instance by
-- adding:
......@@ -2069,9 +2101,13 @@ package body Ocarina.Backends.C_Common.Mapping is
-- Map_C_Subprogram_Body --
---------------------------
function Map_C_Subprogram_Body (S : Node_Id) return Node_Id is
Spec : constant Node_Id := Map_C_Subprogram_Spec (S);
User_Spec : constant Node_Id := Map_C_Subprogram_Spec (S);
function Map_C_Subprogram_Body
(S : Node_Id;
Containing_Device : Node_Id := No_Node) return Node_Id is
Spec : constant Node_Id :=
Map_C_Subprogram_Spec (S, Containing_Device);
User_Spec : constant Node_Id :=
Map_C_Subprogram_Spec (S, Containing_Device);
Declarations : constant List_Id := New_List (CTN.K_Declaration_List);
Statements : constant List_Id := New_List (CTN.K_Statement_List);
Call_Profile : List_Id := New_List (CTN.K_Parameter_Profile);
......
......@@ -64,7 +64,9 @@ package Ocarina.Backends.C_Common.Mapping is
procedure Bind_AADL_To_Subprogram (G : Node_Id; A : Node_Id);
procedure Bind_AADL_To_Servers (G : Node_Id; A : Node_Id);
procedure Bind_AADL_To_Entities (G : Node_Id; A : Node_Id);
function Map_Task_Job_Identifier (E : Node_Id) return Node_Id;
function Map_Task_Job_Identifier
(E : Node_Id; Prefix_Component : Node_Id := No_Node)
return Node_Id;
function Map_Time (T : Time_Type;
Variable : Name_Id := No_Name) return Node_Id;
function Map_C_Enum_Name (E : Node_Id; Enumerator : Name_Id) return Name_Id;
......@@ -111,8 +113,12 @@ package Ocarina.Backends.C_Common.Mapping is
procedure Bind_AADL_To_Local_Port (G : Node_Id; A : Node_Id);
procedure Bind_AADL_To_Global_Port (G : Node_Id; A : Node_Id);
function Map_Stub_Identifier (E : Node_Id) return Node_Id;
function Map_C_Subprogram_Spec (S : Node_Id) return Node_Id;
function Map_C_Subprogram_Body (S : Node_Id) return Node_Id;
function Map_C_Subprogram_Spec
(S : Node_Id; Containing_Device : Node_Id := No_Node)
return Node_Id;
function Map_C_Subprogram_Body
(S : Node_Id; Containing_Device : Node_Id := No_Node)
return Node_Id;
function Map_C_Subprogram_Identifier (E : Node_Id) return Node_Id;
function Map_C_Marshaller_Subprogram (A : Node_Id;
Is_Unmarshall : Boolean := False;
......
......@@ -76,6 +76,8 @@ package body Ocarina.Backends.C_Common.Subprograms is
procedure Visit_Data_Instance (E : Node_Id);
procedure Visit_Device_Instance (E : Node_Id);
Current_Device : Node_Id := No_Node;
-----------
-- Visit --
-----------
......@@ -155,6 +157,7 @@ package body Ocarina.Backends.C_Common.Subprograms is
Implementation : Node_Id;
S : Node_Id;
begin
Current_Device := E;
if Get_Current_Backend_Kind = PolyORB_Kernel_C then
U := CTN.Distributed_Application_Unit
(CTN.Naming_Node (Backend_Node (Identifier (E))));
......@@ -189,6 +192,8 @@ package body Ocarina.Backends.C_Common.Subprograms is
Pop_Entity; -- U
Pop_Entity; -- P
end if;
Current_Device := No_Node;
end Visit_Device_Instance;
-------------------------
......@@ -348,7 +353,7 @@ package body Ocarina.Backends.C_Common.Subprograms is
-- Generate the spec of the subprogram
if No (Get_Handling (E, By_Name, H_C_Subprogram_Spec)) then
N := Map_C_Subprogram_Spec (E);
N := Map_C_Subprogram_Spec (E, Current_Device);
Append_Node_To_List (N, CTN.Declarations (Current_File));
-- Mark the subprogram as being handled
......@@ -494,6 +499,8 @@ package body Ocarina.Backends.C_Common.Subprograms is
procedure Visit_Data_Instance (E : Node_Id);
procedure Visit_Device_Instance (E : Node_Id);
Current_Device : Node_Id := No_Node;
-----------
-- Visit --
-----------
......@@ -783,7 +790,7 @@ package body Ocarina.Backends.C_Common.Subprograms is
CTN.Declarations (Current_File));
end if;
N := Map_C_Subprogram_Body (E);
N := Map_C_Subprogram_Body (E, Current_Device);
Append_Node_To_List (N, CTN.Declarations (Current_File));
-- Mark the subprogram as being handled
......@@ -914,6 +921,9 @@ package body Ocarina.Backends.C_Common.Subprograms is
Implementation : Node_Id;
S : Node_Id;
begin
Current_Device := E;
if Get_Current_Backend_Kind = PolyORB_Kernel_C then
U := CTN.Distributed_Application_Unit
......@@ -950,6 +960,9 @@ package body Ocarina.Backends.C_Common.Subprograms is
Pop_Entity; -- U
Pop_Entity; -- P
end if;
Current_Device := No_Node;
end Visit_Device_Instance;
end Source_File;
......
......@@ -1643,10 +1643,11 @@ package body Ocarina.Backends.C_Tree.Nutils is
--------------------------
procedure Handle_Call_Sequence
(Caller : Node_Id;
Call_Seq : Node_Id;
Declarations : List_Id;
Statements : List_Id)
(Caller : Node_Id;
Call_Seq : Node_Id;
Declarations : List_Id;
Statements : List_Id;
Containing_Device : Node_Id := No_Node)
is
Destination_F : Node_Id;
Source_F : Node_Id;
......@@ -1979,6 +1980,12 @@ package body Ocarina.Backends.C_Tree.Nutils is
if Get_Current_Backend_Kind = PolyORB_HI_C then
N := Map_C_Defining_Identifier (Spg);
if Containing_Device /= No_Node then
CTU.Append_Node_To_List
(Make_Defining_Identifier
(Map_C_Enumerator_Name (Containing_Device)),
Call_Profile);
end if;
elsif Get_Current_Backend_Kind = PolyORB_Kernel_C then
N := Map_C_Defining_Identifier (Spg);
end if;
......
......@@ -211,6 +211,7 @@ package Ocarina.Backends.C_Tree.Nutils is
V_Server_Entity_Table,
V_Invalid_Server,
V_Got_Data,
V_Dev_Id,
V_Entity,
V_Port,
V_Pkt,
......@@ -546,10 +547,15 @@ package Ocarina.Backends.C_Tree.Nutils is
Exception_Error : Node_Id := No_Node);
procedure Handle_Call_Sequence
(Caller : Node_Id;
Call_Seq : Node_Id;
Declarations : List_Id;
Statements : List_Id);
(Caller : Node_Id;
Call_Seq : Node_Id;
Declarations : List_Id;
Statements : List_Id;
Containing_Device : Node_Id := No_Node);
-- The Containing_Device argument is used when the call
-- sequence is generated for a thread that is within
-- a device. In that case, the first parameter is ALWAYS
-- the device id of the containing device.
procedure Set_Deployment_Source (N : Node_Id := No_Node);
......
......@@ -66,6 +66,7 @@ package body Ocarina.Backends.PO_HI_C.Activity is
package CV renames Ocarina.Backends.C_Values;
Send_Output_Specification : Node_Id;
Current_Device : Node_Id := No_Node;
------------
-- Header --
......@@ -94,7 +95,7 @@ package body Ocarina.Backends.PO_HI_C.Activity is
S : constant Node_Id := Parent_Subcomponent (E);
begin
N := Make_Function_Specification
(Defining_Identifier => Map_Task_Job_Identifier (S),
(Defining_Identifier => Map_Task_Job_Identifier (S, Current_Device),
Parameters => No_List,
Return_Type => CTU.Make_Pointer_Type
(New_Node (CTN.K_Void)));
......@@ -259,6 +260,7 @@ package body Ocarina.Backends.PO_HI_C.Activity is
Implementation : constant Node_Id := Get_Implementation (E);
S : Node_Id;
begin
Current_Device := E;
if Implementation /= No_Node then
if not AAU.Is_Empty (AAN.Subcomponents (Implementation)) then
S := First_Node (Subcomponents (Implementation));
......@@ -268,6 +270,7 @@ package body Ocarina.Backends.PO_HI_C.Activity is
end loop;
end if;
end if;
Current_Device := No_Node;
end Visit_Device_Instance;
---------------------------
......@@ -966,7 +969,7 @@ package body Ocarina.Backends.PO_HI_C.Activity is
-- unique call sequence, handle it.
CTU.Handle_Call_Sequence
(S, Call_Seq, Declarations, WStatements);
(S, Call_Seq, Declarations, WStatements, Current_Device);
CTU.Simulate_WCET (E, Declarations, WStatements);
else
N := Message_Comment ("not implemented yet");
......
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