Nios® V Processor Software Developer Handbook

ID 743810
Date 4/01/2024
Public
Document Table of Contents

6.12.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® V processor tools 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++ global constructors, using the _do_ctors() function.
  • Registers the C++ global 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 provides this default implementation. The Nios® V processor tools copies alt_main.c to your BSP directory.