PR c++/11509
[official-gcc.git] / gcc / ada / 5vinmaop.adb
blobe5c8eeedf7ba7c5280578e12481852f9be5cfe12
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNU ADA 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 -- O P E R A T I O N S --
7 -- --
8 -- B o d y --
9 -- --
10 -- Copyright (C) 1991-2001 Florida State University --
11 -- --
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. --
22 -- --
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. --
29 -- --
30 -- GNARL was developed by the GNARL team at Florida State University. It is --
31 -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
32 -- State University (http://www.gnat.com). --
33 -- --
34 ------------------------------------------------------------------------------
36 -- This is a OpenVMS/Alpha version of this package.
38 with System.OS_Interface;
39 -- used for various type, constant, and operations
41 with System.Tasking;
43 with System.Tasking.Initialization;
45 with System.Task_Primitives.Operations;
47 with System.Task_Primitives.Operations.DEC;
49 with Unchecked_Conversion;
51 package body System.Interrupt_Management.Operations is
53 use System.OS_Interface;
54 use System.Tasking;
55 use type unsigned_short;
57 function To_Address is new Unchecked_Conversion (Task_ID, System.Address);
58 package POP renames System.Task_Primitives.Operations;
60 ----------------------------
61 -- Thread_Block_Interrupt --
62 ----------------------------
64 procedure Thread_Block_Interrupt (Interrupt : Interrupt_ID) is
65 begin
66 null;
67 end Thread_Block_Interrupt;
69 ------------------------------
70 -- Thread_Unblock_Interrupt --
71 ------------------------------
73 procedure Thread_Unblock_Interrupt (Interrupt : Interrupt_ID) is
74 begin
75 null;
76 end Thread_Unblock_Interrupt;
78 ------------------------
79 -- Set_Interrupt_Mask --
80 ------------------------
82 procedure Set_Interrupt_Mask (Mask : access Interrupt_Mask) is
83 begin
84 null;
85 end Set_Interrupt_Mask;
87 procedure Set_Interrupt_Mask
88 (Mask : access Interrupt_Mask;
89 OMask : access Interrupt_Mask) is
90 begin
91 null;
92 end Set_Interrupt_Mask;
94 ------------------------
95 -- Get_Interrupt_Mask --
96 ------------------------
98 procedure Get_Interrupt_Mask (Mask : access Interrupt_Mask) is
99 begin
100 null;
101 end Get_Interrupt_Mask;
103 --------------------
104 -- Interrupt_Wait --
105 --------------------
107 function To_unsigned_long is new
108 Unchecked_Conversion (System.Address, unsigned_long);
110 function Interrupt_Wait (Mask : access Interrupt_Mask)
111 return Interrupt_ID
113 Self_ID : Task_ID := Self;
114 Iosb : IO_Status_Block_Type := (0, 0, 0);
115 Status : Cond_Value_Type;
117 begin
119 -- A QIO read is registered. The system call returns immediately
120 -- after scheduling an AST to be fired when the operation
121 -- completes.
123 Sys_QIO
124 (Status => Status,
125 Chan => Rcv_Interrupt_Chan,
126 Func => IO_READVBLK,
127 Iosb => Iosb,
128 Astadr =>
129 POP.DEC.Interrupt_AST_Handler'Access,
130 Astprm => To_Address (Self_ID),
131 P1 => To_unsigned_long (Interrupt_Mailbox'Address),
132 P2 => Interrupt_ID'Size / 8);
134 pragma Assert ((Status and 1) = 1);
136 loop
138 -- Wait to be woken up. Could be that the AST has fired,
139 -- in which case the Iosb.Status variable will be non-zero,
140 -- or maybe the wait is being aborted.
142 POP.Sleep
143 (Self_ID,
144 System.Tasking.Interrupt_Server_Blocked_On_Event_Flag);
146 if Iosb.Status /= 0 then
147 if (Iosb.Status and 1) = 1
148 and then Mask (Signal (Interrupt_Mailbox))
149 then
150 return Interrupt_Mailbox;
151 else
152 return 0;
153 end if;
154 else
155 POP.Unlock (Self_ID);
156 System.Tasking.Initialization.Undefer_Abort (Self_ID);
157 System.Tasking.Initialization.Defer_Abort (Self_ID);
158 POP.Write_Lock (Self_ID);
159 end if;
160 end loop;
161 end Interrupt_Wait;
163 ----------------------------
164 -- Install_Default_Action --
165 ----------------------------
167 procedure Install_Default_Action (Interrupt : Interrupt_ID) is
168 begin
169 null;
170 end Install_Default_Action;
172 ---------------------------
173 -- Install_Ignore_Action --
174 ---------------------------
176 procedure Install_Ignore_Action (Interrupt : Interrupt_ID) is
177 begin
178 null;
179 end Install_Ignore_Action;
181 -------------------------
182 -- Fill_Interrupt_Mask --
183 -------------------------
185 procedure Fill_Interrupt_Mask (Mask : access Interrupt_Mask) is
186 begin
187 Mask.all := (others => True);
188 end Fill_Interrupt_Mask;
190 --------------------------
191 -- Empty_Interrupt_Mask --
192 --------------------------
194 procedure Empty_Interrupt_Mask (Mask : access Interrupt_Mask) is
195 begin
196 Mask.all := (others => False);
197 end Empty_Interrupt_Mask;
199 ---------------------------
200 -- Add_To_Interrupt_Mask --
201 ---------------------------
203 procedure Add_To_Interrupt_Mask
204 (Mask : access Interrupt_Mask;
205 Interrupt : Interrupt_ID)
207 begin
208 Mask (Signal (Interrupt)) := True;
209 end Add_To_Interrupt_Mask;
211 --------------------------------
212 -- Delete_From_Interrupt_Mask --
213 --------------------------------
215 procedure Delete_From_Interrupt_Mask
216 (Mask : access Interrupt_Mask;
217 Interrupt : Interrupt_ID)
219 begin
220 Mask (Signal (Interrupt)) := False;
221 end Delete_From_Interrupt_Mask;
223 ---------------
224 -- Is_Member --
225 ---------------
227 function Is_Member
228 (Mask : access Interrupt_Mask;
229 Interrupt : Interrupt_ID) return Boolean
231 begin
232 return Mask (Signal (Interrupt));
233 end Is_Member;
235 -------------------------
236 -- Copy_Interrupt_Mask --
237 -------------------------
239 procedure Copy_Interrupt_Mask
240 (X : out Interrupt_Mask;
241 Y : Interrupt_Mask)
243 begin
244 X := Y;
245 end Copy_Interrupt_Mask;
247 -------------------------
248 -- Interrupt_Self_Process --
249 -------------------------
251 procedure Interrupt_Self_Process (Interrupt : Interrupt_ID) is
252 Status : Cond_Value_Type;
253 begin
254 Sys_QIO
255 (Status => Status,
256 Chan => Snd_Interrupt_Chan,
257 Func => IO_WRITEVBLK,
258 P1 => To_unsigned_long (Interrupt'Address),
259 P2 => Interrupt_ID'Size / 8);
261 pragma Assert ((Status and 1) = 1);
263 end Interrupt_Self_Process;
265 begin
267 Environment_Mask := (others => False);
268 All_Tasks_Mask := (others => True);
270 for I in Interrupt_ID loop
271 if Keep_Unmasked (I) then
272 Environment_Mask (Signal (I)) := True;
273 All_Tasks_Mask (Signal (I)) := False;
274 end if;
275 end loop;
277 end System.Interrupt_Management.Operations;