|
|
Wiki > Main > TargetTree (compare)
|
Difference: TargetTree (r2 vs. r1)The Target Tree structureGeneral Rockbox builds on many different targets. We need a way to separate the target specific code to keep the common/generic code as clean as possible. The traditional solution in Rockbox so far has been to use void my_hw_init(void) {
#ifdef IRIVER_H100_SERIES
or_l(0x00020000, &GPIO1_ENABLE);
#elif defined(IRIVER_H300_SERIES)
or_l(0x00040000, &GPIO1_ENABLE);
#endif
}
When we have many targets, these The directory structureThe target tree is divided into subdirectories, where each directory is an abstraction level. firmware/target/<cpu>/<manufacturer>/<model>/ The idea is to have CPU-specific code in the #ifndef SIMULATOR #ifdef CPU_COLDFIREtarget/coldfire/memcpy.S target/coldfire/memcpy-coldfire.S # endif #endif Backlight example The backlight code is a perfect example of the benefit of the target tree structure. Here we have a generic functionality that turns off the backlight after a user-defined timeout. However, controlling the actual backlight is done differently in virtually all targets. The backlight code calls two functions, firmware/target/coldfire/iaudio/x5/backlight-x5.c The file is called backlight-x5.c to make it easier to distinguish from the generic one when doing a file search. We recommend you to do the same when you port to a new target. This file defines the void __backlight_on(void)
{
int level = set_irq_level(HIGHEST_IRQ_LEVEL);
pcf50606_write(0x38, 0x30); /* Backlight ON */
set_irq_level(level);
}
void __backlight_off(void)
{
int level = set_irq_level(HIGHEST_IRQ_LEVEL);
pcf50606_write(0x38, 0x70); /* Backlight OFF */
set_irq_level(level);
}
What about targets not yet ported to the target tree? The #ifndef TARGET_TREE
void my_hw_init(void) {
#ifdef IRIVER_H100_SERIES
bla bla
#elif defined(IRIVER_H300_SERIES)
bla bla
#endif
}
#endif
The function is defined in the generic file unless the TARGET_TREE macro is defined. The goal is to remove all target specific code to the target tree, but we're not there yet. What about include files? The target tree is supposed to use the firmware/target/<cpu>/<manufacturer>/<model> firmware/target/<cpu>/<manufacturer>/ firmware/target/<cpu>/ For example, the #include "m5636-target.h" The r3 - 24 Sep 2008 - 14:02:10 - MarcGuay
Revision r2 - 25 Jul 2006 - 10:53 - LinusNielsenFeltzingRevision r1 - 25 Jul 2006 - 09:25 - LinusNielsenFeltzing Copyright © by the contributing authors.
|