Specifications
Specifying an Operating System
Many drivers and software packages do not require any particular operating system. However, you can
structure your software to provide different source files depending on the operating system used.
If your driver or software has different source files, paths, or settings that depend on the operating system
used, write a Tcl script for each variant of the driver or software package. Each script must specify the
same software package or driver name in the create_driver or create_sw_package command, and
same hw_class_name in the case of device drivers. Each script must specify only the files, paths, and other
settings that pertain to that operating system. During BSP generation, only drivers or software packages
that specify compatibility with the selected operating system (OS) type are eligible to add to the BSP.
Specifying Source Files
Using the Tcl command interface, you must specify each source file in your driver or software package
that you want in the generated BSP. The commands discussed in this section add driver source files and
specify their location in the file system and generated BSP.
The add_sw_property command’s c_source and asm_source arguments add a single .c or Nios II
assembly language source file (.s or .S) to your driver or software package. You must express path
information to the source relative to the driver root (the location of the Tcl file). add_sw_property copies
source files to BSPs that incorporate the driver, using the path information specified, and adds them to
source file list in the generated BSP makefile. When you build the BSP using make, the driver source files
are compiled as follows:
add_sw_property c_source HAL/src/my_driver.c
The add_sw_property command’s include_source argument adds a single header file in the path
specified to the driver. The paths are relative to the driver root. add_sw_property copies header files to
the BSP during generation, using the path information specified at generation time. It does not include
header files in the makefile.
add_sw_property include_source inc/my_custom_component_regs.h
add_sw_property include_source HAL/inc/my_custom_component.h
Specifying a Subdirectory
You can optionally specify a subdirectory in the generated BSP for your driver or software package files
using the bsp_subdirectory argument to set_sw_property. All driver source and header files are
copied to this directory, along with any path or hierarchy information specified with each source or
header file. If no bsp_subdirectory is specified, your driver or software package is placed under the
drivers folder of the generated BSP. Set the subdirectory as follows:
set_sw_property bsp_subdirectory my_driver
Note:
If the path begins with the BSP type (e.g HAL or UCOSII), the BSP type is removed and replaced
with the value of the bsp_subdirectory property.
Enabling Software Initialization
If your driver or software package uses the HAL autoinitialization mechanism, your source code includes
INSTANCE and INIT macros, to create storage for each driver instance, and to call any initialization
routines. The generated alt_sys_init.c file invokes these macros, which must be defined in a header file
named <hardware component class>.h.
For more information, refer to the “Provide *INSTANCE and *INIT Macros” chapter.
7-22
Specifying an Operating System
NII5V2
2015.05.14
Altera Corporation
Developing Device Drivers for the Hardware Abstraction Layer
Send Feedback