Specifications
The HAL funnel code is called from the vector table.
Running in a Restricted Environment
ISRs run in a restricted environment. A large number of the HAL API calls are not available from ISRs.
For example, accesses to the HAL file system are not permitted. As a general rule, when writing your own
ISR, never include function calls that can block for any reason (such as waiting for a hardware interrupt).
For more information about identifying these API functions that are not available to ISRs, refer to the
"HAL API Reference" chapter.
Be careful when calling ANSI C standard library functions inside of an ISR. Avoid using the C standard
library I/O API, because calling these functions can result in deadlock within the system, that is, the
system can become permanently blocked in the ISR.
In particular, do not call printf() from within an ISR unless you are certain that stdout is mapped to a
non-interrupt-based device driver. Otherwise, printf() can deadlock the system, waiting for a hardware
interrupt that never occurs because interrupts are disabled.
Related Information
HAL API Reference on page 14-1
Managing Pre-Emption
The HAL enhanced interrupt API supports interrupt pre-emption. When pre-emption is enabled, a
higher-level interrupt can take control even if an ISR is already running. A device driver must be specifi‐
cally written to function correctly under pre-emption. When a device driver supports pre-emption, it
publishes this capability through the isr_preemption_supported driver setting. When constructing the
BSP, the SBT checks each device driver to determine whether it supports pre-emption. If all drivers in the
BSP support pre-emption, it is enabled.
Legacy device drivers do not publish the isr_preemption_supported property. Therefore the SBT
assumes that they do not support pre-emption. If your legacy custom driver supports pre-emption, and
you want to allow pre-emption in the BSP, you must update the driver to use the enhanced interrupt API.
Note:
To enable the enhanced interrupt API, ensure that all drivers in the system are updated to use the
enhanced interrupt API.
For more information and details about the isr_preemption_supported driver setting, refer to the
set_sw_property command in the “Software Build Tools Tcl Commands” section of the "Nios II
Software Build Tools Reference" chapter.
Operating systems can also publish the isr_preemption_supported property.
The HAL enhanced interrupt API supports automatic pre-emption. Automatic pre-emption means that
maskable exceptions remain enabled when the processor accepts the hardware interrupt. This means that
your ISR can immediately be pre-empted by a higher-level ISR, without any need to execute the eret
instruction.
Automatic pre-emption can only take place when the pre-empting hardware interrupt uses a different
register set from the interrupt being pre-empted.
Automatic pre-emption is only available if you enable it in the BSP settings.
Related Information
Nios II Software Build Tools Reference on page 15-1
8-12
Running in a Restricted Environment
NII5V2
2015.05.14
Altera Corporation
Exception Handling
Send Feedback