File : s-interr-raven-vxworks.adb


   1 ------------------------------------------------------------------------------
   2 --                                                                          --
   3 --                 GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                 --
   4 --                                                                          --
   5 --                     S Y S T E M . I N T E R R U P T S                    --
   6 --                                                                          --
   7 --                                  B o d y                                 --
   8 --                                                                          --
   9 --                     Copyright (C) 2001-2013, AdaCore                     --
  10 --                                                                          --
  11 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  12 -- terms of the  GNU General Public License as published  by the Free Soft- --
  13 -- ware  Foundation;  either version 3,  or (at your option) any later ver- --
  14 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  15 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  16 -- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
  17 --                                                                          --
  18 --                                                                          --
  19 --                                                                          --
  20 --                                                                          --
  21 --                                                                          --
  22 -- You should have received a copy of the GNU General Public License and    --
  23 -- a copy of the GCC Runtime Library Exception along with this program;     --
  24 -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
  25 -- <http://www.gnu.org/licenses/>.                                          --
  26 --                                                                          --
  27 -- GNARL was developed by the GNARL team at Florida State University.       --
  28 -- Extensive contributions were provided by Ada Core Technologies, Inc.     --
  29 --                                                                          --
  30 ------------------------------------------------------------------------------
  31 
  32 --  This is the VxWorks/Cert version of this package
  33 
  34 with Interfaces.VxWorks;
  35 with System.OS_Interface; use System.OS_Interface;
  36 with System.Tasking.Restricted.Stages;
  37 
  38 package body System.Interrupts is
  39 
  40    -----------------------
  41    -- Local Subprograms --
  42    -----------------------
  43 
  44    type Handlers_Array is array (Interrupt_ID) of Parameterless_Handler;
  45    pragma Suppress_Initialization (Handlers_Array);
  46 
  47    User_Handlers : Handlers_Array := (others => null);
  48    --  The actual handlers
  49 
  50    procedure Install_Handler (Interrupt : Interrupt_ID);
  51    --  Install the runtime umbrella handler for a vectored hardware interrupt
  52 
  53    procedure Default_Handler (Interrupt : System.Address);
  54    --  Default interrupt handler
  55 
  56    ---------------------
  57    -- Default_Handler --
  58    ---------------------
  59 
  60    procedure Default_Handler (Interrupt : System.Address) is
  61    begin
  62       User_Handlers (Interrupt_ID (Interrupt)).all;
  63    end Default_Handler;
  64 
  65    ---------------------
  66    -- Install_Handler --
  67    ---------------------
  68 
  69    procedure Install_Handler (Interrupt : Interrupt_ID) is
  70       Stat : Interfaces.VxWorks.STATUS;
  71       pragma Unreferenced (Stat);
  72    begin
  73       Stat := Interfaces.VxWorks.intConnect
  74         (Interfaces.VxWorks.Interrupt_Vector (System.Address (Interrupt)),
  75          Default_Handler'Access,
  76          System.Address (Interrupt));
  77    end Install_Handler;
  78 
  79    ---------------------------------
  80    -- Install_Restricted_Handlers --
  81    ---------------------------------
  82 
  83    procedure Install_Restricted_Handlers
  84      (Prio     : Any_Priority;
  85       Handlers : Handler_Array)
  86    is
  87       pragma Unreferenced (Prio);
  88       use System.Tasking.Restricted.Stages;
  89 
  90    begin
  91       for J in Handlers'Range loop
  92 
  93          --  Copy the handler in the table that contains the user handlers
  94 
  95          User_Handlers (Handlers (J).Interrupt) := Handlers (J).Handler;
  96 
  97          --  Install the handler now, unless attachment is deferred because of
  98          --  sequential partition elaboration policy.
  99 
 100          if Partition_Elaboration_Policy /= 'S' then
 101             Install_Handler (Handlers (J).Interrupt);
 102          end if;
 103       end loop;
 104    end Install_Restricted_Handlers;
 105 
 106    --------------------------------------------
 107    -- Install_Restricted_Handlers_Sequential --
 108    --------------------------------------------
 109 
 110    procedure Install_Restricted_Handlers_Sequential is
 111    begin
 112       for J in User_Handlers'Range loop
 113          if User_Handlers (J) /= null then
 114             Install_Handler (J);
 115          end if;
 116       end loop;
 117    end Install_Restricted_Handlers_Sequential;
 118 
 119 end System.Interrupts;