
CHAPTER 9 SYSTEM CONFIGURATION MANAGEMENT
User’s Manual U14833EJ2V0UM
99
9.2.2
Saving/restoring registers
All registers including FPU registers are saved in the initial section of the exception processing. This is because by
informing the exception main processing of the address of this save area, the state in which an exception occurs can
be ascertained during exception processing. When it is not necessary to save all the registers, registers can be saved
in accordance with the function call conventions of the V
R
Series C compiler from Green Hills Software, Inc. When the
exception processing involves the execution of processing described in C language, because the function call
conventions stipulate that the preprocessing and postprocessing values stored in the save register (s0 to s7) must be
the same, there is no particular need to save this register. The kernel will save and restore the gp, fp, sp, and FPU
registers as required.
In either case, for other registers (at, v0 to v1, t0 to t9, ra, epc, status), operation after being restored from an
exception is not guaranteed unless their values are saved when the exception occurred and then returned to their
original values when restored from exception processing.
Note that the size of stack consumed when these registers are saved is not included in the size of the stack
automatically augmented by the kernel when a task is created.
9.2.3
Exception occurrence notification
In order to utilize the services provided by the kernel, such as issuing service calls via exception processing carried
out when an exception occurs, the kernel must be notified of the activation of exception processing. However, there
may also be cases when it is desirable to terminate exception processing without receiving services from the kernel in
order to speed up the processing. Cautions to be observed when using these two types of processing are outlined
below.
(1) Terminating exception processing without using kernel’s services
In this case, it is unnecessary to inform the kernel of the activation of exception processing. However, the user
must describe the entire processing, from activate to finish. Because the kernel cannot participate at all,
service call issuance is completely disabled in the processing.
(2) Using kernel’s services in exception processing
The kernel can be notified of the activation of exception processing by describing the kernel’s internal function
“_kernel_exc_handle” in the initial section of the exception processing. Once notified, the kernel puts the CPU
exception handlers into an activation-enabled state. Exception processing performed by the user is enabled
when the function “_user_exc_handle” is called back from the kernel.
In this function, issuance of service calls activation with i is enabled, allowing the kernel’s services to be
received (without necessarily having to activate a CPU exception handler).
9.2.4
CPU exception handlers
A CPU exception handler is a handler that is activated when an exception occurs. A CPU exception handler
operates using the identical context (stack) to the location of the exception. The service calls that can be issued are
the same as those that can be issued for an interrupt service routine. The description format of a CPU handler is
shown below. Note, however, that this format can be changed arbitrarily by the user by changing the source file. The
address where the data of registers saved when an exception occurred is stored is passed as a parameter for the
source file provided as a sample.
Example)
void exchdr(VP fp)
{
...
return;
}