⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c-basic5.html

📁 vxworks相关论文
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title>     Basic OS   </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="GuideIX.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-basic.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-basic4.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-basic6.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="86559">2.5  &nbsp;&nbsp;Interrupt Service Code<i class="i"></i></a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86563"> </a>Hardware interrupt handling is of key significance in real-time systems, because it is usually through interrupts that the system is informed of external events. For the fastest possible response to interrupts, interrupt service routines (ISRs) in VxWorks run in a special context outside of any task's context. Thus, interrupt handling involves no task context switch. The interrupt routines, listed in <a href="c-basic5.html#86571">Table&nbsp;2-22</a>, are provided in <b class="library">intLib</b> and<b class="library"> intArchLib</b>.<p class="table"><h4 class="EntityTitle"><a name="86571"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 2-22:&nbsp;&nbsp;Interrupt Routines</font></a></h4><table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="86575"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Call</font></b></div></th><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="86577"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Description</font></b></div></th></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86584"> </a><b class="routine"><i class="routine">intConnect</i></b><b>(&nbsp;)</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="86586"> </a>Connect a C routine to an interrupt vector.&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86589"> </a><b class="routine"><i class="routine">intContext</i></b><b>(&nbsp;)</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="86591"> </a>Return TRUE if called from interrupt level.&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86594"> </a><b class="routine"><i class="routine">intCount</i></b><b>(&nbsp;)</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="86596"> </a>Get the current interrupt nesting depth.&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86599"> </a><b class="routine"><i class="routine">intLevelSet</i></b><b>(&nbsp;)</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="86601"> </a>Set the processor interrupt mask level.&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86605"> </a><b class="routine"><i class="routine">intLock</i></b><b>(&nbsp;)</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="86607"> </a>Disable interrupts.&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86610"> </a><b class="routine"><i class="routine">intUnlock</i></b><b>(&nbsp;)</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="86612"> </a>Re-enable interrupts.&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86615"> </a><b class="routine"><i class="routine">intVecBaseSet</i></b><b>(&nbsp;)</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="86617"> </a>Set the vector base address.&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86620"> </a><b class="routine"><i class="routine">intVecBaseGet</i></b><b>(&nbsp;)</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="86622"> </a>Get the vector base address.&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86625"> </a><b class="routine"><i class="routine">intVecSet</i></b><b>(&nbsp;)</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="86627"> </a>Set an exception vector.&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="86630"> </a><b class="routine"><i class="routine">intVecGet</i></b><b>(&nbsp;)</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="86632"> </a>Get an exception vector.&nbsp;</div></td></tr><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p></p><dd><p class="Body"><a name="86637"> </a>For boards with an MMU, the optional product VxVMI provides write protection for the interrupt vector table; see <a href="c-vm.html#84369"><i class="title">7.&nbsp;Virtual Memory Interface</i></a>.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="86643">2.5.1  &nbsp;&nbsp;Connecting Application Code to Interrupts<i class="i"></i></a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86644"> </a>You can use system hardware interrupts other than those used by VxWorks. VxWorks provides the routine <b class="routine"><i class="routine">intConnect</i></b><b>(&nbsp;)</b>, which allows C functions to be connected to any interrupt. The arguments to this routine are the byte offset of the interrupt vector to connect to, the address of the C function to be connected, and an argument to pass to the function. When an interrupt occurs with a vector established in this way, the connected C function is called at interrupt level with the specified argument. When the interrupt handling is finished, the connected function returns. A routine connected to an interrupt in this way is called an <i class="term">interrupt service routine</i> (ISR).</p><dd><p class="Body"><a name="88042"> </a>Interrupts cannot actually vector directly to C functions. Instead, <b class="routine"><i class="routine">intConnect</i></b><b>(&nbsp;)</b> builds a small amount of code that saves the necessary registers, sets up a stack entry (either on a special interrupt stack, or on the current task's stack) with the argument to be passed, and calls the connected function. On return from the function it restores the registers and stack, and exits the interrupt; see <a href="c-basic5.html#88075">Figure&nbsp;2-16</a>. <div class="frame"><h4 class="EntityTitle"><a name="88075"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 2-16:&nbsp;&nbsp;Routine Built by <b class="routine"><i class="routine">intConnect</i></b><b>(&nbsp;)</b></font></a></h4><dl class="margin"><div class="Anchor"><a name="88072"> </a><img class="figure" border="0" src="images/c-basica2.gif"></div></dl></div></p><dd><p class="Body"><a name="89310"> </a>For target boards with VME backplanes, the BSP provides two standard routines for controlling VME bus interrupts, <b class="routine"><i class="routine">sysIntEnable</i></b><b>(&nbsp;)</b> and <b class="routine"><i class="routine">sysIntDisable</i></b><b>(&nbsp;)</b>.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="86685">2.5.2  &nbsp;&nbsp;Interrupt Stack</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86687"> </a>Whenever the architecture allows it, all ISRs use the same <i class="term">interrupt stack</i>. This stack is allocated and initialized by the system at start-up according to specified configuration parameters. It must be large enough to handle the worst possible combination of nested interrupts.</p><dd><p class="Body"><a name="86688"> </a>Some architectures, however, do not permit using a separate interrupt stack. On such architectures, ISRs use the stack of the interrupted task. If you have such an architecture, you must create tasks with enough stack space to handle the worst possible combination of nested interrupts <i class="emphasis">and</i> the worst possible combination of ordinary nested calls. See the reference entry for your BSP to determine whether your architecture supports a separate interrupt stack.</p><dd><p class="Body"><a name="86690"> </a>Use the <b class="routine"><i class="routine">checkStack</i></b><b>(&nbsp;)</b> facility during development to see how close your tasks and ISRs have come to exhausting the available stack space.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="86692">2.5.3  &nbsp;&nbsp;Special Limitations of ISRs</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86693"> </a>Many VxWorks facilities are available to ISRs, but there are some important limitations. These limitations stem from the fact that an ISR does not run in a regular task context: it has no task control block, for example, and all ISRs share a single stack.<p class="table"><h4 class="EntityTitle"><a name="91424"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 2-23:&nbsp;&nbsp;Routines that Can Be Called by Interrupt Service Routines</font></a></h4><table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="91428"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Library</font></b></div></th><th rowspan="1" colspan="1"><div class="CellHeading"><b><a name="91430"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Routines</font></b></div></th></tr><tr><td colspan="20"><hr class="tablerule2"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="91432"> </a><b class="library">bLib</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="91434"> </a>All routines&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="91436"> </a><b class="library">errnoLib</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="91438"> </a><b class="routine"><i class="routine">errnoGet</i></b><b>(&nbsp;)</b>, <b class="routine"><i class="routine">errnoSet</i></b><b>(&nbsp;)</b>&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="91440"> </a><b class="library">fppArchLib</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="91442"> </a><b class="routine"><i class="routine">fppSave</i></b><b>(&nbsp;)</b>, <b class="routine"><i class="routine">fppRestore</i></b><b>(&nbsp;)</b>&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="91444"> </a><b class="library">intLib</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="91446"> </a><b class="routine"><i class="routine">intContext</i></b><b>(&nbsp;)</b>, <b class="routine"><i class="routine">intCount</i></b><b>(&nbsp;)</b>, <b class="routine"><i class="routine">intVecSet</i></b><b>(&nbsp;)</b>, <b class="routine"><i class="routine">intVecGet</i></b><b>(&nbsp;)</b>&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="91448"> </a><b class="library">intArchLib</b>&nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="91450"> </a><b class="routine"><i class="routine">intLock</i></b><b>(&nbsp;)</b>, <b class="routine"><i class="routine">intUnlock</i></b><b>(&nbsp;)</b>&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="91452"> </a><b class="library">logLib</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="91454"> </a><b class="routine"><i class="routine">logMsg</i></b><b>(&nbsp;)</b>&nbsp;</div></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="91456"> </a><b class="library">lstLib</b> &nbsp;</div></td><td colspan=1 rowspan=1><div class="CellBody"><a name="91458"> </a>All routines except <b class="routine"><i class="routine">lstFree</i></b><b>(&nbsp;)</b>&nbsp;</div></td></tr>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -