
CHAPTER 8 INTERRUPT MANAGEMENT
User’s Manual U14833EJ2V0UM
91
8.2.2
Interrupt processing management
When using the source file provided as a sample without modification, the interrupt processing flow is as shown
below. This flow is also shown in diagram form in Figure 8-1.
(1)
An interrupt is generated and control shifts to a CPU interrupt/exception vector.
(2)
At the interrupt/exception vector, in the sample, processing only branches to the interrupt/exception
processing main body.
(3)
Because control shifts to a single vector for all (general) exceptions/interrupts in the V
R
4100 Series or V
R
5000
Series, the exception source is determined by the initial section of the interrupt/exception processing, which
then divides. CPU and service call exceptions are not taken into consideration here.
(4)
Registers that may be corrupted by interrupt processing, such as temporary registers set up by the C
compiler, are saved in the initial section of the interrupt processing.
(v0 to v1, a0 to a3, t0 to t9, ra, epc, sr)
(5)
After these registers have been saved, the kernel’s internal function “_kernel_int_handle” is called, which
notifies the kernel of the activation of interrupt processing. Note that in order to call the above function, the
values of the epc, cause, and status registers must be assigned as parameters when an interrupt is
generated.
(6)
Once the kernel has received notification of the activation of interrupt processing, the interrupt service routine
enters a state in which it can be activated (service calls can be issued). After the state has shifted, the kernel
calls back the function “_user_int_handle” described by the user (function name fixed). Before calling the
function “_user_int_handle”, the kernel switches the stack to the interrupt stack so that all the subsequent
processing is performed on the interrupt stack. It is therefore necessary to add the size of the stack
consumed by interrupt processing to the stack of each task.
(7)
After the interrupt source has been determined by “_user_int_handle”, ivsta_isr is issued, activating an
interrupt service routine in response to the generated interrupt source.
(8)
The required interrupt processing is performed by the interrupt servicing routine.
(9)
“_user_int_handle” is then terminated by C language return or equivalent processing. At this time, if an event
in generated in the interrupt processing that requires scheduling, the kernel activates the scheduler and
switches tasks.
(10) If scheduling is not required in (9) above, or if the interrupted task is re-dispatched after scheduling, control
returns to the point at which “_kernel_int_handle” was called.
(11) The registers saved in (4) are restored, via the eret instruction, to the point where the interrupt was generated.