Commit 9d256c1c authored by julien.delange's avatar julien.delange

* handle connection between processes and device, prototype

   of the pci_minio card now works


git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/ocarina@974 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent e0cadca1
...@@ -2,6 +2,8 @@ package ocarina_drivers_ni_6071e ...@@ -2,6 +2,8 @@ package ocarina_drivers_ni_6071e
public public
with Base_Types;
subprogram spg_init subprogram spg_init
properties properties
Source_Language => C; Source_Language => C;
...@@ -10,6 +12,8 @@ end spg_init; ...@@ -10,6 +12,8 @@ end spg_init;
subprogram spg_poller subprogram spg_poller
features
data1 : out parameter Base_Types::Integer;
properties properties
Source_Language => C; Source_Language => C;
Source_Name => "__po_hi_c_driver_ni_pcimio_poller"; Source_Name => "__po_hi_c_driver_ni_pcimio_poller";
...@@ -17,6 +21,8 @@ end spg_poller; ...@@ -17,6 +21,8 @@ end spg_poller;
thread thr_poller thread thr_poller
features
data1 : out data port Base_Types::Integer;
end thr_poller; end thr_poller;
thread implementation thr_poller.i thread implementation thr_poller.i
...@@ -24,6 +30,8 @@ calls ...@@ -24,6 +30,8 @@ calls
mycall : { mycall : {
pspg : subprogram spg_poller; pspg : subprogram spg_poller;
}; };
connections
parameter pspg.data1 -> data1;
properties properties
Period => 100 ms; Period => 100 ms;
Dispatch_Protocol => Periodic; Dispatch_Protocol => Periodic;
...@@ -31,11 +39,15 @@ end thr_poller.i; ...@@ -31,11 +39,15 @@ end thr_poller.i;
abstract driver abstract driver
features
data1 : out data port Base_Types::Integer;
end driver; end driver;
abstract implementation driver.i abstract implementation driver.i
subcomponents subcomponents
poller : thread thr_poller.i; poller : thread thr_poller.i;
connections
port poller.data1 -> data1;
end driver.i; end driver.i;
end ocarina_drivers_ni_6071e; end ocarina_drivers_ni_6071e;
...@@ -1019,10 +1019,6 @@ package body Ocarina.Backends.C_Common.Mapping is ...@@ -1019,10 +1019,6 @@ package body Ocarina.Backends.C_Common.Mapping is
-- For threads, the enumerator name is mapped from the -- For threads, the enumerator name is mapped from the
-- containing process name and the thread subcomponent name. -- containing process name and the thread subcomponent name.
-- Verifiy that the thread is a subcomponent of a process
pragma Assert (AINU.Is_Process (Parent_Component (E)));
C_Name := C_Name :=
Display_Name Display_Name
(Identifier (Identifier
......
...@@ -51,8 +51,6 @@ with Ocarina.Backends.C_Common.Mapping; ...@@ -51,8 +51,6 @@ with Ocarina.Backends.C_Common.Mapping;
with Ocarina.Backends.PO_HI_C.Runtime; with Ocarina.Backends.PO_HI_C.Runtime;
with Ocarina.Backends.POK_C.Runtime; with Ocarina.Backends.POK_C.Runtime;
with Ocarina.Instances.Queries;
package body Ocarina.Backends.C_Common.Types is package body Ocarina.Backends.C_Common.Types is
use Ocarina.ME_AADL; use Ocarina.ME_AADL;
...@@ -67,8 +65,6 @@ package body Ocarina.Backends.C_Common.Types is ...@@ -67,8 +65,6 @@ package body Ocarina.Backends.C_Common.Types is
use Ocarina.Backends.POK_C; use Ocarina.Backends.POK_C;
use Ocarina.Backends.POK_C.Runtime; use Ocarina.Backends.POK_C.Runtime;
use Ocarina.Instances.Queries;
package ATN renames Ocarina.ME_AADL.AADL_Tree.Nodes; package ATN renames Ocarina.ME_AADL.AADL_Tree.Nodes;
package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes; package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes;
package AINU renames Ocarina.ME_AADL.AADL_Instances.Nutils; package AINU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
...@@ -212,27 +208,31 @@ package body Ocarina.Backends.C_Common.Types is ...@@ -212,27 +208,31 @@ package body Ocarina.Backends.C_Common.Types is
Implementation : Node_Id; Implementation : Node_Id;
S : Node_Id; S : Node_Id;
begin begin
if Get_Current_Backend_Kind /= PolyORB_Kernel_C then if Get_Current_Backend_Kind = PolyORB_Kernel_C then
return; U := CTN.Distributed_Application_Unit
end if; (CTN.Naming_Node (Backend_Node (Identifier (E))));
U := CTN.Distributed_Application_Unit
(CTN.Naming_Node (Backend_Node (Identifier (E))));
P := CTN.Entity (U); P := CTN.Entity (U);
Push_Entity (P); Push_Entity (P);
Push_Entity (U); Push_Entity (U);
end if;
Implementation := Get_Classifier_Property (E, "implemented_as"); Implementation := Get_Implementation (E);
if Implementation /= No_Node then if Implementation /= No_Node then
if not AINU.Is_Empty (AIN.Subcomponents (Implementation)) then if not AINU.Is_Empty (AIN.Subcomponents (Implementation)) then
S := First_Node (Subcomponents (Implementation)); S := First_Node (Subcomponents (Implementation));
while Present (S) loop while Present (S) loop
if Get_Category_Of_Component (S) = CC_Process then
Visit_Process_Instance if Get_Current_Backend_Kind = PolyORB_Kernel_C then
(Corresponding_Instance (S), False); if Get_Category_Of_Component (S) = CC_Process then
Visit_Process_Instance
(Corresponding_Instance (S), False);
end if;
else
Visit
(Corresponding_Instance (S));
end if; end if;
S := Next_Node (S); S := Next_Node (S);
...@@ -241,8 +241,10 @@ package body Ocarina.Backends.C_Common.Types is ...@@ -241,8 +241,10 @@ package body Ocarina.Backends.C_Common.Types is
end if; end if;
Pop_Entity; -- U if Get_Current_Backend_Kind = PolyORB_Kernel_C then
Pop_Entity; -- P Pop_Entity; -- U
Pop_Entity; -- P
end if;
end Visit_Device_Instance; end Visit_Device_Instance;
------------------------------ ------------------------------
...@@ -739,6 +741,8 @@ package body Ocarina.Backends.C_Common.Types is ...@@ -739,6 +741,8 @@ package body Ocarina.Backends.C_Common.Types is
U : Node_Id; U : Node_Id;
P : Node_Id; P : Node_Id;
Declaration : Node_Id; Declaration : Node_Id;
The_System : constant Node_Id := Parent_Component
(Parent_Subcomponent (E));
begin begin
if Real_Process then if Real_Process then
U := CTN.Distributed_Application_Unit U := CTN.Distributed_Application_Unit
...@@ -810,6 +814,26 @@ package body Ocarina.Backends.C_Common.Types is ...@@ -810,6 +814,26 @@ package body Ocarina.Backends.C_Common.Types is
end loop; end loop;
end if; end if;
-- Visit all devices attached to the parent system that
-- share the same processor as process E.
if Get_Current_Backend_Kind = PolyORB_HI_C and then
not AINU.Is_Empty (Subcomponents (The_System)) then
C := First_Node (Subcomponents (The_System));
while Present (C) loop
if AINU.Is_Device (Corresponding_Instance (C))
and then
Get_Bound_Processor (Corresponding_Instance (C))
= Get_Bound_Processor (E)
then
-- Build the enumerator corresponding to the device
-- Note: we reuse the process name XXX
Visit_Device_Instance (Corresponding_Instance (C));
end if;
C := Next_Node (C);
end loop;
end if;
-- We visit all the data of connected components, because -- We visit all the data of connected components, because
-- we may need them in case of a distributed system. -- we may need them in case of a distributed system.
...@@ -935,7 +959,10 @@ package body Ocarina.Backends.C_Common.Types is ...@@ -935,7 +959,10 @@ package body Ocarina.Backends.C_Common.Types is
then then
null; null;
else else
Visit (Corresponding_Instance (S)); if Get_Category_Of_Component
(Corresponding_Instance (S)) /= CC_Device then
Visit (Corresponding_Instance (S));
end if;
end if; end if;
S := Next_Node (S); S := Next_Node (S);
end loop; end loop;
......
...@@ -689,7 +689,7 @@ package body Ocarina.Backends.PO_HI_C.Activity is ...@@ -689,7 +689,7 @@ package body Ocarina.Backends.PO_HI_C.Activity is
Call_Parameters := New_List (CTN.K_Parameter_List); Call_Parameters := New_List (CTN.K_Parameter_List);
N := Make_Defining_Identifier N := Make_Defining_Identifier
(Map_C_Enumerator_Name (S)); (Map_C_Enumerator_Name (S, Current_Device));
Append_Node_To_List (N, Call_Parameters); Append_Node_To_List (N, Call_Parameters);
N := Make_Defining_Identifier N := Make_Defining_Identifier
...@@ -807,7 +807,7 @@ package body Ocarina.Backends.PO_HI_C.Activity is ...@@ -807,7 +807,7 @@ package body Ocarina.Backends.PO_HI_C.Activity is
-- Then, call the send_output in the main loop. -- Then, call the send_output in the main loop.
Call_Parameters := New_List (CTN.K_Parameter_List); Call_Parameters := New_List (CTN.K_Parameter_List);
N := Make_Defining_Identifier N := Make_Defining_Identifier
(Map_C_Enumerator_Name (S)); (Map_C_Enumerator_Name (S, Current_Device));
Append_Node_To_List (N, Call_Parameters); Append_Node_To_List (N, Call_Parameters);
N := Make_Defining_Identifier N := Make_Defining_Identifier
...@@ -1168,7 +1168,7 @@ package body Ocarina.Backends.PO_HI_C.Activity is ...@@ -1168,7 +1168,7 @@ package body Ocarina.Backends.PO_HI_C.Activity is
Append_Node_To_List Append_Node_To_List
(Make_Defining_Identifier (Make_Defining_Identifier
(Map_C_Enumerator_Name (S)), (Map_C_Enumerator_Name (S, Current_Device)),
Call_Parameters); Call_Parameters);
Append_Node_To_List Append_Node_To_List
...@@ -1517,6 +1517,24 @@ package body Ocarina.Backends.PO_HI_C.Activity is ...@@ -1517,6 +1517,24 @@ package body Ocarina.Backends.PO_HI_C.Activity is
end loop; end loop;
end if; end if;
-- Visit all devices attached to the parent system that
-- share the same processor as process E.
if not AAU.Is_Empty (Subcomponents (The_System)) then
S := First_Node (Subcomponents (The_System));
while Present (S) loop
if AAU.Is_Device (Corresponding_Instance (S))
and then
Get_Bound_Processor (Corresponding_Instance (S))
= Get_Bound_Processor (E)
then
Visit_Device_Instance
(Corresponding_Instance (S));
end if;
S := Next_Node (S);
end loop;
end if;
if Present (Backend_Node (Identifier (Parent_Subcomponent if Present (Backend_Node (Identifier (Parent_Subcomponent
(E)))) and then (E)))) and then
Present (CTN.Job_Node (Backend_Node (Identifier Present (CTN.Job_Node (Backend_Node (Identifier
...@@ -1568,6 +1586,10 @@ package body Ocarina.Backends.PO_HI_C.Activity is ...@@ -1568,6 +1586,10 @@ package body Ocarina.Backends.PO_HI_C.Activity is
Append_Node_To_List (N, CTN.Declarations (Current_File)); Append_Node_To_List (N, CTN.Declarations (Current_File));
end if; end if;
-- If some threads are connected to other nodes, we declare
-- a send_output function that is responsible to send
-- data over the network using device drivers functions.
if Has_Send_Output_Declared then if Has_Send_Output_Declared then
Append_Node_To_List Append_Node_To_List
(Make_Switch_Alternative (Make_Switch_Alternative
...@@ -1599,27 +1621,6 @@ package body Ocarina.Backends.PO_HI_C.Activity is ...@@ -1599,27 +1621,6 @@ package body Ocarina.Backends.PO_HI_C.Activity is
Append_Node_To_List (N, CTN.Declarations (Current_File)); Append_Node_To_List (N, CTN.Declarations (Current_File));
end if; end if;
-- If some threads are connected to other nodes, we declare
-- a send_output function that is responsible to send
-- data over the network using device drivers functions.
-- Visit all devices attached to the parent system that
-- share the same processor as process E.
if not AAU.Is_Empty (Subcomponents (The_System)) then
S := First_Node (Subcomponents (The_System));
while Present (S) loop
if AAU.Is_Device (Corresponding_Instance (S))
and then
Get_Bound_Processor (Corresponding_Instance (S))
= Get_Bound_Processor (E)
then
Visit_Device_Instance
(Corresponding_Instance (S));
end if;
S := Next_Node (S);
end loop;
end if;
Pop_Entity; -- U Pop_Entity; -- U
Pop_Entity; -- P Pop_Entity; -- P
...@@ -1715,7 +1716,7 @@ package body Ocarina.Backends.PO_HI_C.Activity is ...@@ -1715,7 +1716,7 @@ package body Ocarina.Backends.PO_HI_C.Activity is
if Kind (F) = K_Port_Spec_Instance then if Kind (F) = K_Port_Spec_Instance then
if Is_Out (F) then if Is_Out (F) then
Destinations := Get_Destination_Ports (F); Destinations := Get_Destination_Ports (F, Current_Device);
Local_Dest_Values := Make_Array_Values; Local_Dest_Values := Make_Array_Values;
if AAU.Is_Empty (Destinations) then if AAU.Is_Empty (Destinations) then
......
...@@ -114,7 +114,7 @@ package body Ocarina.Backends.PO_HI_C.Deployment is ...@@ -114,7 +114,7 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
Global_Port_Model_Names : Node_Id; Global_Port_Model_Names : Node_Id;
Local_Port_List : List_Id; Local_Port_List : List_Id;
Current_Process_Instance : Node_Id := No_Node; Current_Process_Instance : Node_Id := No_Node;
Global_Port_To_Entity : Node_Id; Global_Port_To_Entity : Node_Id;
Global_Port_To_Local : Node_Id; Global_Port_To_Local : Node_Id;
...@@ -277,7 +277,6 @@ package body Ocarina.Backends.PO_HI_C.Deployment is ...@@ -277,7 +277,6 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
--------------------------- ---------------------------
procedure Visit_Device_Instance (E : Node_Id) is procedure Visit_Device_Instance (E : Node_Id) is
Implementation : constant Node_Id := Get_Implementation (E);
N : Node_Id; N : Node_Id;
Conf_Str : Name_Id := No_Name; Conf_Str : Name_Id := No_Name;
Tmp_Name : Name_Id; Tmp_Name : Name_Id;
...@@ -358,16 +357,6 @@ package body Ocarina.Backends.PO_HI_C.Deployment is ...@@ -358,16 +357,6 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
end if; end if;
if Implementation /= No_Node then
if not AAU.Is_Empty (AAN.Subcomponents (Implementation)) then
N := First_Node (Subcomponents (Implementation));
while Present (N) loop
Visit_Component_Instance (Corresponding_Instance (N));
N := Next_Node (N);
end loop;
end if;
end if;
Current_Device := No_Node; Current_Device := No_Node;
end Visit_Device_Instance; end Visit_Device_Instance;
...@@ -394,6 +383,7 @@ package body Ocarina.Backends.PO_HI_C.Deployment is ...@@ -394,6 +383,7 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
Parent : Node_Id; Parent : Node_Id;
The_System : constant Node_Id := Parent_Component The_System : constant Node_Id := Parent_Component
(Parent_Subcomponent (E)); (Parent_Subcomponent (E));
Device_Implementation : Node_Id;
begin begin
pragma Assert (AAU.Is_System (Root_Sys)); pragma Assert (AAU.Is_System (Root_Sys));
...@@ -436,6 +426,27 @@ package body Ocarina.Backends.PO_HI_C.Deployment is ...@@ -436,6 +426,27 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
-- Note: we reuse the process name XXX -- Note: we reuse the process name XXX
Visit_Device_Instance (Corresponding_Instance (C)); Visit_Device_Instance (Corresponding_Instance (C));
Current_Device := Corresponding_Instance (C);
Device_Implementation :=
Get_Implementation (Corresponding_Instance (C));
if Device_Implementation /= No_Node then
if not AAU.Is_Empty
(AAN.Subcomponents (Device_Implementation)) then
N := First_Node (Subcomponents
(Device_Implementation));
while Present (N) loop
Visit_Component_Instance
(Corresponding_Instance (N));
N := Next_Node (N);
end loop;
end if;
end if;
Current_Device := No_Node;
end if; end if;
C := Next_Node (C); C := Next_Node (C);
end loop; end loop;
...@@ -1044,7 +1055,10 @@ package body Ocarina.Backends.PO_HI_C.Deployment is ...@@ -1044,7 +1055,10 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
(N, CTN.Values (Global_Port_To_Local)); (N, CTN.Values (Global_Port_To_Local));
N := Make_Defining_Identifier N := Make_Defining_Identifier
(Map_C_Enumerator_Name (S, Entity => True)); (Map_C_Enumerator_Name
(S,
Entity => True,
Custom_Parent => Current_Device));
Append_Node_To_List Append_Node_To_List
(N, CTN.Values (Global_Port_To_Entity)); (N, CTN.Values (Global_Port_To_Entity));
...@@ -1083,7 +1097,11 @@ package body Ocarina.Backends.PO_HI_C.Deployment is ...@@ -1083,7 +1097,11 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
end loop; end loop;
if Parent_Component (Parent_Subcomponent (E)) if Parent_Component (Parent_Subcomponent (E))
= Current_Process_Instance then = Current_Process_Instance or else
(Current_Device /= No_Node and then
Get_Bound_Processor
(Current_Device) =
Get_Bound_Processor (Current_Process_Instance)) then
N := Make_Define_Statement N := Make_Define_Statement
(Defining_Identifier => (Defining_Identifier =>
Make_Defining_Identifier Make_Defining_Identifier
......
...@@ -43,6 +43,8 @@ with Ocarina.Backends.C_Tree.Nutils; ...@@ -43,6 +43,8 @@ with Ocarina.Backends.C_Tree.Nutils;
with Ocarina.Backends.C_Tree.Nodes; with Ocarina.Backends.C_Tree.Nodes;
with Ocarina.Backends.C_Values; with Ocarina.Backends.C_Values;
with Ocarina.Backends.Properties;
package body Ocarina.Backends.PO_HI_C.Request is package body Ocarina.Backends.PO_HI_C.Request is
use Ocarina.ME_AADL; use Ocarina.ME_AADL;
use Ocarina.ME_AADL.AADL_Instances.Nodes; use Ocarina.ME_AADL.AADL_Instances.Nodes;
...@@ -51,6 +53,7 @@ package body Ocarina.Backends.PO_HI_C.Request is ...@@ -51,6 +53,7 @@ package body Ocarina.Backends.PO_HI_C.Request is
use Ocarina.Backends.C_Common.Mapping; use Ocarina.Backends.C_Common.Mapping;
use Ocarina.Backends.PO_HI_C.Runtime; use Ocarina.Backends.PO_HI_C.Runtime;
use Ocarina.Backends.C_Tree.Nutils; use Ocarina.Backends.C_Tree.Nutils;
use Ocarina.Backends.Properties;
package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes; package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes;
package AINU renames Ocarina.ME_AADL.AADL_Instances.Nutils; package AINU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
...@@ -145,6 +148,9 @@ package body Ocarina.Backends.PO_HI_C.Request is ...@@ -145,6 +148,9 @@ package body Ocarina.Backends.PO_HI_C.Request is
F : Node_Id; F : Node_Id;
J : Node_Id; J : Node_Id;
I : Node_Id; I : Node_Id;
The_System : constant Node_Id := Parent_Component
(Parent_Subcomponent (E));
Device_Implementation : Node_Id;
begin begin
Push_Entity (P); Push_Entity (P);
Push_Entity (U); Push_Entity (U);
...@@ -160,6 +166,34 @@ package body Ocarina.Backends.PO_HI_C.Request is ...@@ -160,6 +166,34 @@ package body Ocarina.Backends.PO_HI_C.Request is
Operation_Identifier := 0; Operation_Identifier := 0;
Request_Declared := False; Request_Declared := False;
if not AINU.Is_Empty (Subcomponents (The_System)) then
C := First_Node (Subcomponents (The_System));
while Present (C) loop
if AINU.Is_Device (Corresponding_Instance (C))
and then
Get_Bound_Processor (Corresponding_Instance (C))
= Get_Bound_Processor (E)
then
Device_Implementation :=
Get_Implementation (Corresponding_Instance (C));
if Device_Implementation /= No_Node then
if not AINU.Is_Empty
(AIN.Subcomponents (Device_Implementation)) then
N := First_Node (Subcomponents
(Device_Implementation));
while Present (N) loop
Visit_Component_Instance
(Corresponding_Instance (N));
N := Next_Node (N);
end loop;
end if;
end if;
end if;
C := Next_Node (C);
end loop;
end if;
if not AINU.Is_Empty (Features (E)) then if not AINU.Is_Empty (Features (E)) then
C := First_Node (Features (E)); C := First_Node (Features (E));
......
...@@ -1478,7 +1478,7 @@ package body Ocarina.Backends.Properties is ...@@ -1478,7 +1478,7 @@ package body Ocarina.Backends.Properties is
-- and a null source name and a null source text is a -- and a null source name and a null source text is a
-- wrong built subprogram. -- wrong built subprogram.
return Subprogram_Unknown; return Subprogram_Opaque_C;
end if; end if;
when Language_RTSJ => when Language_RTSJ =>
......
...@@ -722,11 +722,14 @@ package body Ocarina.Backends.Utils is ...@@ -722,11 +722,14 @@ package body Ocarina.Backends.Utils is
-- Get_Destination_Ports -- -- Get_Destination_Ports --
--------------------------- ---------------------------
function Get_Destination_Ports (P : Node_Id) return List_Id is function Get_Destination_Ports
(P : Node_Id;
Custom_Parent : Node_Id := No_Node) return List_Id is
function Rec_Get_Destination_Ports function Rec_Get_Destination_Ports
(P : Node_Id; (P : Node_Id;
B : Node_Id := No_Node) B : Node_Id := No_Node;
Custom_Parent : Node_Id := No_Node)
return List_Id; return List_Id;
-- Recursive internal routine -- Recursive internal routine