Commit 44465353 authored by julien.delange's avatar julien.delange

generate initialization arguments for device drivers

device devices enumerator
extract port/channel/deployment information and use it for initialization
purposes



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/ocarina@584 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 8a0c99ec
......@@ -14,10 +14,10 @@ property set Deployment is
Port_Number : aadlinteger applies to (process, device);
-- IP port number of a process (BSD_Sockets specific)
Process_ID : aadlinteger applies to (process);
Process_ID : aadlinteger applies to (process, device);
-- Process identifier (SpaceWire specific)
Channel_Address : aadlinteger applies to (process);
Channel_Address : aadlinteger applies to (process, device);
-- Communication channel address (SpaceWire specific)
Protocol_Type : type enumeration (iiop, diop);
......
......@@ -938,6 +938,10 @@ package body Ocarina.Backends.C_Common.Mapping is
Get_Name_String (CTU.To_C_Name (Display_Name (Identifier (E))));
Add_Str_To_Name_Buffer ("_k");
elsif Get_Current_Backend_Kind = PolyORB_HI_C and then
AINU.Is_Device (E) then
Get_Name_String (CTU.To_C_Name (Display_Name (Identifier (E))));
Add_Str_To_Name_Buffer ("_device_id");
elsif (Present (Corresponding_Instance (E))
and then AINU.Is_Process_Or_Device
(Corresponding_Instance (E))) then
......
......@@ -102,6 +102,7 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
Node_Enumerator_List : List_Id;
Tasks_Enumerator_List : List_Id;
Devices_Enumerator_List : List_Id;
Entity_Enumerator_List : List_Id;
Global_Port_List : List_Id;
Global_Port_Names : Node_Id;
......@@ -132,6 +133,7 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
Entity_Identifier : Unsigned_Long_Long := 0;
Task_Identifier : Unsigned_Long_Long := 0;
Nb_Protected : Unsigned_Long_Long := 0;
Nb_Devices : Unsigned_Long_Long := 0;
Nb_Ports_In_Process : Unsigned_Long_Long := 0;
Nb_Ports_Total : Unsigned_Long_Long := 0;
Total_Ports_Node : Node_Id := No_Node;
......@@ -274,6 +276,27 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
begin
Current_Device := E;
if Current_Process_Instance /= No_Node and then
Get_Bound_Processor (E) =
Get_Bound_Processor (Current_Process_Instance) then
Bind_AADL_To_Enumerator
(Identifier (E),
Make_Defining_Identifier
(Map_C_Enumerator_Name (E, Entity => False)));
N := Make_Expression
(Make_Defining_Identifier
(Map_C_Enumerator_Name
(E, Entity => False)),
Op_Equal,
(Make_Literal
(CV.New_Int_Value (Nb_Devices, 0, 10))));
Append_Node_To_List
(N, Devices_Enumerator_List);
Nb_Devices := Nb_Devices + 1;
end if;
if Implementation /= No_Node then
if not AAU.Is_Empty (AAN.Subcomponents (Implementation)) then
N := First_Node (Subcomponents (Implementation));
......@@ -316,6 +339,7 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
Current_Process_Instance := E;
Tasks_Enumerator_List := New_List (CTN.K_Enumeration_Literals);
Devices_Enumerator_List := New_List (CTN.K_Enumeration_Literals);
Node_Enumerator_List := New_List (CTN.K_Enumeration_Literals);
Push_Entity (P);
......@@ -325,9 +349,36 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
Node_Identifier := 0;
Task_Identifier := 0;
Nb_Protected := 0;
Nb_Devices := 0;
Nb_Ports_In_Process := 0;
-- First, we consider that the node has no simulink information.
N := Make_Define_Statement
(Defining_Identifier =>
(RE (RE_My_Node)),
Value => Make_Defining_Identifier
(Map_C_Enumerator_Name (Parent_Subcomponent (E))));
Append_Node_To_List
(N, CTN.Declarations (Current_File));
-- 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
C := First_Node (Subcomponents (The_System));
while Present (C) loop
if AAU.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;
-- Visit all the subcomponents of the process
......@@ -353,26 +404,6 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
end loop;
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
C := First_Node (Subcomponents (The_System));
while Present (C) loop
if AAU.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;
-- For each of the processes P connected to E, (1) we add an
-- enumerator corresponding to P and (2) for each one of the
-- threads of P, we add an enumerator.
......@@ -569,6 +600,22 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
(Tasks_Enumerator_List));
Append_Node_To_List (N, CTN.Declarations (Current_File));
Set_Str_To_Name_Buffer ("invalid_device_id");
N := Make_Expression
(Make_Defining_Identifier
(Name_Find),
Op_Equal,
(Make_Literal
(CV.New_Int_Value (1, -1, 10))));
Append_Node_To_List
(N, Devices_Enumerator_List);
N := Make_Full_Type_Declaration
(Defining_Identifier => RE (RE_Device_Id),
Type_Definition => Make_Enum_Aggregate
(Devices_Enumerator_List));
Append_Node_To_List (N, CTN.Declarations (Current_File));
N := Make_Define_Statement
(Defining_Identifier => RE (RE_Nb_Tasks),
Value => Make_Literal (New_Int_Value (Task_Identifier, 1, 10)));
......@@ -663,6 +710,13 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
Append_Node_To_List (N, CTN.Declarations (Current_File));
end if;
N := Make_Define_Statement
(Defining_Identifier => RE (RE_Nb_Devices),
Value => Make_Literal
(New_Int_Value (Nb_Devices, 1, 10)));
Append_Node_To_List
(N, CTN.Declarations (Current_File));
Current_Process_Instance := No_Node;
Pop_Entity; -- U
......@@ -701,7 +755,12 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
-- Visit the component instance corresponding to the
-- subcomponent S.
Visit (Corresponding_Instance (S));
if Get_Current_Backend_Kind = PolyORB_HI_C and then
not AAU.Is_Device (Corresponding_Instance (S)) then
Visit (Corresponding_Instance (S));
else
Visit (Corresponding_Instance (S));
end if;
S := Next_Node (S);
end loop;
end if;
......@@ -815,6 +874,7 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
(Present (Backend_Node (Identifier (F))) and then
No (CTN.Local_Port_Node
(Backend_Node (Identifier (F))))) then
N := Make_Expression
(Make_Defining_Identifier
(Map_C_Enumerator_Name (F, Local_Port => True)),
......
......@@ -38,6 +38,8 @@ 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;
with Ocarina.Backends.Utils;
with Ocarina.Backends.Messages;
......@@ -60,7 +62,10 @@ package body Ocarina.Backends.PO_HI_C.Main is
use Ocarina.Backends.C_Common.Mapping;
use Ocarina.Backends.Utils;
use Ocarina.Instances.Queries;
package AAU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
package CV renames Ocarina.Backends.C_Values;
package CTN renames Ocarina.Backends.C_Tree.Nodes;
package CTU renames Ocarina.Backends.C_Tree.Nutils;
......@@ -503,23 +508,80 @@ package body Ocarina.Backends.PO_HI_C.Main is
Entrypoint : constant Node_Id
:= Get_Thread_Initialize_Entrypoint (E);
Impl : constant Node_Id := Get_Implementation (E);
Init_Args : constant List_Id := New_List (CTN.K_Parameter_List);
Conf_Str : Name_Id := No_Name;
Tmp_Name : Name_Id;
begin
Current_Device := E;
if Entrypoint /= No_Node then
N := Message_Comment ("Initialize device "
& Get_Name_String
(Name (Identifier (E))));
Append_Node_To_List (N, CTN.Statements (Main_Function));
if Get_String_Property
(E, "deployment::driver_name") /= No_Name then
Append_Node_To_List
(Make_Literal
(CV.New_Pointed_Char_Value
(Get_String_Property (E, "deployment::driver_name"))),
Init_Args);
else
Append_Node_To_List
(Make_Literal
(CV.New_Pointed_Char_Value
(Get_String_Name ("noname"))),
Init_Args);
end if;
if Get_Location (E) /= No_Name then
Get_Name_String (Get_Location (E));
Add_Str_To_Name_Buffer (":");
Add_Str_To_Name_Buffer (Value_Id'Image (Get_Port_Number (E)));
Conf_Str := Name_Find;
elsif Is_Defined_Property (E, "deployment::channel_address") then
Set_Str_To_Name_Buffer
(Unsigned_Long_Long'Image
(Get_Integer_Property
(E, "deployment::channel_address")));
Conf_Str := Name_Find;
if Is_Defined_Property (E, "deployment::process_id") then
Set_Str_To_Name_Buffer
(Unsigned_Long_Long'Image
(Get_Integer_Property (E, "deployment::process_id")));
Tmp_Name := Name_Find;
Get_Name_String (Conf_Str);
Add_Str_To_Name_Buffer (":");
Get_Name_String_And_Append (Tmp_Name);
Conf_Str := Name_Find;
end if;
end if;
if Conf_Str /= No_Name then
Append_Node_To_List
(Make_Literal
(CV.New_Pointed_Char_Value (Conf_Str)),
Init_Args);
else
Append_Node_To_List
(Make_Literal
(CV.New_Pointed_Char_Value
(Get_String_Name ("noaddr"))),
Init_Args);
end if;
N := Make_Extern_Entity_Declaration
(Make_Function_Specification
(Map_C_Subprogram_Identifier (Entrypoint),
No_List,
Make_List_Id
(Make_Parameter_Specification
(Make_Defining_Identifier (Get_String_Name ("name")),
Make_Pointer_Type (New_Node (CTN.K_Char))),
Make_Parameter_Specification
(Make_Defining_Identifier
(Get_String_Name ("location")),
Make_Pointer_Type (New_Node (CTN.K_Char)))),
New_Node (CTN.K_Void)));
Append_Node_To_List (N, CTN.Declarations (Current_File));
N := Make_Call_Profile
(Map_C_Subprogram_Identifier (Entrypoint), No_List);
(Map_C_Subprogram_Identifier (Entrypoint), Init_Args);
Append_Node_To_List (N, CTN.Declarations (Main_Function));
end if;
......
......@@ -144,10 +144,13 @@ package Ocarina.Backends.PO_HI_C.Runtime is
RE_Noport, -- __PO_HI_NOPORT
RE_Bigendian, -- __PO_HI_BIGENDIAN
RE_Littleendian, -- __PO_HI_LITTLEENDIAN
RE_Noaddr, -- __PO_HI_NB_NOADDR
RE_Noaddr, -- __PO_HI_NOADDR
RE_No_Device, -- __PO_HI_NO_DEVICE
RE_Unused_Node, -- __PO_HI_UNUSED_NODE
RE_Nb_Protected, -- __PO_HI_NB_PROTECTED
RE_Nb_Nodes, -- __PO_HI_NB_NODES
RE_Nb_Devices, -- __PO_HI_NB_DEVICES
RE_My_Node, -- __PO_HI_MY_NODE
RE_Gqueue_Fifo_Indata, -- __PO_HI_GQUEUE_FIFO_DATA
RE_Gqueue_Fifo_Out, -- __PO_HI_GQUEUE_FIFO_OUT
RE_Nb_Operations, -- __PO_HI_NB_OPERATIONS
......@@ -160,6 +163,7 @@ package Ocarina.Backends.PO_HI_C.Runtime is
RE_SUCCESS, -- __PO_HI_SUCCESS
RE_Task_Id, -- __po_hi_task_id
RE_Device_Id, -- __po_hi_device_id
RE_Entity_T, -- __po_hi_entity_t
RE_Inetport_T, -- __po_hi_inetport_t
RE_Inetaddr_T, -- __po_hi_inetaddr_t
......@@ -185,7 +189,9 @@ package Ocarina.Backends.PO_HI_C.Runtime is
RE_Operation_Names, -- __po_hi_operation_names
RE_Ports_Names, -- __po_hi_port_names
RE_Devices_Naming, -- __po_hi_devices_naming
RE_Port_Global_To_Entity, -- __po_hi_port_global_to_entity
RE_Port_Global_To_Device, -- __po_hi_port_global_to_device
RE_Port_Global_Names, -- __po_hi_port_global_names
RE_Port_Global_Model_Names, -- __po_hi_port_global_model_names
RE_Port_Global_To_Local -- __po_hi_port_global_to_local
......@@ -277,6 +283,7 @@ package Ocarina.Backends.PO_HI_C.Runtime is
RE_Msg_T => RH_PO_HI_Messages,
RE_Task_Id => RH_Deployment,
RE_Device_Id => RH_Deployment,
RE_Entity_T => RH_Deployment,
RE_Local_Port_T => RH_Deployment,
RE_Port_T => RH_Deployment,
......@@ -307,6 +314,8 @@ package Ocarina.Backends.PO_HI_C.Runtime is
RE_Main_Name => RH_PO_HI_Task,
RE_Main_Return => RH_PO_HI_Task,
RE_Nb_Nodes => RH_Deployment,
RE_Nb_Devices => RH_Deployment,
RE_My_Node => RH_Deployment,
RE_Nb_Ports => RH_Deployment,
RE_Nb_Servers => RH_Deployment,
RE_Nb_Protected => RH_PO_HI_Protected,
......@@ -319,6 +328,7 @@ package Ocarina.Backends.PO_HI_C.Runtime is
RE_Gqueue_Fifo_Out => RH_PO_HI_Gqueue,
RE_Nb_Operations => RH_Request,
RE_Noaddr => RH_PO_HI_Transport,
RE_No_Device => RH_Deployment,
RE_Noport => RH_PO_HI_Transport,
RE_Bigendian => RH_PO_HI_Transport,
RE_Littleendian => RH_PO_HI_Transport,
......@@ -329,8 +339,10 @@ package Ocarina.Backends.PO_HI_C.Runtime is
-- Variables associations
RE_Ports_Names => RH_PO_HI_Types,
RE_Devices_Naming => RH_Deployment,
RE_Operation_Names => RH_PO_HI_Types,
RE_Port_Global_To_Entity => RH_Deployment,
RE_Port_Global_To_Device => RH_Deployment,
RE_Port_Global_Names => RH_Deployment,
RE_Port_Global_Model_Names => RH_Deployment,
RE_Port_Global_To_Local => RH_Deployment
......
......@@ -2234,7 +2234,7 @@ package body Ocarina.Backends.Properties is
function Get_Process_Id (P : Node_Id) return Value_Id is
use Ocarina.AADL_Values;
begin
pragma Assert (Is_Process (P));
pragma Assert (Is_Process_Or_Device (P));
if not Is_Defined_Integer_Property (P, Process_Id) then
return No_Value;
......@@ -2253,7 +2253,7 @@ package body Ocarina.Backends.Properties is
function Get_Channel_Address (P : Node_Id) return Value_Id is
use Ocarina.AADL_Values;
begin
pragma Assert (Is_Process (P));
pragma Assert (Is_Process_Or_Device (P));
if not Is_Defined_Integer_Property (P, Process_Channel_Address) then
return No_Value;
......
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