![](http://datasheet.mmic.net.cn/370000/-PD30101_datasheet_16680756/-PD30101_116.png)
85
CHAPTER 5 EXCEPTION PROCESSING
This chapter describes CPU exception processing, including an explanation of exception processing,
followed by the format and use of each CPU exception register.
The chapter concludes with a description of each exception’s cause, together with the manner in which
the CPU processes and services each exception.
5.1 HOW EXCEPTION PROCESSING WORKS
The processor receives exceptions from a number of sources, including translation lookaside buffer
(TLB) misses, arithmetic overflows, I/O interrupts, and system calls. When the CPU detects an
exception, the normal sequence of instruction execution is suspended and the processor enters Kernel
mode (see Chapter 4 for a description of system operating modes).
The processor then disables interrupts and transfers control for execution to the exception handler
(located at a specific address as an exception handling routine implemented by software). The handler
saves the context of the processor, including the contents of the program counter, the current operating
mode (User or Supervisor), statuses, and interrupt enabling. This context is saved so it can be restored
when the exception has been serviced.
When an exception occurs, the CPU loads the Exception Program Counter (EPC) register with a
location where execution can restart after the exception has been serviced. The restart location in the
EPC register is the address of the instruction that caused the exception or, if the instruction was
executing in a branch delay slot, the address of the branch instruction immediately preceding the delay
slot.
The V
R
4101 processor supports a Supervisor mode and fast TLB refill for all address spaces. The
V
R
4101 also provides the following functions:
"
Interrupt enable (IE) bit
"
Operating mode (User, Supervisor, or Kernel)
"
Exception level (normal or exception, as indicated by the EXL bit in the Status register)
"
Error level (normal or error indicated by the ERL bit in the Status register).
Interrupts are enabled when the following conditions are satisfied:
"
Interrupt enable bit (IE) = 1
"
EXL bit = 0, ERL bit = 0
"
Corresponding IM field bits in the Status register = 1
"
The operating mode is specified by base mode when the exception level is normal (0), and is set to
Kernel mode when either the EXL bit or ERL bit is set to 1.
Returning from an exception resets the exception level to normal.
The registers described later in the chapter assist in this exception processing by retaining address,
cause and status information.
For a description of the exception handling process, see the description of the individual exception
contained in this chapter, or the flowcharts at the end of this chapter.