VxWorks startup code Usrroot () function analysis (i)

Source: Internet
Author: User
Tags message queue posix

Today, in the afternoon of Sunday, I began analyzing the usrroot () function to see what functions the function implemented.

(1) Meminit (Pmempoolstart, mempoolsize); /* Initialize Memory pool */

We know that memory has been zeroed out in the Romstart function, and what is the memory pool for? Search for a long while there is no data specifically how to initialize the memory, according to the experience of previous debugging QNX, I personally think this step is likely to ensure that the corresponding memory 0 operation.

(2) Usrmmuinit (); /* Initialize the MMU * *

Initialize the MMU unit, this is easier to understand, the MMU is the memory management Unit, responsible for the management of virtual address, can ensure that each user process has its own independent address space to use, in time two different processes read and write the same memory virtual address, actually read and write the physical address is not the same. This initializes the MMU unit and opens the function to see that the corresponding library functions are loaded for different CPU types.

(3) Clock setting

Sysclkconnect ((funcptr) usrclock, 0); /* Connect clock ISR connection System clock Interrupt Service Program */

We know that as a multi-tasking operating system, task context switching is the most basic function, the system is scheduled to use the system clock interrupt, where the clock setting provides such a function. With this mechanism, it is possible to implement multithreading in the next step. Where is the interrupt handler hooked up. Originally VxWorks provides the Usrclock () function is the system default clock interrupt processing function, used to call the counter function tickannounce (), to achieve the function of the system counter.

Sysclkrateset (sys_clk_rate); /*set system clock Rate sets the number of interrupts per second, the default interrupt frequency is 60, generally 60 to 100, but not greater than 600, that is, 1s generates 60 interrupts, presumably 16.67ms*/

Here is an interesting topic, that is, according to the default interrupt frequency 60 times, is not set the higher the real-time, the higher it. In fact, this is not the case, the VxWorks manual recommends not to set the clock rate too high, otherwise it will be hard real-time to become soft real-time. Because the high clock rate makes the kernel scheduling frequent entry, it is more likely that some low-priority hardware interrupts can not be timely response.

Sysclkenable (); /* Start it Enable system clock interrupt */

(4) Selectinit (num_files); What does this function do? That is, the _func_selwakeuplistinit function needs to be initialized its first

(5) Iosinit (Num_drivers, Num_files, "/null"); Initialize the IO system, which restricts the opening of up to 20 devices and 50 files at the same time, and also applies some memory space, including the device table, the device driver function table, etc.

(6) Ttydrv (); /*install Console Driver */

Ttydrv is a character-based device that is responsible for the interaction between the serial and IO systems. The device-driven initialization process first calls the system function Ttydrv (), which installs the Ttyopen (), Ttyioctl (), Tyread (), Tyread, and tywrite into the system-driven function table by calling Iosdrvinstall (), for i/ o system call. In fact, it is not difficult to understand, as I wrote before the QNX SD card driver process, responsible for the bottom of the upper layer of fish interaction. Once the driver module is initialized successfully, the application can send and receive data using the standard I/O functions read () and write ().

One problem is which serial port the Ttydrv initializes. Look down.

In some of the following code found a usable serial port, that is sprintf (Tyname, "%s%d", "/tyco/", ix);

So we found/tyco/0,ttydrv. () implements the docking of the driver function with the IO system standard POSIX interface, then

(void) ttydevcreate (Tyname, Sysserialchanget (ix), 512, 512); Create a serial port 0 driver, if it is the system Console_tty port, open, and set.

CONSOLEFD =open (consolename, O_RDWR, 0);

(void) IOCTL (CONSOLEFD, Fiobaudrate, console_baud_rate);

(void) IOCTL (CONSOLEFD, fiosetoptions, opt_terminal);

Pass

Ioglobalstdset (std_in, CONSOLEFD);

Ioglobalstdset (STD_OUT,CONSOLEFD);

Ioglobalstdset (STD_ERR,CONSOLEFD);

By locating the standard input and output to the console, you can implement a call to the console using printf.

(7) Next initialize some structure, signal, pipeline, debug information, standard IO function library, signal queue, semaphore, line libraries, message queue, and some POSIX feature support.

Dosfslibinit (0) Dosfslibinit calls Iosdrvinstall to populate the driver table with 7 function pointers, and to get a corresponding function provided by the entry of each function in the driver list corresponding to the file system.

(8)/*initialize USB Components */

Includes a series of USB device initialization, including Usbhost stack, mouse, keyboard, printer, speaker and so on.

(9) SCSI device initialization

What is SCSI. Explained in the Tornado Devicedriver Workshop book as small computer System Interface, which is designed to provide a separate device interface with the advantage that one controller can control multiple peripherals, which provides a driver writing method , and then study it later.

(10) Idedrvide Drive, SATA HDD Support, PCMCIA card, tffs Flash file system, support for floating point software and hardware calculation, task scheduling tool, Time tool, setting environment variable, module Manager, boot device initialization, etc.

(one) usrnetinit () network device initialization.

The SCSI device and the Usrnetinit () network initialization are then carefully analyzed later.

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.