ocarina-backends-pok_c-activity.adb 80.6 KB
Newer Older
1 2 3 4 5 6 7 8
------------------------------------------------------------------------------
--                                                                          --
--                           OCARINA COMPONENTS                             --
--                                                                          --
--      O C A R I N A . B A C K E N D S . P O K _ C . A C T I V I T Y       --
--                                                                          --
--                                 B o d y                                  --
--                                                                          --
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
--    Copyright (C) 2008-2009 Telecom ParisTech, 2010-2015 ESA & ISAE.      --
--                                                                          --
-- Ocarina  is free software; you can redistribute it and/or modify under   --
-- terms of the  GNU General Public License as published  by the Free Soft- --
-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
-- sion. Ocarina is distributed in the hope that it will be useful, but     --
-- WITHOUT ANY WARRANTY; without even the implied warranty of               --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     --
--                                                                          --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception,   --
-- version 3.1, as published by the Free Software Foundation.               --
--                                                                          --
-- You should have received a copy of the GNU General Public License and    --
-- a copy of the GCC Runtime Library Exception along with this program;     --
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
-- <http://www.gnu.org/licenses/>.                                          --
26
--                                                                          --
jhugues's avatar
jhugues committed
27 28
--                 Ocarina is maintained by the TASTE project               --
--                      (taste-users@lists.tuxfamily.org)                   --
29 30 31
--                                                                          --
------------------------------------------------------------------------------

32
with Ocarina.Namet;
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

with Ocarina.ME_AADL;
with Ocarina.ME_AADL.AADL_Instances.Nodes;
with Ocarina.ME_AADL.AADL_Instances.Nutils;
with Ocarina.Backends.Utils;
with Ocarina.ME_AADL.AADL_Instances.Entities;
with Ocarina.Backends.Properties;
with Ocarina.Backends.C_Tree.Nutils;
with Ocarina.Backends.C_Tree.Nodes;
with Ocarina.Backends.C_Common.Mapping;
with Ocarina.Backends.POK_C.Runtime;
with Ocarina.Backends.C_Values;
with Ocarina.Backends.Messages;

with Ocarina.Instances.Queries;

package body Ocarina.Backends.POK_C.Activity is

51
   use Ocarina.Namet;
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
   use Ocarina.ME_AADL;
   use Ocarina.ME_AADL.AADL_Instances.Nodes;
   use Ocarina.Backends.Utils;
   use Ocarina.ME_AADL.AADL_Instances.Entities;
   use Ocarina.Backends.Properties;
   use Ocarina.Backends.C_Tree.Nutils;
   use Ocarina.Backends.C_Common.Mapping;
   use Ocarina.Backends.POK_C.Runtime;
   use Ocarina.Backends.Messages;

   use Ocarina.Instances.Queries;

   package AIN renames Ocarina.ME_AADL.AADL_Instances.Nodes;
   package AINU renames Ocarina.ME_AADL.AADL_Instances.Nutils;
   package CTN renames Ocarina.Backends.C_Tree.Nodes;
   package CTU renames Ocarina.Backends.C_Tree.Nutils;
   package CV renames Ocarina.Backends.C_Values;

   Current_Device : Node_Id := No_Node;

   ------------
   -- Header --
   ------------

   package body Header_File is

      procedure Visit_Architecture_Instance (E : Node_Id);
      procedure Visit_Component_Instance (E : Node_Id);
      procedure Visit_System_Instance (E : Node_Id);
      procedure Visit_Process_Instance
82 83
        (E            : Node_Id;
         Real_Process : Boolean := True);
84 85 86 87 88 89 90 91 92 93 94 95 96 97
      procedure Visit_Processor_Instance (E : Node_Id);
      procedure Visit_Device_Instance (E : Node_Id);
      procedure Visit_Virtual_Processor_Instance (E : Node_Id);
      procedure Visit_Thread_Instance (E : Node_Id);
      function Task_Job_Spec (E : Node_Id) return Node_Id;

      -------------------
      -- Task_Job_Spec --
      -------------------

      function Task_Job_Spec (E : Node_Id) return Node_Id is
         N : Node_Id;
         S : constant Node_Id := Parent_Subcomponent (E);
      begin
98 99 100 101 102
         N :=
           Make_Function_Specification
             (Defining_Identifier => Map_Task_Job_Identifier (S),
              Parameters          => No_List,
              Return_Type => CTU.Make_Pointer_Type (New_Node (CTN.K_Void)));
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
         return N;
      end Task_Job_Spec;

      -----------
      -- Visit --
      -----------

      procedure Visit (E : Node_Id) is
      begin
         case Kind (E) is
            when K_Architecture_Instance =>
               Visit_Architecture_Instance (E);

            when K_Component_Instance =>
               Visit_Component_Instance (E);

            when others =>
               null;
         end case;
      end Visit;

      ---------------------------------
      -- Visit_Architecture_Instance --
      ---------------------------------

      procedure Visit_Architecture_Instance (E : Node_Id) is
      begin
         Visit (Root_System (E));
      end Visit_Architecture_Instance;

      ------------------------------
      -- Visit_Component_Instance --
      ------------------------------

      procedure Visit_Component_Instance (E : Node_Id) is
138 139
         Category : constant Component_Category :=
           Get_Category_Of_Component (E);
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
      begin
         case Category is
            when CC_System =>
               Visit_System_Instance (E);

            when CC_Process =>
               Visit_Process_Instance (E);

            when CC_Processor =>
               Visit_Processor_Instance (E);

            when CC_Virtual_Processor =>
               Visit_Virtual_Processor_Instance (E);

            when CC_Thread =>
               Visit_Thread_Instance (E);

            when CC_Device =>
               Visit_Device_Instance (E);

            when others =>
               null;
         end case;

      end Visit_Component_Instance;

      --------------------------------------
      -- Visit_Virtual_Processor_Instance --
      --------------------------------------

      procedure Visit_Virtual_Processor_Instance (E : Node_Id) is
171 172
         S         : Node_Id;
         U         : Node_Id;
173 174 175 176
         Processes : List_Id;
      begin
         if Present (Backend_Node (Identifier (E))) then
            Processes := CTN.Processes (Backend_Node (Identifier (E)));
177
            S         := AIN.First_Node (Processes);
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
            while Present (S) loop
               U := Current_Entity;
               Pop_Entity;
               Visit (AIN.Item (S));
               Push_Entity (U);
               S := AIN.Next_Node (S);
            end loop;
         end if;
      end Visit_Virtual_Processor_Instance;

      ------------------------------
      -- Visit_Processor_Instance --
      ------------------------------

      procedure Visit_Processor_Instance (E : Node_Id) is
         S : Node_Id;
         U : Node_Id;
         P : Node_Id;
      begin
         U := CTN.Naming_Node (Backend_Node (Identifier (E)));
         P := CTN.Entity (U);

         Push_Entity (C_Root);
         Push_Entity (P);
         Push_Entity (U);

         Register_Kernel_Unit (U);

         if not AINU.Is_Empty (Subcomponents (E)) then
            S := First_Node (Subcomponents (E));
            while Present (S) loop

               Visit (Corresponding_Instance (S));

               S := Next_Node (S);
            end loop;
         end if;

         Pop_Entity;
         Pop_Entity;
         Pop_Entity;
      end Visit_Processor_Instance;

      ----------------------------
      -- Visit_Process_Instance --
      ----------------------------

      procedure Visit_Process_Instance
226 227 228 229 230 231
        (E            : Node_Id;
         Real_Process : Boolean := True)
      is
         U : Node_Id;
         P : Node_Id;
         S : Node_Id;
232 233
      begin
         if Real_Process then
234 235 236
            U :=
              CTN.Distributed_Application_Unit
                (CTN.Naming_Node (Backend_Node (Identifier (E))));
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
            P := CTN.Entity (U);

            Push_Entity (P);
            Push_Entity (U);
         end if;

         Set_Activity_Header;

         if not AINU.Is_Empty (Subcomponents (E)) then
            S := First_Node (Subcomponents (E));
            while Present (S) loop

               Visit (Corresponding_Instance (S));

               S := Next_Node (S);
            end loop;
         end if;

         if Real_Process then
            Pop_Entity; -- U
            Pop_Entity; -- P
         end if;
      end Visit_Process_Instance;

      ---------------------------
      -- Visit_System_Instance --
      ---------------------------

      procedure Visit_System_Instance (E : Node_Id) is
         S : Node_Id;
      begin
         --  Visit all the subcomponents of the system

         if not AINU.Is_Empty (Subcomponents (E)) then
            S := First_Node (Subcomponents (E));
            while Present (S) loop
               --  Visit the component instance corresponding to the
               --  subcomponent S.
               if AINU.Is_Processor (Corresponding_Instance (S)) then
                  Visit (Corresponding_Instance (S));
               end if;
               S := Next_Node (S);
            end loop;
         end if;
      end Visit_System_Instance;

      ---------------------------
      -- Visit_Device_Instance --
      ---------------------------

      procedure Visit_Device_Instance (E : Node_Id) is
288 289 290 291 292 293
         U : constant Node_Id :=
           CTN.Distributed_Application_Unit
             (CTN.Naming_Node (Backend_Node (Identifier (E))));
         P              : constant Node_Id := CTN.Entity (U);
         Implementation : Node_Id;
         S              : Node_Id;
294 295 296 297 298 299 300 301 302 303 304 305
      begin
         Push_Entity (P);
         Push_Entity (U);

         Implementation := Get_Classifier_Property (E, "implemented_as");

         if Implementation /= No_Node then
            if not AINU.Is_Empty (AIN.Subcomponents (Implementation)) then
               S := First_Node (Subcomponents (Implementation));
               while Present (S) loop
                  if Get_Category_Of_Component (S) = CC_Process then
                     Visit_Process_Instance
306 307
                       (Corresponding_Instance (S),
                        False);
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
                  end if;

                  S := Next_Node (S);
               end loop;
            end if;

         end if;

         Pop_Entity; -- U
         Pop_Entity; -- P
      end Visit_Device_Instance;

      ---------------------------
      -- Visit_Thread_Instance --
      ---------------------------

      procedure Visit_Thread_Instance (E : Node_Id) is
         P : constant Supported_Thread_Dispatch_Protocol :=
           Get_Thread_Dispatch_Protocol (E);
         S : constant Node_Id := Parent_Subcomponent (E);
         N : Node_Id;
      begin
         case P is
            when Thread_Periodic =>

333 334 335 336
               N :=
                 Message_Comment
                   ("Periodic task : " &
                    Get_Name_String (Display_Name (Identifier (S))));
337 338 339 340 341 342 343 344 345 346
               Append_Node_To_List (N, CTN.Declarations (Current_File));

               --  Create the spec of the parameterless subprogram
               --  that executes the thread job.

               N := Task_Job_Spec (E);
               Append_Node_To_List (N, CTN.Declarations (Current_File));
               Bind_AADL_To_Job (Identifier (S), N);

            when Thread_Sporadic =>
347 348 349 350
               N :=
                 Message_Comment
                   ("Sporadic task : " &
                    Get_Name_String (Display_Name (Identifier (S))));
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
               Append_Node_To_List (N, CTN.Declarations (Current_File));

               N := Task_Job_Spec (E);
               Append_Node_To_List (N, CTN.Declarations (Current_File));
               Bind_AADL_To_Job (Identifier (S), N);

            when others =>
               Display_Error ("unknown thread type", Fatal => True);
         end case;
      end Visit_Thread_Instance;

   end Header_File;

   ------------
   -- Source --
   ------------

   package body Source_File is

      procedure Visit_Architecture_Instance (E : Node_Id);
      procedure Visit_Component_Instance (E : Node_Id);
      procedure Visit_System_Instance (E : Node_Id);
      procedure Visit_Process_Instance
374 375
        (E            : Node_Id;
         Real_Process : Boolean := True);
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405
      procedure Visit_Processor_Instance (E : Node_Id);
      procedure Visit_Virtual_Processor_Instance (E : Node_Id);
      procedure Visit_Thread_Instance (E : Node_Id);
      procedure Visit_Device_Instance (E : Node_Id);
      function Get_Timeout_Value (E : Node_Id) return Time_Type;

      function Task_Job_Body (E : Node_Id) return Node_Id;
      --  Create the parameterless subprogram body that does the
      --  thread's job.

      -----------------------
      -- Get_Timeout_Value --
      -----------------------

      function Get_Timeout_Value (E : Node_Id) return Time_Type is
      begin
         if Get_Compute_Deadline (E) /= Null_Time then
            return Get_Compute_Deadline (E);
         elsif Get_ARINC653_Timeout (E) /= Null_Time then
            return Get_ARINC653_Timeout (E);
         else
            return Null_Time;
         end if;
      end Get_Timeout_Value;

      -------------------
      -- Task_Job_Body --
      -------------------

      function Task_Job_Body (E : Node_Id) return Node_Id is
406 407 408 409 410 411 412
         S    : constant Node_Id := Parent_Subcomponent (E);
         Spec : constant Node_Id :=
           CTN.Job_Node (Backend_Node (Identifier (S)));
         Declarations : constant List_Id := New_List (CTN.K_Declaration_List);
         Statements   : constant List_Id := New_List (CTN.K_Statement_List);
         WStatements  : constant List_Id := New_List (CTN.K_Statement_List);
         P            : constant Supported_Thread_Dispatch_Protocol :=
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433
           Get_Thread_Dispatch_Protocol (E);
         Call_Parameters : List_Id;
         N               : Node_Id;
         Call_Seq        : Node_Id;
         Spg_Call        : Node_Id;
         Spg             : Node_Id;
         Called_Function : Node_Id;
         Type_Used       : Node_Id;

         procedure Make_Init;
         procedure Make_Call_Sequence;
         procedure Make_Send_Out;
         procedure Make_End_Period;
         procedure Make_Receive_In;
         procedure Make_Potential_Assignments;

         ---------------
         -- Make_Init --
         ---------------

         procedure Make_Init is
434 435
            Entrypoint : constant Node_Id :=
              Get_Thread_Initialize_Entrypoint (E);
436 437 438
         begin
            if Entrypoint /= No_Node then
               Append_Node_To_List
439
                 (Make_Call_Profile (Map_C_Subprogram_Identifier (Entrypoint)),
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455
                  Statements);
            end if;
         end Make_Init;

         ------------------------
         -- Make_Call_Sequence --
         ------------------------

         procedure Make_Call_Sequence is
            Call_Seq : constant Node_Id := First_Node (Calls (E));
         begin
            if not Has_Modes (E) or else AINU.Length (Calls (E)) = 1 then
               --  If the thread has no modes, then it should has one
               --  unique call sequence, handle it.

               CTU.Handle_Call_Sequence
456 457 458 459
                 (S,
                  Call_Seq,
                  Declarations,
                  WStatements);
460 461 462 463 464 465 466 467 468 469 470
            else
               N := Message_Comment ("not implemented yet");
               Append_Node_To_List (N, WStatements);
            end if;
         end Make_Call_Sequence;

         ---------------------
         -- Make_Receive_In --
         ---------------------

         procedure Make_Receive_In is
471 472 473 474 475 476 477
            F                  : Node_Id;
            Function_Call      : Node_Id;
            Destination_Port   : Node_Id;
            Transport_Type     : Node_Id := No_Node;
            Compute_Entrypoint : Node_Id;
            Virtual_Bus_Size   : Node_Id := No_Node;
            Virtual_Bus_Data   : Node_Id := No_Node;
478
         begin
479
            N := Message_Comment ("Get the IN ports values");
480 481 482 483 484
            Append_Node_To_List (N, WStatements);

            F := First_Node (Features (E));

            while Present (F) loop
485 486
               if Kind (F) = K_Port_Spec_Instance and then Is_In (F) then
                  Transport_Type   := No_Node;
487 488 489 490 491 492
                  Destination_Port := No_Node;

                  if Is_Data (F) then

                     if Current_Device /= No_Node then
                        Destination_Port :=
493 494 495 496 497 498 499 500 501 502 503 504 505
                          Get_Corresponding_Port_In_Component (F);

                        if Destination_Port /= No_Node
                          and then Is_Using_Virtual_Bus
                            (Get_Port_By_Name
                               (Destination_Port,
                                Current_Device))
                        then
                           Transport_Type :=
                             Get_Inter_Partition_Port_Type
                               (Get_Port_By_Name
                                  (Destination_Port,
                                   Current_Device));
506 507
                        end if;

508 509 510 511 512 513 514
                        if Transport_Type = No_Node
                          and then Is_Using_Virtual_Bus
                            (Get_Port_By_Name (F, Current_Device))
                        then
                           Transport_Type :=
                             Get_Inter_Partition_Port_Type
                               (Get_Port_By_Name (F, Current_Device));
515 516
                        end if;
                     else
517 518 519
                        Transport_Type :=
                          Map_C_Data_Type_Designator
                            (Corresponding_Instance (F));
520 521 522
                     end if;

                     if Transport_Type = No_Node then
523 524 525
                        Transport_Type :=
                          Map_C_Data_Type_Designator
                            (Corresponding_Instance (F));
526 527 528
                     end if;

                     Append_Node_To_List
529 530 531 532
                       (Make_Variable_Declaration
                          (Defining_Identifier =>
                             Make_Defining_Identifier
                               (Map_Port_Data (F, Current_Device)),
533 534 535 536 537 538 539
                           Used_Type => Transport_Type),
                        CTN.Declarations (Current_File));
                  end if;

                  Call_Parameters := New_List (CTN.K_Parameter_List);

                  if AIN.Is_Data (F) and then not AIN.Is_Event (F) then
540 541 542 543 544 545 546 547
                     if
                       (Get_Connection_Pattern (F) = Inter_Process
                        and then not Is_Virtual
                          (Get_Port_By_Name (F, Current_Device)))
                       or else
                       (Get_Port_By_Name (F, Current_Device) /= No_Node
                        and then not Is_Pure_Device_Port
                          (Get_Port_By_Name (F, Current_Device)))
548 549
                     then

550 551 552 553
                        if Current_Device /= No_Node
                          and then Is_Using_Virtual_Bus
                            (Get_Port_By_Name (F, Current_Device))
                        then
554 555 556 557 558 559
                           Add_Include (RH (RH_Protocols));
                        end if;
                        --  Check if we are in a device and if the port
                        --  of the device can transport data that was
                        --  manipulated by a virtual bus.

560
                        if Use_ARINC653_API then
561
                           Called_Function := RE (RE_Read_Sampling_Message);
562
                           Type_Used       := RE (RE_Sampling_Port_Id_Type);
563 564
                        else
                           Called_Function := RE (RE_Pok_Port_Sampling_Read);
565
                           Type_Used       := RE (RE_Uint8_T);
566 567
                        end if;

568 569 570 571
                        Function_Call :=
                          CTU.POK_Make_Function_Call_With_Assert
                            (Called_Function,
                             Call_Parameters);
572 573

                        Append_Node_To_List
574 575 576 577 578 579 580
                          (Make_Extern_Entity_Declaration
                             (Make_Variable_Declaration
                                (Defining_Identifier =>
                                   (Make_Defining_Identifier
                                      (Map_Port_Var (F, Current_Device))),
                                 Used_Type => Type_Used)),
                           CTN.Declarations (Current_File));
581

582
                        if Use_ARINC653_API then
583 584 585 586 587 588
                           Type_Used := RE (RE_Validity_Type);
                        else
                           Type_Used := RE (RE_Bool_T);
                        end if;

                        Append_Node_To_List
589 590 591 592 593
                          (Make_Variable_Declaration
                             (Defining_Identifier =>
                                (Make_Defining_Identifier
                                   (Map_Port_Var_Valid (F, Current_Device))),
                              Used_Type => Type_Used),
594 595
                           Statements);

596
                        if Use_ARINC653_API then
597 598 599 600 601 602
                           Type_Used := RE (RE_Message_Size_Type);
                        else
                           Type_Used := RE (RE_Pok_Port_Size_T);
                        end if;

                        Append_Node_To_List
603 604 605 606 607 608
                          (Make_Variable_Declaration
                             (Defining_Identifier =>
                                (Make_Defining_Identifier
                                   (Map_Port_Var_Length (F, Current_Device))),
                              Used_Type => Type_Used),
                           Statements);
609 610 611 612

                        Append_Node_To_List (Function_Call, WStatements);

                        POK_Add_Return_Assertion
613 614
                          (WStatements,
                           RE (RE_Pok_Errno_Empty));
615 616 617

                        --  Call virtual bus hierarchy

618
                        if AIN.First_Node (AIN.Sources (F)) /= No_Node then
619
                           Map_Virtual_Bus_Calls
620
                             (AIN.Item (AIN.First_Node (AIN.Sources (F))),
621 622 623 624 625 626 627 628 629
                              CTN.Declarations (Current_File),
                              WStatements,
                              Receiving,
                              Virtual_Bus_Data,
                              Virtual_Bus_Size,
                              Current_Device);
                        end if;

                        Append_Node_To_List
630 631 632
                          (Make_Defining_Identifier
                             (Map_Port_Var (F, Current_Device)),
                           Call_Parameters);
633 634 635

                        if Virtual_Bus_Data /= No_Node then
                           Append_Node_To_List
636
                             (Make_Variable_Address (Virtual_Bus_Data),
637 638 639
                              Call_Parameters);
                        else
                           if Get_Data_Representation
640 641 642
                               (Corresponding_Instance (F)) =
                             Data_Array
                           then
643
                              Append_Node_To_List
644 645
                                (Make_Defining_Identifier
                                   (Map_Port_Data (F, Current_Device)),
646 647 648
                                 Call_Parameters);
                           else
                              Append_Node_To_List
649 650 651
                                (Make_Variable_Address
                                   (Make_Defining_Identifier
                                      (Map_Port_Data (F, Current_Device))),
652 653 654 655 656 657
                                 Call_Parameters);
                           end if;
                        end if;

                        if Virtual_Bus_Size /= No_Node then
                           Append_Node_To_List
658
                             (Make_Variable_Address (Virtual_Bus_Size),
659 660 661
                              Call_Parameters);
                        else
                           Append_Node_To_List
662 663 664 665
                             (Make_Variable_Address
                                (Make_Defining_Identifier
                                   (Map_Port_Var_Length (F, Current_Device))),
                              Call_Parameters);
666 667 668
                        end if;

                        Append_Node_To_List
669 670 671 672
                          (Make_Variable_Address
                             (Make_Defining_Identifier
                                (Map_Port_Var_Valid (F, Current_Device))),
                           Call_Parameters);
673

674
                        if Use_ARINC653_API then
675
                           Add_Return_Variable_In_Parameters (Call_Parameters);
676 677 678 679 680
                        end if;

                     elsif Get_Connection_Pattern (F) = Intra_Process then

                        Append_Node_To_List
681 682 683
                          (Make_Defining_Identifier
                             (Map_Port_Var (F, Current_Device)),
                           Call_Parameters);
684 685

                        if Get_Timeout_Value (F) /= Null_Time then
686
                           if Use_ARINC653_API then
687 688 689
                              N :=
                                Map_Time_To_Millisecond
                                  (Get_Timeout_Value (F));
690 691 692 693
                           else
                              N := Map_Time (Get_Timeout_Value (F));
                           end if;
                        else
694
                           N := CTU.Make_Literal (CV.New_Int_Value (0, 1, 10));
695 696 697 698
                        end if;
                        Append_Node_To_List (N, Call_Parameters);

                        Append_Node_To_List
699 700 701 702
                          (Make_Variable_Address
                             (Make_Defining_Identifier
                                (Map_Port_Data (F, Current_Device))),
                           Call_Parameters);
703 704

                        Append_Node_To_List
705 706 707 708
                          (Make_Variable_Address
                             (Make_Defining_Identifier
                                (Map_Port_Var_Length (F, Current_Device))),
                           Call_Parameters);
709

710
                        if Use_ARINC653_API then
711
                           Add_Return_Variable_In_Parameters (Call_Parameters);
712 713
                           Called_Function := RF (RE_Read_Blackboard);
                        else
714
                           Called_Function := RF (RE_Pok_Blackboard_Read);
715 716
                        end if;

717 718 719 720
                        Function_Call :=
                          CTU.POK_Make_Function_Call_With_Assert
                            (Called_Function,
                             Call_Parameters);
721

722
                        if Use_ARINC653_API then
723 724 725 726 727 728
                           Type_Used := RE (RE_Message_Size_Type);
                        else
                           Type_Used := RE (RE_Pok_Port_Size_T);
                        end if;

                        Append_Node_To_List
729 730 731 732 733 734
                          (Make_Variable_Declaration
                             (Defining_Identifier =>
                                (Make_Defining_Identifier
                                   (Map_Port_Var_Length (F, Current_Device))),
                              Used_Type => Type_Used),
                           Statements);
735

736
                        if Use_ARINC653_API then
737 738 739 740 741 742
                           Type_Used := RE (RE_Blackboard_Id_Type);
                        else
                           Type_Used := RE (RE_Uint8_T);
                        end if;

                        Append_Node_To_List
743 744 745 746 747 748 749
                          (Make_Extern_Entity_Declaration
                             (Make_Variable_Declaration
                                (Defining_Identifier =>
                                   (Make_Defining_Identifier
                                      (Map_Port_Var (F, Current_Device))),
                                 Used_Type => Type_Used)),
                           CTN.Declarations (Current_File));
750 751 752 753

                        Append_Node_To_List (Function_Call, WStatements);

                        POK_Add_Return_Assertion
754 755
                          (WStatements,
                           RE (RE_Pok_Errno_Empty));
756 757 758 759 760
                     end if;

                  elsif AIN.Is_Data (F) and then AIN.Is_Event (F) then

                     if Get_Connection_Pattern (F) = Inter_Process then
761
                        if AIN.First_Node (AIN.Sources (F)) /= No_Node then
762
                           Map_Virtual_Bus_Calls
763
                             (AIN.Item (AIN.First_Node (AIN.Sources (F))),
764 765 766 767 768 769 770 771
                              CTN.Declarations (Current_File),
                              WStatements,
                              Receiving,
                              Virtual_Bus_Data,
                              Virtual_Bus_Size,
                              Current_Device);
                        end if;

772
                        if Use_ARINC653_API then
773 774

                           Append_Node_To_List
775 776 777 778 779
                             (Make_Expression
                                (Left_Expr =>
                                   Make_Defining_Identifier
                                     (Map_Port_Var_Length (F, Current_Device)),
                                 Operator   => Op_Equal,
780
                                 Right_Expr =>
781
                                   Get_Data_Size (Corresponding_Instance (F))),
782 783 784
                              WStatements);

                           Append_Node_To_List
785 786 787
                             (Make_Defining_Identifier
                                (Map_Port_Var (F, Current_Device)),
                              Call_Parameters);
788 789

                           if Get_Timeout_Value (F) /= Null_Time then
790
                              if Use_ARINC653_API then
791 792 793
                                 N :=
                                   Map_Time_To_Millisecond
                                     (Get_Timeout_Value (F));
794 795 796 797
                              else
                                 N := Map_Time (Get_Timeout_Value (F));
                              end if;
                           else
798 799
                              N :=
                                CTU.Make_Literal (CV.New_Int_Value (0, 1, 10));
800 801 802 803
                           end if;
                           Append_Node_To_List (N, Call_Parameters);

                           if Get_Data_Representation
804 805 806
                               (Corresponding_Instance (F)) =
                             Data_Array
                           then
807
                              Append_Node_To_List
808 809
                                (Make_Defining_Identifier
                                   (Map_Port_Data (F, Current_Device)),
810 811 812
                                 Call_Parameters);
                           else
                              Append_Node_To_List
813 814 815 816
                                (Make_Variable_Address
                                   (Make_Defining_Identifier
                                      (Map_Port_Data (F, Current_Device))),
                                 Call_Parameters);
817 818 819
                           end if;

                           Append_Node_To_List
820 821 822 823
                             (Make_Variable_Address
                                (Make_Defining_Identifier
                                   (Map_Port_Var_Length (F, Current_Device))),
                              Call_Parameters);
824

825
                           Add_Return_Variable_In_Parameters (Call_Parameters);
826

827
                           Called_Function := RE (RE_Receive_Queuing_Message);
828 829 830 831 832 833

                           Type_Used := RE (RE_Queuing_Port_Id_Type);

                        else

                           Append_Node_To_List
834 835 836
                             (Make_Defining_Identifier
                                (Map_Port_Var (F, Current_Device)),
                              Call_Parameters);
837 838

                           if Get_Timeout_Value (F) /= Null_Time then
839
                              if Use_ARINC653_API then
840 841 842
                                 N :=
                                   Map_Time_To_Millisecond
                                     (Get_Timeout_Value (F));
843 844 845 846
                              else
                                 N := Map_Time (Get_Timeout_Value (F));
                              end if;
                           else
847 848
                              N :=
                                CTU.Make_Literal (CV.New_Int_Value (0, 1, 10));
849 850 851 852 853 854 855
                           end if;
                           Append_Node_To_List (N, Call_Parameters);

                           N := CTU.Get_Data_Size (Corresponding_Instance (F));
                           Append_Node_To_List (N, Call_Parameters);

                           if Get_Data_Representation
856 857 858
                               (Corresponding_Instance (F)) =
                             Data_Array
                           then
859
                              Append_Node_To_List
860 861
                                (Make_Defining_Identifier
                                   (Map_Port_Data (F, Current_Device)),
862 863 864
                                 Call_Parameters);
                           else
                              Append_Node_To_List
865 866 867 868
                                (Make_Variable_Address
                                   (Make_Defining_Identifier
                                      (Map_Port_Data (F, Current_Device))),
                                 Call_Parameters);
869 870 871
                           end if;

                           Append_Node_To_List
872 873 874 875
                             (Make_Variable_Address
                                (Make_Defining_Identifier
                                   (Map_Port_Var_Length (F, Current_Device))),
                              Call_Parameters);
876

877 878
                           Called_Function :=
                             RE (RE_Pok_Port_Queueing_Receive);
879 880 881 882 883

                           Type_Used := RE (RE_Uint8_T);

                        end if;

884 885 886 887
                        Function_Call :=
                          CTU.POK_Make_Function_Call_With_Assert
                            (Called_Function,
                             Call_Parameters);
888 889

                        Append_Node_To_List
890 891 892 893 894 895 896
                          (Make_Extern_Entity_Declaration
                             (Make_Variable_Declaration
                                (Defining_Identifier =>
                                   (Make_Defining_Identifier
                                      (Map_Port_Var (F, Current_Device))),
                                 Used_Type => Type_Used)),
                           CTN.Declarations (Current_File));
897

898
                        if Use_ARINC653_API then
899 900 901 902 903 904
                           Type_Used := RE (RE_Message_Size_Type);
                        else
                           Type_Used := RE (RE_Pok_Port_Size_T);
                        end if;

                        Append_Node_To_List
905 906 907 908 909 910
                          (Make_Variable_Declaration
                             (Defining_Identifier =>
                                (Make_Defining_Identifier
                                   (Map_Port_Var_Length (F, Current_Device))),
                              Used_Type => Type_Used),
                           Statements);
911 912
                     else
                        Append_Node_To_List
913 914
                          (Make_Defining_Identifier (Map_Port_Var (F)),
                           Call_Parameters);
915 916

                        if Get_Timeout_Value (F) /= Null_Time then
917
                           if Use_ARINC653_API then
918 919 920
                              N :=
                                Map_Time_To_Millisecond
                                  (Get_Timeout_Value (F));
921 922 923 924
                           else
                              N := Map_Time (Get_Timeout_Value (F));
                           end if;
                        else
925
                           N := CTU.Make_Literal (CV.New_Int_Value (0, 1, 10));
926 927 928 929
                        end if;
                        Append_Node_To_List (N, Call_Parameters);

                        if Get_Data_Representation
930 931 932
                            (Corresponding_Instance (F)) =
                          Data_Array
                        then
933
                           Append_Node_To_List
934
                             (Make_Defining_Identifier (Map_Port_Data (F)),
935 936 937
                              Call_Parameters);
                        else
                           Append_Node_To_List
938 939 940
                             (Make_Variable_Address
                                (Make_Defining_Identifier (Map_Port_Data (F))),
                              Call_Parameters);
941 942 943
                        end if;

                        Append_Node_To_List
944 945 946 947
                          (Make_Variable_Address
                             (Make_Defining_Identifier
                                (Map_Port_Var_Length (F))),
                           Call_Parameters);
948

949
                        if Use_ARINC653_API then
950
                           Add_Return_Variable_In_Parameters (Call_Parameters);
951 952 953 954 955 956

                           Called_Function := RE (RE_Receive_Buffer);
                        else
                           Called_Function := RE (RE_Pok_Buffer_Receive);
                        end if;

957 958 959 960
                        Function_Call :=
                          CTU.POK_Make_Function_Call_With_Assert
                            (Called_Function,
                             Call_Parameters);
961

962
                        if Use_ARINC653_API then
963 964 965 966 967 968
                           Type_Used := RE (RE_Message_Size_Type);
                        else
                           Type_Used := RE (RE_Pok_Port_Size_T);
                        end if;

                        Append_Node_To_List
969 970 971 972 973 974
                          (Make_Variable_Declaration
                             (Defining_Identifier =>
                                (Make_Defining_Identifier
                                   (Map_Port_Var_Length (F))),
                              Used_Type => Type_Used),
                           Statements);
975

976
                        if Use_ARINC653_API then
977 978 979 980 981 982
                           Type_Used := RE (RE_Buffer_Id_Type);
                        else
                           Type_Used := RE (RE_Uint8_T);
                        end if;

                        Append_Node_To_List
983 984 985 986 987 988 989
                          (Make_Extern_Entity_Declaration
                             (Make_Variable_Declaration
                                (Defining_Identifier =>
                                   (Make_Defining_Identifier
                                      (Map_Port_Var (F))),
                                 Used_Type => Type_Used)),
                           CTN.Declarations (Current_File));
990 991 992 993 994
                     end if;

                     Append_Node_To_List (Function_Call, WStatements);

                     POK_Add_Return_Assertion
995 996
                       (WStatements,
                        RE (RE_Pok_Errno_Empty));
997

998 999 1000 1001
                  elsif not AIN.Is_Data (F)
                    and then AIN.Is_Event (F)
                    and then Get_Connection_Pattern (F) = Intra_Process
                  then
1002 1003 1004 1005 1006 1007 1008 1009 1010
                     --  Now, handle events data ports across threads
                     --  located in the same partition.

                     Add_Include (RH (RH_Subprograms));

                     Compute_Entrypoint := Get_Port_Compute_Entrypoint (F);

                     if Compute_Entrypoint = No_Node then
                        Display_Error
1011 1012 1013
                          ("With a pure event port, the compute_entrypoint " &
                           "property must be set",
                           Fatal => True);
1014 1015 1016
                     end if;

                     Append_Node_To_List
1017
                       (Make_Defining_Identifier (Map_Port_Var (F)),
1018 1019 1020
                        Call_Parameters);

                     Append_Node_To_List
1021
                       (CTU.Make_Literal (CV.New_Int_Value (0, 1, 10)),
1022 1023
                        Call_Parameters);

1024
                     if Use_ARINC653_API then
1025 1026
                        Called_Function := RE (RE_Wait_Event);
                        Append_Node_To_List
1027 1028
                          (Make_Variable_Address
                             (Make_Defining_Identifier (VN (V_Ret))),
1029 1030
                           Call_Parameters);

1031 1032
                        N :=
                          Make_Call_Profile (Called_Function, Call_Parameters);
1033 1034
                     else
                        Called_Function := RE (RE_Pok_Event_Wait);
1035 1036 1037 1038 1039 1040 1041 1042 1043
                        N               :=
                          Make_Expression
                            (Left_Expr =>
                               Make_Defining_Identifier (VN (V_Ret)),
                             Operator   => Op_Equal,
                             Right_Expr =>
                               Make_Call_Profile
                                 (Called_Function,
                                  Call_Parameters));
1044 1045 1046 1047
                     end if;

                     Append_Node_To_List (N, WStatements);

1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061
                     N :=
                       Make_If_Statement
                         (Condition =>
                            Make_Expression
                              (Left_Expr =>
                                 Make_Defining_Identifier (VN (V_Ret)),
                               Operator   => Op_Equal_Equal,
                               Right_Expr => Get_Errcode_OK),
                          Statements =>
                            Make_List_Id
                              (Make_Call_Profile
                                 (Map_C_Defining_Identifier
                                    (Compute_Entrypoint),
                                  No_List)));
1062 1063
                     Append_Node_To_List (N, WStatements);

1064
                     if Use_ARINC653_API then
1065 1066 1067 1068 1069 1070
                        Type_Used := RE (RE_Event_Id_Type);
                     else
                        Type_Used := RE (RE_Pok_Event_Id_T);
                     end if;

                     Append_Node_To_List
1071 1072 1073 1074 1075 1076
                       (Make_Extern_Entity_Declaration
                          (Make_Variable_Declaration
                             (Defining_Identifier =>
                                (Make_Defining_Identifier (Map_Port_Var (F))),
                              Used_Type => Type_Used)),
                        CTN.Declarations (Current_File));
1077 1078 1079 1080 1081 1082 1083 1084
                  else
                     Display_Communication_Error;
                     --  Pattern not handled at this time
                  end if;

                  --  If we are in a device, then, we receive the data
                  --  that comes inside the device.

1085 1086 1087 1088
                  if Get_Connection_Pattern (F) = Inter_Process
                    and then Current_Device /= No_Node
                    and then Is_Virtual (Get_Port_By_Name (F, Current_Device))
                  then
1089 1090

                     Append_Node_To_List
1091 1092 1093 1094 1095 1096 1097
                       (Make_Extern_Entity_Declaration
                          (Make_Variable_Declaration
                             (Defining_Identifier =>
                                (Make_Defining_Identifier
                                   (Map_Port_Var (F, Current_Device))),
                              Used_Type => RE (RE_Uint8_T))),
                        CTN.Declarations (Current_File));
1098 1099 1100 1101

                     Call_Parameters := New_List (CTN.K_Parameter_List);

                     Append_Node_To_List
1102 1103 1104
                       (Make_Defining_Identifier
                          (Map_Port_Var (F, Current_Device)),
                        Call_Parameters);
1105 1106

                     Append_Node_To_List
1107 1108 1109 1110
                       (Make_Variable_Address
                          (Make_Defining_Identifier
                             (Map_Port_Data (F, Current_Device))),
                        Call_Parameters);
1111 1112

                     Append_Node_To_List
1113 1114 1115 1116
                       (Get_Inter_Partition_Port_Size
                          (Get_Port_By_Name
                             (Item (First_Node (Destinations (F))),
                              Current_Device)),
1117 1118
                        Call_Parameters);

1119 1120 1121 1122 1123
                     Function_Call :=
                       CTU.Make_Call_Profile
                         (Make_Defining_Identifier
                            (Map_Device_Function_Read (Current_Device)),
                          Call_Parameters);
1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142

                     Append_Node_To_List (Function_Call, WStatements);
                  end if;

               end if;

               F := Next_Node (F);
            end loop;
         end Make_Receive_In;

         --------------------------------
         -- Make_Potential_Assignments --
         --------------------------------

         procedure Make_Potential_Assignments is
            Statement : Node_Id;
            F         : Node_Id;
            D         : Node_Id;
         begin
1143 1144 1145
            Statement :=
              Message_Comment
                ("Copy directly the data from IN ports to OUT ports");
1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158
            Append_Node_To_List (Statement, WStatements);

            F := First_Node (Features (E));

            while Present (F) loop
               if Kind (F) = K_Port_Spec_Instance
                 and then Is_In (F)
                 and then not Is_Out (F)
                 and then Is_Data (F)
                 and then not AINU.Is_Empty (Destinations (F))
               then
                  D := First_Node (Destinations (F));
                  while Present (D) loop
1159 1160 1161
                     if Parent_Subcomponent (Parent_Component (Item (D))) =
                       Parent_Subcomponent (Parent_Component (F))
                     then
1162 1163

                        if Get_Data_Representation
1164 1165 1166
                            (Corresponding_Instance (F)) =
                          Data_Array
                        then
1167

1168
                           Statement := Message_Comment ("Must handle arrays");
1169
                        else
1170 1171 1172 1173 1174 1175 1176
                           Statement :=
                             Make_Expression
                               (Make_Defining_Identifier
                                  (Map_Port_Data (Item (D), Current_Device)),
                                Op_Equal,
                                Make_Defining_Identifier
                                  (Map_Port_Data (F, Current_Device)));
1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199
                        end if;

                        Append_Node_To_List (Statement, WStatements);
                     end if;
                     D := Next_Node (D);
                  end loop;
               end if;
               F := Next_Node (F);
            end loop;
         end Make_Potential_Assignments;

         --  If the thread has ports that are directly connected (no use of a
         --  subprogram), we automatically assign OUT ports with IN ports).

         ---------------------
         -- Make_End_Period --
         ---------------------

         procedure Make_End_Period is
         begin

            Call_Parameters := New_List (CTN.K_Parameter_List);

1200
            if Use_ARINC653_API then
1201 1202 1203 1204 1205 1206 1207
               Called_Function := RF (RE_Periodic_Wait);
               Add_Return_Variable_In_Parameters (Call_Parameters);
            else
               Called_Function := RE (RE_Pok_Thread_Period);
            end if;

            Append_Node_To_List
1208
              (CTU.Make_Call_Profile (Called_Function, Call_Parameters),
1209 1210 1211 1212 1213 1214 1215 1216
               WStatements);
         end Make_End_Period;

         -------------------
         -- Make_Send_Out --
         -------------------

         procedure Make_Send_Out is
1217 1218 1219 1220 1221 1222 1223
            N                : Node_Id;
            F                : Node_Id;
            Function_Call    : Node_Id;
            Source_Port      : Node_Id;
            Transport_Type   : Node_Id := No_Node;
            Virtual_Bus_Data : Node_Id := No_Node;
            Virtual_Bus_Size : Node_Id := No_Node;
1224 1225 1226 1227 1228 1229 1230 1231 1232 1233
         begin
            N := Message_Comment ("Send the OUT ports");
            Append_Node_To_List (N, WStatements);

            F := First_Node (Features (E));

            while Present (F) loop
               if Kind (F) = K_Port_Spec_Instance and then Is_Out (F) then

                  if Is_Data (F) then
1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247
                     if Current_Device /= No_Node
                       and then not AINU.Is_Empty (AIN.Sources (F))
                     then
                        Source_Port :=
                          AIN.Item (AIN.First_Node (AIN.Sources (F)));

                        if Is_Using_Virtual_Bus
                            (Get_Port_By_Name (Source_Port, Current_Device))
                        then
                           Transport_Type :=
                             Get_Inter_Partition_Port_Type
                               (Get_Port_By_Name
                                  (Source_Port,
                                   Current_Device));
1248
                        elsif Is_Using_Virtual_Bus
1249 1250 1251 1252 1253
                            (Get_Port_By_Name (F, Current_Device))
                        then
                           Transport_Type :=
                             Get_Inter_Partition_Port_Type
                               (Get_Port_By_Name (F, Current_Device));
1254 1255 1256
                        end if;

                        if Transport_Type = No_Node then
1257 1258 1259
                           Transport_Type :=
                             Map_C_Data_Type_Designator
                               (Corresponding_Instance (F));
1260 1261
                        end if;
                     else
1262 1263 1264
                        Transport_Type :=
                          Map_C_Data_Type_Designator
                            (Corresponding_Instance (F));
1265 1266 1267
                     end if;

                     Append_Node_To_List
1268 1269 1270 1271
                       (Make_Variable_Declaration
                          (Defining_Identifier =>
                             Make_Defining_Identifier
                               (Map_Port_Data (F, Current_Device)),
1272 1273 1274 1275 1276 1277
                           Used_Type => Transport_Type),
                        CTN.Declarations (Current_File));
                  end if;

                  --  If we are in a device, then, we send the data
                  --  that comes inside the device.
1278 1279 1280 1281 1282
                  if Get_Connection_Pattern (F) = Inter_Process
                    and then Is_Data (F)
                    and then Current_Device /= No_Node
                    and then Is_Virtual (Get_Port_By_Name (F, Current_Device))
                  then
1283

1284 1285
                     Source_Port :=
                       AIN.Item (AIN.First_Node (AIN.Sources (F)));
1286 1287

                     Append_Node_To_List
1288 1289 1290 1291 1292 1293 1294
                       (Make_Extern_Entity_Declaration
                          (Make_Variable_Declaration
                             (Defining_Identifier =>
                                (Make_Defining_Identifier
                                   (Map_Port_Var (F, Current_Device))),
                              Used_Type => RE (RE_Uint8_T))),
                        CTN.Declarations (Current_File));
1295 1296 1297 1298

                     Call_Parameters := New_List (CTN.K_Parameter_List);

                     Append_Node_To_List
1299 1300 1301
                       (Make_Defining_Identifier
                          (Map_Port_Var (F, Current_Device)),
                        Call_Parameters);
1302 1303

                     Append_Node_To_List
1304 1305 1306 1307
                       (Make_Variable_Address
                          (Make_Defining_Identifier
                             (Map_Port_Data (F, Current_Device))),
                        Call_Parameters);
1308 1309

                     Append_Node_To_List
1310 1311 1312
                       (Make_Defining_Identifier
                          (Map_Port_Var_Length (Source_Port, Current_Device)),
                        Call_Parameters);
1313

1314 1315 1316 1317 1318
                     Function_Call :=
                       CTU.Make_Call_Profile
                         (Make_Defining_Identifier
                            (Map_Device_Function_Write (Current_Device)),
                          Call_Parameters);
1319 1320 1321 1322 1323 1324 1325

                     Append_Node_To_List (Function_Call, WStatements);
                  end if;

                  Call_Parameters := New_List (CTN.K_Parameter_List);

                  if AIN.Is_Data (F) and then not AIN.Is_Event (F) then
1326 1327 1328 1329
                     if Get_Connection_Pattern (F) = Inter_Process
                       and then not Is_Virtual
                         (Get_Port_By_Name (F, Current_Device))
                     then
1330

1331
                        Source_Port := First_Node (Destinations (F));
1332

1333
                        while Source_Port /= No_Node loop
1334

1335 1336 1337 1338
                           Call_Parameters := New_List (CTN.K_Parameter_List);

                           if AIN.First_Node (AIN.Destinations (F)) /=
                             No_Node
1339
                           then
1340 1341
                              Map_Virtual_Bus_Calls
                                (AIN.Item
yoogx's avatar
yoogx committed
1342
                                   (AIN.First_Node (AIN.Destinations (F))),
1343 1344 1345 1346 1347 1348
                                 CTN.Declarations (Current_File),
                                 WStatements,
                                 Sending,
                                 Virtual_Bus_Data,
                                 Virtual_Bus_Size,
                                 Current_Device);
1349
                           end if;
1350

1351
                           Append_Node_To_List
1352 1353
                             (Make_Defining_Identifier
                                (Map_Port_Var
yoogx's avatar
yoogx committed
1354 1355
                                   (Item (Source_Port),
                                    Current_Device)),
1356
                              Call_Parameters);
1357

1358 1359 1360 1361
                           if Virtual_Bus_Data = No_Node then
                              if Get_Data_Representation
                                  (Corresponding_Instance (F)) =
                                Data_Array
1362
                              then
1363 1364 1365 1366 1367 1368 1369 1370 1371 1372
                                 Append_Node_To_List
                                   (Make_Defining_Identifier
                                      (Map_Port_Data (F, Current_Device)),
                                    Call_Parameters);
                              else
                                 Append_Node_To_List
                                   (Make_Variable_Address
                                      (Make_Defining_Identifier
                                         (Map_Port_Data (F, Current_Device))),
                                    Call_Parameters);
1373
                              end if;
1374 1375
                           else
                              Append_Node_To_List
yoogx's avatar
yoogx committed
1376
                                (Make_Variable_Address (Virtual_Bus_Data),
1377
                                 Call_Parameters);
1378 1379
                           end if;

1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396
                           if Virtual_Bus_Size /= No_Node then
                              N := Copy_Node (Virtual_Bus_Size);
                           else
                              if Current_Device = No_Node then
                                 N := Get_Inter_Partition_Port_Size (F);
                              else
                                 N :=
                                   Get_Inter_Partition_Port_Size
                                     (Get_Port_By_Name (F, Current_Device));

                                 if Is_Using_Virtual_Bus
                                     (Get_Port_By_Name (F, Current_Device))
                                 then
                                    Add_Include (RH (RH_Protocols));
                                 end if;
                              end if;
                           end if;
1397

1398
                           Append_Node_To_List (N, Call_Parameters);
1399

1400 1401
                           if Use_ARINC653_API then
                              Add_Return_Variable_In_Parameters
yoogx's avatar
yoogx committed
1402
                                (Call_Parameters);
1403
                              Called_Function :=
yoogx's avatar
yoogx committed
1404 1405
                                RE (RE_Write_Sampling_Message);
                              Type_Used := RE (RE_Sampling_Port_Id_Type);
1406 1407
                           else
                              Called_Function :=
yoogx's avatar
yoogx committed
1408 1409
                                RE (RE_Pok_Port_Sampling_Write);
                              Type_Used := RE (RE_Uint8_T);
1410
                           end if;
1411

1412 1413 1414 1415