Commit d6db2ef7 authored by Maxime Perrotin's avatar Maxime Perrotin

Add support for driver configuration in distributed systems

parent d53b2816
......@@ -65,7 +65,6 @@ package body TASTE.Backend.Code_Generators is
Tmplt : constant String := Prefix_Skeletons
& "makefile.tmplt";
begin
Register_Filter ("COUCOU", My_Custom_Filter'Access);
if not Exists (Tmplt) then
raise ACG_Error with "Missing makefile.tmplt";
end if;
......
......@@ -537,6 +537,13 @@ package body TASTE.Concurrency_View is
Device_ASN1_Filename,
Device_ASN1_Typename,
Device_ASN1_Module : Vector_Tag; -- Device drivers
-- To keep a list of ASN.1 files/modules without duplicates:
Unique_ASN1_Sorts_Set : String_Sets.Set;
Unique_ASN1_Files,
Unique_ASN1_Sorts,
Unique_ASN1_Modules : Vector_Tag;
Connect_From_Partition, -- Partition to bus connections
Connect_Port_Name,
Connect_Via_Bus : Vector_Tag;
......@@ -716,6 +723,18 @@ package body TASTE.Concurrency_View is
Device_ASN1_Typename :=
Device_ASN1_Typename & D.ASN1_Typename;
Device_ASN1_Module := Device_ASN1_Module & D.ASN1_Module;
-- Update list of types and files without duplicates
if not Unique_ASN1_Sorts_Set.Contains
(Strip_String (To_String (D.ASN1_Typename)))
then
Unique_ASN1_Sorts_Set.Insert
(Strip_String (To_String (D.ASN1_Typename)));
Unique_ASN1_Sorts := Unique_ASN1_Sorts & D.ASN1_Typename;
Unique_ASN1_Modules :=
Unique_ASN1_Modules & D.ASN1_Module;
Unique_ASN1_Files := Unique_ASN1_Files & D.ASN1_Filename;
end if;
end loop;
end loop;
......@@ -756,6 +775,9 @@ package body TASTE.Concurrency_View is
& Assoc ("Device_ASN1_File", Device_ASN1_Filename)
& Assoc ("Device_ASN1_Sort", Device_ASN1_Typename)
& Assoc ("Device_ASN1_Module", Device_ASN1_Module)
& Assoc ("Unique_Dev_ASN1_Files", Unique_ASN1_Files)
& Assoc ("Unique_Dev_ASN1_Mod", Unique_ASN1_Modules)
& Assoc ("Unique_Dev_ASN1_Sorts", Unique_ASN1_Sorts)
& Assoc ("Connect_From_Part", Connect_From_Partition)
& Assoc ("Connect_Via_Bus", Connect_Via_Bus)
& Assoc ("Connect_Port_Name", Connect_Port_Name);
......
......@@ -83,13 +83,52 @@ package body TASTE.Parser_Utils is
return Ada.Strings.Fixed.Trim (Input_String, Strip_Set, Strip_Set);
end Strip_String;
function My_Custom_Filter
-- str.join as in Python - join string arrays with a separator
function Join_Strings (Str_Set : String_Sets.Set;
Sep : String := ", ";
C : String_Sets.Cursor :=
String_Sets.No_Element)
return String
is
use String_Sets;
begin
return
(if C = String_Sets.No_Element then "" else
(if C /= Str_Set.First then Sep else "")
& String_Sets.Element (C)
& Join_Strings
(Str_Set => Str_Set,
C => String_Sets.Next (C),
Sep => Sep));
end Join_Strings;
function Filter_Uniq
(Value, Parameters : String;
dummy_Context : Filter_Context) return String is
unused_Context : Filter_Context) return String
-- Value is the tag name (list ), and Parameter must be a separator
is
use String_Sets, Ada.Strings.Fixed;
Unique_Set : String_Sets.Set;
Nb : constant Natural :=
Ada.Strings.Fixed.Count (Value, Parameters);
From : Natural := Value'First;
To : Natural;
begin
Put_Debug (Parameters & " - " & Value);
return Value;
end My_Custom_Filter;
if Nb = 0 then
Unique_Set.Insert (Value);
else
for I in 0 .. Nb loop
To := Index (Value, Parameters, From => From);
if To = 0 then
To := Value'Last + 1;
end if;
Unique_Set.Union (To_Set (Strip_String (Value (From .. To - 1))));
From := To + 1;
end loop;
end if;
return Join_Strings
(Unique_Set, Sep => Parameters, C => Unique_Set.First);
end Filter_Uniq;
procedure Parse_Command_Line (Result : out Taste_Configuration) is
Config : Command_Line_Configuration;
......@@ -360,5 +399,6 @@ package body TASTE.Parser_Utils is
Insert (Result, S2);
return Result;
end Join_Sets;
begin
Register_Filter ("UNIQ", Filter_Uniq'Access);
end TASTE.Parser_Utils;
......@@ -75,9 +75,13 @@ package TASTE.Parser_Utils is
package String_Holders is new Indefinite_Holders (String);
function My_Custom_Filter
-- Custom filters for Templates_Parser
-- Return a list without duplicates
-- @_UNIQ(separator):Tag_@
function Filter_Uniq
(Value, Parameters : String;
dummy_Context : Filter_Context) return String;
unused_Context : Filter_Context) return String;
-- Generate documentation for a translate set
procedure Document_Template (Source_Folder, Template_Name : String;
......
......@@ -32,6 +32,9 @@
@@-- @_Device_ASN1_File_@
@@-- @_Device_ASN1_Sort_@
@@-- @_Device_ASN1_Module_@ : Device drivers (vector tag)
@@-- @_Unique_Dev_ASN1_Files_@ : List of ASN.1 files/module/type for device configuration with no duplicates (vector tag)
@@-- @_Unique_Dev_ASN1_Mod_@ |_ corresponding asn1 module
@@-- @_Unique_Dev_ASN1_Sorts_@ |_ type name
@@-- @_Connect_From_Part_@ : Vector tag - bus connection: partition source
@@-- @_Connect_Via_Bus_@ |_ bus name
@@-- @_Connect_Port_Name_@ |_ port name
......
......@@ -16,9 +16,28 @@
@@-- @_Part_Source_Name_@ : Inter-partition connections : partition source name (vector tag)
@@-- @_Part_Source_Port_@ : |_ Corresponding port name
@@-- @_Part_Dest_Name_@ : |_ Corresponding name of the remote partition
@@-- @_Part_Dest_Port_@ : |_ Corresponding name of the port on the remote partition
@@-- @_Bus_Names_@ : Vector tag: busses present in the system
@@-- @_Bus_AADL_Package_@ : |_ corresponding AADL Package
@@-- @_Bus_Classifier_@ : |_ corresponding AADL classifier
@@-- @_Device_Names_@
@@-- @_Device_Node_Name_@
@@-- @_Device_Partition_@ -- Partition name associated to the driver (currently only one supported per node)
@@-- @_Device_AADL_Pkg_@
@@-- @_Device_Classifier_@
@@-- @_Device_CPU_@
@@-- @_Device_Config_@
@@-- @_Device_Bus_Name_@
@@-- @_Device_Port_Name_@
@@-- @_Device_ASN1_File_@
@@-- @_Device_ASN1_Sort_@
@@-- @_Device_ASN1_Module_@ : Device drivers (vector tag)
@@-- @_Unique_Dev_ASN1_Files_@ : List of ASN.1 files/module/type for device configuration with no duplicates (vector tag)
@@-- @_Unique_Dev_ASN1_Mod_@ |_ corresponding asn1 module
@@-- @_Unique_Dev_ASN1_Sorts_@ |_ type name
@@-- @_Connect_From_Part_@ : Vector tag - bus connection: partition source
@@-- @_Connect_Via_Bus_@ |_ bus name
@@-- @_Connect_Port_Name_@ |_ port name
@@-- And all the system configuration obtained from the command line:
@@-- Interface_View, Deployment_View, Data_View, Binary_Path, Check_Data_View,
@@-- Output_Dir, Skeletons, Glue, Use_POHIC, Timer_Resolution, Debug_Flag,
......@@ -68,6 +87,13 @@ air:
make -j -f Makefile.air && mkdir -p ../binaries && cp deploymentview_final/executable/* ../binaries
@@END_TABLE@@
@@-- If there are busses, there are drivers, and therefore asn1 configurations
@@IF@@ @_Bus_Names'Length_@ > 0
DriversConfig/drivers_config.h: drivers_config.asn
mkdir -p DriversConfig
asn1.exe -o DriversConfig -c drivers_config.asn @_REPLACE_ALL(,/ ):UNIQ(,):Device_ASN1_File_@
@@END_IF@@
@_Nodes_@
clean:
......
@@-- The following tags are available in this template:
@@--
@@-- @_Name_@ : Protected block name
@@-- @_Language_@ : Implementation language
@@-- @_Calling_Threads_@ : List of calling threads
@@-- @_Node name_@ : Node name
@@-- @_Protected_PIs_@ : Protected Provided interfaces (from pi.tmplt)
@@-- @_Unprotected_PIs_@ : Unprotected Provided interfaces (from pi.tmplt)
@@-- @_Required_@ : Required interfaces (from ri.tmplt)
@@-- And all the system configuration obtained from the command line:
@@-- Interface_View, Deployment_View, Data_View, Binary_Path, Check_Data_View,
@@-- Output_Dir, Skeletons, Glue, Use_POHIC, Timer_Resolution, Debug_Flag,
@@-- No_Stdlib_Flag, Timer_Resolution, Other_Files (list of aadl files)
@@-- Specify the file name for a protected block
@@-- @_Block_Name_@ is available.
@@-- Don't specify anything if you don't want the file to be created
@@-- The following tags are available in this template:
@@--
@@-- @_Node_Name_@ : Name of the node as defined in the Deployment View
@@-- The content of this file is generated from node.tmplt
@@-- If there is no string defined here, no file will be generated per node,
@@-- (that's an option if the intent is to generate only one file per system)
@@-- Specify the file name for a partition
@@-- @_Partition_Name_@ is available.
@@-- Don't specify anything if you don't want the file to be created
@@-- Specify the file name for the complete system (including nodes)
@@-- (no template tag)
drivers_config.asn
@@-- Specify the file name for a thread
@@-- @_Thread_Name_@ is available.
@@-- Don't specify anything if you don't want the file to be created
@@-- The following tags are available in this template:
@@--
@@-- @_Node_Name_@ : Name of the node from deployment view
@@-- @_Partition_Names_@ : Tag listing the partitions in this node
@@-- @_Has_Memory_@ : Boolean flag indicating that a memory is defined for this node
@@-- @_Partitions_@ : List of rendered code for partitions
@@-- @_VP_Names_@ : Vector tag: list of virtual processors on this node
@@-- VP_Package_Names : |_ Corresponding package name
@@-- VP_Platforms : |_ Corresponding platform name
@@-- VP_Classifiers : |_ Corresponding aadl classifier
@@-- @_CPU_Name_@, _Family_@, Instance_@, _Platform_@, _Classifier_@, _Ada_Runtime_@ : Info about CPU
@@-- Test if the node contains several partitions (virtual processors)
@@-- If that's the case we need to generate a new AADL processor for TSP support
@@-- The following tags are available in this template:
@@--
@@-- @_Name_@ : Partition name (usually the name of the binary)
@@-- @_Threads_@ : Code generated for the threads
@@-- @_Thread_Names_@ : Tag: list of thread names
@@-- @_Node_Name_@ : Name of the node containing this partition
@@-- @_Blocks_@ : Code generated for protected functions
@@-- @_Block_Names@ : Tag: list of block (user functions) names
@@-- @_Coverage_@ : True if user requested code coverage enable
@@-- @_Package_Name_@ : AADL Package name for the target (e.g. ocarina_porocessors_x86)
@@-- @_CPU_Name_@ : CPU AADL Identifier (e.g. x86_inst)
@@-- @_CPU_Family_@ : CPU Kind (e.g. leon3)
@@-- @_CPU_Instance_@ : AADL component instance (e.g. rtems_posix)
@@-- @_CPU_Platform_@ : AADL CPU_Platform (e.g. PLATFORM_NATIVE)
@@-- @_CPU_Classifier_@ : AADL CPU Classifier (e.g. ocarina_processors_x86::x86.linux)
@@-- @_VP_Name_@ : Virtual processor name on which the partition is bounded
@@-- @_VP_Platform_@ : Virtual processor platform (e.g. PLATFORM_AIR)
@@-- @_VP_Classifier_@ : Virtual processor classifier
@@-- @_Bound_Functions_@ : List of user functions from Interface view
@@-- @_Thread_Src_Name_@ : Vector tag : connection thread name (source)
@@-- @_Thread_Dst_Name_@ : Vector tag : connection thread name (dest)
@@-- @_Thread_Src_Port_@ : Vector tag : connection port name (source)
@@-- @_Thread_Dst_Port_@ : Vector tag : connection port name (dest)
@@-- @_In_Port_Names_@ : Vector tag: input ports of the partition
@@-- @_In_Port_Thread_Name_@ : |_ corresponding thread inside the partition
@@-- @_In_Port_Type_Name_@ : |_ corresponding parameter type name (optional)
@@-- @_Out_Port_Names_@ : Vector tag: output ports of the partition
@@-- @_Out_Port_Type_Name_@ : |_ corresponding parameter type name (optional)
@@-- @_Part_Out_Port_Name_@ : Vector tag: output ports of the partition (can be several times the same)
@@-- @_Connected_Threads_@ : |_ Corresponding thread connected to it
@@-- The following tags are available in this template:
@@--
@@-- @_Name_@ : The name of the interface
@@-- @_Direction_@ : "PI" or "RI"
@@-- @_Kind_@ : The RCM Kind
@@-- @_Parent_Function_@ : The name of the function
@@-- @_Param_Names_@ : List of parameter names
@@-- @_Param_Types_@ : |_ Corresponding parameter types
@@-- @_Param_Directions_@ : |_ Corresponding direction
true
@@-- The following tags are available in this template:
@@--
@@-- @_Name_@ : The name of the interface
@@-- @_Direction_@ : "PI" or "RI"
@@-- @_Kind_@ : The RCM Kind
@@-- @_Parent_Function_@ : The name of the function
@@-- @_Param_Names_@ : List of parameter names
@@-- @_Param_Types_@ : |_ Corresponding parameter types
@@-- @_Param_Directions_@ : |_ Corresponding direction
@@-- The following tags are available in this template:
@@--
@@-- @_Nodes_@ : Code generated for the nodes
@@-- @_Node_Names_@ : Vector Tag of node names
@@-- @_Node_CPU_@ : |_ Corresponding CPU name (eg x86_linux)
@@-- @_Node_CPU_Classifier_@ : |_ CPU Classifier (ocarina...::x86_linux)
@@-- @_Node_Major_Frame_@ : |_ Time in milliseconds allocated to the CPU (TSP only)
@@-- @_Partition_Names_@ : Vector Tag of partition names
@@-- @_Partition_Node_@ : |_ Corresponding node name
@@-- @_Partition_CPU_@ : |_ Corresponding CPU name
@@-- @_Partition_Duration_@ : |_ Corresponding time allocation (TSP only)
@@-- @_Partition_VP_@ : |_ Virtual processor binding (TSP only)
@@-- @_Threads_@ : Code generated for the threads
@@-- @_Thread_Names_@ : List of all threads in the complete system
@@-- @_Target_Packages_@ : List of all target package names in the complete system
@@-- @_Part_Source_Name_@ : Inter-partition connections : partition source name (vector tag)
@@-- @_Part_Source_Port_@ : |_ Corresponding port name
@@-- @_Part_Dest_Name_@ : |_ Corresponding name of the remote partition
@@-- @_Part_Dest_Port_@ : |_ Corresponding name of the port on the remote partition
@@-- @_Bus_Names_@ : Vector tag: busses present in the system
@@-- @_Bus_AADL_Package_@ : |_ corresponding AADL Package
@@-- @_Bus_Classifier_@ : |_ corresponding AADL classifier
@@-- @_Device_Names_@
@@-- @_Device_Node_Name_@
@@-- @_Device_Partition_@ -- Partition name associated to the driver (currently only one supported per node)
@@-- @_Device_AADL_Pkg_@
@@-- @_Device_Classifier_@
@@-- @_Device_CPU_@
@@-- @_Device_Config_@
@@-- @_Device_Bus_Name_@
@@-- @_Device_Port_Name_@
@@-- @_Device_ASN1_File_@
@@-- @_Device_ASN1_Sort_@
@@-- @_Device_ASN1_Module_@ : Device drivers (vector tag)
@@-- @_Unique_Dev_ASN1_Files_@ : List of ASN.1 files/module/type for device configuration with no duplicates (vector tag)
@@-- @_Unique_Dev_ASN1_Mod_@ |_ corresponding asn1 module
@@-- @_Unique_Dev_ASN1_Sorts_@ |_ type name
@@-- @_Connect_From_Part_@ : Vector tag - bus connection: partition source
@@-- @_Connect_Via_Bus_@ |_ bus name
@@-- @_Connect_Port_Name_@ |_ port name
@@-- And all the system configuration obtained from the command line:
@@-- Interface_View, Deployment_View, Data_View, Binary_Path, Check_Data_View,
@@-- Output_Dir, Skeletons, Glue, Use_POHIC, Timer_Resolution, Debug_Flag,
@@-- No_Stdlib_Flag, Timer_Resolution, Other_Files (list of aadl files)
-- Configuration data for device drivers in distributed systems
-- This file was generated automatically by taste/kazoo
@@IF@@ @_Bus_Names'Length_@ > 0
Taste-Drivers-Configuation DEFINITIONS ::=
BEGIN
@@INLINE(IMPORTS )(\n )(;)@@
@@TABLE@@
@_Unique_Dev_ASN1_Sorts_@ FROM @_Unique_Dev_ASN1_Mod_@
@@END_TABLE@@
@@END_INLINE@@
@@TABLE@@
pohidrv-@_REPLACE_ALL(_/-):Device_Names_@ @_Device_ASN1_Sort_@ ::= @_Device_Config_@
@@END_TABLE@@
END
@@END_IF@@
@@-- The following tags are available in this template:
@@--
@@-- @_Thread_Name_@ : Thread name
@@-- @_Entry_Port_Name_@ : Name of the PI
@@-- @_RCM_@ : One of "CYCLIC_OPERATION", "SPORADIC_OPERATION"
@@-- @_Need_Mutex_@ : True if the PI is shared with others in the protected block
@@-- @_Pro_Block_Name_@ : Name of the protected function
@@-- @_Node_Name_@ : Name of the deployment node
@@-- @_Remote_Threads_@ : Vector tag: output remote thread list
@@-- @_RI_Port_Name_@ : |_ Corresponding local RI name
@@-- @_Remote_PIs_@ : |_ Associated PI Name
@@-- @_Remote_PI_Sorts_@ : |_ Optional param type of the remote thread
@@-- @_Remote_PI_Modules_@ : |_ Asn1 module of the optional param type
@@-- Tags related to the PI that is at the origin of the thread creation:
@@-- @_Name_@, @_Kind_@, @_Parent_Function_@ : shoud be useless here
@@-- @_Param_Names_@, _Types_@, _ASN1_Modules, _Encodings_@, _Directions_@ : param vector tag
@@-- @_Period_@, @_WCET_@, @_Queue_Size_@ : relevant here
@@-- @_IF_Property_Names_@, _Values_@ : user properties (vector tag)
@@-- the Configuration tags are also avilable (Use_POHIC, etc.)
@@--
@@-- Matrix of output ports: Remote thread/corresponding remote PI @_Name_@
@@-- The following boolean tags are available to decide if the file
@@-- shall be generated or not:
@@-- Filename_Is_Present
@@-- Skeletons
@@-- Glue
@@-- POHIC
@@-- Debug
@@-- No_Stdlib
TRUE
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