Commit ccf1137d authored by jdelange's avatar jdelange

* ocarina/src/backends/ocarina-backends-po_hi_c.adb

   - Fix the build system to include ASN1Scc runtime
     when using ASN1

 * ocarina/src/backends/ocarina-backends-po_hi_c-deployment.adb
   - Generate identifiers for protocols (see enum __po_hi_protocol_t)
   - Generate the macro __PO_HI_NB_PROTOCOLS

 * ocarina/src/backends/ocarina-backends-build_utils.adb
   - Do not visit data subcomponents in build utils since
     it crashes the testsuite

 * ocarina/src/backends/ocarina-backends-po_hi_c-runtime.ads
   - Add RE_Nb_Protocols
   - Add RE_Protocol_T

 * ocarina/src/backends/ocarina-backends-c_common-mapping.adb
   - Add mapping rules to convert virtual bus names into
     C enumerator (see Map_C_Enumerator_Name)


git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/ocarina@2968 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 9d13a2d2
......@@ -751,7 +751,6 @@ package body Ocarina.Backends.Build_Utils is
-------------------------
procedure Visit_Data_Instance (E : Node_Id) is
SC : Node_Id;
Source : Name_Id;
Sources : constant Name_Array := Get_Source_Text (E);
M : constant Makefile_Type :=
......@@ -764,18 +763,6 @@ package body Ocarina.Backends.Build_Utils is
(M.Asn_Sources,
Source);
end if;
if not AAU.Is_Empty (Subcomponents (E)) then
SC := First_Node (Subcomponents (E));
while Present (SC) loop
-- Visit the corresponding instance of SC
Visit (Corresponding_Instance (SC));
SC := Next_Node (SC);
end loop;
end if;
end Visit_Data_Instance;
--------------------------------
......
......@@ -959,6 +959,18 @@ package body Ocarina.Backends.C_Common.Mapping is
Get_Name_String_And_Append
(AIN.Name
(AIN.Identifier (Parent_Subcomponent (E))));
elsif AINU.Is_Virtual_Bus (E) then
Set_Str_To_Name_Buffer ("virtual_bus_");
if Parent_Subcomponent (E) /= No_Node then
Get_Name_String_And_Append
(AIN.Name
(AIN.Identifier
(Parent_Subcomponent (E))));
else
Get_Name_String_And_Append
(AIN.Name
(AIN.Identifier (E)));
end if;
elsif AINU.Is_Subprogram (E) then
-- For subprograms and processes, the enemerator name is
-- mapped from the entity name.
......
......@@ -121,6 +121,7 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
procedure Visit_Subprogram_Instance (E : Node_Id);
procedure Visit_Device_Instance (E : Node_Id);
procedure Visit_Bus_Instance (E : Node_Id);
procedure Visit_Virtual_Bus_Instance (E : Node_Id);
procedure Set_Added (P : Node_Id; E : Node_Id);
......@@ -143,6 +144,7 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
Buses_Enumerator_List : List_Id;
Entity_Enumerator_List : List_Id;
Global_Port_List : List_Id;
Protocol_List : List_Id;
Global_Port_Names : Node_Id;
Global_Port_Model_Names : Node_Id;
Local_Port_List : List_Id;
......@@ -156,6 +158,7 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
Local_Port_Values : Node_Id;
Invalid_Local_Port_Added : Boolean := False;
Invalid_Protocol_Added : Boolean := False;
Invalid_Global_Port_Added : Boolean := False;
Invalid_Entity_Added : Boolean := False;
......@@ -168,6 +171,7 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
-- process.
Node_Identifier : Unsigned_Long_Long := 0;
Protocol_Identifier : Unsigned_Long_Long := 0;
Global_Port_Identifier : Unsigned_Long_Long := 0;
Local_Port_Identifier : Unsigned_Long_Long := 0;
Entity_Identifier : Unsigned_Long_Long := 0;
......@@ -181,6 +185,7 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
Nb_Entities_Node : Node_Id := No_Node;
Nb_Devices_Node : Node_Id := No_Node;
Nb_Buses_Node : Node_Id := No_Node;
Nb_Protocols_Node : Node_Id := No_Node;
-- The information from Simulink can come
-- from both data and subprograms. So, to avoid
......@@ -283,6 +288,9 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
when CC_Bus =>
Visit_Bus_Instance (E);
when CC_Virtual_Bus =>
Visit_Virtual_Bus_Instance (E);
when others =>
null;
end case;
......@@ -313,6 +321,38 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
end Visit_Bus_Instance;
--------------------------------
-- Visit_Virtual_Bus_Instance --
--------------------------------
procedure Visit_Virtual_Bus_Instance (E : Node_Id) is
N : Node_Id;
begin
if Backend_Node (Identifier (E)) /= No_Node and then
CTN.Naming_Node (Backend_Node (Identifier (E))) /= No_Node then
return;
end if;
N := Make_Expression
(Make_Defining_Identifier
(Map_C_Enumerator_Name (E)),
Op_Equal,
(Make_Literal
(CV.New_Int_Value (Protocol_Identifier, 1, 10))));
Append_Node_To_List
(N, Protocol_List);
Protocol_Identifier := Protocol_Identifier + 1;
CTN.Set_Value
(Nb_Protocols_Node, New_Int_Value
(Protocol_Identifier, 1, 10));
Bind_AADL_To_Naming
(Identifier (E),
Make_Defining_Identifier
(Map_C_Enumerator_Name (E)));
end Visit_Virtual_Bus_Instance;
---------------------------
-- Visit_Device_Instance --
---------------------------
......@@ -787,6 +827,13 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
if AAU.Is_Process (Parent)
and then Parent /= E
then
if Get_Provided_Virtual_Bus_Class
(Extra_Item (Src)) /= No_Node then
Visit
(Get_Provided_Virtual_Bus_Class
(Extra_Item (Src)));
end if;
Set_Added (Parent, E);
-- Traverse all the subcomponents of Parent
......@@ -834,6 +881,13 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
if AAU.Is_Process (Parent)
and then Parent /= E
then
if Get_Provided_Virtual_Bus_Class
(Extra_Item (Dst)) /= No_Node then
Visit
(Get_Provided_Virtual_Bus_Class
(Extra_Item (Dst)));
end if;
Set_Added (Parent, E);
if not AAU.Is_Empty (Subcomponents (Parent)) then
......@@ -1066,6 +1120,28 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
Append_Node_To_List (N, CTN.Declarations (Current_File));
end if;
if not Is_Empty (Protocol_List) then
if not Invalid_Protocol_Added then
Set_Str_To_Name_Buffer ("invalid_protocol_t");
N := Make_Expression
(Make_Defining_Identifier
(Name_Find),
Op_Equal,
(Make_Literal
(CV.New_Int_Value (1, -1, 10))));
Append_Node_To_List
(N, Protocol_List);
Invalid_Protocol_Added := True;
end if;
N := Make_Full_Type_Declaration
(Defining_Identifier => RE (RE_Protocol_T),
Type_Definition => Make_Enum_Aggregate
(Protocol_List));
Append_Node_To_List (N, CTN.Declarations (Current_File));
end if;
if not Is_Empty (CTN.Values (Global_Port_To_Local)) then
Bind_AADL_To_Local_Port (Identifier (S), Global_Port_To_Local);
end if;
......@@ -1118,6 +1194,12 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
Append_Node_To_List
(N, CTN.Declarations (Current_File));
N := Make_Define_Statement
(Defining_Identifier => RE (RE_Nb_Protocols),
Value => Nb_Protocols_Node);
Append_Node_To_List
(N, CTN.Declarations (Current_File));
Current_Process_Instance := No_Node;
Pop_Entity; -- U
......@@ -1143,6 +1225,7 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
Devices_Enumerator_List := New_List (CTN.K_Enumeration_Literals);
Buses_Enumerator_List := New_List (CTN.K_Enumeration_Literals);
Global_Port_List := New_List (CTN.K_Enumeration_Literals);
Protocol_List := New_List (CTN.K_Enumeration_Literals);
Global_Port_Names := Make_Array_Values;
Global_Port_Model_Names := Make_Array_Values;
Global_Port_Kind := Make_Array_Values;
......@@ -1161,6 +1244,8 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
(New_Int_Value (0, 1, 10));
Nb_Buses_Node := Make_Literal
(New_Int_Value (0, 1, 10));
Nb_Protocols_Node := Make_Literal
(New_Int_Value (0, 1, 10));
Entity_Array := Make_Array_Values;
Device_Id := 0;
......
......@@ -160,6 +160,7 @@ package Ocarina.Backends.PO_HI_C.Runtime is
RE_Nb_Nodes, -- __PO_HI_NB_NODES
RE_Nb_Devices, -- __PO_HI_NB_DEVICES
RE_Nb_Buses, -- __PO_HI_NB_BUSES
RE_Nb_Protocols, -- __PO_HI_NB_PROTOCOLS
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
......@@ -213,6 +214,7 @@ package Ocarina.Backends.PO_HI_C.Runtime is
RE_Float64_T, -- __po_hi_float64_t
RE_Msg_T, -- __po_hi_msg_t
RE_Port_T, -- __po_hi_port_t
RE_Protocol_T, -- __po_hi_protocol_t
RE_Local_Port_T, -- __po_hi_local_port_t
RE_Node_T, -- __po_hi_node_t
......@@ -334,6 +336,7 @@ package Ocarina.Backends.PO_HI_C.Runtime is
RE_Entity_T => RH_Deployment,
RE_Local_Port_T => RH_Deployment,
RE_Port_T => RH_Deployment,
RE_Protocol_T => RH_Deployment,
RE_Entity_Server_T => RH_Deployment,
RE_Protected_T => RH_PO_HI_Protected,
RE_Inetport_T => RH_PO_HI_Transport,
......@@ -370,6 +373,7 @@ package Ocarina.Backends.PO_HI_C.Runtime is
RE_Nb_Nodes => RH_Deployment,
RE_Nb_Devices => RH_Deployment,
RE_Nb_Buses => RH_Deployment,
RE_Nb_Protocols => RH_Deployment,
RE_My_Node => RH_Deployment,
RE_Nb_Ports => RH_Deployment,
RE_Nb_Servers => RH_Deployment,
......
......@@ -34,6 +34,8 @@
with GNAT.OS_Lib;
with Output;
with GNAT.Directory_Operations;
with Ocarina.Instances;
with Ocarina.Backends.Expander;
with Ocarina.Backends.Messages;
......@@ -70,6 +72,8 @@ package body Ocarina.Backends.PO_HI_C is
use Namet;
use Output;
use GNAT.Directory_Operations;
use Ocarina.Backends.Properties;
use Ocarina.ME_AADL;
use Ocarina.ME_AADL.AADL_Instances.Nodes;
......@@ -151,7 +155,32 @@ package body Ocarina.Backends.PO_HI_C is
C_Sources,
Ada_Sources,
C_Libraries);
O_File : Name_Id;
begin
if Use_Asn1_Deployment then
Write_Str ("ASN_OBJS += asn1_deployment.o ");
if Length (Asn_Sources) > 0 then
for J in
Name_Tables.First .. Name_Tables.Last (Asn_Sources) loop
Get_Name_String (Asn_Sources.Table (J));
Name_Buffer (Name_Len - 2) := 'o';
Set_Str_To_Name_Buffer
(Base_Name (Name_Buffer (1 .. Name_Len - 2)));
O_File := Name_Find;
Write_Str ("");
Write_Name (O_File);
exit when J = Name_Tables.Last (Asn_Sources);
Write_Space;
end loop;
end if;
Write_Eol;
end if;
if Appli_Name /= No_Name then
Write_Str ("MAINAPP = ");
Write_Name (Appli_Name);
......
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