|
发表于 2009-11-12 09:44:22
|
显示全部楼层
NIOS软件手册上也有相关的说明,大家也可以学习啊
Normally, your program’s entry point is the function main(). There is an
alternate entry point, alt_main(), that you can use to gain greater
control of the boot sequence. The difference between entering at main()
and entering at alt_main() is the difference between hosted and free-
standing applications.
Boot Sequence for HAL-Based Programs
The HAL provides system initialization code that performs the following
boot sequence:
■ Flushes the instruction and data cache
■ Configures the stack pointer
■ Configures the global pointer register
■ Zero initializes the BSS region using the linker supplied symbols
__bss_start and __bss_end. These are pointers to the beginning
and the end of the BSS region
■ If there is no boot loader present in the system, copies to RAM any
linker section whose run address is in RAM, such as .rwdata,
.rodata, and .exceptions. See “Global Pointer Register” on
page 4–37.
■ Calls alt_main()
The HAL provides a default implementation of the alt_main()
function, which performs the following steps:
■ Calls ALT_OS_INIT() to perform any necessary operating system
specific initialization. For a system that does not include an 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.
■ Initializes the interrupt controller, and enable interrupts
■ Calls the alt_sys_init() function, which initializes all device
drivers and software components in the system. The Nios II IDE
creates and manages the file alt_sys_init.c for each HAL
system library
■ 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
■ Register 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. You can find it in <Nios II EDS install
path>/components/altera_hal/HAL/src. |
|