02.03.2014 Views

BSP Developer's Guide

BSP Developer's Guide

BSP Developer's Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2<br />

<strong>BSP</strong> Organization<br />

Many VxWorks facilities cannot be invoked from this routine. Because there is no<br />

task context as yet (no TCB and no task stack), facilities that require a task context<br />

cannot be invoked. This includes any facility that can cause the caller to be<br />

preempted, such as semaphores, or any facility that uses such facilities, such as<br />

printf( ). Instead, the usrInit( ) routine does only what is necessary to create an<br />

initial task, usrRoot( ). This task then completes the startup.<br />

The initialization in usrInit( ) includes the following:<br />

■<br />

■<br />

■<br />

Cache Initialization. The code at the beginning of usrInit( ) initializes the<br />

caches, sets the mode of the caches and puts the caches in a safe state. At the<br />

end of usrInit( ), the instruction and data caches are enabled by default.<br />

Zeroing Out the System bss Segment. The C and C++ languages specify that<br />

all uninitialized variables must have initial values of 0. These uninitialized<br />

variables are put together in a segment called the bss. This segment is not<br />

actually loaded during the bootstrap, because it is known to be zeroed out.<br />

Because usrInit( ) is the first C code to execute, it clears the section of memory<br />

containing bss as its very first action. While the VxWorks boot ROMs clear all<br />

memory, VxWorks does not assume that the boot ROMs are used.<br />

Initializing Interrupt Vectors. The exception vectors must be set up before<br />

enabling interrupts and starting the kernel. First, intVecBaseSet( ) is called to<br />

establish the vector table base address.<br />

2<br />

! CAUTION: For some architectures, there are exceptions to the rule that<br />

intVecBaseSet( ) must be called before enabling interrupts and starting the kernel.<br />

See the appropriate VxWorks Architecture Supplement document.<br />

After intVecBaseSet( ) is called, the routine excVecInit( ) initializes all exception<br />

vectors to default handlers that safely trap and report exceptions caused by<br />

program errors or unexpected hardware interrupts.<br />

Initializing System Hardware to a Quiescent State. System hardware is initialized<br />

by calling the system-dependent routine sysHwInit( ). This mainly consists of<br />

resetting and disabling hardware devices that can cause interrupts after interrupts<br />

are enabled (when the kernel is started). This is important because VxWorks ISRs<br />

(for I/O devices, system clocks, and so on) are not connected to their interrupt<br />

vectors until the system initialization is completed in the usrRoot( ) task. However,<br />

because the memory pool is not yet initialized, you must not try to connect an<br />

interrupt handler to an interrupt during the sysHwInit( ) call.<br />

35

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!