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 _ M A N A G E M E N T         --
6--                                                                          --
7--                                  S p e c                                 --
8--                                                                          --
9--          Copyright (C) 1992-2011, Free Software Foundation, Inc.         --
10--                                                                          --
11-- GNARL 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-- As a special exception under Section 7 of GPL version 3, you are granted --
19-- additional permissions described in the GCC Runtime Library Exception,   --
20-- version 3.1, as published by the Free Software Foundation.               --
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 version of this package
33
34--  This package encapsulates and centralizes information about all
35--  uses of interrupts (or signals), including the target-dependent
36--  mapping of interrupts (or signals) to exceptions.
37
38--  Unlike the original design, System.Interrupt_Management can only
39--  be used for tasking systems.
40
41--  PLEASE DO NOT put any subprogram declarations with arguments of
42--  type Interrupt_ID into the visible part of this package. The type
43--  Interrupt_ID is used to derive the type in Ada.Interrupts, and
44--  adding more operations to that type would be illegal according
45--  to the Ada Reference Manual. This is the reason why the signals
46--  sets are implemented using visible arrays rather than functions.
47
48with System.OS_Interface;
49
50with Interfaces.C;
51
52package System.Interrupt_Management is
53   pragma Preelaborate;
54
55   type Interrupt_Mask is limited private;
56
57   type Interrupt_ID is new Interfaces.C.int
58     range 0 .. System.OS_Interface.Max_Interrupt;
59
60   type Interrupt_Set is array (Interrupt_ID) of Boolean;
61
62   subtype Signal_ID is Interrupt_ID range 0 .. System.OS_Interface.NSIG - 1;
63
64   type Signal_Set is array (Signal_ID) of Boolean;
65
66   --  The following objects serve as constants, but are initialized in the
67   --  body to aid portability. This permits us to use more portable names for
68   --  interrupts, where distinct names may map to the same interrupt ID
69   --  value.
70
71   --  For example, suppose SIGRARE is a signal that is not defined on all
72   --  systems, but is always reserved when it is defined. If we have the
73   --  convention that ID zero is not used for any "real" signals, and SIGRARE
74   --  = 0 when SIGRARE is not one of the locally supported signals, we can
75   --  write:
76   --     Reserved (SIGRARE) := True;
77   --  and the initialization code will be portable.
78
79   Abort_Task_Interrupt : Signal_ID;
80   --  The signal that is used to implement task abort if an interrupt is used
81   --  for that purpose. This is one of the reserved signals.
82
83   Reserve : Interrupt_Set := (others => False);
84   --  Reserve (I) is true iff the interrupt I is one that cannot be permitted
85   --  to be attached to a user handler. The possible reasons are many. For
86   --  example, it may be mapped to an exception used to implement task abort,
87   --  or used to implement time delays.
88
89   procedure Initialize_Interrupts;
90   pragma Import (C, Initialize_Interrupts, "__gnat_install_handler");
91   --  Under VxWorks, there is no signal inheritance between tasks.
92   --  This procedure is used to initialize signal-to-exception mapping in
93   --  each task.
94
95   procedure Initialize;
96   --  Initialize the various variables defined in this package. This procedure
97   --  must be called before accessing any object from this package and can be
98   --  called multiple times (only the first call has any effect).
99
100private
101   type Interrupt_Mask is new System.OS_Interface.sigset_t;
102   --  In some implementation Interrupt_Mask can be represented as a linked
103   --  list.
104
105end System.Interrupt_Management;
106