Nios® II Software Developer Handbook

ID 683525
Date 8/28/2023
Public
Document Table of Contents

7.14.2.2. Default Implementation Steps

The HAL provides a default implementation of the alt_main() function, which performs the following steps:
  • Calls the alt_irq_init() function, located in alt_sys_init.c. alt_irq_init() initializes the hardware interrupt controller. The Nios® II development flow creates the file alt_sys_init.c for each HAL BSP.
  • Calls ALT_OS_INIT() to perform any necessary operating system specific initialization. For a system that does not include an operating system (OS) scheduler, this macro has no effect.
  • If you are using the HAL with an operating system, initializes the alt_fd_list_lock semaphore, which controls access to the HAL file systems.
  • Enables interrupts.
  • Calls the alt_sys_init() function, also located in alt_sys_init.c. alt_sys_init() initializes all device drivers and software packages in the system.
  • Redirects the C standard I/O channels (stdin, stdout, and stderr) to use the appropriate devices.
  • Calls the C++ constructors, using the _do_ctors() function.
  • Registers the C++ destructors to be called at system shutdown.
  • Calls main().
  • Calls exit(), passing the return code of main() as the input argument for exit().

alt_main.c, installed with the Nios® II EDS, provides this default implementation. The SBT copies alt_main.c to your BSP directory.