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-2009, 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 Alpha/VMS version of this package 33 34-- This package encapsulates and centralizes information about all uses of 35-- interrupts (or signals), including the target-dependent mapping of 36-- interrupts (or signals) to exceptions. 37 38-- PLEASE DO NOT add any with-clauses to this package 39 40-- PLEASE DO NOT put any subprogram declarations with arguments of type 41-- Interrupt_ID into the visible part of this package. 42 43-- The type Interrupt_ID is used to derive the type in Ada.Interrupts, and 44-- adding more operations to that type would be illegal according to the Ada 45-- Reference Manual. (This is the reason why the signals sets below are 46-- implemented as visible arrays rather than functions.) 47 48with System.OS_Interface; 49 50package System.Interrupt_Management is 51 pragma Preelaborate; 52 53 type Interrupt_Mask is limited private; 54 55 type Interrupt_ID is new System.OS_Interface.Signal; 56 57 type Interrupt_Set is array (Interrupt_ID) of Boolean; 58 59 -- The following objects serve as constants, but are initialized in the 60 -- body to aid portability. This permits us to use more portable names for 61 -- interrupts, where distinct names may map to the same interrupt ID 62 -- value. For example, suppose SIGRARE is a signal that is not defined on 63 -- all systems, but is always reserved when it is defined. If we have the 64 -- convention that ID zero is not used for any "real" signals, and SIGRARE 65 -- = 0 when SIGRARE is not one of the locally supported signals, we can 66 -- write: 67 -- Reserved (SIGRARE) := true; 68 -- Then the initialization code will be portable. 69 70 Abort_Task_Interrupt : Interrupt_ID; 71 -- The interrupt that is used to implement task abort, if an interrupt is 72 -- used for that purpose. This is one of the reserved interrupts. 73 74 Keep_Unmasked : Interrupt_Set := (others => False); 75 -- Keep_Unmasked (I) is true iff the interrupt I is one that must be kept 76 -- unmasked at all times, except (perhaps) for short critical sections. 77 -- This includes interrupts that are mapped to exceptions (see 78 -- System.Interrupt_Exceptions.Is_Exception), but may also include 79 -- interrupts (e.g. timer) that need to be kept unmasked for other 80 -- reasons. Where interrupts are implemented as OS signals, and signal 81 -- masking is per-task, the interrupt should be unmasked in ALL TASKS. 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 88 Keep_Masked : Interrupt_Set := (others => False); 89 -- Keep_Masked (I) is true iff the interrupt I must always be masked. 90 -- Where interrupts are implemented as OS signals, and signal masking is 91 -- per-task, the interrupt should be masked in ALL TASKS. There might not 92 -- be any interrupts in this class, depending on the environment. For 93 -- example, if interrupts are OS signals and signal masking is per-task, 94 -- use of the sigwait operation requires the signal be masked in all tasks. 95 96 procedure Initialize; 97 -- Initialize the various variables defined in this package. 98 -- This procedure must be called before accessing any object from this 99 -- package and can be called multiple times. 100 101private 102 use type System.OS_Interface.unsigned_long; 103 104 type Interrupt_Mask is new System.OS_Interface.sigset_t; 105 106 -- Interrupts on VMS are implemented with a mailbox. A QIO read is 107 -- registered on the Rcv channel and the interrupt occurs by registering 108 -- a QIO write on the Snd channel. The maximum number of pending 109 -- interrupts is arbitrarily set at 1000. One nice feature of using 110 -- a mailbox is that it is trivially extendable to cross process 111 -- interrupts. 112 113 Rcv_Interrupt_Chan : System.OS_Interface.unsigned_short := 0; 114 Snd_Interrupt_Chan : System.OS_Interface.unsigned_short := 0; 115 Interrupt_Mailbox : Interrupt_ID := 0; 116 Interrupt_Bufquo : System.OS_Interface.unsigned_long := 117 1000 * (Interrupt_ID'Size / 8); 118 119end System.Interrupt_Management; 120