1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
5 -- SYSTEM.INTERRUPT_MANAGEMENT.OPERATIONS --
9 -- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
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 2, or (at your option) any later ver- --
14 -- sion. GNARL 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. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNARL; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNARL was developed by the GNARL team at Florida State University. --
30 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
32 ------------------------------------------------------------------------------
34 -- This is a OpenVMS/Alpha version of this package.
36 with System
.OS_Interface
;
37 -- used for various type, constant, and operations
40 -- used for Short_Address
42 with System
.Parameters
;
46 with System
.Tasking
.Initialization
;
48 with System
.Task_Primitives
.Operations
;
50 with System
.Task_Primitives
.Operations
.DEC
;
52 with Unchecked_Conversion
;
54 package body System
.Interrupt_Management
.Operations
is
56 use System
.OS_Interface
;
57 use System
.Parameters
;
59 use type unsigned_short
;
61 function To_Address
is new Unchecked_Conversion
(Task_Id
, System
.Address
);
62 package POP
renames System
.Task_Primitives
.Operations
;
64 ----------------------------
65 -- Thread_Block_Interrupt --
66 ----------------------------
68 procedure Thread_Block_Interrupt
(Interrupt
: Interrupt_ID
) is
69 pragma Warnings
(Off
, Interrupt
);
72 end Thread_Block_Interrupt
;
74 ------------------------------
75 -- Thread_Unblock_Interrupt --
76 ------------------------------
78 procedure Thread_Unblock_Interrupt
(Interrupt
: Interrupt_ID
) is
79 pragma Warnings
(Off
, Interrupt
);
82 end Thread_Unblock_Interrupt
;
84 ------------------------
85 -- Set_Interrupt_Mask --
86 ------------------------
88 procedure Set_Interrupt_Mask
(Mask
: access Interrupt_Mask
) is
89 pragma Warnings
(Off
, Mask
);
92 end Set_Interrupt_Mask
;
94 procedure Set_Interrupt_Mask
95 (Mask
: access Interrupt_Mask
;
96 OMask
: access Interrupt_Mask
)
98 pragma Warnings
(Off
, Mask
);
99 pragma Warnings
(Off
, OMask
);
102 end Set_Interrupt_Mask
;
104 ------------------------
105 -- Get_Interrupt_Mask --
106 ------------------------
108 procedure Get_Interrupt_Mask
(Mask
: access Interrupt_Mask
) is
109 pragma Warnings
(Off
, Mask
);
112 end Get_Interrupt_Mask
;
118 function To_unsigned_long
is new
119 Unchecked_Conversion
(System
.Aux_DEC
.Short_Address
, unsigned_long
);
121 function Interrupt_Wait
(Mask
: access Interrupt_Mask
)
124 Self_ID
: constant Task_Id
:= Self
;
125 Iosb
: IO_Status_Block_Type
:= (0, 0, 0);
126 Status
: Cond_Value_Type
;
130 -- A QIO read is registered. The system call returns immediately
131 -- after scheduling an AST to be fired when the operation
136 Chan
=> Rcv_Interrupt_Chan
,
140 POP
.DEC
.Interrupt_AST_Handler
'Access,
141 Astprm
=> To_Address
(Self_ID
),
142 P1
=> To_unsigned_long
(Interrupt_Mailbox
'Address),
143 P2
=> Interrupt_ID
'Size / 8);
145 pragma Assert
((Status
and 1) = 1);
149 -- Wait to be woken up. Could be that the AST has fired,
150 -- in which case the Iosb.Status variable will be non-zero,
151 -- or maybe the wait is being aborted.
155 System
.Tasking
.Interrupt_Server_Blocked_On_Event_Flag
);
157 if Iosb
.Status
/= 0 then
158 if (Iosb
.Status
and 1) = 1
159 and then Mask
(Signal
(Interrupt_Mailbox
))
161 return Interrupt_Mailbox
;
166 POP
.Unlock
(Self_ID
);
172 System
.Tasking
.Initialization
.Undefer_Abort
(Self_ID
);
173 System
.Tasking
.Initialization
.Defer_Abort
(Self_ID
);
179 POP
.Write_Lock
(Self_ID
);
184 ----------------------------
185 -- Install_Default_Action --
186 ----------------------------
188 procedure Install_Default_Action
(Interrupt
: Interrupt_ID
) is
189 pragma Warnings
(Off
, Interrupt
);
192 end Install_Default_Action
;
194 ---------------------------
195 -- Install_Ignore_Action --
196 ---------------------------
198 procedure Install_Ignore_Action
(Interrupt
: Interrupt_ID
) is
199 pragma Warnings
(Off
, Interrupt
);
202 end Install_Ignore_Action
;
204 -------------------------
205 -- Fill_Interrupt_Mask --
206 -------------------------
208 procedure Fill_Interrupt_Mask
(Mask
: access Interrupt_Mask
) is
210 Mask
.all := (others => True);
211 end Fill_Interrupt_Mask
;
213 --------------------------
214 -- Empty_Interrupt_Mask --
215 --------------------------
217 procedure Empty_Interrupt_Mask
(Mask
: access Interrupt_Mask
) is
219 Mask
.all := (others => False);
220 end Empty_Interrupt_Mask
;
222 ---------------------------
223 -- Add_To_Interrupt_Mask --
224 ---------------------------
226 procedure Add_To_Interrupt_Mask
227 (Mask
: access Interrupt_Mask
;
228 Interrupt
: Interrupt_ID
)
231 Mask
(Signal
(Interrupt
)) := True;
232 end Add_To_Interrupt_Mask
;
234 --------------------------------
235 -- Delete_From_Interrupt_Mask --
236 --------------------------------
238 procedure Delete_From_Interrupt_Mask
239 (Mask
: access Interrupt_Mask
;
240 Interrupt
: Interrupt_ID
)
243 Mask
(Signal
(Interrupt
)) := False;
244 end Delete_From_Interrupt_Mask
;
251 (Mask
: access Interrupt_Mask
;
252 Interrupt
: Interrupt_ID
) return Boolean
255 return Mask
(Signal
(Interrupt
));
258 -------------------------
259 -- Copy_Interrupt_Mask --
260 -------------------------
262 procedure Copy_Interrupt_Mask
263 (X
: out Interrupt_Mask
;
268 end Copy_Interrupt_Mask
;
270 ----------------------------
271 -- Interrupt_Self_Process --
272 ----------------------------
274 procedure Interrupt_Self_Process
(Interrupt
: Interrupt_ID
) is
275 Status
: Cond_Value_Type
;
279 Chan
=> Snd_Interrupt_Chan
,
280 Func
=> IO_WRITEVBLK
,
281 P1
=> To_unsigned_long
(Interrupt
'Address),
282 P2
=> Interrupt_ID
'Size / 8);
284 pragma Assert
((Status
and 1) = 1);
285 end Interrupt_Self_Process
;
287 --------------------------
288 -- Setup_Interrupt_Mask --
289 --------------------------
291 procedure Setup_Interrupt_Mask
is
294 end Setup_Interrupt_Mask
;
297 Interrupt_Management
.Initialize
;
298 Environment_Mask
:= (others => False);
299 All_Tasks_Mask
:= (others => True);
301 for J
in Interrupt_ID
loop
302 if Keep_Unmasked
(J
) then
303 Environment_Mask
(Signal
(J
)) := True;
304 All_Tasks_Mask
(Signal
(J
)) := False;
307 end System
.Interrupt_Management
.Operations
;