📄 irq.htm
字号:
<!-- saved from url=(0022)http://internet.e-mail --><title>The IRQInstall Library Function</title><h1 align=center>The IRQInstall Library Function</h1><!--INDEX "Installing C exception handlers" IRQInstall --></dl><h2>NAME</h2><dl><dd> IRQInstall - connect C exception handler</dl><h2>SYNOPSIS</h2><dl><dd><pre>Func *IRQInstall(int IRQNum, Func *ISRFun)</pre></dl><h2>DESCRIPTION</h2><dl><dd> IRQInstall connects a C language exception handler to a selected EXCCODE in the CAUSE register. It returns the address of previous C function that was installed for this exception. <p> If the IRQNum is 0..7, the appropriate mask bit in the Status register will be enabled, together with the global IEC bit.<p> IRQNum (0..23) specifies which of the possible 24 exceptions vectors should be connected to this handler.<p> <center> <table border=1><tr> <th>IRQNum</th><th>Exception</th> <th>IRQNum</th><th>Exception</th></tr><tr> <td align=right>0</td><td> - sw0 (low priority)</td> <td align=right>12</td><td> - AdEL</td></tr><tr> <td align=right>1</td><td> - sw1</td> <td align=right>13</td><td> - AdES</td></tr><tr> <td align=right>2</td><td> - int0</td> <td align=right>14</td><td> - IBE</td></tr><tr> <td align=right>3</td><td> - int1</td> <td align=right>15</td><td> - DBE</td></tr><tr> <td align=right>4</td><td> - int2</td> <td align=right>16</td><td> - Sys</td></tr><tr> <td align=right>5</td><td> - int3</td> <td align=right>17</td><td> - Bp</td></tr><tr> <td align=right>6</td><td> - int4</td> <td align=right>18</td><td> - RI</td></tr><tr> <td align=right>7</td><td> - int5 (high priority)</td> <td align=right>19</td><td> - CpU</td></tr><tr> <td align=right>8</td><td> - unused</td> <td align=right>20</td><td> - Ovf</td></tr><tr> <td align=right>9</td><td> - TLB MOD</td> <td align=right>21</td><td> - unused</td></tr><tr> <td align=right>10</td><td> - TLBL</td> <td align=right>22</td><td> - unused</td></tr><tr> <td align=right>11</td><td> - TLBS</td> <td align=right>23</td><td> - unused</td></tr><tr> </table> </center><p> ISRFun is the address of the C function that should be called when the specified exception occurs. If a value of zero is specified,the current handler will be uninstalled and the interrupt will be disabled.<p> The ISRFun is passed the base address of the register save area, this permits the ISR to receive incoming register-based variables, and even change the address to which control will pass when the handler terminates.<p> Offsets in the savearea are 0 thru 31 where the offset equals the register number except for the following cases:<p><pre> 0 = EPC 26 = HI 27 = LO 28 = CAUSE 29 = SR</pre> The ISRFun <b>must</b> return non-zero if it handled the exception. If it returns zero, control will be passed to the ICEKernel or PMON.<p> There are actually two separate implementations of this command, <a href="../../lib/pmirq.c">lib/pmirq.c</a> and <a href="../../lib/sairq.c">lib/sairq.c</a>. When you build a program for execution under PMON, your reference to IRQInstall will pull <a href="../../lib/irq.c">lib/irq.c</a> from the library. This module then calls pmirq.c. It is different from sairq.c in that it uses <a href="onintr.htm">onintr</a> to add the handler to PMON's interrupt vector table. <p></dl><h2>EXAMPLE</h2><dl><dd><pre>main(){int isr();IRQInstall(SIO_IRQNum,isr);} isr(Ulong *savearea){/* acknowledge the interrupt *//* do interrupt code */return(1);}</pre><p>For more complete examples, see <a href="../../lib/p2681.c">lib/p2681.c</a> and<a href="../../lib/t1_4102.c">lib/t1_4102.c</a>.<p></dl><p><hr><b>Navigation:</b> <a href="../index.htm">Document Home</a> | <a href="../doctoc.htm">Document Contents</a> | <a href="../docindex.htm">Document Index</a> <p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -