
258
Evaluating and Programming the 29K RISC Family
add
add
lr2,gr96,0
lr3,msp,0
;copy signal #
;pass CTX pointer
;
calli
nop
lr0,lr0
;call handler()
;
add
nop
asleu
const
asneq
gr1,gr1,6*4
;restore stack
V_FILL,lr1,rfb
tav,SYS_SIGRETURN
V_SYSCALL,gr1,gr1 ;system call
After the signal handler returns, the interrupted context is restored via the
sigreturn
system call. The supervisor mode code used to implement the restoration
process is shown in the section titled
Restoring Context
(section 5.10)
.
At the time of
the system call trap, the memory stack pointer,
msp
, must be pointing to the structure
containing the saved context. The system call code checks relevant register data to
ensure that the User is not trying to gain Supervisor access permissions as a result of
manipulating the context information during the signal handler execution. (Note, it is
likely that assembly code library supporting the
sigreturn
system call shall copy the
lr2
parameter value to the
msp
register before issuing the system call trap.)
5.6
INTERRUPTING SUPERVISOR MODE
A user program may be in the process of executing a system call when an
interrupt occurs. This interrupt may require C level handler processing. In some
respects this is similar to a user program dealing with a C level signal handler;
however, there are some important differences. A User mode signal handlers may
chose not to run to completion by doing a
longjmp
out of the signal handler. Also,
signal handlers process User mode data. Supervisor mode interrupt handlers always
run to completion and process data relevant to the Supervisor’s support task rather
than the current User mode task.
Because a user task is being interrupted whilst operating in Supervisor mode,
the complete processor state must be saved in a similar way to an asynchronous
context switch. The context information can not be stored in the current user’s PCB
because it is used to hold the User mode status when Supervisor mode is entered via a
system call.
User programs usually switch stacks when executing system calls (see section
5.7). The user’s system stack is not accessible to the User mode program. This keeps
Supervisor information that appears on the stack during system call execution hidden
from the user. The user’s system stack can be used to support C function calls during
interrupt handler processing. Alternatively, an interrupt processing stack can be
used. Keeping a separate interrupt stack for Supervisor mode interrupt processing
enables a smaller system mode User stack to be supported, as the interrupt processing