Usrinit () function analysis of VxWorks startup code

Source: Internet
Author: User
Usrinit () function analysis of VxWorks startup code

Daniellee_ustb

QQ: 382899443

 

It's another Friday evening, so you don't have to work overtime tomorrow. It's a wonderful day. Now let's look at the third major function usrinit () started by VxWorks ().

This function is the first function executed in Ram. It clears BSS segments, sets exception vectors, and CALLS syshwinit () to initialize hardware. What is a BSS segment? BSS is a memory area used to store 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 whether the data segment can be correctly called. If the data segment is not copied to the corresponding Ram region, or the copy process is incorrect, the program will die here, this can also provide a debugging method.

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 cache? Based on the neutral principle of Application Data Access dataset, it is actually to query the most commonly used data, which can improve the processing speed.

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

This is to clear the data in the BSS segment. In fact, bzero calls the memset function, and edata is directed to an address space in the Rom.

Excvecinit ();/* install exceptionvectors */

This is often seen in the source code. Many functions are external functions such as extern status excvecinit (), which are built-in to initialize all default interrupt vectors of the system.

Syshwinit ();/* initializesystem hardware */This function is in 920 t/syslib. C to see what hardware is initialized.

In fact, two hardware is initialized. One is PCI and the other is serial port. At the moment, we do not care about PCI initialization. The serial port is the focus of our attention. Sysserialhwinit (), which is at 920 t/sysserial. in C, this function obtains the predefined serial port base address, baud rate, clock and other information. Call primecellsiodevinit () à call ambainitchannel () to initialize the chip. It is really hard for the operating system to initialize a serial port. After so many layers, the key point is reached, but this also reflects the hierarchy of coding. There is nothing to say about the initialization of serial ports. The number of FIFO, control registers, clock registers, and so on is not small and easy to understand.

After the initial serial port is complete, something can be printed, but which serial port is initialized?

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}

};

The two serial ports are initialized.

Usrkernelinit ();

In this step, we need to initialize the system kernel, which is located in SRC \ config \ usrkernel. C and mainly configures some operating system mechanisms. These are not necessary, so we don't need to worry about it in the future.

Cacheenable ();

After the cache is configured, you can use it to enable the cache.

Kernelinit (), create the first job usrroot, and then initialize the board and sub-hardware. These are the quasi-work before the VxWorks kernel is started, which is located in config/All/usrconfig. C. Let's first look at his comments:

/* It initializesthe I/O system, installdrivers, creates devices, and sets

* Up thenetwork, Etc., as necessary for a special configuration.

*/

The reason why the Vxworks system is well written is that the detailed function annotation is one aspect. Through these annotations, it is easy to know its function. There are many specific content, and we will analyze it in detail next time.

To sum up, usrinit mainly implements basic mechanisms and devices for clearing BSS, setting default interrupt vectors, initializing serial ports, enabling cache, and creating the first root job of 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.