OSDN Git Service

2007-04-20 Ed Schonberg <schonberg@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-intman-vms.ads
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) 1991-2005 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 2,  or (at your option) any later ver- --
14 -- sion. GNARL 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.  See the GNU General Public License --
17 -- for  more details.  You should have  received  a copy of the GNU General --
18 -- Public License  distributed with GNARL; see file COPYING.  If not, write --
19 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, USA.                                              --
21 --                                                                          --
22 -- As a special exception,  if other files  instantiate  generics from this --
23 -- unit, or you link  this unit with other files  to produce an executable, --
24 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
25 -- covered  by the  GNU  General  Public  License.  This exception does not --
26 -- however invalidate  any other reasons why  the executable file  might be --
27 -- covered by the  GNU Public License.                                      --
28 --                                                                          --
29 -- GNARL was developed by the GNARL team at Florida State University.       --
30 -- Extensive contributions were provided by Ada Core Technologies, Inc.     --
31 --                                                                          --
32 ------------------------------------------------------------------------------
33
34 --  This is the Alpha/VMS version of this package
35
36 --  This package encapsulates and centralizes information about all uses of
37 --  interrupts (or signals), including the target-dependent mapping of
38 --  interrupts (or signals) to exceptions.
39
40 --  PLEASE DO NOT add any with-clauses to this package
41
42 --  PLEASE DO NOT put any subprogram declarations with arguments of type
43 --  Interrupt_ID into the visible part of this package.
44
45 --  The type Interrupt_ID is used to derive the type in Ada.Interrupts, and
46 --  adding more operations to that type would be illegal according to the Ada
47 --  Reference Manual. (This is the reason why the signals sets below are
48 --  implemented as visible arrays rather than functions.)
49
50 with System.OS_Interface;
51 --  used for Signal
52 --           sigset_t
53
54 package System.Interrupt_Management is
55    pragma Preelaborate;
56
57    type Interrupt_Mask is limited private;
58
59    type Interrupt_ID is new System.OS_Interface.Signal;
60
61    type Interrupt_Set is array (Interrupt_ID) of Boolean;
62
63    --  The following objects serve as constants, but are initialized in the
64    --  body to aid portability. This permits us to use more portable names for
65    --  interrupts, where distinct names may map to the same interrupt ID
66    --  value. For example, suppose SIGRARE is a signal that is not defined on
67    --  all systems, but is always reserved when it is defined. If we have the
68    --  convention that ID zero is not used for any "real" signals, and SIGRARE
69    --  = 0 when SIGRARE is not one of the locally supported signals, we can
70    --  write
71
72    --     Reserved (SIGRARE) := true;
73
74    --  Then the initialization code will be portable
75
76    Abort_Task_Interrupt : Interrupt_ID;
77    --  The interrupt that is used to implement task abort, if an interrupt is
78    --  used for that purpose. This is one of the reserved interrupts.
79
80    Keep_Unmasked : Interrupt_Set := (others => False);
81    --  Keep_Unmasked (I) is true iff the interrupt I is one that must be kept
82    --  unmasked at all times, except (perhaps) for short critical sections.
83    --  This includes interrupts that are mapped to exceptions (see
84    --  System.Interrupt_Exceptions.Is_Exception), but may also include
85    --  interrupts (e.g. timer) that need to be kept unmasked for other
86    --  reasons. Where interrupts are implemented as OS signals, and signal
87    --  masking is per-task, the interrupt should be unmasked in ALL TASKS.
88
89    Reserve : Interrupt_Set := (others => False);
90    --  Reserve (I) is true iff the interrupt I is one that cannot be permitted
91    --  to be attached to a user handler. The possible reasons are many. For
92    --  example it may be mapped to an exception used to implement task abort.
93
94    Keep_Masked : Interrupt_Set := (others => False);
95    --  Keep_Masked (I) is true iff the interrupt I must always be masked.
96    --  Where interrupts are implemented as OS signals, and signal masking is
97    --  per-task, the interrupt should be masked in ALL TASKS. There might not
98    --  be any interrupts in this class, depending on the environment. For
99    --  example, if interrupts are OS signals and signal masking is per-task,
100    --  use of the sigwait operation requires the signal be masked in all tasks.
101
102    procedure Initialize;
103    --  Initialize the various variables defined in this package.
104    --  This procedure must be called before accessing any object from this
105    --  package and can be called multiple times.
106
107 private
108    use type System.OS_Interface.unsigned_long;
109
110    type Interrupt_Mask is new System.OS_Interface.sigset_t;
111
112    --  Interrupts on VMS are implemented with a mailbox. A QIO read is
113    --  registered on the Rcv channel and the interrupt occurs by registering
114    --  a QIO write on the Snd channel. The maximum number of pending
115    --  interrupts is arbitrarily set at 1000. One nice feature of using
116    --  a mailbox is that it is trivially extendable to cross process
117    --  interrupts.
118
119    Rcv_Interrupt_Chan : System.OS_Interface.unsigned_short := 0;
120    Snd_Interrupt_Chan : System.OS_Interface.unsigned_short := 0;
121    Interrupt_Mailbox  : Interrupt_ID := 0;
122    Interrupt_Bufquo   : System.OS_Interface.unsigned_long :=
123                           1000 * (Interrupt_ID'Size / 8);
124
125 end System.Interrupt_Management;