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 -- Copyright (C) 1992-2002 Free Software Foundation, Inc. --
12 -- GNARL is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNARL; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
23 -- As a special exception, if other files instantiate generics from this --
24 -- unit, or you link this unit with other files to produce an executable, --
25 -- this unit does not by itself cause the resulting executable to be --
26 -- covered by the GNU General Public License. This exception does not --
27 -- however invalidate any other reasons why the executable file might be --
28 -- covered by the GNU Public License. --
30 -- GNARL was developed by the GNARL team at Florida State University. --
31 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
33 ------------------------------------------------------------------------------
35 -- This is a OpenVMS/Alpha version of this package.
37 with System.OS_Interface;
38 -- used for various type, constant, and operations
40 with System.Parameters;
44 with System.Tasking.Initialization;
46 with System.Task_Primitives.Operations;
48 with System.Task_Primitives.Operations.DEC;
50 with Unchecked_Conversion;
52 package body System.Interrupt_Management.Operations is
54 use System.OS_Interface;
55 use System.Parameters;
57 use type unsigned_short;
59 function To_Address is new Unchecked_Conversion (Task_ID, System.Address);
60 package POP renames System.Task_Primitives.Operations;
62 ----------------------------
63 -- Thread_Block_Interrupt --
64 ----------------------------
66 procedure Thread_Block_Interrupt (Interrupt : Interrupt_ID) is
67 pragma Warnings (Off, Interrupt);
70 end Thread_Block_Interrupt;
72 ------------------------------
73 -- Thread_Unblock_Interrupt --
74 ------------------------------
76 procedure Thread_Unblock_Interrupt (Interrupt : Interrupt_ID) is
77 pragma Warnings (Off, Interrupt);
80 end Thread_Unblock_Interrupt;
82 ------------------------
83 -- Set_Interrupt_Mask --
84 ------------------------
86 procedure Set_Interrupt_Mask (Mask : access Interrupt_Mask) is
87 pragma Warnings (Off, Mask);
90 end Set_Interrupt_Mask;
92 procedure Set_Interrupt_Mask
93 (Mask : access Interrupt_Mask;
94 OMask : access Interrupt_Mask)
96 pragma Warnings (Off, Mask);
97 pragma Warnings (Off, OMask);
100 end Set_Interrupt_Mask;
102 ------------------------
103 -- Get_Interrupt_Mask --
104 ------------------------
106 procedure Get_Interrupt_Mask (Mask : access Interrupt_Mask) is
107 pragma Warnings (Off, Mask);
110 end Get_Interrupt_Mask;
116 function To_unsigned_long is new
117 Unchecked_Conversion (System.Address, unsigned_long);
119 function Interrupt_Wait (Mask : access Interrupt_Mask)
122 Self_ID : Task_ID := Self;
123 Iosb : IO_Status_Block_Type := (0, 0, 0);
124 Status : Cond_Value_Type;
128 -- A QIO read is registered. The system call returns immediately
129 -- after scheduling an AST to be fired when the operation
134 Chan => Rcv_Interrupt_Chan,
138 POP.DEC.Interrupt_AST_Handler'Access,
139 Astprm => To_Address (Self_ID),
140 P1 => To_unsigned_long (Interrupt_Mailbox'Address),
141 P2 => Interrupt_ID'Size / 8);
143 pragma Assert ((Status and 1) = 1);
147 -- Wait to be woken up. Could be that the AST has fired,
148 -- in which case the Iosb.Status variable will be non-zero,
149 -- or maybe the wait is being aborted.
153 System.Tasking.Interrupt_Server_Blocked_On_Event_Flag);
155 if Iosb.Status /= 0 then
156 if (Iosb.Status and 1) = 1
157 and then Mask (Signal (Interrupt_Mailbox))
159 return Interrupt_Mailbox;
164 POP.Unlock (Self_ID);
170 System.Tasking.Initialization.Undefer_Abort (Self_ID);
171 System.Tasking.Initialization.Defer_Abort (Self_ID);
177 POP.Write_Lock (Self_ID);
182 ----------------------------
183 -- Install_Default_Action --
184 ----------------------------
186 procedure Install_Default_Action (Interrupt : Interrupt_ID) is
187 pragma Warnings (Off, Interrupt);
190 end Install_Default_Action;
192 ---------------------------
193 -- Install_Ignore_Action --
194 ---------------------------
196 procedure Install_Ignore_Action (Interrupt : Interrupt_ID) is
197 pragma Warnings (Off, Interrupt);
200 end Install_Ignore_Action;
202 -------------------------
203 -- Fill_Interrupt_Mask --
204 -------------------------
206 procedure Fill_Interrupt_Mask (Mask : access Interrupt_Mask) is
208 Mask.all := (others => True);
209 end Fill_Interrupt_Mask;
211 --------------------------
212 -- Empty_Interrupt_Mask --
213 --------------------------
215 procedure Empty_Interrupt_Mask (Mask : access Interrupt_Mask) is
217 Mask.all := (others => False);
218 end Empty_Interrupt_Mask;
220 ---------------------------
221 -- Add_To_Interrupt_Mask --
222 ---------------------------
224 procedure Add_To_Interrupt_Mask
225 (Mask : access Interrupt_Mask;
226 Interrupt : Interrupt_ID)
229 Mask (Signal (Interrupt)) := True;
230 end Add_To_Interrupt_Mask;
232 --------------------------------
233 -- Delete_From_Interrupt_Mask --
234 --------------------------------
236 procedure Delete_From_Interrupt_Mask
237 (Mask : access Interrupt_Mask;
238 Interrupt : Interrupt_ID)
241 Mask (Signal (Interrupt)) := False;
242 end Delete_From_Interrupt_Mask;
249 (Mask : access Interrupt_Mask;
250 Interrupt : Interrupt_ID) return Boolean
253 return Mask (Signal (Interrupt));
256 -------------------------
257 -- Copy_Interrupt_Mask --
258 -------------------------
260 procedure Copy_Interrupt_Mask
261 (X : out Interrupt_Mask;
266 end Copy_Interrupt_Mask;
268 -------------------------
269 -- Interrupt_Self_Process --
270 -------------------------
272 procedure Interrupt_Self_Process (Interrupt : Interrupt_ID) is
273 Status : Cond_Value_Type;
277 Chan => Snd_Interrupt_Chan,
278 Func => IO_WRITEVBLK,
279 P1 => To_unsigned_long (Interrupt'Address),
280 P2 => Interrupt_ID'Size / 8);
282 pragma Assert ((Status and 1) = 1);
283 end Interrupt_Self_Process;
286 Environment_Mask := (others => False);
287 All_Tasks_Mask := (others => True);
289 for J in Interrupt_ID loop
290 if Keep_Unmasked (J) then
291 Environment_Mask (Signal (J)) := True;
292 All_Tasks_Mask (Signal (J)) := False;
295 end System.Interrupt_Management.Operations;