PR target/9164
[official-gcc.git] / gcc / ada / 5vinmaop.adb
blob6eb6b74014587d51378bab62b8a9dd09056768c1
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 -- --
11 -- Copyright (C) 1991-2001 Florida State University --
12 -- --
13 -- GNARL is free software; you can redistribute it and/or modify it under --
14 -- terms of the GNU General Public License as published by the Free Soft- --
15 -- ware Foundation; either version 2, or (at your option) any later ver- --
16 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
19 -- for more details. You should have received a copy of the GNU General --
20 -- Public License distributed with GNARL; see file COPYING. If not, write --
21 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
22 -- MA 02111-1307, USA. --
23 -- --
24 -- As a special exception, if other files instantiate generics from this --
25 -- unit, or you link this unit with other files to produce an executable, --
26 -- this unit does not by itself cause the resulting executable to be --
27 -- covered by the GNU General Public License. This exception does not --
28 -- however invalidate any other reasons why the executable file might be --
29 -- covered by the GNU Public License. --
30 -- --
31 -- GNARL was developed by the GNARL team at Florida State University. It is --
32 -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
33 -- State University (http://www.gnat.com). --
34 -- --
35 ------------------------------------------------------------------------------
37 -- This is a OpenVMS/Alpha version of this package.
39 with System.OS_Interface;
40 -- used for various type, constant, and operations
42 with System.Tasking;
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.Tasking;
56 use type unsigned_short;
58 function To_Address is new Unchecked_Conversion (Task_ID, System.Address);
59 package POP renames System.Task_Primitives.Operations;
61 ----------------------------
62 -- Thread_Block_Interrupt --
63 ----------------------------
65 procedure Thread_Block_Interrupt (Interrupt : Interrupt_ID) is
66 begin
67 null;
68 end Thread_Block_Interrupt;
70 ------------------------------
71 -- Thread_Unblock_Interrupt --
72 ------------------------------
74 procedure Thread_Unblock_Interrupt (Interrupt : Interrupt_ID) is
75 begin
76 null;
77 end Thread_Unblock_Interrupt;
79 ------------------------
80 -- Set_Interrupt_Mask --
81 ------------------------
83 procedure Set_Interrupt_Mask (Mask : access Interrupt_Mask) is
84 begin
85 null;
86 end Set_Interrupt_Mask;
88 procedure Set_Interrupt_Mask
89 (Mask : access Interrupt_Mask;
90 OMask : access Interrupt_Mask) is
91 begin
92 null;
93 end Set_Interrupt_Mask;
95 ------------------------
96 -- Get_Interrupt_Mask --
97 ------------------------
99 procedure Get_Interrupt_Mask (Mask : access Interrupt_Mask) is
100 begin
101 null;
102 end Get_Interrupt_Mask;
104 --------------------
105 -- Interrupt_Wait --
106 --------------------
108 function To_unsigned_long is new
109 Unchecked_Conversion (System.Address, unsigned_long);
111 function Interrupt_Wait (Mask : access Interrupt_Mask)
112 return Interrupt_ID
114 Self_ID : Task_ID := Self;
115 Iosb : IO_Status_Block_Type := (0, 0, 0);
116 Status : Cond_Value_Type;
118 begin
120 -- A QIO read is registered. The system call returns immediately
121 -- after scheduling an AST to be fired when the operation
122 -- completes.
124 Sys_QIO
125 (Status => Status,
126 Chan => Rcv_Interrupt_Chan,
127 Func => IO_READVBLK,
128 Iosb => Iosb,
129 Astadr =>
130 POP.DEC.Interrupt_AST_Handler'Access,
131 Astprm => To_Address (Self_ID),
132 P1 => To_unsigned_long (Interrupt_Mailbox'Address),
133 P2 => Interrupt_ID'Size / 8);
135 pragma Assert ((Status and 1) = 1);
137 loop
139 -- Wait to be woken up. Could be that the AST has fired,
140 -- in which case the Iosb.Status variable will be non-zero,
141 -- or maybe the wait is being aborted.
143 POP.Sleep
144 (Self_ID,
145 System.Tasking.Interrupt_Server_Blocked_On_Event_Flag);
147 if Iosb.Status /= 0 then
148 if (Iosb.Status and 1) = 1
149 and then Mask (Signal (Interrupt_Mailbox))
150 then
151 return Interrupt_Mailbox;
152 else
153 return 0;
154 end if;
155 else
156 POP.Unlock (Self_ID);
157 System.Tasking.Initialization.Undefer_Abort (Self_ID);
158 System.Tasking.Initialization.Defer_Abort (Self_ID);
159 POP.Write_Lock (Self_ID);
160 end if;
161 end loop;
162 end Interrupt_Wait;
164 ----------------------------
165 -- Install_Default_Action --
166 ----------------------------
168 procedure Install_Default_Action (Interrupt : Interrupt_ID) is
169 begin
170 null;
171 end Install_Default_Action;
173 ---------------------------
174 -- Install_Ignore_Action --
175 ---------------------------
177 procedure Install_Ignore_Action (Interrupt : Interrupt_ID) is
178 begin
179 null;
180 end Install_Ignore_Action;
182 -------------------------
183 -- Fill_Interrupt_Mask --
184 -------------------------
186 procedure Fill_Interrupt_Mask (Mask : access Interrupt_Mask) is
187 begin
188 Mask.all := (others => True);
189 end Fill_Interrupt_Mask;
191 --------------------------
192 -- Empty_Interrupt_Mask --
193 --------------------------
195 procedure Empty_Interrupt_Mask (Mask : access Interrupt_Mask) is
196 begin
197 Mask.all := (others => False);
198 end Empty_Interrupt_Mask;
200 ---------------------------
201 -- Add_To_Interrupt_Mask --
202 ---------------------------
204 procedure Add_To_Interrupt_Mask
205 (Mask : access Interrupt_Mask;
206 Interrupt : Interrupt_ID)
208 begin
209 Mask (Signal (Interrupt)) := True;
210 end Add_To_Interrupt_Mask;
212 --------------------------------
213 -- Delete_From_Interrupt_Mask --
214 --------------------------------
216 procedure Delete_From_Interrupt_Mask
217 (Mask : access Interrupt_Mask;
218 Interrupt : Interrupt_ID)
220 begin
221 Mask (Signal (Interrupt)) := False;
222 end Delete_From_Interrupt_Mask;
224 ---------------
225 -- Is_Member --
226 ---------------
228 function Is_Member
229 (Mask : access Interrupt_Mask;
230 Interrupt : Interrupt_ID) return Boolean
232 begin
233 return Mask (Signal (Interrupt));
234 end Is_Member;
236 -------------------------
237 -- Copy_Interrupt_Mask --
238 -------------------------
240 procedure Copy_Interrupt_Mask
241 (X : out Interrupt_Mask;
242 Y : Interrupt_Mask)
244 begin
245 X := Y;
246 end Copy_Interrupt_Mask;
248 -------------------------
249 -- Interrupt_Self_Process --
250 -------------------------
252 procedure Interrupt_Self_Process (Interrupt : Interrupt_ID) is
253 Status : Cond_Value_Type;
254 begin
255 Sys_QIO
256 (Status => Status,
257 Chan => Snd_Interrupt_Chan,
258 Func => IO_WRITEVBLK,
259 P1 => To_unsigned_long (Interrupt'Address),
260 P2 => Interrupt_ID'Size / 8);
262 pragma Assert ((Status and 1) = 1);
264 end Interrupt_Self_Process;
266 begin
268 Environment_Mask := (others => False);
269 All_Tasks_Mask := (others => True);
271 for I in Interrupt_ID loop
272 if Keep_Unmasked (I) then
273 Environment_Mask (Signal (I)) := True;
274 All_Tasks_Mask (Signal (I)) := False;
275 end if;
276 end loop;
278 end System.Interrupt_Management.Operations;