📄 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 theoccurence of an interrupt in their own unique fashion. Inaddition, each processor type provides a control mechanism toallow for the proper handling of an interrupt. The processordependent response to the interrupt modifies the currentexecution state and results in a change in the execution stream.Most processors require that an interrupt handler utilize somespecial control mechanisms to return to the normal processingstream. Although RTEMS hides many of the processor dependentdetails of interrupt processing, it is important to understandhow the RTEMS interrupt manager is mapped onto the processor'sunique architecture. Discussed in this chapter are the PA-RISC'sinterrupt response and control mechanisms as they pertain toRTEMS.@section Vectoring of Interrupt HandlerUpon receipt of an interrupt the PA-RISCautomatically performs the following actions:@itemize @bullet@item The PSW (Program Status Word) is saved in the IPSW(Interrupt Program Status Word).@item The current privilege level is set to 0.@item The following defined bits in the PSW are set:@item E bit is set to the default endian bit@item M bit is set to 1 if the interrupt is a high-prioritymachine check and 0 otherwise@item Q bit is set to zero thuse freezing the IIA(Instruction Address) queues@item C and D bits are set to zero thus disabling allprotection and translation.@item I bit is set to zero this disabling all external,powerfail, and low-priority machine check interrupts.@item All others bits are set to zero.@item General purpose registers r1, r8, r9, r16, r17, r24, andr25 are copied to the shadow registers.@item Execution begins at the address given by the formula:Interruption Vector Address + (32 * interrupt vector number).@end itemizeOnce the processor has completed the actions it is isrequired to perform for each interrupt, the RTEMS interruptmanagement code (the beginning of which is stored in theInterruption Vector Table) gains control and performs thefollowing actions upon each interrupt:@itemize @bullet@item returns the processor to "virtual mode" thus reenablingall code and data address translation.@item saves all necessary interrupt state information@item saves all floating point registers@item saves all integer registers@item switches the current stack to the interrupt stack@item dispatches to the appropriate user provided interruptservice routine (ISR). If the ISR was installed with theinterrupt_catch directive, then it will be executed at this.Because, the RTEMS interrupt handler saves all registers whichare not preserved according to the calling conventions andinvokes the application's ISR, the ISR can easily be written ina high-level language.@end itemizeRTEMS refers to the combination of the interruptstate information and registers saved when vectoring aninterrupt as the Interrupt Stack Frame (ISF). A nestedinterrupt is processed similarly by the PA-RISC and RTEMS withthe exception that the nested interrupt occurred while executingon the interrupt stack and, thus, the current stack need not beswitched.@section Interrupt Stack FrameThe PA-RISC architecture does not alter the stackwhile processing interrupts. However, RTEMS does saveinformation on the stack as part of processing an interrupt.This following shows the format of the Interrupt Stack Frame forthe PA-RISC as defined by RTEMS:@example@group +------------------------+ | Interrupt Context | 0xXXX +------------------------+ | Integer Context | 0xXXX +------------------------+ | Floating Point Context | 0xXXX +------------------------+@end group@end example@section External Interrupts and TrapsIn addition to the thirty-two unique interruptsources supported by the PA-RISC architecture, RTEMS alsosupports the installation of handlers for each of the thirty-twoexternal interrupts supported by the PA-RISC architecture.Except for interrupt vector 4, each of the interrupt vectors 0through 31 may be associated with a user-provided interrupthandler. Interrupt vector 4 is used for external interrupts.When an external interrupt occurs, the RTEMS external interrupthandler is invoked and the actual interrupt source is indicatedby status bits in the EIR (External Interrupt Request) register.The RTEMS external interrupt handler (or interrupt vector four)examines the EIR to determine which interrupt source requiresservicing.RTEMS supports sixty-four interrupt vectors for thePA-RISC. Vectors 0 through 31 map to the normal interruptsources while RTEMS interrupt vectors 32 through 63 are directlyassociated with the external interrupt sources indicated by bits0 through 31 in the EIR.The exact set of interrupt sources which are checkedfor by the RTEMS external interrupt handler and the order inwhich they are checked are configured by the user in the CPUConfiguration Table. If an external interrupt occurs which doesnot have a handler configured, then the spurious interrupthandler will be invoked. The spurious interrupt handler mayalso be specifiec by the user in the CPU Configuration Table.@section Interrupt LevelsTwo levels (enabled and disabled) of interruptpriorities are supported by the PA-RISC architecture. Levelzero (0) indicates that interrupts are fully enabled (i.e. the Ibit of the PSW is 1). Level one (1) indicates that interruptsare disabled (i.e. the I bit of the PSW is 0). Thirty-twoindependent sources of external interrupts are supported by thePA-RISC architecture. Each of these interrupts sources may beindividually enabled or disabled. When processor interrupts aredisabled, all sources of external interrupts are ignored. Whenprocessor interrupts are enabled, the EIR (External InterruptRequest) register is used to determine which sources arecurrently allowed to generate interrupts.Although RTEMS supports 256 interrupt levels, thePA-RISC architecture only supports two. RTEMS interrupt level 0indicates that interrupts are enabled and level 1 indicates thatinterrupts are disabled. All other RTEMS interrupt levels areundefined 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 external interrupts by setting the Ibit in the PSW to 0 before the execution of this section andrestores them to the previous level upon completion of thesection. RTEMS has been optimized to insure that interrupts aredisabled for less than XXX instructions when compiled with GNUCC at optimization level 4. The exact execution time will varybased on the based on the processor implementation, amount ofcache, the number of wait states for primary memory, andprocessor speed present on the target board.Non-maskable interrupts (NMI) such as high-prioritymachine checks cannot be disabled, and ISRs which execute atthis level MUST NEVER issue RTEMS system calls. If a directiveis invoked, unpredictable results may occur due to the inabilityof RTEMS to protect its critical sections. However, ISRs thatmake no system calls may safely execute as non-maskableinterrupts.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -