Commit 77748e66 authored by julien.delange's avatar julien.delange

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

   - Add extern declaration of configuration variables
     of devices in deployment files

 * ocarina/src/backends/ocarina-backends-build_utils.adb
   - Add the file that contains the configuration variable
     in the list of files to be compiled

 * ocarina/src/backends/ocarina-backends-po_hi_c-runtime.ads
   - Add RE_Devices_Configuration_Values that is an array
     that contains a reference to the variable
     that contain device configuration

 * ocarina/src/backends/ocarina-backends-c_common-mapping.adb
   ocarina/src/backends/ocarina-backends-c_common-mapping.ads
   - Add Map_Device_Confvar_Name to define the name of the
     configuration variable of a device



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/ocarina@2034 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent b84c3ac2
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2008-2010, GET-Telecom Paris. -- -- Copyright (C) 2008-2011, European Space Agency (ESA). --
-- -- -- --
-- Ocarina is free software; you can redistribute it and/or modify -- -- Ocarina is free software; you can redistribute it and/or modify --
-- it under terms of the GNU General Public License as published by the -- -- it under terms of the GNU General Public License as published by the --
...@@ -538,7 +538,7 @@ package body Ocarina.Backends.Build_Utils is ...@@ -538,7 +538,7 @@ package body Ocarina.Backends.Build_Utils is
Set_Name_Table_Byte (Name_Find, 1); Set_Name_Table_Byte (Name_Find, 1);
end if; end if;
elsif Source_Files'Length /= 0 and then Implem_Name /= No_Name then elsif Source_Files'Length /= 0 then
for J in Source_Files'Range loop for J in Source_Files'Range loop
-- Ensure the source is added only once per node -- Ensure the source is added only once per node
...@@ -674,10 +674,14 @@ package body Ocarina.Backends.Build_Utils is ...@@ -674,10 +674,14 @@ package body Ocarina.Backends.Build_Utils is
---------------------------- ----------------------------
procedure Visit_Process_Instance (E : Node_Id) is procedure Visit_Process_Instance (E : Node_Id) is
C : Node_Id;
S : constant Node_Id := Parent_Subcomponent (E); S : constant Node_Id := Parent_Subcomponent (E);
A : constant Node_Id := Parent_Component (Parent_Subcomponent (E)); A : constant Node_Id := Parent_Component (Parent_Subcomponent (E));
M : constant Makefile_Type := new Makefile_Rec; M : constant Makefile_Type := new Makefile_Rec;
SC : Node_Id; SC : Node_Id;
Current_Device : Node_Id;
The_System : constant Node_Id := Parent_Component
(Parent_Subcomponent (E));
begin begin
-- Associates the Makefile structure to the process -- Associates the Makefile structure to the process
-- instance. Keep in mind that it is important to use -- instance. Keep in mind that it is important to use
...@@ -727,6 +731,27 @@ package body Ocarina.Backends.Build_Utils is ...@@ -727,6 +731,27 @@ package body Ocarina.Backends.Build_Utils is
SC := Next_Node (SC); SC := Next_Node (SC);
end loop; end loop;
end if; end if;
-- We look for devices bound to the same processor
-- than the current process to find the file
-- that contains the configuration of the device.
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)) then
Current_Device := Corresponding_Instance (C);
declare
Source_Files : constant Name_Array
:= Get_Source_Text (Current_Device);
begin
Handle_C_Source
(Current_Device, No_Name, Source_Files, M);
end;
end if;
C := Next_Node (C);
end loop;
end if;
end Visit_Process_Instance; end Visit_Process_Instance;
--------------------------- ---------------------------
......
...@@ -4095,4 +4095,23 @@ package body Ocarina.Backends.C_Common.Mapping is ...@@ -4095,4 +4095,23 @@ package body Ocarina.Backends.C_Common.Mapping is
return No_Name; return No_Name;
end Map_Devices_Buses_Array_Name; end Map_Devices_Buses_Array_Name;
-----------------------------
-- Map_Device_Confvar_Name --
-----------------------------
function Map_Device_Confvar_Name
(E : Node_Id)
return Name_Id
is
begin
if AINU.Is_Device (E) then
Set_Str_To_Name_Buffer ("__po_hi_c_confvar_");
Get_Name_String_And_Append
(AIN.Name
(AIN.Identifier (Parent_Subcomponent (E))));
return Name_Find;
end if;
return No_Name;
end Map_Device_Confvar_Name;
end Ocarina.Backends.C_Common.Mapping; end Ocarina.Backends.C_Common.Mapping;
...@@ -389,8 +389,12 @@ package Ocarina.Backends.C_Common.Mapping is ...@@ -389,8 +389,12 @@ package Ocarina.Backends.C_Common.Mapping is
-- * POK_NEEDS_PROTOCOLS_BLOWFISH -- * POK_NEEDS_PROTOCOLS_BLOWFISH
-- * POK_NEEDS_PROTOCOLS_DES -- * POK_NEEDS_PROTOCOLS_DES
function Map_Devices_Buses_Array_Name function Map_Devices_Buses_Array_Name (E : Node_Id) return Name_Id;
(E : Node_Id) -- Provide function to create the name of the array that contains
return Name_Id; -- all accessed buses for a specific device.
function Map_Device_Confvar_Name (E : Node_Id) return Name_Id;
-- Map the device identifier name into a variable name
-- that is supposed to contain the device configuration.
end Ocarina.Backends.C_Common.Mapping; end Ocarina.Backends.C_Common.Mapping;
...@@ -73,6 +73,7 @@ package body Ocarina.Backends.PO_HI_C.Deployment is ...@@ -73,6 +73,7 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
Entity_Array : Node_Id; Entity_Array : Node_Id;
Devices_Array : Node_Id; Devices_Array : Node_Id;
Devices_Nb_Buses_Array : Node_Id; Devices_Nb_Buses_Array : Node_Id;
Devices_Confvars : Node_Id;
Devices_Buses_Array : Node_Id; Devices_Buses_Array : Node_Id;
Port_To_Devices : Node_Id; Port_To_Devices : Node_Id;
...@@ -324,6 +325,8 @@ package body Ocarina.Backends.PO_HI_C.Deployment is ...@@ -324,6 +325,8 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
Nb_Connected_Buses : Unsigned_Long_Long; Nb_Connected_Buses : Unsigned_Long_Long;
Accessed_Buses : constant Node_Id := Make_Array_Values; Accessed_Buses : constant Node_Id := Make_Array_Values;
Accessed_Bus : Node_Id; Accessed_Bus : Node_Id;
Device_Implementation : Node_Id;
Configuration_Data : Node_Id;
The_System : constant Node_Id := Parent_Component The_System : constant Node_Id := Parent_Component
(Parent_Subcomponent (E)); (Parent_Subcomponent (E));
begin begin
...@@ -523,6 +526,106 @@ package body Ocarina.Backends.PO_HI_C.Deployment is ...@@ -523,6 +526,106 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
(Make_Literal (Make_Literal
(CV.New_Int_Value (Nb_Connected_Buses, 1, 10)), (CV.New_Int_Value (Nb_Connected_Buses, 1, 10)),
CTN.Values (Devices_Nb_Buses_Array)); CTN.Values (Devices_Nb_Buses_Array));
if Is_Defined_Property (E, "source_text") then
Append_Node_To_List
(Make_Variable_Address
(Make_Defining_Identifier (Map_Device_Confvar_Name (E))),
CTN.Values (Devices_Confvars));
Set_Deployment_Source;
Device_Implementation := Get_Implementation (Current_Device);
if Is_Defined_Property
(Device_Implementation, "taste::configuration_type") then
Configuration_Data
:= Get_Classifier_Property
(Device_Implementation, "taste::configuration_type");
if Configuration_Data /= No_Node and then
Is_Defined_Property
(Configuration_Data, "type_source_name") then
-- Here, we browse all the process components
-- of the root system to declare external
-- variable that contain the configuration
-- of the device.
Q := First_Node (Subcomponents (The_System));
while Present (Q) loop
if AAU.Is_Process (Corresponding_Instance (Q)) then
U := CTN.Distributed_Application_Unit
(CTN.Naming_Node
(Backend_Node
(Identifier
(Corresponding_Instance (Q)))));
P := CTN.Entity (U);
Push_Entity (P);
Push_Entity (U);
Set_Deployment_Source;
N := Make_Extern_Entity_Declaration
(Make_Variable_Declaration
(Defining_Identifier =>
Make_Defining_Identifier
(Map_Device_Confvar_Name (E)),
Used_Type =>
Make_Pointer_Type
(Make_Defining_Identifier
(Get_String_Property
(Configuration_Data,
"type_source_name")))));
Append_Node_To_List
(N, CTN.Declarations (Current_File));
declare
ST : constant Name_Array
:= Get_Source_Text (Configuration_Data);
Include_Name : Name_Id;
begin
Set_Deployment_Header;
if ST'Length /= 1 then
Display_Error
("Source_Text property of " &
"configuration data" &
" must have only one element " &
"(the header file).",
Fatal => True);
end if;
Get_Name_String (ST (1));
if Name_Len <= 2 then
Display_Error
("Name of Source_Text of " &
"configuration data" &
"must be longer than 2 chars.",
Fatal => True);
end if;
Include_Name := Get_String_Name
(Name_Buffer (1 .. Name_Len - 2));
Add_Include
(Make_Include_Clause
(Make_Defining_Identifier
(Include_Name)));
end;
Pop_Entity;
Pop_Entity;
end if;
Q := Next_Node (Q);
end loop;
end if;
end if;
Set_Deployment_Header;
else
Append_Node_To_List
(Make_Defining_Identifier (CONST (C_Null),
C_Conversion => False),
CTN.Values (Devices_Confvars));
end if;
end if; end if;
Current_Device := No_Node; Current_Device := No_Node;
end Visit_Device_Instance; end Visit_Device_Instance;
...@@ -598,8 +701,7 @@ package body Ocarina.Backends.PO_HI_C.Deployment is ...@@ -598,8 +701,7 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
Current_Device := Corresponding_Instance (C); Current_Device := Corresponding_Instance (C);
Device_Implementation := Device_Implementation := Get_Implementation (Current_Device);
Get_Implementation (Corresponding_Instance (C));
if Device_Implementation /= No_Node then if Device_Implementation /= No_Node then
if not AAU.Is_Empty if not AAU.Is_Empty
...@@ -1014,6 +1116,7 @@ package body Ocarina.Backends.PO_HI_C.Deployment is ...@@ -1014,6 +1116,7 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
Devices_Array := Make_Array_Values; Devices_Array := Make_Array_Values;
Devices_Nb_Buses_Array := Make_Array_Values; Devices_Nb_Buses_Array := Make_Array_Values;
Devices_Confvars := Make_Array_Values;
Devices_Buses_Array := Make_Array_Values; Devices_Buses_Array := Make_Array_Values;
Port_To_Devices := Make_Array_Values; Port_To_Devices := Make_Array_Values;
...@@ -1705,6 +1808,26 @@ package body Ocarina.Backends.PO_HI_C.Deployment is ...@@ -1705,6 +1808,26 @@ package body Ocarina.Backends.PO_HI_C.Deployment is
Append_Node_To_List (N, CTN.Declarations (Current_File)); Append_Node_To_List (N, CTN.Declarations (Current_File));
end if; end if;
-- Here, we define an array that contains reference
-- to all configuration variables.
if not Is_Empty (CTN.Values (Devices_Confvars)) then
N := Make_Expression
(Left_Expr =>
Make_Variable_Declaration
(Defining_Identifier =>
Make_Array_Declaration
(Defining_Identifier =>
RE (RE_Devices_Configuration_Values),
Array_Size =>
RE (RE_Nb_Devices)),
Used_Type =>
Make_Pointer_Type (RE (RE_Uint32_T))),
Operator => Op_Equal,
Right_Expr => Devices_Confvars);
Append_Node_To_List (N, CTN.Declarations (Current_File));
end if;
-- In the following, we add arrays previously filled arrays -- In the following, we add arrays previously filled arrays
-- in the header part of the package. These arrays describe -- in the header part of the package. These arrays describe
-- the number of buses accessed by each device and which -- the number of buses accessed by each device and which
......
...@@ -204,6 +204,7 @@ package Ocarina.Backends.PO_HI_C.Runtime is ...@@ -204,6 +204,7 @@ package Ocarina.Backends.PO_HI_C.Runtime is
RE_Operation_Names, -- __po_hi_operation_names RE_Operation_Names, -- __po_hi_operation_names
RE_Ports_Names, -- __po_hi_port_names RE_Ports_Names, -- __po_hi_port_names
RE_Devices_Naming, -- __po_hi_devices_naming RE_Devices_Naming, -- __po_hi_devices_naming
RE_Devices_Configuration_Values, -- __po_hi_devices_configuration_...
RE_Devices_Nb_Accessed_Buses, -- __po_hi_devices_nb_accessed_buses RE_Devices_Nb_Accessed_Buses, -- __po_hi_devices_nb_accessed_buses
RE_Devices_Accessed_Buses, -- __po_hi_devices_accessed_buses RE_Devices_Accessed_Buses, -- __po_hi_devices_accessed_buses
RE_Protected_Configuration, -- __po_hi_protected_configuration RE_Protected_Configuration, -- __po_hi_protected_configuration
...@@ -379,6 +380,7 @@ package Ocarina.Backends.PO_HI_C.Runtime is ...@@ -379,6 +380,7 @@ package Ocarina.Backends.PO_HI_C.Runtime is
RE_Ports_Names => RH_PO_HI_Types, RE_Ports_Names => RH_PO_HI_Types,
RE_Devices_Naming => RH_Deployment, RE_Devices_Naming => RH_Deployment,
RE_Devices_Configuration_Values => RH_Deployment,
RE_Devices_Nb_Accessed_Buses => RH_Deployment, RE_Devices_Nb_Accessed_Buses => RH_Deployment,
RE_Devices_Accessed_Buses => RH_Deployment, RE_Devices_Accessed_Buses => RH_Deployment,
RE_Port_To_Device => RH_Deployment, RE_Port_To_Device => RH_Deployment,
......
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