
2 Overview of a BSP
2.2 Boot Sequence
17
2
This routine must duplicate much of the hardware initialization done by romInit( )
in order to set the run-time state rather than the boot state. Keep in mind that the
board may have been booted using a ROM monitor or hardware debugger. In this
case, the VxWorks boot ROM code, where romInit( ) is located, is not executed and
VxWorks system initialization is not performed. Therefore, failure to duplicate the
initialization code from romInit( ) may result in BSP failure.
Step 4: Execute usrInit( )
The purpose of the usrInit( ) routine is to completely initialize the CPU and shut
down any other hardware, thus preparing the way for the kernel to initialize and
start itself. This routine is located in usrConfig.c but calls routines in several other
files, some of which you must provide and some of which are provided by Wind
River. Normally, it is not necessary to modify the usrInit( ) routine provided by
Wind River. However, the sysHwInit( ) routine that must be called from usrInit( )
typically requires modification. The sysHwInit( ) routine ensures that the
board-dependent hardware is quiescent. sysHwInit( ) is provided in the reference
BSP or template and is located in sysLib.c.
The usrInit( ) routine (in usrConfig.c) saves information about the boot type,
handles all initialization that must be performed before the kernel is actually
started, and then starts the kernel execution. It is the first C code to run in VxWorks.
This routine is invoked in supervisor mode with all hardware interrupts locked
out.
Many facilities cannot be invoked from this routine. Because there is no task
context yet—that is, no task control block (TCB) and no thread stack—facilities that
require a task context cannot be invoked. This includes any facility that can cause
the caller to be preempted (such as semaphores) or any facility that itself uses a
facility of this type, such as printf( ). Instead, the usrInit( ) routine does only what
is necessary to create the initial thread, usrRoot( ). usrRoot( ) then completes the
startup.
The initialization operations performed in usrInit( ) include the following:
■
Cache Initialization—The code at the beginning of usrInit( ) initializes the
caches, sets the mode of the caches, and puts the caches in a safe state. At the
end of usrInit( ), the instruction and data caches are enabled by default.
■
Zeroing Out the System BSS Segment—C language specifies that all
uninitialized variables (stored in bss) must have initial values of 0. Because
usrInit( ) is the first C code to execute, it clears the section of memory
containing bss.
Komentáře k této Příručce