From 1e1d196b5cdc5146c7b698965343a0ff68d00142 Mon Sep 17 00:00:00 2001 From: Mike Line Date: Wed, 10 Nov 2010 16:53:44 -0500 Subject: [PATCH] Updated make to handle single endian and dual endian The targets can be built with dual endian or in a single endian version. --- src/cfg/c6472/iblcfg.h | 14 +++++-- src/cfg/c6474/iblcfg.h | 23 ++++------ src/main/iblmain.c | 18 ++++++++ src/make/Makefile | 64 +++++++++++++++++++++++++--- src/make/ibl_c6472/i2crom.map.pre | 70 +++++++++++++++++++++++++++++++ src/make/makestg2 | 70 ++++++++++++++++++++++++++++--- src/util/i2cWrite/makestg2 | 4 +- src/util/romparse/romparse.c | 28 +++++++++++-- 8 files changed, 258 insertions(+), 33 deletions(-) create mode 100644 src/make/ibl_c6472/i2crom.map.pre diff --git a/src/cfg/c6472/iblcfg.h b/src/cfg/c6472/iblcfg.h index 8de9522..26f69d8 100644 --- a/src/cfg/c6472/iblcfg.h +++ b/src/cfg/c6472/iblcfg.h @@ -52,10 +52,18 @@ #define IBL_I2C_OWN_ADDR 10 #define IBL_I2C_CFG_ADDR_DELAY 0x100 /* Delay between sending the address and reading data */ -/* #define IBL_I2C_CFG_EEPROM_BUS_ADDR 0x50 */ -#define IBL_I2C_MAP_TABLE_DATA_BUS_ADDR 0x50 -#define IBL_I2C_MAP_TABLE_DATA_ADDR 0x420 +/** + * @brief The default location for the i2c map information can be overridden during make + */ +#ifndef IBL_I2C_MAP_TABLE_DATA_BUS_ADDR + #define IBL_I2C_MAP_TABLE_DATA_BUS_ADDR 0x50 +#endif + + +#ifndef IBL_I2C_MAP_TABLE_DATA_ADDR + #define IBL_I2C_MAP_TABLE_DATA_ADDR 0x420 +#endif diff --git a/src/cfg/c6474/iblcfg.h b/src/cfg/c6474/iblcfg.h index d75946a..2a9a6dc 100644 --- a/src/cfg/c6474/iblcfg.h +++ b/src/cfg/c6474/iblcfg.h @@ -51,25 +51,20 @@ #define IBL_I2C_OWN_ADDR 10 #define IBL_I2C_CFG_ADDR_DELAY 0x100 /* Delay between sending the address and reading data */ -#ifndef IBL_I2C_CFG_EEPROM_BUS_ADDR - #define IBL_I2C_CFG_EEPROM_BUS_ADDR 0x50 +/** + * @brief The default location for the i2c map information can be overridden during make + */ +#ifndef IBL_I2C_MAP_TABLE_DATA_BUS_ADDR + #define IBL_I2C_MAP_TABLE_DATA_BUS_ADDR 0x50 #endif -#define IBL_I2C_CFG_TABLE_DATA_ADDR (0x8000 - 0x300) + +#ifndef IBL_I2C_MAP_TABLE_DATA_ADDR + #define IBL_I2C_MAP_TABLE_DATA_ADDR 0x100 +#endif -/** - * @brief No NAND support. Define the function call to be a void statement - */ -#define iblNandBoot() - -/** - * @brief No Elf support - */ -#define iblIsElf(x) FALSE -#define iblBootElf(x,y) for (;;); - #endif diff --git a/src/main/iblmain.c b/src/main/iblmain.c index f112ee8..2bd7e48 100644 --- a/src/main/iblmain.c +++ b/src/main/iblmain.c @@ -123,13 +123,17 @@ void main (void) * statement is simply defined to be a void statement */ for (i = ibl_HIGHEST_PRIORITY; i < ibl_LOWEST_PRIORITY; i++) { +#ifndef EXCLUDE_ETH for (j = 0; j < ibl_N_ETH_PORTS; j++) { if (ibl.ethConfig[j].ethPriority == i) iblEthBoot (j); } +#endif +#ifndef EXCLUDE_NAND if (ibl.nandConfig.nandPriority == i) iblNandBoot (); +#endif iblStatus.heartBeat += 1; } @@ -172,14 +176,20 @@ Uint32 iblBoot (BOOT_MODULE_FXN_TABLE *bootFxn, Int32 dataFormat, void *formatPa (*bootFxn->peek)((Uint8 *)&fid, sizeof(fid)); /* BIS */ +#ifndef EXCLUDE_BIS if (fid.bisValue == BIS_MAGIC_NUMBER) dataFormat = ibl_BOOT_FORMAT_BIS; +#endif +#ifndef EXCLUDE_COFF if (iblIsCoff (fid.coffVer)) dataFormat = ibl_BOOT_FORMAT_COFF; +#endif +#ifndef EXCLUDE_ELF if (iblIsElf (fid.dataBuf)) dataFormat = ibl_BOOT_FORMAT_ELF; +#endif else { iblStatus.autoDetectFailCnt += 1; @@ -191,25 +201,33 @@ Uint32 iblBoot (BOOT_MODULE_FXN_TABLE *bootFxn, Int32 dataFormat, void *formatPa /* Invoke the parser */ switch (dataFormat) { +#ifndef EXCLUDE_BIS case ibl_BOOT_FORMAT_BIS: iblBootBis (bootFxn, &entry); break; +#endif +#ifndef EXCLUDE_COFF case ibl_BOOT_FORMAT_COFF: iblBootCoff (bootFxn, &entry); break; +#endif case ibl_BOOT_FORMAT_BTBL: iblBootBtbl (bootFxn, &entry); break; +#ifndef EXCLUDE_BLOB case ibl_BOOT_FORMAT_BBLOB: iblBootBlob (bootFxn, &entry, formatParams); break; +#endif +#ifndef EXCLUDE_ELF case ibl_BOOT_FORMAT_ELF: iblBootElf (bootFxn, &entry); break; +#endif default: iblStatus.invalidDataFormatSpec += 1; diff --git a/src/make/Makefile b/src/make/Makefile index fc7db5f..158284b 100644 --- a/src/make/Makefile +++ b/src/make/Makefile @@ -5,10 +5,66 @@ #* #* DESCRIPTION: Builds the Intermediate Boot Loader (IBL) #* +#* Usage: make c6455 | c6472 | c6474 | c6474l | c6457 [DEBUG=yes] [ETH=no] [NAND=no] \ +#* [BIS=no] [COFF=no] [BLOB=no] [ELF=no] [ENDIAN= both | big | little] [I2C_BUS_ADDR= 0x50 | 0x51] \ +#* [COMPACT_I2C=yes] #******************************************************************************************* IBLS_C6X= c6455 c6472 c6474 c6474l c6457 +# Excluding functions from the build reduces the I2C eeprom memory used and +# speeds the initial boot time. Note that boot table cannot be excluded +# because it is required for the two stage I2C load process + +EXCLUDES= + +ifeq ($(ETH),no) + EXCLUDES+= ETH +endif + +ifeq ($(NAND),no) + EXCLUDES+= NAND +endif + +ifeq ($(BIS),no) + EXCLUDES+= BIS +endif + +ifeq ($(COFF),no) + EXCLUDES+= COFF +endif + +ifeq ($(BLOB),no) + EXCLUDES+= BLOB +endif + +ifeq ($(ELF),no) + EXCLUDES+= ELF +endif + +export EXCLUDES + + + + +# The endian of the build. The default target builds a single ROM image with both endians present +ifeq ($(ENDIAN),big) + ENDIAN_MODE=big +else + ifeq ($(ENDIAN),little) + ENDIAN_MODE=little + else + ENDIAN_MODE=both + endif +endif + +# The i2c ROM bus address. The code will advance accross I2C bus address boundaries (the code must +# be blocked so that a single block doesn't cross a boundary, however). +ifndef I2C_BUS_ADDR + I2C_BUS_ADDR=0x50 +endif + + all: @echo must specify a target [ $(IBLS_C6X) ] @@ -21,12 +77,8 @@ endif export DEBUG - -$(IBLS_C6X): - make -f makestg2 ARCH=c64x TARGET=$@ ENDIAN=big $@ - make -f makestg2 ARCH=c64x TARGET=$@ ENDIAN=little $@ - make -f makestg2 ARCH=c64x TARGET=$@ compare - make -f makestg2 ARCH=c64x TARGET=$@ i2cRom +$(IBLS_C6X): + make -f makestg1 ARCH=c64x TARGET=$@ I2C_BUS_ADDR=$(I2C_BUS_ADDR) COMPACT=$(COMPACT) ENDIAN_MODE=$(ENDIAN_MODE) $@ # will need to add a line for each additional ARCH type added diff --git a/src/make/ibl_c6472/i2crom.map.pre b/src/make/ibl_c6472/i2crom.map.pre new file mode 100644 index 0000000..0d15177 --- /dev/null +++ b/src/make/ibl_c6472/i2crom.map.pre @@ -0,0 +1,70 @@ +#include "iblcfg.h" +; This file is run through the C preprocessor to get the build time layout information +; The following values must be defined: +; I2C_BUS_ADDR - The I2C bus address of the eeprom holding the ROM boot info and the layout info +; INIT_EXE_FILE - The I2C blocked stage 1 of the ibl +; EXE_FILE_1 - The I2C blocked stage 2 of the ibl, must be the little endian version +; EXE_FILE_2 - The I2C blocked stage 2 of the ibl, must be the big endian version +; PAD_FILE_ID_1 - This pad holds the IBL configuration structure for the little endian version +; PAD_FILE_ID_2 - This pad holds the IBL configuration structure for the big endian version +; +; The section statement directs the ROM boot loader to load the initial endian independent +; portion of the IBL +section +{ + param_index = 0 + boot_mode = 257 + sw_pll = 25 + options = 1 + + core_freq_mhz = 625 + i2c_clk_freq_khz = 200 + + dev_addr_ext = I2C_BUS_ADDR + + multi_i2c_id = 0 + my_i2c_id = 1 + address_delay = 0 + exe_file = INIT_EXE_FILE +} + +; The layout statement defines how the resulting I2C image is layed out. The base address +; of this (given in the dev_addr) statement must be known to the initial IBL program +; at compile time. The layout block is simple a group of 32 bit i2c addresses, so +; the order of the exe_file and pad_file_id statements must be configured so as to +; match the definition of struct iblI2cMap_t defined in ibl.h. +layout +{ + dev_addr = IBL_I2C_MAP_TABLE_DATA_ADDR ; Defined in iblcfg.h + dev_addr_ext = I2C_BUS_ADDR + file_align = 0x80 + + exe_file = EXE_FILE_1 + pad_file_id = PAD_FILE_ID_1 + + + exe_file = EXE_FILE_2 + pad_file_id = PAD_FILE_ID_2 +} + +; The pad statements simply provide space for the IBL configuration structures. It is valid to +; have a single configuration structure which is used for both endian values. +pad +{ + pad_file_id = 1 + dev_addr = 0x500 + len = 0x300 +} + +#if (PAD_FILE_ID_1 != PAD_FILE_ID_2) +pad +{ + pad_file_id = 2 + dev_addr = 0x800 + len = 0x300 +} +#endif + + + + diff --git a/src/make/makestg2 b/src/make/makestg2 index f2f196d..f675cca 100644 --- a/src/make/makestg2 +++ b/src/make/makestg2 @@ -11,11 +11,24 @@ ifndef IBL_ROOT IBL_ROOT=.. endif -MODULES= main device ethboot nandboot driver hw interp ecc +MAIN_MODULE= main +MODULES= device ethboot nandboot driver hw interp ecc + CLEAN_MODULES=$(addprefix clean_,$(MODULES)) +CLEAN_MODULES+=$(addprefix clean,$(MAIN_MODULE)) + TARGETS= c6472 c6474 c6474l c6455 c6457 +# The main module needs to know the device address of the i2c where the image map resides +MAINDEFS=-DIBL_I2C_MAP_TABLE_DATA_BUS_ADDR=$(I2C_BUS_ADDR) + +# Add build time exclusion definitions +MAINDEFS+=$(addprefix -DEXCLUDE_,$(EXCLUDES)) + + +# Common symbols are functions which are loaded with the stage load of the IBL, and +# also referenced from the second stage COMMON_SYMBOLS= hwI2Cinit hwI2cMasterRead iblBootBtbl iblMalloc iblFree iblMemset iblMemcpy ifeq ($(ENDIAN),little) @@ -39,12 +52,53 @@ export TARGET $(TARGETS): iblMain + + +# The I2C creation options. The I2C map file is run through the C pre-processor to generate +# the desired I2C mapping. There are three possible configurations - an i2c which has +# both endians present, or an I2C with only one of the endians + +I2C_BE_FILE= '"ibl_$(TARGET)/ibl.i2c.be.ccs"' +I2C_LE_FILE= '"ibl_$(TARGET)/ibl.i2c.le.ccs"' +I2C_INIT_BE_FILE= '"ibl_$(TARGET)/ibl_init.i2c.be.ccs"' +I2C_INIT_LE_FILE= '"ibl_$(TARGET)/ibl_init.i2c.le.ccs"' + +I2C_DEFS= -DI2C_BUS_ADDR=$(I2C_BUS_ADDR) + +ifeq ($(I2CROM),both) + I2C_DEFS+= -DINIT_EXE_FILE=$(I2C_INIT_LE_FILE) + I2C_DEFS+= -DEXE_FILE_1=$(I2C_LE_FILE) + I2C_DEFS+= -DPAD_FILE_ID_1=1 + I2C_DEFS+= -DEXE_FILE_2=$(I2C_BE_FILE) + I2C_DEFS+= -DPAD_FILE_ID_2=2 +else + I2C_DEFS+= -DPAD_FILE_ID_1=1 + I2C_DEFS+= -DPAD_FILE_ID_2=1 + + ifeq ($(I2CROM),little_endian) + I2C_DEFS+= -DINIT_EXE_FILE=$(I2C_INIT_LE_FILE) + I2C_DEFS+= -DEXE_FILE_1=$(I2C_LE_FILE) + I2C_DEFS+= -DEXE_FILE_2='""' + else + I2C_DEFS+= -DINIT_EXE_FILE=$(I2C_INIT_BE_FILE) + I2C_DEFS+= -DEXE_FILE_1='""' + I2C_DEFS+= -DEXE_FILE_2=$(I2C_BE_FILE) + endif +endif + + i2cRom: - ../util/romparse/romparse $(COMPACT) ibl_$(TARGET)/i2crom.map - $(CP) i2crom.ccs ibl_$(TARGET)/i2crom.ccs - $(CP) i2crom.ccs ibl_$(TARGET)/i2crom.dat + cl6x -ppo -I../cfg/$(TARGET) $(I2C_DEFS) ibl_$(TARGET)/$@.map.pre + ../util/romparse/romparse $(COMPACT) ibl_$(TARGET)/$@.map.pp + $(CP) i2crom.ccs ibl_$(TARGET)/$@.ccs + $(CP) i2crom.ccs ibl_$(TARGET)/$@.dat $(RM) i2crom.ccs ibl_le.b ibl.b + + + + + # Target compare checks if the iblInit is compiled the same for both endians compare: @echo - @@ -54,7 +108,7 @@ compare: # For the init code a raw image is created as well as the i2c code to verify # endian independent code is generated. The symbols required for linking # the full application are then extracted -iblInit: $(MODULES) utils +iblInit: $(MAIN_MODULE) $(MODULES) utils cat ibl_$(TARGET)/ibl_init_objs_template.inc | sed -e s/ENDIAN_TAG/$(IEXT)/g > ibl_$(TARGET)/ibl_init_objs.inc $(LD) -o ibl_$(TARGET)/ibl_$(TARGET)_init.out -m ibl_$(TARGET)/ibl_$(TARGET)_init.map ibl_$(TARGET)/ibl_init.cmd $(RTLIBS) cp ibl_$(TARGET)/ibl_$(TARGET)_init.out ibl_$(TARGET)/ibl_$(TARGET)_init.$(IEXT).out @@ -73,7 +127,7 @@ iblInit: $(MODULES) utils bash ../util/symExtract/symExtract ibl_$(TARGET)/ibl_$(TARGET)_init.map ibl_$(TARGET)/ibl_init_symbols.inc $(COMMON_SYMBOLS) -iblMain: iblInit $(MODULES) +iblMain: iblInit $(MAIN_MODULE) $(MODULES) cat ibl_$(TARGET)/ibl_objs_template.inc | sed -e s/ENDIAN_TAG/$(IEXT)/g > ibl_$(TARGET)/ibl_objs.inc $(LD) -o ibl_$(TARGET)/ibl_$(TARGET).out -m ibl_$(TARGET)/ibl_$(TARGET).$(IEXT).map ibl_$(TARGET)/ibl.cmd $(RTLIBS) cp ibl_$(TARGET)/ibl_$(TARGET).out ibl_$(TARGET)/ibl_$(TARGET).$(IEXT).out @@ -90,6 +144,10 @@ $(MODULES): @echo making $@ make -C $(IBL_ROOT)/$@/$(ARCH)/make $@ +$(MAIN_MODULE): + @echo making $@ + make -C $(IBL_ROOT)/$@/$(ARCH)/make CDEFS=$(MAINDEFS) $@ + utils: make -C $(IBL_ROOT)/util/btoccs make -C $(IBL_ROOT)/util/romparse TARGET=$(TARGET) diff --git a/src/util/i2cWrite/makestg2 b/src/util/i2cWrite/makestg2 index 4a5cf50..6394b7e 100644 --- a/src/util/i2cWrite/makestg2 +++ b/src/util/i2cWrite/makestg2 @@ -43,6 +43,8 @@ export C6X_C_DIR export ARCH export TARGET + + $(DEVICES): gen_cdefdep $(MODULES) $(OBJS) i2cWrite.cmd $(LD) -o i2cWrite_$(IEXT).out -m i2cWrite_$(IEXT).map i2cWrite.$(IEXT).oc ../../hw/c64x/make/i2c.$(IEXT).oc ../../hw/c64x/make/pll.$(IEXT).oc i2cWrite.cmd $(RTLIBS) @@ -65,6 +67,6 @@ $(OBJS): cdefdep gen_cdefdep: @echo Checking command line dependencies - @echo $(ARCH) > cdefdep.tmp + @echo $(ARCH) $(TARGET) > cdefdep.tmp @sh -c 'if diff -q cdefdep.tmp cdefdep ; then echo same ; else $(CP) cdefdep.tmp cdefdep ; fi ' diff --git a/src/util/romparse/romparse.c b/src/util/romparse/romparse.c index 087cf8b..af925c2 100644 --- a/src/util/romparse/romparse.c +++ b/src/util/romparse/romparse.c @@ -532,6 +532,24 @@ void assignKeyStr (int value, char *y) int i; char *z; + /* The special case of a 0 (plus the quotes) length string means an empty entry for a layout */ + if (strlen(y) == 2) { + + if (currentType == LAYOUT) { + if (layouts[currentLayout].nPlt <= MAX_LAYOUT_FILES) { + layouts[currentLayout].plt[layouts[currentLayout].nPlt].type = PLT_FILE; + layouts[currentLayout].plt[layouts[currentLayout].nPlt].index = -1; + layouts[currentLayout].nPlt += 1; + + } else { + fprintf (stderr, "romparse: line %d: Max number (%d) of layout specification exceeded\n", line, MAX_LAYOUT_FILES); + } + } else + fprintf (stderr, "romparse: Number of layout sections exceeded (max = %d)\n", MAX_LAYOUTS); + + return; + } + /* the input string still contains the quotes. Remove them here */ z = &y[1]; @@ -829,9 +847,13 @@ void createOutput (void) for (j = 0; j < layouts[i].nPlt; j++) { - if (layouts[i].plt[j].type == PLT_FILE) - base = imageWord (base, image, progFile[layouts[i].plt[j].index].addressBytes); - else { + if (layouts[i].plt[j].type == PLT_FILE) { + if (layouts[i].plt[j].index == -1) { + base = imageWord (base, image, 0xffffffff); + } else { + base = imageWord (base, image, progFile[layouts[i].plt[j].index].addressBytes); + } + } else { v1 = pads[layouts[i].plt[j].index].dev_addr; v2 = pads[layouts[i].plt[j].index].address; base = imageWord (base, image, (v1 << 16) + v2); -- 2.39.2