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-2004 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
41 -- used for Short_Address
43 with System
.Parameters
;
47 with System
.Tasking
.Initialization
;
49 with System
.Task_Primitives
.Operations
;
51 with System
.Task_Primitives
.Operations
.DEC
;
53 with Unchecked_Conversion
;
55 package body System
.Interrupt_Management
.Operations
is
57 use System
.OS_Interface
;
58 use System
.Parameters
;
60 use type unsigned_short
;
62 function To_Address
is new Unchecked_Conversion
(Task_Id
, System
.Address
);
63 package POP
renames System
.Task_Primitives
.Operations
;
65 ----------------------------
66 -- Thread_Block_Interrupt --
67 ----------------------------
69 procedure Thread_Block_Interrupt
(Interrupt
: Interrupt_ID
) is
70 pragma Warnings
(Off
, Interrupt
);
73 end Thread_Block_Interrupt
;
75 ------------------------------
76 -- Thread_Unblock_Interrupt --
77 ------------------------------
79 procedure Thread_Unblock_Interrupt
(Interrupt
: Interrupt_ID
) is
80 pragma Warnings
(Off
, Interrupt
);
83 end Thread_Unblock_Interrupt
;
85 ------------------------
86 -- Set_Interrupt_Mask --
87 ------------------------
89 procedure Set_Interrupt_Mask
(Mask
: access Interrupt_Mask
) is
90 pragma Warnings
(Off
, Mask
);
93 end Set_Interrupt_Mask
;
95 procedure Set_Interrupt_Mask
96 (Mask
: access Interrupt_Mask
;
97 OMask
: access Interrupt_Mask
)
99 pragma Warnings
(Off
, Mask
);
100 pragma Warnings
(Off
, OMask
);
103 end Set_Interrupt_Mask
;
105 ------------------------
106 -- Get_Interrupt_Mask --
107 ------------------------
109 procedure Get_Interrupt_Mask
(Mask
: access Interrupt_Mask
) is
110 pragma Warnings
(Off
, Mask
);
113 end Get_Interrupt_Mask
;
119 function To_unsigned_long
is new
120 Unchecked_Conversion
(System
.Aux_DEC
.Short_Address
, unsigned_long
);
122 function Interrupt_Wait
(Mask
: access Interrupt_Mask
)
125 Self_ID
: constant Task_Id
:= Self
;
126 Iosb
: IO_Status_Block_Type
:= (0, 0, 0);
127 Status
: Cond_Value_Type
;
131 -- A QIO read is registered. The system call returns immediately
132 -- after scheduling an AST to be fired when the operation
137 Chan
=> Rcv_Interrupt_Chan
,
141 POP
.DEC
.Interrupt_AST_Handler
'Access,
142 Astprm
=> To_Address
(Self_ID
),
143 P1
=> To_unsigned_long
(Interrupt_Mailbox
'Address),
144 P2
=> Interrupt_ID
'Size / 8);
146 pragma Assert
((Status
and 1) = 1);
150 -- Wait to be woken up. Could be that the AST has fired,
151 -- in which case the Iosb.Status variable will be non-zero,
152 -- or maybe the wait is being aborted.
156 System
.Tasking
.Interrupt_Server_Blocked_On_Event_Flag
);
158 if Iosb
.Status
/= 0 then
159 if (Iosb
.Status
and 1) = 1
160 and then Mask
(Signal
(Interrupt_Mailbox
))
162 return Interrupt_Mailbox
;
167 POP
.Unlock
(Self_ID
);
173 System
.Tasking
.Initialization
.Undefer_Abort
(Self_ID
);
174 System
.Tasking
.Initialization
.Defer_Abort
(Self_ID
);
180 POP
.Write_Lock
(Self_ID
);
185 ----------------------------
186 -- Install_Default_Action --
187 ----------------------------
189 procedure Install_Default_Action
(Interrupt
: Interrupt_ID
) is
190 pragma Warnings
(Off
, Interrupt
);
193 end Install_Default_Action
;
195 ---------------------------
196 -- Install_Ignore_Action --
197 ---------------------------
199 procedure Install_Ignore_Action
(Interrupt
: Interrupt_ID
) is
200 pragma Warnings
(Off
, Interrupt
);
203 end Install_Ignore_Action
;
205 -------------------------
206 -- Fill_Interrupt_Mask --
207 -------------------------
209 procedure Fill_Interrupt_Mask
(Mask
: access Interrupt_Mask
) is
211 Mask
.all := (others => True);
212 end Fill_Interrupt_Mask
;
214 --------------------------
215 -- Empty_Interrupt_Mask --
216 --------------------------
218 procedure Empty_Interrupt_Mask
(Mask
: access Interrupt_Mask
) is
220 Mask
.all := (others => False);
221 end Empty_Interrupt_Mask
;
223 ---------------------------
224 -- Add_To_Interrupt_Mask --
225 ---------------------------
227 procedure Add_To_Interrupt_Mask
228 (Mask
: access Interrupt_Mask
;
229 Interrupt
: Interrupt_ID
)
232 Mask
(Signal
(Interrupt
)) := True;
233 end Add_To_Interrupt_Mask
;
235 --------------------------------
236 -- Delete_From_Interrupt_Mask --
237 --------------------------------
239 procedure Delete_From_Interrupt_Mask
240 (Mask
: access Interrupt_Mask
;
241 Interrupt
: Interrupt_ID
)
244 Mask
(Signal
(Interrupt
)) := False;
245 end Delete_From_Interrupt_Mask
;
252 (Mask
: access Interrupt_Mask
;
253 Interrupt
: Interrupt_ID
) return Boolean
256 return Mask
(Signal
(Interrupt
));
259 -------------------------
260 -- Copy_Interrupt_Mask --
261 -------------------------
263 procedure Copy_Interrupt_Mask
264 (X
: out Interrupt_Mask
;
269 end Copy_Interrupt_Mask
;
271 -------------------------
272 -- Interrupt_Self_Process --
273 -------------------------
275 procedure Interrupt_Self_Process
(Interrupt
: Interrupt_ID
) is
276 Status
: Cond_Value_Type
;
280 Chan
=> Snd_Interrupt_Chan
,
281 Func
=> IO_WRITEVBLK
,
282 P1
=> To_unsigned_long
(Interrupt
'Address),
283 P2
=> Interrupt_ID
'Size / 8);
285 pragma Assert
((Status
and 1) = 1);
286 end Interrupt_Self_Process
;
289 Environment_Mask
:= (others => False);
290 All_Tasks_Mask
:= (others => True);
292 for J
in Interrupt_ID
loop
293 if Keep_Unmasked
(J
) then
294 Environment_Mask
(Signal
(J
)) := True;
295 All_Tasks_Mask
(Signal
(J
)) := False;
298 end System
.Interrupt_Management
.Operations
;