Specifications

The Relationship Between the .sopcinfo File and system.h....................................................... 7-3
Using the System Generation Tool to Optimize Hardware.......................................................7-3
Components, Devices, and Peripherals........................................................................................ 7-3
Accessing Hardware.................................................................................................................................... 7-3
Creating Embedded Drivers for HAL Device Classes............................................................................ 7-5
Character-Mode Device Drivers....................................................................................................7-5
File Subsystem Drivers....................................................................................................................7-7
Timer Device Drivers...................................................................................................................... 7-8
Flash Device Drivers........................................................................................................................7-9
DMA Device Drivers.....................................................................................................................7-10
Ethernet Device Drivers................................................................................................................7-11
Integrating a Device Driver in the HAL................................................................................................. 7-15
Overview......................................................................................................................................... 7-15
Assumptions and Requirements..................................................................................................7-16
The Nios II BSP Generator...........................................................................................................7-17
File Names and Locations.............................................................................................................7-18
Driver and Software Package Tcl Script Creation.....................................................................7-19
Creating a Custom Device Driver for the HAL.....................................................................................7-28
Header Files and alt_sys_init.c.....................................................................................................7-28
Device Driver Source Code.......................................................................................................... 7-29
Reducing Code Footprint in HAL Embedded Drivers.........................................................................7-29
Provide Reduced Footprint Drivers............................................................................................7-30
Support the Lightweight Device Driver API..............................................................................7-30
HAL Namespace Allocation.....................................................................................................................7-31
Overriding the HAL Default Device Drivers.........................................................................................7-32
Document Revision History for Developing Device Drivers for the Hardware Abstraction
Layer.......................................................................................................................................................7-32
Exception Handling.............................................................................................8-1
Nios II Exception Handling Overview......................................................................................................8-1
Exception Handling Terminology.................................................................................................8-1
Interrupt Controllers.......................................................................................................................8-3
Latency and Response Time...........................................................................................................8-5
Nios II Interrupt Service Routines.............................................................................................................8-6
HAL APIs for Hardware Interrupts.............................................................................................. 8-7
HAL ISR Restrictions.................................................................................................................... 8-11
Writing an ISR................................................................................................................................8-11
Registering an ISR with the Enhanced Interrupt API...............................................................8-13
Enabling and Disabling Interrupts..............................................................................................8-14
Configuring an External Interrupt Controller...........................................................................8-14
C Example.......................................................................................................................................8-15
Upgrading to the Enhanced HAL Interrupt API...................................................................... 8-16
Improving Nios II ISR Performance.......................................................................................................8-17
Software Performance Improvements........................................................................................8-17
Hardware Performance Improvements......................................................................................8-22
Debugging Nios II ISRs.............................................................................................................................8-24
HAL Exception Handling System Implementation..............................................................................8-25
Exception Handling System Structure........................................................................................8-25
TOC-7
Altera Corporation