Altera Nios II User Manual page 93

Hide thumbs Also See for Nios II:
Table of Contents

Advertisement

Chapter 3: Programming Model
Exception Processing
System software can globally disable fast nested interrupts by setting config.ANI to 0.
In this state, the Nios II processor disables interrupts when taking a maskable
interrupt (nonmaskable interrupts always disable maskable interrupts). Individual
ISRs can re-enable nested interrupts by setting status.PIE to 1, as described in
"Nested Exceptions with the Internal Interrupt Controller" on page
Handling Nonmaskable Interrupts
Writing an NMI handler involves the same basic techniques as writing any other
interrupt handler. However, nonmaskable interrupts always preempt maskable
interrupts, and cannot be preempted. This knowledge can simplify handler design in
some ways, but it means that an NMI handler can have a significant impact on overall
interrupt latency. For the best system performance, perform the absolute minimum of
processing in your NMI handlers, and defer less-critical processing to maskable
interrupt handlers or foreground software.
NMIs leave intact the processor state associated with maskable interrupts and other
exceptions, as well as normal, nonexception processing, when each NMI is assigned
to a dedicated shadow register set. Therefore, NMIs can be handled transparently.
1
If not assigned to a dedicated shadow register set, an NMI can overwrite the
processor status associated with exception processing, making it impossible to return
to the interrupted exception.
1
Do not set status.PIE in a nonmaskable ISR. If status.PIE is set, a maskable
interrupt can pre-empt an NMI, and the processor exits NMI mode. It cannot be
returned to NMI mode until the next nonmaskable interrupt.
Returning From Interrupt and Instruction-Related Exceptions
The eret instruction is used to resume execution at the pre-exception address.
You must ensure that when an exception handler modifies registers, they are restored
when it returns. This can be taken care of in either of the following ways:
In the case of ISRs, if the EIC interface and shadow register sets are implemented,
and the ISR has a dedicated register set, no software action is required. The Nios II
processor returns to the previous register set when it executes eret, which restores
the register contents. For details, refer to
Interrupt
In the case of noninterrupt exceptions, for ISRs in a system with the internal
interrupt controller, and for ISRs without a dedicated shadow register set, the
exception handler must save registers on entry and restore them on exit. Saving
the register contents on the stack is a typical, re-entrant implementation.
1
It is not necessary to save and restore the exception temporary (et or r24) register.
When executing the eret instruction, the processor performs the following tasks:
1. Restores the previous contents of status as follows:
February 2014 Altera Corporation
Controller".
If status.CRS is 0, copies estatus to status
If status.CRS is nonzero, copies sstatus to status
3–51.
"Nested Exceptions with an External
Nios II Processor Reference Handbook
3–53

Advertisement

Table of Contents
loading

Table of Contents