with Ada.Directories; use Ada.Directories; with Address_Spaces; use Address_Spaces; with Scheduler_Interface; use Scheduler_Interface; with Scheduler.Hierarchical.offline; use Scheduler.Hierarchical.offline; with multiprocessor_services; use multiprocessor_services; with multiprocessor_services_interface; use multiprocessor_services_interface; use Multiprocessor_Services_Interface.Scheduling_Result_Per_Processor_Package; --with Processors.Extended; --use Processors.Extended; with framework; use framework; with Scheduler; use Scheduler; with Processor_Set; use Processor_Set; with time_unit_events; use time_unit_events; use Time_Unit_Events.Time_Unit_Package; with natural_util; use natural_util; with processor_interface; use processor_interface; --with Processors.extended; --use Processors.extended; with Core_Units; use Core_Units.Core_Units_Table_Package; with processor_interface; use processor_interface; with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO; with Tasks; use Tasks; with Task_Set; use Task_Set; with Version; use Version; with Text_IO; use Text_IO; with feasibility_test.feasibility_interval; use feasibility_test.feasibility_interval; with scheduler_builder; use scheduler_builder; with Heuristics; use Heuristics; package body Ellidiss_Tools is -- procedure Set_Arinc653_Partition_Table_Directory (directory : in Unbounded_String ) is begin arinc653_partition_table_directory := directory; end Set_Arinc653_Partition_Table_Directory; -- function Get_Arinc653_Partition_Table_Directory return Unbounded_String is begin return arinc653_partition_table_directory; end Get_Arinc653_Partition_Table_Directory; -- function Get_Arinc653_Partition_Table_Filename (name : in Unbounded_String) return Unbounded_String is result_file_name : Unbounded_String := empty_string; begin result_file_name := To_Unbounded_String(Ada.Directories.Compose (To_String(Get_Arinc653_Partition_Table_Directory), To_String(name))); return result_file_name; end Get_Arinc653_Partition_Table_Filename; -- -- function Get_Offline_Scheduling_Period (A_Processor : in Generic_Processor_Ptr) return Natural is -- scheduling_Period : Natural := Default_Scheduling_Period; -- -- core : Core_Unit_Ptr; -- -- offline_scheduler : Hierarchical_offline_Scheduler; -- offline_scheduling_table : scheduling_table_ptr; -- -- tmp_string : Unbounded_String; -- begin -- Put_Line (To_String (A_Processor.name)); -- -- core := Mono_Core_Processor_Ptr(A_Processor).core; -- -- Put_Line (To_String (core.name)); -- -- offline_scheduler := Hierarchical_offline_Scheduler (extended_Core_Unit_Ptr (core).scheduler.all); -- --offline_scheduler := extended_Core_Unit_Ptr (core).scheduler.all; -- -- offline_scheduling_table := Get_event_table (offline_scheduler); -- -- Display_Scheduling (offline_scheduling_table); -- --indexed_tables.Put (offline_scheduling_table); -- --Put (Item => offline_scheduling_table.Nb_Entries); -- -- --Text_IO.put (Natural'Image (Natural(offline_scheduling_table.Nb_Entries - 1))); -- -- --for I in 0 .. offline_scheduling_table.Nb_Entries - 1 loop -- --tmp_string := xml_string (offline_scheduling_table.entries (I).data); -- --Put_line (To_String(tmp_string)); -- --end loop; -- -- return scheduling_Period; -- end Get_Offline_Scheduling_Period; -- -- function Get_Cyclic_Scheduling_Period (My_Address_Spaces : in Address_Spaces_Set) return Natural is -- scheduling_Period : Natural := Default_Scheduling_Period; -- -- An_Address_Space : Address_Space_Ptr; -- -- Ad_Iterator : address_spaces_iterator; -- tmp_value : Natural := 0; -- -- --position : Address_Spaces_Range; -- begin -- --position := get_number_of_elements (My_Address_Spaces); -- -- -- --get_element_number (My_Address_Spaces, An_Address_Space, position); -- -- reset_iterator (My_Address_Spaces, Ad_Iterator); -- loop -- current_element (My_Address_Spaces, An_Address_Space, Ad_Iterator); -- -- -- get the quantum -- tmp_value := tmp_value + An_Address_Space.scheduling.quantum; -- -- exit when is_last_element (My_Address_Spaces, Ad_Iterator); -- next_element (My_Address_Spaces, Ad_Iterator); -- end loop; -- -- if (tmp_value /= 0) then -- scheduling_Period := tmp_value; -- end if; -- -- return scheduling_Period; -- end Get_Cyclic_Scheduling_Period; function Get_Scheduling_Period (A_Sys : in System; A_Processor : Generic_Processor_Ptr) return Natural is Period : Natural; Message : Unbounded_String; Task_Iterator : Tasks_Iterator; Task_Ptr : Generic_Task_Ptr; Empty_Task_Set : Boolean := True; current_scheduler : Schedulers_Type; begin -- test if the task set per processor is empty reset_iterator (A_Sys.Tasks, Task_Iterator); loop current_element (A_Sys.Tasks, Task_Ptr, Task_Iterator); if (Task_Ptr.cpu_name = A_Processor.name) or (A_Processor.name = empty_string) then Empty_Task_Set := False; end if; exit when is_last_element (A_Sys.Tasks, Task_Iterator); next_element (A_Sys.Tasks, Task_Iterator); end loop; if (Empty_Task_Set = False) then begin current_scheduler := Mono_Core_Processor_Ptr(A_Processor).core.scheduling.scheduler_type; if (current_scheduler = Hierarchical_Offline_Protocol) then -- arinc 653 scheduler --Period := Get_Offline_Scheduling_Period (A_Processor); raise Invalid_Scheduling_Period; else if (current_scheduler = Hierarchical_Cyclic_Protocol) then --Period := Get_Cyclic_Scheduling_Period (A_Sys.Address_Spaces); raise Invalid_Scheduling_Period; else Period := Scheduling_Period (A_Sys.Tasks, A_Processor.name); --Put_Line ("processor name :" & A_Processor.name); end if; end if; exception when TASK_MUST_BE_PERIODIC => raise Invalid_Scheduling_Period; end; else raise Invalid_Scheduling_Period; end if; return (Period); end Get_Scheduling_Period; --procedure Write_Xml_Event_Table (Sys : in out System; File_Name : in Unbounded_String) is --begin --null; --end Write_Xml_Event_Table; procedure Write_Xml_Event_Table (Sys : in out System; File_Name : in Unbounded_String) is A_Processor : Generic_Processor_Ptr; An_Event : Time_Unit_Event_Ptr; validity : Unbounded_String; Tmp_Period : Natural; Xml_File : File_Type; optimizationStr : Unbounded_String := To_Unbounded_String ("False"); begin -- create file -- Create (Xml_File, Mode => Out_File, Name => To_String (File_Name)); if Optimization_Mode_Activated then optimizationStr := To_Unbounded_String ("True"); end if; Put_line (Xml_File, ""); -- Export event table for each processor -- for I in 0 .. framework.Sched.nb_entries - 1 loop A_Processor := Search_Processor (Sys.Processors, framework.Sched.entries (I).item.name); if (framework.Sched.entries (I).data.error_msg = empty_string) then --Put_Line ("Processor name" & A_Processor.name); begin Tmp_Period := Get_Scheduling_Period (Sys, A_Processor); validity := To_Unbounded_String ("true"); exception when Invalid_Scheduling_Period => Tmp_Period := Get_Default_Scheduling_Period; validity := To_Unbounded_String ("false"); end; Put_Line (Xml_File, " "); --Put_line (Xml_File, " "); Put_line (Xml_File, " FALSE"); Put_line (Xml_File, " "); for J in 0 .. framework.Sched.entries (I).data.result.nb_entries - 1 loop -- The event to compute -- An_Event := framework.Sched.entries (I).data.result.entries (J).data; Put_Line (Xml_File, " " & format (Natural (framework.Sched.entries (I).data.result.entries (J).item)) & ""); Put_Line (Xml_File, " "); Put_Line (Xml_File, " " & to_unbounded_string(Time_Unit_Event_Type'image (An_Event.type_of_event)) & ""); case An_Event.type_of_event is when Buffer_Overflow => Put_Line (Xml_File, " "); Put_Line (Xml_File, " "); Put_Line (Xml_File, " " & format (Natural (An_Event.overflow_write_size)) &""); when Buffer_Underflow => Put_Line (Xml_File, " "); Put_Line (Xml_File, " "); Put_Line (Xml_File, " " & format (Natural (An_Event.underflow_read_size)) &""); when Start_Of_Task_Capacity => Put_Line (Xml_File, " "); when End_Of_Task_Capacity => Put_Line (Xml_File, " "); when Write_To_Buffer => Put_Line (Xml_File, " "); Put_Line (Xml_File, " "); Put_Line (Xml_File, " " & format (Natural (An_Event.write_size)) &""); when Read_From_Buffer => Put_Line (Xml_File, " "); Put_Line (Xml_File, " "); Put_Line (Xml_File, " " & format (Natural (An_Event.read_size)) &""); when Context_Switch_Overhead => Put_Line (Xml_File, " "); when Running_Task => Put_Line (Xml_File, " " & An_Event.running_core &""); Put_Line (Xml_File, " "); Put_Line (Xml_File, " " & format (Natural (An_Event.current_priority)) &""); when Task_activation => Put_Line (Xml_File, " "); when Allocate_Resource => Put_Line (Xml_File, " "); Put_Line (Xml_File, " "); when Release_Resource => Put_Line (Xml_File, " "); Put_Line (Xml_File, " "); when Wait_For_Resource => Put_Line (Xml_File, " "); Put_Line (Xml_File, " "); when Send_Message => Put_Line (Xml_File, " "); Put_Line (Xml_File, " "); when Receive_Message => Put_Line (Xml_File, " "); Put_Line (Xml_File, " "); when wait_for_memory => Put_Line (Xml_File, " "); Put_Line (Xml_File, " "); when Address_Space_Activation => Put_Line (Xml_File, " " & An_Event.activation_address_space &""); Put_Line (Xml_File, " " & format (Natural (An_Event.duration)) &""); when Preemption => null; end case; Put_Line (Xml_File, " "); end loop; Put_line (Xml_File, " "); Put_line (Xml_File, " "); else Put_Line (Xml_File, " "); Put_line (Xml_File, " TRUE"); Put_line (Xml_File, " " & framework.Sched.entries (I).data.error_msg & ""); Put_line (Xml_File, " "); -- Put_Line ("Error on processor " & A_Processor.name & " : " & framework.Sched.entries (I).data.error_msg); end if; end loop; Put_Line (Xml_File, ""); Close (Xml_File); end Write_Xml_Event_Table; procedure Write_Xml_Event_Table2 (Sys : in out System; File_Name : in Unbounded_String) is begin Write_To_Xml_File(framework.Sched, Sys, File_Name); end Write_Xml_Event_Table2; -- procedure Set_Default_Scheduling_Period (Scheduling_Period : in Natural) is begin Default_Scheduling_Period := Scheduling_Period; end Set_Default_Scheduling_Period; function Get_Default_Scheduling_Period return Natural is begin return Default_Scheduling_Period; end Get_Default_Scheduling_Period; function CheddarKernel_version return String is begin return Cheddar_Version & "." & CheddarKernel_Verion; end CheddarKernel_version; end Ellidiss_Tools; ---- Check if Tasks Are Periodic ---- --Periodic_Control (My_Tasks, Processor_Name); --Res := new multi_int'(Multi (1)); --reset_iterator (My_Tasks, My_Iterator); --loop --current_element (My_Tasks, A_Task, My_Iterator); --if (A_Task.cpu_name = Processor_Name and --A_Task.task_type = Periodic_Type) --then --Start_Time := Natural'Max (Start_Time, A_Task.start_time); --Current := --new multi_int'(Multi (Periodic_Task_Ptr (A_Task).period)); --Res := lcm (Res, Current); --end if; --exit when is_last_element (My_Tasks, My_Iterator); --next_element (My_Tasks, My_Iterator); --end loop; --if Start_Time /= 0 then --Current := new multi_int'(Multi (2)); --Res.all := Res.all * Current.all; --Current.all := Multi (Start_Time); --Res.all := Res.all + Current.all; --end if; --Period := Double (convert (Res.all)); --return Period;