Guidelines for Developing a Nios II HAL Device Driver

ID 683146
Date 6/12/2015
Public
Document Table of Contents

1.9. Integrating a New HAL Device Driver in the BSP

When you integrate a HAL device driver into a BSP, the following services are enabled:

  • Automatic initialization with the alt_sys_init() function for the HAL device drivers.

    alt_sys_init() is an automatically generated function. alt_sys_init() calls the INIT and INSTANCE macros for each component instance found in the hardware design that has a specific source code directory structure and set of file names. The directory structure for hardware components provided by Altera conforms to:

    <Altera installation>/ip/altera/sopc_builder_ip/<component_folder>

    The easiest option for a directory structure for your custom components conforms to:

    <my_design>/ip/<component_folder>

    Place the device driver source code files in a folder structure under <component_folder>. The file names conform to the following:

    • /inc/<component>_regs.h
    • /HAL/inc/<component>.h
    • /HAL/src/<component>.c

    This document uses the variable <Altera installation> to represent the location where the Altera Complete Design Suite is installed. On a Windows system, by default, that location is c:/altera/<version number>.

  • HAL device-class services can access any specific HAL device in that class. For example, Altera_Avalon_UART is a character-mode device, and so has access to higher level services such as buffer management. HAL software device drivers become available to the UNIX-style POSIX API for device functions such as open() and read().

For more information about adding device drivers using the Nios II SBT, refer to the "Integrating a Device Driver in the HAL" section of the "Developing Device Drivers for the Hardware Abstraction Layer" chapter of the Nios II Software Developer's Handbook.

For more information about how to integrate your own VHDL or Verilog HDL source code as a new HAL-compatible Qsys component, and for details about the Component Editor tool, refer to the "Creating Qsys Components" chapter of Volume 1: Design and Synthesis in the Quartus II Handbook.