Commit 5aa0b952 authored by yoogx's avatar yoogx

* Add functions to get current task Entity_Type value

        For openaadl/ocarina#120
parent 11d8ec1e
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2007-2009 Telecom ParisTech, 2010-2015 ESA & ISAE. --
-- Copyright (C) 2007-2009 Telecom ParisTech, 2010-2017 ESA & ISAE. --
-- --
-- PolyORB-HI is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -34,6 +34,7 @@ pragma SPARK_Mode (Off);
with PolyORB_HI.Output;
with PolyORB_HI.Suspenders;
pragma Elaborate_All (PolyORB_HI.Suspenders);
with PolyORB_HI.Utils;
package body PolyORB_HI.Periodic_Task is
......@@ -42,6 +43,7 @@ package body PolyORB_HI.Periodic_Task is
use PolyORB_HI.Errors;
use PolyORB_HI.Output;
use PolyORB_HI.Suspenders;
use PolyORB_HI.Utils;
use PolyORB_HI_Generated.Deployment;
Next_Deadline_Val : Time;
......@@ -52,6 +54,10 @@ package body PolyORB_HI.Periodic_Task is
Error : Error_Kind;
begin
-- Register task
Set_Task_Id (Entity);
-- Run the initialize entrypoint (if any)
Activate_Entrypoint;
......
......@@ -31,6 +31,7 @@
with PolyORB_HI.Output;
with PolyORB_HI.Suspenders;
with PolyORB_HI.Utils;
package body PolyORB_HI.Sporadic_Task is
......@@ -52,6 +53,10 @@ package body PolyORB_HI.Sporadic_Task is
Error : Error_Kind;
begin
-- Register task
Set_Task_Id (Entity);
-- Run the initialize entrypoint (if any)
Activate_Entrypoint;
......
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 2009 Telecom ParisTech, 2010-2015 ESA & ISAE. --
-- Copyright (C) 2009 Telecom ParisTech, 2010-2017 ESA & ISAE. --
-- --
-- PolyORB-HI is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -29,6 +29,8 @@
-- --
------------------------------------------------------------------------------
with Ada.Task_Identification; use Ada.Task_Identification;
package body PolyORB_HI.Utils is
------------------
......@@ -90,28 +92,6 @@ package body PolyORB_HI.Utils is
end if;
end Swap_Bytes;
-------------------
-- Internal_Code --
-------------------
function Internal_Code (P : Port_Type) return Unsigned_16 is
function To_Internal_Code is new Ada.Unchecked_Conversion
(Port_Type, Unsigned_16);
begin
return Swap_Bytes (To_Internal_Code (P));
end Internal_Code;
------------------------
-- Corresponding_Port --
------------------------
function Corresponding_Port (I : Unsigned_16) return Port_Type is
function To_Corresponding_Port is new Ada.Unchecked_Conversion
(Unsigned_16, Port_Type);
begin
return To_Corresponding_Port (Swap_Bytes (I));
end Corresponding_Port;
------------------
-- Parse_String --
------------------
......@@ -131,4 +111,30 @@ package body PolyORB_HI.Utils is
return Last;
end Parse_String;
-----------------
-- Set_Task_Id --
-----------------
Task_Id_Mapping : array (Entity_Type'Range) of Task_Id;
procedure Set_Task_Id (My_Id : Entity_Type) is
begin
Task_Id_Mapping (My_Id) := Current_Task;
end Set_Task_Id;
-----------------
-- Get_Task_Id --
-----------------
function Get_Task_Id return Entity_Type is
My_Task_Id : constant Task_Id := Current_Task;
begin
for J in Task_Id_Mapping'Range loop
if Task_Id_Mapping (J) = Current_Task then
return J;
end if;
end loop;
return Entity_Type'First;
end Get_Task_Id;
end PolyORB_HI.Utils;
......@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
-- Copyright (C) 2007-2009 Telecom ParisTech, 2010-2015 ESA & ISAE. --
-- Copyright (C) 2007-2009 Telecom ParisTech, 2010-2017 ESA & ISAE. --
-- --
-- PolyORB-HI is free software; you can redistribute it and/or modify under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -69,9 +69,6 @@ package PolyORB_HI.Utils is
function Corresponding_Node is new Ada.Unchecked_Conversion
(Unsigned_8, Node_Type);
function Internal_Code (P : Port_Type) return Unsigned_16;
function Corresponding_Port (I : Unsigned_16) return Port_Type;
function Swap_Bytes (B : Interfaces.Unsigned_16)
return Interfaces.Unsigned_16;
-- Swap bytes iff the host is little endian. This function is
......@@ -119,6 +116,13 @@ package PolyORB_HI.Utils is
type Naming_Table_Type is array (Node_Type'Range)
of PolyORB_HI.Utils.Naming_Entry;
---------------------
-- Task_Id mapping --
---------------------
procedure Set_Task_Id (My_Id : Entity_Type);
function Get_Task_Id return Entity_Type;
private
type HI_String is record
......
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