
VxWorks
BSP Developer’s Guide, 6.0
52
Modified Drivers Located in the Wrong Directory
BSP writers frequently modify Wind River device drivers, as well as provide their
own drivers. These BSP-specific drivers must be delivered in BSP-specific
directories and not in the Wind River directories target/src/drv and target/h/drv.
BSP-specific code belongs in the BSP-specific directory target/config/bspname.
Modifying code in the Wind River directories can have very adverse effects for
customers using multiple BSPs from different sources. The generic directories
should contain only the original code provided by Wind River.
Confusing Configuration Options
In the config.h file, the user should be presented with clear choices for configuring
the BSP. Material that cannot be configured by the user should not be in config.h,
but should be placed in bspname.h instead.
In addition, the user should not have to compute values to be typed into config.h.
Instead, there should be macros for manipulation of the relevant data. For
example, if a register must be loaded with the high 12 bits of an address, the user
should only be required to enter the full address. Even better would be for the user
to enter the name of a symbol or macro that refers to the address. The code, either
the compiler’s preprocessor or the configuration code that is part of the BSP,
should do the computation of the value to load in the register.
The following examples illustrate correct configuration options:
/* Division Factor of BRGCLK shift, specified in hardware docs */
#define SCCR_DFBRG_SHIFT 0x000c
#define BRGCLK_DIV_FACTOR 4
/* set the BRGCLK division factor */
* SCCR(immrVal) = (* SCCR(immrVal) & ~SCCR_DFBRG_MSK) |
(BRGCLK_DIV_FACTOR << SCCR_DFBRG_SHIFT);
Correct example 2:
#define BRGCLK_FREQ (SPLL_FREQ / ( 1 << (2 * BRGCLK_DIV_FACTOR)))
ppc860Chan [i].clockRate = BRGCLK_FREQ;
Correct example 3:
lis r6, HIADJ(ROM_TEXT_ADRS) /* load r6 with the address */
addi r6, r6, LO(ROM_TEXT_ADRS) /* of ROM_TEXT_ADRS */
The following examples show incorrect configuration options:
/* WRONG: DO NOT use a magic number in assembly source code! */
* SCCR(immrVal) = (* SCCR(immrVal) & ~SCCR_DFBRG_MSK) | 0x4000);
Incorrect example 2:
/* WRONG: DO NOT use a magic number in C source code! */
ppc860Chan [i].clockRate = 0x16e3600;
Comentários a estes Manuais