Specifications
Provide Reduced Footprint Drivers
The HAL defines a C preprocessor macro named ALT_USE_SMALL_DRIVERS that you can use in driver
source code to provide alternate behavior for systems that require a minimal code footprint. If
ALT_USE_SMALL_DRIVERS is not defined, driver source code implements a fully featured version of the
driver. If the macro is defined, the source code might provide a driver with restricted functionality. For
example a driver might implement interrupt-driven operation by default, but polled (and presumable
smaller) operation if ALT_USE_SMALL_DRIVERS is defined.
When writing a device driver, if you choose to ignore the value of ALT_USE_SMALL_DRIVERS, the same
version of the driver is used regardless of the definition of this macro.
You can enable ALT_USE_SMALL_DRIVERS in a BSP with the hal.enable_reduced_device_drivers BSP
setting.
For more information, refer to the "Nios II Software Build Tools Reference" chapter.
Related Information
Nios II Software Build Tools Reference on page 15-1
Support the Lightweight Device Driver API
Using Character-Mode Functions
The lightweight device driver API allows you to minimize the overhead of character-mode device drivers.
It does this by removing the need for the alt_fd file descriptor table, and the alt_dev data structure
required by each driver instance.
If you want to support the lightweight device driver API on a character-mode device, you need to write at
least one of the lightweight character-mode functions listed in the "Driver Functions for Lightweight
Device Driver API" table (Table 7-6). Implement the functions needed by your software. For example, if
you only use the device for stdout, you only need to implement the <component class>_write()
function.
Table 7-6: Driver Functions for Lightweight Device Driver API
Function Purpose Example
(7)
<component class>_read() Implements character-
mode read functions
altera_avalon_jtag_uart_read()
<component class>_write() Implements character-
mode write functions
altera_avalon_jtag_uart_write()
<component class>_ioctl() Implements device-
dependent functions
altera_avalon_jtag_uart_ioctl()
Using Macros
When you build your BSP with ALT_USE_DIRECT_DRIVERS enabled, instead of using file descriptors, the
HAL accesses your drivers with the following macros:
(7)
Based on component altera_avalon_jtag_uart.
7-30
Provide Reduced Footprint Drivers
NII5V2
2015.05.14
Altera Corporation
Developing Device Drivers for the Hardware Abstraction Layer
Send Feedback