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 --
11 -- Copyright (C) 1991-2001 Florida State University --
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. --
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. --
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). --
35 ------------------------------------------------------------------------------
37 -- This is a OpenVMS/Alpha version of this package.
39 with System
.OS_Interface
;
40 -- used for various type, constant, and operations
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
;
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
68 end Thread_Block_Interrupt
;
70 ------------------------------
71 -- Thread_Unblock_Interrupt --
72 ------------------------------
74 procedure Thread_Unblock_Interrupt
(Interrupt
: Interrupt_ID
) is
77 end Thread_Unblock_Interrupt
;
79 ------------------------
80 -- Set_Interrupt_Mask --
81 ------------------------
83 procedure Set_Interrupt_Mask
(Mask
: access Interrupt_Mask
) is
86 end Set_Interrupt_Mask
;
88 procedure Set_Interrupt_Mask
89 (Mask
: access Interrupt_Mask
;
90 OMask
: access Interrupt_Mask
) is
93 end Set_Interrupt_Mask
;
95 ------------------------
96 -- Get_Interrupt_Mask --
97 ------------------------
99 procedure Get_Interrupt_Mask
(Mask
: access Interrupt_Mask
) is
102 end Get_Interrupt_Mask
;
108 function To_unsigned_long
is new
109 Unchecked_Conversion
(System
.Address
, unsigned_long
);
111 function Interrupt_Wait
(Mask
: access Interrupt_Mask
)
114 Self_ID
: Task_ID
:= Self
;
115 Iosb
: IO_Status_Block_Type
:= (0, 0, 0);
116 Status
: Cond_Value_Type
;
120 -- A QIO read is registered. The system call returns immediately
121 -- after scheduling an AST to be fired when the operation
126 Chan
=> Rcv_Interrupt_Chan
,
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);
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.
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
))
151 return Interrupt_Mailbox
;
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
);
164 ----------------------------
165 -- Install_Default_Action --
166 ----------------------------
168 procedure Install_Default_Action
(Interrupt
: Interrupt_ID
) is
171 end Install_Default_Action
;
173 ---------------------------
174 -- Install_Ignore_Action --
175 ---------------------------
177 procedure Install_Ignore_Action
(Interrupt
: Interrupt_ID
) is
180 end Install_Ignore_Action
;
182 -------------------------
183 -- Fill_Interrupt_Mask --
184 -------------------------
186 procedure Fill_Interrupt_Mask
(Mask
: access Interrupt_Mask
) is
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
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
)
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
)
221 Mask
(Signal
(Interrupt
)) := False;
222 end Delete_From_Interrupt_Mask
;
229 (Mask
: access Interrupt_Mask
;
230 Interrupt
: Interrupt_ID
) return Boolean
233 return Mask
(Signal
(Interrupt
));
236 -------------------------
237 -- Copy_Interrupt_Mask --
238 -------------------------
240 procedure Copy_Interrupt_Mask
241 (X
: out Interrupt_Mask
;
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
;
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
;
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;
278 end System
.Interrupt_Management
.Operations
;