Nios® V Processor Software Developer Handbook

ID 743810
Date 7/08/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

4.4.2.3. HAL Initialization

As for any other C program, the first part of the HAL's initialization is implemented by the Nios® V processor's crt0.S routine. After crt0.S completes the C run-time initialization, it calls the HAL alt_main() function, which initializes the HAL BSP run-time library and subsystems.

The HAL alt_main() function performs the following steps:

  1. Initializes interrupts—Sets up interrupt support for the Nios® V processor with the alt_irq_init() function.
  2. Starts RTOS—Starts the RTOS, if this OS is configured to run (with the ALT_OS_INIT and ALT_SEM_CREATE functions). For additional information about using and initializing RTOS, refer to Selecting the Operating System.
  3. Initializes device drivers—Initializes device drivers (with the alt_sys_init() function). The Nios® V processor tools automatically find all peripherals supported by the HAL, and automatically insert a call to a device configuration function for each peripheral in the alt_sys_init() code. To override this behavior, you can disable a device driver with the BSP Editor, in the Drivers tab. For information about enabling and disabling device drivers, refer to Managing Device Drivers.
  4. Configures stdio functions—Initializes stdio services for stdin, stderr, and stdout. These services enable the application to use the GNU newlib stdio functions and map the file pointers to supported character devices. For more information about configuring the stdio services, refer to Character Mode Devices.
  5. Initializes C++ global constructors and destructors—Handle’s initialization of global C++ constructor and destructor functions. These function calls are necessary if your application is written in the C++ programming language.
  6. Calls main()—Call’s function main(), or application program. Most applications are constructed using a main() function declaration and begin execution at this function.

By default, the HAL configuration mechanism enables support for the C++ programming language. Disabling this feature reduces your application's code footprint, as noted in Reducing Code Footprint in Embedded System. The Nios® V processor C++ language support depends on the GCC tool chain.