📄 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.7 2002/01/17 21:47:46 joel Exp $@c@chapter Interrupt Processing@section IntroductionDifferent types of processors respond to theoccurrence of an interrupt in its 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 PowerPC'sinterrupt response and control mechanisms as they pertain toRTEMS.RTEMS and associated documentation uses the termsinterrupt and vector. In the PowerPC architecture, these termscorrespond to exception and exception handler, respectively. The terms willbe used interchangeably in this manual.@section Synchronous Versus Asynchronous ExceptionsIn the PowerPC architecture exceptions can be either precise or imprecise and either synchronous or asynchronous. Asynchronous exceptions occur when an external event interrupts the processor.Synchronous exceptions are caused by the actions of an instruction. During an exception SRR0 is used to calculate where instruction processing should resume. All instructions prior tothe resume instruction will have completed execution. SRR1 is used to store the machine status.There are two asynchronous nonmaskable, highest-priority exceptionssystem reset and machine check. There are two asynchrononous maskablelow-priority exceptions external interrupt and decrementer. Nonmaskableexecptions are never delayed, therefore if two nonmaskable, asynchronous exceptions occur in immediate succession, the state information saved bythe first exception may be overwritten when the subsequent exception occurs. The PowerPC arcitecure defines one imprecise exception, the imprecise floating point enabled exception. All other synchronous exceptions areprecise. The synchronization occuring during asynchronous precise exceptions conforms to the requirements for context synchronization.@section Vectoring of Interrupt HandlerUpon determining that an exception can be taken the PowerPC automaticallyperforms the following actions:@itemize @bullet@item an instruction address is loaded into SRR0@item bits 33-36 and 42-47 of SRR1 are loaded with information specific to the exception.@item bits 0-32, 37-41, and 48-63 of SRR1 are loaded with correspondingbits from the MSR.@item the MSR is set based upon the exception type.@item instruction fetch and execution resumes, using the new MSR value, at a location specific to the execption type. @end itemizeIf the interrupt handler was installed as an RTEMSinterrupt handler, then upon receipt of the interrupt, theprocessor passes control to the RTEMS interrupt handler whichperforms the following actions:@itemize @bullet@item saves the state of the interrupted task on it's stack,@item saves all registers which are not normally preservedby the calling sequence so the user's interrupt serviceroutine can be written in a high-level language.@item if this is the outermost (i.e. non-nested) interrupt,then the RTEMS interrupt handler switches from the current stackto the interrupt stack,@item enables exceptions,@item invokes the vectors to a user interrupt service routine (ISR).@end itemizeAsynchronous interrupts are ignored while exceptions aredisabled. Synchronous interrupts which occur while aredisabled result in the CPU being forced into an error mode.A nested interrupt is processed similarly with theexception that the current stack need not be switched to theinterrupt stack.@section Interrupt LevelsThe PowerPC architecture supports only a single externalasynchronous interrupt source. This interrupt sourcemay be enabled and disabled via the External Interrupt Enable (EE)bit in the Machine State Register (MSR). Thus only two level (enabledand disabled) of external device interrupt priorities are directly supported by the PowerPC architecture. Some PowerPC implementations include a Critical Interrupt capabilitywhich is often used to receive interrupts from high priority externaldevices.The RTEMS interrupt level mapping scheme for the PowerPC is not a numeric level as on most RTEMS ports. It is a bit mapping inwhich the least three significiant bits of the interrupt levelare mapped directly to the enabling of specific interrupt sources as follows:@table @b@item Critical InterruptSetting bit 0 (the least significant bit) of the interrupt levelenables the Critical Interrupt source, if it is available on thisCPU model.@item Machine CheckSetting bit 1 of the interrupt level enables Machine Check execptions.@item External InterruptSetting bit 2 of the interrupt level enables External Interrupt execptions.@end tableAll other bits in the RTEMS task interrupt level are ignored.@section Disabling of Interrupts by RTEMSDuring the execution of directive calls, criticalsections of code may be executed. When these sections areencountered, RTEMS disables Critical Interrupts, External Interruptsand Machine Checks before the execution of this section and restoresthem to the previous level upon completion of the section. RTEMS has beenoptimized to insure that interrupts are disabled for less thanRTEMS_MAXIMUM_DISABLE_PERIOD microseconds on a RTEMS_MAXIMUM_DISABLE_PERIOD_MHZ Mhz PowerPC 603e with zerowait states. These numbers will vary based the number of wait states and processor speed present on the target board.[NOTE: The maximum period with interrupts disabled is hand calculated. Thiscalculation was last performed for Release RTEMS_RELEASE_FOR_MAXIMUM_DISABLE_PERIOD.]If a PowerPC implementation provides non-maskable interrupts (NMI)which cannot be disabled, ISRs which process these interruptsMUST NEVER issue RTEMS system calls. If a directive is invoked,unpredictable results may occur due to the inability of RTEMSto protect its critical sections. However, ISRs that make nosystem calls may safely execute as non-maskable interrupts.@section Interrupt StackThe PowerPC architecture does not provide for adedicated interrupt stack. Thus by default, exception handlers wouldexecute on the stack of the RTEMS task which they interrupted.This artificially inflates the stack requirements for each tasksince EVERY task stack would have to include enough space toaccount for the worst case interrupt stack requirements inaddition to it's own worst case usage. RTEMS addresses thisproblem on the PowerPC by providing a dedicated interrupt stackmanaged by software.During system initialization, RTEMS allocates theinterrupt stack from the Workspace Area. The amount of memoryallocated for the interrupt stack is determined by theinterrupt_stack_size field in the CPU Configuration Table. Aspart of processing a non-nested interrupt, RTEMS will switch tothe interrupt stack before invoking the installed handler.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -