VxWorks startup code Usrinit () function analysis

Source: Internet
Author: User
VxWorks startup code usrinit () function Analysis

Daniellee_ustb 2013-6-14 Night

qq:382899443

It's Friday night again, no overtime tomorrow, it's a beautiful day. Now look at the third main function usrinit () VxWorks started.

This function is the first function that executes in RAM, mainly clears the BSS segment, sets the exception vector, and then calls Syshwinit () to initialize the hardware. What is a BSS section? A BSS is an area of memory that is used to hold uninitialized global variables and static variables.

The first sentence is

while (trapValue1! = Trap_value_1 | | TrapValue2! = trap_value_2)

{

/* Infinite loop */;

}

This is used to check if the data segment is correctly called, and if the data segment is not copied to the appropriate RAM area, or if the copy process goes wrong, then the program will die here, which can also provide a debugging tool.

Sys_hw_init_0 ();

Cachelibinit (User_i_cache_mode,user_d_cache_mode);

Is the function used to open the cache, which is related to the defined CPU. So what is the use of ARM's cache, according to the application data access data centralization principle, is actually to query the most commonly used data, can improve processing speed.

Bzero (Edata, end-edata); /* Zero out BSS variables */

This is the data that clears the BSS segment, in fact Bzero call is the Memset function, Edata is pointed to the ROM in a piece of address space.

Excvecinit (); /* Install Exceptionvectors */

In the source code often see this situation, many functions are like extern STATUS Excvecinit () such as external functions, are the system comes with, to initialize the system all default interrupt vector.

Syshwinit (); /* Initializesystem Hardware */This function is in 920t/syslib. c, see what hardware has been initialized.

In fact, the main initialization of two hardware, one is a PCI serial port, temporarily do not care about the initialization of PCI, the serial port is the focus of our watch. Sysserialhwinit (), where the position is in 920t/sysserial.c, this function obtains a pre-defined serial port base address, baud rate, clock and other information called primecellsiodevinit () à call Ambainitchannel ( ) to initialize the chip. Operating system initialization of a serial port really laborious, incredibly after so many layers to the key position, but this also reflects the people write code hierarchy. For the initialization of the serial port there is nothing to say, FIFO, control register, clock register, such as one can not be less, relatively easy to understand.

The initial end of the serial port, can print something, but the initialization of the end is which serial port it.

See:

Localsys_amba_chan_paras devparas[] =

{

{INT_VEC_UART_0, (UINT32 *) Uart_0_base_adr, int_lvl_uart_0},

{int_vec_uart_1, (UINT32 *) Uart_1_base_adr, int_lvl_uart_1}

};

This indicates that both serial ports have been initialized.

Usrkernelinit ();

To this step to initialize the system kernel, location in the SRC\CONFIG\USRKERNEL.C is mainly the configuration of the operating system of some mechanisms, these are not to become, after the transplant also do not have to tube.

Cacheenable ();

The cache can be configured to use, enabling the cache to be used.

Kernelinit (), create the first task Usrroot, and further initialize the board hardware, these are the quasi-work before starting the VxWorks kernel, which is located in Config/all/usrconfig.c. Take a look at his notes first:

/*it initializesthe I/O system, installs drivers, creates devices, and sets

* Up thenetwork, etc., as necessary for a particular configuration.

*/

The VxWorks system is well written, and a very detailed function annotation is one aspect. Through these comments, it is easy to know its role, more specific content, next time detailed analysis.

To summarize, Usrinit mainly implements the basic mechanisms and devices for clearing 0 BSS, setting the default interrupt vector, initializing the serial port, enabling the cache, and creating the root task of the first usrroot.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.