Make the device tree available in the rom stage

We thought about two ways to do this change. The way we decided to try
was to
1. drop all ops from devices in romstage
2. constify all devices in romstage (make them read-only) so we can
   compile static.c into romstage
3. the device tree "devices" can be used to read configuration from
   the device tree (and nothing else, really)
4. the device tree devices are accessed through struct device * in
   romstage only. device_t stays the typedef to int in romstage
5. Use the same static.c file in ramstage and romstage

We declare structs as follows:
ROMSTAGE_CONST struct bus dev_root_links[];
ROMSTAGE_CONST is const in romstage and empty in ramstage; This
forces all of the device tree into the text area.

So a struct looks like this:
static ROMSTAGE_CONST struct device _dev21 = {
 #ifndef __PRE_RAM__
        .ops = 0,
 #endif
        .bus = &_dev7_links[0],
        .path = {.type=DEVICE_PATH_PCI,{.pci={ .devfn = PCI_DEVFN(0x1c,3)}}},
        .enabled = 0,
        .on_mainboard = 1,
        .subsystem_vendor = 0x1ae0,
        .subsystem_device = 0xc000,
        .link_list = NULL,
        .sibling = &_dev22,
 #ifndef __PRE_RAM__
        .chip_ops = &southbridge_intel_bd82x6x_ops,
 #endif
        .chip_info = &southbridge_intel_bd82x6x_info_10,
        .next=&_dev22
};

Change-Id: I722454d8d3c40baf7df989f5a6891f6ba7db5727
Signed-off-by: Ronald G. Minnich <rminnich@chromium.org>
Signed-off-by: Stefan Reinauer <reinauer@google.com>
Reviewed-on: http://review.coreboot.org/1398
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
This commit is contained in:
Stefan Reinauer
2012-07-31 16:47:25 -07:00
committed by Ronald G. Minnich
parent 15dc3ccaab
commit 57879c9bd1
11 changed files with 158 additions and 31 deletions

View File

@ -20,7 +20,7 @@
# $1: command to test for GNU make
search_make() {
if [ -n "`$1 --version 2>&1 |grep GNU`" ]; then MAKE=$1; fi
if [ -n "`$1 --version 2>&1 | grep GNU`" ]; then MAKE=$1; fi
}
# if $1 and $2 differ, exit with failure
@ -33,7 +33,12 @@ fi
# $1: object directory
run_printall() {
$MAKE CONFIG_USE_BLOBS=n CONFIG_CCACHE=n CONFIG_SCANBUILD_ENABLE=n NOMKDIR=1 DOTCONFIG=$TMPCONFIG obj=$1 printall |sed -e "s,^ *,," -e "s,^ramstage-objs:=,," -e "s,mainboard/[^/]*/[^/]*/,.../," |tr " " "\n"|grep "/static.*\.[co]" |sort |tr '\012\015' ' ' |sed -e "s, *, ,g" -e "s, *$,,"
$MAKE CONFIG_USE_BLOBS=n CONFIG_CCACHE=n CONFIG_SCANBUILD_ENABLE=n NOMKDIR=1 \
DOTCONFIG=$TMPCONFIG obj=$1 printall | \
sed -e "s,^ *,," -e "s,^r.mstage-objs:=,," \
-e "s,mainboard/[^/]*/[^/]*/,.../,g" | \
tr " " "\n" | grep "/static.*\.[co]" | sort | \
tr '\012\015' ' ' | sed -e "s, *, ,g" -e "s, *$,,"
}
# find GNU make
@ -54,10 +59,10 @@ $MAKE DOTCONFIG=$TMPCONFIG allyesconfig >/dev/null
# look up parent directory
PARENTDIR=`dirname $PWD`
compare_output "`run_printall build`" "build/.../static.c build/.../static.ramstage.o"
compare_output "`run_printall ../obj`" "$PARENTDIR/obj/.../static.c $PARENTDIR/obj/.../static.ramstage.o"
compare_output "`run_printall /tmp`" "/tmp/.../static.c /tmp/.../static.ramstage.o"
compare_output "`run_printall /../tmp`" "/tmp/.../static.c /tmp/.../static.ramstage.o"
compare_output "`run_printall build`" "build/.../static.c build/.../static.c build/.../static.ramstage.o build/.../static.romstage.o"
compare_output "`run_printall ../obj`" "$PARENTDIR/obj/.../static.c $PARENTDIR/obj/.../static.c $PARENTDIR/obj/.../static.ramstage.o $PARENTDIR/obj/.../static.romstage.o"
compare_output "`run_printall /tmp`" "/tmp/.../static.c /tmp/.../static.c /tmp/.../static.ramstage.o /tmp/.../static.romstage.o"
compare_output "`run_printall /../tmp`" "/tmp/.../static.c /tmp/.../static.c /tmp/.../static.ramstage.o /tmp/.../static.romstage.o"
rm -f $TMPCONFIG