1 ------------------------------------------------------------------------------
3 -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
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 -- O P E R A T I O N S --
10 -- $Revision: 1.8 $ --
12 -- Copyright (C) 1991-2000 Florida State University --
14 -- GNARL is free software; you can redistribute it and/or modify it under --
15 -- terms of the GNU General Public License as published by the Free Soft- --
16 -- ware Foundation; either version 2, or (at your option) any later ver- --
17 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
18 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
19 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
20 -- for more details. You should have received a copy of the GNU General --
21 -- Public License distributed with GNARL; see file COPYING. If not, write --
22 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
23 -- MA 02111-1307, USA. --
25 -- As a special exception, if other files instantiate generics from this --
26 -- unit, or you link this unit with other files to produce an executable, --
27 -- this unit does not by itself cause the resulting executable to be --
28 -- covered by the GNU General Public License. This exception does not --
29 -- however invalidate any other reasons why the executable file might be --
30 -- covered by the GNU Public License. --
32 -- GNARL was developed by the GNARL team at Florida State University. It is --
33 -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
34 -- State University (http://www.gnat.com). --
36 ------------------------------------------------------------------------------
38 -- This is a OpenVMS/Alpha version of this package.
40 with System.OS_Interface;
41 -- used for various type, constant, and operations
45 with System.Tasking.Initialization;
47 with System.Task_Primitives.Operations;
49 with System.Task_Primitives.Operations.DEC;
51 with Unchecked_Conversion;
53 package body System.Interrupt_Management.Operations is
55 use System.OS_Interface;
57 use type unsigned_short;
59 function To_Address is new Unchecked_Conversion (Task_ID, System.Address);
60 function To_Task_ID is new Unchecked_Conversion (System.Address, Task_ID);
61 package POP renames System.Task_Primitives.Operations;
63 ----------------------------
64 -- Thread_Block_Interrupt --
65 ----------------------------
67 procedure Thread_Block_Interrupt (Interrupt : Interrupt_ID) is
70 end Thread_Block_Interrupt;
72 ------------------------------
73 -- Thread_Unblock_Interrupt --
74 ------------------------------
76 procedure Thread_Unblock_Interrupt (Interrupt : Interrupt_ID) is
79 end Thread_Unblock_Interrupt;
81 ------------------------
82 -- Set_Interrupt_Mask --
83 ------------------------
85 procedure Set_Interrupt_Mask (Mask : access Interrupt_Mask) is
88 end Set_Interrupt_Mask;
90 procedure Set_Interrupt_Mask
91 (Mask : access Interrupt_Mask;
92 OMask : access Interrupt_Mask) is
95 end Set_Interrupt_Mask;
97 ------------------------
98 -- Get_Interrupt_Mask --
99 ------------------------
101 procedure Get_Interrupt_Mask (Mask : access Interrupt_Mask) is
104 end Get_Interrupt_Mask;
110 function To_unsigned_long is new
111 Unchecked_Conversion (System.Address, unsigned_long);
113 function Interrupt_Wait (Mask : access Interrupt_Mask)
116 Self_ID : Task_ID := Self;
117 Iosb : IO_Status_Block_Type := (0, 0, 0);
118 Status : Cond_Value_Type;
122 -- A QIO read is registered. The system call returns immediately
123 -- after scheduling an AST to be fired when the operation
128 Chan => Rcv_Interrupt_Chan,
132 POP.DEC.Interrupt_AST_Handler'Access,
133 Astprm => To_Address (Self_ID),
134 P1 => To_unsigned_long (Interrupt_Mailbox'Address),
135 P2 => Interrupt_ID'Size / 8);
137 pragma Assert ((Status and 1) = 1);
141 -- Wait to be woken up. Could be that the AST has fired,
142 -- in which case the Iosb.Status variable will be non-zero,
143 -- or maybe the wait is being aborted.
147 System.Tasking.Interrupt_Server_Blocked_On_Event_Flag);
149 if Iosb.Status /= 0 then
150 if (Iosb.Status and 1) = 1
151 and then Mask (Signal (Interrupt_Mailbox))
153 return Interrupt_Mailbox;
158 POP.Unlock (Self_ID);
159 System.Tasking.Initialization.Undefer_Abort (Self_ID);
160 System.Tasking.Initialization.Defer_Abort (Self_ID);
161 POP.Write_Lock (Self_ID);
166 ----------------------------
167 -- Install_Default_Action --
168 ----------------------------
170 procedure Install_Default_Action (Interrupt : Interrupt_ID) is
173 end Install_Default_Action;
175 ---------------------------
176 -- Install_Ignore_Action --
177 ---------------------------
179 procedure Install_Ignore_Action (Interrupt : Interrupt_ID) is
182 end Install_Ignore_Action;
184 -------------------------
185 -- Fill_Interrupt_Mask --
186 -------------------------
188 procedure Fill_Interrupt_Mask (Mask : access Interrupt_Mask) is
190 Mask.all := (others => True);
191 end Fill_Interrupt_Mask;
193 --------------------------
194 -- Empty_Interrupt_Mask --
195 --------------------------
197 procedure Empty_Interrupt_Mask (Mask : access Interrupt_Mask) is
199 Mask.all := (others => False);
200 end Empty_Interrupt_Mask;
202 ---------------------------
203 -- Add_To_Interrupt_Mask --
204 ---------------------------
206 procedure Add_To_Interrupt_Mask
207 (Mask : access Interrupt_Mask;
208 Interrupt : Interrupt_ID)
211 Mask (Signal (Interrupt)) := True;
212 end Add_To_Interrupt_Mask;
214 --------------------------------
215 -- Delete_From_Interrupt_Mask --
216 --------------------------------
218 procedure Delete_From_Interrupt_Mask
219 (Mask : access Interrupt_Mask;
220 Interrupt : Interrupt_ID)
223 Mask (Signal (Interrupt)) := False;
224 end Delete_From_Interrupt_Mask;
231 (Mask : access Interrupt_Mask;
232 Interrupt : Interrupt_ID) return Boolean
235 return Mask (Signal (Interrupt));
238 -------------------------
239 -- Copy_Interrupt_Mask --
240 -------------------------
242 procedure Copy_Interrupt_Mask
243 (X : out Interrupt_Mask;
248 end Copy_Interrupt_Mask;
250 -------------------------
251 -- Interrupt_Self_Process --
252 -------------------------
254 procedure Interrupt_Self_Process (Interrupt : Interrupt_ID) is
255 Status : Cond_Value_Type;
259 Chan => Snd_Interrupt_Chan,
260 Func => IO_WRITEVBLK,
261 P1 => To_unsigned_long (Interrupt'Address),
262 P2 => Interrupt_ID'Size / 8);
264 pragma Assert ((Status and 1) = 1);
266 end Interrupt_Self_Process;
270 Environment_Mask := (others => False);
271 All_Tasks_Mask := (others => True);
273 for I in Interrupt_ID loop
274 if Keep_Unmasked (I) then
275 Environment_Mask (Signal (I)) := True;
276 All_Tasks_Mask (Signal (I)) := False;
280 end System.Interrupt_Management.Operations;