📄 intr_notimes.t
字号:
@c@c COPYRIGHT (c) 1988-2002.@c On-Line Applications Research Corporation (OAR).@c All rights reserved.@c@c $Id: intr_NOTIMES.t,v 1.6 2002/01/17 21:47:46 joel Exp $@c@chapter Interrupt Processing@section IntroductionDifferent types of processors respond to theoccurrence of an interrupt in their own unique fashion. Inaddition, each processor type provides a control mechanism toallow the proper handling of an interrupt. The processordependent response to the interrupt modifies the execution stateand results in the modification of the execution stream. Thismodification usually requires that an interrupt handler utilizethe provided control mechanisms to return to the normalprocessing stream. Although RTEMS hides many of the processordependent details of interrupt processing, it is important tounderstand how the RTEMS interrupt manager is mapped onto theprocessor's unique architecture. Discussed in this chapter arethe the processor's response and control mechanisms as theypertain to RTEMS.@section Vectoring of Interrupt HandlerAlthough the i386 supports multiple privilege levels,RTEMS and all user software executes at privilege level 0. Thisdecision was made by the RTEMS designers to enhancecompatibility with processors which do not provide sophisticatedprotection facilities like those of the i386. This decisiongreatly simplifies the discussion of i386 processing, as oneneed only consider interrupts without privilege transitions.Upon receipt of an interrupt the i386 automaticallyperforms the following actions:@itemize @bullet@item pushes the EFLAGS register@item pushes the far address of the interrupted instruction@item vectors to the interrupt service routine (ISR).@end itemizeA nested interrupt is processed similarly by thei386.@section Interrupt Stack FrameThe structure of the Interrupt Stack Frame for thei386 which is placed on the interrupt stack by the processor inresponse to an interrupt is as follows:@ifset use-ascii@example@group +----------------------+ | Old EFLAGS Register | ESP+8 +----------+-----------+ | UNUSED | Old CS | ESP+4 +----------+-----------+ | Old EIP | ESP +----------------------+@end group@end example@end ifset@ifset use-tex@sp 1@tex\centerline{\vbox{\offinterlineskip\halign{\strut\vrule#&\hbox to 1.00in{\enskip\hfil#\hfil}&\vrule#&\hbox to 1.00in{\enskip\hfil#\hfil}&\vrule#&\hbox to 0.75in{\enskip\hfil#\hfil}\cr\multispan{4}\hrulefill\cr& \multispan{3} Old EFLAGS Register\quad&&ESP+8\cr\multispan{4}\hrulefill\cr&UNUSED &&Old CS &&ESP+4\cr\multispan{4}\hrulefill\cr& \multispan{3} Old EIP && ESP\cr\multispan{4}\hrulefill\cr}}\hfil}@end tex@end ifset @ifset use-html@html<CENTER> <TABLE COLS=3 WIDTH="40%" BORDER=2><TR><TD ALIGN=center COLSPAN=2><STRONG>Old EFLAGS Register</STRONG></TD> <TD ALIGN=center>0x0</TD></TR><TR><TD ALIGN=center><STRONG>UNUSED</STRONG></TD> <TD ALIGN=center><STRONG>Old CS</STRONG></TD> <TD ALIGN=center>0x2</TD></TR><TR><TD ALIGN=center COLSPAN=2><STRONG>Old EIP</STRONG></TD> <TD ALIGN=center>0x4</TD></TR> </TABLE></CENTER>@end html@end ifset@section Interrupt LevelsAlthough RTEMS supports 256 interrupt levels, thei386 only supports two -- enabled and disabled. Interrupts areenabled when the interrupt-enable flag (IF) in the extendedflags (EFLAGS) is set. Conversely, interrupt processing isinhibited when the IF is cleared. During a non-maskableinterrupt, all other interrupts, including other non-maskableones, are inhibited.RTEMS interrupt levels 0 and 1 such that level zero(0) indicates that interrupts are fully enabled and level onethat interrupts are disabled. All other RTEMS interrupt levelsare undefined and their behavior is unpredictable.@section Disabling of Interrupts by RTEMSDuring the execution of directive calls, criticalsections of code may be executed. When these sections areencountered, RTEMS disables interrupts before the execution ofthis section and restores them to the previous level uponcompletion of the section. RTEMS has been optimized to insurethat interrupts are disabled for less than RTEMS_MAXIMUM_DISABLE_PERIODmicroseconds on a RTEMS_MAXIMUM_DISABLE_PERIOD_MHZ Mhz i386 with zerowait states. These numbers will vary based the number of wait statesand processor speed present on the target board. [NOTE: The maximumperiod with interrupts disabled within RTEMS was last calculated forRelease RTEMS_RELEASE_FOR_MAXIMUM_DISABLE_PERIOD.]Non-maskable interrupts (NMI) cannot be disabled, andISRs which execute at this level MUST NEVER issue RTEMS systemcalls. If a directive is invoked, unpredictable results mayoccur due to the inability of RTEMS to protect its criticalsections. However, ISRs that make no system calls may safelyexecute as non-maskable interrupts.@section Interrupt StackThe i386 family does not support a dedicated hardwareinterrupt stack. On this processor, RTEMS allocates and managesa dedicated interrupt stack. As part of vectoring a non-nestedinterrupt service routine, RTEMS switches from the stack of theinterrupted task to a dedicated interrupt stack. When anon-nested interrupt returns, RTEMS switches back to the stackof the interrupted stack. The current stack pointer is notaltered by RTEMS on nested interrupt.Without a dedicated interrupt stack, every task inthe system MUST have enough stack space to accommodate the worstcase stack usage of that particular task and the interruptservice routines COMBINED. By supporting a dedicated interruptstack, RTEMS significantly lowers the stack requirements foreach task.RTEMS allocates the dedicated interrupt stack fromthe Workspace Area. The amount of memory allocated for theinterrupt stack is determined by the interrupt_stack_size fieldin the CPU Configuration Table.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -