OSDN Git Service

PR target/34091
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-intman-vxworks.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) 1992-2007, 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 VxWorks version of this package
35
36 --  This package encapsulates and centralizes information about all
37 --  uses of interrupts (or signals), including the target-dependent
38 --  mapping of interrupts (or signals) to exceptions.
39
40 --  Unlike the original design, System.Interrupt_Management can only
41 --  be used for tasking systems.
42
43 --  PLEASE DO NOT put any subprogram declarations with arguments of
44 --  type Interrupt_ID into the visible part of this package. The type
45 --  Interrupt_ID is used to derive the type in Ada.Interrupts, and
46 --  adding more operations to that type would be illegal according
47 --  to the Ada Reference Manual. This is the reason why the signals
48 --  sets are implemeneted using visible arrays rather than functions.
49
50 with System.OS_Interface;
51 --  used for sigset_t
52
53 with Interfaces.C;
54 --  used for int
55
56 package System.Interrupt_Management is
57    pragma Preelaborate;
58
59    type Interrupt_Mask is limited private;
60
61    type Interrupt_ID is new Interfaces.C.int
62      range 0 .. System.OS_Interface.Max_Interrupt;
63
64    type Interrupt_Set is array (Interrupt_ID) of Boolean;
65
66    subtype Signal_ID is Interrupt_ID
67      range 0 .. Interfaces.C."-" (System.OS_Interface.NSIG, 1);
68
69    type Signal_Set is array (Signal_ID) of Boolean;
70
71    --  The following objects serve as constants, but are initialized in the
72    --  body to aid portability. This permits us to use more portable names for
73    --  interrupts, where distinct names may map to the same interrupt ID
74    --  value.
75
76    --  For example, suppose SIGRARE is a signal that is not defined on all
77    --  systems, but is always reserved when it is defined. If we have the
78    --  convention that ID zero is not used for any "real" signals, and SIGRARE
79    --  = 0 when SIGRARE is not one of the locally supported signals, we can
80    --  write:
81    --     Reserved (SIGRARE) := true;
82    --  and the initialization code will be portable.
83
84    Abort_Task_Interrupt : Signal_ID;
85    --  The signal that is used to implement task abort if an interrupt is used
86    --  for that purpose. This is one of the reserved signals.
87
88    Keep_Unmasked : Signal_Set := (others => False);
89    --  Keep_Unmasked (I) is true iff the signal I is one that must that must
90    --  be kept unmasked at all times, except (perhaps) for short critical
91    --  sections. This includes signals that are mapped to exceptions, but may
92    --  also include interrupts (e.g. timer) that need to be kept unmasked for
93    --  other reasons. Where signal masking is per-task, the signal should be
94    --  unmasked in ALL TASKS.
95
96    Reserve : Interrupt_Set := (others => False);
97    --  Reserve (I) is true iff the interrupt I is one that cannot be permitted
98    --  to be attached to a user handler. The possible reasons are many. For
99    --  example, it may be mapped to an exception used to implement task abort,
100    --  or used to implement time delays.
101
102    procedure Initialize_Interrupts;
103    --  Under VxWorks, there is no signal inheritance between tasks.
104    --  This procedure is used to initialize signal-to-exception mapping in
105    --  each task.
106
107    procedure Initialize;
108    --  Initialize the various variables defined in this package.
109    --  This procedure must be called before accessing any object from this
110    --  package and can be called multiple times.
111
112 private
113    type Interrupt_Mask is new System.OS_Interface.sigset_t;
114    --  In some implementation Interrupt_Mask can be represented as a linked
115    --  list.
116
117 end System.Interrupt_Management;