Commit 0229a69d authored by Julien's avatar Julien
Browse files

Code that can compile on deos

parent 45ac55a3
...@@ -3357,6 +3357,33 @@ package body Ocarina.Backends.C_Common.Mapping is ...@@ -3357,6 +3357,33 @@ package body Ocarina.Backends.C_Common.Mapping is
return Make_Call_Profile (S, Parameters); return Make_Call_Profile (S, Parameters);
end Map_Time; end Map_Time;
----------------------------
-- Map_Time_To_Nanosecond --
----------------------------
function Map_Time_To_Nanosecond (T : Time_Type) return Node_Id is
Time : Unsigned_Long_Long;
begin
case T.U is
when Millisecond =>
Time := T.T * 1000_000;
when Second =>
Time := T.T * 1000_000_000;
when Microsecond =>
Time := T.T * 1000;
when Nanosecond =>
Time := T.T;
when others =>
raise Program_Error with "time value not handled at this time";
end case;
return Make_Literal (New_Int_Value (Time, 1, 10));
end Map_Time_To_Nanosecond;
----------------------------- -----------------------------
-- Map_Time_To_Millisecond -- -- Map_Time_To_Millisecond --
----------------------------- -----------------------------
......
...@@ -209,6 +209,9 @@ package Ocarina.Backends.C_Common.Mapping is ...@@ -209,6 +209,9 @@ package Ocarina.Backends.C_Common.Mapping is
function Map_Time_To_Millisecond (T : Time_Type) return Node_Id; function Map_Time_To_Millisecond (T : Time_Type) return Node_Id;
-- Return a amount of millisecond from a time -- Return a amount of millisecond from a time
function Map_Time_To_Nanosecond (T : Time_Type) return Node_Id;
-- Return a amount of nanosecond from a time
function Map_Simulink_Var (Corresponding_Feature : Node_Id) return Node_Id; function Map_Simulink_Var (Corresponding_Feature : Node_Id) return Node_Id;
-- Map simulink variable name -- Map simulink variable name
......
...@@ -2265,7 +2265,7 @@ package body Ocarina.Backends.C_Tree.Nutils is ...@@ -2265,7 +2265,7 @@ package body Ocarina.Backends.C_Tree.Nutils is
(Defining_Identifier => Make_Defining_Identifier (VN (V_Ret)), (Defining_Identifier => Make_Defining_Identifier (VN (V_Ret)),
Used_Type => RE (RE_Pok_Ret_T)); Used_Type => RE (RE_Pok_Ret_T));
Append_Node_To_List (N, Declarations); Append_Node_To_List (N, Declarations);
elsif POK_Flavor = ARINC653 then elsif Use_ARINC653_API then
N := N :=
Make_Variable_Declaration Make_Variable_Declaration
(Defining_Identifier => Make_Defining_Identifier (VN (V_Ret)), (Defining_Identifier => Make_Defining_Identifier (VN (V_Ret)),
......
...@@ -207,13 +207,16 @@ package body Ocarina.Backends.POK_C.Main is ...@@ -207,13 +207,16 @@ package body Ocarina.Backends.POK_C.Main is
end if; end if;
if Get_Thread_Deadline (E) /= Null_Time then if Get_Thread_Deadline (E) /= Null_Time then
if Use_ARINC653_API then if POK_Flavor = ARINC653 then
Member_Value := Member_Value :=
Map_Time_To_Millisecond (Get_Thread_Deadline (E)); Map_Time_To_Millisecond (Get_Thread_Deadline (E));
else elsif POK_Flavor = POK then
Member_Value := Map_Time (Get_Thread_Deadline (E)); Member_Value := Map_Time (Get_Thread_Deadline (E));
else
Member_Value := No_Node;
end if; end if;
if Member_Value /= No_Node then
N := N :=
Make_Expression Make_Expression
(Left_Expr => (Left_Expr =>
...@@ -223,25 +226,35 @@ package body Ocarina.Backends.POK_C.Main is ...@@ -223,25 +226,35 @@ package body Ocarina.Backends.POK_C.Main is
Operator => Op_Equal, Operator => Op_Equal,
Right_Expr => Member_Value); Right_Expr => Member_Value);
Append_Node_To_List (N, Statements); Append_Node_To_List (N, Statements);
end if;
else else
Display_Error ("Deadline not specified", Fatal => False); Display_Error ("Deadline not specified", Fatal => False);
end if; end if;
if Get_Thread_Period (E) /= Null_Time then if Get_Thread_Period (E) /= Null_Time then
if Use_ARINC653_API then if Use_ARINC653_API then
Member_Value := Map_Time_To_Millisecond (Get_Thread_Period (E)); if POK_Flavor = POK then
Member_Value := Map_Time_To_Millisecond
(Get_Thread_Period (E));
elsif POK_Flavor = DEOS then
Member_Value := Map_Time_To_Nanosecond
(Get_Thread_Period (E));
end if;
else else
Member_Value := Map_Time (Get_Thread_Period (E)); Member_Value := Map_Time (Get_Thread_Period (E));
end if; end if;
if Member_Value /= No_Node then
N := N :=
Make_Expression Make_Expression
(Left_Expr => (Left_Expr =>
Make_Member_Designator (RE (RE_Period), Copy_Node (Tattr)), Make_Member_Designator
(RE (RE_Period), Copy_Node (Tattr)),
Operator => Op_Equal, Operator => Op_Equal,
Right_Expr => Member_Value); Right_Expr => Member_Value);
Append_Node_To_List (N, Statements); Append_Node_To_List (N, Statements);
end if;
else else
Display_Error ("Period not specified", Fatal => True); Display_Error ("Period not specified", Fatal => True);
end if; end if;
...@@ -270,7 +283,13 @@ package body Ocarina.Backends.POK_C.Main is ...@@ -270,7 +283,13 @@ package body Ocarina.Backends.POK_C.Main is
begin begin
if TA /= Empty_Time_Array then if TA /= Empty_Time_Array then
if Use_ARINC653_API then if Use_ARINC653_API then
if POK_Flavor = ARINC653 then
Capacity := Map_Time_To_Millisecond (TA (1)); Capacity := Map_Time_To_Millisecond (TA (1));
elsif POK_Flavor = DEOS then
Capacity := Map_Time_To_Nanosecond (TA (1));
else
Capacity := No_Node;
end if;
else else
Capacity := Map_Time (TA (1)); Capacity := Map_Time (TA (1));
end if; end if;
...@@ -282,6 +301,9 @@ package body Ocarina.Backends.POK_C.Main is ...@@ -282,6 +301,9 @@ package body Ocarina.Backends.POK_C.Main is
-- By default, we allocate 1 ms for thread execution. -- By default, we allocate 1 ms for thread execution.
Capacity := Capacity :=
CTU.Make_Literal (CV.New_Int_Value (Thread_Id, 1, 10)); CTU.Make_Literal (CV.New_Int_Value (Thread_Id, 1, 10));
-- DeOS works with Nanoseconds
end if; end if;
N := N :=
Make_Expression Make_Expression
......
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