To understand the production of VxWorks BSP, you must first have a general understanding of the startup process of VxWorks. Let's first talk about the startup process of VxWorks. In general, all processors perform the same logic step to initialize and load VxWorks, but some processors may have some special steps, while others may skip some steps. However, they all take the following steps, into: Initialization processor, and provide a piece of code in the specific location of the memory (there may be some tables) to operate when the processor is powered or restarted. This code sets the status of the processor, initialize the memory, and memory address, and the control is handed over to the bootstrapping code.
1. The processor first jumps to the entry address of the ROM, set the status word and create a dumb stack (Dummy Stack)
2, jump to the entrance address of the C program, determine if the parameters in the dummy stack determine whether the memory RAM (if the COLD Start is cleared), copy the remainder of the ROM segment to the RAM (if the ROM code is compressed) And decompress it).
3. The processor jumps to the entry address of the RAM, which is invalid, clear the BSS segment, the initialization interrupt vector table, and is initialized.
4, start multiple task kernels
The Boot Rom of VxWorks is an independent application. Developers can use it to launch a VxWorks image through the network and connected to the application code.
VxWorks startup process
Rominit () ------ romstart () ------- sysinit () --------- InitVectBaseset () ------- Syshwinit () ------ --usrkernelinit () ------- kernelinit () ------- USRROOT ()
Document and program description:
Rominit.s: rominit ()
At the interrupt, put the start type (Cold / Warm), and then jump to the Romstart entry.
Bootinit.c: romstart ()
Copy the ROM code and data segment to the RAM, clear the unused part of the RAM, and if you need it, you need to decompress it, then jump to the entry address of the sysinit ().
The process of copying is as follows:
A, code segment is not residing in the ROM, copy code segment and data segment
B, if the code segment is residing in the ROM, only copy the data segment
C, unused memory clear zero
D, when needed, decompression
Sysalib.s: sysinit ()
Sysinit () is the entry address of the VxWorks image, the start address is defined by the RAM_LOW_ADR. It first closes the interrupt, so that the cache is invalid, the initialization processor's register is the default value, so that the Tracing is invalid, clear the interrupt register, initialize the stack of the USRinit () and activates USRinit ().
Note that the hardware initialization in Rominit () must be reinitial in sysinit ().
USRCONFIG.C and bootconfig.c: usrinit ()
It is the first C code running in VxWorks and is activated in Supervisor Mode. It offers interrupts that store information about starting type (boot type), which is necessary to initialize before the VxWorks kernel run.
A. Initialize the Cache mode, set to a safe state, make Cache valid at the end of usrinit ().
B, clear system BSS segment
C, initialize the interrupt vector table, call vectbaseset (), exevecinit ();
D, initialize the system hardware, but make it invalid Qiescent State, call SyshWinit (), which is a process related to hardware, is an important part we want to modify against different target boards, which involve the initialization of serial port and network port. , Console configuration, etc. E, call usrkernelinit (), and enable Cache
F, call kernelinit (), create usrroot ().
Usrkernel.c: kernelinit ()
Initializing the kernel optionally forming kernel facility
Kernellib.c: usrkernelinit ()
Initialize the multi-task environment.
Call the intlocklevelSet () to make the run-robin mode, create the interrupt stack, root stack, and TCB in memory, create usrroot (), interrupt usrinit () run, then open the interrupt, note to clear the interrupt register .
USRCONFIG.C and bootconfig.c: usrroot ()
Initialize I / O system, drive, device (specified in Configall.h and Config.h)
Program list
For the order of hardware initialization, it can be performed in the form of the following table:
function
sysinit ()
The file sysalib.s
Function function
(A) locking interruption
(B) disable buffer
(C) Initialize the system interrupt table (I960) with the default value
(D) Initialize the system error table with default value (I960)
(E) Some default values of the initialization processor register
(F) makes the backtrack
(G) Clear all suspension interrupts
(H) Activate usrinit () to indicate the start type.
function
usrinit ()
File
USRCONFIG.C
Function function
(A) Mercing BSS
(B) Save boottype at SysstartType;
(C) calls ExcVecinit (), initialize all systems and default interrupt vectors
(D) Call SyshWinit () in turn, kernelinit ().
USRkernelinit () calls classlibinit (), Tasklibinit (), SemBlibinit (), SemBlibinit (), SEMBLIBIT (),
Semclibinit (), Semolibinit (), WBLibinit (), Msgqlibinit (), Qinit (), Workqinit (), USRKERNEL.C
Function kernelinit ()
KERNELINIT () initialized and launched the kernel.
File
Kernellib.c
Function function
(A) Activate intlocklevelSet ()
(B) Creating a stack and TCB from top of the memory pool
(C) call taskinit (), Taskactivate () for usrroot ()
(D) call usrroot ()
function
Usrroot (), initialization I / O system, drive, device (specified in configall.h and config.h)
USRCONFIG.C
Function function
(A) call sysclkconnect (), sysclkrateset (), iosinit (), [TTYDRV ()]
(B) Initialization EXCINIT (), loginit (), SIGINIT ()
(C) Initializing pipe pipedrv ()
(D) stdioinit (), mathsoftinit () or mathhardinit ()
(E) WDBCONFIG (): Configure and initialize the target agent
In most target boards, VxWorks's entry points are completed by two functions: rominit () and romstart () instead of sysinit (). The initialization process of the specific ROM-based VxWorks is shown in the following table:
Function function function
1, rominit ()
2, ROMSTART ()
3, usrinit ()
4, usrkernelinit ()
5, kernelinit ()
6, usrroot ()
7. Application Routine
(A) Prohibition of interruption
(B) Save the start type
(C) Hardware initialization
(D) call ROMSTART ()
(A) copy the data segment from the ROM to RAM, clear memory
(B) copy the code segment from the ROM to the RAM, and if necessary, decompression
(C) call usrinit ()
Initializer
If the corresponding configuration file is defined, the corresponding function is called
Initialization and start the kernel
Initialize I / O system, drive, create equipment
Application code
Rominit.s
Bootinit.c
USRCONFIG.C
USRKERNEL.C
Kernellib.c
USRCONFIG.C
Application Source File
The files of the BSP are as follows:
1, hardware initialization file: processor initialization program
2. Operating system initialization file: various types of header files, drivers, operating system kernel initialization programs, create multi-tasking environment programs
3, tool file: various MAKE files, tools for making system boot files
BSP work
1. Single board hardware initialization, mainly the initialization of the CPU, providing the underlying hardware support for the entire software system
2. Provide device drivers and system interrupt service programs for operating systems
3, customize the function of the operating system, provide a real-time multitasking operating environment for the software system
4, initialize the operating system, prepare for the operating system
BSP generation depends on some development and debugging tools provided by VxWorks
The meaning of the term:
CPU: CPU of the target board
Tool: Host Development Tool
ROM_TEXT_ADRS: Start the ROM's 16-entered address, most target boards set to the start address of the ROM
ROM_SIZE: ROM's 16-in-room size
ROM_LOW_ADRS: The start address loaded by VxWorks
ROM_HIGH_ADRS: Boot ROM Copy to RAM's starting address
LOCAL_MEM_LOCAL_ADRS: The start address of the target board storage space
Local_mem_size: Fixed (Static) Memory Size
User_reserved_mem: Keep memory size RAM_HIGH_ADRS: Copy the target address of the Boot ROM image
ROM_BASE_ADRS: ROM start address
Rom_text_adrs: The entrance address of the boot ROM, most of the start addresses for ROM space
ROM_WARM_ADRS: Thermally started the entry address
ROM_SIZE: Size of ROM Space
The definition of ROM_TEXT_ADRS and ROM_SIZE must be consistent with Makefile.
Common mistake
A, local_mem_local_ads importance, most applications are set to 0
B, do too much device initialization in rominit.s, Rominit.s only do basic initialization, and true device is initialized in syshwinit ().
C, do too little in sysalib.s, all initialization made in rominit.s must be reinitialized in sysalib.s
D. Place the modified driver in the wrong directory, the driver related to the BSP should be placed in Target / Config / BSPName, not the WRS Target / SRC / DRV and Target / H / DRV.
E, confuse the configuration option, must be an optional BSP configuration in file config.h, and omnipotentation should be included in bspname.h.