Specifications
net structure internally to define its interface to device drivers. The net structure is defined in net.h, in
<iniche path>/src/downloads/30src/h. Among other things, the net structure contains the following
things:
• A field for the IP address of the interface
• A function pointer to a low-level function to initialize the MAC device
• Function pointers to low-level functions to send packets
Typical NicheStack code refers to type NET, which is defined as *net.
Related Information
• NicheStack Technical Reference Manual
For more information about the NicheStack TCP/IP Stack implementation, refer to the NicheStack
Technical Reference Manual, available on the Nios II Processor Documentation website.
• NicheStackRef.zip
For access to the NicheStackRef.zip file.
Provide *INSTANCE and *INIT Macros
To enable the HAL to use your driver, you must provide two HAL macros. The names of these macros are
based on the name of your network interface component, according to the following templates:
• <component name>_INSTANCE
• <component name>_INIT
For examples, refer to ALTERA_AVALON_LAN91C111_INSTANCE and ALTERA_AVALON_LAN91C111_INIT in
<SMSC path>/inc/iniche/altera_avalon_lan91c111_iniche.h, which is included in <iniche path>/inc/altera_
avalon_lan91c111.h.
You can copy altera_avalon_lan91c111_iniche.h and modify it for your own driver. The HAL expects to find
the *INIT and *INSTANCE macros in <component name>.h.
For more information, refer to the “Header Files and alt_sys_init.c” chapter. You can accomplish this with
a #include directive as in altera_avalon_lan91c111.h, or you can define the macros directly in
<component name>.h.
Your *INSTANCE macro declares data structures required by an instance of the MAC. These data
structures must include an alt_iniche_dev structure. The *INSTANCE macro must initialize the first
three fields of the alt_iniche_dev structure, as follows:
• The first field, llist, is for internal use, and must always be set to the value ALT_LLIST_ENTRY.
• The second field, name, must be set to the device name as defined in system.h. For example, altera_
avalon_lan91c111_iniche.h uses the C preprocessor’s ## (concatenation) operator to reference the
LAN91C111_NAME symbol defined in system.h.
• The third field, init_func, must point to your software initialization function.
For more information, refer to the “Provide a Software Initialization Function” chapter.
For example, altera_avalon_lan91c111_iniche.h inserts a pointer to alt_avalon_lan91c111_init().
Your *INIT macro initializes the driver software. Initialization must include a call to the
alt_iniche_dev_reg() macro, defined in alt_iniche_dev.h. This macro registers the device with the HAL
by adding the driver instance to alt_iniche_dev_list.
When your driver is included in a Nios II BSP project, the HAL automatically initializes your driver by
invoking the *INSTANCE and *INIT macros from its alt_sys_init() function. For more information
about the *INSTANCE and *INIT macros, refer to the “Header Files and alt_sys_init.c” chapter.
7-14
Provide *INSTANCE and *INIT Macros
NII5V2
2015.05.14
Altera Corporation
Developing Device Drivers for the Hardware Abstraction Layer
Send Feedback