
222
Evaluating and Programming the 29K RISC Family
the DI bit. For this reason, the use of TRAP[1,0] pins requires complex software sup-
port. It is best to avoid the use of these input pins.
It is often desirable to disable timer interrupts during critical code stages, be-
cause timer interrupts often lead to such tasks as context switching. However, timer
interrupts may be required to support a real–time clock, and to maintain accuracy, a
timer interrupt can not be missed. The timer interrupt must be taken but processing
the event can be postponed till later, when it can be dealt with. To do this efficiently,
the Freeze mode interrupt handler for the timer should set register
ast
to true. This
register is a kernel space support register chosen from the range
ks0–ks15
(
gr80
–
gr95
). It indicates an Asynchronous Software Trap (AST) is ready for proces-
sing. The
ast
register can be quickly tested with an ASSERT type instruction, as
shown below:
mfsr
andn
mtsrim
asneq
iret
it0,ops
it0,it0,1
ops,it0
V_AST,ast,0
;get OPS register, DA already clear
;clear DI bit
;enable interrupts
;trap if ast != 0, timer ’event’
;otherwise iret
Clearing the DI bit reenables asynchronous interrupts (with the exception that
TRAP[1,0] are already active); but we must check to see if an AST is pending (timer
event). The
high level
timer processing is performed before the IRET instruction is
executed, via trapware supporting the V_AST trap.
4.4
USER-MODE INTERRUPT HANDLERS
Many present day operating systems allow interrupt handlers to be written in
high-order languages. User mode routines for 29K Processor Family based systems
are no different. When providing this facility, the operating system designer must be
aware of the following concerns.
User mode programs are often written by programmers who lack specific
knowledge of the operating system and it’s allocation of global registers.
The User mode handler, when written in a high-level language, such as C, will
require access to the local register stack, as well as global registers defined for
its management.
A good approach for addressing these concerns is to perform all necessary regis-
ter saving, with interrupts disabled, while in Supervisor mode; remove the cause of
the interrupt, then enable interrupts and enter User mode to execute the user’s inter-
rupt handler code. This allows interrupt (signal) handlers to be compatible with
AMD’s
Host Interface (HIF) v2.0 Specification
(see section 2.2), which includes the
definition of operating system services . These services install and invoke user-sup-
plied interrupt handlers for floating-point exceptions and keyboard interrupt