1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>AARM95 - The Package Interrupts</TITLE>
<META NAME="Author" CONTENT="JTC1/SC22/WG9/ARG, by Randall Brukardt, ARG Editor">
<META NAME="GENERATOR" CONTENT="Arm_Form.Exe, Ada Reference Manual generator">
<STYLE type="text/css">
DIV.paranum {position: absolute; font-family: Arial, Helvetica, sans-serif; left: 0.5 em; top: auto}
TT {font-family: "Courier New", monospace}
DT {display: compact}
DIV.Normal {font-family: "Times New Roman", Times, serif; margin-bottom: 0.6em}
DIV.Wide {font-family: "Times New Roman", Times, serif; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Annotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.WideAnnotations {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0.6em; margin-bottom: 0.6em}
DIV.Index {font-family: "Times New Roman", Times, serif}
DIV.SyntaxSummary {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Notes {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.NotesHeader {font-family: "Times New Roman", Times, serif; margin-left: 2.0em}
DIV.SyntaxIndented {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-bottom: 0.4em}
DIV.Indented {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-bottom: 0.6em}
DIV.CodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-bottom: 0.6em}
DIV.SmallIndented {font-family: "Times New Roman", Times, serif; margin-left: 10.0em; margin-bottom: 0.6em}
DIV.SmallCodeIndented {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.Examples {font-family: "Courier New", monospace; margin-left: 2.0em; margin-bottom: 0.6em}
DIV.SmallExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 7.5em; margin-bottom: 0.6em}
DIV.IndentedExamples {font-family: "Courier New", monospace; margin-left: 8.0em; margin-bottom: 0.6em}
DIV.SmallIndentedExamples {font-family: "Courier New", monospace; font-size: 80%; margin-left: 15.0em; margin-bottom: 0.6em}
UL.Bulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SmallNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.IndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.CodeIndentedNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-right: 8.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.SyntaxIndentedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesBulleted {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
UL.NotesNestedBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.Hanging {font-family: "Times New Roman", Times, serif; margin-top: 0em; margin-bottom: 0.6em}
DD.Hanging {margin-left: 6.0em}
DL.IndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.IndentedHanging {margin-left: 2.0em}
DL.HangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.HangingInBulleted {margin-left: 4.0em}
DL.SmallHanging {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallHanging {margin-left: 7.5em}
DL.SmallIndentedHanging {font-family: "Times New Roman", Times, serif; margin-left: 8.0em; margin-top: 0em; margin-bottom: 0.6em}
DD.SmallIndentedHanging {margin-left: 2.0em}
DL.SmallHangingInBulleted {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallHangingInBulleted {margin-left: 5.0em}
DL.Enumerated {font-family: "Times New Roman", Times, serif; margin-right: 0.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.Enumerated {margin-left: 2.0em}
DL.SmallEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 4.0em; margin-right: 4.0em; margin-top: 0em; margin-bottom: 0.5em}
DD.SmallEnumerated {margin-left: 2.5em}
DL.NestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 2.0em; margin-right: 2.0em; margin-top: 0em; margin-bottom: 0.5em}
DL.SmallNestedEnumerated {font-family: "Times New Roman", Times, serif; margin-left: 6.0em; margin-right: 6.0em; margin-top: 0em; margin-bottom: 0.5em}
</STYLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFF0" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-C-3-1.html">Previous</A> <A HREF="AA-C-4.html">Next</A></P>
<HR>
<H1> C.3.2 The Package Interrupts</H1>
<H4 ALIGN=CENTER>Static Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>1</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> The following language-defined
packages exist: </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>2</FONT></DIV>
<DIV Class="Examples"><TT><B>with</B> System;<A NAME="I6659"></A><A NAME="I6660"></A><A NAME="I6661"></A><BR>
<B>package</B> Ada.Interrupts <B>is</B><BR>
<B>type</B> <A NAME="I6662"></A><A NAME="I6663"></A>Interrupt_ID <B>is</B> <I>implementation-defined</I>;<BR>
<B>type</B> <A NAME="I6664"></A><A NAME="I6665"></A>Parameterless_Handler <B>is</B><BR>
<B>access</B> <B>protected</B> <B>procedure</B>;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>3/1</FONT></DIV>
<DIV Class="Examples"><TT><FONT SIZE=-1><I>This paragraph was deleted.</I></FONT><S> </S></TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>4</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I6666"></A><A NAME="I6667"></A>Is_Reserved (Interrupt : Interrupt_ID)<BR>
<B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>5</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I6668"></A><A NAME="I6669"></A>Is_Attached (Interrupt : Interrupt_ID)<BR>
<B>return</B> Boolean;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>6</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I6670"></A><A NAME="I6671"></A>Current_Handler (Interrupt : Interrupt_ID)<BR>
<B>return</B> Parameterless_Handler;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>7</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I6672"></A><A NAME="I6673"></A>Attach_Handler<BR>
(New_Handler : <B>in</B> Parameterless_Handler;<BR>
Interrupt : <B>in</B> Interrupt_ID);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>8</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I6674"></A><A NAME="I6675"></A>Exchange_Handler<BR>
(Old_Handler : <B>out</B> Parameterless_Handler;<BR>
New_Handler : <B>in</B> Parameterless_Handler;<BR>
Interrupt : <B>in</B> Interrupt_ID);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>9</FONT></DIV>
<DIV Class="Examples"><TT> <B>procedure</B> <A NAME="I6676"></A><A NAME="I6677"></A>Detach_Handler<BR>
(Interrupt : <B>in</B> Interrupt_ID);</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>10</FONT></DIV>
<DIV Class="Examples"><TT> <B>function</B> <A NAME="I6678"></A><A NAME="I6679"></A>Reference(Interrupt : Interrupt_ID)<BR>
<B>return</B> System.Address;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>11</FONT></DIV>
<DIV Class="Examples"><TT><B>private</B><BR>
... -- <I>not specified by the language</I><BR>
<B>end</B> Ada.Interrupts;</TT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>12</FONT></DIV>
<DIV Class="Examples"><TT><B>package</B> Ada.Interrupts.Names <B>is</B><A NAME="I6680"></A><A NAME="I6681"></A><A NAME="I6682"></A><BR>
<I>implementation-defined</I> : <B>constant</B> Interrupt_ID :=<BR>
<I>implementation-defined</I>;<BR>
. . .<BR>
<I>implementation-defined</I> : <B>constant</B> Interrupt_ID :=<BR>
<I>implementation-defined</I>;<BR>
<B>end</B> Ada.Interrupts.Names;</TT></DIV>
<H4 ALIGN=CENTER>Dynamic Semantics</H4>
<DIV Class="Paranum"><FONT SIZE=-2>13</FONT></DIV>
<DIV Class="Normal"> The Interrupt_ID type is an implementation-defined
discrete type used to identify interrupts.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>14</FONT></DIV>
<DIV Class="Normal"> The Is_Reserved function returns True if and
only if the specified interrupt is reserved.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>15</FONT></DIV>
<DIV Class="Normal"> The Is_Attached function returns True if and
only if a user-specified interrupt handler is attached to the interrupt.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>16/1</FONT></DIV>
<DIV Class="Normal"> {<I><A HREF="defect1.html#8652/0069">8652/0069</A></I>}
The Current_Handler function returns a value that represents the attached
handler of the interrupt. If no user-defined handler is attached to the
interrupt, Current_Handler returns <U><B>null</B></U><S>a value that
designates the default treatment; calling Attach_Handler or Exchange_Handler
with this value restores the default treatment</S>.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>17</FONT></DIV>
<DIV Class="Normal"> The Attach_Handler procedure attaches the specified
handler to the interrupt, overriding any existing treatment (including
a user handler) in effect for that interrupt. If New_Handler is <B>null</B>,
the default treatment is restored. <A NAME="I6683"></A>If New_Handler
designates a protected procedure to which the pragma Interrupt_Handler
does not apply, Program_Error is raised. In this case, the operation
does not modify the existing interrupt treatment.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18/1</FONT></DIV>
<DIV Class="Normal"> {<I><A HREF="defect1.html#8652/0069">8652/0069</A></I>}
The Exchange_Handler procedure operates in the same manner as Attach_Handler
with the addition that the value returned in Old_Handler designates the
previous treatment for the specified interrupt.<U> If the previous treatment
is not a user-defined handler, <B>null</B> is returned.</U> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18.a</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1><B>Ramification: </B>Calling Attach_Handler
or Exchange_Handler with this value for New_Handler restores the previous
handler.</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>18.a.1/1</FONT></DIV>
<DIV Class="Annotations"><FONT SIZE=-1>{<I><A HREF="defect1.html#8652/0069">8652/0069</A></I>}
<U>If the application uses only parameterless procedures as handlers
(other types of handlers may be provided by the implementation, but are
not required by the standard), then if Old_Handler is not <B>null</B>,
it may be called to execute the previous handler. This provides a way
to cascade application interrupt handlers. However, the default handler
cannot be cascaded this way (Old_Handler must be <B>null</B> for the
default handler).</U> </FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>19</FONT></DIV>
<DIV Class="Normal"> The Detach_Handler procedure restores the default
treatment for the specified interrupt.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>20</FONT></DIV>
<DIV Class="Normal"> For all operations defined in this package that
take a parameter of type Interrupt_ID, with the exception of Is_Reserved
and Reference, a check is made that the specified interrupt is not reserved.
<A NAME="I6684"></A>Program_Error is raised if this check fails.</DIV>
<DIV Class="Paranum"><FONT SIZE=-2>21</FONT></DIV>
<DIV Class="Normal"> If, by using the Attach_Handler, Detach_Handler,
or Exchange_Handler procedures, an attempt is made to detach a handler
that was attached statically (using the pragma Attach_Handler), the handler
is not detached and Program_Error is raised. <A NAME="I6685"></A></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>22</FONT></DIV>
<DIV Class="Normal"> The Reference function returns a value of type
System.Address that can be used to attach a task entry, via an address
clause (see <A HREF="AA-J-7-1.html">J.7.1</A>) to the interrupt specified
by Interrupt. This function raises Program_Error if attaching task entries
to interrupts (or to this particular interrupt) is not supported. <A NAME="I6686"></A></DIV>
<H4 ALIGN=CENTER>Implementation Requirements</H4>
<DIV Class="Paranum"><FONT SIZE=-2>23</FONT></DIV>
<DIV Class="Normal"> At no time during attachment or exchange of handlers
shall the current handler of the corresponding interrupt be undefined.</DIV>
<H4 ALIGN=CENTER>Documentation Requirements</H4>
<DIV Class="Paranum"><FONT SIZE=-2>24</FONT></DIV>
<DIV Class="Normal"> If the Ceiling_Locking policy (see <A HREF="AA-D-3.html">D.3</A>)
is in effect the implementation shall document the default ceiling priority
assigned to a protected object that contains either the Attach_Handler
or Interrupt_Handler pragmas, but not the Interrupt_Priority pragma.
[This default need not be the same for all interrupts.]</DIV>
<H4 ALIGN=CENTER>Implementation Advice</H4>
<DIV Class="Paranum"><FONT SIZE=-2>25</FONT></DIV>
<DIV Class="Normal"> If implementation-defined forms of interrupt
handler procedures are supported, such as protected procedures with parameters,
then for each such form of a handler, a type analogous to Parameterless_Handler
should be specified in a child package of Interrupts, with the same operations
as in the predefined package Interrupts.</DIV>
<DIV Class="NotesHeader"><FONT SIZE=-1>NOTES</FONT></DIV>
<DIV Class="Paranum"><FONT SIZE=-2>26</FONT></DIV>
<DIV Class="Notes"><FONT SIZE=-1>8 The package Interrupts.Names
contains implementation-defined names (and constant values) for the interrupts
that are supported by the implementation.</FONT></DIV>
<H4 ALIGN=CENTER>Examples</H4>
<DIV Class="Paranum"><FONT SIZE=-2>27</FONT></DIV>
<DIV Class="Normal" Style="margin-bottom: 0.4em"> <I>Example of interrupt
handlers:</I> </DIV>
<DIV Class="Paranum"><FONT SIZE=-2>28</FONT></DIV>
<DIV Class="Examples"><TT>Device_Priority : <B>constant</B><BR>
<B>array</B> (1..5) of System.Interrupt_Priority := ( ... );<BR>
<B>protected</B> <B>type</B> Device_Interface<BR>
(Int_ID : Ada.Interrupts.Interrupt_ID) <B>is</B><BR>
<B>procedure</B> Handler;<BR>
<B>pragma</B> Attach_Handler(Handler, Int_ID);<BR>
...<BR>
<B>pragma</B> Interrupt_Priority(Device_Priority(Int_ID));<BR>
<B>end</B> Device_Interface;<BR>
...<BR>
Device_1_Driver : Device_Interface(1);<BR>
...<BR>
Device_5_Driver : Device_Interface(5);<BR>
...</TT></DIV>
<HR>
<P><A HREF="AA-TOC.html">Contents</A> <A HREF="AA-0-29.html">Index</A> <A HREF="AA-C-3-1.html">Previous</A> <A HREF="AA-C-4.html">Next</A> <A HREF="AA-TTL.html">Legal</A></P>
</BODY>
</HTML>
|