Visible to Intel only — GUID: mwh1416946798631
Ixiasoft
Visible to Intel only — GUID: mwh1416946798631
Ixiasoft
7.14.1. Hosted Versus Free-Standing Applications
The ANSI C standard defines a hosted application as one that calls main() to begin execution. At the start of main(), a hosted application presumes the runtime environment and all system services are initialized and ready to use. This is true in the HAL environment. If you are new to Nios® II programming, the HAL’s hosted environment helps you come up to speed more easily, because you need not consider what devices exist in the system or how to initialize each one. The HAL initializes the whole system.
The ANSI C standard also provides for an alternate entry point that avoids automatic initialization, and assumes that the Nios® II programmer initializes any needed hardware explicitly. The alt_main() function provides a free-standing environment, giving you complete control over the initialization of the system. The free-standing environment places on the programmer the responsibility to initialize any system features used in the program. For example, calls to printf() do not function correctly in the free-standing environment, unless alt_main() first instantiates a character-mode device driver, and redirects stdout to the device.
For more information about reducing code footprint, refer to and use the suggestions described in the “Reducing Code Footprint in Embedded Systems” chapter.
The Nios® II EDS provides examples of both free-standing and hosted programs.