]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/sbl.git/commitdiff
CATREQ-1707: Added OMAPL137 support for SBL
authorPratap Reddy <x0257344@ti.com>
Tue, 7 Mar 2017 22:34:37 +0000 (04:04 +0530)
committerPratap Reddy <x0257344@ti.com>
Mon, 5 Jun 2017 14:09:08 +0000 (19:39 +0530)
CATREQ-1707: Updated flash writer to support OMAPL137

Removed hard-coded PDK path variable

CATREQ-1707: Initial version of OMAPL13x boot utils source code

CATREQ-1707: Updated the OMAPL137 SBL memory allocation and build options

CATREQ-1707: Updated SDRAM/EMIF configurations

 - Added pinmux for EMIF
 - Disabled SDRAM initialization in ROM configurations
 - Removed AISGen folder as it is avaialble in omapl13x_boot_utils folder

CATREQ-1707: Removed binary files

PRSDK-2281: Added C6748 SBL

PRSDK-2281: Added MMCSD flash writer for C6748

CATREQ-1707: Changed the permissions of OMAPL13x boot scripts to executable

PRSDK-2281: Added code for C6748 AISGen tool

123 files changed:
board/evmOMAPL137/build/makefile [new file with mode: 0644]
board/evmOMAPL137/sbl_main.c [new file with mode: 0644]
board/lcdkC6748/build/makefile [new file with mode: 0644]
board/lcdkC6748/sbl_main.c [new file with mode: 0644]
build/sbl_c6748.sh [new file with mode: 0755]
build/sbl_omapl137.sh [new file with mode: 0755]
makefile
soc/c6748/c6748.cfg [new file with mode: 0644]
soc/c6748/linker.cmd [new file with mode: 0644]
soc/c6748/sbl_slave_boot.c [new file with mode: 0644]
soc/c6748/sbl_slave_core_boot.h [new file with mode: 0644]
soc/c6748/sbl_soc.c [new file with mode: 0644]
soc/omapl137/linker.cmd [new file with mode: 0644]
soc/omapl137/omapl137.ini [new file with mode: 0644]
soc/omapl137/sbl_slave_boot.c [new file with mode: 0644]
soc/omapl137/sbl_slave_core_boot.h [new file with mode: 0644]
soc/omapl137/sbl_soc.c [new file with mode: 0644]
src/rprc/sbl_rprc.c
tools/flashWriter/mmcsd/bin/lcdkOMAPL138/config [new file with mode: 0644]
tools/flashWriter/mmcsd/src/c67x.cmd [new file with mode: 0644]
tools/flashWriter/mmcsd/src/makefile [new file with mode: 0644]
tools/flashWriter/mmcsd/src/sbl_mmcsd_writer.c [new file with mode: 0644]
tools/flashWriter/spi/bin/evmOMAPL137/config [new file with mode: 0644]
tools/flashWriter/spi/src/c67x.cmd [new file with mode: 0644]
tools/flashWriter/spi/src/makefile
tools/flashWriter/spi/src/sbl_spi_writer.c
tools/omapl13x_boot_utils/CREDITS [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/AIS/AIS.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/AIS/AISGen.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/AIS/AISParse.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/AIS/HexAIS_version.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/UtilLib/ASN1.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/UtilLib/BinaryFile.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/UtilLib/CRC.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/UtilLib/CoffFile.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/UtilLib/ConsoleUtility.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/UtilLib/CryptoLoadMod.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/UtilLib/CryptoUtility.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/UtilLib/Debug.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/UtilLib/ECC.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/UtilLib/ElfFile.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/UtilLib/EmbeddedFileIO.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/UtilLib/Endian.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/UtilLib/FileIO.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/UtilLib/HexConv.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/UtilLib/Ini.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/UtilLib/ObjectFile.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/UtilLib/SRecord.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/UtilLib/SerialIO.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/build.mak [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/include/tistdtypes.h [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/include/util.h [new file with mode: 0644]
tools/omapl13x_boot_utils/Common/ti.ico [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/Common/include/device.h [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/Common/include/device_async_mem.h [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/Common/include/device_nand.h [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/Common/include/device_spi.h [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/Common/include/device_uart.h [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/Common/include/tps65023.h [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/Common/src/device_name.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/AISextra/makefile [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/AISextra/src/ARM_AISExtra.lds [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/AISextra/src/DSP_AISExtra.cmd [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/AISextra/src/aisextra.c [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/AISextra/src/makefile [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/HexAIS/HexAIS.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/HexAIS/makefile [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/HexAIS_OMAP-L137.exe [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/OMAP-L137-uart.ini [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/OMAP-L137.ini [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/makefile [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/readme.txt [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/GNU/Common/AISGenLib/AISGen_OMAP-L137.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/GNU/makefile [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/device.mak [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L137/makefile [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/Common/include/device.h [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/Common/include/device_async_mem.h [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/Common/include/device_nand.h [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/Common/include/device_sdmmc.h [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/Common/include/device_spi.h [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/Common/include/device_uart.h [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/Common/include/tps65070.h [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/Common/src/device_name.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/AISGen.csproj [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/AISGen_GUI.sln [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/AboutForm.Designer.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/AboutForm.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/AboutForm.resx [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/BootMode.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/BootOptions.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/Consts.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/MainForm.Designer.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/MainForm.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/MainForm.resx [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/ParamError.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/Program.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/Properties/Resources.Designer.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/Properties/Resources.resx [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/Properties/Settings.Designer.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/Properties/Settings.settings [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/README.txt [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/Settings.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/makefile [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISextra/makefile [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISextra/src/ARM_AISExtra.lds [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISextra/src/DSP_AISExtra.cmd [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISextra/src/aisextra.c [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISextra/src/makefile [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISgen.exe [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/NAND_ECC_Patch/makefile [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/NAND_ECC_Patch/src/ARM.cmd [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/NAND_ECC_Patch/src/ARM.lds [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/NAND_ECC_Patch/src/DSP.cmd [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/NAND_ECC_Patch/src/makefile [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/NAND_ECC_Patch/src/nand_ecc_patch.c [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/makefile [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/readme.txt [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/Common/AISGenLib/AISGen_OMAP-L138.cs [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/GNU/makefile [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/device.mak [new file with mode: 0644]
tools/omapl13x_boot_utils/OMAP-L138/makefile [new file with mode: 0644]
tools/omapl13x_sd_card_format/create-sdcard-omapl13x.sh [new file with mode: 0644]

diff --git a/board/evmOMAPL137/build/makefile b/board/evmOMAPL137/build/makefile
new file mode 100644 (file)
index 0000000..0738fdc
--- /dev/null
@@ -0,0 +1,137 @@
+# Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+#
+#
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions
+#  are met:
+#
+#    Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+#
+#    Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the
+#    distribution.
+#
+#    Neither the name of Texas Instruments Incorporated nor the names of
+#    its contributors may be used to endorse or promote products derived
+#    from this software without specific prior written permission.
+#
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#
+# Macro definitions referenced below
+#
+
+SBL_SRC_DIR ?= $(PDK_INSTALL_PATH)/ti/boot/sbl
+SBLOBJDIR = $(SBL_SRC_DIR)/binary/$(BOARD)/$(BOOTMODE)/obj
+SBLBINDIR = $(SBL_SRC_DIR)/binary/$(BOARD)/$(BOOTMODE)/bin
+ARMV7LIBDIR ?= ./lib
+BINFLAGS = -O binary
+
+#Cross tools
+CC = $(C6X_GEN_INSTALL_PATH)/bin/cl6x
+
+# INCLUDE Directories
+CSL_DIR = $(PDK_INSTALL_PATH)/ti/csl
+BOARD_DIR = $(PDK_INSTALL_PATH)/ti/board
+SBL_INC_DIR = $(SBL_SRC_DIR)/board/src
+SBL_LIB_INC_DIR = $(SBL_SRC_DIR)/src/rprc
+SBL_SOC_DIR = $(SBL_SRC_DIR)/soc
+
+# Libraries
+BOARD_LIB = "$(PDK_INSTALL_PATH)/ti/board/lib/$(BOARD)/c674/release/ti.board.ae674"
+UART_LIB = "$(PDK_INSTALL_PATH)/ti/drv/uart/lib/omapl137/c674/release/ti.drv.uart.ae674"
+I2C_LIB = "$(PDK_INSTALL_PATH)/ti/drv/i2c/lib/omapl137/c674/release/ti.drv.i2c.ae674"
+SPI_LIB = "$(PDK_INSTALL_PATH)/ti/drv/spi/lib/omapl137/c674/release/ti.drv.spi.ae674"
+CSL_LIB = "$(PDK_INSTALL_PATH)/ti/csl/lib/omapl137/c674/release/ti.csl.ae674"
+CSL_INTC_LIB = "$(PDK_INSTALL_PATH)/ti/csl/lib/omapl137/c674/release/ti.csl.intc.ae674"
+OSAL_LIB = "$(PDK_INSTALL_PATH)/ti/osal/lib/nonos/omapl137/c674/release/ti.osal.ae674"
+RTSLIB_PATH = "$(C6X_GEN_INSTALL_PATH)/lib/libc.a"
+
+ifeq ($(BOOTMODE), spi)
+  INTERNALDEFS += -DBOOT_SPI
+  SBL_SPI_DIR = $(SBL_SRC_DIR)/src/spi
+  INCDIR := $(CSL_DIR);$(PDK_INSTALL_PATH);$(BOARD_DIR);$(SBL_INC_DIR);$(SBL_LIB_INC_DIR);$(SBL_SPI_DIR);$(SBL_SOC_DIR);$(SBL_SOC_DIR)/omapl137;$(C6X_GEN_INSTALL_PATH)/include
+  PERIPHERAL_LIB = $(UART_LIB) $(I2C_LIB) $(CSL_LIB) $(SPI_LIB) $(BOARD_LIB) $(OSAL_LIB) $(CSL_INTC_LIB)
+endif
+
+# Compiler options
+INTERNALDEFS += -mv64+ --abi=eabi -g --display_error_number --diag_warning=225 -g -DSOC_$(SOC) -DEVM_$(SOC) -D$(SOC)_BUILD
+
+# Linker options
+INTERNALLINKDEFS = -mv64+ -g --diag_wrap=off --diag_warning=225 --display_error_number -z $(SBL_SOC_DIR)/omapl137/linker.cmd
+
+# Executable using device independent library and device object file
+EXE=sbl.out
+
+OBJEXT = o
+ASMOBJEXT = ao
+SRCDIR = $(SBL_SRC_DIR)/board
+
+INCS = -I. -I$(strip $(subst ;, -I,$(INCDIR)))
+
+VPATH=$(SRCDIR):$(SRCDIR)/$(BOARD):$(SBL_SRC_DIR)/board/src:$(SBL_SRC_DIR)/soc/omapl137:$(PDK_INSTALL_PATH)/ti/drv/uart/soc/omapl137:$(SBL_SRC_DIR)/src/$(BOOTMODE):$(SBL_SRC_DIR)/src/rprc:$(PDK_INSTALL_PATH)/ti/drv/spi/soc/omapl137
+
+#List the Source Files
+SRC_C = \
+       sbl_main.c \
+    sbl_rprc.c \
+       sbl_spi.c
+
+SRC_DRV = \
+    sbl_soc.c \
+    sbl_slave_boot.c \
+    SPI_soc.c
+
+#Common entry object
+ENTRY_SRC =
+
+# FLAGS for the SourceFiles
+CFLAGS += 
+SRC_CFLAGS = -I. $(CFLAGS) -eo.$(OBJEXT) -ea.$(ASMOBJEXT) -g
+
+# Make Rule for the SRC Files
+SRC_OBJS = $(patsubst %.c, $(SBLOBJDIR)/%.$(OBJEXT), $(SRC_C))
+ENTRY_OBJ = $(patsubst %.asm, $(SBLOBJDIR)/%.$(ASMOBJEXT), $(ENTRY_SRC))
+SRC_DRV_OBJS = $(patsubst %.c, $(SBLOBJDIR)/%.$(OBJEXT), $(SRC_DRV))
+
+all:$(SBLBINDIR)/$(EXE) MLO
+
+MLO: $(SBLBINDIR)/$(EXE)
+       $(SBL_SRC_DIR)/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/HexAIS_OMAP-L137.exe -o $(SBLBINDIR)/MLO -ini $(SBL_SOC_DIR)/omapl137/omapl137.ini $(SBLBINDIR)/sbl.out;
+
+$(SBLBINDIR)/$(EXE): $(SRC_OBJS) $(SRC_DRV_OBJS) $(ENTRY_OBJ) $(SBLBINDIR)/.created $(SBLOBJDIR)/.created
+       @echo linking $(SRC_OBJS) $(SRC_DRV_OBJS) $(ENTRY_OBJ) into $@ ...
+       @$(CC) $(SRC_OBJS) $(SRC_DRV_OBJS) $(ENTRY_OBJ) $(INTERNALLINKDEFS) -m"$(SBLBINDIR)/sbl.map" --reread_libs --rom_model -o $@ $(PERIPHERAL_LIB) $(RTSLIB_PATH)
+
+$(SBLOBJDIR)/%.$(OBJEXT): %.c $(SBLOBJDIR)/.created
+       @echo compiling $< ...
+       @$(CC) -c $(SRC_CFLAGS) $(INTERNALDEFS) $(INCS) -fr=$(SBLOBJDIR) -fs=$(SBLOBJDIR) -fc $<
+
+$(SBLOBJDIR)/%.$(ASMOBJEXT): %.asm $(SBLOBJDIR)/.created
+       @echo compiling $< ...
+       @$(CC) -c $(INTERNALDEFS) $(INCS)  $< -o $@
+
+$(SBLOBJDIR)/.created:
+       @mkdir -p $(SBLOBJDIR)
+       @touch $(SBLOBJDIR)/.created
+
+$(SBLBINDIR)/.created:
+       @mkdir -p $(SBLBINDIR)
+       @touch $(SBLBINDIR)/.created
+
+clean:
+       @rm -f $(SBLBINDIR)/$(EXE)
+       @rm -f $(SRC_OBJS) $(SRC_DRV_OBJS) $(ENTRY_OBJ) $(SBLBINDIR)/.created $(SBLOBJDIR)/.created
+
diff --git a/board/evmOMAPL137/sbl_main.c b/board/evmOMAPL137/sbl_main.c
new file mode 100644 (file)
index 0000000..6121f8a
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <ti/board/board.h>
+#include <ti/drv/uart/UART_stdio.h>
+#include "sbl_soc.h"
+#include "sbl_slave_core_boot.h"
+
+sblEntryPoint_t entry;
+typedef void (*EntryFunPtr_t)(void);
+
+int main() {
+    void (*func_ptr)(void);
+    if (SBL_socInit() < 0)
+    {
+        /* Something went wrong with init, trap here */
+        while(1);
+    }
+
+    UART_printf("\n**** PDK SBL ****\n");
+    UART_printf("Boot succesful!\n");
+
+    UART_printf("Begin parsing user application\n");
+    SBL_ImageCopy(&entry);
+    UART_printf("Jumping to user application...\n");
+
+    if (entry.entryPoint_MPU_CPU0 != 0)
+    {
+        SBL_ARMBringUp(0, entry.entryPoint_MPU_CPU0);
+    }
+
+    /*Jump to DSP0 APP*/    
+    if (entry.entryPoint_DSP0 != 0)
+    {
+        func_ptr = (EntryFunPtr_t) entry.entryPoint_DSP0;
+        func_ptr();
+    }
+    else
+    {
+        while(1);
+    }
+
+    return 0;
+}
\ No newline at end of file
diff --git a/board/lcdkC6748/build/makefile b/board/lcdkC6748/build/makefile
new file mode 100644 (file)
index 0000000..a549407
--- /dev/null
@@ -0,0 +1,141 @@
+# Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+#
+#
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions
+#  are met:
+#
+#    Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+#
+#    Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the
+#    distribution.
+#
+#    Neither the name of Texas Instruments Incorporated nor the names of
+#    its contributors may be used to endorse or promote products derived
+#    from this software without specific prior written permission.
+#
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#
+# Macro definitions referenced below
+#
+
+SBL_SRC_DIR ?= $(PDK_INSTALL_PATH)/ti/boot/sbl
+SBLOBJDIR = $(SBL_SRC_DIR)/binary/$(BOARD)/$(BOOTMODE)/obj
+SBLBINDIR = $(SBL_SRC_DIR)/binary/$(BOARD)/$(BOOTMODE)/bin
+ARMV7LIBDIR ?= ./lib
+BINFLAGS = -O binary
+
+#Cross tools
+CC = $(C6X_GEN_INSTALL_PATH)/bin/cl6x
+
+# INCLUDE Directories
+CSL_DIR = $(PDK_INSTALL_PATH)/ti/csl
+BOARD_DIR = $(PDK_INSTALL_PATH)/ti/board
+SBL_INC_DIR = $(SBL_SRC_DIR)/board/src
+SBL_LIB_INC_DIR = $(SBL_SRC_DIR)/src/rprc
+SBL_SOC_DIR = $(SBL_SRC_DIR)/soc
+
+# Libraries
+BOARD_LIB = "$(PDK_INSTALL_PATH)/ti/board/lib/lcdkOMAPL138/c674/release/ti.board.ae674"
+UART_LIB = "$(PDK_INSTALL_PATH)/ti/drv/uart/lib/omapl138/c674/release/ti.drv.uart.ae674"
+I2C_LIB = "$(PDK_INSTALL_PATH)/ti/drv/i2c/lib/omapl138/c674/release/ti.drv.i2c.ae674"
+SPI_LIB = "$(PDK_INSTALL_PATH)/ti/drv/spi/lib/omapl138/c674/release/ti.drv.spi.ae674"
+MMCSD_LIB = "$(PDK_INSTALL_PATH)/ti/drv/mmcsd/lib/omapl138/c674/release/ti.drv.mmcsd.ae674"
+FATFS_LIB = "$(PDK_INSTALL_PATH)/ti/fs/fatfs/lib/c674/release/ti.fs.fatfs.ae674"
+CSL_LIB = "$(PDK_INSTALL_PATH)/ti/csl/lib/omapl138/c674/release/ti.csl.ae674"
+CSL_INTC_LIB = "$(PDK_INSTALL_PATH)/ti/csl/lib/omapl138/c674/release/ti.csl.intc.ae674"
+OSAL_LIB = "$(PDK_INSTALL_PATH)/ti/osal/lib/nonos/omapl138/c674/release/ti.osal.ae674"
+RTSLIB_PATH = "$(C6X_GEN_INSTALL_PATH)/lib/libc.a"
+
+ifeq ($(BOOTMODE), mmcsd)
+  INTERNALDEFS += -DBOOT_MMCSD
+  SBL_MMCSD_DIR = $(SBL_SRC_DIR)/src/mmcsd
+  INCDIR := $(CSL_DIR);$(PDK_INSTALL_PATH);$(BOARD_DIR);$(SBL_INC_DIR);$(SBL_LIB_INC_DIR);$(SBL_MMCSD_DIR);$(SBL_SOC_DIR);$(SBL_SOC_DIR)/c6748;$(C6X_GEN_INSTALL_PATH)/include
+  PERIPHERAL_LIB = $(UART_LIB) $(I2C_LIB) $(FATFS_LIB) $(MMCSD_LIB) $(CSL_LIB) $(SPI_LIB) $(BOARD_LIB) $(OSAL_LIB) $(CSL_INTC_LIB)
+endif
+
+# Compiler options
+INTERNALDEFS += -mv64+ --abi=eabi -g --display_error_number --diag_warning=225 -g -DSOC_OMAPL138 -DSOC_C6748 -DEVM_$(SOC) -D$(SOC)_BUILD
+
+# Linker options
+INTERNALLINKDEFS = -mv64+ -g --diag_wrap=off --diag_warning=225 --display_error_number -z $(SBL_SOC_DIR)/c6748/linker.cmd
+
+# Executable using device independent library and device object file
+EXE=sbl.out
+
+OBJEXT = o
+ASMOBJEXT = ao
+SRCDIR = $(SBL_SRC_DIR)/board
+
+INCS = -I. -I$(strip $(subst ;, -I,$(INCDIR)))
+
+VPATH=$(SRCDIR):$(SRCDIR)/$(BOARD):$(SBL_SRC_DIR)/board/src:$(SBL_SRC_DIR)/soc/c6748:$(PDK_INSTALL_PATH)/ti/drv/uart/soc/omapl138:$(SBL_SRC_DIR)/src/$(BOOTMODE):$(SBL_SRC_DIR)/src/rprc:$(PDK_INSTALL_PATH)/ti/drv/spi/soc/omapl138
+
+#List the Source Files
+SRC_C = \
+       sbl_main.c \
+    sbl_rprc.c \
+    sbl_mmcsd.c
+
+SRC_DRV = \
+    sbl_soc.c \
+    sbl_slave_boot.c
+
+#Common entry object
+ENTRY_SRC =
+
+# FLAGS for the SourceFiles
+CFLAGS += 
+SRC_CFLAGS = -I. $(CFLAGS) -eo.$(OBJEXT) -ea.$(ASMOBJEXT) -g
+
+# Make Rule for the SRC Files
+SRC_OBJS = $(patsubst %.c, $(SBLOBJDIR)/%.$(OBJEXT), $(SRC_C))
+ENTRY_OBJ = $(patsubst %.asm, $(SBLOBJDIR)/%.$(ASMOBJEXT), $(ENTRY_SRC))
+SRC_DRV_OBJS = $(patsubst %.c, $(SBLOBJDIR)/%.$(OBJEXT), $(SRC_DRV))
+
+all:$(SBLBINDIR)/$(EXE) MLO
+
+MLO: $(SBLBINDIR)/$(EXE)
+       @cp -f $(SBL_SOC_DIR)/c6748/c6748.cfg $(SBL_SOC_DIR)/c6748/c6748_temp.cfg
+       @echo App File String=$(SBLBINDIR)/sbl.out >> $(SBL_SOC_DIR)/c6748/c6748_temp.cfg
+       @echo AIS File Name=$(SBLBINDIR)/MLO >> $(SBL_SOC_DIR)/c6748/c6748_temp.cfg
+       $(SBL_SRC_DIR)/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISgen.exe -cfg=$(SBL_SOC_DIR)/c6748/c6748_temp.cfg
+
+$(SBLBINDIR)/$(EXE): $(SRC_OBJS) $(SRC_DRV_OBJS) $(ENTRY_OBJ) $(SBLBINDIR)/.created $(SBLOBJDIR)/.created
+       @echo linking $(SRC_OBJS) $(SRC_DRV_OBJS) $(ENTRY_OBJ) into $@ ...
+       @$(CC) $(SRC_OBJS) $(SRC_DRV_OBJS) $(ENTRY_OBJ) $(INTERNALLINKDEFS) -m"$(SBLBINDIR)/sbl.map" --reread_libs --rom_model -o $@ $(PERIPHERAL_LIB) $(RTSLIB_PATH)
+
+$(SBLOBJDIR)/%.$(OBJEXT): %.c $(SBLOBJDIR)/.created
+       @echo compiling $< ...
+       @$(CC) -c $(SRC_CFLAGS) $(INTERNALDEFS) $(INCS) -fr=$(SBLOBJDIR) -fs=$(SBLOBJDIR) -fc $<
+
+$(SBLOBJDIR)/%.$(ASMOBJEXT): %.asm $(SBLOBJDIR)/.created
+       @echo compiling $< ...
+       @$(CC) -c $(INTERNALDEFS) $(INCS)  $< -o $@
+
+$(SBLOBJDIR)/.created:
+       @mkdir -p $(SBLOBJDIR)
+       @touch $(SBLOBJDIR)/.created
+
+$(SBLBINDIR)/.created:
+       @mkdir -p $(SBLBINDIR)
+       @touch $(SBLBINDIR)/.created
+
+clean:
+       @rm -f $(SBLBINDIR)/$(EXE)
+       @rm -f $(SRC_OBJS) $(SRC_DRV_OBJS) $(ENTRY_OBJ) $(SBLBINDIR)/.created $(SBLOBJDIR)/.created
+
diff --git a/board/lcdkC6748/sbl_main.c b/board/lcdkC6748/sbl_main.c
new file mode 100644 (file)
index 0000000..fe42a27
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <ti/board/board.h>
+#include <ti/drv/uart/UART_stdio.h>
+#include "sbl_soc.h"
+#include "sbl_slave_core_boot.h"
+
+sblEntryPoint_t entry;
+typedef void (*EntryFunPtr_t)(void);
+
+int main() {
+    void (*func_ptr)(void);
+    int32_t retval = 0;
+
+    if (SBL_socInit() < 0)
+    {
+        /* Something went wrong with init, trap here */
+        while(1);
+    }
+
+    UART_printf("\n**** PDK SBL ****\n");
+    UART_printf("Boot succesful!\n");
+
+    UART_printf("Begin parsing user application\n");
+    retval = SBL_ImageCopy(&entry);
+    if(retval)
+    {
+        UART_printf("Error while copying the images\n");
+        while(1); /*  Error case. No need to proceed */
+    }
+    
+    UART_printf("Jumping to user application...\n");
+
+    /*Jump to DSP0 APP*/    
+    if (entry.entryPoint_DSP0 != 0)
+    {
+        func_ptr = (EntryFunPtr_t) entry.entryPoint_DSP0;
+        func_ptr();
+    }
+    else
+    {
+        while(1);
+    }
+
+    return 0;
+}
diff --git a/build/sbl_c6748.sh b/build/sbl_c6748.sh
new file mode 100755 (executable)
index 0000000..3989003
--- /dev/null
@@ -0,0 +1,18 @@
+# Go to PDK SBL root directory
+cd ..
+
+#build instructions for bootloader
+
+ls
+make clean BOARD=lcdkC6748
+make mmcsd_flashwriter_clean BOARD=lcdkC6748
+
+
+make all BOARD=lcdkC6748 SOC=C6748 BOOTMODE=mmcsd
+make mmcsd_flashwriter BOARD=lcdkC6748 SOC=C6748
+
+# removes the object files
+rm -rf binary/lcdkC6748/mmcsd/obj/
+
+#archive
+tar -cf sbl.tar --exclude='*.tar' --exclude='*.git*' ./*
diff --git a/build/sbl_omapl137.sh b/build/sbl_omapl137.sh
new file mode 100755 (executable)
index 0000000..870f496
--- /dev/null
@@ -0,0 +1,18 @@
+# Go to PDK SBL root directory
+cd ..
+
+#build instructions for bootloader
+
+ls
+make clean BOARD=evmOMAPL137
+make spi_flashwriter_clean BOARD=evmOMAPL137
+
+
+make all BOARD=evmOMAPL137 SOC=OMAPL137 BOOTMODE=spi
+make spi_flashwriter BOARD=evmOMAPL137 SOC=OMAPL137
+
+# removes the object files
+rm -rf binary/evmOMAPL137/spi/obj/
+
+#archive
+tar -cf sbl.tar --exclude='*.tar' --exclude='*.git*' ./*
index ccff201056065823c9ac8281a69aacd3b7dc2994..b1ee9a975676d5ab0a3405fd25920137c146b1c1 100644 (file)
--- a/makefile
+++ b/makefile
@@ -58,7 +58,7 @@ export MAKE = make
 endif
 
 # PHONY Targets
-.PHONY: all clean spi_flashwriter spi_flashwriter_clean flashwriter flashwriter_clean example example_clean tools
+.PHONY: all clean spi_flashwriter spi_flashwriter_clean flashwriter flashwriter_clean mmcsd_flashwriter mmcsd_flashwriter_clean example example_clean tools
 
 # all rule
 all:
@@ -70,6 +70,9 @@ spi_flashwriter:
 flashwriter:
        @$(MAKE) -f ./tools/flashWriter/qspi/src/makefile $@
 
+mmcsd_flashwriter:
+       @$(MAKE) -f ./tools/flashWriter/mmcsd/src/makefile $@
+
 example:
        @$(MAKE) -f ./example/mpuMulticoreApp/makefile $@
        @$(MAKE) -f ./example/dsp1MulticoreApp/makefile $@
@@ -98,6 +101,9 @@ flashwriter_clean:
        @$(MAKE) -f ./tools/flashWriter/qspi/src/makefile $@
        @$(RMDIR) $(PDK_INSTALL_PATH)/ti/boot/sbl/tools/flashWriter/qspi/bin/$(BOARD)
 
+mmcsd_flashwriter_clean:
+       @$(MAKE) -f ./tools/flashWriter/mmcsd/src/makefile $@
+
 example_clean:
        @$(MAKE) -f ./example/mpuMulticoreApp/makefile $@
        @$(MAKE) -f ./example/dsp1MulticoreApp/makefile $@
diff --git a/soc/c6748/c6748.cfg b/soc/c6748/c6748.cfg
new file mode 100644 (file)
index 0000000..eac8220
--- /dev/null
@@ -0,0 +1,50 @@
+Boot Mode=MMC/SD0
+Boot Speed=20
+Flash Width=0
+Flash Timing=3ffffffc
+Configure Peripheral=True
+Configure PLL0=True
+Configure SDRAM=False
+Configure PLL1=True
+Configure DDR2=True
+Configure LPSC=True
+Configure Pinmux=False
+Enable CRC=False
+Specify Entrypoint=False
+Enable Sequential Read=False
+Use 4.5 Clock Divider=False
+Use DDR2 Direct Clock=False
+Use mDDR=False
+ROM ID=3
+Device Type=1
+Input Clock Speed=24
+Clock Type=0
+PLL0 Pre Divider=1
+PLL0 Multiplier=25
+PLL0 Post Divider=2
+PLL0 Div1=1
+PLL0 Div3=3
+PLL0 Div7=6
+PLL1 Multiplier=25
+PLL1 Post Divider=2
+PLL1 Div1=1
+PLL1 Div2=2
+PLL1 Div3=3
+Entrypoint=0
+SDRAM SDBCR=0
+SDRAM SDTMR=0
+SDRAM SDRSRPDEXIT=0
+SDRAM SDRCR=0
+DDR2 PHY=c5
+DDR2 SDCR=134832
+DDR2 SDCR2=0
+DDR2 SDTIMR=264a3209
+DDR2 SDTIMR2=3c14c722
+DDR2 SDRCR=492
+LPSC0 Enable=
+LPSC0 Disable=
+LPSC0 SyncRst=
+LPSC1 Enable=13+
+LPSC1 Disable=
+LPSC1 SyncRst=
+Pinmux=
diff --git a/soc/c6748/linker.cmd b/soc/c6748/linker.cmd
new file mode 100644 (file)
index 0000000..c3dac6b
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+-c
+-heap  0x4000
+-stack 0x8000
+
+MEMORY
+{
+    SBL_MEM (RWX)     : o = 0x80000000, l = 0x20000 /* Onchip RAM */
+}
+
+SECTIONS
+{
+    .text          >  SBL_MEM
+    .stack         >  SBL_MEM
+    .bss           >  SBL_MEM
+    .cio           >  SBL_MEM
+    .const         >  SBL_MEM
+    .data          >  SBL_MEM
+    .switch        >  SBL_MEM
+    .sysmem        >  SBL_MEM
+    .far           >  SBL_MEM
+    .args          >  SBL_MEM
+    .ppinfo        >  SBL_MEM
+    .ppdata        >  SBL_MEM
+    .pinit         >  SBL_MEM
+    .cinit         >  SBL_MEM
+    .binit         >  SBL_MEM
+    .init_array    >  SBL_MEM
+    .neardata      >  SBL_MEM
+    .fardata       >  SBL_MEM
+    .rodata        >  SBL_MEM
+    .c6xabi.exidx  >  SBL_MEM
+    .c6xabi.extab  >  SBL_MEM
+}
diff --git a/soc/c6748/sbl_slave_boot.c b/soc/c6748/sbl_slave_boot.c
new file mode 100644 (file)
index 0000000..b626a72
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <ti/csl/csl.h>
+#include <ti/csl/tistdtypes.h>
+
+#include "sbl_slave_core_boot.h"
+
+#if defined(BOOT_MMCSD)
+#include "sbl_mmcsd.h"
+#endif
+
+int32_t SBL_ImageCopy(sblEntryPoint_t *pEntry)
+{
+    int32_t retval = 0;
+
+#if defined(BOOT_MMCSD)
+    /* MMCSD Boot Mode Image Copy function. */
+    if (SBL_MMCBootImage(pEntry) != 0)
+    {
+        retval = -1;
+    }
+#endif  
+
+    return retval;
+}
+
+void SBL_ARMBringUp(uint8_t core, uint32_t entry)
+{
+   /* Add ARM init code */
+}
diff --git a/soc/c6748/sbl_slave_core_boot.h b/soc/c6748/sbl_slave_core_boot.h
new file mode 100644 (file)
index 0000000..97c021d
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef SBL_SLAVE_CORE_BOOT_H_
+#define SBL_SLAVE_CORE_BOOT_H_
+
+/*
+ *    SOC core definitions
+ */
+typedef enum cpu_core_id
+{
+    MPU_CPU0_ID = 0,
+    DSP0_ID = 1   
+} cpu_core_id_t;
+
+/* Structure holding the entry address of the applications for different cores. */
+typedef struct sblEntryPoint
+{
+    uint32_t entryPoint_MPU_CPU0;
+    uint32_t entryPoint_DSP0;
+} sblEntryPoint_t;
+
+/*
+ *  \brief    SBL_ImageCopy function is a wrapper to Multicore Image parser
+ *            function. Based on boot-mode jumps into specific Image copy
+ *            function for the particular bootmode.
+ *
+ *  \param    pointer to the structure holding the entry pointers for different
+ *            cores.
+ *
+ *  \return   error status.If error has occured it returns a non zero value.
+ *            If no error has occured then return status will be zero.
+ *
+ */
+int32_t SBL_ImageCopy(sblEntryPoint_t *pEntry);
+
+/*
+ * \brief    SBL_BootCore populates the entry point for each core
+ *
+ * \param
+ *      entry = entry address
+ *      CoreID = Core ID. Differs depending on SOC, refer to cpu_core_id enum
+ *      pAppEntry = SBL entry point struct
+ *
+ */
+void SBL_BootCore(uint32_t entry, uint32_t CoreID, sblEntryPoint_t *pAppEntry);
+
+#endif
diff --git a/soc/c6748/sbl_soc.c b/soc/c6748/sbl_soc.c
new file mode 100644 (file)
index 0000000..e1f3a37
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "sbl_soc.h"
+
+#include <ti/board/src/lcdkOMAPL138/include/board_cfg.h>
+#include <ti/drv/mmcsd/soc/MMCSD_soc.h>
+
+int32_t SBL_socInit(void)
+{
+    Board_initCfg boardCfg;
+
+    boardCfg = BOARD_INIT_UNLOCK_MMR |
+        BOARD_INIT_MODULE_CLOCK      |
+        BOARD_INIT_PLL               |
+        BOARD_INIT_DDR               |
+        BOARD_INIT_PINMUX_CONFIG     |
+        BOARD_INIT_UART_STDIO;
+
+    /* Board Library Init. */
+    if (Board_init(boardCfg))
+    {
+        return -1;
+    }
+
+    return 0;
+}
diff --git a/soc/omapl137/linker.cmd b/soc/omapl137/linker.cmd
new file mode 100644 (file)
index 0000000..2885f76
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+-c
+-heap  0x4000
+-stack 0x8000
+
+MEMORY
+{
+    SBL_MEM (RWX)     : o = 0x80000000, l = 0x20000 /* Shared RAM */
+}
+
+SECTIONS
+{
+    .text          >  SBL_MEM
+    .stack         >  SBL_MEM
+    .bss           >  SBL_MEM
+    .cio           >  SBL_MEM
+    .const         >  SBL_MEM
+    .data          >  SBL_MEM
+    .switch        >  SBL_MEM
+    .sysmem        >  SBL_MEM
+    .far           >  SBL_MEM
+    .args          >  SBL_MEM
+    .ppinfo        >  SBL_MEM
+    .ppdata        >  SBL_MEM
+    .pinit         >  SBL_MEM
+    .cinit         >  SBL_MEM
+    .binit         >  SBL_MEM
+    .init_array    >  SBL_MEM
+    .neardata      >  SBL_MEM
+    .fardata       >  SBL_MEM
+    .rodata        >  SBL_MEM
+    .c6xabi.exidx  >  SBL_MEM
+    .c6xabi.extab  >  SBL_MEM
+}
diff --git a/soc/omapl137/omapl137.ini b/soc/omapl137/omapl137.ini
new file mode 100644 (file)
index 0000000..74cbfc4
--- /dev/null
@@ -0,0 +1,123 @@
+; General settings that can be overwritten in the host code
+; that calls the AISGen library.
+[General]
+
+; Can be 8 or 16 - used in emifa
+busWidth=8            
+
+; EMIFA,NONE
+; EMIFA required for NOR boot modes, along with busWidth field
+BootMode=none
+
+; NO_CRC,SECTION_CRC,SINGLE_CRC
+crcCheckType=NO_CRC
+
+
+; Enable sequential read mode for boot modes that support it.
+; Does not impact boot modes that don't use it.
+[AIS_SeqReadEnable]
+
+
+; This section allows setting the PLL system clock with a  
+; specified multiplier and divider as shown. The clock source
+; can also be chosen for internal or external.
+;           |------24|------16|-------8|-------0|
+; PLLCFG0:  |    PLLM| POSTDIV| PLLDIV3| PLLDIV5|
+; PLLCFG1:  | CLKMODE| PLLDIV7|PLL_LOCK_TIME_CNT|
+[PLLCONFIG]
+PLLCFG0 = 0x18010202
+PLLCFG1 = 0x00050800
+
+; This section lets us configure the peripheral interface
+; of the current booting peripheral (I2C, SPI, or UART).
+; Use with caution. The format of the PERIPHCLKCFG field 
+; is as follows:
+; SPI:        |------24|------16|-------8|-------0|
+;             |           RSVD           |PRESCALE|
+;
+; I2C:        |------24|------16|-------8|-------0|
+;             |  RSVD  |PRESCALE|  CLKL  |  CLKH  |
+;
+; UART:       |------24|------16|-------8|-------0|
+;             | RSVD   |  OSR   |  DLH   |  DLL   |
+;[PERIPHCLKCFG]
+;PERIPHCLKCFG = 0x00000000
+
+; This section can be used to configure the PLL1 and the EMIF3a registers
+; for starting the DDR2 interface. 
+; See PLL1CONFIG section for the format of the PLL1CFG fields.
+;            |------24|------16|-------8|-------0|
+; SDCR:      |              SDCR                 |
+; SDTIMR:    |              SDTIMR               |
+; SDTIMR2:   |              SDTIMR2              |
+; SDRCR:     |              SDRCR                |
+[EMIF3SDRAM]
+;SDCR     = 0x00008621
+;SDTIMR   = 0x0A492148
+;SDTIMR2  = 0x70060004
+;SDRCR    = 0x0000030E
+
+; This section can be used to configure the EMIFA to use 
+; CS0 as an SDRAM interface.  The fields required to do this
+; are given below.
+;                     |------24|------16|-------8|-------0|
+; SDBCR:              |               SDBCR               |
+; SDTIMR:             |               SDTIMR              |
+; SDRSRPDEXIT:        |             SDRSRPDEXIT           |
+; SDRCR:              |               SDRCR               |
+[EMIF25SDRAM]
+;SDBCR        = 0x00004721
+;SDTIMR       = 0x29114510
+;SDRSRPDEXIT  = 0x00000006
+;SDRCR        = 0x0000030E
+
+; This section can be used to configure the async chip selects
+; of the EMIFA (CS2-CS5).  The fields required to do this
+; are given below.
+;           |------24|------16|-------8|-------0|
+; A1CR:     |                A1CR               |
+; A2CR:     |                A2CR               |
+; A3CR:     |                A3CR               |
+; A4CR:     |                A4CR               |
+;[EMIF25ASYNC]
+;A1CR = 0x00000000
+;A2CR = 0x00000000
+;A3CR = 0x00000000
+;A4CR = 0x00000000
+
+; This section should be used in place of PLL0CONFIG when
+; the I2C, SPI, or UART modes are being used.  This ensures that 
+; the system PLL and the peripheral's clocks are changed together.
+; See PLL0CONFIG section for the format of the PLL0CFG fields.
+; See PERIPHCLKCFG section for the format of the CLKCFG field.
+;               |------24|------16|-------8|-------0|
+; PLLCFG0:      |              PLL0CFG              |
+; PLLCFG1:      |              PLL0CFG              |
+; PERIPHCLKCFG: |              CLKCFG               |
+;[PLLANDCLOCKCONFIG]
+;PLLCFG0 = 0x00000000
+;PLLCFG1 = 0x00000000
+;PERIPHCLKCFG = 0x00000000
+
+; This section should be used to setup the power state of modules
+; of the two PSCs.  This section can be included multiple times to
+; allow the configuration of any or all of the device modules.
+;           |------24|------16|-------8|-------0|
+; LPSCCFG:  | PSCNUM | MODULE |   PD   | STATE  |
+;[PSCCONFIG]
+;LPSCCFG = 0x01030003
+
+; This section allows setting of a single PINMUX register.
+; This section can be included multiple times to allow setting
+; as many PINMUX registers as needed.
+;         |------24|------16|-------8|-------0|
+; REGNUM: |              regNum               |
+; MASK:   |               mask                |
+; VALUE:  |              value                |
+;[PINMUX]
+;REGNUM = 5
+;MASK = 0x00FF0000
+;VALUE = 0x00880000
+
+; No Params required - simply include this section for the fast boot function to be called
+;[FASTBOOT]
diff --git a/soc/omapl137/sbl_slave_boot.c b/soc/omapl137/sbl_slave_boot.c
new file mode 100644 (file)
index 0000000..00b614f
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <ti/csl/csl.h>
+#include <ti/csl/tistdtypes.h>
+
+#include "sbl_slave_core_boot.h"
+
+#if defined(BOOT_SPI)
+#include "sbl_spi.h"
+#endif
+
+int32_t SBL_ImageCopy(sblEntryPoint_t *pEntry)
+{
+    int32_t retval = 0;
+
+#if defined(BOOT_SPI)
+    if (SBL_SPIBootImage(pEntry) != 0U)
+#endif
+    {
+        retval = -1;
+    }
+
+    return retval;
+}
+
+void SBL_ARMBringUp(uint8_t core, uint32_t entry)
+{
+   /* Add ARM init code */
+}
diff --git a/soc/omapl137/sbl_slave_core_boot.h b/soc/omapl137/sbl_slave_core_boot.h
new file mode 100644 (file)
index 0000000..3fea92d
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2016-2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#ifndef SBL_SLAVE_CORE_BOOT_H_
+#define SBL_SLAVE_CORE_BOOT_H_
+
+/*
+ *    SOC core definitions
+ */
+typedef enum cpu_core_id
+{
+    MPU_CPU0_ID = 0,
+    DSP0_ID = 1   
+} cpu_core_id_t;
+
+/* Structure holding the entry address of the applications for different cores. */
+typedef struct sblEntryPoint
+{
+    uint32_t entryPoint_MPU_CPU0;
+    uint32_t entryPoint_DSP0;
+} sblEntryPoint_t;
+
+/*
+ *  \brief    SBL_ImageCopy function is a wrapper to Multicore Image parser
+ *            function. Based on boot-mode jumps into specific Image copy
+ *            function for the particular bootmode.
+ *
+ *  \param    pointer to the structure holding the entry pointers for different
+ *            cores.
+ *
+ *  \return   error status.If error has occured it returns a non zero value.
+ *            If no error has occured then return status will be zero.
+ *
+ */
+int32_t SBL_ImageCopy(sblEntryPoint_t *pEntry);
+
+/*
+ * \brief    SBL_BootCore populates the entry point for each core
+ *
+ * \param
+ *      entry = entry address
+ *      CoreID = Core ID. Differs depending on SOC, refer to cpu_core_id enum
+ *      pAppEntry = SBL entry point struct
+ *
+ */
+void SBL_BootCore(uint32_t entry, uint32_t CoreID, sblEntryPoint_t *pAppEntry);
+
+/*
+ * \brief    SBL_ARMBringUp sets the entry point and kick off application
+ *           for ARM cores
+ *
+ * \param
+ *      core = ARM core number. Cannot be 0.
+ *      entry = application entry address
+ *
+ */
+void SBL_ARMBringUp(uint8_t core, uint32_t entry);
+
+#endif
diff --git a/soc/omapl137/sbl_soc.c b/soc/omapl137/sbl_soc.c
new file mode 100644 (file)
index 0000000..a87c13a
--- /dev/null
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "sbl_soc.h"
+
+#include <ti/board/src/evmOMAPL137/include/board_cfg.h>
+#include <ti/board/src/flash/include/board_flash.h>
+#include <ti/board/src/flash/nor/device/w25x32vsfig.h>
+#include <ti/drv/spi/soc/SPI_soc.h>
+
+int32_t SBL_socInit()
+{
+    Board_initCfg boardCfg;
+  boardCfg = BOARD_INIT_UNLOCK_MMR |
+        BOARD_INIT_PLL             |
+        BOARD_INIT_MODULE_CLOCK    |
+        BOARD_INIT_DDR             |
+        BOARD_INIT_PINMUX_CONFIG   |
+        BOARD_INIT_EMIF_PINMUX     |
+        BOARD_INIT_UART_STDIO;
+
+    /* Board Library Init. */
+    if (Board_init(boardCfg))
+    {
+        return -1;
+    }
+    return 0;
+}
+
+#if defined (BOOT_SPI)
+int32_t SBL_spiInit(void *handle)
+{
+    SPI_v0_HWAttrs spi_cfg;
+    SPI_Params       spiParams;
+
+    /* Get the default SPI init configurations */
+    SPI_socGetInitCfg(BOARD_SPI_NOR_INSTANCE, &spi_cfg);
+
+    /* Modify the default SPI configurations if necessary */
+    /* Turning off interrupts for baremetal mode. May be re-enabled by app */
+    spi_cfg.enableIntr = false;
+
+    /* Set the default SPI init configurations */
+    SPI_socSetInitCfg(BOARD_SPI_NOR_INSTANCE, &spi_cfg);
+
+    /* Default SPI configuration parameters */
+    SPI_Params_init(&spiParams);
+    spiParams.frameFormat  = SPI_POL0_PHA1;
+
+    *(Board_flashHandle *) handle = Board_flashOpen(BOARD_FLASH_ID_W25X32VSFIG,
+                            BOARD_SPI_NOR_INSTANCE, &spiParams);
+
+    if (*(uint32_t *) handle == 0)
+    {
+        return -1;
+    }
+
+    return 0;
+}
+
+int32_t SBL_spiFlashWrite(void *handle, uint8_t *src, uint32_t length,
+    uint32_t offset)
+{
+    Board_flashHandle h = *(Board_flashHandle *) handle;
+    int32_t ret;
+    uint32_t blockNum, pageNum, len, lenOffset;
+    uint8_t dst[1];
+
+    /* Iterate through block size = 0x10000 */
+    len = length;
+    lenOffset = 0;
+    while (len > 0x1000)
+    {
+        if ((ret = Board_flashOffsetToBlkPage(h, offset+lenOffset, &blockNum, &pageNum)))
+        {
+            return ret;
+        }
+
+        /* Erase block, to which data has to be written */
+        if ((ret = Board_flashEraseBlk(h, blockNum)))
+        {
+            return ret;
+        }
+        /* Write buffer to flash */
+        if ((ret = Board_flashWrite(h, offset+lenOffset, src+lenOffset, 0x1000, NULL)))
+        {
+            return ret;
+        }
+
+        /* dummy read */
+        Board_flashRead(h, offset+lenOffset, dst, 1, NULL);
+        len -= 0x1000;
+        lenOffset += 0x1000;
+    }
+
+    /* Flash remainder as necessary */
+    if ((ret = Board_flashOffsetToBlkPage(h, offset+lenOffset, &blockNum, &pageNum)))
+    {
+        return ret;
+    }
+
+    /* Erase block, to which data has to be written */
+    if ((ret = Board_flashEraseBlk(h, blockNum)))
+    {
+        return ret;
+    }
+
+    /* Write buffer to flash */
+    if ((ret = Board_flashWrite(h, offset+lenOffset, src+lenOffset, len, NULL)))
+    {
+        return ret;
+    }
+
+    return 0;
+}
+
+int32_t SBL_spiFlashRead(void *handle, uint8_t *dst, uint32_t length,
+    uint32_t offset)
+{
+    Board_flashHandle h = *(Board_flashHandle *) handle;
+
+    if (Board_flashRead(h, offset, dst, length, NULL))
+    {
+        return -1;
+    }
+
+    return 0;
+}
+
+int32_t SBL_spiClose(void *handle)
+{
+    Board_flashHandle h = *(Board_flashHandle *) handle;
+    Board_flashClose(h);
+    return 0;
+}
+#endif
index 37f7f4ade9edc0ae9ca76d2ce9c3b7283fa57d7f..07d35b2bdf52002a70655d06ec386468a418c1cf 100644 (file)
@@ -100,6 +100,7 @@ typedef struct meta_header_end
 #define META_HDR_MAGIC_STR 0x5254534D /* MSTR in ascii */
 #define META_HDR_MAGIC_END 0x444E454D /* MEND in ascii */
 
+#if !defined(OMAPL137_BUILD)
 #define SOC_OCMC_RAM1_SIZE          ((uint32_t) 0x80000)     /*OCMC1 512KB*/
 #define SOC_OCMC_RAM2_SIZE          ((uint32_t) 0x100000)    /*OCMC2 1MB   */
 #define SOC_OCMC_RAM3_SIZE          ((uint32_t) 0x100000)    /*OCMC3  1MB   */
@@ -124,6 +125,7 @@ typedef struct meta_header_end
 #define SOC_DSP_L2_BASE                 (0x800000)
 #define SOC_DSP_L1P_BASE                (0xe00000)
 #define SOC_DSP_L1D_BASE                (0xf00000)
+#endif
 
 /* Function Pointer used while reading data from the storage. */
 int32_t (*fp_readData)(void *dstAddr, void *srcAddr,
@@ -263,7 +265,12 @@ void SBL_BootCore(uint32_t entry, uint32_t CoreID, sblEntryPoint_t *pAppEntry)
             /* CSL_MPU CPU0*/
             pAppEntry->entryPoint_MPU_CPU0 = entry;
             break;
-
+#if defined(OMAPL137_BUILD) || defined(C6748_BUILD)
+        case DSP0_ID:
+            /* DSP0*/
+            pAppEntry->entryPoint_DSP0 = entry;
+            break;
+#endif    
 #if defined(AM572x_BUILD) || defined(K2H_BUILD) || defined(K2E_BUILD) || defined(K2L_BUILD) || defined(K2K_BUILD) || defined(K2G_BUILD)
         case MPU_CPU1_ID:
             /* CSL_MPU CPU1 */
@@ -374,6 +381,7 @@ void SBL_BootCore(uint32_t entry, uint32_t CoreID, sblEntryPoint_t *pAppEntry)
     }
 }
 
+#if !defined(OMAPL137_BUILD) && !defined(OMAPL138_BUILD) && !defined(C6748_BUILD)
 static int32_t SBL_RprcImageParse(void *srcAddr,
                                   uint32_t *entryPoint,
                                   int32_t CoreId)
@@ -585,6 +593,41 @@ static int32_t SBL_RprcImageParse(void *srcAddr,
     }
     return retVal;
 }
+#else
+/* */
+static int32_t SBL_RprcImageParse(void *srcAddr,
+                                  uint32_t *entryPoint,
+                                  int32_t CoreId)
+{
+    rprcFileHeader_t    header;
+    rprcSectionHeader_t section;
+    int32_t i;
+    int32_t retVal = E_PASS;
+
+    /*read application image header*/
+    fp_readData(&header, srcAddr, sizeof (rprcFileHeader_t));
+
+    /*check magic number*/
+    if (header.magic != RPRC_MAGIC_NUMBER)
+    {
+        UART_printf("Invalid magic number in boot image. Expected: %x, received: %x\n", RPRC_MAGIC_NUMBER, header.magic);
+        retVal = E_FAIL;
+    }
+    else
+    {
+        /* Set the Entry Point */
+        *entryPoint = header.entry;
+
+        /*read entrypoint and copy sections to memory*/
+        for (i = 0; i < header.SectionCount; i++)
+        {
+            fp_readData(&section, srcAddr, sizeof (rprcSectionHeader_t));
+            fp_readData((void *) section.addr, srcAddr, section.size);
+        }
+    }
+    return retVal;
+}
+#endif
 
 /**
  * \brief  Function to read the device ID
diff --git a/tools/flashWriter/mmcsd/bin/lcdkOMAPL138/config b/tools/flashWriter/mmcsd/bin/lcdkOMAPL138/config
new file mode 100644 (file)
index 0000000..ec1a98a
--- /dev/null
@@ -0,0 +1 @@
+MLO 200
\ No newline at end of file
diff --git a/tools/flashWriter/mmcsd/src/c67x.cmd b/tools/flashWriter/mmcsd/src/c67x.cmd
new file mode 100644 (file)
index 0000000..132959c
--- /dev/null
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * Copyright (c) 2017 Texas Instruments Incorporated - http://www.ti.com
+ * 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ *****************************************************************************/
+/*
+ *  Linker command file
+ *
+ */
+
+-c
+-heap  0x8000
+-stack 0x8000
+
+/* Memory Map 1 - the default */
+MEMORY
+{
+    L1PSRAM (RWX)  : org = 0x0E00000, len = 0x7FFF
+    L1DSRAM (RWX)  : org = 0x0F00000, len = 0x7FFF 
+
+    L2SRAM (RWX)   : org = 0x0800000, len = 0x40000
+}
+
+SECTIONS
+{
+    .csl_vect   >       L2SRAM
+    .cppi       >       L2SRAM
+    .linkram    >       L2SRAM
+    .mac_buffer >       L2SRAM
+    .text       >       L2SRAM
+    GROUP (NEAR_DP)
+    {
+    .neardata
+    .rodata 
+    .bss
+    } load > L2SRAM
+    .stack      >       L2SRAM
+    .cinit      >       L2SRAM
+    .cio        >       L2SRAM
+    .const      >       L2SRAM
+    .data       >       L2SRAM
+    .switch     >       L2SRAM
+    .sysmem     >       L2SRAM
+    .far        >       L2SRAM
+    .testMem    >       L2SRAM
+    .fardata    >       L2SRAM
+}
diff --git a/tools/flashWriter/mmcsd/src/makefile b/tools/flashWriter/mmcsd/src/makefile
new file mode 100644 (file)
index 0000000..91875a6
--- /dev/null
@@ -0,0 +1,132 @@
+# Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+#
+#
+#  Redistribution and use in source and binary forms, with or without
+#  modification, are permitted provided that the following conditions
+#  are met:
+#
+#    Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+#
+#    Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the
+#    distribution.
+#
+#    Neither the name of Texas Instruments Incorporated nor the names of
+#    its contributors may be used to endorse or promote products derived
+#    from this software without specific prior written permission.
+#
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#
+# Macro definitions referenced below
+#
+
+MMCSD_WRTR_SRC_DIR ?= $(PDK_INSTALL_PATH)/ti/boot/sbl
+MMCSD_WRTR_BINDIR = $(MMCSD_WRTR_SRC_DIR)/tools/flashWriter/mmcsd/bin/$(BOARD)
+MMCSD_WRTR_OBJDIR = $(MMCSD_WRTR_SRC_DIR)/tools/flashWriter/mmcsd/bin/$(BOARD)/obj
+
+
+CC = $(C6X_GEN_INSTALL_PATH)/bin/cl6x
+
+# INCLUDE Directories
+CSL_DIR = $(PDK_INSTALL_PATH)/ti/csl
+BOARD_DIR = $(PDK_INSTALL_PATH)/ti/board
+
+# Libraries
+UART_LIB = "$(PDK_INSTALL_PATH)/ti/drv/uart/lib/c674/release/ti.drv.uart.ae674"
+MMCSD_LIB = "$(PDK_INSTALL_PATH)/ti/drv/mmcsd/lib/c674/release/ti.drv.mmcsd.ae674"
+I2C_LIB = "$(PDK_INSTALL_PATH)/ti/drv/i2c/lib/c674/release/ti.drv.i2c.ae674"
+
+BOARD_LIB = "$(PDK_INSTALL_PATH)/ti/board/lib/$(BOARD)/c674/release/ti.board.ae674"
+BOARD_INC_DIR = $(BOARD_DIR)/src/$(BOARD)/include
+MMCSD_WRTR_SOC = omapl138
+MMCSD_WRTR_SOC_DIR = $(MMCSD_WRTR_SRC_DIR)/soc/omapl138
+CSL_LIB = "$(PDK_INSTALL_PATH)/ti/csl/lib/omapl138/c674/release/ti.csl.ae674"
+CSL_INTC_LIB = "$(PDK_INSTALL_PATH)/ti/csl/lib/omapl138/c674/release/ti.csl.intc.ae674"
+I2C_LIB = "$(PDK_INSTALL_PATH)/ti/drv/i2c/lib/omapl138/c674/release/ti.drv.i2c.ae674"
+OSAL_LIB = "$(PDK_INSTALL_PATH)/ti/osal/lib/nonos/omapl138/c674/release/ti.osal.ae674"
+RTSLIB_PATH = "$(C6X_GEN_INSTALL_PATH)/lib/libc.a"
+
+PERIPHERAL_LIB = $(UART_LIB) $(I2C_LIB) $(MMCSD_LIB) $(OSAL_LIB) $(CSL_LIB) $(CSL_INTC_LIB) $(BOARD_LIB) $(RTSLIB_PATH)
+
+INCDIR := $(CSL_DIR);$(PDK_INSTALL_PATH);$(BOARD_DIR);$(BOARD_INC_DIR);$(MMCSD_WRTR_SRC_DIR)/soc;$(C6X_GEN_INSTALL_PATH)/include
+
+LIBDIR :=
+
+# Compiler options
+INTERNALDEFS += -mv64+ --abi=eabi -g --display_error_number --diag_warning=225 -g -DSOC_$(SOC) -DEVM_$(SOC) -DBOOT_MMCSD -D$(SOC)_BUILD
+
+# Linker options
+INTERNALLINKDEFS = -mfloat-abi=hard -Wl,--undefined,__aeabi_uidiv -Wl,--undefined,__aeabi_idiv --entry Entry -nostartfiles -static -Wl,--gc-sections -Wl,-T $(MMCSD_WRTR_SOC_DIR)/linker.cmd -Wl,--start-group -lgcc -lc -lrdimon $(BOARD_LIB) $(PERIPHERAL_LIB) $(TMP) -Wl,--end-group $(LDFLAGS)
+
+# Executable using device independent library and device object file
+EXE=mmcsd_flash_writer.out
+
+OBJEXT = obj
+ASMOBJEXT = ao
+SRCDIR = $(MMCSD_WRTR_SRC_DIR)/tools/flashWriter/mmcsd/src
+
+INCS = --include_path=$(strip $(subst ;, --include_path=,$(INCDIR)))
+
+VPATH=$(SRCDIR):$(MMCSD_WRTR_SRC_DIR)/board:$(PDK_INSTALL_PATH)/ti/drv/uart/soc/$(MMCSD_WRTR_SOC):$(PDK_INSTALL_PATH)/ti/drv/mmcsd/soc/$(MMCSD_WRTR_SOC):$(PDK_INSTALL_PATH)/ti/drv/mmcsd/soc/$(MMCSD_WRTR_SOC):$(MMCSD_WRTR_SOC_DIR)
+
+ifeq ($(SOC), OMAPL138)
+ LINK_CMD = $(SRCDIR)/c67x.cmd
+else
+ LINK_CMD = $(SRCDIR)/c6x.cmd
+endif 
+#List the Source Files
+SRC_C = \
+       sbl_mmcsd_writer.c
+
+SRC_DRV = \
+    UART_soc.c \
+    MMCSD_soc.c \
+    sbl_soc.c
+
+# FLAGS for the SourceFiles
+CFLAGS +=
+SRC_CFLAGS = -I. $(CFLAGS) -eo.$(OBJEXT) -ea.$(ASMOBJEXT) -g
+
+# Make Rule for the SRC Files
+SRC_OBJS = $(patsubst %.c, $(MMCSD_WRTR_OBJDIR)/%.$(OBJEXT), $(SRC_C))
+ENTRY_OBJ = $(patsubst %.asm, $(MMCSD_WRTR_OBJDIR)/%.$(ASMOBJEXT), $(ENTRY_SRC))
+SRC_DRV_OBJS = $(patsubst %.c, $(MMCSD_WRTR_OBJDIR)/%.$(OBJEXT), $(SRC_DRV))
+
+mmcsd_flashwriter:$(MMCSD_WRTR_BINDIR)/$(EXE)
+
+$(MMCSD_WRTR_BINDIR)/$(EXE): $(SRC_OBJS) $(SRC_DRV_OBJS) $(ENTRY_OBJ) $(MMCSD_WRTR_BINDIR)/.created $(MMCSD_WRTR_OBJDIR)/.created
+       @echo linking $(SRC_OBJS) $(SRC_DRV_OBJS) $(ENTRY_OBJ) into $@ ...
+       @$(CC) $(INTERNALDEFS) -z -m"$(MMCSD_WRTR_BINDIR)/mmcsd_flash_writer.map" -i"$(C6X_GEN_INSTALL_PATH)/lib" --reread_libs --warn_sections --rom_model -o $@ $(LINK_CMD) $(SRC_OBJS) $(SRC_DRV_OBJS) $(PERIPHERAL_LIB)
+
+$(MMCSD_WRTR_OBJDIR)/%.$(OBJEXT): %.c $(MMCSD_WRTR_OBJDIR)/.created
+       @echo compiling $< ...
+       @$(CC) -c $(SRC_CFLAGS) $(INTERNALDEFS) $(INCS) -fr=$(MMCSD_WRTR_OBJDIR) -fs=$(MMCSD_WRTR_OBJDIR) -fc $<
+
+$(MMCSD_WRTR_OBJDIR)/%.$(ASMOBJEXT): %.asm $(MMCSD_WRTR_OBJDIR)/.created
+       @echo compiling $< ...
+       @$(CC) -c $(SRC_CFLAGS) $(INTERNALDEFS) $(INCS)  $< -o $@
+
+$(MMCSD_WRTR_OBJDIR)/.created:
+       @mkdir -p $(MMCSD_WRTR_OBJDIR)
+       @touch $(MMCSD_WRTR_OBJDIR)/.created
+
+$(MMCSD_WRTR_BINDIR)/.created:
+       @mkdir -p $(MMCSD_WRTR_BINDIR)
+       @touch $(MMCSD_WRTR_BINDIR)/.created
+
+mmcsd_flashwriter_clean:
+       @rm -f $(MMCSD_WRTR_BINDIR)/$(EXE)
+       @rm -f $(SRC_OBJS) $(SRC_DEV_OBJS) $(ENTRY_OBJ) $(MMCSD_WRTR_BINDIR)/.created $(MMCSD_WRTR_OBJDIR)/.created
diff --git a/tools/flashWriter/mmcsd/src/sbl_mmcsd_writer.c b/tools/flashWriter/mmcsd/src/sbl_mmcsd_writer.c
new file mode 100644 (file)
index 0000000..4642e93
--- /dev/null
@@ -0,0 +1,231 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/* TI-RTOS Header files */
+#include <ti/drv/uart/UART_stdio.h>
+#include <ti/csl/tistdtypes.h>
+
+/* TI-RTOS Header files */
+#include <ti/drv/mmcsd/MMCSD.h>
+
+#include "board_cfg.h"
+#include "sbl_soc.h"
+
+/* Name of config file to parse */
+#define MMCSD_CONFIG_FILE_NAME "config"
+
+/* Maximum length of each config line */
+#define MAX_LINE_LENGTH 128
+
+/* Size of the MMCSD sectors */
+#define MMCSD_SECTOR_SIZE   512
+
+#ifdef SOC_OMAPL138
+/* Temporary memory to hold binary to flash. Default is base of DDR */
+#define LOAD_BUFFER_ADDR 0xC3000000
+
+/* Temporary memory to read binary from flash. */
+#define READ_BUFFER_ADDR 0xC5000000
+
+#else
+/* Temporary memory to hold binary to flash. Default is base of DDR */
+#define LOAD_BUFFER_ADDR 0x80000000
+
+/* Temporary memory to read binary from flash. */
+#define READ_BUFFER_ADDR 0x90000000
+
+#endif
+
+/* Buffer pointer to load temporary memory */
+uint8_t *buf_ptr;
+
+int32_t FW_parseInputFile(const char *s, void *mmcsdHandle)
+{
+    FILE *fp;
+    FILE *binPtr;
+    char line[MAX_LINE_LENGTH];
+    char fileName[20];
+    int32_t offsetAddr = 0U;
+    uint32_t len, dataSize, i;
+    int32_t ret;
+
+    buf_ptr = (uint8_t *) LOAD_BUFFER_ADDR;
+
+    fp = fopen(s, "r");
+    if (fp == NULL)
+    {
+        UART_printf("Error opening file %s\n", s);
+        return -1;
+    }
+
+    memset(line, 0, MAX_LINE_LENGTH);
+
+    while (fgets(line, MAX_LINE_LENGTH, fp) != 0)
+    {
+        if (sscanf(line,"%s %x", fileName, &offsetAddr) < 0)
+        {
+            UART_printf("Error parsing config line -\n");
+            UART_printf("\t Make sure each line is in the format: [filename] [address]\n");
+            fclose(fp);
+            return -2;
+        }
+        else
+        {
+            //offsetAddr = 512;
+            UART_printf("Parsed config line, received parameters: filename = %s, address = 0x%x\n", fileName, offsetAddr);
+            binPtr = fopen(fileName, "rb");
+            if (binPtr == NULL)
+            {
+                UART_printf("\tUnable to open file to load: %s\n", fileName);
+                fclose(fp);
+                return -3;
+            }
+            fseek(binPtr, 0, SEEK_END);
+            len = ftell(binPtr);
+            fseek(binPtr, 0, SEEK_SET);
+            if (len == 0)
+            {
+                UART_printf("\tUnable to read size of file %s\n", fileName);
+                fclose(binPtr);
+                fclose(fp);
+                return -4;
+            }
+            else
+            {
+                UART_printf("\tSize of %s is 0x%x\n", fileName, len);
+            }
+            UART_printf("\tLoading binary to memory ...\n");
+            fread(buf_ptr, len, 1, binPtr);
+
+            /* Legth of the data being written to MMCSD should be multiples
+             * of sector size. Adjust the lenth if it is not multiples of
+             * sector size which make the end of buffer to be padded with some data.
+             * This will be ignored by RBL as boot images header does not include
+             * the details of padded data */
+            if(len % MMCSD_SECTOR_SIZE)
+            {
+                dataSize = len + (MMCSD_SECTOR_SIZE - (len % MMCSD_SECTOR_SIZE));
+            }
+            
+            UART_printf("\tFinished loading binary to memory!\n");
+            if (ret = SBL_mmcsdWrite(mmcsdHandle, (uint8_t *) LOAD_BUFFER_ADDR,
+                                     offsetAddr/MMCSD_SECTOR_SIZE,
+                                     dataSize/MMCSD_SECTOR_SIZE))
+            {
+                UART_printf("\tError flashing memory! Error code %d\n", ret);
+                return -5;
+            }
+            else
+            {
+                UART_printf("\tFlashed %s to offset 0x%x!\n", fileName, offsetAddr);
+            }
+            
+            if (ret = SBL_mmcsdRead(mmcsdHandle, (uint8_t *) READ_BUFFER_ADDR, 
+                                    offsetAddr/MMCSD_SECTOR_SIZE,
+                                    dataSize/MMCSD_SECTOR_SIZE))
+            {
+                UART_printf("\tError reading memory at addr 0x%x\n", offsetAddr);
+                return -6;
+            }
+            else
+            {
+                UART_printf("\tRead flash memory at 0x%x, checking flashed content...\n", offsetAddr);
+            }
+            
+            for (i = 0; i < len; i++)
+            {
+                if ( (*(uint8_t *) (LOAD_BUFFER_ADDR + i)) != (*(uint8_t *) (READ_BUFFER_ADDR + i)) )
+                {
+                    UART_printf("\t\tMismatched data at offset 0x%x, expected = 0x%08x, read = 0x%08x\n",
+                        i, (*(uint8_t *) (LOAD_BUFFER_ADDR + i)), (*(uint8_t *) (READ_BUFFER_ADDR + i)));
+                    ret = -7;
+                }
+            }
+            
+            if (ret == -7)
+            {
+                UART_printf("\tVerifying flashed data failed!\n");
+            }
+            else
+            {
+                UART_printf("\tVerified flash data equal expected data!\n");
+            }
+
+            fclose(binPtr);
+        }
+    }
+
+    fclose(fp);
+
+    return 0;
+}
+
+MMCSD_Handle handle = NULL;
+int main(void)
+{
+    if (SBL_socInit())
+    {
+        return -1;
+    }
+    else
+    {
+        UART_printf("\n*** PDK SPI Flash Writer ***\n");
+    }
+
+    UART_printf("Opening MMCSD handle...\n");
+    if (SBL_mmcsdInit(&handle) < 0)
+    {
+        UART_printf("\tMMCSD init failed! \n");
+        return -1;
+    }
+    UART_printf("MMCSD handle opened!\n");
+
+    UART_printf("Parsing config file and flashing content to MMCSD...\n");
+    if (FW_parseInputFile(MMCSD_CONFIG_FILE_NAME, handle) < 0)
+    {
+        UART_printf("Error parsing config file!\n");
+        return -1;
+    }
+    else
+    {
+        UART_printf("Successfully flashed memory content!\n");
+    }
+
+    SBL_mmcsdClose(handle);
+
+    return 0;
+}
diff --git a/tools/flashWriter/spi/bin/evmOMAPL137/config b/tools/flashWriter/spi/bin/evmOMAPL137/config
new file mode 100644 (file)
index 0000000..14b400b
--- /dev/null
@@ -0,0 +1,2 @@
+MLO 0
+app 80000
diff --git a/tools/flashWriter/spi/src/c67x.cmd b/tools/flashWriter/spi/src/c67x.cmd
new file mode 100644 (file)
index 0000000..822af19
--- /dev/null
@@ -0,0 +1,75 @@
+/******************************************************************************
+ * Copyright (c) 2017 Texas Instruments Incorporated - http://www.ti.com
+ * 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ *****************************************************************************/
+/*
+ *  Linker command file
+ *
+ */
+
+-c
+-heap  0x8000
+-stack 0x8000
+
+/* Memory Map 1 - the default */
+MEMORY
+{
+    L1PSRAM (RWX)  : org = 0x0E00000, len = 0x7FFF
+    L1DSRAM (RWX)  : org = 0x0F00000, len = 0x7FFF 
+
+    L2SRAM (RWX)   : org = 0x0800000, len = 0x40000
+}
+
+SECTIONS
+{
+    .csl_vect   >       L2SRAM
+    .cppi       >       L2SRAM
+    .linkram    >       L2SRAM
+    .mac_buffer >       L2SRAM
+    platform_lib >     L2SRAM
+    .text       >       L2SRAM
+    GROUP (NEAR_DP)
+    {
+    .neardata
+    .rodata 
+    .bss
+    } load > L2SRAM
+    .stack      >       L2SRAM
+    .cinit      >       L2SRAM
+    .cio        >       L2SRAM
+    .const      >       L2SRAM
+    .data       >       L2SRAM
+    .switch     >       L2SRAM
+    .sysmem     >       L2SRAM
+    .far        >       L2SRAM
+    .testMem    >       L2SRAM
+    .fardata    >       L2SRAM
+}
index 10356ac13b46f249ddf0fd3f1eebdd91cc99ee87..d1742971bba766a5dc6a0a91af65f2ace4d8dd30 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2016 Texas Instruments Incorporated - http://www.ti.com/
+# Copyright (C) 2015-2017 Texas Instruments Incorporated - http://www.ti.com/
 #
 #
 #  Redistribution and use in source and binary forms, with or without
@@ -45,9 +45,27 @@ CSL_DIR = $(PDK_INSTALL_PATH)/ti/csl
 BOARD_DIR = $(PDK_INSTALL_PATH)/ti/board
 
 # Libraries
+ifeq ($(SOC), OMAPL137)
+UART_LIB = "$(PDK_INSTALL_PATH)/ti/drv/uart/lib/c674/release/ti.drv.uart.ae674"
+SPI_LIB = "$(PDK_INSTALL_PATH)/ti/drv/spi/lib/c674/release/ti.drv.spi.ae674"
+I2C_LIB = "$(PDK_INSTALL_PATH)/ti/drv/i2c/lib/c674/release/ti.drv.i2c.ae674"
+else
 UART_LIB = "$(PDK_INSTALL_PATH)/ti/drv/uart/lib/c66/release/ti.drv.uart.ae66"
 SPI_LIB = "$(PDK_INSTALL_PATH)/ti/drv/spi/lib/c66/release/ti.drv.spi.ae66"
 I2C_LIB = "$(PDK_INSTALL_PATH)/ti/drv/i2c/lib/c66/release/ti.drv.i2c.ae66"
+endif
+
+ifeq ($(SOC), OMAPL137)
+       BOARD_LIB = "$(PDK_INSTALL_PATH)/ti/board/lib/$(BOARD)/c674/release/ti.board.ae674"
+       BOARD_INC_DIR = $(BOARD_DIR)/src/$(BOARD)/include
+       SPI_WRTR_SOC = omapl137
+       SPI_WRTR_SOC_DIR = $(SPI_WRTR_SRC_DIR)/soc/omapl137
+       CSL_LIB = "$(PDK_INSTALL_PATH)/ti/csl/lib/omapl137/c674/release/ti.csl.ae674"
+       CSL_INTC_LIB = "$(PDK_INSTALL_PATH)/ti/csl/lib/omapl137/c674/release/ti.csl.intc.ae674"
+       I2C_LIB = "$(PDK_INSTALL_PATH)/ti/drv/i2c/lib/omapl137/c674/release/ti.drv.i2c.ae674"
+       OSAL_LIB = "$(PDK_INSTALL_PATH)/ti/osal/lib/nonos/omapl137/c674/release/ti.osal.ae674"
+       PERIPHERAL_LIB = $(UART_LIB) $(I2C_LIB) $(SPI_LIB) $(OSAL_LIB) $(CSL_LIB) $(CSL_INTC_LIB) $(BOARD_LIB)
+endif
 
 ifeq ($(SOC), K2H)
        BOARD_LIB = "$(PDK_INSTALL_PATH)/ti/board/lib/$(BOARD)/c66/release/ti.board.ae66"
@@ -102,7 +120,11 @@ INCDIR := $(CSL_DIR);$(PDK_INSTALL_PATH);$(BOARD_DIR);$(BOARD_INC_DIR);$(SPI_WRT
 LIBDIR :=
 
 # Compiler options
+ifeq ($(SOC), OMAPL137)
+INTERNALDEFS += -mv64+ --abi=eabi -g --display_error_number --diag_warning=225 -g -DSOC_$(SOC) -DEVM_$(SOC) -DBOOT_SPI -D$(SOC)_BUILD
+else
 INTERNALDEFS += -mv6600 --abi=eabi -g --display_error_number --diag_warning=225 -g -DSOC_$(SOC) -DEVM_$(SOC) -DBOOT_SPI -D$(SOC)_BUILD
+endif
 
 # Linker options
 INTERNALLINKDEFS = -mfloat-abi=hard -Wl,--undefined,__aeabi_uidiv -Wl,--undefined,__aeabi_idiv --entry Entry -nostartfiles -static -Wl,--gc-sections -Wl,-T $(SPI_WRTR_SOC_DIR)/linker.cmd -Wl,--start-group -lgcc -lc -lrdimon $(BOARD_LIB) $(PERIPHERAL_LIB) $(TMP) -Wl,--end-group $(LDFLAGS)
@@ -118,6 +140,11 @@ INCS = --include_path=$(strip $(subst ;, --include_path=,$(INCDIR)))
 
 VPATH=$(SRCDIR):$(SPI_WRTR_SRC_DIR)/board:$(PDK_INSTALL_PATH)/ti/drv/uart/soc/$(SPI_WRTR_SOC):$(PDK_INSTALL_PATH)/ti/drv/mmcsd/soc/$(SPI_WRTR_SOC):$(PDK_INSTALL_PATH)/ti/drv/spi/soc/$(SPI_WRTR_SOC):$(SPI_WRTR_SOC_DIR)
 
+ifeq ($(SOC), OMAPL137)
+ LINK_CMD = $(SRCDIR)/c67x.cmd
+else
+ LINK_CMD = $(SRCDIR)/c6x.cmd
+endif 
 #List the Source Files
 SRC_C = \
        sbl_spi_writer.c
@@ -140,11 +167,15 @@ spi_flashwriter:$(SPI_WRTR_BINDIR)/$(EXE)
 
 $(SPI_WRTR_BINDIR)/$(EXE): $(SRC_OBJS) $(SRC_DRV_OBJS) $(ENTRY_OBJ) $(SPI_WRTR_BINDIR)/.created $(SPI_WRTR_OBJDIR)/.created
        @echo linking $(SRC_OBJS) $(SRC_DRV_OBJS) $(ENTRY_OBJ) into $@ ...
-       @$(CC) $(INTERNALDEFS) -z -m"$(SPI_WRTR_BINDIR)/spi_flash_writer.map" -i"$(C6X_GEN_INSTALL_PATH)/lib" --reread_libs --warn_sections --rom_model -o $@ $(SRCDIR)/c6x.cmd $(SRC_OBJS) $(SRC_DRV_OBJS) $(PERIPHERAL_LIB)
+       @$(CC) $(INTERNALDEFS) -z -m"$(SPI_WRTR_BINDIR)/spi_flash_writer.map" -i"$(C6X_GEN_INSTALL_PATH)/lib" --reread_libs --warn_sections --rom_model -o $@ $(LINK_CMD) $(SRC_OBJS) $(SRC_DRV_OBJS) $(PERIPHERAL_LIB)
 
 $(SPI_WRTR_OBJDIR)/%.$(OBJEXT): %.c $(SPI_WRTR_OBJDIR)/.created
        @echo compiling $< ...
+ifeq ($(SOC), OMAPL137)
+       @$(CC) --include_path="$(C6X_GEN_INSTALL_PATH)/include" $(INCS) $(INTERNALDEFS) -fr=$(SPI_WRTR_OBJDIR) -fs=$(SPI_WRTR_OBJDIR) -fc $<
+else
        @$(CC) --include_path="$(C6X_GEN_INSTALL_PATH)/include" $(INCS) $< $(INTERNALDEFS) --output_file=$@
+endif
 
 $(SPI_WRTR_OBJDIR)/%.$(ASMOBJEXT): %.S $(SPI_WRTR_OBJDIR)/.created
        @echo compiling $< ...
index e9e64a5994a658dd922d67007deb270d11087db6..93ddfff8252310d54300283f94308e203718a453 100644 (file)
 /* Maximum length of each config line */
 #define MAX_LINE_LENGTH 128
 
+#ifdef SOC_OMAPL137
+/* Temporary memory to hold binary to flash. Default is base of DDR */
+#define LOAD_BUFFER_ADDR 0xC0000000
+
+/* Temporary memory to read binary from flash. */
+#define READ_BUFFER_ADDR 0xC1000000
+
+#else
 /* Temporary memory to hold binary to flash. Default is base of DDR */
 #define LOAD_BUFFER_ADDR 0x80000000
 
 /* Temporary memory to read binary from flash. */
 #define READ_BUFFER_ADDR 0x90000000
 
+#endif
+
 /* Buffer pointer to load temporary memory */
 uint32_t *buf_ptr;
 
@@ -143,7 +153,7 @@ int32_t FW_parseInputFile(const char *s, void *spiHandle)
             {
                 if ( (*(uint32_t *) (LOAD_BUFFER_ADDR + i)) != (*(uint32_t *) (READ_BUFFER_ADDR + i)) )
                 {
-                    UART_printf("\t\tMismatched data at offset 0x%x, expected = 0x%08x, read = 0x%08x\n", 
+                    UART_printf("\t\tMismatched data at offset 0x%x, expected = 0x%08x, read = 0x%08x\n",
                         i, (*(uint32_t *) (LOAD_BUFFER_ADDR + i)), (*(uint32_t *) (READ_BUFFER_ADDR + i)));
                     ret = -7;
                 }
diff --git a/tools/omapl13x_boot_utils/CREDITS b/tools/omapl13x_boot_utils/CREDITS
new file mode 100644 (file)
index 0000000..391a3a2
--- /dev/null
@@ -0,0 +1,36 @@
+#
+#   Parts of the development effort for this project have been
+#   sponsored by Texas Instrument, Inc. Thanks to TI for
+#   supporting an Open Source project!
+#
+#   This is at least a partial credits-file of individual people that
+#   have contributed to the this project. It is sorted by name and
+#   formatted to allow easy grepping and beautification by scripts.
+#   The fields are: name (N), email (E), web-address (W), PGP key ID
+#   and fingerprint (P), description (D), and snail-mail address (S).
+#
+
+N: Daniel Allred
+E: moridinga@users.sourceforge.net
+D: Project Initiation 
+D: NAND, NOR, SPI_MEM driver
+D: Serial Loading/Flashing Host and Targets
+
+N: Steve Gorwood
+D: Testing
+D: DM35x Porting
+
+N: Sandeep Paulraj
+D: Testing
+D: DM357 Porting, DM36x Porting
+
+N: Joe Coombs
+D: AIS parsing tools
+D: AIS UART Boot GUIs
+
+N: Jeff Cobb
+D: OMAP-L138 porting, 
+D: Improved UI for serial flasher
+
+N: Gaurav Agarwal
+D: SD/MMC work for DM35x, DM36x
\ No newline at end of file
diff --git a/tools/omapl13x_boot_utils/Common/AIS/AIS.cs b/tools/omapl13x_boot_utils/Common/AIS/AIS.cs
new file mode 100644 (file)
index 0000000..9248a55
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ * AIS.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+/****************************************************************
+ *  TI AIS Namespace Definitions
+ *  (C) 2007-2009, Texas Instruments, Inc.                           
+ *                                                              
+ * Author:  Daniel Allred   
+ *                                                              
+ ****************************************************************/
+
+using System;
+
+namespace TI.AISLib
+{
+
+  /// <summary>
+  /// Generic return type enumeration
+  /// </summary>
+  public enum retType : uint
+  {
+    SUCCESS = 0,
+    FAIL    = 1,
+    TIMEOUT = 2
+  }
+
+  /// <summary>
+  /// Enum of AIS values that can be used in AIS scripts
+  /// </summary>
+  public enum AisOps : uint
+  {
+    MagicNumber     = 0x41504954,
+    Section_Load    = 0x58535901,
+    RequestCRC      = 0x58535902,
+    EnableCRC       = 0x58535903,
+    DisableCRC      = 0x58535904,
+    Jump            = 0x58535905,
+    Jump_Close      = 0x58535906,
+    Set             = 0x58535907,
+    Start_Over      = 0x58535908,
+    CmpSection_Load = 0x58535909,
+    Section_Fill    = 0x5853590A,
+    Ping            = 0x5853590B,
+    Get             = 0x5853590C,
+    FunctionExec    = 0x5853590D,
+    FastBoot        = 0x58535913,
+    ReadWait        = 0x58535914,
+    FinalFxnReg     = 0x58535915,
+    SecureKeyLoad   = 0x58535920,
+    EncSection_Load = 0x58535921,
+    SecSection_Load = 0x58535922,
+    SetSecExitMode  = 0x58535923,
+    SetDelegateKey  = 0x58535924,
+    RemDelegateKey  = 0x58535925,
+    SeqReadEnable   = 0x58535963,
+    XmtStartWord    = 0x58535441,
+    RcvStartWord    = 0x52535454
+  };
+
+  public enum AisSetType : uint
+  {
+    BYTE    = 0x00,
+    SHORT   = 0x01,
+    INT     = 0x02,
+    FIELD   = 0x03,
+    BITS    = 0x04,
+  }
+  
+  public enum AisSecureType:int
+  {
+    NONE    = 0x0,
+    CUSTOM  = 0x1,
+    GENERIC = 0x2
+  }
+  
+  public enum AisHostType : uint
+  {
+    I2C   = 0,
+    SPI   = 1,
+    UART  = 2
+  }
+  
+  public enum AisStatus : int
+  {
+    ERROR         = -1,
+    IN_PROGRESS   =  0,
+    COMPLETE      =  1
+  }
+
+  /// <summary>
+  /// Enum of memory types
+  /// </summary>
+  public enum AisMemType : uint
+  {
+    EightBit = 0x1,
+    SixteenBit = 0x2,
+    ThirtyTwoBit = 0x4,
+    SixtyFourBit = 0x8
+  };
+  
+  public enum AisMachineType : uint
+  {
+    NONE,
+    ARM,
+    DSP
+  }
+
+  /// <summary>
+  /// Enum of possible boot modes
+  /// </summary>
+  public enum AisBootModes : uint
+  {
+    NONE = 0x0,
+    SPIMASTER,
+    I2CMASTER,
+    EMIFA,
+    NAND,
+    EMAC,
+    UART,
+    PCI,
+    HPI,
+    USB,
+    MMC_SD,
+    VLYNQ,
+    RAW,
+    LEGACY
+  };
+
+  /// <summary>
+  /// CRC check type for the AIS stream
+  /// </summary>
+  public enum AisCRCCheckType : uint
+  {
+    NO_CRC = 0,
+    SECTION_CRC = 1,
+    SINGLE_CRC = 2
+  };
+  
+} //end of TI.AIS namespace
+
diff --git a/tools/omapl13x_boot_utils/Common/AIS/AISGen.cs b/tools/omapl13x_boot_utils/Common/AIS/AISGen.cs
new file mode 100644 (file)
index 0000000..7123ff3
--- /dev/null
@@ -0,0 +1,1695 @@
+/*
+ * AISGen.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+/****************************************************************
+ *  TI Abstract AISGen Class
+ *  (C) 2007-2009, Texas Instruments, Inc.
+ *                                                              
+ * Author:  Daniel Allred
+ *                                     
+ ****************************************************************/
+
+using System;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.IO;
+using System.IO.Ports;
+using System.Reflection;
+using System.Threading;
+using System.Globalization;
+using System.Collections;
+using System.Collections.Generic;
+using TI.AISLib;
+using TI.UtilLib;
+using TI.UtilLib.IO;
+using TI.UtilLib.Ini;
+using TI.UtilLib.CRC;
+using TI.UtilLib.ObjectFile;
+
+namespace TI.AISLib
+{
+#region Public enums and structs for AIS creation
+  
+  /// <summary>
+  /// AIS ROM Function struct
+  /// </summary>
+  public struct AisROMFunction
+  {
+    public String funcName;
+    public String iniSectionName;
+    public UInt16 numParams;
+    public String[] paramNames;
+  }
+
+  /// <summary>
+  /// AIS Extra Function Struct
+  /// </summary>
+  public struct AisExtraFunction
+  {
+    public String funcName;
+    public String iniSectionName;
+    public String aisExtraFileName;
+    public UInt16 numParams;
+    public String[] paramNames;
+    public UInt32 paramAddr;
+    public UInt32 funcAddr;
+    public Boolean isInitFunc;
+  }
+
+  public class InputFile
+  {
+    public String   fileName;
+    public UInt32   loadAddr;
+    public UInt32   entryPointAddr;
+    public Boolean  useEntryPoint;      
+  }
+
+  public struct MemoryRange
+  {
+    public UInt32 startAddr;
+    public UInt32 endAddr;
+    
+    public MemoryRange(UInt32 start, UInt32 end)
+    {
+      startAddr = start;  endAddr = end;
+    }      
+  }
+#endregion
+
+  /// <summary>
+  /// Public abstract class (with static parts) to handle generic activities
+  /// for device specific AISGen objects.
+  /// </summary>
+  public abstract partial class AISGen 
+  {
+  
+  #region Protected Variables
+    /// <summary>
+    /// Short name of device 
+    /// </summary>
+    protected String devNameShort;
+
+    /// <summary>
+    /// Long name of device
+    /// </summary>
+    protected String devNameLong;
+
+    /// <summary>
+    /// The bootmode currently selected for the AIS generator.
+    /// </summary>
+    protected AisBootModes bootMode;
+
+    /// <summary>
+    /// An array of bytes for holding the generated AIS data.
+    /// </summary>
+    protected Byte[] AISData;
+
+    /// <summary>
+    /// An array of AisROMFunction objects for holding info about the device's callable AIS ROM functions. 
+    /// </summary>
+    protected AisROMFunction[] ROMFunc;
+    
+    /// <summary>
+    /// An array of AisExtraFunction objects that correspond to the special functions offered in extra Object Files.
+    /// </summary>
+    protected AisExtraFunction[] AISExtraFunc;
+
+    /// <summary>
+    /// The current type of CRC checking that the device generator is using for AIS section load commands.
+    /// This can be modified via the public property.
+    /// </summary>
+    protected AisCRCCheckType aisCRCType;
+
+    /// <summary>
+    /// The endianness of the device.
+    /// </summary>
+    protected Endian devEndian;
+    
+    /// <summary>
+    /// The endianness of the device AIS data.
+    /// </summary>
+    protected Endian devAISEndian;
+
+    protected CRC32 devCRC;
+    protected UInt32 CRCStartPosition;
+    protected UInt32 CRCEndPosition;
+    protected Boolean crcIsEnabled;    
+    
+    protected UInt32 busWidth;
+    protected UInt32 addrWidth;
+    protected UInt32 entryPoint;
+
+    protected AisMachineType machineType;
+    
+    protected Stream devAISStream;
+    protected EndianBinaryWriter writer;
+    
+    protected Stream sigStream;
+    protected EndianBinaryWriter sigWriter;
+    
+    // Private security type variable
+    protected AisSecureType AisSecureTypeValue;
+  #endregion
+    
+  #region Private Variables
+    // List to keep track of memory regions being used
+    // (used to warn about overlaps)
+    private List<MemoryRange> sectionMemory;
+    // List of ObjectFile objects that are being given to the 
+    // AIS generating tool
+    private List<ObjectFile> objectFiles;
+  #endregion
+  
+  #region Public Properties
+    /// <summary>
+    /// Read or Set the type of CRC checking used in section loading.
+    /// </summary>
+    public AisCRCCheckType AISCRCType
+    {
+      get { return aisCRCType; }
+      set
+      {
+          aisCRCType = value;
+      }
+    }
+
+    /// <summary>
+    /// Get or set the bootmode for the AIS generator.
+    /// </summary>
+    public AisBootModes BootMode
+    {
+      get { return bootMode; }
+      set { bootMode = value; }
+    }
+    
+    /// <summary>
+    /// The AIS data.
+    /// </summary>
+    public Byte[] Data
+    {
+      get { return AISData; }
+    }
+
+    public String DeviceNameShort
+    {
+      get { return devNameShort; }
+    }
+
+    public String DeviceNameLong
+    {
+      get { return devNameLong; }
+    }
+    
+    public UInt32 EntryPoint
+    {
+      get { return entryPoint; }
+    }
+    
+    public AisMachineType MachineType
+    {
+      get{ return machineType; }
+      set{ machineType = value; }
+    }
+    
+    public AisSecureType SecureType
+    {
+      get { return AisSecureTypeValue; }
+      set { AisSecureTypeValue = value; }
+    }
+  #endregion
+    
+  #region Public Contructor
+    public AISGen()
+    {
+      // Set defaults for AISGen object
+      bootMode        = AisBootModes.NONE;
+      busWidth        = 8;
+      addrWidth       = 16;
+      entryPoint      = 0xFFFFFFFF;
+      crcIsEnabled    = false;
+      aisCRCType      = AisCRCCheckType.NO_CRC;
+      ROMFunc         = null;
+      AISExtraFunc    = null;
+      writer          = null;
+      devAISStream    = null;
+      sigStream       = null;
+      SecureType      = AisSecureType.NONE;
+    }
+  #endregion
+  
+  #region Public Virtual Methods
+    public virtual retType InsertAISPreamble()
+    {
+      Debug.DebugMSG("Writing AIS Preamble");
+      writer.Write((UInt32)AisOps.MagicNumber);
+      
+      // Add the AIS magic number to signature buffer if a secure boot image
+      if ( this.SecureType != AisSecureType.NONE )
+      {
+        sigWriter.Write((UInt32)AisOps.MagicNumber);
+      }
+      
+      return retType.SUCCESS;
+    }
+  
+    public virtual retType InsertAISObjectFile( String fileName )
+    {
+      Debug.DebugMSG("Inserting Object File, fileName = " + fileName);
+      // Since no load address is provided, we can assume ObjectFile is ElfFile or CoffFile
+      if (File.Exists(fileName))
+      {
+        // Parse the object file
+        ObjectFile file;
+        if (ElfFile.IsElfFile(fileName))
+        {
+          file = new ElfFile(fileName);
+        }
+        else if (CoffFile.IsCoffFile(fileName))
+        {
+          file = new CoffFile(fileName);
+        }
+        else
+        {
+          Console.WriteLine("ERROR: Not a valid object file.");
+          return retType.FAIL;
+        }
+          
+        if (file != null)
+        {
+          // Load the object file contents
+          AISObjectFileLoad(this,file);
+          file.Close();
+        }
+        else
+        {
+          Console.WriteLine("ERROR: Parsing the input file {0} failed!",fileName);
+        }
+      }
+      else
+      {
+        Console.WriteLine("WARNING: File {0} does not exist. Ignoring insert command.",fileName);
+      }
+      
+      return retType.SUCCESS;
+    }
+    
+    public virtual retType InsertAISObjectFile( String fileName, Boolean useEntryPoint )
+    {
+      // Since no load address is provided, we can assume ObjectFile is ElfFile or CoffFile
+      if (InsertAISObjectFile( fileName ) != retType.SUCCESS)
+      {
+        return retType.FAIL;
+      }
+      
+      // Set AIS entry point
+      if (useEntryPoint)
+      {
+        ObjectFile file = FindObjectFile( this, fileName );
+      
+        this.entryPoint = (UInt32) file.EntryPoint;          
+      }
+      
+      return retType.SUCCESS;
+    }
+    
+    public virtual retType InsertAISObjectFile( String fileName, UInt32 loadAddr )
+    {
+      Debug.DebugMSG("Inserting Object File, fileName = " + fileName);
+      // Since a load address is provided, we can assume ObjectFile is BinaryFile
+      if (File.Exists(fileName))
+      {
+        // Parse the object file
+        ObjectFile file = new BinaryFile(fileName, loadAddr);
+          
+        if (file != null)
+        {
+          // Load the object file contents
+          AISObjectFileLoad(this, file);
+          file.Close();
+        }
+        else
+        {
+          Console.WriteLine("ERROR: Parsing the input file {0} failed!",fileName);
+          return retType.FAIL;          
+        }
+      }
+      else
+      {
+        Console.WriteLine("ERROR: File {0} does not exist! ",fileName);
+        return retType.FAIL;
+      }
+      
+      return retType.SUCCESS;
+    }
+    
+    public virtual retType InsertAISObjectFile( String fileName, UInt32 loadAddr, UInt32 entryPoint )
+    {
+      // Since a load address is provided, we can assume ObjectFile is BinaryFile
+      if (InsertAISObjectFile( fileName, loadAddr) != retType.SUCCESS)
+      {
+        return retType.FAIL;
+      }
+      
+      if (entryPoint != 0xFFFFFFFF)
+      {
+        this.entryPoint = entryPoint;
+      }
+      
+      return retType.SUCCESS;
+    }
+  
+    public virtual retType InsertAISEnableCRC()
+    {
+      Debug.DebugMSG("Enable CRC command called.");
+      if ( this.SecureType == AisSecureType.NONE )
+      {
+        if (this.aisCRCType != AisCRCCheckType.NO_CRC)
+        {
+          if (!crcIsEnabled)
+          {
+            Debug.DebugMSG("Inserting Enable CRC command.");
+            writer.Write((UInt32)AisOps.EnableCRC);
+            this.CRCStartPosition = (UInt32) this.devAISStream.Position;
+            crcIsEnabled = true;
+          }
+        }
+      }
+      
+      return retType.SUCCESS;
+    }
+  
+    public virtual retType InsertAISDisableCRC()
+    {
+      Debug.DebugMSG("Disable CRC command called.");
+      if ( this.SecureType == AisSecureType.NONE )
+      {
+        if (this.aisCRCType != AisCRCCheckType.NO_CRC)
+        {
+          if (crcIsEnabled)
+          {
+            Debug.DebugMSG("Inserting Disable CRC command.");
+            writer.Write((UInt32)AisOps.DisableCRC);
+            crcIsEnabled = false;
+          }
+        }
+      }
+      
+      return retType.SUCCESS;
+    }
+  
+    public virtual retType InsertAISRequestCRC(UInt32 crcValue, Int32 seekValue)
+    {
+      // For secure boot, silently discard CRC commands
+      if ( this.SecureType == AisSecureType.NONE )
+      {
+        Debug.DebugMSG("Request CRC command called.");
+        if (this.aisCRCType != AisCRCCheckType.NO_CRC)
+        {
+          if (crcIsEnabled)
+          {
+            Debug.DebugMSG("Inserting Request CRC command.");
+            writer.Write((UInt32)AisOps.RequestCRC);
+            writer.Write( crcValue );
+            writer.Write( seekValue );
+          }
+        }
+      }
+      
+      return retType.SUCCESS;
+    }
+    
+    public virtual retType InsertAISRequestCRC(Int32 seekValue)
+    {
+      return InsertAISRequestCRC(this.devCRC.CurrentCRC, seekValue);
+    }
+    
+    public virtual retType InsertAISRequestCRC()
+    {
+      Int32 seekValue;
+      
+      this.CRCEndPosition = (UInt32) this.devAISStream.Position;
+      seekValue = (Int32)(-1) * (Int32)(12 + this.CRCEndPosition - this.CRCStartPosition);
+      
+      return InsertAISRequestCRC(this.devCRC.CurrentCRC, seekValue);
+    }
+  
+    public virtual retType InsertAISFunctionExecute(UInt16 fxnNum, UInt16 argCnt, UInt32[] args)
+    {
+      Debug.DebugMSG("Inserting Function Execute command.");
+      writer.Write((UInt32)AisOps.FunctionExec);
+      writer.Write( (((UInt32)argCnt) << 16) | (((UInt32)fxnNum) << 0) );
+      writer.Write(args);
+      
+      if ( this.SecureType != AisSecureType.NONE )
+      {
+        sigWriter.Write((UInt32)AisOps.FunctionExec);
+        sigWriter.Write( (((UInt32)argCnt) << 16) | (((UInt32)fxnNum) << 0) );
+        sigWriter.Write(args);
+      }
+      
+      return retType.SUCCESS;
+    }
+  
+    public virtual retType InsertAISSectionLoad(UInt32 address, UInt32 size, Byte[] data)
+    {
+      Debug.DebugMSG("Inserting AIS Section Load command.");
+      writer.Write((UInt32)AisOps.Section_Load);
+      writer.Write(address);
+      writer.Write(size);
+      writer.Write(data);
+     
+      if ( this.SecureType != AisSecureType.NONE )
+      {
+        sigWriter.Write((UInt32)AisOps.Section_Load);
+        sigWriter.Write(address);
+        sigWriter.Write(size);
+        sigWriter.Write(data);
+      }
+      
+      return retType.SUCCESS;
+    }
+  
+    public virtual retType InsertAISJump(String symbolName)
+    {
+      ObjectSymbol sym = FindSymbol(this, symbolName);
+      
+      if (sym != null)
+      {
+        return InsertAISJump((UInt32)sym.value);
+      }
+      
+      return retType.FAIL;
+    }
+    
+    public virtual retType InsertAISJump(UInt32 address)
+    {
+      Debug.DebugMSG("Inserting AIS Jump command.");
+    
+      writer.Write((UInt32)AisOps.Jump);
+      writer.Write(address);
+      
+      // Add the data to signature buffer if a secure boot image
+      if ( this.SecureType != AisSecureType.NONE )
+      {
+        sigWriter.Write((UInt32)AisOps.Jump);
+        sigWriter.Write(address);
+      }
+      
+      return retType.SUCCESS;
+    }
+
+    public virtual retType InsertAISJumpClose(String symbolName)
+    {
+      ObjectSymbol sym = FindSymbol(this, symbolName);
+      
+      if (sym != null)
+      {
+        return InsertAISJumpClose((UInt32)sym.value);
+      }
+      
+      return retType.FAIL;  
+    }
+
+    public virtual retType InsertAISJumpClose(UInt32 address)
+    {
+      Debug.DebugMSG("Inserting AIS JumpClose command, jumping to 0x" + address.ToString("X8"));
+    
+      writer.Write((UInt32)AisOps.Jump_Close);
+      writer.Write(address);
+      
+      // Add the data to signature buffer if a secure boot image
+      if ( this.SecureType != AisSecureType.NONE )
+      {
+        sigWriter.Write((UInt32)AisOps.Jump_Close);
+        sigWriter.Write(address);
+      }
+      
+      return retType.SUCCESS;
+    }
+  
+    public virtual retType InsertAISSet(UInt32 type, UInt32 address, UInt32 data, UInt32 sleep)
+    {
+      Debug.DebugMSG("Inserting AIS Set command, writing to 0x" + address.ToString("X8"));
+    
+      // Write SET command
+      writer.Write((UInt32)AisOps.Set);
+      
+      // Write type field (32-bit only)
+      writer.Write(type);
+      
+      // Write appropriate parameter address
+      writer.Write(address);
+      
+      // Write data to write
+      writer.Write(data);
+      
+      // Write Sleep value 
+      writer.Write(sleep);
+      
+      if ( this.SecureType != AisSecureType.NONE )
+      {
+        // Write SET command
+        sigWriter.Write((UInt32)AisOps.Set);
+      
+        // Write type field (32-bit only)
+        sigWriter.Write(type);
+        
+        // Write appropriate parameter address
+        sigWriter.Write(address);
+        
+        // Write data to write
+        sigWriter.Write(data);
+        
+        // Write Sleep value 
+        sigWriter.Write(sleep);
+      }
+      
+      return retType.SUCCESS;
+    }
+  
+    public virtual retType InsertAISSectionFill(UInt32 address, UInt32 size, UInt32 type, UInt32 pattern )
+    {
+      Debug.DebugMSG("Inserting AIS Section Fill command, writing to 0x" + address.ToString("X8"));
+      
+      // Write SECTION FILL command
+      writer.Write((UInt32)AisOps.Section_Fill);
+      
+      // Write section start address
+      writer.Write(address);
+      
+      // Write section size
+      writer.Write(size);
+      
+      // Write memory access type
+      writer.Write(type);
+      
+      // Write data pattern
+      writer.Write(pattern);
+      
+      if ( this.SecureType != AisSecureType.NONE )
+      {
+        // Write SECTION FILL command
+        sigWriter.Write((UInt32)AisOps.Section_Fill);
+        
+        // Write section start address
+        sigWriter.Write(address);
+        
+        // Write section size
+        sigWriter.Write(size);
+        
+        // Write memory access type
+        sigWriter.Write(type);
+        
+        // Write data pattern
+        sigWriter.Write(pattern);
+      }
+            
+      return retType.SUCCESS;
+    }
+  
+    public virtual retType InsertAISReadWait(UInt32 address, UInt32 mask, UInt32 data )
+    {
+      Debug.DebugMSG("Inserting AIS ReadWait command, reading from 0x" + address.ToString("X8"));
+    
+      writer.Write((UInt32)AisOps.ReadWait);
+      writer.Write(address);
+      writer.Write(mask);
+      writer.Write(data);
+      
+      if ( this.SecureType != AisSecureType.NONE )
+      {
+        sigWriter.Write((UInt32)AisOps.ReadWait);
+        sigWriter.Write(address);
+        sigWriter.Write(mask);
+        sigWriter.Write(data);
+      }
+      
+      return retType.SUCCESS;
+    }
+  
+    public virtual retType InsertAISFastBoot()
+    {
+      Debug.DebugMSG("Inserting AIS FastBoot command");
+    
+      writer.Write((UInt32)AisOps.FastBoot);
+      
+      if ( this.SecureType != AisSecureType.NONE )
+      {
+        // Write SET command
+        sigWriter.Write((UInt32)AisOps.FastBoot);
+      }
+      
+      return retType.SUCCESS;
+    }
+  
+    public virtual retType InsertAISFinalFxnReg( String symbolName)
+    {
+      Debug.DebugMSG("Inserting AIS FinalFxnReg command, fxnName = " + symbolName);
+    
+      ObjectSymbol sym = FindSymbol(this, symbolName);
+      
+      if (sym != null)
+      {
+        InsertAISFinalFxnReg((UInt32)sym.value);
+        return retType.SUCCESS;
+      }
+      
+      return retType.FAIL;  
+    }
+  
+    public virtual retType InsertAISFinalFxnReg(UInt32 address)
+    {
+      Debug.DebugMSG("Inserting AIS FinalFxnReg command, fxnAddress = " + address.ToString("X8"));
+    
+      writer.Write((UInt32)AisOps.FinalFxnReg);
+      writer.Write(address);
+      
+      if ( this.SecureType != AisSecureType.NONE )
+      {
+        sigWriter.Write((UInt32)AisOps.FinalFxnReg);
+        sigWriter.Write(address);
+      }
+      
+      return retType.SUCCESS;
+    }
+  
+    public virtual retType InsertAISSeqReadEnable()
+    {
+      Debug.DebugMSG("Inserting AIS SeqReadEnable command");
+    
+      writer.Write((UInt32)AisOps.SeqReadEnable);
+      
+      if ( this.SecureType != AisSecureType.NONE )
+      {
+        sigWriter.Write((UInt32)AisOps.SeqReadEnable);
+      }
+      
+      return retType.SUCCESS;
+    } 
+  #endregion
+
+  #region Public Static Methods
+    /// <summary>
+    /// genAIS command.  Always use section-by-section CRC checks
+    /// </summary>
+    /// <param name="mainObjectFileName"></param>
+    /// <param name="bootMode"></param>
+    /// <returns>Bytes of the binary or text AIS command</returns>
+    public static Byte[] GenAIS( AISGen devAISGen, 
+                                 List<String> inputFileNames,
+                                 IniFile iniFile )
+    {
+      UInt32 numWords;
+      
+      // Setup the binary writer to generate the temp AIS file
+      devAISGen.devAISStream = new MemoryStream();
+      using ( devAISGen.writer = new EndianBinaryWriter( devAISGen.devAISStream, devAISGen.devEndian) )
+      {
+        // List to keep track of loadable sections and their occupied memory ranges
+        devAISGen.sectionMemory = new List<MemoryRange>();  
+        // Initiate list to keep track of the input files
+        devAISGen.objectFiles   = new List<ObjectFile>();
+        
+        // Get data from the GENERAL INI Section
+        GeneralIniSectionParse(devAISGen, iniFile);
+        
+        #region Main AIS Generation      
+        // ---------------------------------------------------------
+        // ****************** BEGIN AIS GENERATION *****************
+        // ---------------------------------------------------------
+        Console.WriteLine("Begining the AIS file generation.");
+        
+        // Diaplay currently selected boot mode
+        Console.WriteLine("AIS file being generated for bootmode: {0}.",Enum.GetName(typeof(AisBootModes),devAISGen.bootMode));
+        
+        // Write the premilinary header and fields (everything before first AIS command)
+        devAISGen.InsertAISPreamble();
+        Debug.DebugMSG("Preamble Complete");
+        
+        // Parse the INI sections in order, inserting needed AIS commands
+        if (iniFile != null)
+        {
+          foreach(IniSection sec in iniFile.Sections)
+          {
+            InsertAISCommandViaINI(devAISGen, sec);
+          }
+          Debug.DebugMSG("INI parsing complete");
+        }
+        
+        // Insert the object file passed in on the top-level (if it exists)
+        if (inputFileNames != null)
+        {
+          foreach (String fn in inputFileNames)
+          {
+            String[] nameAndAddr = fn.Split('@');
+            
+            Debug.DebugMSG("Inserting file " + nameAndAddr[0]);
+            
+            if (!File.Exists(nameAndAddr[0]))
+            {
+              Console.WriteLine("ERROR: {0} does not exist. Aborting...", nameAndAddr[0]);
+              return null;
+            }
+            
+            if (nameAndAddr.Length == 2)
+            {
+              UInt32 loadAddr;
+              
+              nameAndAddr[1] = nameAndAddr[1].ToLower();
+              
+              if (nameAndAddr[1].StartsWith("0x"))
+              {
+                if (!UInt32.TryParse(nameAndAddr[1].Replace("0x", ""), NumberStyles.HexNumber, null, out loadAddr))
+                {
+                  Console.WriteLine("WARNING: Invalid address format, {0}. Ignoring...", nameAndAddr[1]);
+                }
+                else
+                {
+                  devAISGen.InsertAISObjectFile(nameAndAddr[0], loadAddr);
+                }
+              }
+              else if (UInt32.TryParse(nameAndAddr[1], out loadAddr))
+              {
+                devAISGen.InsertAISObjectFile(nameAndAddr[0], loadAddr);
+              }
+              else
+              {
+                Console.WriteLine("WARNING: Invalid address format, {0}. Ignoring...", nameAndAddr[1]);
+              }
+            }
+            else if (nameAndAddr.Length == 1)
+            {
+              // If we still have not had a valid entry point set, then use entry point from 
+              // first encountered non-binary file in the inputFileNames list
+              if (devAISGen.entryPoint == 0xFFFFFFFF)
+              {
+                devAISGen.InsertAISObjectFile(nameAndAddr[0], true);
+              }
+              else
+              {
+                devAISGen.InsertAISObjectFile(nameAndAddr[0], false);
+              }
+            }
+            else
+            {
+              Console.WriteLine("WARNING: Invalid filename format, {0}. Ignoring...", fn);
+            }
+          }
+          
+          Debug.DebugMSG("Main input file insertion complete.");
+        }
+
+        // If CRC type is for single CRC, send Request CRC now
+        if (devAISGen.aisCRCType == AisCRCCheckType.SINGLE_CRC)
+        {
+          devAISGen.InsertAISRequestCRC();
+        }
+        
+        // Insert closing JumpClose AIS command (issue warning)
+        if (devAISGen.entryPoint == 0xFFFFFFFF)
+        {
+          // No valid entry point was ever set (issue warning)
+          Console.WriteLine("WARNING: Entry point set to null pointer!");
+          devAISGen.InsertAISJumpClose(0x00000000);
+        }
+        else
+        {
+          devAISGen.InsertAISJumpClose(devAISGen.entryPoint);
+        }
+        
+        
+        // Flush the data and then return to start
+        devAISGen.devAISStream.Flush();
+        devAISGen.devAISStream.Seek(0,SeekOrigin.Begin);
+        
+        Console.WriteLine("AIS file generation was successful.");
+        // ---------------------------------------------------------
+        // ******************* END AIS GENERATION ******************
+        // ---------------------------------------------------------
+
+      #endregion
+      
+        // Now create return Byte array based on tempAIS file and the bootmode
+        EndianBinaryReader tempAIS_br = new EndianBinaryReader(devAISGen.devAISStream, Endian.LittleEndian);
+      
+        // Setup the binary reader object
+        numWords = ((UInt32)tempAIS_br.BaseStream.Length) >> 2;
+        devAISGen.AISData = new Byte[numWords << 2];   //Each word converts to 4 binary bytes
+        
+        Debug.DebugMSG("Number of words in the AIS output is {0}", numWords);
+
+        // Copy the data to the output Byte array
+        for (UInt32 i = 0; i < numWords; i++)
+        {
+          BitConverter.GetBytes(tempAIS_br.ReadUInt32()).CopyTo(devAISGen.AISData, i * 4);
+        }
+
+        // Close the binary reader
+        tempAIS_br.Close();  
+      }
+      
+      // Dispose of all object files
+      foreach (ObjectFile file in devAISGen.objectFiles)
+      {
+        try
+        {
+          file.Dispose();
+        }
+        catch (Exception e)
+        {
+          Console.WriteLine(e.Message);
+        }
+      }
+
+      // Clean up any embedded file resources that may have been extracted
+      EmbeddedFileIO.CleanUpEmbeddedFiles();
+
+      // Return Byte Array
+      return devAISGen.AISData;
+    }
+
+          
+    /// <summary>
+    /// genAIS command.  Always use section-by-section CRC checks
+    /// </summary>
+    /// <param name="mainObjectFileName"></param>
+    /// <param name="bootMode"></param>
+    /// <returns>Bytes of the binary or text AIS command</returns>
+    public static Byte[] GenAIS( AISGen devAISGen,
+                                 List<String> inputFileNames,
+                                 String iniData )
+    {
+      return GenAIS(devAISGen, inputFileNames, new IniFile(iniData));
+    }
+    
+    /// <summary>
+    /// Secondary genAIS that calls the first
+    /// </summary>
+    /// <param name="mainObjectFileName">File name of .out file</param>
+    /// <param name="bootmode">String containing desired boot mode</param>
+    /// <returns>an Array of bytes to write to create an AIS file</returns>
+    public static Byte[] GenAIS( AISGen devAISGen,
+                                 List<String> inputFileNames,
+                                 String bootmode,
+                                 IniFile iniFile )
+    {
+      devAISGen.bootMode = (AisBootModes)Enum.Parse(typeof(AisBootModes), bootmode, true);
+      Console.WriteLine("Chosen bootmode is {0}.", devAISGen.bootMode.ToString());
+      return GenAIS(devAISGen, inputFileNames, iniFile);
+    }
+    
+    /// <summary>
+    /// Secondary genAIS that calls the first
+    /// </summary>
+    /// <param name="mainObjectFileName">File name of .out file</param>
+    /// <param name="bootmode">String containing desired boot mode</param>
+    /// <returns>an Array of bytes to write to create an AIS file</returns>
+    public static Byte[] GenAIS( AISGen devAISGen,
+                                 List<String> inputFileNames,
+                                 String bootmode,
+                                 String iniData )
+    {
+      devAISGen.bootMode = (AisBootModes)Enum.Parse(typeof(AisBootModes), bootmode, true);
+      Console.WriteLine("Chosen bootmode is {0}.", devAISGen.bootMode.ToString());
+      return GenAIS(devAISGen, inputFileNames, iniData);
+    }
+    
+    /// <summary>
+    /// Secondary genAIS that calls the first
+    /// </summary>
+    /// <param name="mainObjectFileName">File name of .out file</param>
+    /// <param name="bootmode">AISGen.AisBootModes Enum value containing desired boot mode</param>
+    /// <returns>an Array of bytes to write to create an AIS file</returns>
+    public static Byte[] GenAIS( AISGen devAISGen,
+                                 List<String> inputFileNames,
+                                 AisBootModes bootmode,
+                                 IniFile iniFile )
+    {
+      devAISGen.bootMode = bootmode;
+      Console.WriteLine("Chosen bootmode is {0}.", devAISGen.bootMode.ToString());
+      return GenAIS(devAISGen, inputFileNames, iniFile);
+    }
+    
+    /// <summary>
+    /// Secondary genAIS that calls the first
+    /// </summary>
+    /// <param name="mainObjectFileName">File name of .out file</param>
+    /// <param name="bootmode">AISGen.AisBootModes Enum value containing desired boot mode</param>
+    /// <returns>an Array of bytes to write to create an AIS file</returns>
+    public static Byte[] GenAIS( AISGen devAISGen,
+                                 List<String> inputFileNames,
+                                 AisBootModes bootmode,
+                                 String iniData )
+    {
+      devAISGen.bootMode = bootmode;
+      Console.WriteLine("Chosen bootmode is {0}.", devAISGen.bootMode.ToString());
+      return GenAIS(devAISGen, inputFileNames, iniData);
+    }
+
+    
+    public static retType InsertAISCommandViaINI(AISGen devAISGen, IniSection sec)
+    {
+      #region Handle Input Binary and Object Files
+      if (sec.sectionName.Equals("INPUTFILE", StringComparison.OrdinalIgnoreCase))
+      {
+        String fileName = null;
+        Boolean useEntryPoint = false;
+        UInt32 loadAddr = 0xFFFFFFFF;
+        UInt32 entryPointAddr = 0xFFFFFFFF;
+        
+        foreach (DictionaryEntry de in sec.sectionValues)
+        {
+          // File name for binary section data
+          if (((String)de.Key).Equals("FILENAME", StringComparison.OrdinalIgnoreCase))
+          {
+            fileName = (String) sec.sectionValues["FILENAME"];
+          }
+          
+          // Binary section's load address in the memory map
+          if (((String)de.Key).Equals("LOADADDRESS", StringComparison.OrdinalIgnoreCase))
+          {
+            loadAddr = (UInt32) sec.sectionValues["LOADADDRESS"];
+          }
+          
+          // Binary section's entry point address in the memory map
+          if (((String)de.Key).Equals("ENTRYPOINTADDRESS", StringComparison.OrdinalIgnoreCase))
+          {
+            entryPointAddr = (UInt32) sec.sectionValues["ENTRYPOINTADDRESS"];
+          }
+          
+          // Option to specify that this entry point should be used for AIS
+          if (((String)de.Key).Equals("USEENTRYPOINT", StringComparison.OrdinalIgnoreCase))
+          {
+            if (((String)sec.sectionValues["USEENTRYPOINT"]).Equals("YES", StringComparison.OrdinalIgnoreCase))
+            {
+              useEntryPoint = true;
+            }
+            else if (((String)sec.sectionValues["USEENTRYPOINT"]).Equals("TRUE", StringComparison.OrdinalIgnoreCase))
+            {
+              useEntryPoint = true;
+            }
+          }
+        }
+        
+        if (fileName == null)
+        {
+          Console.WriteLine("ERROR: File name must be provided in INPUTFILE section.");
+          return retType.FAIL;
+        }
+        
+        // Insert the file into the AIS image
+        if ( loadAddr != 0xFFFFFFFF )
+        {
+          // binary image
+          if ( entryPointAddr != 0xFFFFFFFF )
+          {
+            devAISGen.InsertAISObjectFile(fileName, loadAddr, entryPointAddr);
+          }
+          else
+          {
+            devAISGen.InsertAISObjectFile(fileName, loadAddr);
+          }
+        }
+        else
+        {
+          if ( entryPointAddr != 0xFFFFFFFF )
+          {
+            devAISGen.InsertAISObjectFile(fileName,true);
+          }
+          else
+          {
+            devAISGen.InsertAISObjectFile(fileName,useEntryPoint);
+          }
+        }
+        return retType.SUCCESS;
+      }
+      #endregion
+      
+      #region Handle ROM and AIS Extra Functions  
+      // Handle ROM functions
+      if (devAISGen.ROMFunc != null)
+      {
+        for (UInt32 j = 0; j < devAISGen.ROMFunc.Length; j++)
+        {
+          if (sec.sectionName.Equals(devAISGen.ROMFunc[j].iniSectionName, StringComparison.OrdinalIgnoreCase))
+          {
+            UInt32 funcIndex = j;
+
+            UInt32[] args = new UInt32[ (UInt32)devAISGen.ROMFunc[funcIndex].numParams ];
+            
+            for (Int32 k = 0; k < devAISGen.ROMFunc[funcIndex].numParams; k++)
+            {
+              Debug.DebugMSG("\tParam name: {0}, Param num: {1}, Value: {2}\n",
+                devAISGen.ROMFunc[funcIndex].paramNames[k],
+                k, 
+                sec.sectionValues[devAISGen.ROMFunc[funcIndex].paramNames[k].ToUpper()]);
+              try
+              {              
+                args[k] = (UInt32) sec.sectionValues[devAISGen.ROMFunc[funcIndex].paramNames[k].ToUpper()];
+              }
+              catch
+              {
+                Console.WriteLine("WARNING: INI Section {0} is malformed - {1} parameter not provided. Ignoring section contens.",sec.sectionName, devAISGen.ROMFunc[funcIndex].paramNames[k].ToUpper());
+                return retType.SUCCESS;
+              }
+            }
+
+            devAISGen.InsertAISFunctionExecute((UInt16) funcIndex, (UInt16) devAISGen.ROMFunc[funcIndex].numParams, args);
+            
+            return retType.SUCCESS;
+          }
+        }
+      }
+      
+      // Handle AISExtras functions
+      if (devAISGen.AISExtraFunc != null)
+      {
+        for (UInt32 j = 0; j < devAISGen.AISExtraFunc.Length; j++)
+        {
+          if (sec.sectionName.Equals(devAISGen.AISExtraFunc[j].iniSectionName, StringComparison.OrdinalIgnoreCase))
+          {
+            UInt32 funcIndex = j;
+            
+            UInt32[] args = new UInt32[ (UInt32)devAISGen.AISExtraFunc[j].numParams ];
+            
+            // Load the AIS extras file if needed
+            {
+              IniSection tempSec = new IniSection();
+              tempSec.sectionName = "INPUTFILE";
+              tempSec.sectionValues = new Hashtable();
+              tempSec.sectionValues["FILENAME"] = devAISGen.AISExtraFunc[funcIndex].aisExtraFileName;
+              
+              EmbeddedFileIO.ExtractFile(Assembly.GetExecutingAssembly(), devAISGen.AISExtraFunc[funcIndex].aisExtraFileName, true);
+                    
+              InsertAISCommandViaINI(devAISGen, tempSec);
+              
+              Debug.DebugMSG("AISExtras file loaded.\n");
+              
+              // Use symbols to get address for AISExtra functions and parameters
+              for (Int32 k = 0; k < devAISGen.AISExtraFunc.Length; k++)
+              {
+                ObjectFile tempFile = FindFileWithSymbol(devAISGen, devAISGen.AISExtraFunc[funcIndex].funcName);
+                if (tempFile == null)
+                {
+                  // Try looking for underscore version
+                  tempFile = FindFileWithSymbol(devAISGen, "_" + devAISGen.AISExtraFunc[funcIndex].funcName);
+                }
+                
+                if (tempFile != null)
+                {
+                  ObjectSymbol tempSym = tempFile.symFind(devAISGen.AISExtraFunc[funcIndex].funcName);
+                  if (tempSym == null)
+                  {
+                    // Try looking for underscore version
+                    tempSym = tempFile.symFind("_"+devAISGen.AISExtraFunc[funcIndex].funcName);
+                  }
+                  
+                  if (tempSym != null)
+                  {
+                    devAISGen.AISExtraFunc[funcIndex].funcAddr = (UInt32) tempSym.value;
+                    ObjectSection tempObjSec = tempFile.secFind(".params");
+                    if (tempObjSec == null)
+                    {
+                      Console.WriteLine(".params section not found in file {0}.", 
+                                        devAISGen.AISExtraFunc[funcIndex].aisExtraFileName);
+                      return retType.FAIL;
+                    }
+                    else
+                    {
+                      devAISGen.AISExtraFunc[funcIndex].paramAddr = (UInt32) tempObjSec.runAddr;
+                    }
+                  }
+                  else
+                  {
+                    Console.WriteLine("AIS extra function, {0}, not found in file {1}.", 
+                                      devAISGen.AISExtraFunc[funcIndex].funcName, 
+                                      devAISGen.AISExtraFunc[funcIndex].aisExtraFileName);
+                    return retType.FAIL;
+                  }
+                }
+                else
+                {
+                  // The function name was not found - that's a big problem with our 
+                  // device specific AISGen class.
+                  Console.WriteLine("AIS extra function, {0}, not found in file {1}.", 
+                                    devAISGen.AISExtraFunc[funcIndex].funcName, 
+                                    devAISGen.AISExtraFunc[funcIndex].aisExtraFileName);
+                  return retType.FAIL;
+                }
+              }
+            }
+            
+            Debug.DebugMSG("Found required sections and symbols in AISExtras file.\n");
+            
+            // Validate input parameters
+            for (Int32 k = 0; k < devAISGen.AISExtraFunc[funcIndex].numParams; k++)
+            {
+              try
+              {              
+                args[k] = (UInt32) sec.sectionValues[devAISGen.AISExtraFunc[funcIndex].paramNames[k].ToUpper()];
+              }
+              catch
+              {
+                Console.WriteLine("WARNING: INI Section {0} is malformed - {1} parameter not provided. Ignoring section contens.",sec.sectionName, devAISGen.ROMFunc[funcIndex].paramNames[k].ToUpper());
+                return retType.SUCCESS;
+              }
+            }
+            
+            Debug.DebugMSG("Input parameter validation for AISExtras function is complete.\n");
+            
+            // Write SET command for each input parameter
+            for (Int32 k = 0; k < devAISGen.AISExtraFunc[funcIndex].numParams; k++)
+            {
+              devAISGen.InsertAISSet(
+                (UInt32)AisSetType.INT,    // Write type field (32-bit only)
+                (UInt32) (devAISGen.AISExtraFunc[funcIndex].paramAddr + (k * 4)), 
+                args[k],
+                (UInt32)0x0 );  // Write Sleep value (should always be zero)
+            }
+
+            // Now that params are set, Jump to function
+            devAISGen.InsertAISJump(devAISGen.AISExtraFunc[funcIndex].funcAddr);
+            
+            return retType.SUCCESS;
+          }
+        }
+      }
+      #endregion
+      
+      #region Handle AIS Command Sections
+      
+      if (sec.sectionName.Equals("AIS_EnableCRC", StringComparison.OrdinalIgnoreCase))
+      {
+        devAISGen.InsertAISEnableCRC();
+      }
+      
+      else if (sec.sectionName.Equals("AIS_DisableCRC", StringComparison.OrdinalIgnoreCase))
+      {
+        devAISGen.InsertAISDisableCRC();
+      }
+      
+      else if (sec.sectionName.Equals("AIS_RequestCRC", StringComparison.OrdinalIgnoreCase))
+      {
+        UInt32 crcValue = 0x00000000;
+        Int32 seekValue = -12;
+        
+        foreach (DictionaryEntry de in sec.sectionValues)
+        {
+          if (((String)de.Key).Equals("CRCValue", StringComparison.OrdinalIgnoreCase))
+          {
+            crcValue = (UInt32)sec.sectionValues["CRCVALUE"];
+          }
+          if (((String)de.Key).Equals("SEEKValue", StringComparison.OrdinalIgnoreCase))
+          {
+            seekValue = (Int32)sec.sectionValues["SEEKVALUE"];
+          }
+        }
+        if (devAISGen.InsertAISRequestCRC(crcValue, seekValue) != retType.SUCCESS)
+        {
+          Console.WriteLine("WARNING: Final function register AIS command failed.");
+        }
+      }
+      
+      else if (sec.sectionName.Equals("AIS_Jump", StringComparison.OrdinalIgnoreCase))
+      {
+        String symbolName = "";
+        UInt32 address = 0x00000000;
+      
+        foreach (DictionaryEntry de in sec.sectionValues)
+        {
+          if (((String)de.Key).Equals("LOCATION", StringComparison.OrdinalIgnoreCase))
+          {
+            symbolName = sec.sectionValues["LOCATION"].ToString();
+          }
+        }
+        // See if string is number (address)
+        if (UInt32.TryParse(symbolName, out address))
+        {
+          if (devAISGen.InsertAISJump(address) != retType.SUCCESS)
+          {
+            Console.WriteLine("WARNING: AIS Jump to {0} was not inserted.",symbolName);
+          }
+        }
+        else
+        {
+          if (devAISGen.InsertAISJump(symbolName) != retType.SUCCESS)
+          {
+            Console.WriteLine("WARNING: AIS Jump to {0} was not inserted.",symbolName);
+          }
+        }
+      }
+      
+      else if (sec.sectionName.Equals("AIS_JumpClose", StringComparison.OrdinalIgnoreCase))
+      {
+        String symbolName = "";
+        UInt32 address = 0x00000000;
+      
+        foreach (DictionaryEntry de in sec.sectionValues)
+        {
+          if (((String)de.Key).Equals("ENTRYPOINT", StringComparison.OrdinalIgnoreCase))
+          {
+            symbolName = (String)sec.sectionValues["ENTRYPOINT"];
+          }
+        }
+        
+        if (symbolName == "")
+        {
+          devAISGen.InsertAISJumpClose(devAISGen.entryPoint);
+        }
+        else
+        {
+          // See if string is number (address)
+          if (UInt32.TryParse(symbolName, out address))
+          {
+            if (devAISGen.InsertAISJumpClose(address) != retType.SUCCESS)
+            {
+              Console.WriteLine("WARNING: AIS Jump to {0} was not inserted.",symbolName);
+            }
+          }
+          else
+          {
+            if (devAISGen.InsertAISJumpClose(symbolName) != retType.SUCCESS)
+            {
+              Console.WriteLine("WARNING: AIS Jump to {0} was not inserted.",symbolName);
+            }
+          }
+        }
+      }
+      
+      else if (sec.sectionName.Equals("AIS_Set", StringComparison.OrdinalIgnoreCase))
+      {
+        UInt32 type     = 0x00000000;
+        UInt32 address  = 0x00000000;
+        UInt32 data     = 0x00000000;
+        UInt32 sleep    = 0x00000000;
+      
+        foreach (DictionaryEntry de in sec.sectionValues)
+        {
+          if (sec.sectionValues["TYPE"].GetType() == typeof(String))
+          {          
+            if (((String)de.Key).Equals("TYPE", StringComparison.OrdinalIgnoreCase))
+            {
+              if (! UInt32.TryParse((String)sec.sectionValues["TYPE"], out type))
+              {
+                try
+                {
+                  type = (UInt32)Enum.Parse(typeof(AisSetType),(String)sec.sectionValues["TYPE"]);
+                }
+                catch (ArgumentException e)
+                {
+                  Console.WriteLine((String)sec.sectionValues["TYPE"] + " is not allowed specifier for SET type.");
+                  Console.WriteLine(e.Message);
+                  return retType.FAIL;
+                }
+              }
+            }
+          }
+          else
+          {
+            type = (UInt32)sec.sectionValues["TYPE"];
+          }
+          if (((String)de.Key).Equals("ADDRESS", StringComparison.OrdinalIgnoreCase))
+          {
+            address = (UInt32)sec.sectionValues["ADDRESS"];
+          }
+          if (((String)de.Key).Equals("DATA", StringComparison.OrdinalIgnoreCase))
+          {
+            data = (UInt32)sec.sectionValues["DATA"];
+          }
+          if (((String)de.Key).Equals("SLEEP", StringComparison.OrdinalIgnoreCase))
+          {
+            sleep = (UInt32)sec.sectionValues["SLEEP"];
+          }
+          
+        }
+        devAISGen.InsertAISSet(type, address, data, sleep);
+      }
+      
+      else if (sec.sectionName.Equals("AIS_SectionFill", StringComparison.OrdinalIgnoreCase))
+      {
+        UInt32 address  = 0x00000000;
+        UInt32 size     = 0x00000000;
+        UInt32 type     = 0x00000000;
+        UInt32 pattern  = 0x00000000;
+      
+        foreach (DictionaryEntry de in sec.sectionValues)
+        {
+          if (((String)de.Key).Equals("ADDRESS", StringComparison.OrdinalIgnoreCase))
+          {
+            address = (UInt32)sec.sectionValues["ADDRESS"];
+          }
+          if (((String)de.Key).Equals("SIZE", StringComparison.OrdinalIgnoreCase))
+          {
+            size = (UInt32)sec.sectionValues["SIZE"];
+          }
+          if (((String)de.Key).Equals("TYPE", StringComparison.OrdinalIgnoreCase))
+          {
+            type = (UInt32)sec.sectionValues["TYPE"];
+          }
+          if (((String)de.Key).Equals("PATTERN", StringComparison.OrdinalIgnoreCase))
+          {
+            pattern = (UInt32)sec.sectionValues["PATTERN"];
+          }
+        }
+        devAISGen.InsertAISSectionFill( address, size, type, pattern);
+      }
+      
+      else if (sec.sectionName.Equals("AIS_FastBoot", StringComparison.OrdinalIgnoreCase))
+      {
+        devAISGen.InsertAISFastBoot();
+      }
+      
+      else if (sec.sectionName.Equals("AIS_ReadWait", StringComparison.OrdinalIgnoreCase))
+      {
+        UInt32 address  = 0x00000000;
+        UInt32 mask     = 0xFFFFFFFF;
+        UInt32 data     = 0xFFFFFFFF;
+      
+        foreach (DictionaryEntry de in sec.sectionValues)
+        {
+          if (((String)de.Key).Equals("ADDRESS", StringComparison.OrdinalIgnoreCase))
+          {
+            address = (UInt32)sec.sectionValues["ADDRESS"];
+          }
+          if (((String)de.Key).Equals("MASK", StringComparison.OrdinalIgnoreCase))
+          {
+            mask = (UInt32)sec.sectionValues["MASK"];
+          }
+          if (((String)de.Key).Equals("DATA", StringComparison.OrdinalIgnoreCase))
+          {
+            data = (UInt32)sec.sectionValues["DATA"];
+          }
+        }
+        devAISGen.InsertAISReadWait(address, mask, data);
+      }
+      
+      else if (sec.sectionName.Equals("AIS_SeqReadEnable", StringComparison.OrdinalIgnoreCase))
+      {
+        devAISGen.InsertAISSeqReadEnable();
+      }
+      
+      else if (sec.sectionName.Equals("AIS_FinalFunctionReg", StringComparison.OrdinalIgnoreCase))
+      {
+        String finalFxnName = "";
+        
+        foreach (DictionaryEntry de in sec.sectionValues)
+        {
+          if (((String)de.Key).Equals("FINALFXNSYMBOLNAME", StringComparison.OrdinalIgnoreCase))
+          {
+            finalFxnName = (String)sec.sectionValues["FINALFXNSYMBOLNAME"];
+          }
+        }
+        if (devAISGen.InsertAISFinalFxnReg(finalFxnName) != retType.SUCCESS)
+        {
+          Console.WriteLine("WARNING: Final function register AIS command failed.");
+        }
+      }
+      
+      else if ( (sec.sectionName.Equals("GENERAL", StringComparison.OrdinalIgnoreCase)) ||
+                (sec.sectionName.Equals("SECURITY", StringComparison.OrdinalIgnoreCase)) )
+      {
+        // Ignore General/Security section here since it should have already been processed
+      }
+      
+      else
+      {
+        // Any other sections names should be ignored with warning
+        Console.WriteLine("WARNING: Unrecognized INI section, {0}. Ignoring...", sec.sectionName );
+      }
+      
+      #endregion  
+    
+      return retType.SUCCESS;
+    }
+    
+    public static ObjectFile FindFileWithSymbol(AISGen devAISGen, String symbolName)
+    {
+      foreach (ObjectFile file in devAISGen.objectFiles)
+      {
+        if (file.symFind(symbolName) != null)
+        {
+          return file;
+        }
+      }
+      return null;
+    }
+    
+    public static ObjectSymbol FindSymbol(AISGen devAISGen, String symbolName)
+    {
+      ObjectSymbol sym = null;
+      foreach (ObjectFile file in devAISGen.objectFiles)
+      {
+        sym = file.symFind(symbolName);
+        if (sym != null) break;
+      }
+      return sym;
+    }
+    
+    public static ObjectFile FindObjectFile(AISGen devAISGen, String fileName)
+    {
+      foreach (ObjectFile file in devAISGen.objectFiles)
+      {
+        if (file.FileName.Equals(fileName))
+        {
+          return file;
+        }
+      }
+      return null;
+    }
+  #endregion
+    
+  #region Private Static Methods
+    private static void GeneralIniSectionParse(AISGen devAISGen, IniFile iniFile)
+    {
+      // Get data from the GENERAL INI Section
+      IniSection genSec = iniFile.GetSectionByName("General");
+      
+      foreach (DictionaryEntry de in genSec.sectionValues)
+      {
+        // Read buswidth
+        if (((String)de.Key).Equals("BUSWIDTH", StringComparison.OrdinalIgnoreCase))
+          devAISGen.busWidth = (UInt32)genSec.sectionValues["BUSWIDTH"];
+        
+        // Read BootMode (unless already set)
+        if ((((String)de.Key).Equals("BOOTMODE", StringComparison.OrdinalIgnoreCase)) && (devAISGen.bootMode == AisBootModes.NONE))
+          devAISGen.bootMode = (AisBootModes) Enum.Parse(typeof(AisBootModes), (String)genSec.sectionValues["BOOTMODE"], true);
+        
+        // Read Addr width (for I2C/SPI)
+        if (((String)de.Key).Equals("ADDRWIDTH", StringComparison.OrdinalIgnoreCase))
+        {
+          devAISGen.addrWidth = (UInt32)genSec.sectionValues["ADDRWIDTH"];
+        }
+        
+        // CRC Type override
+        if (((String)de.Key).Equals("CRCCheckType", StringComparison.OrdinalIgnoreCase))
+        {
+          devAISGen.AISCRCType = (AisCRCCheckType) Enum.Parse(typeof(AisCRCCheckType), (String)genSec.sectionValues["CRCCHECKTYPE"], true);
+        }
+        
+        // Read global entry point
+        if (((String)de.Key).Equals("ENTRYPOINT", StringComparison.OrdinalIgnoreCase))
+        {
+          devAISGen.entryPoint = (UInt32)genSec.sectionValues["ENTRYPOINT"];
+        }
+      }
+    }
+  
+    private static retType AISObjectFileLoad( AISGen devAISGen, ObjectFile file )
+    {
+      UInt32 loadedSectionCount = 0;
+    
+      // Check if object file already loaded
+      if (FindObjectFile(devAISGen,file.FileName) != null)
+      {
+        return retType.FAIL;
+      }
+      
+      // If this is a new file, let's add it to our list
+      devAISGen.objectFiles.Add(file);
+    
+      if (!devAISGen.devEndian.ToString().Equals(file.Endianness))
+      {
+        Console.WriteLine("Endianness mismatch. Device is {0} endian, Object file is {1} endian",
+            devAISGen.devEndian.ToString(),
+            file.Endianness);
+        return retType.FAIL;
+      }
+
+      // Make sure the .TIBoot section is first (if it exists)
+      ObjectSection firstSection = file.LoadableSections[0];
+      for (Int32 i = 1; i < file.LoadableSectionCount; i++)
+      {
+        if ((file.LoadableSections[i].name).Equals(".TIBoot"))
+        {
+          file.LoadableSections[0] = file.LoadableSections[i];
+          file.LoadableSections[i] = firstSection;
+          break;
+        }
+      }
+
+      // Enable CRC if needed
+      devAISGen.InsertAISEnableCRC();
+      
+      // Do all SECTION_LOAD commands
+      for (Int32 i = 0; i < file.LoadableSectionCount; i++)
+      {
+        if (AISSectionLoad(devAISGen, file, file.LoadableSections[i]) != retType.SUCCESS)
+        {
+          return retType.FAIL;
+        }
+        
+        // Check for need to do TIBoot initialization
+        if (loadedSectionCount == 0)
+        {
+          devAISGen.InsertAISJump("_TIBootSetup");
+        }
+        
+        loadedSectionCount++;
+      } 
+      // End of SECTION_LOAD commands
+      
+      // Now that we are done with file contents, we can close it
+      file.Close();
+      
+      return retType.SUCCESS;
+    }
+    
+    private static retType AISSectionLoad( AISGen devAISGen, ObjectFile file, ObjectSection section)
+    {
+      Byte[] secData = file.secRead(section);
+      Byte[] srcCRCData = new Byte[section.size + 8];
+      
+      Debug.DebugMSG("AISSectionLoad for section " + section.name + " from file " + file.FileName + ".");
+      
+      // If we are doing section-by-section CRC, then zero out the CRC value
+      if (devAISGen.aisCRCType == AisCRCCheckType.SECTION_CRC)
+      {
+        devAISGen.devCRC.ResetCRC();
+      }
+      
+      // Add section load to the output
+      devAISGen.InsertAISSectionLoad((UInt32) section.loadAddr, (UInt32) section.size, secData);
+
+      // Copy bytes to CRC byte array for future CRC calculation
+      if (devAISGen.aisCRCType != AisCRCCheckType.NO_CRC)
+      {
+        if (devAISGen.devEndian != devAISGen.devAISEndian)
+        {
+          Endian.swapEndian(BitConverter.GetBytes(section.loadAddr)).CopyTo(srcCRCData, 0);
+          Endian.swapEndian(BitConverter.GetBytes(section.size)).CopyTo(srcCRCData, 4);
+        }
+        else
+        {
+          BitConverter.GetBytes(section.loadAddr).CopyTo(srcCRCData, 0);
+          BitConverter.GetBytes(section.size).CopyTo(srcCRCData, 4);
+        }
+        
+      }
+
+      // Now write contents to CRC array
+      for (UInt32 k = 0; k < section.size; k+=4)
+      {
+        // Copy bytes to array for future CRC calculation
+        if (devAISGen.aisCRCType != AisCRCCheckType.NO_CRC)
+        {
+          Byte[] temp = new Byte[4];
+          Array.Copy(secData,k,temp,0,4);
+          if (devAISGen.devEndian != devAISGen.devAISEndian)
+          {
+            Endian.swapEndian(temp).CopyTo(srcCRCData, (8 + k));
+          }
+          else
+          {
+            temp.CopyTo(srcCRCData, (8 + k));
+          }
+        }
+      }
+        
+      // Add this section's memory range, checking for overlap
+      AddMemoryRange(devAISGen, (UInt32) section.loadAddr, (UInt32) (section.loadAddr+section.size-1));
+
+      // Perform CRC calculation of the section's contents
+      if (devAISGen.aisCRCType != AisCRCCheckType.NO_CRC)
+      {
+        devAISGen.devCRC.CalculateCRC(srcCRCData);
+        if (devAISGen.aisCRCType == AisCRCCheckType.SECTION_CRC)
+        {
+          // Write CRC request command, value, and jump value to temp AIS file
+          devAISGen.InsertAISRequestCRC(((Int32)(-1) * (Int32)(section.size + 12 + 12)));
+        }
+      }
+
+      return retType.SUCCESS;
+    }
+    
+    private static void AddMemoryRange(AISGen devAISGen, UInt32 startAddr, UInt32 endAddr)
+    {
+      // Cycle through entire list looking for overlaps
+      foreach (MemoryRange m in devAISGen.sectionMemory)
+      {
+        // Three issues:
+        //   1) Both fall in occupied memory        
+        //   2) Input startAddr falls in occuppied memory, input endAddr does not
+        //   3) Input endAddr falls in occuppied memory
+        if ( ( (startAddr >= m.startAddr) && (startAddr <= m.endAddr) ) && ( (endAddr >= m.startAddr) && (endAddr <= m.endAddr) ) )
+        {
+          Console.WriteLine("WARNING: Memory overlap from 0x{0:X8} to 0x{1:X8}.",startAddr, endAddr);
+          continue;
+        }
+        
+        if ( (startAddr >= m.startAddr) && (startAddr <= m.endAddr) && (endAddr > m.endAddr) )
+        {
+          Console.WriteLine("WARNING: Memory overlap from 0x{0:X8} to 0x{1:X8}.",startAddr, m.endAddr);
+          continue;
+        }
+        
+        if ( (startAddr < m.startAddr) && (endAddr >= m.startAddr) && (endAddr <= m.endAddr) )
+        {
+          Console.WriteLine("WARNING: Memory overlap from 0x{0:X8} to 0x{1:X8}.",m.startAddr, endAddr);
+          continue;
+        }
+      }
+      
+      // Add the MemoryRange for this section to the list
+      devAISGen.sectionMemory.Add(new MemoryRange(startAddr,endAddr));
+    }
+  #endregion
+  
+  }                    
+} //end of AISGenLib namespace
+
diff --git a/tools/omapl13x_boot_utils/Common/AIS/AISParse.cs b/tools/omapl13x_boot_utils/Common/AIS/AISParse.cs
new file mode 100644 (file)
index 0000000..6156ea2
--- /dev/null
@@ -0,0 +1,865 @@
+/*
+ * AISParse.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+// ======================================================================= 
+//  TEXAS INSTRUMENTS, INC.                                                
+// ----------------------------------------------------------------------- 
+//                                                                         
+// AIS_Util_SEC.cs -- Implements AIS_Parser class for secure boot (C#)
+//                                                                         
+// Rev 0.0.1                                                               
+//                                                                         
+//  USAGE                                                                  
+//      Include AIS_Util namespace in your project and use the following
+//      constructor:
+//                                                                         
+//          AIS_Parser parser = new AIS_Parser
+//                                  (
+//                                      AIS_Parser.AIS_<bootPeripheral>,
+//                                      FxnDelegate_msg_log,
+//                                      FxnDelegate_<bootPeripheral>_read,
+//                                      FxnDelegate_<bootPeripheral>_write
+//                                  );
+//
+//      Call parsing function using the contents of a binary AIS file
+//      stored in a Byte array:
+//
+//          parser.boot(ais_file_contents);
+//                                                                         
+//  DESCRIPTION                                                            
+//      Parses a binary AIS file passed in as a Byte array.  Uses external
+//      functions (passed as delegates) for I/O read and write and message
+//      logging.  Performs all host operations as described in "Using the
+//      D800K001 Bootloader" application note for I2C slave, SPI slave, and
+//      UART boot modes.
+//                                                                         
+// ----------------------------------------------------------------------- 
+//            Copyright (c) 2009 Texas Instruments, Incorporated.          
+//                           All Rights Reserved.                          
+// ======================================================================= 
+
+// Security mode (default: custom secure)
+//#define AIS_GENERIC_SECURE
+
+/****************************************************************
+ *  TI AIS Parsing Class
+ *  (C) 2007-2009, Texas Instruments, Inc.                           
+ *                                                              
+ * Author:  Joseph Coombs (minor updates by Daniel Allred)
+ *                                                              
+ ****************************************************************/
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading;
+using TI.AISLib;
+
+namespace TI.AISLib
+{
+  // host function delegates (rx, tx, log)
+  delegate AisStatus ReadFxnDelegate(Byte[] rcvBuf, Int32 index, Int32 rcvSize, Int32 timeout);
+  delegate AisStatus WriteFxnDelegate(Byte[] xmtBuf, Int32 index, Int32 xmtSize, Int32 timeout);
+  delegate void LogFxnDelegate(String line);
+  class AIS_Parser
+  {
+    // Public data members
+    public Int32 posN, ioBits, ioDelay, opcodeDelay, ioTimeout;
+    public bool waitBOOTME;
+
+    // Private members
+    private AisSecureType secureType;
+    private AisHostType hostDevice;
+    private ReadFxnDelegate readFxn;
+    private WriteFxnDelegate writeFxn;
+    private LogFxnDelegate logFxn;
+    private Int32 sigSize;
+
+    // Public Constructor
+    public AIS_Parser(AisHostType hostType, AisSecureType secType, LogFxnDelegate hostLogFxn, ReadFxnDelegate hostReadFxn, WriteFxnDelegate hostWriteFxn)
+    {
+      // apply specified params
+      this.hostDevice = hostType;
+      this.readFxn = hostReadFxn;
+      this.writeFxn = hostWriteFxn;
+      this.logFxn = hostLogFxn;
+      this.secureType = secType;
+
+      // use defaults for others
+      posN = 2;
+      ioBits = 8;
+      ioDelay = 0;
+      opcodeDelay = 5;
+      ioTimeout = 5000; // 5s
+      waitBOOTME = true;
+      
+      if (secureType == AisSecureType.GENERIC)
+      {
+        sigSize = 32;
+      }
+      else if (secureType == AisSecureType.CUSTOM)
+      {
+        sigSize = 128; // default to RSA1024 to start
+      }
+      else
+      {
+        sigSize = 0;
+      }
+    }
+
+    // Private utility functions (were C macros)
+    private UInt32 AIS_XMT_START(Int32 bits)
+    {
+      // return (bits) MSBs or AIS start word
+      return ((UInt32)AisOps.XmtStartWord) >> (32 - bits);
+    }
+
+    private UInt32 AIS_RCV_START(Int32 bits)
+    {
+      // return (bits) MSBs or AIS start word ACK
+      return ((UInt32)AisOps.RcvStartWord) >> (32 - bits);
+    }
+
+    private UInt32 AIS_opcode2ack(UInt32 opcode)
+    {
+      // return opcode ACK
+      return (opcode & 0xF0FFFFFF) | 0x02000000;
+    }
+
+    private Int32 LOCAL_roundUpTo(Int32 num, Int32 mod)
+    {
+      // round (num) up to nearest multiple of (mod)
+      return ( (num + (mod - 1)) / mod * mod);
+    }
+
+    private UInt32 LOCAL_b2UInt32(Byte[] ba)
+    {
+      // convert Byte array to UInt32 with little endian order
+      return (UInt32)ba[0] + ((UInt32)ba[1] << 8) + ((UInt32)ba[2] << 16) + ((UInt32)ba[3] << 24);
+    }
+
+    private Byte[] LOCAL_UInt322b(UInt32 ui)
+    {
+      // convert UInt32 to Byte array with little endian order
+      Byte[] ba = new Byte[4];
+      ba[0] = (Byte)(ui & 0xFF);
+      ba[1] = (Byte)((ui >> 8) & 0xFF);
+      ba[2] = (Byte)((ui >> 16) & 0xFF);
+      ba[3] = (Byte)((ui >> 24) & 0xFF);
+      return ba;
+    }
+
+    private void LOCAL_delay(Int32 N)
+    {
+      Thread.Sleep(N);
+    }
+      
+    // Start Word Sync Function
+    private AisStatus AIS_SWS()
+    {
+      UInt32 rcvWord = 0;
+      Byte[] rcvWordB = new Byte[4];
+      UInt32 xmtWord = AIS_XMT_START(ioBits);
+      AisStatus status = AisStatus.IN_PROGRESS;
+
+      while (true)
+      {
+        // send xmt start
+        status |= LOCAL_bufWrite(LOCAL_UInt322b(xmtWord), 0, ioBits / 8, ioTimeout);
+        if (status < 0)
+        {
+          status = 0;
+          LOCAL_delay(opcodeDelay);
+          continue;
+        }
+
+        // receive word
+        status |= LOCAL_bufRead(rcvWordB, 0, ioBits / 8, ioTimeout);
+        rcvWord = LOCAL_b2UInt32(rcvWordB);
+
+        // fail on IO error
+        if (status < 0)
+        {
+          return AisStatus.ERROR;
+        }
+
+        // break if word is rcv start
+        if (rcvWord == AIS_RCV_START(ioBits))
+        {
+                break;
+        }
+      }
+
+      return AisStatus.IN_PROGRESS;
+    }
+    
+    private AisStatus AIS_POS(UInt32 command)
+    {
+        UInt32 xmtWord = command;
+        UInt32 rcvWord;
+        Byte[] rcvWordB = new Byte[4];
+        AisStatus status;
+        Int32  i;
+
+        // 1. send ping
+        status = LOCAL_bufWrite(LOCAL_UInt322b(xmtWord), 0, 4, ioTimeout);
+        // receive pong
+        status |= LOCAL_bufRead(rcvWordB, 0, 4, ioTimeout);
+        rcvWord = LOCAL_b2UInt32(rcvWordB);
+
+        // fail on improper response or IO error
+        if (rcvWord != AIS_opcode2ack(xmtWord) || status < 0)
+            return AisStatus.ERROR;
+
+        LOCAL_delay(opcodeDelay);
+
+        // 2. send N
+        xmtWord = (UInt32)posN;
+        // send ping
+        status |= LOCAL_bufWrite(LOCAL_UInt322b(xmtWord), 0, 4, ioTimeout);
+        // receive pong
+        status |= LOCAL_bufRead(rcvWordB, 0, 4, ioTimeout);
+        rcvWord = LOCAL_b2UInt32(rcvWordB);
+
+        // fail on improper response or IO error
+        if (rcvWord != posN || status < 0)
+        {
+          return AisStatus.ERROR;
+        }
+
+        // 3. send/receive numerical sequence
+        for (i = 1; i <= posN; i++)
+        {
+          LOCAL_delay(opcodeDelay);
+
+          xmtWord = (UInt32)i;
+          status |= LOCAL_bufWrite(LOCAL_UInt322b(xmtWord), 0, 4, ioTimeout);
+          status |= LOCAL_bufRead(rcvWordB, 0, 4, ioTimeout);
+          rcvWord = LOCAL_b2UInt32(rcvWordB);
+
+          // fail on improper response or IO error
+          if (rcvWord != xmtWord || status < 0)
+          {
+            return AisStatus.ERROR;
+          }
+        }
+
+        return AisStatus.IN_PROGRESS;
+    }
+
+    private AisStatus AIS_OS(UInt32 command)
+    {
+      UInt32 xmtWord = command;
+      UInt32 rcvWord = 0;
+      Byte[] rcvWordB = new Byte[4];
+      AisStatus status = AisStatus.IN_PROGRESS;
+      Int32 retryCnt = 0;
+      Int32 retryCntMax = 10;
+
+      while (true)
+      {
+        // send ping
+        status |= LOCAL_bufWrite(LOCAL_UInt322b(xmtWord), 0, 4, ioTimeout);
+        // receive pong
+        if (status >= 0)
+        {
+          status |= LOCAL_bufRead(rcvWordB, 0, 4, ioTimeout);
+          rcvWord = LOCAL_b2UInt32(rcvWordB);
+        }
+
+        // fail on IO error
+        if (status < 0)
+        {
+          LOCAL_delay(opcodeDelay);
+          if (retryCnt++ >= retryCntMax)
+          {
+            logFxn(String.Format("(AIS Parse): Opcode Sync failed after {0} consecutive I/O failures.", retryCnt));
+            return AisStatus.ERROR;
+          }
+
+          // send zero word (32 bits) to clear potentially corrupted state on target
+          status |= LOCAL_bufWrite(LOCAL_UInt322b(0), 0, 4, ioTimeout);
+
+          status = 0;
+          continue;
+        }
+
+        // pass on proper response
+        if (rcvWord == AIS_opcode2ack(xmtWord))
+        {
+          if (retryCnt > 0)
+          {
+            logFxn( String.Format("(AIS Parse): Opcode Sync passed after {0} consecutive I/O failures.", retryCnt) );
+          }
+          return AisStatus.IN_PROGRESS;
+        }
+      }
+    }
+
+    // Read Int32 (4 Bytes) and advance cursor
+    private UInt32 LOCAL_parseInt(Byte[] ais, ref Int32 cursor)
+    {
+      UInt32 token = 0;
+
+      token = BitConverter.ToUInt32(ais, cursor);
+      cursor += 4;
+      
+      return token;
+    }
+
+    // Advance cursor arbitrary number of Bytes (ignore data)
+    private void LOCAL_parseSkip(ref Int32 cursor, Int32 n)
+    {
+      cursor += n;
+    }
+
+    private AisStatus LOCAL_bufRead(Byte[] buffer, Int32 index, Int32 Bytes, Int32 timeout)
+    {
+      Int32 rcvSize = ioBits / 8;
+      AisStatus status = AisStatus.IN_PROGRESS;
+
+        // check that we can read specified Byte count cleanly
+        if (Bytes % rcvSize != 0)
+        {
+            logFxn( String.Format("(AIS Parse): Cannot read {0} Bytes in chunks of {1}!", Bytes, rcvSize) );
+            return AisStatus.ERROR;
+        }
+
+      // perform IO transaction in N-bit "bites"
+      for (Int32 i = 0; i < Bytes / rcvSize; i++)
+      {
+        status |= readFxn(buffer, index + i * rcvSize, rcvSize, timeout);
+        LOCAL_delay(ioDelay);
+
+        if (status < 0)
+        {
+          logFxn("(AIS Parse): I/O Error in read!");
+          break;
+        }
+      }
+
+      return status;
+    }
+
+    private AisStatus LOCAL_bufWrite(Byte[] buffer, Int32 index, Int32 Bytes, Int32 timeout)
+    {
+      Int32 xmtSize = ioBits / 8;
+      AisStatus status = AisStatus.IN_PROGRESS;
+
+      // check that we can write specified Byte count cleanly
+      if (Bytes % xmtSize != 0)
+      {
+        logFxn( String.Format("(AIS Parse): Cannot write {0} Bytes in chunks of {1}!", Bytes, xmtSize) );
+        return AisStatus.ERROR;
+      }
+      
+      // perform IO transaction in N-bit "bites"
+      for (Int32 i = 0; i < Bytes / xmtSize; i++)
+      {
+        status |= writeFxn(buffer, index + i * xmtSize, xmtSize, timeout);
+        LOCAL_delay(ioDelay);
+
+        if (status < 0)
+        {
+          logFxn("(AIS Parse): I/O Error in write!");
+          break;
+        }
+      }
+
+      return status;
+    }
+
+    // Public boot loading function
+    public AisStatus boot(Byte[] AIS_Contents)
+    {
+      Int32 AIS_Cursor = 0;
+      UInt32 command, addr, size, type,
+           sleep, data, crc, crcGuess,
+           seek, exp, mask, val,
+           args;
+      Byte[] crcGuessB = new Byte[4];
+      Int32 i;
+      Int32 BytesLeft;
+      AisStatus status;
+      Int32 opsRead = 0;
+      bool secureMode = false;
+
+      // check for magic word first
+      command = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+      status = (command == (UInt32) AisOps.MagicNumber) ? AisStatus.IN_PROGRESS : AisStatus.ERROR;
+      logFxn(String.Format("(AIS Parse): Read magic word 0x{0:X8}.", command));
+
+      // UART only: read "BOOTME "
+      if ((status == AisStatus.IN_PROGRESS) && (hostDevice == AisHostType.UART) && waitBOOTME)
+      {
+        Byte[] rcvInit = new Byte[1];
+        Byte[] corInit = { (Byte)'B', (Byte)'O', (Byte)'O', (Byte)'T',
+                                 (Byte)'M', (Byte)'E', (Byte)' ', (Byte)0 };
+
+        logFxn("(AIS Parse): Waiting for BOOTME... (power on or reset target now)");
+        //status = readFxn(rcvInit, 0, 8, -1);
+
+        BytesLeft=7;
+        while(true) 
+        {
+            status = readFxn(rcvInit, 0, 1, -1);
+
+            //Allow for leading NULL character
+            if (BytesLeft == 7 && rcvInit[0] == (Byte)0) 
+            {
+                continue;
+            }        
+
+            //Exit after trailing NULL character received
+            if (BytesLeft == 0 && rcvInit[0] == (Byte)0)
+            {
+                break;
+            }
+
+            //Error if read something other than 'BOOTME'
+            else if (rcvInit[0] != corInit[7 - BytesLeft])
+            {
+                logFxn("(AIS Parse): Read invalid BOOTME string.");
+                status = AisStatus.ERROR;
+                break;
+            }
+            else
+            {
+                BytesLeft--;
+            }
+        }
+        // report if correct BOOTME is received
+        if (status == AisStatus.IN_PROGRESS)
+            logFxn("(AIS Parse): BOOTME received!");
+      }
+      
+      while (status == AisStatus.IN_PROGRESS)
+      {
+        // perform synchronization on first pass
+        if (opsRead == 0)
+        {
+          // perform SWS
+          logFxn("(AIS Parse): Performing Start-Word Sync...");
+          status = AIS_SWS();
+          if (status == AisStatus.ERROR)
+          {
+            break;    // fail if SWS fails
+          }
+
+          // perform POS
+          logFxn("(AIS Parse): Performing Ping Opcode Sync...");
+          status = AIS_POS((UInt32)AisOps.Ping);
+          if (status == AisStatus.ERROR)
+          {
+            continue;  // retry SWS if POS fails
+          }
+        }
+
+        // delay; give bootloader a chance to process previous command
+        LOCAL_delay(opcodeDelay);
+
+        // read a command
+        command = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+        logFxn( String.Format("(AIS Parse): Processing command {0}: 0x{1:X8}.", opsRead, command) );
+        opsRead++;
+
+        // perform Op-code sync
+        logFxn("(AIS Parse): Performing Opcode Sync...");
+        status = AIS_OS(command);
+
+        //
+        if (status == AisStatus.ERROR)
+          break;    // fail if OS fails
+
+        switch((AisOps)command)
+        {
+          case AisOps.Set:
+            logFxn("(AIS Parse): Loading boot table...");
+            // read: type, addr, data, sleep
+            type = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            addr = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            data = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            sleep = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            // send: type, addr, data, sleep
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(type), 0, 4, ioTimeout);
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(addr), 0, 4, ioTimeout);
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(data), 0, 4, ioTimeout);
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(sleep), 0, 4, ioTimeout);
+            if (secureMode)
+            {
+              // secure mode: send key (custom secure: 128 Bytes; generic secure: 32 Bytes)
+              status |= LOCAL_bufWrite(AIS_Contents, AIS_Cursor, sigSize, ioTimeout);
+              LOCAL_parseSkip(ref AIS_Cursor, sigSize);
+              logFxn("(AIS Parse): Secure mode; sending signature.");
+            }
+            break;
+
+          case AisOps.SeqReadEnable:
+            // no extra IO required
+            logFxn("(AIS Parse): No slave memory present; Sequential Read Enable has no effect.");
+            break;
+
+          case AisOps.Section_Load:
+          case AisOps.CmpSection_Load:
+            logFxn("(AIS Parse): Loading section...");
+            // send address
+            addr = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(addr), 0, 4, ioTimeout);
+            // send size
+            size = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(size), 0, 4, ioTimeout);
+            // send data
+            status |= LOCAL_bufWrite(AIS_Contents, AIS_Cursor, LOCAL_roundUpTo((Int32)size, 4), ioTimeout);
+                    LOCAL_parseSkip(ref AIS_Cursor, LOCAL_roundUpTo((Int32)size, 4));
+            logFxn( String.Format("(AIS Parse): Loaded {0}-Byte section to address 0x{1:X8}.", size, addr) );
+                    break;
+
+          case AisOps.Section_Fill:
+            logFxn("(AIS Parse): Filling section...");
+            // send address
+            addr = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(addr), 0, 4, ioTimeout);
+            // send size
+            size = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(size), 0, 4, ioTimeout);
+            // send type
+            type = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(type), 0, 4, ioTimeout);
+            // send pattern (data)
+            data = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(data), 0, 4, ioTimeout);
+            logFxn( String.Format("(AIS Parse): Filled {0}-Byte section with pattern 0x{1:X8}.", size, data) );
+            break;
+
+          case AisOps.SecureKeyLoad:
+            logFxn("(AIS Parse): Secure key loading, entering secure mode.");
+
+            // If custom secure device, get sigSize from key data
+            if (secureType == AisSecureType.CUSTOM)
+            {
+              // Send exponent
+              exp = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+              status |= LOCAL_bufWrite(LOCAL_UInt322b(exp), 0, 4, ioTimeout);
+              
+              // Send modulus size
+              size = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+              status |= LOCAL_bufWrite(LOCAL_UInt322b(size), 0, 4, ioTimeout);
+              // NOTE: use only upper half; value listed in 2-Byte chunks (convert to Bytes)
+              size = (size >> 16) * 2;
+              
+              // Update signature size based on modulus size
+              sigSize = (Int32) size;
+              
+            }
+            else if (secureType == AisSecureType.GENERIC)
+            {
+              size = (UInt32) sigSize;
+            }
+            else
+            {
+              size = 0;
+            }
+
+
+            // Send key data (modulus for Custom, key header for Generic)
+            status |= LOCAL_bufWrite(AIS_Contents, AIS_Cursor, (Int32)size, ioTimeout);
+            LOCAL_parseSkip(ref AIS_Cursor, (Int32)size);
+            // enable secure mode
+            secureMode = true;
+            break;
+
+          case AisOps.SecSection_Load:
+            logFxn("(AIS Parse): Loading secure section...");
+            // send address
+            addr = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(addr), 0, 4, ioTimeout);
+            // send size
+            size = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(size), 0, 4, ioTimeout);
+            // send reserved word
+            val = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(val), 0, 4, ioTimeout);
+            // send data
+                    status |= LOCAL_bufWrite(AIS_Contents, AIS_Cursor, LOCAL_roundUpTo((Int32)size, 4), ioTimeout);
+                    LOCAL_parseSkip(ref AIS_Cursor, LOCAL_roundUpTo((Int32)size, 4));
+            logFxn( String.Format("(AIS Parse): Loaded {0}-Byte section to address 0x{1:X8}.", size, addr) );
+            break;
+
+          case AisOps.EncSection_Load:
+            if (!secureMode)
+            {
+              logFxn( String.Format("Secure opcode (0x{0:X8}), not allowed.", command) );
+              status = AisStatus.ERROR;
+              break;
+            }
+          
+            logFxn("(AIS Parse): Loading encoded section...");
+            // send address
+            addr = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(addr), 0, 4, ioTimeout);
+            // send size
+            size = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(size), 0, 4, ioTimeout);
+            
+
+#if AIS_D800K001
+            // send reserved word
+            val = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(val), 0, 4, ioTimeout);
+            // send data
+                    status |= LOCAL_bufWrite(AIS_Contents, AIS_Cursor, (Int32)LOCAL_roundUpTo((Int32)size, 16), ioTimeout);
+                    LOCAL_parseSkip(ref AIS_Cursor, LOCAL_roundUpTo((Int32)size, 16));
+#else
+            // AIS contains at least 16 Bytes
+            if (size < 16) size = 16;
+            // send data
+            status |= LOCAL_bufWrite(AIS_Contents, AIS_Cursor, (Int32)size, ioTimeout);
+            LOCAL_parseSkip(ref AIS_Cursor, (Int32)size);
+#endif
+            logFxn( String.Format("(AIS Parse): Loaded {0}-Byte section to address 0x{1:X8}.", size, addr) );
+            break;
+
+          case AisOps.SetSecExitMode:
+            if (!secureMode)
+            {
+              logFxn( String.Format("Secure opcode (0x{0:X8}), not allowed.", command) );
+              status = AisStatus.ERROR;
+              break;
+            }
+            logFxn("(AIS Parse): Setting boot exit mode...");
+            // send mode value (32-bit)
+            val = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(val), 0, 4, ioTimeout);
+            logFxn( String.Format("(AIS Parse): Set exit mode to 0x{0:X8}.", val) );
+            break;
+
+          case AisOps.DisableCRC:
+            // no extra IO required
+            logFxn("(AIS Parse): CRC disabled.");
+            break;
+
+          case AisOps.EnableCRC:
+            // no extra IO required
+            logFxn("(AIS Parse): CRC enabled.");
+            break;
+
+          case AisOps.RequestCRC:
+            logFxn("(AIS Parse): Requesting CRC...");
+            // read computed CRC
+            status |= LOCAL_bufRead(crcGuessB, 0, 4, ioTimeout);
+                    crcGuess = LOCAL_b2UInt32(crcGuessB);
+            crc = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            if (crcGuess == crc)
+            {
+              // CRC succeeded.  Skip seek value to reach next opcode
+              logFxn("(AIS Parse): CRC passed!");
+              LOCAL_parseSkip(ref AIS_Cursor, 4);
+            }
+            else
+            {
+              // CRC error; send startover opcode and seek AIS
+              logFxn("(AIS Parse): CRC failed!  Sending STARTOVER...");
+              status |= AIS_OS((UInt32)AisOps.Start_Over);
+              // seek AIS
+              seek = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+              logFxn( String.Format("(AIS Parse): {0}-Byte seek applied.", seek) );
+                        LOCAL_parseSkip(ref AIS_Cursor, (Int32)seek);
+            }
+            break;
+            
+          case AisOps.ReadWait:
+            logFxn("(AIS Parse): Performing read-wait...");
+            // send address
+            addr = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(addr), 0, 4, ioTimeout);
+            // send mask
+            mask = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(mask), 0, 4, ioTimeout);
+            // send value
+            val = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(val), 0, 4, ioTimeout);
+            if (secureMode)
+            {
+              // secure mode: send key
+              status |= LOCAL_bufWrite(AIS_Contents, AIS_Cursor, sigSize, ioTimeout);
+              LOCAL_parseSkip(ref AIS_Cursor, sigSize);
+              logFxn("(AIS Parse): Secure mode; sending signature.");
+            }
+            break;
+
+          case AisOps.FunctionExec:
+            logFxn("(AIS Parse): Executing function...");
+            // send function number and number of arguments
+            args = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(args), 0, 4, ioTimeout);
+            args = (args & 0xFFFF0000) >> 16;
+            for (i = 0; i < args; i++)
+            {
+              // send arg i
+              val = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+              status |= LOCAL_bufWrite(LOCAL_UInt322b(val), 0, 4, ioTimeout);
+            }
+            if (secureMode)
+            {
+              // secure mode: send key
+              status |= LOCAL_bufWrite(AIS_Contents, AIS_Cursor, sigSize, ioTimeout);
+              LOCAL_parseSkip(ref AIS_Cursor, sigSize);
+              logFxn("(AIS Parse): Secure mode; sending signature.");
+            }
+            break;
+
+          case AisOps.Jump:
+            logFxn("(AIS Parse): Performing jump...");
+            // send address
+            addr = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(addr), 0, 4, ioTimeout);
+            if (secureMode)
+            {
+              // secure mode: send key
+              status |= LOCAL_bufWrite(AIS_Contents, AIS_Cursor, sigSize, ioTimeout);
+              LOCAL_parseSkip(ref AIS_Cursor, sigSize);
+              logFxn("(AIS Parse): Secure mode; sending signature.");
+            }
+            // TODO:  wait?
+            logFxn( String.Format("(AIS Parse): Jump to address 0x{0:X8}.", addr) );
+            break;
+
+          case AisOps.Jump_Close:
+            logFxn("(AIS Parse): Performing jump and close...");
+            // send address
+            addr = LOCAL_parseInt(AIS_Contents, ref AIS_Cursor);
+            status |= LOCAL_bufWrite(LOCAL_UInt322b(addr), 0, 4, ioTimeout);
+            if (secureMode)
+            {
+              // secure mode: send signature
+              status |= LOCAL_bufWrite(AIS_Contents, AIS_Cursor, sigSize, ioTimeout);
+              LOCAL_parseSkip(ref AIS_Cursor, sigSize);
+              logFxn("(AIS Parse): Secure mode; sending signature.");
+            }
+            // parsing complete
+            status = AisStatus.COMPLETE;
+            logFxn( String.Format("(AIS Parse): AIS complete. Jump to address 0x{0:X8}.", addr) );
+            break;
+
+          case AisOps.Start_Over:
+            // control should never pass here; opcode is not present in AIS files
+            break;
+          
+          case AisOps.SetDelegateKey:
+            if (!secureMode)
+            {
+              logFxn( String.Format("Secure opcode (0x{0:X8}), not allowed.", command) );
+              status = AisStatus.ERROR;
+              break;
+            }
+            
+            logFxn("(AIS Parse): Setting Delegate Key...");
+            
+            // secure mode: send key Certificate
+            status |= LOCAL_bufWrite(AIS_Contents, AIS_Cursor, sigSize + 48, ioTimeout);
+            LOCAL_parseSkip(ref AIS_Cursor, sigSize + 48);
+            logFxn("(AIS Parse): Secure mode - sending delegate key certificate .");
+            
+            // secure mode: send signature
+            status |= LOCAL_bufWrite(AIS_Contents, AIS_Cursor, sigSize, ioTimeout);
+            LOCAL_parseSkip(ref AIS_Cursor, sigSize);
+            logFxn("(AIS Parse): Secure mode - sending signature.");
+            
+            break;
+            
+          case AisOps.RemDelegateKey:
+            if (!secureMode)
+            {
+              logFxn( String.Format("Secure opcode (0x{0:X8}), not allowed.", command) );
+              status = AisStatus.ERROR;
+              break;
+            }
+            logFxn("(AIS Parse): Removing Delegate Key.");
+            break;
+
+          // Unrecognized opcode
+          default:
+            logFxn( String.Format("(AIS Parse): Unhandled opcode (0x{0:X8}).", command) );
+            status = AisStatus.ERROR;
+                    break;
+        }
+      }
+
+      // UART only: read "   DONE"
+      if ((status == AisStatus.COMPLETE) && (hostDevice == AisHostType.UART))
+      {
+        Byte[] rcvEnd = new Byte[8];
+        Byte[] corEnd = { (Byte)' ', (Byte)' ', (Byte)' ', (Byte)'D',
+                              (Byte)'O', (Byte)'N', (Byte)'E', (Byte)0 };
+
+        logFxn("(AIS Parse): Waiting for DONE...");
+        status = readFxn(rcvEnd, 0, 8, -1);
+
+        // fail on incorrect sequence or IO error
+        for (i = 0; i < 7; i++)
+        {
+          if (rcvEnd[i] != corEnd[i])
+          {
+            logFxn("(AIS Parse): Read invalid DONE string.");
+            status = AisStatus.ERROR;
+            break;
+          }
+        }
+        
+        if (status != AisStatus.ERROR)
+        {
+          // success
+          status = AisStatus.COMPLETE;
+        }
+      }            
+
+      if (status == AisStatus.COMPLETE)
+      {
+        logFxn("(AIS Parse): Boot completed successfully.");
+      }
+      else
+      {
+        logFxn("(AIS Parse): Boot aborted.");
+      }
+      return status;
+    }
+
+
+  }
+}
diff --git a/tools/omapl13x_boot_utils/Common/AIS/HexAIS_version.cs b/tools/omapl13x_boot_utils/Common/AIS/HexAIS_version.cs
new file mode 100644 (file)
index 0000000..981c192
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * HexAIS_version.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+/* --------------------------------------------------------------------------
+    FILE        : HexAIS_version.cs
+    PURPOSE     : TI Booting and Flashing Utilities
+    AUTHOR      : Daniel Allred
+    DESC        : Common Version file for various HexAIS tools
+ ----------------------------------------------------------------------------- */
+
+using System;
+using System.Text;
+using System.IO;
+using System.Globalization;
+using System.Reflection;
+using System.Collections;
+using System.Collections.Generic;
+
+using TI.AISLib;
+using TI.UtilLib;
+using TI.UtilLib.IO;
+using TI.UtilLib.Ini;
+using TI.UtilLib.HexConv;
+
+[assembly: AssemblyTitle("HexAIS")]
+[assembly: AssemblyVersion("1.27.*")]
+
+namespace TIBootAndFlash
+{
+  partial class Program
+  {
+    static System.Version GetVersion()
+    {
+      // Assumes that in AssemblyInfo.cs, the version is specified as 1.0.* or the like,
+      // with only 2 numbers specified;  the next two are generated from the date.
+      return (System.Reflection.Assembly.GetExecutingAssembly().GetName().Version);
+    }
+    
+    static Int32 GetBuildYear()
+    {
+      System.Version v = GetVersion();
+      return (new DateTime( v.Build * TimeSpan.TicksPerDay + v.Revision * TimeSpan.TicksPerSecond * 2 ).AddYears(1999).Year);   
+    }
+  }
+}
diff --git a/tools/omapl13x_boot_utils/Common/UtilLib/ASN1.cs b/tools/omapl13x_boot_utils/Common/UtilLib/ASN1.cs
new file mode 100644 (file)
index 0000000..12e89bb
--- /dev/null
@@ -0,0 +1,569 @@
+/*
+ * ASN1.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.IO.Ports;
+using System.Reflection;
+using System.Security.Cryptography;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading;
+
+using TI.UtilLib.IO;
+
+namespace TI.UtilLib
+{
+  // Public Enums for ASN1 class
+  public enum Asn1TagClass : uint
+  {
+    UNIVERSAL = 0x00,
+    APPLICATION = 0x01,
+    CONTEXT_SPECIFIC = 0x02,
+    PRIVATE = 0x03
+  }
+  
+  public enum Asn1TagType : uint
+  {
+    PRIMITIVE = 0x00,
+    CONSTRUCTED = 0x01
+  }
+
+  public enum Asn1TagNumber : uint
+  {
+    EOC             = 0x00,
+    BOOLEAN         = 0x01,
+    INTEGER         = 0x02,
+    BITSTRING       = 0x03,
+    OCTETSTRING     = 0x04,
+    NULL            = 0x05,
+    OID             = 0x06,
+    OBJ_DESCRIPTOR  = 0x07,
+    EXTERNAL        = 0x08,
+    REAL            = 0x09,
+    ENUMERATED      = 0x0A,
+    EMBEDDED_PDV    = 0x0B,
+    UTF8STRING      = 0x0C,
+    RELATIVE_OID    = 0x0D,
+    SEQUENCE        = 0x10,
+    SET             = 0x11,
+    PRINTABLESTRING = 0x13,
+    T61STRING       = 0x14,
+    IA5STRING       = 0x16,
+    UTCTIME         = 0x17,
+    HIGHNUMBER      = 0x1F
+  }
+  
+  public enum Asn1LengthType : uint
+  {
+    SHORT = 0x00,
+    LONG_DEFINITE  = 0x01,
+    LONG_INDEFINITE = 0x03
+  }
+
+  
+  // Base ASN.1 Octet Field class - used as base for Tag and Length classes
+  public class Asn1OctetField
+  {
+    // Private members
+    private Byte[] octets;  
+    private UInt32 octetFieldLength;
+    
+    // Public properties/indexer
+    public Byte this [int index]
+    {
+      get { return octets[index]; }
+    }
+    
+    public UInt32 OctetFieldLength
+    {
+      get { return octetFieldLength; }
+    }
+    
+    // Public constructors
+    public Asn1OctetField() : this((UInt32) 0)
+    {
+      octets = new Byte[16];
+    }
+    
+    public Asn1OctetField(UInt32 length)
+    {
+      octetFieldLength = length;
+      octets = new Byte[length];
+    }
+    
+    // Protected read byte function
+    protected Byte ReadByte(Stream dataStream)
+    {
+      Byte b = Convert.ToByte(dataStream.ReadByte());
+      octetFieldLength++;
+      if ( octetFieldLength > octets.Length)
+      {
+        Byte[] temp = new Byte[octets.Length * 2];
+        octets.CopyTo(temp,0);
+        octets = temp;
+      }
+      
+      octets[octetFieldLength - 1] = b;
+      
+      return b;
+    }
+    
+    public Byte[] ToArray()
+    {
+      Byte[] temp = new Byte[octetFieldLength];
+      octets.CopyTo(temp,0);
+      return temp;
+    }
+  }
+  
+  // Class for analyzing ASN.1 Identifier Octets in BER/CER/DER
+  public class Asn1Tag : Asn1OctetField
+  {
+    // Private members
+    private Asn1TagNumber tagNumber;
+    private Asn1TagType   tagType;
+    private Asn1TagClass  tagClass;
+
+    
+    // Public properties
+    public Asn1TagNumber TagNumber
+    {
+      get{ return tagNumber; }
+    }
+    
+    public Asn1TagType TagType
+    {
+      get{ return tagType; }
+    }
+    
+    public Asn1TagClass TagClass
+    {
+      get{ return tagClass; }
+    }
+    
+    
+    // Public Constructors
+    public Asn1Tag( Stream dataStream ) : base()
+    {
+      Byte b = ReadByte(dataStream);
+      tagNumber = GetNumber(b);
+      tagType   = GetType(b);
+      tagClass  = GetClass(b);
+      
+      if (tagNumber == Asn1TagNumber.HIGHNUMBER)
+      {
+        UInt32 tagNo = 0;
+        b = ReadByte(dataStream);
+        if ((b & 0x7F) == 0x00)
+          throw new IOException("Invalid tag number!");
+        else
+        {
+          while ((b & 0x80) == 0x80)
+          {
+            // Get bits from intermdeiate octets
+            tagNo |= (UInt32)(b & 0x7F);
+            tagNo <<= 7; 
+            // Read next byte from dataStream
+            b = ReadByte(dataStream);
+          }
+          
+          // Get bits from last octet
+          tagNo |= (UInt32) (b & 0x7F);
+        }
+        tagNumber = (Asn1TagNumber) tagNo;
+      }
+      
+    }
+    
+    public Asn1Tag( Byte[] dataBytes ) : this(new MemoryStream(dataBytes,false))
+    {
+    }
+
+    
+    // Public Static class methods
+    public static Asn1TagNumber GetNumber(Byte tag)
+    {
+      tag = (Byte) ((tag >> 0) & 0x1F);
+      if (Enum.IsDefined(typeof(Asn1TagNumber), (UInt32) tag)) 
+        return (Asn1TagNumber) tag;
+      else
+        throw new ArgumentException(String.Format("Tag number, {0}, is not defined",tag));
+    }
+    
+    public static Asn1TagType GetType(Byte tag)
+    {
+      tag = (Byte) ((tag >> 5) & 0x01);
+      if (Enum.IsDefined(typeof(Asn1TagType), (UInt32) tag))
+        return (Asn1TagType) tag;
+      else
+        throw new ArgumentException(String.Format("Tag type, {0}, is not defined",tag));
+    }
+    
+    public static Asn1TagClass GetClass(Byte tag)
+    {
+      tag = (Byte) ((tag >> 6) & 0x03);
+      if (Enum.IsDefined(typeof(Asn1TagClass), (UInt32) tag))
+        return (Asn1TagClass) tag;
+      else
+        throw new ArgumentException(String.Format("Tag class, {0}, is not defined",tag));
+    }
+
+    
+    // Static function to parse get the tag number from a data stream
+    public static UInt32 ReadTagNumber(Stream dataStream)
+    {
+      return (UInt32) (new Asn1Tag(dataStream)).TagNumber;
+    }
+  }
+  
+  // Class for analyzing ASN.1 Length Octets in BER/CER/DER
+  public class Asn1Length : Asn1OctetField
+  {
+    //  Private class variables
+    private UInt32 length;
+    private Asn1LengthType lengthType;
+    
+    
+    // Public properties
+    public UInt32 Length 
+    {
+      get { return length; }
+    }
+    
+    public Asn1LengthType LengthType
+    {
+      get { return lengthType; }
+    }
+    
+    // Public Constructors
+    public Asn1Length( Stream dataStream ) : base()
+    {
+      Byte b = ReadByte(dataStream);
+      
+      if ((b & 0x80) == 0x00)
+      {
+        lengthType = Asn1LengthType.SHORT;
+        // Short Form
+        length = (UInt32) (b & 0x7F);
+      }
+      else
+      {
+        length = 0;
+        // Long Form
+        UInt32 numLengthOctets = (UInt32) (b & 0x7F);
+        if (numLengthOctets == 0x00)
+        {
+          lengthType = Asn1LengthType.LONG_INDEFINITE;
+        }
+        else
+        {
+          lengthType = Asn1LengthType.LONG_DEFINITE;        
+          while (numLengthOctets > 0)
+          {
+            b = ReadByte(dataStream);
+            length <<= 8;
+            length |= b;
+            numLengthOctets--;
+          }
+        }
+      }
+    }
+  
+    public Asn1Length( Byte[] dataBytes ) : this(new MemoryStream(dataBytes,false))
+    {
+    }
+    
+    
+    // Static function to read ASN.1 BER length value from data stream 
+    public static UInt32 ReadLength(Stream dataStream)
+    {
+      return (UInt32) (new Asn1Length(dataStream)).Length;
+    }
+  }
+  
+  // Base ASN.1 Object class
+  public class Asn1Object
+  {
+    // Private Members
+    protected Asn1Tag identification;
+    protected Asn1Length length;
+    protected Stream contents;
+    
+    // Public Properties
+    public Asn1Tag ContentID
+    {
+      get { return identification; }
+      set { identification = value; }
+    }
+    
+    public Asn1Length ContentLength
+    {
+      get { return length; }
+      set { length = value; }
+    }
+    
+    public Stream Contents
+    {
+      get { return contents; }
+      set { contents = value; }
+    }
+    
+    // Public contructors
+    public Asn1Object()
+    {
+    }
+    
+    public Asn1Object(Byte[] asn1Data) : this(new MemoryStream(asn1Data, false))
+    {
+    }
+    
+    public Asn1Object(Stream asn1Stream)
+    {
+      if (!asn1Stream.CanRead) throw new ArgumentException("Input data stream must be readable!");
+    
+      // Get ID and Length from stream
+      identification = new Asn1Tag(asn1Stream);
+      length = new Asn1Length(asn1Stream);
+     
+      // Check if has definite length (only kind currently supported)
+      if (length.LengthType == Asn1LengthType.LONG_INDEFINITE)
+      {
+        // Indefinite Length Streams (terminated by EOC)
+        throw new ArgumentException("Indefinite length ASN.1 streams are not supported!");
+      }
+      else
+      {
+        // Definite length stream
+        if (length.Length == 0)
+          contents = null;
+        else
+        {
+          // Create a new Stream containing just the contents bytes
+          Byte[] bytesRead = new Byte[length.Length];
+          asn1Stream.Read(bytesRead,(Int32)0,(Int32)length.Length);
+          contents = new MemoryStream(bytesRead,false);
+        }
+      }
+    }
+    
+    public Byte[] ContentsToArray()
+    {
+      if (Contents is MemoryStream)
+        return ((MemoryStream) Contents).ToArray();
+      else
+      {
+        Byte[] bytesRead = new Byte[length.Length];
+        Contents.Seek(0,SeekOrigin.Begin);
+        Contents.Read(bytesRead, (Int32)0, (Int32)length.Length);
+        return bytesRead;
+      }
+    }
+    
+    public override String ToString()
+    {
+      UInt32 pos = 0,i=0;
+      StringBuilder sb = new StringBuilder();
+      
+      sb.AppendFormat("{0,5}{1,5:X2}{2,5}: ",pos,ContentID[0],ContentLength.Length);
+      sb.AppendFormat("{0} (Class={1},Type={2})\n",ContentID.TagNumber,ContentID.TagClass,ContentID.TagType);
+      
+      pos += (ContentID.OctetFieldLength + ContentLength.OctetFieldLength);
+      
+      for (i=0; i<ContentLength.Length; i+=16,pos+=16)
+      {
+        sb.AppendFormat("{0,5}{1,10:X2}: ",pos," ");
+        if ( (ContentLength.Length - i) < 16)
+          sb.AppendFormat("  {0}\n", BitConverter.ToString(this.ContentsToArray(),(Int32)i,(Int32)(ContentLength.Length - i)));
+        else
+          sb.AppendFormat("  {0}\n", BitConverter.ToString(this.ContentsToArray(),(Int32)i,16));
+      }
+      
+      return sb.ToString();
+    }
+  }
+  
+  // ASN.1 Sequence Class, inheriting from base ASN.1 Object class
+  public class Asn1Sequence : Asn1Object
+  {
+    // Private array reflecting the sequence of Asn1Object
+    private Asn1Object[] seqElements;
+    
+    private UInt32 depth;
+
+    
+    // Public indexer/properties
+    public Asn1Object this [int index]
+    {
+      get { return seqElements[index]; }
+    }
+
+    public UInt32 SequenceLength
+    {
+      get { return ((UInt32) seqElements.Length); }
+    }
+    
+    
+    // Public Constructors
+    public Asn1Sequence( Stream asn1Stream ) : this(asn1Stream, 0)
+    {
+    }
+    
+    public Asn1Sequence( Byte[] asn1Data ) : this( asn1Data, 0 )
+    {
+    }
+    
+    public Asn1Sequence( Stream asn1Stream, UInt32 depth ) : base(asn1Stream)
+    {
+      this.depth = depth;
+      
+      if (identification.TagNumber != Asn1TagNumber.SEQUENCE)
+      {
+        throw new ArgumentException("Input data is not an ASN.1 Sequence!");
+      }
+      
+      // Parse through the Sequence and generate array of Asn1Object's
+      seqElements = ParseAsn1Sequence(contents, length.Length);
+    }
+    
+    public Asn1Sequence( Byte[] asn1Data, UInt32 depth ) : base( asn1Data )
+    {
+      this.depth = depth;
+      
+      if (identification.TagNumber != Asn1TagNumber.SEQUENCE)
+      {
+        throw new ArgumentException("Input data is not an ASN.1 Sequence!");
+      }
+      
+      // Parse through the Sequence and generate array of Asn1Object's
+      seqElements = ParseAsn1Sequence(contents, length.Length);
+    }
+    
+    public Asn1Sequence( Asn1Object asn1Obj )
+    {
+      if (asn1Obj.ContentID.TagNumber != Asn1TagNumber.SEQUENCE)
+      {
+        throw new ArgumentException("Input Object is not an ASN.1 Sequence!");
+      }
+      
+      this.identification = asn1Obj.ContentID;
+      this.length = asn1Obj.ContentLength;
+      this.contents = asn1Obj.Contents;
+      
+      // Parse through the Sequence and generate array of Asn1Object's
+      seqElements = ParseAsn1Sequence(contents,length.Length);
+    }
+    
+    public Asn1Sequence( Asn1Object asn1Obj, UInt32 depth ) : this(asn1Obj)
+    {
+      this.depth = depth;
+    }
+
+    
+    // Static class functions
+    public static Asn1Object[] ParseAsn1Sequence(Byte[] asn1Data)
+    {
+      return ParseAsn1Sequence(new MemoryStream(asn1Data,false), (UInt32) asn1Data.Length);
+    }
+    
+    public static Asn1Object[] ParseAsn1Sequence(Stream asn1Stream, UInt32 length)
+    {
+      Asn1Object myObj;
+          
+      // Create new generic list class for holding Asn1Objects
+      List<Asn1Object> myList = new List<Asn1Object>();
+      
+      while (length > 0)
+      {
+        myObj = new Asn1Object(asn1Stream);   // Stream position is incremented in object creation
+        
+        if (myObj.ContentID.TagNumber == Asn1TagNumber.SEQUENCE)
+        {
+          myList.Add(new Asn1Sequence(myObj));
+        }
+        else
+        {
+          myList.Add(myObj);
+        }
+        length -= (myObj.ContentID.OctetFieldLength + myObj.ContentLength.OctetFieldLength + myObj.ContentLength.Length);
+      }
+      
+      if (length != 0)
+        throw new IOException("Amount of data parsed did not match amount available!");
+            
+      return myList.ToArray();
+    }
+  
+    public new String ToString()
+    {
+      StringBuilder sb = new StringBuilder();
+      sb.Append(((Asn1Object) this).ToString());
+      foreach (Asn1Object obj in seqElements)
+      {
+        if (obj.ContentID.TagNumber == Asn1TagNumber.SEQUENCE)
+        {
+          sb.Append(((Asn1Sequence)obj).ToString());
+        }
+        else
+        {
+          sb.Append(obj.ToString());
+        }
+      }
+      return sb.ToString();
+    }
+  
+  }
+/*
+  public class Asn1DERSequence : Asn1Sequence
+  {
+  
+  }
+  
+  public class Asn1BERSequence : Asn1Sequence
+  {
+  
+  }
+  
+  public class Asn1Set : Asn1Object
+  {
+  
+  } */
+}
\ No newline at end of file
diff --git a/tools/omapl13x_boot_utils/Common/UtilLib/BinaryFile.cs b/tools/omapl13x_boot_utils/Common/UtilLib/BinaryFile.cs
new file mode 100644 (file)
index 0000000..7e568b3
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ * BinaryFile.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+// This module parses a COFF file created by Texas Instruments TMS DSP
+// code generation tools and offers a set of easy to use methods for obtaining
+// information from the COFF file. This information includes header info.,
+// symbol table, section data, etc.
+
+using System;
+using System.Text;
+using System.IO;
+using System.IO.Ports;
+using System.Reflection;
+using System.Threading;
+using System.Globalization;
+using System.Collections;
+using TI.UtilLib;
+using TI.UtilLib.IO;
+
+namespace TI.UtilLib.ObjectFile
+{
+  public class BinaryFile : ObjectFile
+  {
+    #region Public Class constructor(s)
+    public BinaryFile(String filename) : base(filename)
+    {     
+      // Parse the Binary file
+      try
+      {
+        ParseBinaryFile(0x00000000);
+      }
+      catch (Exception e)
+      {
+        Console.Write(e.Message);
+        throw e;
+      }
+      
+      fileType = ObjectFileType.BINARY;
+    }
+
+    public BinaryFile(String filename, UInt64 address) : base(filename)
+    {     
+      // Parse the Binary file
+      try
+      {
+        ParseBinaryFile(address);
+      }
+      catch (Exception e)
+      {
+        Console.Write(e.Message);
+        throw e;
+      }
+      
+      fileType = ObjectFileType.BINARY;
+    }       
+    #endregion
+
+    #region Public Class Methods
+    public new String ToString()
+    {
+      StringBuilder strBuilder = new StringBuilder(512);
+      
+      strBuilder.Append(base.ToString());
+
+      return strBuilder.ToString();
+    }
+    
+    #endregion
+
+    #region Private parsing functions
+    private void ParseBinaryFile(UInt64 address)
+    {
+      // Output console message
+      Console.WriteLine("Parsing the input file, {0}.", fileName);
+      
+      // Set endian to little
+      endian = Endian.LittleEndian;
+      
+      // Set section count
+      sectionCount = 1;
+      loadableSectionCount = 1;
+      symbolCount  = 0;
+      
+      binFile.Seek(0, SeekOrigin.Begin);
+      EndianBinaryReader ebr = new EndianBinaryReader(binFile, endian);
+     
+      sections      = new ObjectSection[sectionCount];
+      sections[0]   = new ObjectSection();
+
+      sections[0].name         = fileName;
+      sections[0].loadAddr     = address;
+      sections[0].runAddr      = address;
+      sections[0].size         = (UInt64) binFile.Length;
+      sections[0].size         = ((sections[0].size + 3) >> 2) << 2;
+      sections[0].binFileAddr  = 0x00000000;
+      sections[0].isLoadable   = true;
+      
+      loadableSections    = new ObjectSection[loadableSectionCount];
+      loadableSections[0] = sections[0];
+      
+    } // end ParseBinaryFile()
+    #endregion
+      
+    #region Public Static Class Methods
+    public static Boolean IsBinaryFile(String filename)
+    {        
+      // Get File Details
+      FileInfo fi = new FileInfo(filename);
+      if (fi.Exists)
+      {
+        return true;
+      }
+      else
+      {
+        return false;
+      }
+    }
+    #endregion
+  } //End BinaryFile class
+
+} //end of namespace
diff --git a/tools/omapl13x_boot_utils/Common/UtilLib/CRC.cs b/tools/omapl13x_boot_utils/Common/UtilLib/CRC.cs
new file mode 100644 (file)
index 0000000..d3e5b38
--- /dev/null
@@ -0,0 +1,787 @@
+/*
+ * CRC.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+/****************************************************************
+ *  TI UtilLib.CRC namespace: CRC-32, CRC-16 code               *
+ *  (C) 2008, Texas Instruments, Inc.                           *
+ *                                                              *
+ * Author:  Daniel Allred                                       *
+ * Revision: 13-Jun-2008, added CRC-16 class and routines       *
+ *                                                              * 
+ ****************************************************************/
+
+using System;
+using System.Text;
+using TI.UtilLib;
+
+namespace TI.UtilLib.CRC
+{
+  public enum CRCCalcMethod : uint
+  {
+    LUT = 1,
+    BITWISE =2
+  }
+  
+  public enum CRCType : uint
+  {
+    ONESHOT = 1,
+    INCREMENTAL = 2
+  }
+  
+  public class CRC32
+  {
+    #region Data members
+
+    private UInt32[] lut;
+    private UInt32 poly = 0x04C11DB7; //Bit32 is 1 is always 1 and therefore not needed
+    private UInt32 initReg = 0xFFFFFFFF;
+    private UInt32 finalReg = 0xFFFFFFFF;
+    private Boolean reflected = true; //follows hardware convention that receive bits in reverse order 
+    private Int32 numBytesPerRegShift = 1;
+    private UInt32 currCRC;
+    private CRCType crcType = CRCType.INCREMENTAL;
+    private CRCCalcMethod crcCalcMethod = CRCCalcMethod.LUT;
+
+    #endregion
+
+    #region Indexer and Properties
+    
+    public UInt32 this[int index]
+    {
+      get
+      {
+        if (crcCalcMethod == CRCCalcMethod.LUT)
+          return lut[index];
+        else
+          return 0;
+      }
+    }
+    
+    public Int32 Length
+    {
+      get
+      {
+        if (crcCalcMethod == CRCCalcMethod.LUT)
+          return lut.Length;
+        else
+          return 0;
+      }
+    }
+    
+    private Int32 NumBytesPerRegShift
+    {
+      get { return numBytesPerRegShift; }
+      set { numBytesPerRegShift = ((value < 3) && (value > 0)) ? value : 1; }
+    }
+
+    public UInt32 CurrentCRC
+    {
+      get { return currCRC; }
+      set { currCRC = value; }
+    }
+    
+    public CRCType CrcType
+    {
+      get { return crcType;  }
+      set { crcType = value; }
+    }
+    
+    public CRCCalcMethod CrcCalcMethod
+    {
+      get { return crcCalcMethod;  }
+      set { crcCalcMethod = value; }
+    }
+    
+    #endregion
+
+    #region Constructors
+    /// <summary>
+    /// Basic Constructor to generate the standard CRC-32 (used in ethernet packets, Zip files, etc.)
+    /// </summary>
+    public CRC32() : this(0x04C11DB7, CRCType.ONESHOT)
+    {
+    }
+    
+    /// <summary>
+    /// Basic Constructor except with a different key (divisor) polynomial
+    /// </summary>
+    /// <param name="KeyPoly">The user-provided key polynomial (hex number of bits[31-0])</param>
+    public CRC32(UInt32 KeyPoly) : this(KeyPoly, 0xFFFFFFFF, 0xFFFFFFFF, true, 1, CRCType.ONESHOT, CRCCalcMethod.LUT)
+    {
+    }
+
+    /// <summary>
+    /// Basic Constructor except with a different key (divisor) polynomial
+    /// </summary>
+    /// <param name="KeyPoly">The user-provided key polynomial (hex number of bits[31-0])</param>
+    /// <param name="CrcType">Indicates whether CRC is incremental (incomplete) or oneshot (complete).</param>
+    public CRC32(UInt32 KeyPoly, CRCType CrcType) : this(KeyPoly, 0xFFFFFFFF, 0xFFFFFFFF, true, 1, CrcType, CRCCalcMethod.LUT)
+    {
+    }
+
+    /// <summary>
+    /// Constructor for custom 32-bit CRC object - Don't use this unless you really know
+    /// what the heck you are doing.
+    /// </summary>
+    /// <param name="KeyPoly">Custom key polynomial</param>
+    /// <param name="InitialRegVal">Initial register value</param>
+    /// <param name="FinalizeXorVal">Value that is xor'd with final CRC</param>
+    /// <param name="Reflected">Indicates whether the algorithm expects reflected input bytes</param>
+    /// <param name="BytesShiftedPerCycle">How many bytes are handled at a time (1 or 2).
+    /// <param name="CrcType">Indicates whether CRC is incremental (incomplete) or oneshot (complete).</param>
+    /// <param name="CrcCalcMethod">How many bytes are handled at a time (1 or 2).
+    /// The internal table size is determined by this parameter, 1 is most common (leads to 1kbyte table).</param>
+    public CRC32( UInt32 KeyPoly,
+                  UInt32 InitialRegVal,
+                  UInt32 FinalizeXorVal,
+                  Boolean Reflected,
+                  Int32 BytesShiftedPerCycle,
+                  CRCType CrcType,
+                  CRCCalcMethod CrcCalcMethod  )
+    {
+      lut = null;
+      poly = KeyPoly;
+      initReg = InitialRegVal;
+      currCRC = initReg;
+      finalReg = FinalizeXorVal;
+      reflected = Reflected;
+      NumBytesPerRegShift = BytesShiftedPerCycle;
+      this.CrcType = CrcType;
+      this.CrcCalcMethod = CrcCalcMethod;
+      
+      // Build the look up table
+      BuildTable();
+      
+      // Call reset to set initial value for currCRC;
+      ResetCRC();
+    }
+    #endregion
+
+    #region Table building method used by Constructors
+    /// <summary>
+    /// Function to generate the table of values used in the CRC-32 calculation
+    /// </summary>
+    private void BuildTable()
+    {
+      Int32 NumBitsPerRegShift = NumBytesPerRegShift*8;
+      Int32 tableLen = (Int32) Math.Pow(2.0,NumBitsPerRegShift);
+      UInt32 crcAccum;
+      lut = new UInt32[tableLen];
+
+      if (reflected)
+      {
+        for (UInt32 i = 0; i < tableLen; i++)
+        {
+          crcAccum = ReflectNum(i, NumBitsPerRegShift) << (32 - NumBitsPerRegShift);
+          for (Byte j = 0; j < NumBitsPerRegShift; j++)
+          {
+            if ((crcAccum & 0x80000000) != 0x00000000)
+            {
+              crcAccum = (crcAccum << 1) ^ poly;
+            }
+            else
+            {
+              crcAccum = (crcAccum << 1);
+            }
+            lut[i] = ReflectNum(crcAccum, 32);
+          }
+        }
+      }
+      else
+      {
+        for (UInt32 i = 0; i < tableLen; i++)
+        {
+          crcAccum = i << (32 - NumBitsPerRegShift);
+          for (Byte j = 0; j < NumBitsPerRegShift; j++)
+          {
+            if ((crcAccum & 0x80000000) != 0x00000000)
+            {
+              crcAccum = (crcAccum << 1) ^ poly;
+            }
+            else
+            {
+              crcAccum = (crcAccum << 1);
+            }
+            lut[i] = crcAccum;
+          }
+        }
+      }
+    }
+    #endregion
+                                       
+    #region Public Methods
+    
+    /// <summary>
+    /// Calculate the CRC-32 checksum on the given array of bytes
+    /// </summary>
+    /// <param name="Data">Array of bytes of data.</param>
+    /// <returns>The 32-bit CRC of the data.</returns>
+    public UInt32 CalculateCRC(Byte[] Data)
+    {
+      return CalculateCRC(Data,0,Data.Length);
+    }
+
+    /// <summary>
+    /// Calculate the CRC-32 checksum on the given array of bytes
+    /// </summary>
+    /// <param name="Data">The input byte array.</param>
+    /// <param name="offset">The offset into the Byte array.</param>
+    /// <param name="count">The number of bytes to use for the CRC calculation.</param>
+    /// <returns>CRC32 value.</returns>
+    public UInt32 CalculateCRC(Byte[] Data, int offset, int count)
+    {
+      if ( CrcType == CRCType.ONESHOT )
+      {
+        currCRC = initReg;
+        if ( CrcCalcMethod == CRCCalcMethod.LUT)
+          currCRC = LUTBasedCRC(Data, offset, count);
+        else
+          currCRC = BitWiseCRC(Data, offset, count);
+      }
+      else
+      {
+        currCRC = currCRC ^ finalReg;   // undo XOR from last calculation
+        if ( CrcCalcMethod == CRCCalcMethod.LUT)
+          currCRC = LUTBasedCRC(Data, offset, count);
+        else
+          currCRC = BitWiseCRC(Data, offset, count);
+      }
+      
+      // Prep CRC for output
+      currCRC = currCRC ^ finalReg;
+
+      return (currCRC);
+    }
+    
+
+    /// <summary>
+    /// Calculate the CRC-32 checksum using LUT.
+    /// </summary>
+    /// <param name="Data">The input byte array.</param>
+    /// <param name="offset">The offset into the Byte array.</param>
+    /// <param name="count">The number of bytes to use for the CRC calculation.</param>
+    /// <returns>CRC32 value.</returns>
+    private UInt32 LUTBasedCRC(Byte[] Data, int offset, int count)
+    {
+      UInt32 crc = currCRC;
+      Int32 len = count;
+      Int32 NumBitsPerRegShift = NumBytesPerRegShift * 8;
+      UInt32 Mask = (UInt32)(Math.Pow(2.0, NumBitsPerRegShift) - 1);
+      
+      Debug.DebugMSG("LUT-Based CRC, NumBitsPerRegShift = {0}, Refelected = {1}",NumBitsPerRegShift,reflected);
+      Debug.DebugMSG("Offset = {0}, length = {1}",offset,count);
+      Debug.DebugMSG("Interim Calculated CRC = 0x{0:X8}",crc);
+
+      // Perform the algorithm on each byte
+      if (reflected)
+      {
+        if (NumBytesPerRegShift == 2)
+        {
+          for (Int32 i = 0; i < (len / NumBytesPerRegShift); i++)
+          {
+            crc = (crc >> NumBitsPerRegShift) ^ lut[(crc & Mask) ^ ((Data[2 * i + 1 + offset] << 8) | Data[2 * i + offset])];
+          }
+        }
+        else
+        {
+          for (Int32 i = 0; i < len; i++)
+          {
+            crc = (crc >> NumBitsPerRegShift) ^ lut[(crc & Mask) ^ Data[offset+i]];
+            Debug.DebugMSG("Data = {0:X2},Index = {1},Interim Calculated CRC = 0x{2:X8}",Data[offset+i],(crc & Mask) ^ Data[offset+i],crc);
+          }
+        }
+      }
+      else
+      {
+        if (NumBytesPerRegShift == 2)
+        {
+          for (Int32 i = 0; i < (len / NumBytesPerRegShift); i++)
+          {
+            crc = (crc << NumBitsPerRegShift) ^ lut[((crc >> (32 - NumBitsPerRegShift)) & Mask) ^ ((Data[2 * i + offset] << 8) | Data[2 * i + 1 + offset])];
+          }
+        }
+        else
+        {
+          for (Int32 i = 0; i < len; i++)
+          {
+            crc = (crc << NumBitsPerRegShift) ^ lut[((crc >> (32 - NumBitsPerRegShift)) & Mask) ^ Data[offset+i]];
+            Debug.DebugMSG("Data = {0:X2},Index = {1},Interim Calculated CRC = 0x{2:X8}",Data[offset+i],(crc & Mask) ^ Data[offset+i],crc);
+          }
+        }
+      }
+      return crc;
+    }
+    
+    /// <summary>
+    /// Calculate the CRC-32 checksum using simple, inefficient bit wise operations.
+    /// </summary>
+    /// <param name="Data">The input byte array.</param>
+    /// <param name="offset">The offset into the Byte array.</param>
+    /// <param name="count">The number of bytes to use for the CRC calculation.</param>
+    /// <returns>CRC32 value.</returns>
+    private UInt32 BitWiseCRC(Byte[] Data, int offset, int count)
+    { 
+      UInt32 crc = currCRC;
+      Int32 len = Data.Length;
+      Int32 NumBitsPerRegShift = NumBytesPerRegShift * 8;
+      UInt32 Mask = (UInt32)(Math.Pow(2.0, NumBitsPerRegShift) - 1);
+      
+      if (reflected)
+      {
+        // Perform the algorithm on each byte
+        if (NumBytesPerRegShift == 2)
+        {
+          for (Int32 i = 0; i < (len / NumBytesPerRegShift); i++)
+          {
+            crc = ((crc << NumBitsPerRegShift) + (UInt32)((Data[2 * i] << 8) | Data[2 * i + 1])) ^ lut[((crc >> (32 - NumBitsPerRegShift)) & Mask)];
+          }
+        }
+        else
+        {
+          for (Int32 i = 0; i < len; i++)
+          {
+            crc = ((crc << NumBitsPerRegShift) + Data[i]) ^ lut[((crc >> (32 - NumBitsPerRegShift)) & Mask)];            
+          }
+        }
+      }
+      else
+      {
+        if (NumBytesPerRegShift == 2)
+        {
+          for (Int32 i = 0; i < len; i+=2)
+          {
+            int index = (i & (~3)) + 2*(1 - ((i/2)%2));
+            crc = ((crc << NumBitsPerRegShift) + (UInt32)BitConverter.ToUInt16(Data,index)) ^ lut[((crc >> (32 - NumBitsPerRegShift)) & Mask)];          
+          }
+        }
+        else
+        {
+          for (Int32 i = 0; i < len; i++)
+          {
+            int index = (i & (~3)) + (3 - (i%4));
+            crc = ((crc << NumBitsPerRegShift) + Data[index]) ^ lut[((crc >> (32 - NumBitsPerRegShift)) & Mask)];
+          }
+        }
+      }
+      // Exclusive OR the result with the specified value
+      currCRC = (crc ^ finalReg);
+      return currCRC; 
+    }
+    
+    public void ResetCRC()
+    {
+      if ( this.CrcType == CRCType.ONESHOT )
+        currCRC = initReg;
+      else
+        // Must do this since incremental calc always
+        // "un"-XORs the previous calculations final XOR.
+        currCRC = initReg ^ finalReg; 
+    }
+
+    /// <summary>
+    /// Method to reflect a specified number of bits in the integer
+    /// </summary>
+    /// <param name="inVal">The unsigned integer value input</param>
+    /// <param name="num">The number of lower bits to reflect.</param>
+    /// <returns></returns>
+    public UInt32 ReflectNum(UInt32 inVal, Int32 num)
+    {
+        UInt32 outVal = 0x0;
+
+        for (Int32 i = 1; i < (num + 1); i++)
+        {
+            if ((inVal & 0x1) != 0x0)
+            {
+                outVal |= (UInt32)(0x1 << (num - i));
+            }
+            inVal >>= 1;
+        }
+        return outVal;
+    }
+            
+    #endregion
+
+
+  }
+
+    public class CRC16
+    {
+        #region Data members
+
+        private UInt16[] lut;
+        private UInt16 poly = 0x8005; //Bit32 is 1 is always 1 and therefore not needed
+        private UInt16 initReg = 0xFFFF;
+        private UInt16 finalReg = 0xFFFF;
+        private Boolean reflected = true; //follows hardware convention that receive bits in reverse order 
+        private Int32 numBytesPerRegShift = 1;
+        private UInt16 currCRC;
+
+        #endregion
+
+        #region Indexer and Properties
+        
+        public UInt32 this[int index]
+        {
+            get{
+                return lut[index];
+            }
+        }
+        
+        public Int32 Length
+        {
+            get{
+                return lut.Length;
+            }
+        }
+        
+        private Int32 NumBytesPerRegShift
+        {
+            get { return numBytesPerRegShift; }
+            set { numBytesPerRegShift = ((value < 3) && (value > 0)) ? value : 1; }
+        }
+
+        public UInt16 CurrentCRC
+        {
+            get { return currCRC; }
+            set { currCRC = value; }
+        }
+        
+        #endregion
+
+        #region Constructors
+        /// <summary>
+        /// Basic Constructor to generate the standard CRC-16 (used in ethernet packets, Zip files, etc.)
+        /// </summary>
+        public CRC16()
+        {
+            poly = 0x8005; //Bit32 is 1 by default
+            initReg = 0xFFFF;
+            finalReg = 0xFFFF;
+            currCRC = initReg;
+            reflected = true; //follows hardware convention that receive bits in reverse order 
+            numBytesPerRegShift = 1;
+            BuildTable();
+        }
+
+        /// <summary>
+        /// Basic Constructor except with a different key (divisor) polynomial
+        /// </summary>
+        /// <param name="KeyPoly">The user-provided key polynomial (hex number of bits[15-0])</param>
+        public CRC16(UInt16 KeyPoly)
+        {
+            poly = KeyPoly;
+            currCRC = initReg;
+            BuildTable();
+        }
+
+        /// <summary>
+        /// Constructor for custom 16-bit CRC object - Don't use this unless you really know
+        /// what the heck you are doing.
+        /// </summary>
+        /// <param name="KeyPoly">Custom key polynomial</param>
+        /// <param name="InitialRegVal">Initial register value</param>
+        /// <param name="FinalizeXorVal">Value that is xor'd with final CRC</param>
+        /// <param name="Reflected">Indicates whether the algorithm expects reflected input bytes</param>
+        /// <param name="BytesShiftedPerCycle">How many bytes are handled at a time (1 or 2).
+        /// The internal table size is determined by this parameter, 1 is most common (leads to 512 byte table).</param>
+        public CRC16(UInt16 KeyPoly,
+            UInt16 InitialRegVal,
+            UInt16 FinalizeXorVal,
+            Boolean Reflected,
+            Int32 BytesShiftedPerCycle)
+        {
+            poly = KeyPoly;
+            initReg = InitialRegVal;
+            currCRC = initReg;
+            finalReg = FinalizeXorVal;
+            reflected = Reflected;
+            NumBytesPerRegShift = BytesShiftedPerCycle;
+            BuildTable();
+        }
+        #endregion
+
+        #region Table building method used by Constructors
+        /// <summary>
+        /// Function to generate the table of values used in the CRC-32 calculation
+        /// </summary>
+        private void BuildTable()
+        {
+            Int32 NumBitsPerRegShift = NumBytesPerRegShift*8;
+            Int32 tableLen = (Int32) Math.Pow(2.0,NumBitsPerRegShift);
+            UInt16 crcAccum;
+            lut = new UInt16[tableLen];
+
+            if (reflected)
+            {
+                for (UInt16 i = 0; i < tableLen; i++)
+                {
+                    crcAccum = (UInt16) (ReflectNum(i, NumBitsPerRegShift) << (16 - NumBitsPerRegShift));
+                    for (Byte j = 0; j < NumBitsPerRegShift; j++)
+                    {
+                        if ((crcAccum & 0x8000) != 0x0000)
+                        {
+                            crcAccum = (UInt16) ((crcAccum << 1) ^ poly);
+                        }
+                        else
+                        {
+                            crcAccum = (UInt16) (crcAccum << 1);
+                        }
+                        lut[i] = ReflectNum(crcAccum, 16);
+                    }
+                }
+            }
+            else
+            {
+                for (UInt16 i = 0; i < tableLen; i++)
+                {
+                    crcAccum = (UInt16) (i << (16 - NumBitsPerRegShift));
+                    for (Byte j = 0; j < NumBitsPerRegShift; j++)
+                    {
+                        if ((crcAccum & 0x8000) != 0x0000)
+                        {
+                            crcAccum = (UInt16) ((crcAccum << 1) ^ poly);
+                        }
+                        else
+                        {
+                            crcAccum = (UInt16) (crcAccum << 1);
+                        }
+                        lut[i] = crcAccum;
+                    }
+                }
+            }
+        }
+        #endregion
+                                       
+        #region Public Methods
+        
+        /// <summary>
+        /// Calculate the CRC-32 checksum on the given array of bytes
+        /// </summary>
+        /// <param name="Data">Array of bytes of data.</param>
+        /// <returns>The 32-bit CRC of the data.</returns>
+        public UInt16 CalculateCRC(Byte[] Data)
+        {
+            UInt16 crc = initReg;
+            Int32 len = Data.Length;
+            Int32 NumBitsPerRegShift = NumBytesPerRegShift * 8;
+            UInt16 Mask = (UInt16)(Math.Pow(2.0, NumBitsPerRegShift) - 1);
+
+            // Perform the algorithm on each byte
+            if (reflected)
+            {
+                if (NumBytesPerRegShift == 2)
+                {
+                    for (Int32 i = 0; i < (len / NumBytesPerRegShift); i++)
+                    {
+                        crc = (UInt16) ((crc >> NumBitsPerRegShift) ^ lut[(crc & Mask) ^ ((Data[2 * i + 1] << 8) | Data[2 * i])]);
+                    }
+                }
+                else
+                {
+                    for (Int32 i = 0; i < len; i++)
+                    {
+                        crc = (UInt16) (((UInt16)(crc >> NumBitsPerRegShift)) ^ ((UInt16) lut[(crc & Mask) ^ Data[i]]));
+                    }
+                }
+            }
+            else
+            {
+                if (NumBytesPerRegShift == 2)
+                {
+                    for (Int32 i = 0; i < (len / NumBytesPerRegShift); i++)
+                    {
+                        crc = (UInt16) ((crc << NumBitsPerRegShift) ^ lut[((crc >> (16 - NumBitsPerRegShift)) & Mask) ^ ((Data[2 * i] << 8) | Data[2 * i + 1])]);
+                    }
+                }
+                else
+                {
+                    for (Int32 i = 0; i < len; i++)
+                    {
+                        crc = (UInt16) ((crc << NumBitsPerRegShift) ^ lut[((crc >> (16 - NumBitsPerRegShift)) & Mask) ^ Data[i]]);
+                    }
+                }
+            }
+            // Exclusive OR the result with the specified value
+            currCRC = (UInt16) (crc ^ finalReg);
+            return currCRC;
+        }
+
+        /// <summary>
+        /// Calculate the CRC-32 checksum.
+        /// </summary>
+        /// <param name="Data">The input byte array.</param>
+        /// <param name="offset">The offset into the Byte array.</param>
+        /// <param name="count">The number of bytes to use for the CRC calculation.</param>
+        /// <returns>CRC32 value.</returns>
+        public UInt16 CalculateCRC(Byte[] Data, int offset, int count)
+        {
+            UInt16 crc = initReg;
+            Int32 len = count;
+            Int32 NumBitsPerRegShift = NumBytesPerRegShift * 8;
+            UInt16 Mask = (UInt16)(Math.Pow(2.0, NumBitsPerRegShift) - 1);
+
+            // Perform the algorithm on each byte
+            if (reflected)
+            {
+                if (NumBytesPerRegShift == 2)
+                {
+                    for (Int32 i = 0; i < (len / NumBytesPerRegShift); i++)
+                    {
+                        crc = (UInt16)((crc >> NumBitsPerRegShift) ^ lut[(crc & Mask) ^ ((Data[2 * i + 1 + offset] << 8) | Data[2 * i + offset])]);
+                    }
+                }
+                else
+                {
+                    for (Int32 i = 0; i < len; i++)
+                    {
+                        crc = (UInt16)((crc >> NumBitsPerRegShift) ^ lut[(crc & Mask) ^ Data[offset+i]]);
+                    }
+                }
+            }
+            else
+            {
+                if (NumBytesPerRegShift == 2)
+                {
+                    for (Int32 i = 0; i < (len / NumBytesPerRegShift); i++)
+                    {
+                        crc = (UInt16) ((crc << NumBitsPerRegShift) ^ lut[((crc >> (16 - NumBitsPerRegShift)) & Mask) ^ ((Data[2 * i + offset] << 8) | Data[2 * i + 1 + offset])]);
+                    }
+                }
+                else
+                {
+                    for (Int32 i = 0; i < len; i++)
+                    {
+                        crc = (UInt16) ((crc << NumBitsPerRegShift) ^ lut[((crc >> (16 - NumBitsPerRegShift)) & Mask) ^ Data[offset+i]]);
+                    }
+                }
+            }
+            // Exclusive OR the result with the specified value
+            currCRC = (UInt16) (crc ^ finalReg);
+            return currCRC;
+        }
+
+        public UInt16 SimpleCRC(Byte[] Data)
+        {
+            UInt16 crc = initReg;
+            Int32 len = Data.Length;
+            Int32 NumBitsPerRegShift = NumBytesPerRegShift * 8;
+            UInt16 Mask = (UInt16)(Math.Pow(2.0, NumBitsPerRegShift) - 1);
+
+            // Perform the algorithm on each byte
+            if (NumBytesPerRegShift == 2)
+            {
+                for (Int32 i = 0; i < (len / NumBytesPerRegShift); i++)
+                {
+                    crc = (UInt16) (((crc << NumBitsPerRegShift) + (UInt16)((Data[2 * i] << 8) | Data[2 * i + 1])) ^ lut[((crc >> (16 - NumBitsPerRegShift)) & Mask)]);
+                }
+            }
+            else
+            {
+                for (Int32 i = 0; i < len; i++)
+                {
+                    crc = (UInt16) (((crc << NumBitsPerRegShift) + Data[i]) ^ lut[((crc >> (16 - NumBitsPerRegShift)) & Mask)]);
+                }
+            }
+            // Exclusive OR the result with the specified value
+            currCRC = (UInt16) (crc ^ finalReg);
+            return currCRC;
+        }
+
+        public UInt16 IncrementalCRC(Byte[] Data)
+        {
+            UInt16 temp = initReg;
+            initReg = (UInt16) (currCRC ^ finalReg);
+            CalculateCRC(Data);
+            initReg = temp;
+            return currCRC;
+        }
+
+        /// <summary>
+        /// Incrementally calculate the CRC using the result of the previous CRC calculation.
+        /// </summary>
+        /// <param name="Data">The input byte array.</param>
+        /// <param name="offset">The offset into the Byte array.</param>
+        /// <param name="count">The number of bytes to use for the CRC calculation.</param>
+        /// <returns>The current incremental CRC32 value.</returns>
+        public UInt16 IncrementalCRC(Byte[] Data, int offset, int count)
+        {
+            UInt16 temp = initReg;
+            initReg = (UInt16)(currCRC ^ finalReg);
+            CalculateCRC(Data,offset,count);
+            initReg = temp;
+            return currCRC;
+        }
+
+        public UInt16 IncrementalSimpleCRC(Byte[] Data)
+        {
+            UInt16 temp = initReg;
+            initReg = currCRC;
+            SimpleCRC(Data);
+            initReg = temp;
+            return currCRC;
+        }
+        
+        public void ResetCRC()
+        {
+            currCRC = initReg;
+        }
+
+        /// <summary>
+        /// Method to reflect a specified number of bits in the integer
+        /// </summary>
+        /// <param name="inVal">The unsigned integer value input</param>
+        /// <param name="num">The number of lower bits to reflect.</param>
+        /// <returns></returns>
+        public UInt16 ReflectNum(UInt16 inVal, Int32 num)
+        {
+            UInt16 outVal = 0x0;
+
+            for (Int32 i = 1; i < (num + 1); i++)
+            {
+                if ((inVal & 0x1) != 0x0)
+                {
+                    outVal |= (UInt16)(0x1 << (num - i));
+                }
+                inVal >>= 1;
+            }
+            return outVal;
+        }
+                
+        #endregion
+    }    
+}
diff --git a/tools/omapl13x_boot_utils/Common/UtilLib/CoffFile.cs b/tools/omapl13x_boot_utils/Common/UtilLib/CoffFile.cs
new file mode 100644 (file)
index 0000000..e288a23
--- /dev/null
@@ -0,0 +1,679 @@
+/*
+ * CoffFile.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+// This module parses a COFF file created by Texas Instruments TMS DSP
+// code generation tools and offers a set of easy to use methods for obtaining
+// information from the COFF file. This information includes header info.,
+// symbol table, section data, etc.
+
+using System;
+using System.Text;
+using System.IO;
+using System.IO.Ports;
+using System.Reflection;
+using System.Threading;
+using System.Globalization;
+using System.Collections;
+using TI.UtilLib;
+using TI.UtilLib.IO;
+
+namespace TI.UtilLib.ObjectFile
+{
+  public enum COFF_Version : ushort
+  {
+    COFF1 = 0x00C1,
+    COFF2 = 0x00C2
+  }
+  
+  public enum COFF_Machine: ushort
+  {
+    CM_TI_ARM           = 0x0097,  // Texas Instruments TMS470 family
+    CM_TI_C5400         = 0x0098,  // Texas Instruments TMS320C5400 family
+    CM_TI_C6000         = 0x0099,  // Texas Instruments TMS320C6000 family
+    CM_TI_C5500         = 0x009C,  // Texas Instruments TMS320C5500 family
+    CM_TI_C2800         = 0x009D,  // Texas Instruments TMS320C2800 family
+    CM_TI_MSP430        = 0x00A0,  // Texas Instruments MSP430
+    CM_TI_C5500p        = 0x00A1,  // Texas Instruments TMS320C5500+ DSP
+  }
+  
+  [Flags]
+  public enum COFF_HeaderFlags: ushort
+  {
+    CF_RELFLG           = 0x0001,
+    CF_EXEC             = 0x0002,
+    CF_LNNO             = 0x0004,
+    CF_LSYMS            = 0x0008,
+    CF_LITTLE           = 0x0100,
+    CF_BIG              = 0x0200,
+    CF_SYMMERGE         = 0x1000
+  }
+    
+  [Flags]
+  public enum COFF_SectionType : uint
+  {
+    REG     = 0x00000000,
+    DUMMY   = 0x00000001,
+    NOLOAD  = 0x00000002,
+    GROUP   = 0x00000004,
+    PAD     = 0x00000008,
+    COPY    = 0x00000010,
+    TEXT    = 0x00000020,
+    DATA    = 0x00000040,
+    BSS     = 0x00000080,
+    BLOCK   = 0x00001000,
+    PASS    = 0x00002000,
+    CLINK   = 0x00004000,
+    VECTOR  = 0x00008000,
+    PADDED  = 0x00010000
+  }
+  
+  public enum COFF_symbolClass : byte
+  {
+    C_NULL    = 0,
+    C_AUTO    = 1,
+    C_EXT     = 2,
+    C_STAT    = 3,
+    C_REG     = 4,
+    C_EXTREF  = 5,
+    C_LABEL   = 6,
+    C_ULABEL  = 7,
+    C_MOS     = 8,
+    C_ARG     = 9,
+    C_STRTAG  = 10,
+    C_MOU     = 11,
+    C_UNTAG   = 12,
+    C_TPDEF   = 13, 
+    C_USTATIC = 14,
+    C_ENTAG   = 15,
+    C_MOE     = 16,
+    C_REGPARM = 17,
+    C_FIELD   = 18,
+    C_UEXT    = 19,
+    C_STATLAB = 20,
+    C_EXTLAB  = 21,
+    C_VARARG  = 27,
+    C_BLOCK   = 100,
+    C_FCN     = 101,
+    C_EOS     = 102,
+    C_FILE    = 103,
+    C_LINE    = 104
+  }
+  
+  public struct COFF_Header
+  {
+    public COFF_Version     c_version;
+    public UInt16           c_shnum;
+    public UInt32           c_datestamp;
+    public UInt32           c_psymtable;
+    public UInt32           c_symnum;
+    public UInt16           c_ehsize;
+    public COFF_HeaderFlags c_flags;
+    public COFF_Machine     c_machine;
+    public Endian           c_endian;
+  }
+
+  /// <summary>
+  /// Public class to read and parse a COFF object file
+  /// </summary>
+  public class CoffFile : ObjectFile
+  {
+    #region Private constants
+    private const UInt32 COFFHeaderSize = 22;
+    private const UInt32 symbolTableEntrySize = 18;
+    #endregion
+  
+    #region Private internal members
+    private COFF_Header hdr;
+    private Hashtable headerRef;
+    private Hashtable[] sectionRef;
+    private Hashtable[] symRef;
+    private Int64       symbolTableFileAddr;
+    private Int64       stringTableFileAddr;
+    #endregion
+
+    #region Public properties and indexers      
+    public Hashtable Header
+    {
+      get { return headerRef; }
+    }      
+    #endregion
+
+    #region Public Class constructor(s)
+    public CoffFile(String filename) : base(filename)
+    {
+      // Init header hashtable
+      headerRef = new Hashtable();
+      
+      // Parse the COFF file
+      try
+      {
+        ParseCoffFile();
+      }
+      catch (Exception e)
+      {
+        Console.Write(e.Message);
+        throw e;
+      }
+      
+      fileType = ObjectFileType.COFF;
+    }   
+    #endregion
+
+    #region Public Class Methods
+    public void dumpFileHeader()
+    {
+      foreach (DictionaryEntry de in headerRef)
+      {
+        Console.WriteLine("header[{0}] = {1}", de.Key, de.Value);
+      }
+    }
+
+    public new String ToString()
+    {
+      StringBuilder strBuilder = new StringBuilder(512);
+      
+      dumpFileHeader();
+      
+      strBuilder.Append(base.ToString());
+
+      return strBuilder.ToString();
+    }
+    
+    #endregion
+
+    #region Private Methods
+    private void ParseCoffFile()
+    {
+      // Output console message
+      Console.WriteLine("Parsing the input object file, {0}.", fileName);
+      
+      // Parse the COFF header
+      try
+      {
+        hdr = CoffFile.ParseCOFFHeader(binFile);
+      }
+      catch (Exception e)
+      {
+        Console.Write(e.Message);
+        return;
+      }
+      
+      // Set section count
+      sectionCount = hdr.c_shnum;
+      symbolCount  = hdr.c_symnum;
+      
+      // Set Table File Addresses
+      symbolTableFileAddr = (Int64) hdr.c_psymtable;
+      stringTableFileAddr = (Int64) (symbolTableFileAddr + (symbolTableEntrySize * symbolCount));
+      
+      // Set endianness
+      endian = hdr.c_endian;
+      Debug.DebugMSG("Endianness: " + endian.ToString());
+      
+      binFile.Seek(0, SeekOrigin.Begin);
+      EndianBinaryReader ebr = new EndianBinaryReader(binFile, hdr.c_endian);
+      
+      headerRef["numBootSections"] = (UInt32)0;
+
+      // Read the optional COFF header
+      if (hdr.c_ehsize != 0)
+      {
+        ebr.BaseStream.Seek(COFFHeaderSize,SeekOrigin.Begin);
+        headerRef["optMagicNumber"] = (UInt32) ebr.ReadUInt16();
+        Debug.DebugMSG("optMagicNumber: " + ((UInt32)headerRef["optMagicNumber"]).ToString("X4"));
+
+        headerRef["optVersionStamp"] = (UInt32)ebr.ReadUInt16();
+        Debug.DebugMSG("optVersionStamp: " + ((UInt32)headerRef["optVersionStamp"]).ToString("X4"));
+
+        headerRef["optExeSize"] = ebr.ReadUInt32();
+        Debug.DebugMSG("optExeSize: " + ((UInt32)headerRef["optExeSize"]).ToString("X8"));
+
+        headerRef["optInitSize"] = ebr.ReadUInt32();
+        Debug.DebugMSG("optInitSize: " + ((UInt32)headerRef["optInitSize"]).ToString("X8"));
+
+        headerRef["optUninitSize"] = ebr.ReadUInt32();
+        Debug.DebugMSG("optUninitSize: " + ((UInt32)headerRef["optUninitSize"]).ToString("X8"));
+
+        entryPoint = (UInt64) ebr.ReadUInt32();
+        headerRef["optEntryPoint"] = (UInt32) entryPoint;
+        Debug.DebugMSG("optEntryPoint: " + ((UInt32)headerRef["optEntryPoint"]).ToString("X8"));
+        
+        headerRef["optExeAddr"] = ebr.ReadUInt32();
+        Debug.DebugMSG("optExeAddr: " + ((UInt32)headerRef["optExeAddr"]).ToString("X8"));
+
+        headerRef["optInitAddr"] = ebr.ReadUInt32();
+        Debug.DebugMSG("optInitAddr: " + ((UInt32)headerRef["optInitAddr"]).ToString("X8"));
+      }
+     
+      // Read the section headers
+      ParseSectionHdrs();
+
+      // Parse the symbol table
+      ParseSymbolTable();
+    } // end ParseCOFFFile()
+
+    
+    /// <summary>
+    /// Parse the section headers.
+    /// </summary>
+    private void ParseSectionHdrs()
+    {
+      UInt32 numBytesInSectionHdr;
+      EndianBinaryReader ebr = new EndianBinaryReader(binFile, endian);
+
+      if (hdr.c_version == COFF_Version.COFF2)
+      {
+        numBytesInSectionHdr = 48;
+      }
+      else if (hdr.c_version == COFF_Version.COFF1)
+      {
+        numBytesInSectionHdr = 40;
+      }
+      else
+      {
+        numBytesInSectionHdr = 0;
+      }
+                    
+      sectionRef  = new Hashtable[sectionCount];
+      sections    = new ObjectSection[sectionCount];
+      
+      for (UInt16 secNum = 0; secNum < sectionCount; secNum++)
+      {
+        sectionRef[secNum] = new Hashtable();
+        sections[secNum]   = new ObjectSection();
+
+        ebr.BaseStream.Seek(numBytesInSectionHdr * secNum + COFFHeaderSize + hdr.c_ehsize, SeekOrigin.Begin);
+        sections[secNum].name         = COFF_getName();
+
+        ebr.BaseStream.Seek(numBytesInSectionHdr * secNum + COFFHeaderSize + hdr.c_ehsize + 8, SeekOrigin.Begin);
+        sections[secNum].runAddr      = (UInt64) ebr.ReadUInt32();
+        sections[secNum].loadAddr     = (UInt64) ebr.ReadUInt32();
+        sections[secNum].size         = (UInt64) ebr.ReadUInt32();
+        sections[secNum].size         = ((sections[secNum].size + 3) >> 2) << 2;
+        sections[secNum].binFileAddr  = (UInt64) ebr.ReadUInt32();
+
+        sectionRef[secNum]["reloPtr"] = ebr.ReadUInt32();
+        sectionRef[secNum]["linePtr"] = ebr.ReadUInt32();
+
+        if (hdr.c_version == COFF_Version.COFF2)
+        {
+          sectionRef[secNum].Add("numRelos", ebr.ReadUInt32());
+          sectionRef[secNum].Add("numLines", ebr.ReadUInt32());
+          sectionRef[secNum].Add("flags", ebr.ReadUInt32());
+          sectionRef[secNum].Add("reserved", (UInt32) ebr.ReadUInt16());
+          sectionRef[secNum].Add("memPage", (UInt32) ebr.ReadUInt16());
+        }
+        else
+        {
+          sectionRef[secNum].Add("numRelos", (UInt32) ebr.ReadUInt16());
+          sectionRef[secNum].Add("numLines", (UInt32) ebr.ReadUInt16());
+          sectionRef[secNum].Add("flags", (UInt32) ebr.ReadUInt16());
+          sectionRef[secNum].Add("reserved", (UInt32) ebr.ReadByte());
+          sectionRef[secNum].Add("memPage", (UInt32) ebr.ReadByte());
+        }
+
+        //Check to see if section is bootable
+        UInt32 flags = (UInt32)sectionRef[secNum]["flags"];
+        sectionRef[secNum]["bootable"] = false;
+        if ((flags & ((UInt32)(COFF_SectionType.TEXT | COFF_SectionType.DATA))) != 0)
+        {
+          if ((flags & ((UInt32)COFF_SectionType.COPY)) == 0)
+          {
+            if (sections[secNum].size != 0)
+            {
+              headerRef["numBootSections"] = ((UInt32)headerRef["numBootSections"]) + 1;
+              sectionRef[secNum]["bootable"] = true;
+            }
+          }
+        }
+
+        // Check to see if section is loadable
+        sections[secNum].isLoadable = false;
+        if ( ( sections[secNum].binFileAddr != 0 ) && ( sections[secNum].size != 0 ) )
+        {
+          if ((flags & ((UInt32)(COFF_SectionType.BSS |        // No BSS sections
+                        COFF_SectionType.COPY |                // No COPY sections
+                        COFF_SectionType.NOLOAD |              // No NOLOAD sections
+                        COFF_SectionType.DUMMY))               // No DUMMY sections
+               ) == 0)
+          {
+            sections[secNum].isLoadable = true;
+            loadableSectionCount++;
+          }
+        }
+        
+        Debug.DebugMSG("ObjectSection sections[" + secNum + "] = \n{");
+        Debug.DebugMSG("\tname = " + sections[secNum].name + ",");
+        Debug.DebugMSG("\tsize = " + sections[secNum].size.ToString("X8") + ",");
+        Debug.DebugMSG("\trunAddr = " + sections[secNum].runAddr.ToString("X8") + ",");
+        Debug.DebugMSG("\tloadAddr = " + sections[secNum].loadAddr.ToString("X8") + ",");
+        Debug.DebugMSG("\tisLoadable = " + sections[secNum].isLoadable + ",");
+        Debug.DebugMSG("\tbinFileAddr = " + sections[secNum].binFileAddr.ToString("X8"));
+        Debug.DebugMSG("}");
+      }
+      
+      // Fill in the loadableSections array
+      loadableSections = new ObjectSection[loadableSectionCount];
+      for (UInt32 secNum = 0,loadableSecNum=0; secNum < sectionCount; secNum++)
+      {
+        if (sections[secNum].isLoadable)
+        {
+          loadableSections[loadableSecNum] = sections[secNum];
+          loadableSecNum++;
+        }
+      }
+      
+      // Finally, sort the loadable sections array by load address
+      Array.Sort<ObjectSection>(loadableSections);
+      
+      Debug.DebugMSG("Parse Section Headers Done");
+    } // end of ParseSectionHdrs()
+
+    
+    /// <summary>
+    /// Parse the COFF file's symbol table.
+    /// </summary>
+    private void ParseSymbolTable()
+    {
+      EndianBinaryReader ebr = new EndianBinaryReader(binFile, endian);
+      Int64 currSymbolTableEntryFileAddr = symbolTableFileAddr;
+      
+      symRef  = new Hashtable[symbolCount];
+      symbols = new ObjectSymbol[symbolCount];
+      
+      Debug.DebugMSG("Begin parsing symbol table.  Symbol Count = " + symbolCount + ".\n");
+      
+      // Read the symbol table
+      for (UInt32 symNum = 0; symNum < symbolCount; symNum++)
+      {
+        symRef[symNum]  = new Hashtable();
+        symbols[symNum] = new ObjectSymbol();
+        
+        Debug.DebugMSG("symbols[" + symNum + "] = \n{");        
+        
+        ebr.BaseStream.Seek( (UInt32)currSymbolTableEntryFileAddr, SeekOrigin.Begin);
+        symbols[symNum].name = COFF_getName();
+        
+        Debug.DebugMSG("\tname = " + symbols[symNum].name);        
+        
+        ebr.BaseStream.Seek( (UInt32)currSymbolTableEntryFileAddr + 8, SeekOrigin.Begin);
+        symbols[symNum].value = (UInt64) ebr.ReadUInt32();
+        
+        Debug.DebugMSG("\tvalue = " + symbols[symNum].value.ToString("X8") + ",");
+        
+        symRef[symNum]["secNum"]  = (Int32)  ebr.ReadInt16();
+        symRef[symNum]["type"]    = (UInt32) ebr.ReadUInt16();
+        symRef[symNum]["class"]   = (UInt32) ebr.ReadByte();
+        symRef[symNum]["auxNum"]  = (UInt32) ebr.ReadByte();
+        
+        
+        Debug.DebugMSG("\tsecNum = " + ((Int32)symRef[symNum]["secNum"]).ToString());
+        Debug.DebugMSG("\ttype   = " + ((UInt32)symRef[symNum]["type"]).ToString("X4"));
+        Debug.DebugMSG("\tclass  = " + ((UInt32)symRef[symNum]["class"]).ToString());
+        Debug.DebugMSG("\tauxNum = " + ((UInt32)symRef[symNum]["auxNum"]).ToString("X2"));
+        
+        // Check to make sure auxNum is either 0 or 1
+        if ((((UInt32)symRef[symNum]["auxNum"]) != 0) && (((UInt32)symRef[symNum]["auxNum"]) != 1))
+        {
+          throw new Exception("Invalid auxNum (" + ((UInt32)symRef[symNum]["auxNum"]) + ") detected for symbol " + symbols[symNum].name + ".");
+        }
+        
+        if (((UInt32)symRef[symNum]["auxNum"]) != 0)
+        {
+          currSymbolTableEntryFileAddr += 2*symbolTableEntrySize;
+          symNum++;
+          
+          symRef[symNum] = null;
+          symbols[symNum] = new ObjectSymbol();
+          
+          symbols[symNum].name = "";
+          symbols[symNum].value = symbols[symNum-1].value;
+          
+          Debug.DebugMSG("\tsectionLength       = " + (UInt32) ebr.ReadInt32());
+          Debug.DebugMSG("\tnumRelocEntries     = " + (UInt32) ebr.ReadUInt16());
+          Debug.DebugMSG("\tnumLineNumberntries = " + (UInt32) ebr.ReadUInt16());
+        }
+        else
+        {
+          currSymbolTableEntryFileAddr += symbolTableEntrySize;
+        }
+        
+        Debug.DebugMSG("}");                
+      }
+      
+      // Finally, sort the symbols by value (address)
+      Array.Sort<ObjectSymbol>(symbols);
+      
+      Debug.DebugMSG("Parse Symbol Table Done");
+    } // end of ParseSymbolTable()
+
+    
+    /// <summary>
+    /// Function to retrieve name string either from string table or from current stream pointer.
+    /// </summary>
+    /// <returns>String containing name.</returns>
+    private String COFF_getName()
+    {
+      Int64 currPos = binFile.Position;
+      UInt32 int0,int1;
+      Byte currByte;
+      ArrayList name = new ArrayList(128);
+                  
+      EndianBinaryReader ebr =  new EndianBinaryReader(binFile,endian);
+      int0 = ebr.ReadUInt32();
+      int1 = ebr.ReadUInt32();
+      ebr.BaseStream.Seek(currPos,SeekOrigin.Begin);
+      
+      if (int0 == 0x00000000)
+      { 
+        if ((int1 + stringTableFileAddr) > binFile.Length)
+        {
+          Console.WriteLine("WARNING: Symbol name's offset in string table is beyond EOF! Returning NULL.\n");
+        }
+        else
+        {
+          ebr.BaseStream.Seek((int1 + (UInt32)stringTableFileAddr),SeekOrigin.Begin);
+        
+          // Read characters and build string until terminating null
+          currByte = ebr.ReadByte();
+          
+          while (currByte != 0)
+          {
+            name.Add(currByte);
+            currByte = ebr.ReadByte();
+          }
+        }
+      }
+      else
+      {
+        // Read characters straight from string table and build string until terminating null
+        currByte = ebr.ReadByte();
+        while ( (currByte != 0) && (name.Count < 8) )
+        {
+          name.Add(currByte);
+          currByte = ebr.ReadByte();
+        }
+      }
+      ebr.BaseStream.Seek(currPos, SeekOrigin.Begin);
+      if (name.Count > 128)
+      {
+        Debug.DebugMSG(ASCIIEncoding.ASCII.GetString((Byte[])name.ToArray(typeof(Byte)), 0, name.Count));
+      }
+      return ASCIIEncoding.ASCII.GetString((Byte[]) name.ToArray(typeof(Byte)), 0, name.Count);
+    }
+    #endregion
+      
+    #region Public Static Class Methods
+    public static Boolean IsCoffFile(String filename)
+    {        
+      // Get File Details
+      try
+      {
+        if (File.Exists(filename))
+        {
+          // Parse the input file header
+          using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read))
+          {
+            ParseCOFFHeader(fs);
+          }
+        }
+      }
+      catch
+      {
+        //Console.Write(e.Message);
+        return false;
+      }
+      return true;
+    }
+    
+    public static Endian GetCOFFEndianness(Stream fs)
+    {
+      Endian endian = null;
+      Int64 tempPos = fs.Position;
+      
+      // Read COFF Header
+      fs.Seek(20, SeekOrigin.Begin);
+      
+      BinaryReader br = new BinaryReader(fs);
+      
+      {  
+        // Check for COFF magic number and endianness
+        UInt16 val = br.ReadByte();
+        if (val == 0x00)
+        {
+          // Check for big endian
+          val = (UInt16)br.ReadByte();
+          if ( Enum.IsDefined(typeof(COFF_Machine),val) )
+          {
+            endian = Endian.BigEndian;
+            if ( (val != (UInt16) COFF_Machine.CM_TI_C6000) && 
+                 (val != (UInt16) COFF_Machine.CM_TI_ARM)   &&
+                 (val != (UInt16) COFF_Machine.CM_TI_MSP430)   )
+            {
+              throw new Exception("Big endian detected for invalid machine type: " + Enum.GetName(typeof(COFF_Machine),val));
+            }
+          }
+        }
+        else if (br.ReadByte() == 0x00)
+        {
+          if ( Enum.IsDefined(typeof(COFF_Machine),val) )
+          {
+            endian = Endian.LittleEndian;
+          }
+        }
+        else
+        {
+          throw new Exception("Unknown COFF magic number.");
+        }        
+      }
+      
+      // Get stream back to where it was
+      fs.Seek(tempPos, SeekOrigin.Begin);
+      
+      return endian;
+    }
+    
+    public static COFF_Header ParseCOFFHeader(Stream fs)
+    {
+      COFF_Header hdr;
+      
+      // Go to start of COFF file stream
+      fs.Seek(0, SeekOrigin.Begin);
+
+      // Figure out COFF endianness
+      hdr.c_endian = GetCOFFEndianness(fs);
+      
+      // Create binary endian reader
+      EndianBinaryReader ebr = new EndianBinaryReader(fs, hdr.c_endian);
+      
+      { 
+        // Read the main COFF header
+        // Only COFF type 1 and type 2 supported
+        hdr.c_version = (COFF_Version) ebr.ReadUInt16();;
+        Debug.DebugMSG("versionID: " + hdr.c_version);
+        
+        hdr.c_shnum = ebr.ReadUInt16();
+        Debug.DebugMSG("numSectionHdrs: " + hdr.c_shnum.ToString("X4"));
+        
+        hdr.c_datestamp = ebr.ReadUInt32();
+        Debug.DebugMSG("datestamp: " + hdr.c_datestamp.ToString("X8"));
+        
+        hdr.c_psymtable = ebr.ReadUInt32();
+        Debug.DebugMSG("symbolTableAddr: " + hdr.c_psymtable.ToString("X8"));
+        
+        hdr.c_symnum = ebr.ReadUInt32();
+        Debug.DebugMSG("numEntriesInSymTable: " + hdr.c_symnum.ToString("X8"));
+
+        hdr.c_ehsize = ebr.ReadUInt16();
+        Debug.DebugMSG("hdr.c_ehsize: " + hdr.c_ehsize.ToString("X4"));
+        
+        hdr.c_flags = (COFF_HeaderFlags) ebr.ReadUInt16();
+        Debug.DebugMSG("flags: " + hdr.c_flags);
+        
+        hdr.c_machine = (COFF_Machine) ebr.ReadUInt16();
+        Debug.DebugMSG("machineType: " + hdr.c_machine);
+        
+        // Check endianness in flags, check for match
+        /*
+        if ((hdr.c_flags & COFF_HeaderFlags.CF_LITTLE) == COFF_HeaderFlags.CF_LITTLE)
+        {
+          if (!endian.isLittleEndian())
+          {
+            throw new Exception("Endianness mismatch in header flags!");
+          }
+        }
+        else if ((hdr.c_flags & COFF_HeaderFlags.CF_BIG) == COFF_HeaderFlags.CF_BIG)
+        {
+          if (!endian.isBigEndian())
+          {
+            throw new Exception("Endianness mismatch in header flags!");
+          }
+        }
+        else
+        {
+          throw new Exception("Endianness flag not set!");
+        }*/
+      }
+      
+      return hdr;
+    }
+    #endregion
+    
+  } //End CoffFile class
+
+} //end of namespace
diff --git a/tools/omapl13x_boot_utils/Common/UtilLib/ConsoleUtility.cs b/tools/omapl13x_boot_utils/Common/UtilLib/ConsoleUtility.cs
new file mode 100644 (file)
index 0000000..1d502c0
--- /dev/null
@@ -0,0 +1,382 @@
+/*
+ * ConsoleUtility.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+/****************************************************************
+ *  TI UtilLib.ConsoleUtility namespace: Useful Console Utils   *
+ *  (C) 2007, Texas Instruments, Inc.                           *
+ *                                                              *
+ * Author:  Daniel Allred                                       *
+ *                                                              *
+ ****************************************************************/
+
+using System;
+using System.Text;
+
+namespace TI.UtilLib.ConsoleUtility
+{
+  public enum Position : uint
+  {
+    NONE = 0,
+    TOP,
+    BOTTOM,
+    RIGHT,
+    LEFT,
+  }
+    
+    public class ProgressBar
+    {
+        #region Private Variables
+
+        private Int32 posYBar, posXBar;
+        private Int32 posYPercent,posXPercent;
+        private Int32 posYText, posXText;
+        private Int32 barWidth, totalWidth;
+        private Position percPosition, textPosition;
+        private Double percent;
+        private String text;
+
+        #endregion
+
+        #region Private Properties
+
+        private Position PercentPosition
+        {
+          get
+          {
+            return percPosition;
+          }
+          set
+          {
+            if ((value == Position.BOTTOM) || (value == Position.TOP))
+            {
+                percPosition = Position.LEFT;
+            }
+            else
+            {
+                percPosition = value;
+            }
+          }
+        }
+
+        private Position TextPosition
+        {
+          get
+          {
+            return textPosition;
+          }
+          set
+          {
+            if ((value == Position.RIGHT) || (value == Position.LEFT))
+            {
+              textPosition = Position.BOTTOM;
+            }
+            else
+            {
+              textPosition = value;
+            }
+          }
+        }
+
+        #endregion
+
+        #region Public Properties
+
+        /// <summary>
+        /// Set the percentage completeness of the progress bar.
+        /// </summary>
+        public Double Percent
+        {
+          get
+          {
+            return percent;
+          }
+          set
+          {
+            percent = (value > 1) ? 1 : value;
+            UpdatePercent();
+            if (percent == 1)
+            {
+              Console.CursorVisible = true;
+            }
+          }
+        }
+
+        /// <summary>
+        /// Set the status text field
+        /// </summary>
+        public String Text
+        {
+          get
+          {
+            return text;
+          }
+          set
+          {
+            text = value;
+            UpdateText();
+          }
+        }
+        #endregion
+
+        #region Class Constructors
+        /// <summary>
+        /// Default constructor
+        /// </summary>
+        public ProgressBar():this(60)
+        {
+        }
+
+        /// <summary>
+        /// Variable-width ProgressBar constructor
+        /// </summary>
+        /// <param name="charWidth">Width of progress bar.</param>
+        public ProgressBar(Int32 charWidth): this(charWidth,Position.LEFT,Position.BOTTOM)
+        {
+        }
+
+        /// <summary>
+        /// Variable-width and variable percent location ProgressBar constructor
+        /// </summary>
+        /// <param name="charWidth">Width of status bar in characters.</param>
+        /// <param name="pos">StatusPosition enum value.</param>
+        /// <param name="percentPos">Position enum for Percentage location.</param>
+        /// <param name="txtPos">Position enum for the text location.</param>
+      
+        public ProgressBar(Int32 charWidth, Position percentPos, Position textPos)
+        {
+          Int32 prevCursorTop;
+          
+          // Make sure we are starting on a clean, new line           
+          if (Console.CursorLeft != 0)
+          {
+            Console.WriteLine();
+          }
+          
+          // Set private member values
+          PercentPosition = percentPos;
+          TextPosition = textPos;
+          barWidth = charWidth;
+          percent = 0.0;
+          
+          posYText    = -1;  posXText    = -1;
+          posYPercent = -1;  posXPercent = -1;
+          posYBar     = -1;  posXBar     = -1;
+          
+          //Make the cursor invisible
+          Console.CursorVisible = false;
+
+          // Place initial fields
+          if (TextPosition == Position.TOP)
+          {
+            posYText = Console.CursorTop;
+            posXText = Console.CursorLeft;
+            prevCursorTop = Console.CursorTop;
+            Console.WriteLine("Status Undefined");
+            if (Console.CursorTop == prevCursorTop)
+            {
+              // This indicates that we hit the end of the buffer and 
+              // that everything scrolled up
+              posYText = (posYText<0) ? posYText : (posYText-1);
+              posYPercent = (posYPercent<0) ? posYPercent : (posYPercent-1);
+              posYBar = (posYBar<0) ? posYBar : (posYBar-1);
+            }
+          }
+          if (PercentPosition == Position.LEFT)
+          {
+            posXPercent = Console.CursorLeft;
+            posYPercent = Console.CursorTop;
+            Console.Write(" {0,3:D}% ", 0);
+          }
+          
+          Console.Write("[ ");
+          posYBar = Console.CursorTop;
+          posXBar = Console.CursorLeft;
+          for (int i = 0; i < barWidth; i++)
+          {
+            Console.Write("-");
+          }
+          Console.Write(" ]");
+          
+          if (PercentPosition == Position.RIGHT)
+          {
+            posXPercent = Console.CursorLeft;
+            posYPercent = Console.CursorTop;                
+            Console.Write(" {0,3:D}% ", 0);
+          }
+          totalWidth = Console.CursorLeft;
+
+          if (Console.CursorLeft != 0)
+          {
+            prevCursorTop = Console.CursorTop;
+            Console.WriteLine();
+            if (Console.CursorTop == prevCursorTop)
+            {
+              // This indicates that we hit the end of the buffer and 
+              // that everything scrolled up
+              posYText = (posYText<0) ? posYText : (posYText-1);
+              posYPercent = (posYPercent<0) ? posYPercent : (posYPercent-1);
+              posYBar = (posYBar<0) ? posYBar : (posYBar-1);
+            }
+          }
+          if (TextPosition == Position.BOTTOM)
+          {
+            posYText = Console.CursorTop;
+            posXText = Console.CursorLeft;
+            prevCursorTop = Console.CursorTop;
+            Console.WriteLine("Status Undefined");
+            if (Console.CursorTop == prevCursorTop)
+            {
+              // This indicates that we hit the end of the buffer and 
+              // that everything scrolled up
+              posYText = (posYText<0) ? posYText : (posYText-1);
+              posYPercent = (posYPercent<0) ? posYPercent : (posYPercent-1);
+              posYBar = (posYBar<0) ? posYBar : (posYBar-1);
+            }
+          }
+
+          //Go to a new line so any future text can be placed
+          prevCursorTop = Console.CursorTop;
+          Console.WriteLine();
+          if (Console.CursorTop == prevCursorTop)
+          {
+            // This indicates that we hit the end of the buffer and 
+            // that everything scrolled up
+            posYText = (posYText<0) ? posYText : (posYText-1);
+            posYPercent = (posYPercent<0) ? posYPercent : (posYPercent-1);
+            posYBar = (posYBar<0) ? posYBar : (posYBar-1);
+          }
+        }
+        #endregion
+
+        #region Class methods
+
+        #region Public Methods
+        public void Update(Double percent, String status)
+        {
+          Percent = percent;
+          Text = "".PadLeft(totalWidth,Char.Parse(" "));
+          Text = status;
+        }
+        
+        public void WriteLine(String text)
+        {
+          this.Write(text+"\n");
+        }
+        
+        public void Write(String text)
+        {
+          Int32 prevCursorTop;
+          Int32 newLineCount = 0;
+          
+          //Count newlines in text to figure out how much buffer will scroll
+          newLineCount = text.Split(Char.Parse("\n")).Length - 1;
+          
+          prevCursorTop = Console.CursorTop;
+          Console.Write(text);
+          if ((Console.CursorTop - prevCursorTop) < newLineCount)
+          {
+            Int32 shiftValue = newLineCount - (Console.CursorTop - prevCursorTop);
+            // This indicates that we hit the end of the buffer and 
+            // that everything scrolled up
+            posYText = (posYText<0) ? posYText : (posYText-shiftValue);
+            posYPercent = (posYPercent<0) ? posYPercent : (posYPercent-shiftValue);
+            posYBar = (posYBar<0) ? posYBar : (posYBar-shiftValue);
+          }
+        }
+        
+        
+        #endregion
+        
+        #region Public Static Methods
+        public static void WriteLine(ProgressBar pb, String text)
+        {
+          pb.WriteLine(text);
+        }
+        
+        public static void Write(ProgressBar pb, String text)
+        {
+          pb.Write(text);
+        }
+        
+        #endregion
+
+        #region Private helper functions
+        private void UpdatePercent()
+        {
+            // Save current cursor position
+            int oldCursorTop = Console.CursorTop, oldCursorLeft = Console.CursorLeft;
+            
+            // Update the percent if needed
+            if (PercentPosition != Position.NONE)
+            {
+                Console.SetCursorPosition(posXPercent,posYPercent);
+                Console.Write(" {0,3:D}% ", (Int32)(Percent*100));
+            }
+
+            // Update the progress bar
+            Console.SetCursorPosition(posXBar,posYBar);
+            Int32 numOfBlocks = (Int32)Math.Floor(barWidth * Percent);
+            Console.Write("".PadLeft(numOfBlocks,Char.Parse("\u2588")));
+            
+            // Reset the cursor location            
+            Console.SetCursorPosition(oldCursorLeft, oldCursorTop);
+        }
+
+        private void UpdateText()
+        {
+            int oldCursorTop = Console.CursorTop, oldCursorLeft = Console.CursorLeft;
+
+            // Update the text field
+            if (TextPosition != Position.NONE)
+            {
+                Console.SetCursorPosition(posXText, posYText);
+                if (text.Length < totalWidth)
+                    Console.Write(text.PadLeft((totalWidth + text.Length) / 2));
+                else
+                    Console.Write(text);
+            }
+            
+            // Reset the cursor location            
+            Console.SetCursorPosition(oldCursorLeft, oldCursorTop);
+        }
+        #endregion
+
+        #endregion
+
+    }
+}
\ No newline at end of file
diff --git a/tools/omapl13x_boot_utils/Common/UtilLib/CryptoLoadMod.cs b/tools/omapl13x_boot_utils/Common/UtilLib/CryptoLoadMod.cs
new file mode 100644 (file)
index 0000000..35a6481
--- /dev/null
@@ -0,0 +1,579 @@
+/*
+ * CryptoLoadMod.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+using System;
+using System.Collections;
+using System.Globalization;
+using System.IO;
+using System.IO.Ports;
+using System.Reflection;
+using System.Security.Cryptography;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading;
+
+using TI.UtilLib;
+using TI.UtilLib.IO;
+using TI.UtilLib.Ini;
+using TI.AISLib;
+
+namespace TI.UtilLib.Crypto
+{ 
+  public enum SHA_Algorithm : int
+  {
+    SHA1 = 0x0,
+    SHA256 = 0x1,
+    SHA384 = 0x2,
+    SHA512 = 0x3
+  }
+  
+  public enum SecureLoadMagic : uint
+  {
+    // Load module magic ID
+    LOADMOD_MAGIC   = 0x70ADC0DE,
+    // Key certificate magic ID
+    CERT_MAGIC      = 0x70ADCE87,
+    // Generic user key magic ID
+    GENKEY_MAGIC    = 0xBE40C0DE
+  }
+  public class LoadModule
+  {
+    public SecureLoadMagic MagicNum;
+    
+    public UInt32 bufSize;
+    
+    // Private security type variable
+    public AisSecureType SecureType;
+    
+    // Encryption Key
+    public Byte[] customerEncryptionKey;
+    public Byte[] certEncryptionKey;
+    public Byte[] CEKInitialValue;
+    public Byte[] keyEncryptionKey;
+
+    // RSA Object
+    public RSACryptoServiceProvider rsaObject;
+    public RSACryptoServiceProvider certRsaObject;
+    
+    // Variable for current selected Hash algorihtm
+    public SHA_Algorithm currHashAlgorithmValue;
+    public HashAlgorithm currHashAlgorithm;
+    
+    public Boolean encryptData;
+    
+    public LoadModule()
+    {
+      SecureType = AisSecureType.NONE;
+      MagicNum = SecureLoadMagic.LOADMOD_MAGIC;
+      certRsaObject = null;
+      rsaObject = null;
+      certEncryptionKey = null;
+      customerEncryptionKey = null;
+    }
+    
+    public LoadModule(AisSecureType secureType, SecureLoadMagic magic): this()
+    {
+      SecureType = secureType;
+      MagicNum = magic;
+    }
+    
+    public LoadModule(AisSecureType secureType, SecureLoadMagic magic, String encKey, String rsaKeyFileName) : this()
+    {
+      String currHashAlgorithmString = "SHA1";  // Default hash algorithm
+    
+      SecureType = secureType;
+      MagicNum = magic;
+    
+      // Get the encryption key
+      customerEncryptionKey = new Byte[16];
+      CEKInitialValue = new Byte[16];
+      
+      if (encKey.Length != 32)
+      {
+        throw new ArgumentException("AES Encryption Key is wrong length!");
+      }
+      for (int j=0; j<encKey.Length; j+=2)
+      {
+        customerEncryptionKey[(j>>1)] = Convert.ToByte(encKey.Substring(j,2),16);
+      }
+      
+      // Generate IV as encrypted version of AES Key
+      using (MemoryStream ms = new MemoryStream(CEKInitialValue))
+      {
+        Aes myAES = new AesManaged();
+        myAES.KeySize = 128;
+        myAES.Mode = CipherMode.ECB;
+        myAES.Padding = PaddingMode.None;
+        ICryptoTransform encryptor = myAES.CreateEncryptor(customerEncryptionKey, new Byte[16]);
+        CryptoStream cs = new CryptoStream(ms,encryptor,CryptoStreamMode.Write);
+        cs.Write(customerEncryptionKey,0,customerEncryptionKey.Length);
+      }
+      
+      // Get RSA key
+      rsaObject = RSAKey.LoadFromFile(rsaKeyFileName);
+      if (rsaObject == null)
+      {
+        throw new ArgumentException("RSA key loading failed!");
+      }
+      
+      // Update the hash algo string if RSA key size is 2048 bits
+      if (rsaObject.KeySize == 2048)
+      {
+        currHashAlgorithmString = "SHA256";
+        currHashAlgorithmValue = SHA_Algorithm.SHA256;
+      }
+      
+      try
+      {
+        currHashAlgorithm = HashAlgorithm.Create(currHashAlgorithmString);
+      }
+      catch (Exception e)
+      {
+        Console.WriteLine("Invalid Hash Algorithm Selected. Exception message: {0}.",e.Message);
+        throw e;
+      }
+    }
+    
+    public LoadModule(IniFile iniFile) : this()
+    {
+      if (SecurityIniSectionParse(this, iniFile) != retType.SUCCESS)
+      {
+        throw new ArgumentException();
+      }
+    }
+    
+    public static Byte[] GenerateCertData(LoadModule loadMod)
+    {
+      Byte[] delegateKeyData = null;
+     
+      if (loadMod.SecureType == AisSecureType.CUSTOM)
+      {
+        // Create Delegate Key Certificate Format
+        //Key cert: 32 + (128 or 256) bytes
+        //  decryptionKey: 16 byte (128 bits) AES key
+
+        //  rsaPublicKey: 8 bytes + 128/256 for modulus data (actual modulus data may only be 128 bytes for RSA1024)
+        //    keyExponent: 4 bytes
+        //    keyPad: 2 bytes
+        //    modLength: 2 bytes
+        //    modData: 128 or 256 bytes
+        //  keyFlags: 8 bytes
+      
+        delegateKeyData = new Byte[32 + (loadMod.rsaObject.KeySize >> 3)];
+      
+        // Fill with random data
+        (new Random()).NextBytes(delegateKeyData);
+        
+        // Insert decryptionKey at offset 0
+        loadMod.certEncryptionKey.CopyTo(delegateKeyData, 0);
+        
+        // Insert rsaPublicKey at offset 16
+        RSAKey.CreateCustomSecureKeyVerifyStruct(loadMod.certRsaObject).CopyTo(delegateKeyData, 16);
+        
+        // Insert flags data
+        BitConverter.GetBytes((UInt32)0x00000000).CopyTo(delegateKeyData, 24 + (loadMod.rsaObject.KeySize >> 3) );
+        BitConverter.GetBytes((UInt32)0x00000000).CopyTo(delegateKeyData, 28 + (loadMod.rsaObject.KeySize >> 3) );
+        
+      }
+      else if (loadMod.SecureType == AisSecureType.GENERIC)
+      {
+        delegateKeyData = new Byte[32];
+      
+        // Fill with random data
+        (new Random()).NextBytes(delegateKeyData);
+        
+        // Insert decryptionKey at offset 0
+        loadMod.certEncryptionKey.CopyTo(delegateKeyData, 0);
+        
+        // Insert flags data
+        BitConverter.GetBytes((UInt32)0x00000000).CopyTo(delegateKeyData, 16 );
+        BitConverter.GetBytes((UInt32)0x00000000).CopyTo(delegateKeyData, 20 );
+        BitConverter.GetBytes((UInt32)0x00000000).CopyTo(delegateKeyData, 24 );
+        BitConverter.GetBytes((UInt32)0x00000000).CopyTo(delegateKeyData, 28 );        
+      }
+      
+      return delegateKeyData;
+    }
+    
+    public static Byte[] GenerateLoadModule(LoadModule loadMod, Byte[] loadData)
+    {
+      Byte[] outputData, sigData;
+      Byte[] outputDataSigOrder, encOutputData;
+      Int32 sigSize = 0;
+      
+      if (loadMod.SecureType == AisSecureType.CUSTOM)
+      {
+        sigSize = (loadMod.rsaObject.KeySize >> 3);
+      }
+      else if (loadMod.SecureType == AisSecureType.GENERIC)
+      {
+        sigSize = 32;
+      }
+      
+      if ((loadData.Length % 16) != 0)
+      {
+        Int32 len = ((loadData.Length + 15) / 16) * 16;
+        Byte[] temp = new Byte[len];
+        loadData.CopyTo(temp,0);
+        loadData = temp;
+      }
+      
+      outputData = new Byte[loadData.Length + 16 + sigSize];
+    
+      // Fill with random data
+      (new Random()).NextBytes(outputData);
+      
+      // Insert load module header data
+      BitConverter.GetBytes((UInt32)loadMod.MagicNum).CopyTo(outputData, 0 );
+      BitConverter.GetBytes((UInt32)outputData.Length).CopyTo(outputData, 4 );
+      
+      // FIXME - use random data in practice
+      BitConverter.GetBytes((UInt32)0x00000000).CopyTo(outputData, 8 );
+      BitConverter.GetBytes((UInt32)0x00000000).CopyTo(outputData, 12 );
+      
+      
+      // Insert load module payload data at offset 16
+      loadData.CopyTo(outputData, 16);
+      
+      // Create copy of load module in output/signature order
+      outputDataSigOrder = new Byte[outputData.Length - sigSize];
+      Array.Copy(outputData, 0 , outputDataSigOrder, loadData.Length, 16);
+      loadData.CopyTo(outputDataSigOrder, 0);
+      
+      // Encrypt the data (load header first, then payload)
+      if (loadMod.encryptData)
+      {
+        encOutputData = AesManagedUtil.AesCBCEncrypt(outputData, loadMod.customerEncryptionKey, loadMod.CEKInitialValue);
+        Array.Copy(encOutputData, 0 , outputData, loadData.Length, 16);
+        Array.Copy(encOutputData, 16, outputData,  0, loadData.Length);
+      }
+      else
+      {
+        outputDataSigOrder.CopyTo(outputData, 0);
+      }
+      
+      // Generate and Insert Signature
+      sigData = GenerateSecureSignature(loadMod, outputDataSigOrder);
+      
+      // Append signature to the end of output data
+      sigData.CopyTo(outputData, (loadData.Length + 16));
+      
+      return outputData;
+    }
+    
+    private static Byte[] GenerateSecureSignature(LoadModule loadMod, Byte[] dataForSigGen)
+    {
+      Byte[] signatureData = null;
+      
+      // Calculate hash of data
+      Byte[] hash = loadMod.currHashAlgorithm.ComputeHash(dataForSigGen);
+      
+      // Generate signature via encryption
+      if ( loadMod.SecureType == AisSecureType.GENERIC )
+      {
+        signatureData = new Byte[32];
+               
+        // Fill signature data buffer with random bytes
+        (new Random()).NextBytes(signatureData);
+        
+        // Copy calculated SHA hash into signature data buffer
+        hash.CopyTo(signatureData,0);
+
+        using (MemoryStream ms = new MemoryStream())
+        {
+          Aes myAES = new AesManaged();
+          myAES.KeySize = 128;
+          myAES.Mode = CipherMode.CBC;
+          myAES.Padding = PaddingMode.None;
+          ICryptoTransform encryptor = myAES.CreateEncryptor(loadMod.customerEncryptionKey, loadMod.CEKInitialValue);
+          CryptoStream cs = new CryptoStream(ms,encryptor,CryptoStreamMode.Write);
+          cs.Write(signatureData,0,signatureData.Length);
+          cs.FlushFinalBlock();
+          ms.ToArray().CopyTo(signatureData,0);
+        }
+      }
+      else if ( loadMod.SecureType == AisSecureType.CUSTOM )
+      {
+
+        RSAPKCS1SignatureFormatter rsaFormatter = new RSAPKCS1SignatureFormatter(loadMod.rsaObject);
+
+        // Create a signature for HashValue and return it.
+        signatureData = rsaFormatter.CreateSignature(loadMod.currHashAlgorithm);
+        
+        // Signature info needs to be revered to work with RSA functionality in ROM
+        Array.Reverse(signatureData);
+      }
+
+      return signatureData;
+    }
+    
+    private static retType SecurityIniSectionParse(LoadModule loadMod, IniFile iniFile)
+    {
+      String currHashAlgorithmString = "SHA1";  // Default hash algorithm
+      
+      // Get data from the GENERAL INI Section
+      IniSection sec = iniFile.GetSectionByName("Security");
+    
+    #region INI Section parsing
+      if (sec != null)
+      {
+        foreach (DictionaryEntry de in sec.sectionValues)
+        {
+          // Security Type
+          if (((String)de.Key).Equals("SECURITYTYPE", StringComparison.OrdinalIgnoreCase))
+          {
+            loadMod.SecureType = (AisSecureType) Enum.Parse(typeof(AisSecureType), (String)sec.sectionValues["SECURITYTYPE"], true);
+          }
+           
+          if (((String)de.Key).Equals("ENCRYPT", StringComparison.OrdinalIgnoreCase))
+          {
+            if (((String)sec.sectionValues["ENCRYPT"]).Equals("YES", StringComparison.OrdinalIgnoreCase))
+              loadMod.encryptData = true;
+            if (((String)sec.sectionValues["ENCRYPT"]).Equals("TRUE", StringComparison.OrdinalIgnoreCase))
+              loadMod.encryptData = true;
+          }
+          
+          // AES Encryption Key (CEK)
+          if (((String)de.Key).Equals("MAGICNUM", StringComparison.OrdinalIgnoreCase))
+          {
+            loadMod.MagicNum = (SecureLoadMagic) Enum.Parse(typeof(SecureLoadMagic), (String)sec.sectionValues["MAGICNUM"], true);
+          }
+
+          // AES Encryption Key (CEK)
+          if (((String)de.Key).Equals("ENCRYPTIONKEY", StringComparison.OrdinalIgnoreCase))
+          {
+            loadMod.customerEncryptionKey = new Byte[16];
+            loadMod.CEKInitialValue = new Byte[16];
+            
+            String keyString = (String)sec.sectionValues["ENCRYPTIONKEY"];
+            if (keyString.Length != 32)
+            {
+              Console.WriteLine("AES Encryption Key is wrong length!");
+              return retType.FAIL;
+            }
+            for (int j=0; j<keyString.Length; j+=2)
+            {
+              loadMod.customerEncryptionKey[(j>>1)] = Convert.ToByte(keyString.Substring(j,2),16);
+            }
+            
+            // Generate IV as encrypted version of AES Key
+            using (MemoryStream ms = new MemoryStream(loadMod.CEKInitialValue))
+            {
+              Aes myAES = new AesManaged();
+              myAES.KeySize = 128;
+              myAES.Mode = CipherMode.ECB;
+              myAES.Padding = PaddingMode.None;
+              ICryptoTransform encryptor = myAES.CreateEncryptor(loadMod.customerEncryptionKey, new Byte[16]);
+              CryptoStream cs = new CryptoStream(ms,encryptor,CryptoStreamMode.Write);
+              cs.Write(loadMod.customerEncryptionKey,0,loadMod.customerEncryptionKey.Length);
+            }  
+          }
+          
+          // Key Encryption Key (not normally known, here for debug/testing purposes)
+          if (((String)de.Key).Equals("KEYENCRYPTIONKEY", StringComparison.OrdinalIgnoreCase))
+          {
+            loadMod.keyEncryptionKey = new Byte[16];
+            String keyString = (String)sec.sectionValues["KEYENCRYPTIONKEY"];
+            if (keyString.Length != 32)
+            {
+              Console.WriteLine("Key Encryption Key is wrong length!");
+              return retType.FAIL;
+            }
+            for (int j=0; j<keyString.Length; j+=2)
+            {
+              loadMod.keyEncryptionKey[(j>>1)] = Convert.ToByte(keyString.Substring(j,2),16);
+            }
+          }
+          
+          // Custom Secure RSA Key File
+          if (((String)de.Key).Equals("RSAKEYFILENAME", StringComparison.OrdinalIgnoreCase))
+          {
+            String rsaKeyFileName = (String)sec.sectionValues["RSAKEYFILENAME"];
+            loadMod.rsaObject = RSAKey.LoadFromFile(rsaKeyFileName);
+            
+            if (loadMod.rsaObject == null)
+            {
+              Console.WriteLine("RSA key loading failed!");
+              return retType.FAIL;
+            }
+            
+            // Update the hash algo string if RSA key size is 2048 bits
+            if (loadMod.rsaObject.KeySize == 2048)
+            {
+              currHashAlgorithmString = "SHA256";
+              loadMod.currHashAlgorithmValue = SHA_Algorithm.SHA256;
+            }
+          }
+          
+          // Custom Secure RSA Key File
+          if (((String)de.Key).Equals("CERTRSAKEYFILENAME", StringComparison.OrdinalIgnoreCase))
+          {
+            String rsaKeyFileName = (String)sec.sectionValues["CERTRSAKEYFILENAME"];
+            loadMod.certRsaObject = RSAKey.LoadFromFile(rsaKeyFileName);
+            
+            if (loadMod.certRsaObject == null)
+            {
+              Console.WriteLine("Certificate RSA key loading failed!");
+              return retType.FAIL;
+            }
+          }
+          
+          // AES Encryption Key (CEK)
+          if (((String)de.Key).Equals("CERTENCRYPTIONKEY", StringComparison.OrdinalIgnoreCase))
+          {
+            loadMod.certEncryptionKey = new Byte[16];
+            
+            String keyString = (String)sec.sectionValues["CERTENCRYPTIONKEY"];
+            if (keyString.Length != 32)
+            {
+              Console.WriteLine("AES Encryption Key is wrong length!");
+              return retType.FAIL;
+            }
+            for (int j=0; j<keyString.Length; j+=2)
+            {
+              loadMod.certEncryptionKey[(j>>1)] = Convert.ToByte(keyString.Substring(j,2),16);
+            }
+          }
+          
+          // Generic Secure Option to select the hash algorithm for signatures
+          if (((String)de.Key).Equals("GENERICSHASELECTION", StringComparison.OrdinalIgnoreCase))
+          {
+            currHashAlgorithmString = (String)sec.sectionValues["GENERICSHASELECTION"];
+            loadMod.currHashAlgorithmValue = (SHA_Algorithm) Enum.Parse(typeof(SHA_Algorithm), currHashAlgorithmString, true);
+          }
+        }
+      }
+    #endregion
+      
+    #region Security INI Input Validation
+      // 2) Make sure a secure type has been specified
+      if (loadMod.SecureType == AisSecureType.NONE)
+      {
+        Console.WriteLine("ERROR: The security type was not specified!");
+        return retType.FAIL;
+      }
+      else
+      {
+        Console.WriteLine("Generating load modulefor a {0} secure device.",loadMod.SecureType.ToString().ToLower());
+        // 3) Make sure we have a CEK and IV
+        if (loadMod.customerEncryptionKey == null)
+        {
+          Console.WriteLine("ERROR: No encryption key was specified!");
+          return retType.FAIL;
+        }
+        
+        // 4) If custom secure, make sure we have an rsaObject
+        if ((loadMod.SecureType == AisSecureType.CUSTOM) && (loadMod.rsaObject == null))
+        {
+          Console.WriteLine("ERROR: No RSA key file was specified!");
+          return retType.FAIL;
+        }
+        
+        // 5) Make sure RSA key size is supported
+        if ((loadMod.SecureType == AisSecureType.CUSTOM) && (loadMod.rsaObject != null))
+        {
+          if ( (loadMod.rsaObject.KeySize != 1024) && (loadMod.rsaObject.KeySize != 2048) )
+          {
+            Console.WriteLine("ERROR: No RSA key size is invalid!");
+            return retType.FAIL;
+          }
+          else
+          {
+            Console.WriteLine("INFO: RSA key is {0} bits.",loadMod.rsaObject.KeySize);
+          }
+        }
+      }
+
+      // 6) Make sure valid hash algorithm was selected      
+      try
+      {
+        loadMod.currHashAlgorithm = HashAlgorithm.Create(currHashAlgorithmString);
+        Console.WriteLine("INFO: Current SHA algorithm is {0}.",loadMod.currHashAlgorithmValue);
+      }
+      catch (Exception e)
+      {
+        Console.WriteLine("ERROR: Invalid Hash Algorithm Selected. Exception message: {0}.",e.Message);
+        return retType.FAIL;
+      }
+      
+      // 7) If custom CERT_MAGIC module, verify certRsaObject and certEncryptionKey are set
+      if ((loadMod.MagicNum == SecureLoadMagic.CERT_MAGIC) && (loadMod.SecureType == AisSecureType.CUSTOM))
+      {
+        if (loadMod.certRsaObject == null)
+        {
+          Console.WriteLine("ERROR: Delegate Key Certificate load module for custom devices requires CERTRSAKEYFILENAME value.");
+          return retType.FAIL;
+        }
+        if (loadMod.certEncryptionKey == null)
+        {
+          Console.WriteLine("ERROR:Delegate Key Certificate load module for custom devices requires CERTENCRYPTIONKEY value.");
+          return retType.FAIL;
+        }
+        
+        // 9) Make sure RSA key sizes match  
+        if (loadMod.certRsaObject.KeySize != loadMod.rsaObject.KeySize)
+        {
+          Console.WriteLine("ERROR: Certificate RSA key size does not match current RSA key size.");
+          return retType.FAIL;
+        }
+      }
+      
+      // 8) If custom CERT_MAGIC module, verify certRsaObject and certEncryptionKey are set
+      if ((loadMod.MagicNum == SecureLoadMagic.CERT_MAGIC) && (loadMod.SecureType == AisSecureType.GENERIC))
+      {
+        if (loadMod.certEncryptionKey == null)
+        {
+          Console.WriteLine("ERROR: Delegate Key Certificate load module for generic devices requires CERTENCRYPTIONKEY value.");
+          return retType.FAIL;
+        }
+      }
+      
+      if ((loadMod.MagicNum == SecureLoadMagic.CERT_MAGIC) && (!loadMod.encryptData))
+      {
+        Console.WriteLine("INFO: For CERT_MAGIC, encryption is required - forcing load module payload to be encrypted.");
+        loadMod.encryptData = true;
+      }
+      
+    #endregion
+      return retType.SUCCESS;
+    }
+    
+    
+  }
+}
\ No newline at end of file
diff --git a/tools/omapl13x_boot_utils/Common/UtilLib/CryptoUtility.cs b/tools/omapl13x_boot_utils/Common/UtilLib/CryptoUtility.cs
new file mode 100644 (file)
index 0000000..56201df
--- /dev/null
@@ -0,0 +1,989 @@
+/*
+ * CryptoUtility.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+using System;
+using System.Collections;
+using System.Globalization;
+using System.IO;
+using System.IO.Ports;
+using System.Reflection;
+using System.Security.Cryptography;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading;
+using TI.UtilLib;
+using TI.UtilLib.IO;
+
+namespace TI.UtilLib.Crypto
+{
+  public class RSAKey
+  {
+    private const string PEMStartString         = "-----BEGIN ";
+    private const string PEMEndString           = "-----END ";
+
+    private const string PEMPubString           = "PUBLIC KEY-----";    
+    private const string PEMPrivString          = "RSA PRIVATE KEY-----";
+    private const string PEMPKCS8PrivString     = "PRIVATE KEY-----";
+    private const string PEMPKCS8EncPrivString  = "ENCRYPTED PUBLIC KEY-----";
+
+    private static RSACryptoServiceProvider LoadPEMKey(String fileName)
+    {
+      StreamReader sr = File.OpenText(fileName);
+      String fileStr = sr.ReadToEnd().Trim();
+      sr.Close();
+      
+      if( fileStr.StartsWith(PEMStartString+PEMPubString) && fileStr.EndsWith(PEMEndString+PEMPubString) )
+      {
+        // Unencrypted Private Key PEM file
+        byte[] keyBlob = null;
+        
+        Console.WriteLine("Reading PEM public key from file {0}...", fileName);
+        fileStr = TrimPEMData(fileStr);
+        try
+        {
+          // Get binary data from Base64 string
+          keyBlob = Convert.FromBase64String (fileStr);
+
+          // Convert binary data to ASN.1 Sequence object and then parse the sequence
+          // into RSAPrivateKey Components, then use to create an RSA CSP object.
+          Asn1Sequence seq = new Asn1Sequence(keyBlob);
+
+          if (seq.SequenceLength == 2)
+          {
+            if ( (seq[0].ContentID.TagNumber == Asn1TagNumber.INTEGER) && 
+                 (seq[1].ContentID.TagNumber == Asn1TagNumber.INTEGER) )
+            {
+              return ParseRSAPublicKey(seq);
+            }
+            else if ( (seq[0].ContentID.TagNumber == Asn1TagNumber.SEQUENCE) && 
+                      (seq[1].ContentID.TagNumber == Asn1TagNumber.BITSTRING) )
+            {
+              Byte[] tempData = seq[1].ContentsToArray();
+              
+              // Trim leading zeros in BitString 
+              if ( (tempData[0] == 0x00) && (tempData.Length > 1) )
+              {
+                Byte[] tempData2 = new Byte[tempData.Length - 1];
+                Array.Copy(tempData,1,tempData2,0,tempData.Length - 1);
+                tempData = tempData2;
+              }
+              
+              // Now see if we can interpret the BITSTRING data as an ASN.1 Sequence
+              seq = new Asn1Sequence(tempData);
+              
+              if ( (seq.SequenceLength == 2)  &&
+                   (seq[0].ContentID.TagNumber == Asn1TagNumber.INTEGER) && 
+                   (seq[1].ContentID.TagNumber == Asn1TagNumber.INTEGER) )
+              {
+                return ParseRSAPublicKey(seq);
+              }
+              else
+              {
+                return null;
+              }
+            }
+            else
+            {
+              return null;
+            }
+          }
+          else
+          {
+            return null;
+          }
+        }
+        catch(FormatException )
+        {
+          Console.WriteLine("Error in the PEM data!");
+          return null;
+        }
+      }
+      else if( fileStr.StartsWith(PEMStartString+PEMPrivString) && fileStr.EndsWith(PEMEndString+PEMPrivString) )
+      {
+        // Unencrypted Private Key PEM file
+        byte[] keyBlob = null;
+        
+        Console.WriteLine("Reading PEM private key from file {0}...", fileName);
+        fileStr = TrimPEMData(fileStr);
+        try
+        {
+          // Get binary data from Base64 string
+          keyBlob = Convert.FromBase64String (fileStr);
+
+          // Convert binary data to ASN.1 Sequence object and then parse the sequence
+          // into RSAPrivateKey Components, then use to create an RSA CSP object.
+          return ParseRSAPrivateKey(new Asn1Sequence(keyBlob));
+        }
+        catch(FormatException )
+        {
+          Console.WriteLine("Error in the PEM data!");
+          return null;
+        }
+      }
+      else if( fileStr.StartsWith(PEMStartString+PEMPKCS8PrivString) && fileStr.EndsWith(PEMEndString+PEMPKCS8PrivString) )
+      {
+        // Unencrypted PKCS#8 Private Key PEM file
+        Console.WriteLine("Reading PKCS#8 PEM private key from file {0}...", fileName);
+        return null;
+      }
+      else if( fileStr.StartsWith(PEMStartString+PEMPKCS8EncPrivString) && fileStr.EndsWith(PEMEndString+PEMPKCS8EncPrivString) )
+      {
+        // Encrypted PKCS#8 Private Key PEM file
+        Console.WriteLine("Reading Encrypted PKCS#8 PEM private key from file {0}...", fileName);
+        return null;
+      }
+      else
+        return null;
+    }      
+        
+    private static RSACryptoServiceProvider LoadDERKey(String fileName)
+    {
+      BinaryReader br = new BinaryReader(File.OpenRead(fileName));
+      
+      Byte[] fileData = br.ReadBytes((Int32) br.BaseStream.Length);
+      
+      return ParseRSAPrivateKey(new Asn1Sequence(fileData));
+    }
+    
+    private static RSACryptoServiceProvider LoadXMLKey(String fileName)
+    {
+      StreamReader sr = File.OpenText(fileName);
+      String fileStr = sr.ReadToEnd().Trim();
+      sr.Close();
+      
+      try
+      {
+        RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
+        RSA.FromXmlString(fileStr);
+        return RSA;
+      }
+      catch
+      {
+        return null;
+      }
+    }
+
+    private static String TrimPEMData(String pemString)
+    {
+      Regex rgx = new Regex("-{5}.+-{5}");
+      return (rgx.Replace(pemString,"")).Trim();
+    }    
+
+
+    /* ASN.1 definitions from PKCS#1 v2.1
+      RSAPublicKey ::= SEQUENCE {
+          modulus           INTEGER,  -- n
+          publicExponent    INTEGER   -- e 
+      }
+
+      -- 
+      -- Representation of RSA private key with information for the CRT algorithm.
+      --
+      RSAPrivateKey ::= SEQUENCE {
+          version           Version, 
+          modulus           INTEGER,  -- n
+          publicExponent    INTEGER,  -- e
+          privateExponent   INTEGER,  -- d
+          prime1            INTEGER,  -- p
+          prime2            INTEGER,  -- q
+          exponent1         INTEGER,  -- d mod (p-1)
+          exponent2         INTEGER,  -- d mod (q-1) 
+          coefficient       INTEGER,  -- (inverse of q) mod p
+          otherPrimeInfos   OtherPrimeInfos OPTIONAL 
+      }
+
+      Version ::= INTEGER { two-prime(0), multi(1) }
+          (CONSTRAINED BY {-- version must be multi if otherPrimeInfos present --})
+
+      OtherPrimeInfos ::= SEQUENCE SIZE(1..MAX) OF OtherPrimeInfo
+
+
+      OtherPrimeInfo ::= SEQUENCE {
+          prime             INTEGER,  -- ri
+          exponent          INTEGER,  -- di
+          coefficient       INTEGER   -- ti
+      } 
+    */
+    public static RSACryptoServiceProvider ParseRSAPrivateKey(Asn1Sequence RSAPrivateKey)
+    {
+      Byte[][] RSAPrivateKeyData;
+      
+      RSAParameters RSAParams = new RSAParameters();
+
+      if ( (RSAPrivateKey.SequenceLength != 9) && (RSAPrivateKey.SequenceLength != 10) )
+        throw new ArgumentException("ASN.1 Sequence has wrong number of elements for RSAPrivateKey.");
+        
+      RSAPrivateKeyData = new Byte[RSAPrivateKey.SequenceLength][];
+      
+      for(int i=0; i<RSAPrivateKey.SequenceLength; i++)
+      {
+        RSAPrivateKeyData[i] = RSAPrivateKey[i].ContentsToArray();
+        
+        // Trim leading zeros if any
+        if ( (RSAPrivateKeyData[i][0] == 0x00) && (RSAPrivateKeyData[i].Length > 1) )
+        {
+          Byte[] temp = new Byte[RSAPrivateKeyData[i].Length - 1];
+          Array.Copy(RSAPrivateKeyData[i],1,temp,0,RSAPrivateKeyData[i].Length - 1);
+          RSAPrivateKeyData[i] = temp;
+        }
+      }
+      
+      // Verify version is v2.1
+      //Console.WriteLine(RSAPrivateKeyData[0][0]);
+      //Console.WriteLine(RSAPrivateKeyData[0][1]);
+      //if( (RSAPrivateKeyData[0][0] != 0x02) || (RSAPrivateKeyData[0][1] != 0x01) )
+      //  throw new ArgumentException("ASN.1 RSAPrivateKey Sequence has wrong version number.");
+      
+      // rsaData[0] is version field
+      RSAParams.Modulus     = RSAPrivateKeyData[1];
+      RSAParams.Exponent    = RSAPrivateKeyData[2];
+      RSAParams.D           = RSAPrivateKeyData[3];
+      RSAParams.P           = RSAPrivateKeyData[4];
+      RSAParams.Q           = RSAPrivateKeyData[5];
+      RSAParams.DP          = RSAPrivateKeyData[6];
+      RSAParams.DQ          = RSAPrivateKeyData[7];
+      RSAParams.InverseQ    = RSAPrivateKeyData[8];
+      
+      // Import the params into the RSA CSP
+      try
+      {
+        RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
+        RSA.ImportParameters(RSAParams);
+        return RSA;
+      }
+      catch
+      {
+        return null;
+      }
+    }
+    
+    
+    public static RSACryptoServiceProvider ParseRSAPublicKey(Asn1Sequence RSAPublicKey)
+    {
+      Byte[][] RSAPublicKeyData;
+      
+      RSAParameters RSAParams = new RSAParameters();
+
+      if (RSAPublicKey.SequenceLength != 2)
+      {
+        throw new ArgumentException("ASN.1 Sequence has wrong number of elements for RSAPublicKey.");
+      }
+        
+      RSAPublicKeyData = new Byte[RSAPublicKey.SequenceLength][];
+      
+      for(int i=0; i<RSAPublicKey.SequenceLength; i++)
+      {
+        RSAPublicKeyData[i] = RSAPublicKey[i].ContentsToArray();
+        
+        // Trim leading zeros if any
+        if ( (RSAPublicKeyData[i][0] == 0x00) && (RSAPublicKeyData[i].Length > 1) )
+        {
+          Byte[] temp = new Byte[RSAPublicKeyData[i].Length - 1];
+          Array.Copy(RSAPublicKeyData[i],1,temp,0,RSAPublicKeyData[i].Length - 1);
+          RSAPublicKeyData[i] = temp;
+        }
+      }
+      
+      RSAParams.Modulus     = RSAPublicKeyData[0];
+      RSAParams.Exponent    = RSAPublicKeyData[1];
+
+      // Import the params into the RSA CSP
+      try
+      {
+        RSACryptoServiceProvider RSA = new RSACryptoServiceProvider();
+        RSA.ImportParameters(RSAParams);
+        return RSA;
+      }
+      catch
+      {
+        return null;
+      }
+    }
+    
+    
+    public static RSACryptoServiceProvider LoadFromFile(String fileName)
+    {
+      RSACryptoServiceProvider retVal = null;
+      
+      Console.WriteLine("Reading RSA Key information from file {0}...", fileName);
+      
+      // Try various formats in turn to see what works
+      // Priority is .Net XML format, then PEM from OpenSSL, then DER from OpenSSL
+      if( retVal == null ) retVal = LoadXMLKey(fileName);
+      if( retVal == null ) retVal = LoadPEMKey(fileName);
+      if( retVal == null ) retVal = LoadDERKey(fileName);
+      
+      if (retVal == null ) 
+      {
+        Console.WriteLine("Import of RSA key data failed!");
+      }
+      
+      return retVal;
+    }
+
+
+    public static Byte[] CreateCustomSecureKeyVerifyStruct(RSA rsa)
+    {
+      Int32 modSizeInBytes = (rsa.KeySize >> 3);
+      Int32 keyStructSize = 8 + modSizeInBytes;
+      Byte[] modData = new Byte[modSizeInBytes];
+      Byte[] keyVerifyStruct = new Byte[keyStructSize];
+
+      // Zero out the array
+      Array.Clear(keyVerifyStruct,0,keyStructSize);
+
+      // Get the RSA Public Key Params
+      RSAParameters RSAParams = rsa.ExportParameters(false);
+
+      RSAParams.Exponent.CopyTo(keyVerifyStruct,0);
+
+      BitConverter.GetBytes((Int16) (modSizeInBytes>>1)).CopyTo(keyVerifyStruct,6);
+      
+      // Modulus Bytes Need to be reversed for RSA code in ROM to work
+      RSAParams.Modulus.CopyTo(modData,0);
+      Array.Reverse(modData);
+      modData.CopyTo(keyVerifyStruct,8);
+
+      return keyVerifyStruct;
+    }
+  }
+
+  public static class AesManagedUtil
+  {
+    private static AesManaged aes;
+    private static int blockSizeInBytes;
+    
+    #region Static constructor
+    static AesManagedUtil()
+    {
+      aes = new AesManaged();
+      aes.Mode = CipherMode.CBC;
+      aes.Padding = PaddingMode.None;
+      
+      blockSizeInBytes = (aes.BlockSize >> 3);
+    }
+    #endregion
+    
+    public static byte[] AesCBCEncrypt( byte[] input, byte[] key, byte[] iv )
+    {
+      byte[] output;
+      int blockCnt;
+      
+      // Get block count (rounded up so all data is covered)
+      blockCnt = (input.Length + (blockSizeInBytes - 1)) / blockSizeInBytes;
+      
+      // Validate input
+      if ((blockCnt * blockSizeInBytes) != input.Length)
+      {
+        aes.Padding = PaddingMode.PKCS7;
+        output = new byte[blockCnt * blockSizeInBytes];
+      }
+      else
+      {
+        aes.Padding = PaddingMode.None;
+        output = new byte[input.Length];
+      }
+      
+      aes.Key = key;
+      aes.IV = iv;
+      
+      // Use CBC encryption to do CTS, with last two blocks swapped 
+     
+      // Do complete CBC encryption
+      MemoryStream ms = new MemoryStream(output);
+      CryptoStream cs = new CryptoStream(ms, aes.CreateEncryptor(), CryptoStreamMode.Write);
+      try
+      {
+        cs.Write(input,0,input.Length);  
+      }
+      finally
+      {
+        cs.Close();
+        ms.Close();
+      }
+      
+      return output;
+    }
+    
+    
+    public static byte[] AesCTSEncrypt( byte[] input, byte[] key, byte[] iv )
+    {
+      byte[] output;
+      byte[] tempIn,tempOut,tempSwap;
+      int blockCnt;
+                
+      // Validate input
+      if (input.Length < blockSizeInBytes)
+      {
+        aes.Padding = PaddingMode.PKCS7;
+        output = new byte[blockSizeInBytes];
+      }
+      else
+      {
+        aes.Padding = PaddingMode.None;
+        output = new byte[input.Length];
+      }
+      
+      
+      aes.Key = key;
+      aes.IV = iv;
+      
+      // Get block count (rounded up so all data is covered)
+      blockCnt = (input.Length + (blockSizeInBytes - 1)) / blockSizeInBytes;
+      
+      if (blockCnt == 1)
+      {
+        // Do single block CBC encryption with PKCS7 padding
+        MemoryStream ms = new MemoryStream(output);
+        CryptoStream cs = new CryptoStream(ms, aes.CreateEncryptor(), CryptoStreamMode.Write);
+        try
+        {
+          // Write Partial block
+          cs.Write(input,0,input.Length);
+          cs.FlushFinalBlock();
+        }
+        finally
+        {
+          cs.Close();
+          ms.Close();
+        }
+      }
+      else if (blockCnt > 1)
+      {
+        // Use CBC encryption to do CTS, with last two blocks swapped 
+        tempSwap  = new byte[blockSizeInBytes];
+        tempIn    = new byte[blockCnt * blockSizeInBytes];
+        tempOut   = new byte[blockCnt * blockSizeInBytes];
+        input.CopyTo(tempIn,0);
+        
+        Debug.DebugMSG("Input: {0}",BitConverter.ToString(input,(blockCnt - 2) * blockSizeInBytes));
+        Debug.DebugMSG("tempIn: {0}",BitConverter.ToString(tempIn,(blockCnt - 2) * blockSizeInBytes));
+        
+        // Do complete CBC encryption
+        MemoryStream ms = new MemoryStream(tempOut);
+        CryptoStream cs = new CryptoStream(ms, aes.CreateEncryptor(), CryptoStreamMode.Write);
+        try
+        {
+          cs.Write(tempIn,0,tempIn.Length);  
+        }
+        finally
+        {
+          cs.Close();
+          ms.Close();
+        }
+        
+        Debug.DebugMSG("tempOut: {0}",BitConverter.ToString(tempOut,(blockCnt - 2) * blockSizeInBytes));
+        
+        // Swap last two blocks of ciphertext
+        Array.Copy(tempOut,blockSizeInBytes*(blockCnt-2),tempSwap,0,blockSizeInBytes);
+        Array.Copy(tempOut,blockSizeInBytes*(blockCnt-1),tempOut,blockSizeInBytes*(blockCnt-2),blockSizeInBytes);
+        Array.Copy(tempSwap,0,tempOut,blockSizeInBytes*(blockCnt-1),blockSizeInBytes);
+        
+        // Truncate to original input length
+        Array.Copy(tempOut,0,output,0,input.Length);
+        
+        Debug.DebugMSG("output: {0}",BitConverter.ToString(output,(blockCnt - 2) * blockSizeInBytes));
+      }
+      
+      return output;
+    }
+    
+    public static byte[] AesCTSDecrypt( byte[] input, byte[] key, byte[] iv )
+    {
+      byte[] output = new byte[input.Length];
+      byte[] tempIn,tempOut,tempSwap;
+      int blockCnt;
+      AesManaged ecbAes = new AesManaged();
+      MemoryStream ms;
+      CryptoStream cs;
+      
+      // Validate input
+      if (input.Length <= blockSizeInBytes)
+        throw new ArgumentException("Array size too small for Ciphertext Stealing","input");
+     
+      aes.Key = key;
+      aes.IV = iv;
+      
+      if ( (input.Length % blockSizeInBytes) != 0)
+        blockCnt = ((input.Length / blockSizeInBytes) + 1 );
+      else
+        blockCnt = (input.Length / blockSizeInBytes);
+      
+      tempSwap  = new byte[blockSizeInBytes];
+      tempIn    = new byte[blockCnt * blockSizeInBytes];
+      tempOut   = new byte[blockCnt * blockSizeInBytes];
+      input.CopyTo(tempIn,0);
+            
+      // Decrypt second to last input block
+      ecbAes.Mode = CipherMode.ECB;
+      ecbAes.Padding = PaddingMode.None;
+      ecbAes.Key = key;
+      ecbAes.IV = iv;
+      ms = new MemoryStream(input,(blockCnt-2)*blockSizeInBytes,blockSizeInBytes,false);
+      cs = new CryptoStream(ms, ecbAes.CreateDecryptor(), CryptoStreamMode.Read);
+      try
+      {
+        cs.Read(tempSwap,0,tempSwap.Length);
+      }
+      catch (Exception e)
+      {
+        Console.WriteLine(e.Message);
+        return null;
+      }
+      finally
+      {
+        cs.Close();
+        ms.Close();
+      }
+      
+      // Append stolen ciphertext bytes from decrypted block to end of input
+      int stolenByteCnt = (tempIn.Length - input.Length);
+      Array.Copy(tempSwap,tempSwap.Length - stolenByteCnt,tempIn,tempIn.Length-stolenByteCnt,stolenByteCnt);
+      
+      // Swap last two blocks of ciphertext
+      Array.Copy(tempIn,blockSizeInBytes*(blockCnt-2),tempSwap,0,blockSizeInBytes);
+      Array.Copy(tempIn,blockSizeInBytes*(blockCnt-1),tempIn,blockSizeInBytes*(blockCnt-2),blockSizeInBytes);
+      Array.Copy(tempSwap,0,tempIn,blockSizeInBytes*(blockCnt-1),blockSizeInBytes);
+          
+      // Do complete CBC encryption
+      ms = new MemoryStream(tempIn, false);
+      cs = new CryptoStream(ms, aes.CreateDecryptor(), CryptoStreamMode.Read);
+      try
+      {
+        cs.Read(tempOut,0,tempOut.Length);  
+      }
+      catch (Exception e)
+      {
+        Console.WriteLine(e.Message);
+        return null;
+      }
+      finally
+      {
+        cs.Close();
+        ms.Close();
+      }
+      
+      // Truncate to original input length
+      Array.Copy(tempOut,0,output,0,input.Length);
+      
+      return output;
+    }
+  }
+  /*
+  public class CryptoStreamWithCTS : Stream
+  {
+    public CryptoStreamWithCTS(): base()
+    {
+    }
+  }
+  */
+  
+  public class AesManagedWithCTS : Aes
+  {
+  #region Private Class Member
+    private AesManaged aes;
+  
+  #endregion
+  
+  #region Public Constructor
+    public AesManagedWithCTS() : base()
+    {
+      aes = new AesManaged();
+    }
+  #endregion
+  
+  #region Public Override Properties
+    public override CipherMode Mode
+    {
+      get
+      {
+        return this.ModeValue;
+      }
+      set
+      {
+        if (value != CipherMode.CTS)
+          aes.Mode = value;
+        else
+          aes.Mode = CipherMode.CBC;
+        ModeValue = value; 
+      }
+    }
+    
+    public override PaddingMode Padding
+    {
+      get
+      {
+        return aes.Padding;
+      }
+      set
+      {
+        aes.Padding = value;
+        PaddingValue = aes.Padding;
+      }
+    }
+    
+    public override int FeedbackSize
+    {
+      get
+      {
+        return aes.FeedbackSize;
+      }
+      set
+      {
+        aes.FeedbackSize = value;
+        FeedbackSizeValue = aes.FeedbackSize;
+      }
+    }
+    
+    public override byte[] IV
+    {
+      get
+      {
+        if (this.IVValue == null)
+          GenerateIV();
+          
+        return IVValue;
+      }
+      set
+      {
+        if (value == null)
+                                       throw new ArgumentNullException ("IV");
+        aes.IV = value;
+        this.IVValue = aes.IV;
+      }
+    }
+    
+    public override byte[] Key
+    {
+      get
+      {
+        if (this.KeyValue == null)
+          GenerateKey();
+         
+        return (byte[]) this.KeyValue.Clone();
+      }
+      set
+      {
+        if (value == null)
+                                       throw new ArgumentNullException ("Key");
+        aes.Key = value;
+        this.KeyValue = aes.Key;
+      }
+    }
+    
+    public override int KeySize
+    {
+      get
+      {
+        return aes.KeySize;
+      }
+      set
+      {
+        aes.KeySize = value;
+        KeySizeValue = aes.KeySize;
+      }
+    }
+  #endregion
+  
+  #region Public Override Functions
+    public override ICryptoTransform CreateDecryptor()
+    {
+      if (this.Mode != CipherMode.CTS)
+        return aes.CreateDecryptor();
+      else
+        return new AesManagedWithCTSTransform(aes, this.Mode, false);
+    }
+    
+    public override ICryptoTransform CreateDecryptor(byte[] key, byte[] iv)
+    {
+      if (this.Mode != CipherMode.CTS)
+        return aes.CreateDecryptor(key,iv);
+      else
+      {
+        aes.Key = key;
+        aes.IV = iv;
+        return new AesManagedWithCTSTransform(aes, this.Mode, false);
+      }
+    }
+    
+    public override ICryptoTransform CreateEncryptor()
+    {
+      if (this.Mode != CipherMode.CTS)
+        return aes.CreateEncryptor();
+      else
+        return new AesManagedWithCTSTransform(aes, this.Mode, true);
+    }
+    
+    public override ICryptoTransform CreateEncryptor(byte[] key, byte[] iv)
+    {
+      if (this.Mode != CipherMode.CTS)
+        return aes.CreateEncryptor(key,iv);
+      else
+      {
+        aes.Key = key;
+        aes.IV = iv;
+        return new AesManagedWithCTSTransform(aes, this.Mode, true);
+      }
+    }
+
+    public override void GenerateIV()
+    {
+      aes.GenerateIV();
+      this.IVValue = aes.IV;
+    }
+    
+    public override void GenerateKey()
+    {
+      aes.GenerateKey();
+      this.KeyValue = aes.Key;
+    }
+  
+  #endregion
+  }
+  
+  internal class AesManagedWithCTSTransform: ICryptoTransform, IDisposable
+  {
+    protected CipherMode ModeValue;
+    protected ICryptoTransform aesTransform;
+    protected bool EncryptValue;
+    
+    private bool disposed;
+    private bool flushed;
+    
+    // Public Class constructor
+    public AesManagedWithCTSTransform(AesManaged aes, CipherMode mode, bool encrypt)
+    {
+      this.ModeValue = mode;
+      this.EncryptValue = encrypt;
+      if (mode == CipherMode.CTS)
+      {
+        // Use CBC for simple encryption, ECB for decryption
+        if (encrypt)
+          aes.Mode = CipherMode.CBC;
+        else
+          aes.Mode = CipherMode.ECB;
+      }
+      else
+      {
+        aes.Mode = mode;
+      }
+      
+      if (encrypt)
+      {
+        aesTransform = aes.CreateEncryptor();
+      }
+      else
+      {
+        aesTransform = aes.CreateDecryptor();
+      }
+    
+    }
+    
+    ~AesManagedWithCTSTransform () 
+               {
+                       Dispose (false);
+               }
+
+    
+  #region IDisposable interface implementation
+    void IDisposable.Dispose () 
+               {
+                       Dispose (true);
+                       GC.SuppressFinalize (this);
+               }
+
+  
+    public virtual void Dispose(bool doDispose)
+    {
+      if (!disposed)
+      {
+        if (doDispose)
+        {
+        
+        }
+        disposed = true;
+        
+      }
+      
+      
+    }
+  #endregion
+    
+  
+  #region ICryptoTransform interface implementation
+    public int InputBlockSize
+    {
+      get
+      {
+        return aesTransform.InputBlockSize;
+      }
+    }
+    
+    public int OutputBlockSize
+    {
+      get
+      {
+        return aesTransform.OutputBlockSize;
+      }
+    }
+    
+    public bool CanReuseTransform
+    {
+      get
+      {
+        if (ModeValue == CipherMode.CTS)
+        {
+          return false;
+        }
+        else
+        {
+          return aesTransform.CanReuseTransform;
+        }
+      }
+    }
+    
+    public bool CanTransformMultipleBlocks 
+    {
+      get
+      {
+        Console.WriteLine("CanTransformMultipleBlocks = {0}",CanTransformMultipleBlocks);
+        if (ModeValue == CipherMode.CTS)
+        {
+          return true;
+        }
+        else
+        {
+          return aesTransform.CanTransformMultipleBlocks;
+        }
+      }
+    }
+    
+    public virtual int TransformBlock(
+      byte[] inputBuffer,
+      int inputOffset,
+      int inputCount,
+      byte[] outputBuffer,
+      int outputOffset )
+    {
+      if (disposed)
+        throw new ObjectDisposedException ("Object is disposed");
+
+      // Check input and output params
+      Console.WriteLine("Called TransformBlock() with following params:");
+      Console.WriteLine("\tinputBuffer.Length = {0}",inputBuffer.Length);
+      Console.WriteLine("\tinputOffset = {0}",inputOffset);
+      Console.WriteLine("\tinputCount = {0}",inputCount);
+      Console.WriteLine("\toutputBuffer.Length = {0}",inputBuffer.Length);
+      Console.WriteLine("\toutputOffset = {0}",outputOffset);
+    
+      if (this.ModeValue != CipherMode.CTS)
+        return aesTransform.TransformBlock(inputBuffer, inputOffset, inputCount, outputBuffer, outputOffset);
+      else
+      {
+        //if (EncryptValue)
+        {
+        // Implement the CTS using AES CBC
+        int len = Math.Min(inputCount,(outputBuffer.Length - outputOffset));
+        len = Math.Min(len,(inputBuffer.Length - inputOffset));
+        Array.Copy( inputBuffer, inputOffset, outputBuffer, outputOffset, len);
+        return len;
+        }
+      }
+    }
+    
+    public virtual byte[] TransformFinalBlock (byte[] inputBuffer, int inputOffset, int inputCount) 
+               {
+                       if (disposed)
+                               throw new ObjectDisposedException ("Object is disposed");
+      
+      if (flushed)
+        return null;
+        
+      // Check input params
+      Console.WriteLine("Called TransformFinalBlock() with following params:");
+      Console.WriteLine("\tinputBuffer.Length = {0}",inputBuffer.Length);
+      Console.WriteLine("\tinputOffset = {0}",inputOffset);
+      Console.WriteLine("\tinputCount = {0}",inputCount);
+      
+      byte[] retVal = new byte[inputCount];
+      
+      Array.Copy( inputBuffer, inputOffset, retVal, 0, inputCount);
+      
+      flushed = true;
+      
+      return retVal;
+               }
+    
+
+  #endregion
+    public void Clear()
+    {
+      Dispose(true);
+    }
+    
+  }
+  
+  public class Misc
+  {
+    private static String KeyToBinaryString(Byte[] key,UInt32 startAddr,Boolean readProtect, Boolean writeProtect)
+    {
+      Byte bits40to32 = (Byte) (0 + (readProtect?2:0) + (writeProtect?4:0));    
+      StringBuilder sb = new StringBuilder(256);
+      
+      for (int i= 0; i < (key.Length >> 2); i++)
+      {
+        sb.AppendFormat("{0:X8} ",startAddr + i);
+        sb.Append((Convert.ToString(bits40to32,2)).PadLeft(9,'0'));
+        
+        // Get bytes of keys in chunks of four, in reverse order, convert to UInt32, Convert to binary string, pad left with zeros, then convert to char array
+        Char[] data = Convert.ToString( BitConverter.ToUInt32(key,key.Length-(4*(i+1))), 2).PadLeft(32,'0').ToCharArray();
+        
+        // Reverse data in array
+        Array.Reverse(data);
+        
+        // Append the reversed binary string into the StringBuilder object        
+        sb.Append( new String(data) );
+        
+        // Finish this line
+        sb.Append("\n");
+      }
+      
+      return sb.ToString();    
+    }
+  }
+}
\ No newline at end of file
diff --git a/tools/omapl13x_boot_utils/Common/UtilLib/Debug.cs b/tools/omapl13x_boot_utils/Common/UtilLib/Debug.cs
new file mode 100644 (file)
index 0000000..9512da5
--- /dev/null
@@ -0,0 +1,215 @@
+/*
+ * Debug.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+using System;
+using System.Text;
+
+namespace TI.UtilLib
+{
+    public class Debug
+    {
+        /// <summary>
+        /// Writes the text representation of the specified array of objects, followed by the line terminator, to the standard
+        /// output, but only if the current build is a DEBUG build.  
+        /// </summary>
+        /// <param name="value">The value to write.</param>
+        public static void DebugMSG(String value)
+        {
+#if DEBUG
+            Console.WriteLine(value);
+#endif
+        }
+        
+        /// <summary>
+        /// Writes the text representation of the specified array of objects, followed by the line terminator, to the standard
+        /// output, but only if the current build is a DEBUG build.  
+        /// </summary>
+        /// <param name="value">The value to write.</param>
+        public static void DebugMSG(Boolean value)
+        {
+#if DEBUG
+            Console.WriteLine(value);
+#endif
+        }
+
+        /// <summary>
+        /// Writes the text representation of the specified array of objects, followed by the line terminator, to the standard
+        /// output, but only if the current build is a DEBUG build.  
+        /// </summary>
+        /// <param name="value">The value to write.</param>
+        public static void DebugMSG(Char value)
+        {
+#if DEBUG
+            Console.WriteLine(value);
+#endif
+        }
+
+        /// <summary>
+        /// Writes the text representation of the specified array of objects, followed by the line terminator, to the standard
+        /// output, but only if the current build is a DEBUG build.  
+        /// </summary>
+        /// <param name="buffer">A unicode character array.</param>
+        public static void DebugMSG(char[] buffer)
+        {
+#if DEBUG
+            Console.WriteLine(buffer);
+#endif
+        }
+
+        /// <summary>
+        /// Writes the text representation of the specified array of objects, followed by the line terminator, to the standard
+        /// output, but only if the current build is a DEBUG build.  
+        /// </summary>
+        /// <param name="value">The value to write.</param>
+        public static void DebugMSG(int value)
+        {
+#if DEBUG
+            Console.WriteLine(value);
+#endif
+        }
+
+        /// <summary>
+        /// Writes the text representation of the specified array of objects, followed by the line terminator, to the standard
+        /// output, but only if the current build is a DEBUG build.  
+        /// </summary>
+        /// <param name="value">The value to write.</param>
+        public static void DebugMSG(double value)
+        {
+#if DEBUG
+            Console.WriteLine(value);
+#endif
+        }
+
+        /// <summary>
+        /// Writes the text representation of the specified array of objects, followed by the line terminator, to the standard
+        /// output, but only if the current build is a DEBUG build.  
+        /// </summary>
+        /// <param name="value">The value to write.</param>
+        public static void DebugMSG(float value)
+        {
+#if DEBUG
+            Console.WriteLine(value);
+#endif
+        }
+
+        /// <summary>
+        /// Writes the text representation of the specified array of objects, followed by the line terminator, to the standard
+        /// output, but only if the current build is a DEBUG build.  
+        /// </summary>
+        /// <param name="value">The value to write.</param>
+        public static void DebugMSG(decimal value)
+        {
+#if DEBUG
+            Console.WriteLine(value);
+#endif
+        }
+
+        /// <summary>
+        /// Writes the text representation of the specified array of objects, followed by the line terminator, to the standard
+        /// output, but only if the current build is a DEBUG build.  
+        /// </summary>
+        /// <param name="value">The value to write.</param>
+        public static void DebugMSG(short value)
+        {
+#if DEBUG
+            Console.WriteLine(value);
+#endif
+        }
+
+        /// <summary>
+        /// Writes the text representation of the specified array of objects, followed by the line terminator, to the standard
+        /// output, but only if the current build is a DEBUG build.  
+        /// </summary>
+        /// <param name="value">The value to write.</param>
+        public static void DebugMSG(long value)
+        {
+#if DEBUG
+            Console.WriteLine(value);
+#endif
+        }
+
+        /// <summary>
+        /// Writes the text representation of the specified array of objects, followed by the line terminator, to the standard
+        /// output, but only if the current build is a DEBUG build.  
+        /// </summary>
+        /// <param name="value">The value to write.</param>
+        public static void DebugMSG(object value)
+        {
+#if DEBUG
+            Console.WriteLine(value);
+#endif
+        }
+
+        /// <summary>
+        /// Writes the text representation of the specified array of objects, followed by the line terminator, to the standard
+        /// output, but only if the current build is a DEBUG build.  
+        /// </summary>
+        /// <param name="value">The value to write.</param>
+        public static void DebugMSG(uint value)
+        {
+#if DEBUG
+            Console.WriteLine(value);
+#endif
+        }       
+
+        /// <summary>
+        /// Writes the text representation of the specified array of objects, followed by the line terminator, to the standard
+        /// output, but only if the current build is a DEBUG build.  
+        /// </summary>
+        /// <param name="value">The value to write.</param>
+        public static void DebugMSG(ulong value)
+        {
+#if DEBUG
+            Console.WriteLine(value);
+#endif
+        }
+
+        /// <summary>
+        /// Writes the text representation of the specified array of objects, followed by the line terminator, to the standard
+        /// output, but only if the current build is a DEBUG build.  
+        /// </summary>
+        /// <param name="value">The value to write.</param>
+        public static void DebugMSG(String format, params Object[] arg)
+        {
+#if DEBUG
+            Console.WriteLine(format, arg);
+#endif
+        }
+
+    }
+}
diff --git a/tools/omapl13x_boot_utils/Common/UtilLib/ECC.cs b/tools/omapl13x_boot_utils/Common/UtilLib/ECC.cs
new file mode 100644 (file)
index 0000000..eacace1
--- /dev/null
@@ -0,0 +1,783 @@
+/*
+ * ECC.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+/* --------------------------------------------------------------------------
+    FILE        : ECC.cs
+    PROJECT     : TI Booting and Flashing Utilities
+    AUTHOR      : Daniel Allred
+    DESC        : Error Correction Code calculators for EMIF interfaces
+ ----------------------------------------------------------------------------- */
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TI.UtilLib
+{
+
+    public class HammingECC
+    {
+      
+      // *************************************************
+      // *              Consts and Enums                 *
+      // *************************************************   
+      
+      private enum colMasks: byte
+      {
+        evenWhole  = 0xFF,
+        evenHalf   = 0x0F,
+        oddHalf    = 0xF0,
+        evenFourth = 0x33,
+        oddFourth  = 0xCC,
+        evenEighth = 0x55,
+        oddEighth  = 0xAA,
+        oddWhole   = 0x00
+      }
+      
+      
+      // *************************************************
+      // *               Private Members                 *
+      // *************************************************
+      
+      // Total number of message symbols
+      private Int32 k;
+      
+      
+      // *************************************************
+      // *            Private Constructors               *
+      // *************************************************
+      
+      
+      // *************************************************
+      // *               Private Methods                 *
+      // *************************************************
+
+      
+      // *************************************************
+      // *        Public properties and Indexer          *
+      // *************************************************
+
+
+      // *************************************************
+      // *             Public constructors               *
+      // *************************************************
+      
+      
+      public HammingECC(Int32 messageCnt)
+      {
+        k = messageCnt;
+      }
+      
+      
+      // *************************************************
+      // *           Public Instance Methods             *
+      // *************************************************      
+
+      // Single Bit ECC algorithm
+      public Int32 GenerateParity(Byte[] messageData)
+      {
+        UInt16 oddResult=0, evenResult=0;
+        Byte bitParities = 0;
+        Byte[] byteParities = new Byte[k];
+        
+        if (messageData.Length != k)
+          throw new ArgumentException("Wrong size.","messageData");
+
+        // Create column parities
+        for (int i = 0; i < k; i++)
+        {
+          bitParities ^= messageData[i];
+        }
+        
+        evenResult |= (UInt16)( (CalcBitWiseParity(bitParities,colMasks.evenHalf) << 2) |
+                        (CalcBitWiseParity(bitParities,colMasks.evenFourth) << 1) |
+                        (CalcBitWiseParity(bitParities,colMasks.evenEighth) << 0) );
+
+        oddResult |=  (UInt16)( (CalcBitWiseParity(bitParities,colMasks.oddHalf) << 2) |
+                       (CalcBitWiseParity(bitParities,colMasks.oddFourth) << 1) |
+                       (CalcBitWiseParity(bitParities,colMasks.oddEighth) << 0) );
+                       
+        // Create row Parities
+        for (int i = 0; i < k; i++)
+        {
+          byteParities[i] = CalcBitWiseParity(messageData[i],colMasks.evenWhole);
+        }
+
+        // Place even row parity bits
+        for (int i = 0; i < ((Int32) Math.Log(k,2)); i++ )
+        {
+          Byte val = CalcRowParityBits(byteParities, true, (Int32) Math.Pow(2,i));
+          evenResult |= (UInt16) (val << (3+i));
+
+          val = CalcRowParityBits(byteParities, false, (Int32) Math.Pow(2,i));
+          oddResult  |= (UInt16) (val << (3+i));
+        }
+        
+        return (Int32) ((oddResult << 16) | (evenResult));
+      }
+      
+      
+      // *************************************************
+      // *             Public Class Methods              *
+      // *************************************************      
+        
+      private static Byte CalcBitWiseParity(Byte val, colMasks mask)
+      {
+        Byte result = 0, byteMask = (Byte) mask;
+        
+        for (int i = 0; i < 8; i++)
+        {
+          if ((byteMask & 0x1) != 0)
+          {
+            result ^= (Byte)(val & 1);
+          }
+          byteMask >>= 1;
+          val >>= 1;
+        }
+        return (Byte)(result & 0x1);
+      }
+  
+      private static Byte CalcRowParityBits(Byte[] byteParities, Boolean even, Int32 chunkSize)
+      {
+        Byte result = 0;
+        for (int i = (even ? 0 : chunkSize); i < byteParities.Length; i += (2*chunkSize))
+        {
+          for (int j = 0; j < chunkSize; j++)
+          {
+            result ^= byteParities[i + j];
+          }
+        }
+        return (Byte)(result & 0x1);
+      }
+    }
+  
+    public class ReedSolomonECC
+    {
+      // *************************************************
+      // *              Consts and Enums                 *
+      // *************************************************    
+
+      
+      // *************************************************
+      // *               Private Members                 *
+      // *************************************************
+      
+      // Total number of transmitted symbols (message + parity)
+      private Int32 N;
+      
+      // Total number of message symbols
+      private Int32 k;
+      
+      // Total number of correctible symbol errors
+      private Int32 s;
+      
+      // Array of BinaryGaloisFieldElement for building and storing the generator polynomial 
+      private BinaryGaloisFieldElement[] generatorPoly;
+      
+      // The BinaryGaloisField under which all operations take place
+      private BinaryGaloisField galoisField;
+      
+      
+      // *************************************************
+      // *            Private Constructors               *
+      // *************************************************
+      
+      
+      // *************************************************
+      // *               Private Methods                 *
+      // *************************************************
+
+      
+      // *************************************************
+      // *        Public properties and Indexer          *
+      // *************************************************
+
+
+      // *************************************************
+      // *             Public constructors               *
+      // *************************************************
+
+      public ReedSolomonECC(Int32 msgSymbolCnt, Int32 maxCorrectibleErrorCnt, Byte symbolBitWidth)
+      {
+        k = msgSymbolCnt;
+        s = maxCorrectibleErrorCnt;
+        N = k + 2*s;
+        
+        // Create Binary Galois Field ( that is GF(2^symbolBitWidth) )
+        galoisField = new BinaryGaloisField(symbolBitWidth);
+        
+        // Create the generator polynomial, g(x)
+        generatorPoly = ReedSolomonECC.createGeneratorPolynomial(galoisField, maxCorrectibleErrorCnt);
+      }
+      
+
+      // *************************************************
+      // *           Public Instance Methods             *
+      // *************************************************      
+      
+      public Int32[] GenerateParity(Int32[] messageData)
+      {
+        Int32[] retArray = new Int32[2*s];
+        BinaryGaloisFieldElement[] data = new BinaryGaloisFieldElement[N];
+      
+        if (messageData.Length != k)
+          throw new ArgumentException("Wrong size.","messageData");
+
+        // Parity is defined parityPoly(x) = x^2s * messagePoly(x) (mod generatorPoly(x))
+        // Convert input message data to array of BinaryGaloisFieldElement (implicit cast)
+        // Create x^2s * messagePoly(x) by shifting data up by 2s positions
+        for (int i=0; i<k; i++)
+        {
+          data[i+(2*s)] = messageData[i];
+        }
+        
+        // Now do long division using generatorPoly, remainder is parity data
+        // Use synthetic division since generatorPoly is monic
+        for(int i = N - 1; i >=(2*s); i--)
+        {
+          if (data[i] != 0)
+          {
+            for (int j = 1; j <= (2*s); j++)
+            {
+              data[i - j] = data[i - j] - galoisField.Multiply(data[i],generatorPoly[2*s - j]);
+            }
+            // Set to zero
+            data[i] = 0;
+          }
+        }
+        
+        // Copy 2*s pieces of data to the parity symbols array
+        for (int i=0; i<(2*s); i++)
+        {
+          retArray[i] = (Int32) data[i];
+        }
+        
+        // Return parity symbols
+        return retArray;
+      }
+      
+      
+      // *************************************************
+      // *             Public Class Methods              *
+      // *************************************************
+      
+      public static BinaryGaloisFieldElement[] createGeneratorPolynomial(BinaryGaloisField gf, Int32 maxCorrectibleErrorCnt)
+      {
+        // Generator polynomial, g(x), is of order 2s, so has 2s+1 coefficients
+        BinaryGaloisFieldElement[] g = new BinaryGaloisFieldElement[2*maxCorrectibleErrorCnt + 1];
+        
+        // Make g(x) = 1
+        g[0] = 1;
+        for (int i = 1; i<=(2*maxCorrectibleErrorCnt); i++)
+        {
+          // Always make coefficient of x^i term equal to 1
+          g[i] = 1;
+          
+          // Below multiply (g(x) = g[0] + g[1]*x + ... + g[i]*(x^i)) by (x - alpha^i)
+          for (int j=(i-1); j > 0; j--)
+          {
+            if (g[j] != 0)
+              g[j] = g[j - 1] - gf.Multiply(gf.AlphaFromIndex(i),g[j]);
+            else
+              g[j] = g[j - 1];
+          }
+          // Coefficient of x^0 term is alpha^(1+2+...+i)
+          g[0] = gf.AlphaFromIndex( ((i*(i+1))/2) );
+        }
+        return g;
+      }
+      
+      
+      // *************************************************
+      // *               Public operators                *
+      // *************************************************
+      
+    }      
+        
+
+    public struct BinaryGaloisFieldElement
+    {
+      // *************************************************
+      // *              Consts and Enums                 *
+      // *************************************************
+      
+      
+      // *************************************************
+      // *               Private Members                 *
+      // *************************************************      
+
+      private Int32 value;      
+     
+      
+      // *************************************************
+      // *            Private Constructors               *
+      // *************************************************
+      
+      // Private instance constructor. Creates a BinaryGaloisFieldElement
+      // with a known value.
+      private BinaryGaloisFieldElement(Int32 value)
+      {
+        this.value = value;
+      }
+      
+      
+      // *************************************************
+      // *               Private Methods                 *
+      // *************************************************      
+
+
+      // *************************************************
+      // *        Public properties and Indexer          *
+      // *************************************************
+
+      // The Value property is the known value of this BinaryGaloisFieldElement, or 0 if this
+      // BinaryGaloisFieldElement represents an unknown value.
+      public int Value
+      { 
+        get { return value; }
+      }
+
+      
+      // *************************************************
+      // *             Public constructors               *
+      // *************************************************      
+
+      
+      // *************************************************
+      // *                Public methods                 *
+      // *************************************************
+      
+      public static Int32 Order(BinaryGaloisFieldElement x)
+      {
+        UInt32 Mask = 0x80000000;
+        Int32 order = 31;
+        
+        while (((x.Value & Mask) == 0x0) && (order > 0))
+        {
+          Mask >>= 1;
+          order--;
+        }
+        
+        return order;
+      }
+
+      
+      // *************************************************
+      // *               Public operators                *
+      // *************************************************
+      
+      // Implicit conversion from int to BinaryGaloisFieldElement.
+      public static implicit operator BinaryGaloisFieldElement(Int32 x) 
+      {
+        return new BinaryGaloisFieldElement(x);
+      }
+      
+      public static implicit operator BinaryGaloisFieldElement(Int16 x) 
+      {
+        return new BinaryGaloisFieldElement((Int32)x);
+      }      
+      
+      public static implicit operator BinaryGaloisFieldElement(SByte x) 
+      {
+        return new BinaryGaloisFieldElement((Int32)x);
+      }
+      
+      public static implicit operator BinaryGaloisFieldElement(UInt32 x) 
+      {
+        return new BinaryGaloisFieldElement((Int32)x);
+      }
+      
+      public static implicit operator BinaryGaloisFieldElement(UInt16 x) 
+      {
+        return new BinaryGaloisFieldElement((Int32)x);
+      }      
+      
+      public static implicit operator BinaryGaloisFieldElement(Byte x) 
+      {
+        return new BinaryGaloisFieldElement((Int32)x);
+      }            
+
+      // Explicit conversion from BinaryGaloisFieldElement to int. Throws an exception if the
+      // given BinaryGaloisFieldElement represents an unknown value.
+      public static explicit operator Int32(BinaryGaloisFieldElement x)
+      {
+        return x.value;
+      }
+   
+      // Unary + operator
+      public static BinaryGaloisFieldElement operator +(BinaryGaloisFieldElement x)
+      {
+        return x;
+      }
+
+      // Unary - operator
+      public static BinaryGaloisFieldElement operator -(BinaryGaloisFieldElement x)
+      {
+        return x;
+      }
+
+      public static BinaryGaloisFieldElement operator +(BinaryGaloisFieldElement x, BinaryGaloisFieldElement y)
+      {
+        return x^y;
+      }
+
+      public static BinaryGaloisFieldElement operator -(BinaryGaloisFieldElement x, BinaryGaloisFieldElement y)
+      {
+        return x^y;
+      }
+      
+      public static BinaryGaloisFieldElement operator ^(BinaryGaloisFieldElement x, BinaryGaloisFieldElement y)
+      {
+        return (x.value ^ y.value);
+      }
+      
+      public static BinaryGaloisFieldElement operator &(BinaryGaloisFieldElement x, BinaryGaloisFieldElement y)
+      {
+        return (x.value & y.value);
+      }
+      
+      public static BinaryGaloisFieldElement operator |(BinaryGaloisFieldElement x, BinaryGaloisFieldElement y)
+      {
+        return (x.value | y.value);
+      }
+
+      public static BinaryGaloisFieldElement operator <<(BinaryGaloisFieldElement x, Int32 y)
+      {
+        return (x.value << y);
+      }
+      
+      public static BinaryGaloisFieldElement operator >>(BinaryGaloisFieldElement x, Int32 y)
+      {
+        return (x.value >> y);
+      }
+
+/*
+      public static BinaryGaloisFieldElement operator *(BinaryGaloisFieldElement x, BinaryGaloisFieldElement y)
+      {
+        return (x.defined && y.defined) ? x.value * y.value: Null;
+      }
+
+      public static BinaryGaloisFieldElement operator /(BinaryGaloisFieldElement x, BinaryGaloisFieldElement y)
+      {
+        return (x.defined && y.defined) ? x.value / y.value: Null;
+      }
+
+      public static BinaryGaloisFieldElement operator %(BinaryGaloisFieldElement x, BinaryGaloisFieldElement y)
+      {
+        return (x.defined && y.defined) ? x.value % y.value: Null;
+      }
+*/
+
+
+      public static Boolean operator ==(BinaryGaloisFieldElement x, BinaryGaloisFieldElement y)
+      {
+        return (x.value == y.value);
+      }
+
+      public static Boolean operator !=(BinaryGaloisFieldElement x, BinaryGaloisFieldElement y)
+      {
+        return (x.value != y.value);
+      }
+
+      public static Boolean operator >(BinaryGaloisFieldElement x, BinaryGaloisFieldElement y)
+      {
+        return (x.value > y.value);
+      }
+
+      public static Boolean operator <(BinaryGaloisFieldElement x, BinaryGaloisFieldElement y)
+      {
+        return (x.value < y.value);
+      }
+
+      public static Boolean operator >=(BinaryGaloisFieldElement x, BinaryGaloisFieldElement y)
+      {
+        return (x.value >= y.value);
+      }
+
+      public static Boolean operator <=(BinaryGaloisFieldElement x, BinaryGaloisFieldElement y)
+      {
+        return (x.value <= y.value);
+      }
+
+      public override Boolean Equals(object obj)
+      {
+        if (!(obj is BinaryGaloisFieldElement)) 
+          return false;
+        BinaryGaloisFieldElement x = (BinaryGaloisFieldElement)obj;
+        return ((value == x.value));
+      }
+
+      public override Int32 GetHashCode()
+      {
+        return value;
+      }
+
+      public override String ToString()
+      {
+        return Convert.ToString(value,2);
+      }
+    }
+    
+    public class BinaryGaloisField
+    {
+      // *************************************************
+      // *              Consts and Enums                 *
+      // *************************************************
+    
+      // Lee & Messerschmitt, p. 453
+      private static readonly Int32[] primPoly = new Int32[]
+      {
+        0x00000000, // 0-th element is don't care
+        0x00000000, // 1-st element is don't care
+        0x00000007, // 2-nd: poly = x^2 + x + 1
+        0x0000000B, // 3-rd: poly = x^3 + x + 1
+        0x00000013, // 4-th: poly = x^4 + x + 1
+        0x00000025, // 5-th: poly = x^5 + x^2 + 1
+        0x00000043, // 6-th: poly = x^6 + x + 1
+        0x00000089, // 7-th: poly = x^7 + x^3 + 1
+        0x0000011D, // 8-th: poly = x^8 + x^4 + x^3 + x^2 + 1
+        0x00000211, // 9-th: poly = x^9 + x^4 + 1        
+        0x00000409, // 10-th: poly = x^10 + x^3 + 1
+        0x00000805, // 11-th: poly = x^11 + x^2 + 1
+        0x00001053, // 12-th: poly = x^12 + x^6 + x^4 + x + 1
+        0x0000201B, // 13-th: poly = x^13 + x^4 + x^3 + x + 1
+        0x00004443, // 14-th: poly = x^14 + x^10 + x^6 + x + 1
+        0x00008003, // 15-th: poly = x^15 + x + 1
+        0x0001100B  // 16-th: poly = x^16 + x^12 + x^3 + x + 1
+      };
+
+      
+      // *************************************************
+      // *               Private Members                 *
+      // *************************************************
+      
+      // Currently selected irreducible poly
+      private BinaryGaloisFieldElement poly;
+      
+      // Primitive element, alpha
+      private BinaryGaloisFieldElement primElement;
+      
+      // Length of field
+      private Int32 length;
+    
+      // Field values in order
+      private BinaryGaloisFieldElement[] element;
+      
+      // Field values using cyclic generator alpha
+      private BinaryGaloisFieldElement[] alpha;
+      
+      // Index values for each alpha exponent
+      private Int32[] index;
+      
+      
+      // *************************************************
+      // *               Private Methods                 *
+      // *************************************************
+      
+      // Create array of in order field elements
+      private void GenerateFieldElements()
+      {
+        element = new BinaryGaloisFieldElement[length];
+        
+        for (int i = 0; i<length; i++)
+        {
+          element[i] = i;
+        }
+      }
+      
+      // Create array of alpha exponents
+      private void GenerateAlphaExponents()
+      {
+        alpha = new BinaryGaloisFieldElement[length];
+        index = new Int32[length];
+        
+        // This is a dummy value so that alpha^i is at index i;
+        alpha[0] = (BinaryGaloisFieldElement) 1;
+        index[0] = 1;
+        
+        for (int i = 1; i<length; i++)
+        {
+          alpha[i] = Multiply(alpha[i-1],primElement);
+          index[alpha[i].Value] = i;
+        }
+      }      
+      
+      
+      // *************************************************
+      // *        Public Properties and Indexer          *
+      // *************************************************
+
+      // Field Length
+      public Int32 Length
+      {
+        get
+        { 
+          return length; 
+        }
+      }
+      
+      
+      // *************************************************
+      // *             Public constructors               *
+      // *************************************************
+      
+      // Public constructor for Binary Galois Field class
+      // r is the exponent to which 2 is raised
+      public BinaryGaloisField(Int32 r)
+      {
+        // Set the irreducible polynomial for GF(2^r)
+        poly = (BinaryGaloisFieldElement) primPoly[r];
+        
+        // Set the primitive element alpha
+        primElement = (BinaryGaloisFieldElement) 2;
+        
+        // Set the field length
+        length = (1 << r);
+        
+        // Generate the field elements
+        GenerateFieldElements();
+        
+        // Generate the alpha exponents
+        GenerateAlphaExponents();
+      }
+      
+      
+      // *************************************************
+      // *                Public methods                 *
+      // *************************************************
+      
+      // Array for access to field element
+      public BinaryGaloisFieldElement Element(int index)
+      {
+        return this.element[index];
+      }
+      
+      // Array for access to alpha exponents
+      public BinaryGaloisFieldElement AlphaFromIndex(int index)
+      {
+        //Console.WriteLine("index = {0}",(index % length));
+        return this.alpha[(index % (length-1))];
+      }
+      
+      // Array for access to alpha exponents
+      public Int32 IndexFromAlpha(BinaryGaloisFieldElement alpha)
+      {
+        if ( (alpha.Value == 0) || (alpha.Value >= Length) )
+          throw new ArgumentException("IndexFromAlpha: Out of range", "alpha");
+        return this.index[alpha.Value];
+      }
+      
+      // Assume field Elements are polynomials of max order 15
+      public BinaryGaloisFieldElement Multiply(BinaryGaloisFieldElement x, BinaryGaloisFieldElement y)
+      {
+        BinaryGaloisFieldElement tempVal = (BinaryGaloisFieldElement) 0;
+        UInt32 mask = 0x1;
+        
+        // Perform multiplication
+        for (int i = 0; i<16; i++)
+        {
+          if ((x.Value & mask) != 0)
+          {
+            tempVal += (y << i);
+          }
+          mask <<= 1;
+        }
+        
+        // Now take modulo poly
+        return Modulo(tempVal,poly);
+      }
+      
+      public BinaryGaloisFieldElement Divide(BinaryGaloisFieldElement x, BinaryGaloisFieldElement y)
+      {
+        Int32 result = 0x0;
+        Int32 ordX, ordY;
+        
+        ordX = BinaryGaloisFieldElement.Order(x);
+        ordY = BinaryGaloisFieldElement.Order(y);
+        
+        // if x is already of lower order than y, abort
+        if ( ordX < ordY)
+          return ((BinaryGaloisFieldElement) 0);
+        
+        // Perform long division
+        while (ordX >= ordY)
+        {
+          if ( (x.Value & (0x1 << ordX)) != 0)
+          {
+            result = 0x1 << (ordX - ordY);
+            x -= (y << (ordX - ordY));
+          }
+          ordX--;
+        }
+
+        return ((BinaryGaloisFieldElement)result);
+      }
+      
+      public BinaryGaloisFieldElement Modulo(BinaryGaloisFieldElement x, BinaryGaloisFieldElement y)
+      {
+        Int32 ordX, ordY;
+        
+        ordX = BinaryGaloisFieldElement.Order(x);
+        ordY = BinaryGaloisFieldElement.Order(y);
+      
+        // if x is already of lower order than y, abort
+        if (BinaryGaloisFieldElement.Order(x) < BinaryGaloisFieldElement.Order(y))
+          return x;
+      
+        // Keep subtracting mod value until we are in a valid range
+        // Perform long division
+        while (ordX >= ordY)
+        {
+          if ( (x.Value & (0x1 << ordX)) != 0)
+          {
+            x -= (y << (ordX - ordY));
+          }
+          ordX--;
+        }
+        return x;
+      }
+      
+
+      // *************************************************
+      // *               Public operators                *
+      // *************************************************
+      
+      
+      
+    }
+}
diff --git a/tools/omapl13x_boot_utils/Common/UtilLib/ElfFile.cs b/tools/omapl13x_boot_utils/Common/UtilLib/ElfFile.cs
new file mode 100644 (file)
index 0000000..0cc9a40
--- /dev/null
@@ -0,0 +1,1168 @@
+/*
+ * ElfFile.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+// This module parses an ELF file. This information includes header info.,
+// symbol table, section data, etc.
+
+using System;
+using System.Text;
+using System.IO;
+using System.IO.Ports;
+using System.Reflection;
+using System.Threading;
+using System.Globalization;
+using System.Collections;
+using TI.UtilLib;
+using TI.UtilLib.IO;
+
+namespace TI.UtilLib.ObjectFile
+{ 
+
+#region ELF Identifier Typedefs/Enums
+  // ELF Class (invalid, 32-bit, or 64-bit), used in ELF_Identifier
+  public enum ELF_FileClass : byte
+  {
+    ELFCLASS_NONE = 0x0,
+    ELFCLASS_32   = 0x1,
+    ELFCLASS_64   = 0x2
+  }
+  
+  // ELF Data encoding (endianness), used in ELF_Identifier
+  public enum ELF_DataEncoding : byte
+  {
+    ELFDATA_NONE   = 0x0,
+    ELFDATA_2LSB   = 0x1, // Little Endian
+    ELFDATA_2MSB   = 0x2  // Big Endian
+  }
+  
+  // ELF File Version, used in ELF_Identifier
+  public enum ELF_FileVersion : byte
+  {
+    ELFVER_NONE       = 0x0,
+    ELFVER_CURRENT    = 0x1
+  }
+  
+  // ELF OS/ABI Identification, used in ELF_Identifier
+  public enum ELF_OsAbiID : byte
+  {
+    ELFOSABI_NONE     = 0,    // No extensions or unspecified
+    ELFOSABI_HPUX     = 1,    // Hewlett-Packard HP-UX
+    ELFOSABI_NETBSD   = 2,    // NetBSD
+    ELFOSABI_SOLARIS  = 6,    // Sun Solaris
+    ELFOSABI_AIX      = 7,    // AIX
+    ELFOSABI_IRIX     = 8,    // IRIX
+    ELFOSABI_FREEBSD  = 9,    // FreeBSD
+    ELFOSABI_TRU64    = 10,   // Compaq TRU64 UNIX
+    ELFOSABI_MODESTO  = 11,   // Novell Modesto
+    ELFOSABI_OPENBSD  = 12,   // Open BSD
+    ELFOSABI_OPENVMS  = 13,   // Open VMS
+    ELFOSABI_NSK      = 14,   // Hewlett-Packard Non-Stop Kernel
+    ELFOSABI_AROS     = 15       // Amiga Research OS  
+  }
+  
+  // ELF Identifier Structure, used in ELF header
+  public struct ELF_Identifier
+  {
+    public Byte[]            magic;
+    public ELF_FileClass     fileClass;
+    public ELF_DataEncoding  dataEncoding;
+    public ELF_FileVersion   fileVersion;
+    public ELF_OsAbiID       osAbiID;
+    public Byte              abiVersion;
+    public Byte[]            pad;
+  }
+#endregion
+
+
+#region ELF Header Typedefs/Enums
+  // ELF Type, used in ELF header
+  public enum ELF_Type : ushort
+  {
+    ELFTYPE_NONE    = 0x00C0,
+    ELFTYPE_REL     = 0x0001,
+    ELFTYPE_EXEC    = 0x0002,
+    ELFTYPE_DYN     = 0x0003,
+    ELFTYPE_CORE    = 0x0004,
+    ELFTYPE_LOOS    = 0xfe00,   // Operating system-specific
+    ELFTYPE_HIOS    = 0xfeff,   // Operating system-specific
+    ELFTYPE_LOPROC  = 0xff00,  // Processor-specific
+    ELFTYPE_HIPROC  = 0xffff    // Processor-specific      
+  }
+
+  // ELF Machine (Architecture) Identifier, used in ELF Header
+  public enum ELF_Machine: ushort
+  {
+    EM_NONE             = 0,    // No machine
+    EM_M32              = 1,     // AT&T WE 32100
+    EM_SPARC            = 2,     // SPARC
+    EM_386              = 3,     // Intel 80386
+    EM_68K              = 4,    // Motorola 68000
+    EM_88K              = 5,    // Motorola 88000
+    EM_860              = 7,    // Intel 80860
+    EM_MIPS             = 8,    // MIPS I Architecture
+    EM_S370             = 9,    // IBM System/370 Processor
+    EM_MIPS_RS3_LE      = 10,   // MIPS RS3000 Little-endian
+    EM_PARISC           = 15,   // Hewlett-Packard PA-RISC
+    EM_VPP500           = 17,   // Fujitsu VPP500
+    EM_SPARC32PLUS      = 18,   // Enhanced instruction set SPARC
+    EM_960              = 19,   // Intel 80960
+    EM_PPC              = 20,   // PowerPC
+    EM_PPC64            = 21,   // 64-bit PowerPC
+    EM_S390             = 22,   // IBM System/390 Processor
+    EM_V800             = 36,   // NEC V800
+    EM_FR20             = 37,   // Fujitsu FR20
+    EM_RH32             = 38,   // TRW RH-32
+    EM_RCE              = 39,   // Motorola RCE
+    EM_ARM              = 40,   // Advanced RISC Machines ARM
+    EM_ALPHA            = 41,   // Digital Alpha
+    EM_SH               = 42,   // Hitachi SH
+    EM_SPARCV9          = 43,  // SPARC Version 9
+    EM_TRICORE          = 44,   // Siemens TriCore embedded processor
+    EM_ARC              = 45,   // Argonaut RISC Core, Argonaut Technologies Inc.
+    EM_H8_300           = 46,   // Hitachi H8/300
+    EM_H8_300H          = 47,   // Hitachi H8/300H
+    EM_H8S              = 48,   // Hitachi H8S
+    EM_H8_500           = 49,   // Hitachi H8/500
+    EM_IA_64            = 50,   // Intel IA-64 processor architecture
+    EM_MIPS_X           = 51,   // Stanford MIPS-X
+    EM_COLDFIRE         = 52,   // Motorola ColdFire
+    EM_68HC12           = 53,   // Motorola M68HC12
+    EM_MMA              = 54,   // Fujitsu MMA Multimedia Accelerator
+    EM_PCP              = 55,   // Siemens PCP
+    EM_NCPU             = 56,  // Sony nCPU embedded RISC processor
+    EM_NDR1             = 57,   // Denso NDR1 microprocessor
+    EM_STARCORE         = 58,   // Motorola Star*Core processor
+    EM_ME16             = 59,   // Toyota ME16 processor
+    EM_ST100            = 60,   // STMicroelectronics ST100 processor
+    EM_TINYJ            = 61,   // Advanced Logic Corp. TinyJ embedded processor family
+    EM_X86_64           = 62,   // AMD x86-64 architecture
+    EM_PDSP             = 63,   // Sony DSP Processor
+    EM_PDP10            = 64,   // Digital Equipment Corp. PDP-10
+    EM_PDP11            = 65,   // Digital Equipment Corp. PDP-11
+    EM_FX66             = 66,   // Siemens FX66 microcontroller
+    EM_ST9PLUS          = 67,   // STMicroelectronics ST9+ 8/16 bit microcontroller
+    EM_ST7              = 68,   // STMicroelectronics ST7 8-bit microcontroller
+    EM_68HC16           = 69,   // Motorola MC68HC16 Microcontroller
+    EM_68HC11           = 70,   // Motorola MC68HC11 Microcontroller
+    EM_68HC08           = 71,   // Motorola MC68HC08 Microcontroller
+    EM_68HC05           = 72,   // Motorola MC68HC05 Microcontroller
+    EM_SVX              = 73,   // Silicon Graphics SVx
+    EM_ST19             = 74,   // STMicroelectronics ST19 8-bit microcontroller
+    EM_VAX              = 75,   // Digital VAX
+    EM_CRIS             = 76,   // Axis Communications 32-bit embedded processor
+    EM_JAVELIN          = 77,   // Infineon Technologies 32-bit embedded processor
+    EM_FIREPATH         = 78,   // Element 14 64-bit DSP Processor
+    EM_ZSP              = 79,   // LSI Logic 16-bit DSP Processor
+    EM_MMIX             = 80,   // Donald Knuth's educational 64-bit processor
+    EM_HUANY            = 81,   // Harvard University machine-independent object files
+    EM_PRISM            = 82,   // SiTera Prism
+    EM_AVR              = 83,   // Atmel AVR 8-bit microcontroller
+    EM_FR30             = 84,   // Fujitsu FR30
+    EM_D10V             = 85,   // Mitsubishi D10V
+    EM_D30V             = 86,   // Mitsubishi D30V
+    EM_V850             = 87,   // NEC v850
+    EM_M32R             = 88,   // Mitsubishi M32R
+    EM_MN10300          = 89,   // Matsushita MN10300
+    EM_MN10200          = 90,   // Matsushita MN10200
+    EM_PJ               = 91,   // picoJava
+    EM_OPENRISC         = 92,   // OpenRISC 32-bit embedded processor
+    EM_ARC_A5           = 93,   // ARC Cores Tangent-A5
+    EM_XTENSA           = 94,   // Tensilica Xtensa Architecture
+    EM_VIDEOCORE        = 95,   // Alphamosaic VideoCore processor
+    EM_TMM_GPP          = 96,   // Thompson Multimedia General Purpose Processor
+    EM_NS32K            = 97,   // National Semiconductor 32000 series
+    EM_TPC              = 98,   // Tenor Network TPC processor
+    EM_SNP1K            = 99,   // Trebia SNP 1000 processor
+    EM_ST200            = 100,  // STMicroelectronics (www.st.com) ST200 microcontroller
+    EM_IP2K             = 101,  // Ubicom IP2xxx microcontroller family
+    EM_MAX              = 102,  // MAX Processor
+    EM_CR               = 103,  // National Semiconductor CompactRISC microprocessor
+    EM_F2MC16           = 104,  // Fujitsu F2MC16
+    EM_MSP430           = 105,  // Texas Instruments embedded microcontroller msp430
+    EM_BLACKFIN         = 106,  // Analog Devices Blackfin (DSP) processor
+    EM_SE_C33           = 107,  // S1C33 Family of Seiko Epson processors
+    EM_SEP              = 108,  // Sharp embedded microprocessor
+    EM_ARCA             = 109,  // Arca RISC Microprocessor
+    EM_UNICORE          = 110,  // Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University
+    EM_TI_C6000         = 140  // Texas Instruments C6000 DSP
+  }
+  
+  // ELF Version, used in ELF Header
+  public enum ELF_Version : uint
+  {
+    EV_NONE       = 0x0,
+    EV_CURRENT    = 0x1
+  }
+  
+  public struct ELF_Header
+  {
+    public ELF_Identifier    e_ident;
+    public ELF_Type          e_type;
+    public ELF_Machine       e_machine;
+    public ELF_Version       e_version;
+    public UInt64            e_entry;
+    public UInt64            e_phoff;
+    public UInt64            e_shoff;
+    public UInt32            e_flags;
+    public UInt16            e_ehsize;
+    public UInt16            e_phentsize;
+    public UInt16            e_phnum;
+    public UInt16            e_shentsize;
+    public UInt16            e_shnum;
+    public UInt16            e_shstrndx;
+  }
+#endregion
+  
+  
+#region ELF Section Typedefs/Enums
+  public enum ELF_SectionIndex : ushort
+  {
+    SHN_UNDEF       = 0,
+    SHN_LORESERVE   = 0xff00,
+    SHN_LOPROC      = 0xff00,
+    SHN_HIPROC      = 0xff1f,
+    SHN_LOOS        = 0xff20,
+    SHN_HIOS        = 0xff3f,
+    SHN_ABS         = 0xfff1,
+    SHN_COMMON      = 0xfff2,
+    SHN_XINDEX      = 0xffff,
+    SHN_HIRESERVE   = 0xffff
+  }
+  
+  public enum ELF_SectionType : uint
+  {
+    SHT_NULL              = 0,
+    SHT_PROGBITS          = 1,
+    SHT_SYMTAB            = 2,
+    SHT_STRTAB            = 3,
+    SHT_RELA              = 4,
+    SHT_HASH              = 5,
+    SHT_DYNAMIC           = 6,
+    SHT_NOTE              = 7,
+    SHT_NOBITS            = 8,
+    SHT_REL               = 9,
+    SHT_SHLIB             = 10,
+    SHT_DYNSYM            = 11,
+    SHT_INIT_ARRAY        = 14,
+    SHT_FINI_ARRAY        = 15,
+    SHT_PREINIT_ARRAY     = 16,
+    SHT_GROUP             = 17,
+    SHT_SYMTAB_SHNDX      = 18,
+    SHT_LOOS              = 0x60000000,
+    SHT_HIOS              = 0x6fffffff,
+    SHT_LOPROC            = 0x70000000,
+    SHT_TI_UNWIND         = 0x70000001,
+    SHT_TI_PREEMPTMAP     = 0x70000002,
+    SHT_TI_ATTRIBUTES     = 0x70000003,
+    SHT_TI_ICODE          = 0x70000004,
+    SHT_TI_XREF           = 0x70000005,
+    SHT_TI_HANDLER        = 0x70000006,
+    SHT_TI_INITINFO       = 0x70000007,
+    SHT_HIPROC            = 0x7fffffff,
+    SHT_LOUSER            = 0x80000000,
+    SHT_HIUSER            = 0xffffffff
+  }
+  
+  public enum ELF_SectionFlag : uint
+  {
+    SHF_WRITE             = 0x1,
+    SHF_ALLOC             = 0x2,
+    SHF_EXECINSTR         = 0x4,
+    SHF_MERGE             = 0x10,
+    SHF_STRINGS           = 0x20,
+    SHF_INFO_LINK         = 0x40,
+    SHF_LINK_ORDER        = 0x80,
+    SHF_OS_NONCONFORMING  = 0x100,
+    SHF_GROUP             = 0x200,
+    SHF_TLS               = 0x400,
+    SHF_MASKOS            = 0x0ff00000,
+    SHF_MASKPROC          = 0xf0000000
+  }
+  
+  public struct ELF_SectionHeader
+  {
+    public UInt32                sh_name;
+    public ELF_SectionType  sh_type;
+    public UInt64                sh_flags;
+    public UInt64                sh_addr;
+    public UInt64           sh_offset;
+    public UInt64                sh_size;
+    public UInt32                sh_link;
+    public UInt32                sh_info;
+    public UInt64                sh_addralign;
+    public UInt64                sh_entsize;
+  }  
+#endregion
+  
+
+#region ELF Segment Typedefs/Enums
+  public enum ELF_SegmentType
+  {
+    PT_NULL             = 0,
+    PT_LOAD             = 1,
+    PT_DYNAMIC          = 2,
+    PT_INTERP           = 3,
+    PT_NOTE             = 4,
+    PT_SHLIB            = 5,
+    PT_PHDR             = 6,
+    PT_TLS              = 7,
+    PT_LOOS             = 0x60000000,
+    PT_HIOS             = 0x6fffffff,
+    PT_LOPROC           = 0x70000000,
+    PT_HIPROC           = 0x7fffffff
+  }
+  
+  public enum ELF_SegmentFlags : uint
+  {
+    PF_X                = 0x1,  // Execute
+    PF_W                = 0x2,         // Write
+    PF_R                = 0x4,  // Read
+    PF_MASKOS           = 0x0ff00000, // Unspecified
+    PF_MASKPROC         = 0xf0000000  // Unspecified
+  }
+  
+  public struct ELF_SegmentHeader
+  {
+    public ELF_SegmentType p_type;
+    public UInt32 p_flags;
+    public UInt64 p_offset;
+    public UInt64 p_vaddr;
+    public UInt64 p_paddr;
+    public UInt64 p_filesz;
+    public UInt64 p_memsz;
+    public UInt64 p_align;
+  }
+#endregion
+
+
+#region ELF Symbol Typedefs/Enums
+  public enum ELF_SymbolType : byte
+  {
+    STT_NOTYPE    = 0,
+    STT_OBJECT    = 1,
+    STT_FUNC      = 2,
+    STT_SECTION   = 3,
+    STT_FILE      = 4,
+    STT_COMMON    = 5,
+    STT_TLS       = 6,
+    STT_LOOS      = 10,
+    STT_HIOS      = 12,
+    STT_LOPROC    = 13,
+    STT_HIPROC    = 15  
+  }
+  
+  public enum ELF_SymbolBinding : byte
+  {
+    STB_LOCAL   = 0,
+    STB_GLOBAL  = 1,
+    STB_WEAK    = 2,
+    STB_LOOS    = 10,
+    STB_HIOS    = 12,
+    STB_LOPROC  = 13,
+    STB_HIPROC  = 15, 
+  }
+  
+  public enum ELF_SymbolVisibility : byte
+  {
+    STV_DEFAULT   = 0,
+    STV_INTERNAL  = 1,
+    STV_HIDDEN    = 2,
+    STV_PROTECTED = 3
+  }
+
+  public struct ELF_Symbol
+  {
+    public UInt32                st_name;
+    public ELF_SymbolType        st_type;
+    public ELF_SymbolBinding     st_binding;
+    public ELF_SymbolVisibility  st_visibility;
+    public UInt16                st_shndx;
+    public UInt64                st_value;
+    public UInt64                st_size;
+  }  
+#endregion
+
+  /// <summary>
+  /// Public class to read and parse an ELF object file
+  /// </summary>
+  public class ElfFile : ObjectFile
+  {
+    #region Private internal members
+    // ELF Header
+    private ELF_Header hdr;
+    private Hashtable headerRef;
+    private Hashtable[] sectionRef;       
+    private Hashtable[] symRef;
+    #endregion
+    
+    
+    #region Public properties and indexers  
+    public Hashtable Header
+    {
+      get { return headerRef; }
+    }
+    #endregion
+    
+    #region Class constructors
+    /// <summary>
+    /// ElfFile constructor
+    /// </summary>
+    /// <param name="filename">Input .out filename as a string.</param>
+    public ElfFile(String filename) : base(filename)
+    {
+      // Init header hashtable
+      headerRef = new Hashtable();
+      
+      // Parse the COFF file
+      try
+      {
+        ParseElfFile();
+      }
+      catch (Exception e)
+      {
+        Console.Write(e.Message);
+        throw e;
+      }
+      
+      fileType = ObjectFileType.ELF;
+    }
+    #endregion
+
+    
+    #region Public Class Methods
+    public void dumpFileHeader()
+    {
+      foreach (DictionaryEntry de in headerRef)
+      {
+        Console.WriteLine("header[{0}] = {1}", de.Key, de.Value);
+      }
+    }
+
+    public new String ToString()
+    {
+      StringBuilder strBuilder = new StringBuilder(512);
+      
+      foreach (DictionaryEntry de in headerRef)
+      {
+        strBuilder.Append("header{"+de.Key.ToString()+"} = "+de.Value.ToString() + "\n");
+      }
+
+      for (int i = 0; i < sectionRef.Length; i++)
+      {
+        foreach (DictionaryEntry de in sectionRef[i])
+        {
+          strBuilder.Append("sectionHdr["+i+"]{" + de.Key.ToString() + "} = " + de.Value.ToString() + "\n");
+        }
+      }
+
+      for (int i = 0; i < symRef.Length; i++)
+      {
+        foreach (DictionaryEntry de in sectionRef[i])
+        {
+          strBuilder.Append("symbolHdr[" + i + "]{" + de.Key.ToString() + "} = " + de.Value.ToString() + "\n");
+        }
+      }
+
+      return strBuilder.ToString();
+    }
+    
+    #endregion
+
+    
+    #region Private parsing functions
+    /// <summary>
+    /// Parse the ELF file and put info
+    /// </summary>
+    protected void ParseElfFile()
+    {
+      ELF_SectionHeader secHdr;
+    
+      // Output console message
+      Console.WriteLine("Parsing the input object file, {0}.", fileName);
+    
+      // Parse the ELF header
+      try
+      {
+        hdr = ElfFile.ParseELFHeader(binFile);
+      }
+      catch (Exception e)
+      {
+        Console.Write(e.Message);
+        return;
+      }
+      
+      // Determine the Endianness and use an EndianBinaryReader Object
+      endian = (ELF_DataEncoding.ELFDATA_2LSB == hdr.e_ident.dataEncoding) ? Endian.LittleEndian : Endian.BigEndian;
+      EndianBinaryReader ebr = new EndianBinaryReader(binFile,endian);
+      
+      // Set endianness
+      headerRef["endian"] = endian;
+      Debug.DebugMSG("Endianness: " + endian.ToString());
+      
+      // Set entry point of Object File
+      this.entryPoint = (UInt64) hdr.e_entry;
+      
+      // Read the section headers
+      sectionCount = (UInt32) hdr.e_shnum;
+      headerRef["numBootSections"] = (UInt32)0;
+      headerRef["numTargetSections"] = (UInt32)0;      
+      ParseSectionHdrs();
+
+      // Find the symbol table section, symbol table entry size, and number of symbols
+      secFind(".symtab");
+      secHdr = ReadSectionHeader(currSectionIndex);
+      if (secHdr.sh_type != ELF_SectionType.SHT_SYMTAB)
+      {
+        throw new Exception("Symbol table not found in file!");
+      }
+      headerRef["symbolTableAddr"] = (UInt64) secHdr.sh_offset;
+      headerRef["symbolTableEntrySize"] = (UInt32) secHdr.sh_entsize;
+      headerRef["numEntriesInSymTable"] =  (UInt32) (secHdr.sh_size / secHdr.sh_entsize);
+      symbolCount = (UInt32) headerRef["numEntriesInSymTable"];
+
+      Debug.DebugMSG("symbolTableAddr: " + ((UInt64)headerRef["symbolTableAddr"]).ToString("X8"));
+      Debug.DebugMSG("symbolTableEntrySize: " + ((UInt32)headerRef["symbolTableEntrySize"]).ToString("X8"));    
+      Debug.DebugMSG("numEntriesInSymTable: " + ((UInt32)headerRef["numEntriesInSymTable"]).ToString());
+      
+      // Find the string table section
+      secFind(".strtab");
+      secHdr = ReadSectionHeader(currSectionIndex);
+      if (secHdr.sh_type != ELF_SectionType.SHT_STRTAB)
+      {
+        throw new Exception("String table not found in file!");
+      }
+      // Verify that the section header string table section is flagged as a string section
+      if ( ( ((UInt64) secHdr.sh_flags) & ((UInt64) ELF_SectionFlag.SHF_STRINGS) ) == 0 )
+      {
+        Debug.DebugMSG("WARNING: String Table Section is not flagged with SHF_STRINGS.");
+      }
+      
+      headerRef["stringTableAddr"] = (UInt64) secHdr.sh_offset;
+      Debug.DebugMSG("stringTableAddr: " + ((UInt64)headerRef["stringTableAddr"]).ToString("X8"));
+
+      // Now parse the symbol table
+      ParseSymbolTable();
+      
+      // Read the remaining pertinent info from header
+      headerRef["versionID"] = (UInt32) hdr.e_version;
+      Debug.DebugMSG("versionID: " + ((UInt32)headerRef["versionID"]).ToString("X4"));
+      
+      headerRef["flags"] = hdr.e_flags;
+      Debug.DebugMSG("flags: " + ((UInt32)headerRef["flags"]).ToString("X8"));
+
+    } // end ParseElfFile()
+
+    /// <summary>
+    /// Parse the section headers.
+    /// </summary>
+    private void ParseSectionHdrs()
+    {
+      UInt32 byteSize, wordSize, numBytesInSectionHdr;
+      UInt64 flags;
+      ELF_SectionHeader secHdr;
+      EndianBinaryReader ebr = new EndianBinaryReader(binFile, endian);
+      
+      numBytesInSectionHdr = hdr.e_shentsize;
+      
+      
+      Debug.DebugMSG("Parsing ELF Sections Headers");
+     
+      if (sectionCount == (UInt32) ELF_SectionIndex.SHN_UNDEF)
+      {
+        // Get the actual number of sections from the sh_size field of the
+        // 0th section header table entry
+        secHdr = ReadSectionHeader(0);
+        sectionCount = (UInt32) secHdr.sh_size;
+        headerRef["numSectionHdrs"] = (UInt32) secHdr.sh_size;
+      }
+      
+      // Get Section Header String Table Section Header Index and Section Header String Table Section Address
+      if (hdr.e_shstrndx == (UInt16) ELF_SectionIndex.SHN_UNDEF)
+      {
+        headerRef["stringTableAddr"] = null;
+        headerRef["stringHeaderTableIndex"] = null;
+        secHdr = new ELF_SectionHeader();
+      }
+      else if (hdr.e_shstrndx == (UInt16) ELF_SectionIndex.SHN_XINDEX)
+      {
+        secHdr = ReadSectionHeader(0);
+        headerRef["stringHeaderTableIndex"] = (UInt32) secHdr.sh_link;
+        secHdr = ReadSectionHeader((UInt32) headerRef["stringHeaderTableIndex"]);
+        headerRef["stringTableAddr"] = (UInt64) secHdr.sh_addr;
+      }
+      else
+      {
+        headerRef["stringHeaderTableIndex"] = (UInt32) hdr.e_shstrndx;
+        secHdr = ReadSectionHeader((UInt32) headerRef["stringHeaderTableIndex"]);
+        headerRef["stringTableAddr"] = (UInt64) (secHdr.sh_offset);
+      }
+      Debug.DebugMSG("Section Header Table Index for Section Header String Table: " + (UInt32)headerRef["stringHeaderTableIndex"]);
+      Debug.DebugMSG("String Section Start Addr: 0x" + ((UInt64)headerRef["stringTableAddr"]).ToString("X8"));
+      
+      // Verify that the section header string table section is flagged as a string section
+      flags = (UInt64) secHdr.sh_flags;
+      Debug.DebugMSG("secHdr.sh_flags = " + secHdr.sh_flags.ToString());
+      if ( ( flags & ((UInt64) ELF_SectionFlag.SHF_STRINGS) ) == 0 )
+      {
+        Debug.DebugMSG("WARNING: Section Header String Section is not flagged with SHF_STRINGS");
+      }
+      if (secHdr.sh_type != ELF_SectionType.SHT_STRTAB)
+      {
+        throw new Exception("Section Header String Section is not of type SHT_STRTAB.");
+      }
+      
+      if ( hdr.e_phnum == 0x0)
+      {
+        throw new Exception("Load addresses cannot be calculated without program header.");
+      }
+      
+      // Cycle through all sections, collecting info about each (name, type, etc.)
+      sectionRef  = new Hashtable[sectionCount];
+      sections    = new ObjectSection[sectionCount];
+      for (UInt32 secNum = 0; secNum < sectionCount; secNum++)
+      {
+        sectionRef[secNum]  = new Hashtable();
+        sections[secNum]    = new ObjectSection();
+        secHdr = ReadSectionHeader((UInt32) secNum);
+
+        ebr.BaseStream.Seek((Int64)(secHdr.sh_name + (UInt64)headerRef["stringTableAddr"]), SeekOrigin.Begin);
+        sectionRef[secNum]["name"]      = ELF_getStringFromStringTable();
+        sectionRef[secNum]["type"]      = (ELF_SectionType) secHdr.sh_type;
+        sectionRef[secNum]["phyAddr"]   = (UInt64) secHdr.sh_addr;
+        sectionRef[secNum]["virAddr"]   = (UInt64) secHdr.sh_addr;
+        sectionRef[secNum]["fileAddr"]  = (UInt64) secHdr.sh_offset;
+        
+        byteSize = (UInt32) secHdr.sh_size;
+        wordSize = (byteSize + 3) >> 2;
+        byteSize = wordSize << 2;
+        sectionRef[secNum]["byteSize"]  = byteSize;
+        sectionRef[secNum]["wordSize"] = wordSize;
+        sectionRef[secNum]["flags"] = (UInt64) secHdr.sh_flags;
+        
+        flags = (UInt64) sectionRef[secNum]["flags"];
+        
+        // FIXME: Check to see if section should be copied to target
+        sectionRef[secNum]["copyToTarget"] = false;
+        if ( ( ((UInt64) sectionRef[secNum]["phyAddr"])   != 0 ) &&
+             ( ((UInt32) sectionRef[secNum]["byteSize"])  != 0 ) &&
+             ( ELF_SectionType.SHT_NULL                   != (ELF_SectionType)sectionRef[secNum]["type"] ) &&
+             ( ELF_SectionType.SHT_NOBITS                 != (ELF_SectionType)sectionRef[secNum]["type"] ) &&
+             ( ELF_SectionType.SHT_SYMTAB                 != (ELF_SectionType)sectionRef[secNum]["type"] ) &&
+             ( ELF_SectionType.SHT_DYNSYM                 != (ELF_SectionType)sectionRef[secNum]["type"] ) &&
+             ( ELF_SectionType.SHT_STRTAB                 != (ELF_SectionType)sectionRef[secNum]["type"] )             )
+        {
+          if ( ( ELF_SectionType.SHT_PROGBITS == (ELF_SectionType)sectionRef[secNum]["type"] ) &&
+               ( (flags | ((UInt64) ELF_SectionFlag.SHF_ALLOC)) != 0x0 ) )
+          {
+            headerRef["numTargetSections"] = ((UInt32)headerRef["numTargetSections"]) + 1;
+            sectionRef[secNum]["copyToTarget"] = true;
+          }
+        }
+        
+        // If we think this section should be copied to target, make sure it is 
+        // in a loadable ELF program segment.  If it is, then update physical 
+        // and virtual addresses. If not, then mark it as such.
+        if ((Boolean) sectionRef[secNum]["copyToTarget"])
+        {
+          Boolean segmentFoundForSection = false;
+          for (UInt32 segmentNum = 0; segmentNum < (UInt32)hdr.e_phnum; segmentNum++)
+          {
+            ELF_SegmentHeader segmentHdr = ReadSegmentHeader((UInt32) segmentNum);
+            
+            // If the segment is of load type, check to see if the current section resides in it
+            if (segmentHdr.p_type == ELF_SegmentType.PT_LOAD)
+            {
+              // Check if data is in the file, and if so then check if the section
+              // is within this current segment
+              if ( ( segmentHdr.p_filesz                         != 0                      ) &&
+                   ( segmentHdr.p_vaddr                          <= (UInt64) secHdr.sh_addr) &&
+                   ( (segmentHdr.p_vaddr + segmentHdr.p_filesz)  >  (UInt64) secHdr.sh_addr) &&
+                   ( segmentHdr.p_offset                         <= (UInt64) secHdr.sh_offset) &&
+                   ( (segmentHdr.p_offset + segmentHdr.p_filesz) >  (UInt64) secHdr.sh_offset) )
+                   
+              {
+                sectionRef[secNum]["phyAddr"] = (UInt64) segmentHdr.p_paddr + ( secHdr.sh_addr - segmentHdr.p_vaddr);
+                segmentFoundForSection = true;
+              }
+            }
+          }
+          if (!segmentFoundForSection)
+          {
+            // This section is not actually in a loadable ELF program segment, indicate that
+            sectionRef[secNum]["copyToTarget"] = false;
+          }
+        }
+        
+        sections[secNum].name         = (String) sectionRef[secNum]["name"];
+        sections[secNum].size         = (UInt32) sectionRef[secNum]["byteSize"];        
+        sections[secNum].runAddr      = (UInt64) sectionRef[secNum]["virAddr"];
+        sections[secNum].loadAddr     = (UInt64) sectionRef[secNum]["phyAddr"];
+        sections[secNum].isLoadable   = (Boolean) sectionRef[secNum]["copyToTarget"];
+        if (sections[secNum].isLoadable)
+        {
+          loadableSectionCount++;
+        }
+        sections[secNum].binFileAddr  = (UInt64) sectionRef[secNum]["fileAddr"];
+        
+        Debug.DebugMSG("ObjectSection sections[" + secNum + "] = \n{");
+        Debug.DebugMSG("\tname = " + sections[secNum].name + ",");
+        Debug.DebugMSG("\tsize = " + sections[secNum].size.ToString("X8") + ",");
+        Debug.DebugMSG("\trunAddr = " + sections[secNum].runAddr.ToString("X8") + ",");
+        Debug.DebugMSG("\tloadAddr = " + sections[secNum].loadAddr.ToString("X8") + ",");
+        Debug.DebugMSG("\tisLoadable = " + sections[secNum].isLoadable + ",");
+        Debug.DebugMSG("\tbinFileAddr = " + sections[secNum].binFileAddr.ToString("X8"));
+        Debug.DebugMSG("}");
+      }
+      
+      // Fill in the loadableSections array
+      loadableSections = new ObjectSection[loadableSectionCount];
+      for (UInt32 secNum = 0,loadableSecNum=0; secNum < sectionCount; secNum++)
+      {
+        if (sections[secNum].isLoadable)
+        {
+          loadableSections[loadableSecNum] = sections[secNum];
+          loadableSecNum++;
+        }
+      }
+      
+      // Finally, sort the loadable sections array by load address
+      Array.Sort<ObjectSection>(loadableSections);
+      
+      Debug.DebugMSG("Parse Section Headers Done");
+    } // end of ParseSectionHdrs()
+    
+    /// <summary>
+    /// Read the section header from the section header table
+    /// </summary>
+    private ELF_SectionHeader ReadSectionHeader(UInt32 index)
+    {
+      EndianBinaryReader ebr = new EndianBinaryReader(binFile, endian);
+      ELF_SectionHeader sectionHeader = new ELF_SectionHeader();
+     
+      // Seek to the start of the section header in section header table
+      binFile.Seek((Int64)(hdr.e_shentsize * index + hdr.e_shoff), SeekOrigin.Begin);
+      
+      //Debug.DebugMSG( "Header for Section["+index+"] = \n{");
+      
+      sectionHeader.sh_name = ebr.ReadUInt32();
+      sectionHeader.sh_type = (ELF_SectionType) ebr.ReadUInt32();
+      
+      //Debug.DebugMSG(   "  Section Name Index         : " + sectionHeader.sh_name);
+      //Debug.DebugMSG(   "  Section Type               : " + sectionHeader.sh_type);
+      
+      if (ELF_FileClass.ELFCLASS_32 == hdr.e_ident.fileClass)
+      {
+        sectionHeader.sh_flags      = (UInt64) ebr.ReadUInt32();
+        sectionHeader.sh_addr       = (UInt64) ebr.ReadUInt32();
+        sectionHeader.sh_offset     = (UInt64) ebr.ReadUInt32();
+        sectionHeader.sh_size       = (UInt64) ebr.ReadUInt32();
+        
+        //Debug.DebugMSG( "  Section Flags              : 0x" + sectionHeader.sh_flags.ToString("X8"));
+        //Debug.DebugMSG( "  Section Address            : 0x" + sectionHeader.sh_addr.ToString("X8"));        
+        //Debug.DebugMSG( "  Section Offset             : 0x" + sectionHeader.sh_offset.ToString("X8"));
+        //Debug.DebugMSG( "  Section Size               : 0x" + sectionHeader.sh_size.ToString("X8"));
+      }
+      else
+      {
+        sectionHeader.sh_flags      = ebr.ReadUInt64();
+        sectionHeader.sh_addr       = ebr.ReadUInt64();
+        sectionHeader.sh_offset     = ebr.ReadUInt64();
+        sectionHeader.sh_size       = ebr.ReadUInt64();
+        
+        //Debug.DebugMSG( "  Section Flags              : 0x" + sectionHeader.sh_flags.ToString("X16"));
+        //Debug.DebugMSG( "  Section Address            : 0x" + sectionHeader.sh_addr.ToString("X16"));        
+        //Debug.DebugMSG( "  Section Offset             : 0x" + sectionHeader.sh_offset.ToString("X16"));
+        //Debug.DebugMSG( "  Section Size               : 0x" + sectionHeader.sh_size.ToString("X16"));
+      }
+      sectionHeader.sh_link      = ebr.ReadUInt32();
+      sectionHeader.sh_info      = ebr.ReadUInt32();
+      //Debug.DebugMSG(   "  Section Link Index         : 0x" + sectionHeader.sh_flags.ToString("X8"));
+      //Debug.DebugMSG(   "  Section Info Field         : 0x" + sectionHeader.sh_addr.ToString("X8")); 
+      
+      if (ELF_FileClass.ELFCLASS_32 == hdr.e_ident.fileClass)
+      {
+        sectionHeader.sh_addralign      = (UInt64) ebr.ReadUInt32();
+        sectionHeader.sh_entsize        = (UInt64) ebr.ReadUInt32();
+        
+        //Debug.DebugMSG( "  Section Addr Aligmnent     : 0x" + sectionHeader.sh_addralign.ToString("X8"));
+        //Debug.DebugMSG( "  Section Entry Size         : 0x" + sectionHeader.sh_entsize.ToString("X8"));
+      }
+      else
+      {
+        sectionHeader.sh_addralign      = ebr.ReadUInt64();
+        sectionHeader.sh_entsize        = ebr.ReadUInt64();
+        
+        //Debug.DebugMSG( "  Section Addr Aligmnent     : 0x" + sectionHeader.sh_addralign.ToString("X16"));
+        //Debug.DebugMSG( "  Section Entry Size         : 0x" + sectionHeader.sh_entsize.ToString("X16"));
+      }
+      //Debug.DebugMSG("}");
+      
+      return sectionHeader;
+    }
+    
+    // 
+    /// <summary>
+    /// Read the segment header from the program header table
+    /// </summary>
+    private ELF_SegmentHeader ReadSegmentHeader(UInt32 index)
+    {
+      EndianBinaryReader ebr = new EndianBinaryReader(binFile, endian);
+      ELF_SegmentHeader segmentHeader = new ELF_SegmentHeader();
+     
+      // Seek to the start of the section header in section header table
+      binFile.Seek((Int64)(hdr.e_phentsize * index + hdr.e_phoff), SeekOrigin.Begin);
+      
+      //Debug.DebugMSG( "Segment["+index+"] = \n{");
+
+      // Read segment type
+      segmentHeader.p_type = (ELF_SegmentType) ebr.ReadUInt32();
+      
+      //Debug.DebugMSG(   "  Segment Type               : " + segmentHeader.p_type);
+      
+      if (ELF_FileClass.ELFCLASS_32 == hdr.e_ident.fileClass)
+      {
+        segmentHeader.p_offset      = (UInt64) ebr.ReadUInt32();        
+        segmentHeader.p_vaddr       = (UInt64) ebr.ReadUInt32();
+        segmentHeader.p_paddr       = (UInt64) ebr.ReadUInt32();        
+        segmentHeader.p_filesz      = (UInt64) ebr.ReadUInt32();
+        segmentHeader.p_memsz       = (UInt64) ebr.ReadUInt32();        
+        segmentHeader.p_flags       = (UInt32) ebr.ReadUInt32();
+        segmentHeader.p_align       = (UInt64) ebr.ReadUInt32();        
+        
+        /*
+        Debug.DebugMSG( "  Segment Flags              : 0x" + segmentHeader.p_flags.ToString("X8"));        
+        Debug.DebugMSG( "  Segment Offset             : 0x" + segmentHeader.p_offset.ToString("X8"));
+        Debug.DebugMSG( "  Segment Virtual Address    : 0x" + segmentHeader.p_vaddr.ToString("X8"));
+        Debug.DebugMSG( "  Segment Physical Address   : 0x" + segmentHeader.p_paddr.ToString("X8"));
+        Debug.DebugMSG( "  Segment File Size          : 0x" + segmentHeader.p_filesz.ToString("X8"));
+        Debug.DebugMSG( "  Segment Memory Size        : 0x" + segmentHeader.p_memsz.ToString("X8"));
+        Debug.DebugMSG( "  Segment Align              : 0x" + segmentHeader.p_align.ToString("X8"));
+        */
+      }
+      else
+      {
+        segmentHeader.p_flags       = (UInt32) ebr.ReadUInt32();
+        segmentHeader.p_offset      = (UInt64) ebr.ReadUInt64();
+        segmentHeader.p_vaddr       = (UInt64) ebr.ReadUInt64();
+        segmentHeader.p_paddr       = (UInt64) ebr.ReadUInt64();
+        segmentHeader.p_filesz      = (UInt64) ebr.ReadUInt64();
+        segmentHeader.p_memsz       = (UInt64) ebr.ReadUInt64();
+        segmentHeader.p_align       = (UInt64) ebr.ReadUInt64();
+        
+        /*
+        Debug.DebugMSG( "  Segment Flags              : 0x" + segmentHeader.p_flags.ToString("X8"));
+        Debug.DebugMSG( "  Segment Offset             : 0x" + segmentHeader.p_offset.ToString("X16"));
+        Debug.DebugMSG( "  Segment Virtual Address    : 0x" + segmentHeader.p_vaddr.ToString("X16"));
+        Debug.DebugMSG( "  Segment Physical Address   : 0x" + segmentHeader.p_paddr.ToString("X16"));
+        Debug.DebugMSG( "  Segment File Size          : 0x" + segmentHeader.p_filesz.ToString("X16"));
+        Debug.DebugMSG( "  Segment Memory Size        : 0x" + segmentHeader.p_memsz.ToString("X16"));
+        Debug.DebugMSG( "  Segment Align              : 0x" + segmentHeader.p_align.ToString("X16"));
+        */
+      }
+      
+      //Debug.DebugMSG(   "}" );
+    
+      return segmentHeader;
+    }
+    
+    private void ParseSymbolTable()
+    {
+      EndianBinaryReader ebr = new EndianBinaryReader(binFile, endian);
+      UInt32 numSymbols = (UInt32) headerRef["numEntriesInSymTable"];
+      ELF_Symbol sym;
+      Byte info, other;
+      
+      symRef = new Hashtable[symbolCount];
+      symbols = new ObjectSymbol[symbolCount];
+
+      // Read the symbol table
+      for (UInt32 symNum = 0; symNum < symbolCount; symNum++)
+      {
+        symRef[symNum] = new Hashtable();
+        symbols[symNum] = new ObjectSymbol();
+        
+        // Go to current symbol
+        ebr.BaseStream.Seek((Int64) ((UInt64)headerRef["symbolTableAddr"]) + ((UInt32)headerRef["symbolTableEntrySize"] * symNum),SeekOrigin.Begin);
+        sym.st_name       = (UInt32) ebr.ReadUInt32();
+
+        if (ELF_FileClass.ELFCLASS_32 == hdr.e_ident.fileClass)
+        {
+          sym.st_value    = (UInt64) ebr.ReadUInt32();
+          sym.st_size     = (UInt64) ebr.ReadUInt32();
+          info            = ebr.ReadByte();
+          other           = ebr.ReadByte();
+          sym.st_shndx    = ebr.ReadUInt16();
+        }
+        else
+        {
+          info            = ebr.ReadByte();
+          other           = ebr.ReadByte();
+          sym.st_shndx    = ebr.ReadUInt16();
+          sym.st_value    = ebr.ReadUInt64();
+          sym.st_size     = ebr.ReadUInt64();
+        }
+        sym.st_type       = (ELF_SymbolType) (info & 0xF);
+        sym.st_binding    = (ELF_SymbolBinding) ((info >> 4) & 0xF);
+        sym.st_visibility = (ELF_SymbolVisibility) (other & 0x3);
+        
+        /*
+        Debug.DebugMSG( "Symbol[" + symNum + "] = \n{" );
+        Debug.DebugMSG( "  Symbol Name Offset        : 0x" + sym.st_name.ToString("X8"));        
+        Debug.DebugMSG( "  Symbol Value              : 0x" + sym.st_value.ToString("X16"));
+        Debug.DebugMSG( "  Symbol Size               : 0x" + sym.st_size.ToString("X16"));
+        Debug.DebugMSG( "  Symbol Type               : "   + sym.st_type);
+        Debug.DebugMSG( "  Symbol Binding            : "   + sym.st_binding);
+        Debug.DebugMSG( "  Symbol Visibility         : "   + sym.st_visibility);
+        Debug.DebugMSG( "  Symbol's Relevant Section : 0x" + sym.st_shndx.ToString("X4"));
+        Debug.DebugMSG( "}\n");
+        */
+
+        // Move to name in String Table
+        ebr.BaseStream.Seek( (Int64) ((UInt64)headerRef["stringTableAddr"]) + (sym.st_name), SeekOrigin.Begin);
+        symRef[symNum]["name"] = ELF_getStringFromStringTable();
+        symRef[symNum]["value"] = sym.st_value;
+        symRef[symNum]["secNum"] = sym.st_shndx;
+        symRef[symNum]["type"] = sym.st_type;
+        symRef[symNum]["binding"] = sym.st_binding;
+        symRef[symNum]["visibility"] = sym.st_visibility;
+        
+        symbols[symNum].name = (String) symRef[symNum]["name"];
+        symbols[symNum].value = (UInt64) symRef[symNum]["value"];
+        
+        Debug.DebugMSG("symbols[" + symNum + "] = {");
+        Debug.DebugMSG("\tname = " + symbols[symNum].name + ",");
+        Debug.DebugMSG("\tvalue = " + symbols[symNum].value.ToString("X8") + " }");
+        
+        /*
+        Debug.DebugMSG("symRef[" + symNum.ToString() + "][\"name\"]: " + ((String)symRef[symNum]["name"]).ToString());
+        Debug.DebugMSG("symRef[" + symNum.ToString() + "][\"value\"]: " + ((UInt64)symRef[symNum]["value"]).ToString("X8"));
+        Debug.DebugMSG("symRef[" + symNum.ToString() + "][\"secNum\"]: " + ((UInt16)symRef[symNum]["secNum"]).ToString("X4"));
+        Debug.DebugMSG("symRef[" + symNum.ToString() + "][\"type\"]: " + sym.st_type);
+        Debug.DebugMSG("symRef[" + symNum.ToString() + "][\"binding\"]: " + sym.st_binding);
+        Debug.DebugMSG("symRef[" + symNum.ToString() + "][\"visibility\"]: " + sym.st_visibility);
+        */
+      }
+
+      // Finally, sort the symbols by value (address)
+      Array.Sort<ObjectSymbol>(symbols);
+      
+      Debug.DebugMSG("Parse Symbol Table Done");
+    } // end of ParseSymbolTable()
+    #endregion
+
+    
+    #region Private helper and debug functions
+    /// <summary>
+    /// Function to retrieve name string either from string table or from current stream pointer.
+    /// </summary>
+    /// <returns>String containing name.</returns>
+    private String ELF_getStringFromStringTable()
+    {
+      Byte currByte;
+      ArrayList name = new ArrayList(128);
+      
+      EndianBinaryReader ebr =  new EndianBinaryReader(binFile,(Endian) headerRef["endian"]);
+
+      // Read characters and build string until terminating null
+      currByte = ebr.ReadByte();
+      
+      while (currByte != 0)
+      {
+          name.Add(currByte);
+          currByte = ebr.ReadByte();
+      }
+
+      if (name.Count > 128)
+          Debug.DebugMSG(ASCIIEncoding.ASCII.GetString((Byte[])name.ToArray(typeof(Byte)), 0, name.Count));
+      return ASCIIEncoding.ASCII.GetString((Byte[]) name.ToArray(typeof(Byte)), 0, name.Count);
+    }
+    #endregion
+
+
+    #region Public Static Class Methods
+    public static Boolean IsElfFile(String filename)
+    {
+      // Get File Details
+      try
+      {
+        if (File.Exists(filename))
+        {
+          // Parse the input file header
+          using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read))
+          {
+            ParseELFHeader(fs);
+          }
+        }
+      }
+      catch
+      {
+        //Console.WriteLine(e.Message);
+        return false;
+      }
+      return true;
+    }
+    
+    public static ELF_Header ParseELFHeader(Stream fs)
+    {
+      ELF_Header hdr;
+
+      // Read ELF Header
+      fs.Seek(0, SeekOrigin.Begin);
+      
+      BinaryReader br = new BinaryReader(fs);
+      
+      {
+        hdr.e_ident.magic         = br.ReadBytes(4);
+        hdr.e_ident.fileClass     = (ELF_FileClass) br.ReadByte();
+        hdr.e_ident.dataEncoding  = (ELF_DataEncoding) br.ReadByte();
+        hdr.e_ident.fileVersion   = (ELF_FileVersion) br.ReadByte();
+        hdr.e_ident.osAbiID       = (ELF_OsAbiID) br.ReadByte();
+        hdr.e_ident.abiVersion    = br.ReadByte();
+        hdr.e_ident.pad           = br.ReadBytes(7);
+        
+        if ( (0x7F != hdr.e_ident.magic[0]) ||
+             ('E' != hdr.e_ident.magic[1])  ||
+             ('L' != hdr.e_ident.magic[2])  ||
+             ('F' != hdr.e_ident.magic[3]) )
+        {
+          throw new Exception("ELF magic number not found. Not an ELF object file.");
+        }
+        
+        if ( (ELF_FileClass.ELFCLASS_32 != hdr.e_ident.fileClass) &&
+             (ELF_FileClass.ELFCLASS_64 != hdr.e_ident.fileClass) )
+        {
+          throw new Exception("Invalid ELF class. Not a valid ELF object file.");
+        }
+        
+        if ( (ELF_DataEncoding.ELFDATA_2LSB != hdr.e_ident.dataEncoding) &&
+             (ELF_DataEncoding.ELFDATA_2MSB != hdr.e_ident.dataEncoding) )
+        {
+          throw new Exception("Invalid ELF encoding. Not a valid ELF object file.");
+        }
+        
+        if ( (ELF_FileVersion.ELFVER_CURRENT != hdr.e_ident.fileVersion) )
+        {
+          throw new Exception("Invalid ELF file version. Not a valid ELF object file.");
+        }
+                
+        Debug.DebugMSG("ELF Identifier = \n{");
+        Debug.DebugMSG("  magic[0]        : 0x" + hdr.e_ident.magic[0].ToString("X2"));
+        Debug.DebugMSG("  magic[1]        : 0x" + hdr.e_ident.magic[1].ToString("X2"));
+        Debug.DebugMSG("  magic[2]        : 0x" + hdr.e_ident.magic[2].ToString("X2"));
+        Debug.DebugMSG("  magic[3]        : 0x" + hdr.e_ident.magic[3].ToString("X2"));
+        Debug.DebugMSG("  fileClass       : " + hdr.e_ident.fileClass);        
+        Debug.DebugMSG("  dataEncoding    : " + hdr.e_ident.dataEncoding);        
+        Debug.DebugMSG("  fileVersion     : " + hdr.e_ident.fileVersion);
+        Debug.DebugMSG("  OS/ABI ID       : " + hdr.e_ident.osAbiID);
+        Debug.DebugMSG("  ABIVersion      : " + hdr.e_ident.abiVersion);
+        Debug.DebugMSG("}\n\n");
+        
+
+        // Now that we have read and parsed the ELF Identifier array,
+        // we have enough info to get the rest of the header and 
+        // correctly parse entire file            
+        Endian endian = (ELF_DataEncoding.ELFDATA_2LSB == hdr.e_ident.dataEncoding) ? Endian.LittleEndian : Endian.BigEndian;
+        EndianBinaryReader ebr = new EndianBinaryReader(fs,endian);
+
+        hdr.e_type          = (ELF_Type)    ebr.ReadUInt16();
+        hdr.e_machine       = (ELF_Machine) ebr.ReadUInt16();
+        hdr.e_version       = (ELF_Version) ebr.ReadUInt32();
+        
+        Debug.DebugMSG(   "ELF Type                               : " + hdr.e_type);        
+        Debug.DebugMSG(   "ELF Machine                            : " + hdr.e_machine);        
+        Debug.DebugMSG(   "ELF Version                            : " + hdr.e_version);
+        
+        // FIXME: Do we need this check? Is it a good idea?
+        if (ELF_Type.ELFTYPE_EXEC != hdr.e_type)
+        {
+          throw new Exception("ELF file type is wrong - not a valid ELF executable.");
+        }
+        
+        // Read entry point and program header and section header offsets
+        // The size of these values is class dependent (32- or 64-bit)
+        if (ELF_FileClass.ELFCLASS_32 == hdr.e_ident.fileClass)
+        {
+          hdr.e_entry       = (UInt64) ebr.ReadUInt32();
+          hdr.e_phoff       = (UInt64) ebr.ReadUInt32();
+          hdr.e_shoff       = (UInt64) ebr.ReadUInt32();
+          
+          Debug.DebugMSG( "ELF Entry Point                        : 0x" + hdr.e_entry.ToString("X8"));
+          Debug.DebugMSG( "ELF Program Header Offset              : 0x" + hdr.e_phoff.ToString("X8"));        
+          Debug.DebugMSG( "ELF Section Header Table Offset        : 0x" + hdr.e_shoff.ToString("X8"));
+        }
+        else
+        {
+          hdr.e_entry       = ebr.ReadUInt64();    
+          hdr.e_phoff       = ebr.ReadUInt64();
+          hdr.e_shoff       = ebr.ReadUInt64();
+          
+          Debug.DebugMSG( "ELF Entry Point                        : 0x" + hdr.e_entry.ToString("X16"));
+          Debug.DebugMSG( "ELF Program Header Offset              : 0x" + hdr.e_phoff.ToString("X16"));        
+          Debug.DebugMSG( "ELF Section Header Table Offset        : 0x" + hdr.e_shoff.ToString("X16"));
+        }
+        
+        hdr.e_flags         = ebr.ReadUInt32();
+        hdr.e_ehsize        = ebr.ReadUInt16();
+        hdr.e_phentsize     = ebr.ReadUInt16();
+        hdr.e_phnum         = ebr.ReadUInt16();
+        hdr.e_shentsize     = ebr.ReadUInt16();
+        hdr.e_shnum         = ebr.ReadUInt16();
+        hdr.e_shstrndx      = ebr.ReadUInt16();
+        
+        
+        Debug.DebugMSG(   "ELF Header Flags                       : 0x" + hdr.e_flags.ToString("X8"));
+        Debug.DebugMSG(   "ELF Header Size In Bytes               : " + hdr.e_ehsize);
+        Debug.DebugMSG(   "ELF Program Header Entry Size          : " + hdr.e_phentsize);
+        Debug.DebugMSG(   "ELF Program Header Entry Count         : " + hdr.e_phnum);
+        Debug.DebugMSG(   "ELF Section Header Table Entry Size    : " + hdr.e_shentsize);
+        Debug.DebugMSG(   "ELF Section Header Table Entry Count   : " + hdr.e_shnum);
+        Debug.DebugMSG(   "ELF Section Header String Table Index  : " + hdr.e_shstrndx);
+        
+        // Check for presence of program header
+        if ( (hdr.e_phoff == 0) || ((hdr.e_phnum * hdr.e_phentsize) == 0) )
+        {
+          throw new Exception("No ELF program header. Not a valid ELF executable.");
+        }
+      }
+      
+      return hdr;
+    }
+    #endregion
+  } //End ElfFile class
+
+} //end of namespace
diff --git a/tools/omapl13x_boot_utils/Common/UtilLib/EmbeddedFileIO.cs b/tools/omapl13x_boot_utils/Common/UtilLib/EmbeddedFileIO.cs
new file mode 100644 (file)
index 0000000..1fc8048
--- /dev/null
@@ -0,0 +1,163 @@
+/*
+ * EmbeddedFileIO.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+using System;
+using System.IO;
+using System.Reflection;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TI.UtilLib.IO
+{
+  public class EmbeddedFileIO
+  {
+    private static List<String> resources = new List<String>(10);
+    private static List<String> files = new List<String>(10);
+
+    public static void ExtractFile(Assembly thisAssm, String fileName, Boolean overWrite)
+    {
+      Stream dataStream;
+      String myResourceName = "";
+
+      dataStream = GetEmbeddedStream(thisAssm, fileName);
+
+      if ((File.Exists(fileName)) && overWrite)
+      {
+        // If the file is already there and we are supposed to overwrite,
+        // but there is no embedded version, do nothing
+        if (dataStream == null)
+        {
+          return;
+        }
+        // If the file is already there and we are supposed to overwrite,
+        // but we already extracted it from here, do nothing
+        else if (resources.Contains(myResourceName))
+          return;
+      }
+      else if (!File.Exists(fileName))
+      {
+        if (dataStream == null)
+          throw new FileNotFoundException("File " + fileName + " was not found in the assembly or in the current directory.");
+      }
+      else
+      {
+        return;
+      }
+
+      FileStream newFile = File.Open(fileName, FileMode.Create, FileAccess.Write);
+      Byte[] buffer = new Byte[dataStream.Length];
+      dataStream.Seek(0, SeekOrigin.Begin);
+      dataStream.Read(buffer, 0, (int)dataStream.Length);
+      newFile.Write(buffer, 0, (int)buffer.Length);
+      newFile.Close();
+      files.Add(fileName);
+      resources.Add(myResourceName);
+    }
+    
+    public static Byte[] ExtractFileBytes(Assembly thisAssm, String fileName)
+    {
+      Stream dataStream = GetEmbeddedStream(thisAssm, fileName);
+      Byte[] buffer;
+      
+      if (dataStream == null)
+      {
+        throw new FileNotFoundException("File " + fileName + " was not found in the assembly or in the current directory.");
+      }
+      
+      buffer = new Byte[dataStream.Length];
+      
+      // Read data to byte array
+      dataStream.Seek(0, SeekOrigin.Begin);
+      dataStream.Read(buffer, 0, (int)dataStream.Length);
+      
+      return buffer;
+    }
+
+    public static void CleanUpEmbeddedFiles()
+    {
+      foreach (String s in files)
+      {
+        if (File.Exists(s))
+        {
+          try 
+          {
+            File.Delete(s);
+          }
+          catch (Exception e)
+          {
+            Console.WriteLine(e.Message);
+          }
+        }
+      }
+      files.Clear();
+    }
+
+    private static Stream GetEmbeddedStream(Assembly thisAssm, String fileName)
+    {
+      Stream myStream = null;
+      String myResourceName = "";
+
+      foreach (String s in thisAssm.GetManifestResourceNames())
+      {
+        if (s.Contains(fileName))
+        {
+          myResourceName = s;
+          break;
+        }
+      }
+      if (myResourceName.Equals(""))
+        return null;
+
+      try
+      {
+        myStream = thisAssm.GetManifestResourceStream(myResourceName);
+      }
+      catch (Exception e)
+      {
+        if (e is FileNotFoundException)
+          return null;
+        else
+          throw e;
+      }
+
+      return myStream;
+    }
+
+    
+  }
+}
diff --git a/tools/omapl13x_boot_utils/Common/UtilLib/Endian.cs b/tools/omapl13x_boot_utils/Common/UtilLib/Endian.cs
new file mode 100644 (file)
index 0000000..5a18565
--- /dev/null
@@ -0,0 +1,472 @@
+/*
+ * Endian.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+using System;
+using System.Text;
+using System.IO;
+using System.IO.Ports;
+using System.Reflection;
+using System.Threading;
+using System.Globalization;
+using System.Collections;
+
+namespace TI.UtilLib.IO
+{
+
+    /// <summary>
+    /// Public class to express big and Little endianness.
+    /// Only creatable via BigEndian and LittleEndian public property.
+    /// </summary>
+    public class Endian
+    {
+        #region Private members and methods
+        // Private internal members and constants
+        private UInt32 endianness;
+        private const UInt32 Big = 0x0;
+        private const UInt32 Little = 0x1;
+
+        /// <summary>
+        /// Private hidden constructor
+        /// </summary>
+        private Endian()
+        {
+        }
+
+        /// <summary>
+        /// Private hidden constructor - called from public properties
+        /// </summary>
+        /// <param name="endian">UInt32 indicating endianness - provided from private constants</param>
+        private Endian(UInt32 endian)
+        {
+            endianness = endian;
+        }
+        #endregion
+
+        #region Public properties and methods
+        /// <summary>
+        /// Public static property that returns an Endian object of Big type
+        /// </summary>
+        public static Endian BigEndian
+        {
+            get
+            {
+                return new Endian(Big);
+            }
+        }
+
+        /// <summary>
+        /// Public static property that returns an Endian object of the Little type
+        /// </summary>
+        public static Endian LittleEndian
+        {
+            get
+            {
+                return new Endian(Little);
+            }
+        }
+
+        /// <summary>
+        /// Public static function to reverse endianness of the byte array
+        /// </summary>
+        /// <param name="bytes">Input byte array</param>
+        /// <returns></returns>
+        public static byte[] swapEndian(byte[] bytes)
+        {
+            Int32 length = bytes.Length;
+            Int32 halfLen = bytes.Length / 2;
+            Byte temp;
+            for (int i = 0; i < halfLen; i++)
+            {
+                temp = bytes[length - i - 1];
+                bytes[length - i - 1] = bytes[i];
+                bytes[i] = temp;
+            }
+            return bytes;
+        }
+
+        /// <summary>
+        /// Check if this object is LittleEndian
+        /// </summary>
+        /// <returns>Boolean True if object is little endian</returns>
+        public Boolean isLittleEndian()
+        {
+            return (endianness == Little);
+        }
+
+        /// <summary>
+        /// Check if this object if BigEndian
+        /// </summary>
+        /// <returns>Boolean True if oject if big endian</returns>
+        public Boolean isBigEndian()
+        {
+            return (endianness == Big);
+        }
+
+        public new string ToString()
+        {
+            if (endianness == Big)
+                return "big";
+            else
+                return "little";
+        }
+
+        #endregion
+        
+        # region Public operator overloading
+        
+        public static Boolean operator== (Endian endian1, Endian endian2)
+        {
+          return endian1.Equals(endian2);
+        }
+        
+        public static Boolean operator!= (Endian endian1, Endian endian2)
+        {
+          return !endian1.Equals(endian2);
+        }
+        
+        // Override of Equals from object class
+        public override bool Equals( object endian )
+        {
+          if (endian is Endian)
+          {
+            return Equals( (Endian) endian );
+          }
+          else 
+          {
+            return false;
+          }
+        }
+        
+        // Equals operator for this class
+        public bool Equals (Endian endian)
+        {
+          return (bool)( this.endianness == endian.endianness);
+        }
+        
+        // Must override this if overriding Equals from object class
+        public override int GetHashCode()
+        {
+          return (int) this.endianness;
+        }
+        
+        #endregion
+
+    }
+
+    /// <summary>
+    /// Wrapper class to add endianness to the BinaryReader class
+    /// </summary>
+    public class EndianBinaryReader : BinaryReader
+    {
+        private Endian myEndian;
+
+        public Endian endianness
+        {
+            get { return myEndian; }
+        }
+
+        /// <summary>
+        /// Public EndianBinaryReader constructor
+        /// </summary>
+        /// <param name="str">Stream</param>
+        /// <param name="endian">Endian object</param>
+        public EndianBinaryReader(Stream str, Endian endian)
+            : base(str)
+        {
+            myEndian = endian;
+        }
+
+        /// <summary>
+        /// Public EndianBinaryReader constructor
+        /// </summary>
+        /// <param name="str">Base Stream object</param>
+        /// <param name="enc">Encoding object</param>
+        /// <param name="endian">Endian object</param>
+        public EndianBinaryReader(Stream str, Encoding enc, Endian endian)
+            : base(str, enc)
+        {
+            myEndian = endian;
+        }
+
+        public new short ReadInt16()
+        {
+            if (myEndian.isBigEndian())
+            {
+                return BitConverter.ToInt16(Endian.swapEndian(BitConverter.GetBytes(base.ReadInt16())), 0);
+            }
+            else
+            {
+                return base.ReadInt16();
+            }
+        }
+
+        public new int ReadInt32()
+        {
+            if (myEndian.isBigEndian())
+            {
+                return BitConverter.ToInt32(Endian.swapEndian(BitConverter.GetBytes(base.ReadInt32())), 0);
+            }
+            else
+            {
+                return base.ReadInt32();
+            }
+        }
+
+        public new long ReadInt64()
+        {
+            if (myEndian.isBigEndian())
+            {
+                return BitConverter.ToInt64(Endian.swapEndian(BitConverter.GetBytes(base.ReadInt64())), 0);
+            }
+            else
+            {
+                return base.ReadInt64();
+            }
+        }
+
+        public new ushort ReadUInt16()
+        {
+            if (myEndian.isBigEndian())
+            {
+                return BitConverter.ToUInt16(Endian.swapEndian(BitConverter.GetBytes(base.ReadUInt16())), 0);
+            }
+            else
+            {
+                return base.ReadUInt16();
+            }
+        }
+
+        public new uint ReadUInt32()
+        {
+            if (myEndian.isBigEndian())
+            {
+                return BitConverter.ToUInt32(Endian.swapEndian(BitConverter.GetBytes(base.ReadUInt32())), 0);
+            }
+            else
+            {
+                return base.ReadUInt32();
+            }
+        }
+
+        public new ulong ReadUInt64()
+        {
+            if (myEndian.isBigEndian())
+            {
+                return BitConverter.ToUInt64(Endian.swapEndian(BitConverter.GetBytes(base.ReadUInt64())), 0);
+            }
+            else
+            {
+                return base.ReadUInt64();
+            }
+        }
+    }
+
+    /// <summary>
+    /// Wrapper class to add endianness to the BinaryWriter class
+    /// </summary>
+    public class EndianBinaryWriter : BinaryWriter
+    {
+        private Endian myEndian;
+
+        public Endian endianness
+        {
+            get { return myEndian; }
+        }
+
+        /// <summary>
+        /// Public EndianBinaryWriter constructor
+        /// </summary>
+        /// <param name="str">Stream</param>
+        /// <param name="endian">Endian object</param>
+        public EndianBinaryWriter(Stream str, Endian endian)
+            : base(str)
+        {
+            myEndian = endian;
+        }
+
+        /// <summary>
+        /// Public EndianBinaryWriter constructor
+        /// </summary>
+        /// <param name="str">Base Stream object</param>
+        /// <param name="enc">Encoding object</param>
+        /// <param name="endian">Endian object</param>
+        public EndianBinaryWriter(Stream str, Encoding enc, Endian endian)
+            : base(str, enc)
+        {
+            myEndian = endian;
+        }
+
+        public new void Write(short value)
+        {
+            if (myEndian.isBigEndian())
+            {
+                base.Write(BitConverter.ToInt16(Endian.swapEndian(BitConverter.GetBytes(value)), 0));
+            }
+            else
+            {
+                base.Write(value);
+            }
+        }
+        
+        public void Write(short[] value)
+        {
+          if (value != null)
+          {
+            foreach(short val in value)
+            {
+              this.Write(val);
+            }
+          }
+        }
+
+        public new void Write(int value)
+        {
+          if (myEndian.isBigEndian())
+          {
+            base.Write(BitConverter.ToInt32(Endian.swapEndian(BitConverter.GetBytes(value)), 0));
+          }
+          else
+          {
+            base.Write(value);
+          }
+        }
+        
+        public void Write(int[] value)
+        {
+          if (value != null)
+          {
+            foreach(int val in value)
+            {
+              this.Write(val);
+            }
+          }
+        }
+
+        public new void Write(long value)
+        {
+          if (myEndian.isBigEndian())
+          {
+            base.Write(BitConverter.ToInt64(Endian.swapEndian(BitConverter.GetBytes(value)), 0));
+          }
+          else
+          {
+            base.Write(value);
+          }
+        }
+        
+        public void Write(long[] value)
+        {
+          if (value != null)
+          {
+            foreach(long val in value)
+            {
+              this.Write(val);
+            }
+          }
+        }
+
+        public new void Write(ushort value)
+        {
+          if (myEndian.isBigEndian())
+          {
+            base.Write(BitConverter.ToUInt16(Endian.swapEndian(BitConverter.GetBytes(value)), 0));
+          }
+          else
+          {
+            base.Write(value);
+          }
+        }
+        
+        public void Write(ushort[] value)
+        {
+          if (value != null)
+          {
+            foreach(ushort val in value)
+            {
+              this.Write(val);
+            }
+          }
+        }
+
+        public new void Write(uint value)
+        {
+          if (myEndian.isBigEndian())
+          {
+            base.Write(BitConverter.ToUInt32(Endian.swapEndian(BitConverter.GetBytes(value)), 0));
+          }
+          else
+          {
+            base.Write(value);
+          }
+        }
+        
+        public void Write(uint[] value)
+        {
+          if (value != null)
+          {
+            foreach(uint val in value)
+            {
+              this.Write(val);
+            }
+          }
+        }
+
+        public new void Write(ulong value)
+        {
+          if (myEndian.isBigEndian())
+          {
+            base.Write(BitConverter.ToUInt64(Endian.swapEndian(BitConverter.GetBytes(value)), 0));
+          }
+          else
+          {
+            base.Write(value);
+          }
+        }
+        
+        public void Write(ulong[] value)
+        {
+          if (value != null)
+          {
+            foreach(ulong val in value)
+            {
+              this.Write(val);
+            }
+          }
+        }
+    }
+}
\ No newline at end of file
diff --git a/tools/omapl13x_boot_utils/Common/UtilLib/FileIO.cs b/tools/omapl13x_boot_utils/Common/UtilLib/FileIO.cs
new file mode 100644 (file)
index 0000000..2b25b47
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * FileIO.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+using System;
+using System.IO;
+using System.Reflection;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TI.UtilLib.IO
+{
+  public class FileIO
+  {
+    /// <summary>
+    /// Function to find and read a file's data
+    /// </summary>
+    /// <param name="filename">The name of the file to load</param>
+    /// <returns></returns>
+    public static Byte[] GetFileData(String filename)
+    {
+      Byte[] data;
+
+      if (!File.Exists(filename))
+      {
+        throw new FileNotFoundException("File " + filename + " is not present.");
+      }
+
+      // Open file and read data
+      try
+      {
+        data = File.ReadAllBytes(filename);
+      }
+      catch (Exception e)
+      {
+        Console.WriteLine("Error: "+e.Message);
+        throw e;
+      }
+
+      return data;
+    }
+    
+    public static String GetFileText(String filename)
+    {
+      String text;
+
+      if (!File.Exists(filename))
+      {
+        throw new FileNotFoundException("File " + filename + " is not present.");
+      }
+
+      // Open file and read data
+      try
+      {
+        text = File.ReadAllText(filename);
+      }
+      catch (Exception e)
+      {
+        Console.WriteLine("Error: "+e.Message);
+        throw e;
+      }
+
+      return text;
+    }
+
+    public static void SetFileData(String filename, Byte[] data, Boolean overwrite)
+    {
+      // Open file and read data
+      try
+      {
+        if (!File.Exists(filename))
+        {
+          using (FileStream fs = File.Create(filename)){}
+        }
+        else if (overwrite)
+        {
+          using (FileStream fs = File.Create(filename)){}
+        }
+        
+        File.WriteAllBytes(filename,data);
+      }
+      catch (Exception e)
+      {
+        Console.WriteLine("Error: "+e.Message);
+        throw e;
+      }
+    }
+    
+    public static void SetFileText(String filename, String data, Boolean overwrite)
+    {
+      // Open file and read data
+      try
+      {
+        if (!File.Exists(filename))
+        {
+          using (FileStream fs = File.Create(filename)){}
+        }
+        else if (overwrite)
+        {
+          using (FileStream fs = File.Create(filename)){}
+        }
+
+        File.WriteAllText(filename,data);
+      }
+      catch (Exception e)
+      {
+        Console.WriteLine("Error: "+e.Message);
+        throw e;
+      }
+    }
+    
+
+  }
+}
diff --git a/tools/omapl13x_boot_utils/Common/UtilLib/HexConv.cs b/tools/omapl13x_boot_utils/Common/UtilLib/HexConv.cs
new file mode 100644 (file)
index 0000000..5c0d002
--- /dev/null
@@ -0,0 +1,459 @@
+/*
+ * HexConv.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+using System;
+using System.Text;
+using System.IO;
+using System.IO.Ports;
+using System.Reflection;
+using System.Threading;
+using System.Globalization;
+
+namespace TI.UtilLib.HexConv
+{
+  class SRecord
+  {
+      /// <summary>
+      /// Function to convert the input filestream into an byte array in S-record format.
+      /// </summary>
+      /// <param name="inputFileStream">The input filestream that encapsulates the
+      /// input binary file.</param>
+      /// <param name="startAddr">The starting address of the RAM location where the binary data
+      /// encapsulated by the S-record will be stored.</param>
+      /// <returns>A byte array of the file data.</returns>
+      public static Byte[] bin2srec(Stream inputStream, UInt32 startAddr)
+      {
+          Int64 totalLen;
+          BinaryReader fileBR = new BinaryReader(inputStream);
+          StringBuilder fileSB;
+          String fileName;
+          String shortFileName;
+          Byte[] currChar = new Byte[1];
+          Byte[] currDataRecord;
+          Int32 i, checksum8 = 0;
+          Int32 recordSize = 16;
+          UInt32 memAddr = startAddr;
+
+          // Set the actual length
+          totalLen = fileBR.BaseStream.Length;
+          fileSB = new StringBuilder(4 * (int)totalLen);
+
+          // Set S-record filename (real name or fake)
+          if (inputStream is FileStream)
+              fileName = ((FileStream)inputStream).Name;
+          else
+              fileName = "ublDaVinci.bin";
+
+          // Make sure we are at the right place in the stream
+          fileBR.BaseStream.Seek(0x0, SeekOrigin.Begin);
+
+          // Get filename (this is S-record module name)
+          if (Path.HasExtension(fileName))
+              shortFileName = Path.GetFileNameWithoutExtension(fileName) + ".hex";
+          else
+              shortFileName = Path.GetFileName(fileName) + ".hex";
+
+          // Make sure S-record module name fits in 20 byte field
+          if (shortFileName.Length > 20)
+              shortFileName = shortFileName.Substring(0, 20);
+
+          // Create first s-record (S0 record)
+          fileSB.Append("S0");
+          // Write length field
+          fileSB.AppendFormat("{0:X2}", shortFileName.Length + 3);
+          checksum8 += (Byte)(shortFileName.Length + 3);
+          // Write address field
+          fileSB.Append("0000");
+          // Write name field
+          for (i = 0; i < shortFileName.Length; i++)
+          {
+              currChar = (new ASCIIEncoding()).GetBytes(shortFileName.Substring(i, 1));
+              checksum8 += currChar[0];
+              fileSB.AppendFormat("{0:X2}", currChar[0]);
+          }
+          // Write Checksum field
+          fileSB.AppendFormat("{0:X2}\x0A", ((checksum8 & 0xFF) ^ 0xFF));
+
+          // Write collection of S3 records (actual binary data)
+          i = (Int32)totalLen;
+
+          while (i >= recordSize)
+          {
+              checksum8 = 0;
+              // Write S3 record label
+              fileSB.Append("S3");
+              // Write length field (4 address bytes + 16 data bytes + 1 checksum byte)
+              fileSB.AppendFormat("{0:X2}", recordSize + 5);
+              checksum8 += (recordSize + 5);
+
+              // Write address field and update it
+              fileSB.AppendFormat("{0:X8}", memAddr);
+              currDataRecord = System.BitConverter.GetBytes(memAddr);
+              for (int j = 0; j < 4; j++)
+              {
+                  checksum8 += currDataRecord[j];
+              }
+
+              // Write out the bytes of data
+              currDataRecord = fileBR.ReadBytes(recordSize);
+              for (int j = 0; j < recordSize; j++)
+              {
+                  fileSB.AppendFormat("{0:X2}", currDataRecord[j]);
+                  checksum8 += currDataRecord[j];
+              }
+              //Write out checksum and linefeed character
+              fileSB.AppendFormat("{0:X2}\x0A", ((checksum8 & 0xFF) ^ 0xFF));
+
+              memAddr += (UInt32)recordSize; i -= recordSize;
+          }
+
+          // Finish out the record if anything is left over
+          if (i > 0)
+          {
+              checksum8 = 0;
+              // Write S3 record label
+              fileSB.Append("S3");
+              // Write length field (4 address bytes + 16 data bytes + 1 checksum byte)
+              fileSB.AppendFormat("{0:X2}", i + 5);
+              checksum8 += (i + 5);
+
+              // Write address field and update it
+              fileSB.AppendFormat("{0:X8}", memAddr);
+              currDataRecord = System.BitConverter.GetBytes(memAddr);
+              for (int j = 0; j < 4; j++)
+              {
+                  checksum8 += currDataRecord[j];
+              }
+
+              // Write out the bytes of data
+              currDataRecord = fileBR.ReadBytes(i);
+              for (int j = 0; j < i; j++)
+              {
+                  fileSB.AppendFormat("{0:X2}", currDataRecord[j]);
+                  checksum8 += currDataRecord[j];
+              }
+              //Write out checksum and linefeed character
+              fileSB.AppendFormat("{0:X2}\x0A", ((checksum8 & 0xFF) ^ 0xFF));
+
+              memAddr += (UInt32)i; i = 0;
+
+          }
+
+          // Write out the final record (S7 record)
+          checksum8 = 0;
+          // Write S7 record label
+          fileSB.Append("S7");
+          // Write length field (4 address bytes + 1 checksum byte)
+          fileSB.AppendFormat("{0:X2}", 5);
+          checksum8 += 5;
+
+          // Write execution start address field and update it
+          fileSB.AppendFormat("{0:X8}", startAddr);
+          currDataRecord = System.BitConverter.GetBytes(startAddr);
+          for (int j = 0; j < 4; j++)
+          {
+              checksum8 += currDataRecord[j];
+          }
+          //Write out checksum and linefeed character
+          fileSB.AppendFormat("{0:X2}\x0A", ((checksum8 & 0xFF) ^ 0xFF));
+
+          return (new ASCIIEncoding()).GetBytes(fileSB.ToString());
+
+      }
+      
+      /// <summary>
+      /// Function to convert the input binary byte array into an byte array in S-record format.
+      /// </summary>
+      /// <param name="inputFileStream">The input filestream that encapsulates the
+      /// input binary file.</param>
+      /// <param name="startAddr">The starting address of the RAM location where the binary data
+      /// encapsulated by the S-record will be stored.</param>
+      /// <param name="recordSize">The size in bytes of each S-record (line) of the output.</param>
+      /// <returns>A byte array of the file data.</returns>
+      public static Byte[] bin2srec(Byte[] inputData, UInt32 startAddr, Int32 recordSize)
+      {
+          Int64 totalLen;
+          StringBuilder fileSB;
+          String fileName;
+          String shortFileName;
+          Byte[] currChar = new Byte[1];
+          Byte[] currDataRecord;
+          Int32 i, checksum8 = 0;
+          UInt32 memAddr = startAddr;
+
+          // Set the actual length
+          totalLen = inputData.Length;
+          fileSB = new StringBuilder(4 * (int)totalLen);
+
+          // Set S-record filename (real name or fake)
+          //if (inputStream is FileStream)
+          //    fileName = ((FileStream)inputStream).Name;
+          //else
+              fileName = "ublDaVinci.bin";
+
+          // Make sure we are at the right place in the stream
+          //fileBR.BaseStream.Seek(0x0, SeekOrigin.Begin);
+
+          // Get filename (this is S-record module name)
+          if (Path.HasExtension(fileName))
+              shortFileName = Path.GetFileNameWithoutExtension(fileName) + ".hex";
+          else
+              shortFileName = Path.GetFileName(fileName) + ".hex";
+
+          // Make sure S-record module name fits in 20 byte field
+          if (shortFileName.Length > 20)
+              shortFileName = shortFileName.Substring(0, 20);
+
+          // Create first s-record (S0 record)
+          fileSB.Append("S0");
+          // Write length field
+          fileSB.AppendFormat("{0:X2}", shortFileName.Length + 3);
+          checksum8 += (Byte)(shortFileName.Length + 3);
+          // Write address field
+          fileSB.Append("0000");
+          // Write name field
+          for (i = 0; i < shortFileName.Length; i++)
+          {
+              currChar = (new ASCIIEncoding()).GetBytes(shortFileName.Substring(i, 1));
+              checksum8 += currChar[0];
+              fileSB.AppendFormat("{0:X2}", currChar[0]);
+          }
+          // Write Checksum field
+          fileSB.AppendFormat("{0:X2}\x0A", ((checksum8 & 0xFF) ^ 0xFF));
+
+          // Write collection of S3 records (actual binary data)
+          i = (Int32)totalLen;
+
+          while (i >= recordSize)
+          {
+              checksum8 = 0;
+              // Write S3 record label
+              fileSB.Append("S3");
+              // Write length field (4 address bytes + 16 data bytes + 1 checksum byte)
+              fileSB.AppendFormat("{0:X2}", recordSize + 5);
+              checksum8 += (recordSize + 5);
+
+              // Write address field and update it
+              fileSB.AppendFormat("{0:X8}", memAddr);
+              currDataRecord = System.BitConverter.GetBytes(memAddr);
+              for (int j = 0; j < 4; j++)
+              {
+                  checksum8 += currDataRecord[j];
+              }
+
+              // Write out the bytes of data
+              //currDataRecord = fileBR.ReadBytes(recordSize);
+              
+              for (int j = 0; j < recordSize; j++)
+              {
+                  //fileSB.AppendFormat("{0:X2}", currDataRecord[j]);
+                  fileSB.AppendFormat("{0:X2}", inputData[j + (memAddr - startAddr)]);
+                  //checksum8 += currDataRecord[j];
+                  checksum8 += inputData[j + (memAddr - startAddr)];
+              }
+              //Write out checksum and linefeed character
+              fileSB.AppendFormat("{0:X2}\x0A", ((checksum8 & 0xFF) ^ 0xFF));
+
+              memAddr += (UInt32)recordSize; i -= recordSize;
+          }
+
+          // Finish out the record if anything is left over
+          if (i > 0)
+          {
+              checksum8 = 0;
+              // Write S3 record label
+              fileSB.Append("S3");
+              // Write length field (4 address bytes + 16 data bytes + 1 checksum byte)
+              fileSB.AppendFormat("{0:X2}", i + 5);
+              checksum8 += (i + 5);
+
+              // Write address field and update it
+              fileSB.AppendFormat("{0:X8}", memAddr);
+              currDataRecord = System.BitConverter.GetBytes(memAddr);
+              for (int j = 0; j < 4; j++)
+              {
+                  checksum8 += currDataRecord[j];
+              }
+
+              // Write out the bytes of data
+              //currDataRecord = fileBR.ReadBytes(i);
+              for (int j = 0; j < i; j++)
+              {
+                  //fileSB.AppendFormat("{0:X2}", currDataRecord[j]);
+                  fileSB.AppendFormat("{0:X2}", inputData[j + (memAddr - startAddr)]);
+                  //checksum8 += currDataRecord[j];
+                  checksum8 += inputData[j + (memAddr - startAddr)];
+              }
+              //Write out checksum and linefeed character
+              fileSB.AppendFormat("{0:X2}\x0A", ((checksum8 & 0xFF) ^ 0xFF));
+
+              memAddr += (UInt32)i; i = 0;
+
+          }
+
+          // Write out the final record (S7 record)
+          checksum8 = 0;
+          // Write S7 record label
+          fileSB.Append("S7");
+          // Write length field (4 address bytes + 1 checksum byte)
+          fileSB.AppendFormat("{0:X2}", 5);
+          checksum8 += 5;
+
+          // Write execution start address field and update it
+          fileSB.AppendFormat("{0:X8}", startAddr);
+          currDataRecord = System.BitConverter.GetBytes(startAddr);
+          for (int j = 0; j < 4; j++)
+          {
+              checksum8 += currDataRecord[j];
+          }
+          //Write out checksum and linefeed character
+          fileSB.AppendFormat("{0:X2}\x0A", ((checksum8 & 0xFF) ^ 0xFF));
+
+          return (new ASCIIEncoding()).GetBytes(fileSB.ToString());
+      }
+
+  }
+
+  class CArray
+  {
+    public static Byte[] bin2CArray(Byte[] inputData, UInt32 memberSizeInBytes)
+    {
+      return CArray.bin2CArray("data_array", inputData, memberSizeInBytes);
+    }
+    
+    public static Byte[] bin2CArray(String arrayName, Byte[] inputData, UInt32 memberSizeInBytes)
+    {
+      StringBuilder cArraySB;
+      UInt32 sizeSB = (((UInt32)inputData.Length)/memberSizeInBytes +1) * (memberSizeInBytes*2 + 4) + 30;
+    
+      cArraySB = new StringBuilder((Int32)sizeSB);
+      
+      switch(memberSizeInBytes)
+      {
+        case 1:
+          bin2charArray(arrayName,inputData,cArraySB);
+          break;
+        case 2:
+          bin2ushortArray(arrayName,inputData,cArraySB);
+          break;
+        case 4:
+          bin2uintArray(arrayName,inputData,cArraySB);
+          break;
+        case 8:
+          break;
+        default:
+          throw new ArgumentException("Must be 1, 2, 4, or 8","memberSizeInBytes");
+      } 
+    
+      return (new ASCIIEncoding()).GetBytes(cArraySB.ToString());    
+    }
+    
+    private static void bin2charArray(String arrayName, Byte[] inputData, StringBuilder sb)
+    {
+      sb.Append("const unsigned char "+ arrayName + "[] = {");
+      
+      // Output data in hex format
+      for (int i = 0; i<inputData.Length; i++)
+      {
+        sb.AppendFormat("\n0x{0:X2},",inputData[i]);
+      }
+  
+      // Delete comma from last one 
+      sb.Remove(sb.Length - 1, 1);
+      sb.Append("\n};\n");
+    }
+    
+    private static void bin2ushortArray(String arrayName, Byte[] inputData, StringBuilder sb)
+    {
+      sb.Append("const unsigned short "+ arrayName + "[] = {");
+      
+      // Output data in hex format
+      for (int i = 0; i<inputData.Length/2; i++)
+      {
+        UInt32 data = System.BitConverter.ToUInt32(inputData, i*2);
+        sb.AppendFormat("\n0x{0:X4},",data);
+      }
+      
+      if ((inputData.Length % 2) != 0)
+      {
+        Byte[] temp = new Byte[] {0x00,0x00};
+        System.Array.Copy(inputData,inputData.Length - (inputData.Length % 2), temp, 0, (inputData.Length % 2));
+        sb.AppendFormat("\n0x{0:X4}",System.BitConverter.ToUInt32(temp,0));
+      }
+      else
+      {
+        // delete comma from last one 
+        sb.Remove(sb.Length - 1, 1);
+      }
+      sb.Append("\n};\n");
+    }
+    
+    private static void bin2uintArray(String arrayName, Byte[] inputData, StringBuilder sb)
+    {
+      sb.Append("const unsigned int "+ arrayName + "[] = {");
+      
+      // Output data in hex format
+      for (int i = 0; i<inputData.Length/4; i++)
+      {
+        UInt32 data = System.BitConverter.ToUInt32(inputData, i*4);
+        sb.AppendFormat("\n0x{0:X8},",data);
+      }
+      
+      if ((inputData.Length % 4) != 0)
+      {
+        Byte[] temp = new Byte[] {0x00,0x00,0x00,0x00};
+        System.Array.Copy(inputData,inputData.Length - (inputData.Length % 4), temp, 0, (inputData.Length % 4));
+        sb.AppendFormat("\n0x{0:X8}",System.BitConverter.ToUInt32(temp,0));
+      }
+      else
+      {
+        // delete comma from last one 
+        sb.Remove(sb.Length - 1, 1);
+      }
+      sb.Append("\n};\n");
+    }
+  }
+
+  /*  
+  class Text
+  {
+  
+  }
+  */
+
+}
diff --git a/tools/omapl13x_boot_utils/Common/UtilLib/Ini.cs b/tools/omapl13x_boot_utils/Common/UtilLib/Ini.cs
new file mode 100644 (file)
index 0000000..653d62e
--- /dev/null
@@ -0,0 +1,467 @@
+/*
+ * Ini.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+using System;
+using System.IO;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Collections;
+using System.Collections.Generic;
+using System.Globalization;
+
+namespace TI.UtilLib.Ini
+{
+
+  /**
+   * This struct defines a section of an INI file/stream
+   */
+  public class IniSection
+  {
+    /**
+     * INI Section Name
+     */
+    public String sectionName;
+    
+    /**
+     * HashTable of the section values
+     */
+    public Hashtable sectionValues;
+    
+    /**
+     * Default Constructor
+     */
+    public IniSection()
+    {
+      sectionName = null;
+      sectionValues = new Hashtable();
+    }
+    
+    public IniSection(String name)
+    {
+      sectionName = name;
+      sectionValues = new Hashtable();
+    }
+    
+    public IniSection(String name, Hashtable values)
+    {
+      sectionName = name;
+      sectionValues = values;
+    }
+    
+    public Object GetValue(String valueName)
+    {
+      return sectionValues[valueName.ToUpper()];
+    }
+    
+    public void InsertValue(String valueName, String value)
+    {
+      if (sectionValues == null)
+      {
+        sectionValues = new Hashtable();
+      }
+      TryInsertValue(this, valueName, value);
+    }
+    
+    public override String ToString()
+    {
+      return IniSection.ToString(this);
+    }
+    
+    /**
+     * Static function to insert key/value pair into specified IniSection
+     */
+    public static Boolean TryInsertValue(IniSection section, String valueName, String value)
+    {
+      if ((section == null) || (section.sectionValues == null))
+      {
+        return false;
+      }
+      else
+      {
+        UInt32 valueNum;
+        valueName = valueName.ToUpper();
+        
+        // Hex values must be prefixed by "0x"
+        value = value.ToLower();
+        if (value.StartsWith("0x"))
+        {
+          if (!UInt32.TryParse(value.Replace("0x", ""), NumberStyles.HexNumber, null, out valueNum) )
+          {
+            return false;
+          }
+          else
+          {
+            section.sectionValues[valueName] = valueNum;
+          }
+        }
+        else if (UInt32.TryParse(value, out valueNum))
+        {
+          section.sectionValues[valueName] = valueNum;
+        }
+        else
+        {
+          section.sectionValues[valueName] = value;
+        }
+      }
+      return true;
+    }
+    
+    public static String ToString(IniSection section)
+    {
+      StringWriter sw = new StringWriter(new StringBuilder());
+      sw.WriteLine("[{0}]",section.sectionName);
+        
+      foreach (DictionaryEntry de in section.sectionValues)
+      {
+        sw.WriteLine("{0} = {1}",de.Key,de.Value);
+      }
+      return sw.GetStringBuilder().ToString();
+    }
+  }
+  
+  public class IniFile
+  {
+    private List<IniSection> sections;
+    private String fileName;
+    
+    public IniFile()
+    {
+      fileName = null;
+      sections = null;
+    }
+    
+    public List<IniSection> Sections
+    {
+      get { return sections; }
+    }
+  
+    public IniFile(String fileName)
+    {
+      try
+      {
+        this.sections = (IniFile.Parse(fileName)).sections;
+      }
+      catch (Exception e)
+      {
+        //Fixme
+        Console.WriteLine(e.Message);
+        throw new ArgumentException();
+      }
+        
+      this.fileName = fileName;
+    }
+    
+    public IniFile(Stream fileStream, String fileName)
+    {
+      try
+      {
+        this.sections = (IniFile.Parse(fileStream)).sections;
+      }
+      catch (Exception e)
+      {
+        //Fixme
+        Console.WriteLine(e.Message);
+        throw new ArgumentException();
+      }
+      this.fileName = fileName;
+    }
+    
+    public IniFile(String iniString, String fileName)
+    {
+      try
+      {
+        this.sections = (IniFile.Parse(iniString)).sections;
+      }
+      catch (Exception e)
+      {
+        //Fixme
+        Console.WriteLine(e.Message);
+        throw new ArgumentException();
+      }
+      this.fileName = fileName;
+    }
+    
+    public IniFile(Byte[] iniFileData, String fileName)
+    {
+      try
+      {
+        this.sections = (IniFile.Parse(iniFileData)).sections;
+      }
+      catch (Exception e)
+      {
+        //Fixme
+        Console.WriteLine(e.Message);
+        throw new ArgumentException();
+      }
+      this.fileName = fileName;
+    }
+    
+    public IniFile(List<IniSection> sections, String fileName)
+    {
+      this.sections = sections;
+      this.fileName = fileName;
+    }
+    
+    public IniSection GetSectionByName(String name)
+    {
+      foreach (IniSection sec in sections)
+      {
+        if (sec.sectionName.Equals(name, StringComparison.OrdinalIgnoreCase))
+        {
+          return sec;
+        }
+      }
+      return null;
+    }
+    
+    public Object GetValueByName(String sectionName, String valueName)
+    {
+      IniSection section = GetSectionByName(sectionName);
+      if (section != null)
+      {
+        return section.GetValue(valueName);
+      }
+      else
+      {
+        return null;
+      }
+    }
+    
+    public void InsertSection(String sectionName)
+    {
+      InsertSection(new IniSection(sectionName));
+    }
+    
+    public void InsertSection(IniSection section)
+    {
+      IniSection sec = GetSectionByName(section.sectionName);
+      if (sec == null)
+      {
+        // Section by this name does not exist
+        sections.Add(sec);
+      }
+      else 
+      {
+        // Section by this name exists, simply insert values
+        foreach (DictionaryEntry de in section.sectionValues)
+        {
+          sec.InsertValue((String)de.Key, (String)de.Value);
+        }
+      }
+    }
+    
+    public void InsertValue(String sectionName, String valueName, String value)
+    {
+      IniSection sec = GetSectionByName(sectionName);
+      if (sec == null)
+      {
+        // Section doesn't yet exist, so insert it
+        InsertSection(sectionName);
+      }
+      sec = GetSectionByName(sectionName);
+      sec.InsertValue(valueName, value);
+    }
+    
+    /**
+     * Function to Parse an input data stream containing INI data
+     *
+     * @param iniStream is an input Stream object
+     */
+    public static IniFile Parse(Stream iniStream)
+    {
+      IniFile myFile = new IniFile();
+      List<String> streamLines = new List<String>();
+      List<IniSection> streamSections = new List<IniSection>();
+      StreamReader iniSR;
+      
+      IniSection currSec = new IniSection();
+      Boolean inASection = false;
+      Regex iniSecHdr = new Regex("\\[[A-Za-z0-9_]*\\]");
+
+      try
+      {
+        iniSR = new StreamReader(iniStream);
+      }
+      catch (Exception e)
+      {
+        Console.WriteLine(e.Message);
+        throw e;
+      }
+     
+      // Get lines of data from the stream
+      while (!iniSR.EndOfStream)
+      {
+        streamLines.Add(iniSR.ReadLine());
+      }
+
+      // Parse actually line contents
+      for (int i=0; i<streamLines.Count; i++)
+      {
+        // Get current line from the streamLines List
+        String currLine = (streamLines[i]).Trim();
+        
+        // Ignore comment and empty lines
+        if ( (currLine.StartsWith(";")) || (currLine.Equals("")) )
+        {
+          continue;
+        }                                  
+          
+        // If we find a section header, begin a new section
+        Match m = iniSecHdr.Match(currLine);
+        if (m.Success)
+        {
+          if (inASection)
+          {
+            streamSections.Add(currSec);
+          }
+          inASection = true;
+          currSec = new IniSection();
+          currSec.sectionName = m.Value.ToUpper().Trim('[', ']');
+          currSec.sectionValues = new Hashtable();
+          Debug.DebugMSG("INI Section: {0}", currSec.sectionName);
+          continue;
+        }
+
+        // If we find key/value paramter pairs, parse the value and key
+        if (currLine.Contains("="))
+        {
+          // Split the name at the '=' sign
+          String[] paramAndValue = currLine.Split(new char[1] { '=' }, StringSplitOptions.RemoveEmptyEntries);
+
+          // Trim the param name and value
+          paramAndValue[0] = paramAndValue[0].Trim().ToUpper();
+          paramAndValue[1] = paramAndValue[1].Trim();
+
+          // Hex values must be prefixed by "0x"
+          if (paramAndValue[1].StartsWith("0x") || paramAndValue[1].StartsWith("0X"))
+          {
+            currSec.sectionValues[paramAndValue[0]]
+              = UInt32.Parse(paramAndValue[1].Replace("0x", ""), NumberStyles.AllowHexSpecifier);
+          }
+          else
+          {
+            UInt32 value;
+            if (UInt32.TryParse(paramAndValue[1], out value))
+            {
+              currSec.sectionValues[paramAndValue[0]] = value;
+            }
+            else
+            {
+              currSec.sectionValues[paramAndValue[0]] = paramAndValue[1];
+            }
+          }
+          Debug.DebugMSG("\t{0} = {1}", paramAndValue[0], currSec.sectionValues[paramAndValue[0]]);
+          continue;
+        }
+        
+        // Any other lines throw an error
+        throw new Exception(String.Format("Bad INI data at line {0}: {1}.", i, currLine));
+      } // End of parsing INI
+      
+      // Add last section to return value
+      if (inASection)
+      {
+        streamSections.Add(currSec);
+      }
+
+      // Return parsed ini sections    
+      myFile.sections = streamSections;
+      return myFile;
+    }
+    
+    /**
+     * Function to parse an input data stream containing INI data
+     *
+     * @param iniData is a String containing the INI data
+     */    
+    public static IniFile Parse(String iniData)
+    {
+      ASCIIEncoding ae = new ASCIIEncoding();
+      return IniFile.Parse(ae.GetBytes(iniData));
+    }
+    
+    /**
+     * Function to parse an input data stream containing INI data
+     *
+     * @param iniData is an array of bytes containing the INI data
+     */
+    public static IniFile Parse(Byte[] iniData)
+    {
+      return IniFile.Parse(new MemoryStream(iniData, false));
+    }
+    
+    /**
+     * Static function to build an INI data string
+     *
+     * @param sections is an array of IniSection objects
+     */
+    public static String ToString(IniSection[] sections)
+    {
+      StringWriter sw = new StringWriter(new StringBuilder());
+      
+      foreach(IniSection currSection in sections)
+      {
+        sw.WriteLine(currSection.ToString());
+        sw.WriteLine();
+      }
+      
+      return sw.GetStringBuilder().ToString();
+    }
+    
+    /**
+     * Static function to build an INI data string
+     *
+     * @param sections is a List of IniSection objects
+     */
+    public static String ToString(List<IniSection> sections)
+    {
+      return IniFile.ToString(sections.ToArray());
+    }
+    
+    /**
+     * Static function to build an INI data string
+     *
+     * @param sections is a List of IniSection objects
+     */
+    public static String ToString(IniFile file)
+    {
+      return IniFile.ToString(file.sections);
+    }
+  }
+  
+}
\ No newline at end of file
diff --git a/tools/omapl13x_boot_utils/Common/UtilLib/ObjectFile.cs b/tools/omapl13x_boot_utils/Common/UtilLib/ObjectFile.cs
new file mode 100644 (file)
index 0000000..0da937f
--- /dev/null
@@ -0,0 +1,498 @@
+/*
+ * ObjectFile.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+// Abstract ObjectFile class
+
+using System;
+using System.Text;
+using System.IO;
+using System.IO.Ports;
+using System.Reflection;
+using System.Threading;
+using System.Globalization;
+using System.Collections;
+using System.Collections.Generic;
+using TI.UtilLib;
+using TI.UtilLib.IO;
+
+namespace TI.UtilLib.ObjectFile
+{ 
+
+  public enum ObjectMachineType
+  {
+    ARM,
+    C6000,
+    C2400,
+    C5400,
+    C5500,
+    C2000,
+    MSP430,
+    C5500p    
+  }
+
+  public enum ObjectFileType
+  {
+    COFF,
+    ELF,
+    PE, 
+    BINARY
+  }
+  
+  public class ObjectSection : IComparable<ObjectSection>
+  {
+    public String name;
+    public UInt64 size;
+    public UInt64 runAddr;
+    public UInt64 loadAddr;
+    public Boolean isLoadable;
+    public UInt64 binFileAddr;
+    
+    public int CompareTo(ObjectSection otherSection)
+    {
+      // The ObjectSection comparison depends on the comparison of the
+      // the underlying loadAddr values. Because the CompareTo method is
+      // strongly typed, it is not necessary to test for the correct
+      // object type.
+      return this.loadAddr.CompareTo(otherSection.loadAddr);
+    }
+  }
+  
+  public class ObjectSymbol : IComparable<ObjectSymbol>, IEquatable<ObjectSymbol>
+  {
+    public String name;
+    public UInt64 value;
+    
+    public int CompareTo(ObjectSymbol otherSymbol)
+    {
+      // The ObjectSymbol comparison depends on the comparison of the
+      // the underlying value values. Because the CompareTo method is
+      // strongly typed, it is not necessary to test for the correct
+      // object type.
+      return this.value.CompareTo(otherSymbol.value);
+    }
+    
+    public bool Equals(ObjectSymbol otherSymbol)
+    {
+      return (this.value.Equals(otherSymbol.value) && 
+              this.name.Equals(otherSymbol.name)); 
+    }
+    
+    
+  }
+
+  /// <summary>
+  /// Generic Public class for Object Files
+  /// </summary>
+  public class ObjectFile : IDisposable
+  {
+    #region Private internal members
+    protected String            fileName;
+    protected Stream            binFile;
+    protected Endian            endian;
+    protected UInt32            sectionCount;
+    protected UInt32            loadableSectionCount;
+    protected UInt32            symbolCount;
+    protected UInt32            currSectionIndex;
+    protected UInt32            currSymbolIndex;
+    protected UInt64            entryPoint;
+    protected ObjectMachineType machineType;
+    protected ObjectFileType    fileType;
+        
+    protected ObjectSection[]   sections;
+    protected ObjectSection[]   loadableSections;
+    protected ObjectSymbol[]    symbols;
+    
+    private Boolean disposed = false;
+    #endregion
+    
+    #region Class constructors
+    public ObjectFile()
+    {
+      fileName    = "";
+      binFile     = null;
+      
+      sectionCount = 0;
+      symbolCount = 0;
+      loadableSectionCount = 0;
+      
+      currSectionIndex = 0;
+      currSymbolIndex = 0;
+      entryPoint = 0;
+      
+      sections    = null;
+      symbols     = null;
+    }
+    
+    public ObjectFile(String filename)
+    {
+      
+      // Get COFF file details
+      FileInfo fi = new FileInfo(filename);
+      try
+      {
+        if (fi.Exists)
+          binFile = new FileStream(filename, FileMode.Open, FileAccess.Read);
+      }
+      catch (Exception e)
+      {
+          Console.Write(e.Message);
+      }
+                  
+      // Init parsing info
+      currSectionIndex = 0;
+      currSymbolIndex = 0;
+
+      this.fileName = filename;
+
+    }
+    #endregion
+    
+    #region Public properties and indexers
+    public String FileName
+    {
+      get {return fileName; }
+    }
+    
+    public UInt64 EntryPoint
+    {
+      get { return entryPoint; }
+    }
+    
+    public ObjectMachineType MachineType
+    {
+      get { return machineType; }
+    }
+    
+    public ObjectFileType FileType
+    {
+      get { return fileType; }
+    }
+    
+    public String Endianness
+    {
+      get { return endian.ToString(); }
+    }
+    
+    public UInt32 SectionCount
+    {
+      get { return sectionCount; }
+    }
+    
+    public UInt32 LoadableSectionCount
+    {
+      get { return loadableSectionCount; }
+    }
+    
+    public UInt32 SymbolCount
+    {
+      get { return symbolCount; }
+    }
+    
+    /// <summary>
+    /// Indexer to return section with specified index
+    /// </summary>
+    /// <param name="index">Index of section in the COFF file</param>
+    /// <returns>Array of section's data</returns>
+    public Byte[] this[UInt32 index]
+    {
+      get
+      {
+        return secRead(index);
+      }
+    }
+
+    /// <summary>
+    /// Indexer to return section with specified name
+    /// </summary>
+    /// <param name="name">Section name we wish to get</param>
+    /// <returns>Array of section's data </returns>
+    public Byte[] this[String name]
+    {
+      get
+      {
+        return secRead(name);
+      }
+    }
+
+    public ObjectSection[] Sections
+    {
+      get { return sections; }
+    }
+    
+    public ObjectSection[] LoadableSections
+    {
+      get { return loadableSections; }
+    }
+
+    public ObjectSymbol[] Symbols
+    {
+      get { return symbols; }
+    }
+
+    #endregion
+    
+    #region Public Class Methods
+    public void Dispose()
+    {
+      Dispose(true);
+
+      // This object will be cleaned up by the Dispose method.
+      // Therefore, you should call GC.SupressFinalize to
+      // take this object off the finalization queue
+      // and prevent finalization code for this object
+      // from executing a second time.
+      GC.SuppressFinalize(this);    
+    }
+    
+    public void dumpSymbolTable()
+    {
+      symRewind();
+      Console.WriteLine("\tValue     \tName");
+      Console.WriteLine("\t==========\t========");
+      foreach (ObjectSymbol sym in Symbols)
+      {
+        if (!( (sym.name).Equals("") || (sym.name == null) ))
+        {
+          Console.WriteLine("\t0x{0:X8}\t {1}", ((UInt32)sym.value), sym.name);
+        }
+      }
+    }
+    
+    public new String ToString()
+    {
+      StringBuilder strBuilder = new StringBuilder(512);
+      FieldInfo[] myFieldInfo;
+      Type myType;
+      
+      // Get the type and fields of ObjectSection.
+      myType = typeof(ObjectSection);
+      myFieldInfo = myType.GetFields();
+
+      for (int i = 0; i < sectionCount; i++)
+      {
+        for (int j = 0; j<myFieldInfo.Length; j++)
+        {
+          strBuilder.Append("Sections["+i+"]." + myFieldInfo[j].Name + " = " + myFieldInfo[j].GetValue(sections[i]) + "\n");  
+        }
+      }
+      
+      myType = typeof(ObjectSymbol);
+      myFieldInfo = myType.GetFields();
+
+      for (int i = 0; i < symbolCount; i++)
+      {
+        for (int j = 0; j<myFieldInfo.Length; j++)
+        {
+          strBuilder.Append("Symbols["+i+"]." + myFieldInfo[j].Name + " = " + myFieldInfo[j].GetValue(symbols[i]) + "\n");
+        }
+      }
+
+      return strBuilder.ToString();
+    }
+
+    #region Section seek and access commands
+    
+    public ObjectSection secRewind()
+    {
+      currSectionIndex = 0;
+      return Sections[currSectionIndex];
+    }
+
+    public ObjectSection secSeek(UInt32 index)
+    {
+      if ( (index >= 0) && (index < sectionCount) )
+      {
+        currSectionIndex = index;
+        return Sections[currSectionIndex];
+      }
+      return null;
+    }
+
+    public ObjectSection secFind(String secName)
+    {
+      for (UInt32 i = 0; i < sectionCount; i++)
+      {
+        if ( (Sections[i].name).Equals(secName))
+        {
+          currSectionIndex = i;
+          return Sections[currSectionIndex];
+        }
+      }
+      return null;
+    }
+
+    public ObjectSection secEnum()
+    {
+      if ( (currSectionIndex >= 0) && ( currSectionIndex < sectionCount ) )
+      {
+        currSectionIndex++;
+        return Sections[currSectionIndex-1];
+      }
+      
+      return null;
+    }
+    
+    public Byte[] secRead(ObjectSection section)
+    {
+      Byte[] dataArr          = new Byte[section.size];
+      EndianBinaryReader ebr  = new EndianBinaryReader(this.binFile,this.endian);
+      
+      // Go to start of section in the binary file
+      binFile.Seek((Int64) section.binFileAddr, SeekOrigin.Begin);
+      
+      // Read section bytes
+      dataArr = ebr.ReadBytes((Int32)section.size);
+      
+      // Check to see if we need to pad the output array
+      // Should only be needed for binary files
+      if (dataArr.Length < (Int32) section.size)
+      {
+        Array.Resize(ref dataArr, (Int32) section.size);
+      }
+
+      return dataArr;
+    }
+    
+    public Byte[] secRead()
+    {
+      ObjectSection section   = Sections[currSectionIndex];
+      return secRead(section);
+    }    
+
+    public Byte[] secRead(UInt32 secNum)
+    {
+        secSeek(secNum);
+        return secRead();
+    }
+
+    public Byte[] secRead(String secName)
+    {
+        secFind(secName);
+        return secRead();
+    }
+    
+    #endregion
+
+    #region Symbol seek and access commands
+    public ObjectSymbol symRewind()
+    {
+      currSymbolIndex = 0;
+      return Symbols[currSymbolIndex];
+    }
+
+    public ObjectSymbol symSeek( UInt32 index)
+    {
+      if ((index>=0) && (index < symbolCount))
+      {
+        currSymbolIndex = index;
+        return Symbols[currSymbolIndex];
+      }
+      return null;
+    }
+
+    public ObjectSymbol symFind( String symName)
+    {
+      for(UInt32 i = 0; i < symbolCount; i++)
+      {
+        if ( (Symbols[i].name).Equals(symName))
+        {
+          currSymbolIndex = i;
+          return Symbols[currSymbolIndex];
+        }
+      }
+      return null;
+    }
+
+    public ObjectSymbol symEnum()
+    {
+      if ( (currSymbolIndex >=0) && (currSymbolIndex <= symbolCount) )
+      {
+        currSymbolIndex++;
+        return Symbols[currSymbolIndex-1];
+      }
+     
+      return null;
+    }
+    #endregion
+
+    /// <summary>
+    /// Function to close the Object file associated with this object
+    /// </summary>
+    public void Close()
+    {
+      binFile.Close();
+    }
+
+    #endregion
+
+    #region Public Static Class Methods
+    public static Boolean IsElfFile(ObjectFile file)
+    {
+      return (file.FileType == ObjectFileType.ELF);
+    }
+    
+    public static Boolean IsCoffFile(ObjectFile file)
+    {
+      return (file.FileType == ObjectFileType.COFF);
+    }
+    #endregion
+    
+    #region Private class Methods
+    private void Dispose(Boolean disposing)
+    {
+      // Check to see if Dispose has already been called.
+      if(!this.disposed)
+      {
+        // If disposing equals true, dispose all managed
+        // and unmanaged resources.
+        if(disposing)
+        {
+          // Dispose managed resources.
+          binFile.Dispose();
+        }
+
+        // Dispose any unmanaged resource here
+        
+        // Note disposing has been done.
+        disposed = true;
+      }
+    }
+    #endregion
+  }
+
+} //end of namespace
diff --git a/tools/omapl13x_boot_utils/Common/UtilLib/SRecord.cs b/tools/omapl13x_boot_utils/Common/UtilLib/SRecord.cs
new file mode 100644 (file)
index 0000000..07d985e
--- /dev/null
@@ -0,0 +1,351 @@
+/*
+ * SRecord.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+using System;
+using System.Text;
+using System.IO;
+using System.IO.Ports;
+using System.Reflection;
+using System.Threading;
+using System.Globalization;
+
+namespace TI.UtilLib
+{
+    class SRecord
+    {
+        /// <summary>
+        /// Function to convert the input filestream into an byte array in S-record format.
+        /// </summary>
+        /// <param name="inputFileStream">The input filestream that encapsulates the
+        /// input binary file.</param>
+        /// <param name="startAddr">The starting address of the RAM location where the binary data
+        /// encapsulated by the S-record will be stored.</param>
+        /// <returns>A byte array of the file data.</returns>
+        public static Byte[] bin2srec(Stream inputStream, UInt32 startAddr)
+        {
+            Int64 totalLen;
+            BinaryReader fileBR = new BinaryReader(inputStream);
+            StringBuilder fileSB;
+            String fileName;
+            String shortFileName;
+            Byte[] currChar = new Byte[1];
+            Byte[] currDataRecord;
+            Int32 i, checksum8 = 0;
+            Int32 recordSize = 16;
+            UInt32 memAddr = startAddr;
+
+            // Set the actual length
+            totalLen = fileBR.BaseStream.Length;
+            fileSB = new StringBuilder(4 * (int)totalLen);
+
+            // Set S-record filename (real name or fake)
+            if (inputStream is FileStream)
+                fileName = ((FileStream)inputStream).Name;
+            else
+                fileName = "ublDaVinci.bin";
+
+            // Make sure we are at the right place in the stream
+            fileBR.BaseStream.Seek(0x0, SeekOrigin.Begin);
+
+            // Get filename (this is S-record module name)
+            if (Path.HasExtension(fileName))
+                shortFileName = Path.GetFileNameWithoutExtension(fileName) + ".hex";
+            else
+                shortFileName = Path.GetFileName(fileName) + ".hex";
+
+            // Make sure S-record module name fits in 20 byte field
+            if (shortFileName.Length > 20)
+                shortFileName = shortFileName.Substring(0, 20);
+
+            // Create first s-record (S0 record)
+            fileSB.Append("S0");
+            // Write length field
+            fileSB.AppendFormat("{0:X2}", shortFileName.Length + 3);
+            checksum8 += (Byte)(shortFileName.Length + 3);
+            // Write address field
+            fileSB.Append("0000");
+            // Write name field
+            for (i = 0; i < shortFileName.Length; i++)
+            {
+                currChar = (new ASCIIEncoding()).GetBytes(shortFileName.Substring(i, 1));
+                checksum8 += currChar[0];
+                fileSB.AppendFormat("{0:X2}", currChar[0]);
+            }
+            // Write Checksum field
+            fileSB.AppendFormat("{0:X2}\x0A", ((checksum8 & 0xFF) ^ 0xFF));
+
+            // Write collection of S3 records (actual binary data)
+            i = (Int32)totalLen;
+
+            while (i >= recordSize)
+            {
+                checksum8 = 0;
+                // Write S3 record label
+                fileSB.Append("S3");
+                // Write length field (4 address bytes + 16 data bytes + 1 checksum byte)
+                fileSB.AppendFormat("{0:X2}", recordSize + 5);
+                checksum8 += (recordSize + 5);
+
+                // Write address field and update it
+                fileSB.AppendFormat("{0:X8}", memAddr);
+                currDataRecord = System.BitConverter.GetBytes(memAddr);
+                for (int j = 0; j < 4; j++)
+                {
+                    checksum8 += currDataRecord[j];
+                }
+
+                // Write out the bytes of data
+                currDataRecord = fileBR.ReadBytes(recordSize);
+                for (int j = 0; j < recordSize; j++)
+                {
+                    fileSB.AppendFormat("{0:X2}", currDataRecord[j]);
+                    checksum8 += currDataRecord[j];
+                }
+                //Write out checksum and linefeed character
+                fileSB.AppendFormat("{0:X2}\x0A", ((checksum8 & 0xFF) ^ 0xFF));
+
+                memAddr += (UInt32)recordSize; i -= recordSize;
+            }
+
+            // Finish out the record if anything is left over
+            if (i > 0)
+            {
+                checksum8 = 0;
+                // Write S3 record label
+                fileSB.Append("S3");
+                // Write length field (4 address bytes + 16 data bytes + 1 checksum byte)
+                fileSB.AppendFormat("{0:X2}", i + 5);
+                checksum8 += (i + 5);
+
+                // Write address field and update it
+                fileSB.AppendFormat("{0:X8}", memAddr);
+                currDataRecord = System.BitConverter.GetBytes(memAddr);
+                for (int j = 0; j < 4; j++)
+                {
+                    checksum8 += currDataRecord[j];
+                }
+
+                // Write out the bytes of data
+                currDataRecord = fileBR.ReadBytes(i);
+                for (int j = 0; j < i; j++)
+                {
+                    fileSB.AppendFormat("{0:X2}", currDataRecord[j]);
+                    checksum8 += currDataRecord[j];
+                }
+                //Write out checksum and linefeed character
+                fileSB.AppendFormat("{0:X2}\x0A", ((checksum8 & 0xFF) ^ 0xFF));
+
+                memAddr += (UInt32)i; i = 0;
+
+            }
+
+            // Write out the final record (S7 record)
+            checksum8 = 0;
+            // Write S7 record label
+            fileSB.Append("S7");
+            // Write length field (4 address bytes + 1 checksum byte)
+            fileSB.AppendFormat("{0:X2}", 5);
+            checksum8 += 5;
+
+            // Write execution start address field and update it
+            fileSB.AppendFormat("{0:X8}", startAddr);
+            currDataRecord = System.BitConverter.GetBytes(startAddr);
+            for (int j = 0; j < 4; j++)
+            {
+                checksum8 += currDataRecord[j];
+            }
+            //Write out checksum and linefeed character
+            fileSB.AppendFormat("{0:X2}\x0A", ((checksum8 & 0xFF) ^ 0xFF));
+
+            return (new ASCIIEncoding()).GetBytes(fileSB.ToString());
+
+        }
+        
+        /// <summary>
+        /// Function to convert the input binary byte array into an byte array in S-record format.
+        /// </summary>
+        /// <param name="inputFileStream">The input filestream that encapsulates the
+        /// input binary file.</param>
+        /// <param name="startAddr">The starting address of the RAM location where the binary data
+        /// encapsulated by the S-record will be stored.</param>
+        /// <param name="recordSize">The size in bytes of each S-record (line) of the output.</param>
+        /// <returns>A byte array of the file data.</returns>
+        public static Byte[] bin2srec(Byte[] inputData, UInt32 startAddr, Int32 recordSize)
+        {
+            Int64 totalLen;
+            StringBuilder fileSB;
+            String fileName;
+            String shortFileName;
+            Byte[] currChar = new Byte[1];
+            Byte[] currDataRecord;
+            Int32 i, checksum8 = 0;
+            UInt32 memAddr = startAddr;
+
+            // Set the actual length
+            totalLen = inputData.Length;
+            fileSB = new StringBuilder(4 * (int)totalLen);
+
+            // Set S-record filename (real name or fake)
+            //if (inputStream is FileStream)
+            //    fileName = ((FileStream)inputStream).Name;
+            //else
+                fileName = "ublDaVinci.bin";
+
+            // Make sure we are at the right place in the stream
+            //fileBR.BaseStream.Seek(0x0, SeekOrigin.Begin);
+
+            // Get filename (this is S-record module name)
+            if (Path.HasExtension(fileName))
+                shortFileName = Path.GetFileNameWithoutExtension(fileName) + ".hex";
+            else
+                shortFileName = Path.GetFileName(fileName) + ".hex";
+
+            // Make sure S-record module name fits in 20 byte field
+            if (shortFileName.Length > 20)
+                shortFileName = shortFileName.Substring(0, 20);
+
+            // Create first s-record (S0 record)
+            fileSB.Append("S0");
+            // Write length field
+            fileSB.AppendFormat("{0:X2}", shortFileName.Length + 3);
+            checksum8 += (Byte)(shortFileName.Length + 3);
+            // Write address field
+            fileSB.Append("0000");
+            // Write name field
+            for (i = 0; i < shortFileName.Length; i++)
+            {
+                currChar = (new ASCIIEncoding()).GetBytes(shortFileName.Substring(i, 1));
+                checksum8 += currChar[0];
+                fileSB.AppendFormat("{0:X2}", currChar[0]);
+            }
+            // Write Checksum field
+            fileSB.AppendFormat("{0:X2}\x0A", ((checksum8 & 0xFF) ^ 0xFF));
+
+            // Write collection of S3 records (actual binary data)
+            i = (Int32)totalLen;
+
+            while (i >= recordSize)
+            {
+                checksum8 = 0;
+                // Write S3 record label
+                fileSB.Append("S3");
+                // Write length field (4 address bytes + 16 data bytes + 1 checksum byte)
+                fileSB.AppendFormat("{0:X2}", recordSize + 5);
+                checksum8 += (recordSize + 5);
+
+                // Write address field and update it
+                fileSB.AppendFormat("{0:X8}", memAddr);
+                currDataRecord = System.BitConverter.GetBytes(memAddr);
+                for (int j = 0; j < 4; j++)
+                {
+                    checksum8 += currDataRecord[j];
+                }
+
+                // Write out the bytes of data
+                //currDataRecord = fileBR.ReadBytes(recordSize);
+                
+                for (int j = 0; j < recordSize; j++)
+                {
+                    //fileSB.AppendFormat("{0:X2}", currDataRecord[j]);
+                    fileSB.AppendFormat("{0:X2}", inputData[j + (memAddr - startAddr)]);
+                    //checksum8 += currDataRecord[j];
+                    checksum8 += inputData[j + (memAddr - startAddr)];
+                }
+                //Write out checksum and linefeed character
+                fileSB.AppendFormat("{0:X2}\x0A", ((checksum8 & 0xFF) ^ 0xFF));
+
+                memAddr += (UInt32)recordSize; i -= recordSize;
+            }
+
+            // Finish out the record if anything is left over
+            if (i > 0)
+            {
+                checksum8 = 0;
+                // Write S3 record label
+                fileSB.Append("S3");
+                // Write length field (4 address bytes + 16 data bytes + 1 checksum byte)
+                fileSB.AppendFormat("{0:X2}", i + 5);
+                checksum8 += (i + 5);
+
+                // Write address field and update it
+                fileSB.AppendFormat("{0:X8}", memAddr);
+                currDataRecord = System.BitConverter.GetBytes(memAddr);
+                for (int j = 0; j < 4; j++)
+                {
+                    checksum8 += currDataRecord[j];
+                }
+
+                // Write out the bytes of data
+                //currDataRecord = fileBR.ReadBytes(i);
+                for (int j = 0; j < i; j++)
+                {
+                    //fileSB.AppendFormat("{0:X2}", currDataRecord[j]);
+                    fileSB.AppendFormat("{0:X2}", inputData[j + (memAddr - startAddr)]);
+                    //checksum8 += currDataRecord[j];
+                    checksum8 += inputData[j + (memAddr - startAddr)];
+                }
+                //Write out checksum and linefeed character
+                fileSB.AppendFormat("{0:X2}\x0A", ((checksum8 & 0xFF) ^ 0xFF));
+
+                memAddr += (UInt32)i; i = 0;
+
+            }
+
+            // Write out the final record (S7 record)
+            checksum8 = 0;
+            // Write S7 record label
+            fileSB.Append("S7");
+            // Write length field (4 address bytes + 1 checksum byte)
+            fileSB.AppendFormat("{0:X2}", 5);
+            checksum8 += 5;
+
+            // Write execution start address field and update it
+            fileSB.AppendFormat("{0:X8}", startAddr);
+            currDataRecord = System.BitConverter.GetBytes(startAddr);
+            for (int j = 0; j < 4; j++)
+            {
+                checksum8 += currDataRecord[j];
+            }
+            //Write out checksum and linefeed character
+            fileSB.AppendFormat("{0:X2}\x0A", ((checksum8 & 0xFF) ^ 0xFF));
+
+            return (new ASCIIEncoding()).GetBytes(fileSB.ToString());
+        }
+
+    }
+}
diff --git a/tools/omapl13x_boot_utils/Common/UtilLib/SerialIO.cs b/tools/omapl13x_boot_utils/Common/UtilLib/SerialIO.cs
new file mode 100644 (file)
index 0000000..9390981
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ * SerialIO.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+using System;
+using System.IO;
+using System.IO.Ports;
+using System.Reflection;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TI.UtilLib.IO
+{
+  public class SerialIO
+  {
+        /// <summary>
+    /// Waitforsequence with option for verbosity
+    /// </summary>
+    /// <param name="str">String to look for</param>
+    /// <param name="altStr">String to look for but don't want</param>
+    /// <param name="sp">SerialPort object.</param>
+    /// <param name="verbose">Boolean to indicate verbosity.</param>
+    /// <returns>Boolean to indicate if str or altStr was found.</returns>
+    public static Boolean waitForSequence(String str, String altStr, SerialPort sp, Boolean verbose)
+    {
+        Boolean strFound = false, altStrFound = false;
+        Byte[] input = new Byte[256];
+        String inputStr;
+        Int32 i;
+               sp.ReadTimeout=300000;
+        while ((!strFound) && (!altStrFound))
+        {
+            
+            i = 0;
+            do
+            {
+                try
+                {
+                    input[i++] = (Byte)sp.ReadByte();
+                }
+                catch
+                {
+                                       //Console.Write(".");
+                }
+                //Console.Write(input[i - 1] + " ");
+            } while ( (input[i - 1] != 0) &&
+                      (i < (input.Length - 1)) &&
+                      (input[i - 1] != 0x0A) &&
+                      (input[i - 1] != 0x0D) );
+
+            // Convert to string for comparison
+            if ((input[i-1] == 0x0A) || (input[i-1] == 0x0D))
+                inputStr = (new ASCIIEncoding()).GetString(input, 0, i-1);
+            else
+                inputStr = (new ASCIIEncoding()).GetString(input, 0, i);
+
+            if (inputStr.Length == 0)
+            {
+                continue;
+            }
+
+            // Compare Strings to see what came back
+            if (verbose)
+                Console.WriteLine("\tTarget:\t{0}", inputStr);
+            if (inputStr.Contains(altStr))
+            {
+                altStrFound = true;
+                if (String.Equals(str, altStr))
+                {
+                    strFound = altStrFound;
+                }
+            }
+            else if (inputStr.Contains(str))
+            {
+                strFound = true;
+            }
+            else
+            {
+                strFound = false;
+            }
+        }
+        return strFound;
+    }
+    public static string readSequence(SerialPort sp, Boolean verbose)
+    {
+        Boolean strFound = false, altStrFound = false;
+        Byte[] input = new Byte[256];
+        String inputStr;
+        Int32 i;
+               sp.ReadTimeout=300000;
+        while ((!strFound) && (!altStrFound))
+        {
+            
+            i = 0;
+            do
+            {
+                try
+                {
+                    input[i++] = (Byte)sp.ReadByte();
+                }
+                catch
+                {
+                                       //Console.Write(".");
+                }
+                //Console.Write(input[i - 1] + " ");
+            } while ( (input[i - 1] != 0) &&
+                      (i < (input.Length - 1)) &&
+                      (input[i - 1] != 0x0A) &&
+                      (input[i - 1] != 0x0D) );
+
+            // Convert to string for comparison
+            if ((input[i-1] == 0x0A) || (input[i-1] == 0x0D))
+                inputStr = (new ASCIIEncoding()).GetString(input, 0, i-1);
+            else
+                inputStr = (new ASCIIEncoding()).GetString(input, 0, i);
+
+            if (inputStr.Length == 0)
+            {
+                continue;
+            }
+
+            // Compare Strings to see what came back
+            if (verbose)
+                Console.WriteLine("\tTarget:\t{0}", inputStr);
+                                               return inputStr;
+           }
+               return "FAIL";
+    }
+  }
+}
diff --git a/tools/omapl13x_boot_utils/Common/build.mak b/tools/omapl13x_boot_utils/Common/build.mak
new file mode 100644 (file)
index 0000000..a5b4d2d
--- /dev/null
@@ -0,0 +1,16 @@
+#############################################################
+# Common build definitions for Makefile use                 #
+#############################################################
+#
+
+ARM_TOOLS_PATH?=C:\\ti\\gcc-arm-none-eabi-4_9-2015q3\\
+ARM_TOOLS_PREFIX?=arm-none-eabi-
+
+CROSSCOMPILE?=$(ARM_TOOLS_PATH)bin\\$(ARM_TOOLS_PREFIX)
+ARM_CROSSCOMPILE=$(CROSSCOMPILE)
+
+DSP_TOOLS_PATH?=C:\\ti\\ti-cgt-c6000_8.1.3\\
+
+DSP_LIB_PATH=$(DSP_TOOLS_PATH)lib\\
+DSP_CROSSCOMPILE=$(DSP_TOOLS_PATH)bin\\
+DSP_INC_PATH=$(DSP_TOOLS_PATH)include\\
diff --git a/tools/omapl13x_boot_utils/Common/include/tistdtypes.h b/tools/omapl13x_boot_utils/Common/include/tistdtypes.h
new file mode 100644 (file)
index 0000000..017516b
--- /dev/null
@@ -0,0 +1,237 @@
+/*
+ * tistdtypes.h
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+/*
+ *  Copyright 2008 by Texas Instruments Incorporated.
+ *  All rights reserved. Property of Texas Instruments Incorporated.
+ *  Restricted rights to use, duplicate or disclose this code are
+ *  granted through contract.
+ *
+ */
+/*
+ *  ======== tistdtypes.h ========
+ *
+ */
+
+
+/*
+ *  These types are also defined by other TI components.  They are bracketed
+ *  with _TI_STD_TYPES to avoid warnings for duplicate definition.  The
+ *  The Uint16, etc. definitions were provided in early 2.x versions of CSL
+ *  that did not have _TI_STD_TYPES protection.
+ *
+ *  You may get warnings about duplicate type definitions when using this
+ *  header file with 2.x CSL.  You can use the '-pds303' compiler option to
+ *  suppress these warnings.
+ */
+#ifndef _TI_STD_TYPES
+#define _TI_STD_TYPES
+
+/*
+ * Null declaration 
+ */
+#ifndef NULL
+  #define NULL    (0)
+#endif
+
+/*
+ * Return type defines 
+ */
+#ifndef E_PASS
+  #define E_PASS    (0x00000000u)
+#endif
+#ifndef E_FAIL
+  #define E_FAIL    (0x00000001u)
+#endif
+#ifndef E_TIMEOUT
+  #define E_TIMEOUT (0x00000002u)
+#endif
+#ifndef E_DEVICE
+  #define E_DEVICE (0x00000003u)
+#endif
+
+// Aliases for standard C types
+typedef int                     Int;
+typedef unsigned                Uns;
+typedef char                    Char;
+typedef char                    *String;       /* pointer to null-terminated character sequence */
+typedef void                    *Ptr;       /* pointer to arbitrary type */
+typedef unsigned short          Bool;       /* boolean */
+
+// Boolean declarations
+#ifndef TRUE
+  #define TRUE    ((Bool) 1)
+#endif
+#ifndef FALSE
+  #define FALSE   ((Bool) 0)
+#endif
+
+// GENERIC BUS width defines
+#ifndef BUS_8BIT
+  #define BUS_8BIT            (0x01)
+#endif
+#ifndef BUS_16BIT
+  #define BUS_16BIT           (0x02)
+#endif
+#ifndef BUS_32BIT
+  #define BUS_32BIT           (0x04)
+#endif
+#ifndef BUS_64BIT
+  #define BUS_64BIT           (0x08)
+#endif
+
+// Generic bit mask defines
+#ifndef BIT0
+  #define BIT0    (0x00000001)
+  #define BIT1    (0x00000002)
+  #define BIT2    (0x00000004)
+  #define BIT3    (0x00000008)
+  #define BIT4    (0x00000010)
+  #define BIT5    (0x00000020)
+  #define BIT6    (0x00000040)
+  #define BIT7    (0x00000080)
+  #define BIT8    (0x00000100)
+  #define BIT9    (0x00000200)
+  #define BIT10   (0x00000400)
+  #define BIT11   (0x00000800)
+  #define BIT12   (0x00001000)
+  #define BIT13   (0x00002000)
+  #define BIT14   (0x00004000)
+  #define BIT15   (0x00008000)
+  #define BIT16   (0x00010000)
+  #define BIT17   (0x00020000)
+  #define BIT18   (0x00040000)
+  #define BIT19   (0x00080000)
+  #define BIT20   (0x00100000)
+  #define BIT21   (0x00200000)
+  #define BIT22   (0x00400000)
+  #define BIT23   (0x00800000)
+  #define BIT24   (0x01000000)
+  #define BIT25   (0x02000000)
+  #define BIT26   (0x04000000)
+  #define BIT27   (0x08000000)
+  #define BIT28   (0x10000000)
+  #define BIT29   (0x20000000)
+  #define BIT30   (0x40000000)
+  #define BIT31   (0x80000000)
+#endif
+  
+
+/*
+ * Uint8, Uint16, Uint32, etc are defined to be "smallest unit of
+ * available storage that is large enough to hold unsigned or integer
+ * of specified size".
+ */
+
+/* Handle the 6x ISA */
+#if defined(_TMS320C6X)
+    /* Unsigned integer definitions (32bit, 16bit, 8bit) follow... */
+    typedef unsigned int                 Uint32;
+    typedef unsigned short               Uint16;
+    typedef unsigned char                Uint8;
+
+    /* Signed integer definitions (32bit, 16bit, 8bit) follow... */
+    typedef int                          Int32;
+    typedef short                        Int16;
+    typedef char                         Int8;
+
+       /* Volatile unsigned integer definitions (32bit, 16bit, 8bit) follow... */
+    typedef volatile unsigned int        VUint32;
+    typedef volatile unsigned short      VUint16;
+    typedef volatile unsigned char       VUint8;
+
+    /* Volatile signed integer definitions (32bit, 16bit, 8bit) follow... */
+    typedef volatile int                 VInt32;
+    typedef volatile short               VInt16;
+    typedef volatile char                VInt8;
+
+    #define __FAR__                      far
+    #define __NEAR__                     near
+
+/* Handle the 54x, 55x ISAs */
+#elif defined(_TMS320C5XX) || defined(__TMS320C55X__)
+    /* Unsigned integer definitions (32bit, 16bit, 8bit) follow... */
+    typedef unsigned long       Uint32;
+    typedef unsigned short      Uint16;
+    typedef unsigned char       Uint8;
+
+    /* Signed integer definitions (32bit, 16bit, 8bit) follow... */
+    typedef long                Int32;
+    typedef short               Int16;
+    typedef char                Int8;
+/* Handle 28x ISA */
+#elif defined(_TMS320C28X)
+    /* Unsigned integer definitions (32bit, 16bit, 8bit) follow... */
+    typedef unsigned long       Uint32;
+    typedef unsigned int        Uint16;
+    typedef unsigned char       Uint8;
+
+    /* Signed integer definitions (32bit, 16bit, 8bit) follow... */
+    typedef long                Int32;
+    typedef int                 Int16;
+    typedef char                Int8;
+/* Handle ARM TMS470 ISA (GNU compiler is assumed to exist for ARM only)*/
+#elif (defined(__TMS470__) || defined(__GNUC__))
+    /* Unsigned integer definitions (32bit, 16bit, 8bit) follow... */
+    typedef unsigned int                 Uint32;
+    typedef unsigned short               Uint16;
+    typedef unsigned char                Uint8;
+
+    /* Signed integer definitions (32bit, 16bit, 8bit) follow... */
+    typedef int                          Int32;
+    typedef short                        Int16;
+    typedef char                         Int8;
+
+       /* Volatile unsigned integer definitions (32bit, 16bit, 8bit) follow... */
+    typedef volatile unsigned int        VUint32;
+    typedef volatile unsigned short      VUint16;
+    typedef volatile unsigned char       VUint8;
+
+    /* Volatile signed integer definitions (32bit, 16bit, 8bit) follow... */
+    typedef volatile int                 VInt32;
+    typedef volatile short               VInt16;
+    typedef volatile char                VInt8;
+
+    /* empty defines */
+    #define __FAR__ 
+    #define __NEAR__
+#else
+    /* Other ISAs not supported */
+    #error <tistdtypes.h> is not supported for this target
+#endif
+
+#endif  /* _TI_STD_TYPES */
diff --git a/tools/omapl13x_boot_utils/Common/include/util.h b/tools/omapl13x_boot_utils/Common/include/util.h
new file mode 100644 (file)
index 0000000..8b3f4e0
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * util.h
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+/* --------------------------------------------------------------------------
+  FILE        : util.h
+  PURPOSE     : Misc. utility header file
+  PROJECT     : DaVinci Flashing Utilities
+  AUTHOR      : Daniel Allred
+  DESC        : Header for UTIL module
+ ----------------------------------------------------------------------------- */ 
+
+#ifndef _UTIL_H_
+#define _UTIL_H_
+
+#include "tistdtypes.h"
+
+// Prevent C++ name mangling
+#ifdef __cplusplus
+extern far "c" {
+#endif
+
+/***********************************************************
+* Global Macro Declarations                                *
+***********************************************************/
+
+#define ENDIAN_SWAP(a) (((a&0xFF)<<24)|((a&0xFF0000)>>8)|((a&0xFF00)<<8)|((a&0xFF000000)>>24))
+
+
+/***********************************************************
+* Global Typedef declarations                              *
+***********************************************************/
+
+
+/***********************************************************
+* Global Function Declarations                             *
+***********************************************************/
+
+void *UTIL_getCurrMemPtr(void);
+void UTIL_setCurrMemPtr(void *value);
+void *UTIL_allocMem (Uint32 size);
+void *UTIL_callocMem(Uint32 size);
+void UTIL_memcpy(void *dest, void *src, Uint32 size);
+void UTIL_waitLoop(Uint32 loopcnt);
+void UTIL_waitLoopAccurate (Uint32 loopcnt);
+Uint32 UTIL_calcCRC32(Uint32* lutCRC, Uint8 *data, Uint32 size, Uint32 currCRC);
+void UTIL_buildCRC32Table(Uint32* lutCRC, Uint32 poly);
+Uint16 UTIL_calcCRC16(Uint16* lutCRC, Uint8 *data, Uint32 size, Uint16 currCRC);
+void UTIL_buildCRC16Table(Uint16* lutCRC, Uint16 poly);
+
+
+/***********************************************************
+* End file                                                 *
+***********************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //_UTIL_H_
+
+/* --------------------------------------------------------------------------
+  HISTORY
+         v1.00  -  DJA  -  07-Nov-2007
+      Initial release 
+ ----------------------------------------------------------------------------- */
+
diff --git a/tools/omapl13x_boot_utils/Common/ti.ico b/tools/omapl13x_boot_utils/Common/ti.ico
new file mode 100644 (file)
index 0000000..d4a5e2f
Binary files /dev/null and b/tools/omapl13x_boot_utils/Common/ti.ico differ
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/Common/include/device.h b/tools/omapl13x_boot_utils/OMAP-L137/Common/include/device.h
new file mode 100644 (file)
index 0000000..c184b83
--- /dev/null
@@ -0,0 +1,1088 @@
+/*
+ * device.h
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+/* --------------------------------------------------------------------------
+  FILE        : device.h                                                   
+  PROJECT     : TI Booting and Flashing Utilities for OMAP-L137
+  AUTHOR      : Daniel Allred
+  DESC        : Provides device differentiation for the project files. This
+                file MUST be modified to match the device specifics.
+----------------------------------------------------------------------------- */
+
+#ifndef _DEVICE_H_
+#define _DEVICE_H_
+
+#include "tistdtypes.h"
+
+// Prevent C++ name mangling
+#ifdef __cplusplus
+extern far "c" {
+#endif
+
+/***********************************************************
+* Global Macro Declarations                                *
+***********************************************************/
+
+
+/************************************************************
+* Global Variable Declarations                              *
+************************************************************/
+
+extern const char devString[];
+
+
+/******************************************************
+* Global Typedef declarations                         *
+******************************************************/
+
+typedef enum _DEVICE_CacheType_
+{
+  DEVICE_CACHETYPE_L1P = 0x0,
+  DEVICE_CACHETYPE_L1D = 0x1,
+  DEVICE_CACHETYPE_L2  = 0x2
+}
+DEVICE_CacheType;
+
+// Supported buswidth
+typedef enum _DEVICE_BUSWIDTH_
+{
+  DEVICE_BUSWIDTH_8BIT  = BUS_8BIT,
+  DEVICE_BUSWIDTH_16BIT = BUS_16BIT
+}
+DEVICE_BusWidth;
+
+typedef enum _DEVICE_CHIPREVID_TYPE_
+{
+  DEVICE_CHIPREVID_TYPE_DSPONLY = 0x0, 
+  DEVICE_CHIPREVID_TYPE_ARMONLY = 0x1,
+  DEVICE_CHIPREVID_TYPE_DSPBOOT = 0x2,
+  DEVICE_CHIPREVID_TYPE_ARMBOOT = 0x3
+}
+DEVICE_ChipRevIDType;
+
+typedef enum _DEVICE_BOOTPERIPHERAL_
+{
+  DEVICE_BOOTPERIPHERAL_NONE = 0,
+  DEVICE_BOOTPERIPHERAL_NOR,
+  DEVICE_BOOTPERIPHERAL_UHPI,
+  DEVICE_BOOTPERIPHERAL_SPI,
+  DEVICE_BOOTPERIPHERAL_I2C,
+  DEVICE_BOOTPERIPHERAL_NAND,
+  DEVICE_BOOTPERIPHERAL_USB,
+  DEVICE_BOOTPERIPHERAL_UART,
+  DEVICE_BOOTPERIPHERAL_RMII,
+  DEVICE_BOOTPERIPHERAL_ESF
+}
+DEVICE_BootPeripheral;
+
+typedef enum _DEVICE_BOOTMODE_
+{
+  DEVICE_BOOTMODE_NONE = 0,
+  DEVICE_BOOTMODE_EMU_DEBUG,  
+  DEVICE_BOOTMODE_NOR_EMIFA,
+  DEVICE_BOOTMODE_NAND_EMIFA_8BIT,
+  DEVICE_BOOTMODE_NAND_EMIFA_16BIT,
+  DEVICE_BOOTMODE_UHPI,                       // 16 bit
+  DEVICE_BOOTMODE_SPI0_FLASH,                 // 24 bit address
+  DEVICE_BOOTMODE_SPI0_EEPROM,                // 16 bit address
+  DEVICE_BOOTMODE_SPI0_SLAVE,                 // 16 bit data
+  DEVICE_BOOTMODE_SPI1_FLASH,                 // 24 bit address
+  DEVICE_BOOTMODE_SPI1_EEPROM,                // 16 bit address
+  DEVICE_BOOTMODE_SPI1_SLAVE,                 // 16 bit data
+  DEVICE_BOOTMODE_I2C0_MASTER,                // 16 bit address
+  DEVICE_BOOTMODE_I2C0_SLAVE,                 // 16 bit data
+  DEVICE_BOOTMODE_I2C1_MASTER,                // 16 bit address
+  DEVICE_BOOTMODE_I2C1_SLAVE,                 // 16 bit data
+  DEVICE_BOOTMODE_UART0,
+  DEVICE_BOOTMODE_UART1,
+  DEVICE_BOOTMODE_UART2,
+  DEVICE_BOOTMODE_ESF,
+  DEVICE_BOOTMODE_MMC,                        // Not supported
+  DEVICE_BOOTMODE_RMII,                       // Not supported
+  DEVICE_BOOTMODE_USB11,                      // Not supported
+  DEVICE_BOOTMODE_USB20,                      // Not supported
+  DEVICE_BOOTMODE_THB = 0xAA  
+}
+DEVICE_BootMode;
+
+// C6740 Megamodule Power Down Controller 
+typedef struct _DEVICE_C6740_PDC_
+{
+  VUint32 PDCCMD;
+}
+DEVICE_C6740_PDCRegs;
+
+#define PDC ((DEVICE_C6740_PDCRegs *) 0x01810000)
+
+// C6740 IDMA
+typedef struct _DEVICE_C6740_IDMA_
+{
+  VUint32 STAT;
+  VUint32 MASK;
+  VUint32 SOURCE;  
+  VUint32 DEST;
+  VUint32 CNT;  
+}
+DEVICE_C6740_IDMARegs;
+
+#define IDMA0 ((DEVICE_C6740_IDMARegs *) 0x01820000)
+#define IDMA1 ((DEVICE_C6740_IDMARegs *) 0x01820100)
+
+// C6740 L1P Control
+typedef struct _DEVICE_C6740_L1P_
+{
+  VUint8  RSVD0[0x20];    // 0x0000
+  VUint32 L1PCFG;         // 0x0020
+  VUint32 L1PCC;          // 0x0024
+  VUint8  RSVD1[0x3FF8];  // 0x0028
+  VUint32 L1PIBAR;        // 0x4020
+  VUint32 L1PIWC;         // 0x4024
+  VUint8  RSVD2[0x1000];  // 0x4028
+  VUint32 L1PINV;         // 0x5028
+}
+DEVICE_C6740_L1PRegs;
+
+#define L1PCTL ((DEVICE_C6740_L1PRegs *) 0x01840000)
+
+// C6740 L1D Control
+typedef struct _DEVICE_C6740_L1D_
+{
+  VUint8  RSVD0[0x40];    // 0x0000
+  VUint32 L1DCFG;         // 0x0040
+  VUint32 L1DCC;          // 0x0044
+  VUint8  RSVD1[0x3FE8];  // 0x0048
+  VUint32 L1DWIBAR;       // 0x4030
+  VUint32 L1DWIWC;        // 0x4034
+  VUint8  RSVD2[0x08];    // 0x4038
+  VUint32 L1DWBAR;        // 0x4040
+  VUint32 L1DWWC;         // 0x4044
+  VUint32 L1DIBAR;        // 0x4048
+  VUint32 L1DIWC;         // 0x404C
+  VUint8  RSVD3[0xFF0];   // 0x4050
+  VUint32 L1DWB;          // 0x5040
+  VUint32 L1DWBINV;       // 0x5044
+  VUint32 L1DINV;         // 0x5048
+}
+DEVICE_C6740_L1DRegs;
+
+#define L1DCTL ((DEVICE_C6740_L1DRegs *) 0x01840000)
+
+
+// C6740 L2 Control
+typedef struct _DEVICE_C6740_L2_
+{
+  VUint32 L2CFG;          // 0x0000
+  VUint8  RSVD0[0x3FFC];  // 0x0004
+  VUint32 L2WBAR;         // 0x4000
+  VUint32 L2WWC;          // 0x4004
+  VUint8  RSVD1[0x08];    // 0x4008
+  VUint32 L2WIBAR;        // 0x4010
+  VUint32 L2WIWC;         // 0x4014
+  VUint32 L2IBAR;         // 0x4018
+  VUint32 L2IWC;          // 0x401C
+  VUint8  RSVD2[0xFE0];   // 0x4020
+  VUint32 L2WB;           // 0x5000
+  VUint32 L2WBINV;        // 0x5004
+  VUint32 L2INV;          // 0x5008
+}
+DEVICE_C6740_L2Regs;
+
+#define L2CTL ((DEVICE_C6740_L2Regs *) 0x01840000)
+
+
+// C6740 Megamodule memory error controller
+typedef struct _DEVICE_C6740_EDC_
+{
+  VUint8  RSVD0[4];     // 0x000
+  VUint32 L2EDSTAT;     // 0x004
+  VUint32 L2EDCMD;      // 0x008
+  VUint32 L2EDADDR;     // 0x00C
+  VUint32 L2EDPEN0;     // 0x010
+  VUint32 L2EDPEN1;     // 0x014
+  VUint32 L2EDCPEC;     // 0x018
+  VUint32 L2EDNPEC;     // 0x01C
+  VUint8  RSVD1[0x3E4]; // 0x020
+  VUint32 L1PEDSTAT;    // 0x404
+  VUint32 L1PEDCMD;     // 0x408
+  VUint32 L1PEDADDR;    // 0x40C
+}
+DEVICE_C6740_EDCRegs;
+
+#define DSP_EDC ((DEVICE_C6740_EDCRegs *) 0x01846000)
+
+
+// C6740 Megamodule Interrupt Controller
+typedef struct _DEVICE_C6740_INTC_
+{
+  VUint32 EVTFLAG[4];     // 0x000
+  VUint8 RSVD0[16];       // 0x010
+  VUint32 EVTSET[4];      // 0x020
+  VUint8 RSVD1[16];       // 0x030
+  VUint32 EVTCLR[4];      // 0x040
+  VUint8 RSVD2[48];       // 0x050
+  VUint32 EVTMASK[4];     // 0x080
+  VUint8 RSVD3[16];       // 0x090
+  VUint32 MEVTFLAG[4];    // 0x0A0
+  VUint8 RSVD4[16];       // 0x0B0
+  VUint32 EXPMASK[4];     // 0x0C0
+  VUint8 RSVD5[16];
+  VUint32 MEXPFLAG[4];
+  VUint8 RSVD6[20];
+  VUint32 INTMUX1;
+  VUint32 INTMUX2;
+  VUint32 INTMUX3;
+  VUint8 RSVD7[48];
+  VUint32 AEGMUX0;
+  VUint32 AEGMUX1;
+  VUint8 RSVD8[56];
+  VUint32 INTXSTAT;
+  VUint32 INTXCLR;
+  VUint32 INTDMASK;
+  VUint8 RSVD9[52];
+  VUint32 EVTASRT;
+}
+DEVICE_C6740_INTCRegs;
+
+#define DSP_INTC ((DEVICE_C6740_INTCRegs *) 0x01800000)
+
+
+// System Control Module register structure
+typedef struct _DEVICE_SYS_MODULE_REGS_
+{
+  VUint32 REVID;              //0x00
+  VUint8  RSVD0[4];           //0x04
+  VUint32 DIEIDR[4];          //0x08
+  VUint32 DEVIDD[2];          //0x18
+  VUint32 BOOTCFG;            //0x20
+  VUint32 CHIPREVID;          //0x24
+  VUint32 FEATURE_ENA;        //0x28
+  VUint32 L2ROMDIV;           //0x2C
+  VUint8  RSVD1[8];           //0x30
+  VUint32 KICKR[2];           //0x38
+  VUint32 HOSTCFG[2];         //0x40
+  VUint8  RSVD2[152];         //0x48
+  VUint32 IRAWSTRAT;          //0xE0
+  VUint32 IENSTAT;            //0xE4
+  VUint32 IENSET;             //0xE8
+  VUint32 IENCLR;             //0xEC
+  VUint32 EOI;                //0xF0
+  VUint32 FLTADDRR;           //0xF4  
+  VUint32 FLTSTAT;            //0xF8
+  VUint32 FLTCLR;             //0xFC
+  VUint8  RSVD3[16];          //0x100
+  VUint32 MSTPRI[3];          //0x110
+  VUint8  RSVD4[4];           //0x11C
+  VUint32 PINMUX[20];         //0x120
+  VUint32 SUSPSRC;            //0x170
+  VUint32 CHIPSIG;            //0x174
+  VUint32 CHIPSIG_CLR;        //0x178
+  VUint32 CFGCHIP[5];         //0x17C
+  VUint8  RSVD5[5];           //0x190
+  VUint32 ROMCHECKSUM[2];     //0x1A0
+}
+DEVICE_SysModuleRegs;
+
+#define SYSTEM ((DEVICE_SysModuleRegs*) 0x01C14000)
+
+#define DEVICE_BOOTCFG_BOOTMODE_MASK    (0x000000FF)
+#define DEVICE_BOOTCFG_BOOTMODE_SHIFT   (0)
+
+#define DEVICE_CHIPREVID_TYPE_MASK      (0x00000030u)
+#define DEVICE_CHIPREVID_TYPE_SHIFT     (4)
+
+
+
+// ARM Interrupt Controller register structure
+typedef struct _DEVICE_AINTC_REGS_
+{
+    VUint32 FIQ0;
+    VUint32 FIQ1;
+    VUint32 IRQ0;
+    VUint32 IRQ1;
+    VUint32 FIQENTRY;
+    VUint32 IRQENTRY;
+    VUint32 EINT0;
+    VUint32 EINT1;
+    VUint32 INTCTL;
+    VUint32 EABASE;
+    VUint8 RSVD0[8];
+    VUint32 INTPRI0;
+    VUint32 INTPRI1;
+    VUint32 INTPRI2;
+    VUint32 INTPRI3;
+    VUint32 INTPRI4;
+    VUint32 INTPRI5;
+    VUint32 INTPRI6;
+    VUint32 INTPRI7;
+}
+DEVICE_AIntcRegs;
+
+#define AINTC ((DEVICE_AIntcRegs*) 0xFFFEE000)
+
+
+// PRU Control register structure
+typedef struct _DEVICE_PRU_CTRL_REGS_
+{
+  VUint32 CONTROL;
+  VUint32 STATUS;
+  VUint32 WAKEUP;
+  VUint32 CYCLECNT;
+  VUint32 STALLCNT;
+  VUint8 RSVD0[12];
+  VUint32 CONTABBLKIDX0;
+  VUint32 CONTABBLKIDX1;
+  VUint32 CONTABPROPTR0;
+  VUint32 CONTABPROPTR1;
+  VUint8 RSVD1[976];
+  VUint32 INTGPR0;
+  VUint32 INTGPR1;
+  VUint32 INTGPR2;
+  VUint32 INTGPR3;
+  VUint32 INTGPR4;
+  VUint32 INTGPR5;
+  VUint32 INTGPR6;
+  VUint32 INTGPR7;
+  VUint32 INTGPR8;
+  VUint32 INTGPR9;
+  VUint32 INTGPR10;
+  VUint32 INTGPR11;
+  VUint32 INTGPR12;
+  VUint32 INTGPR13;
+  VUint32 INTGPR14;
+  VUint32 INTGPR15;
+  VUint32 INTGPR16;
+  VUint32 INTGPR17;
+  VUint32 INTGPR18;
+  VUint32 INTGPR19;
+  VUint32 INTGPR20;
+  VUint32 INTGPR21;
+  VUint32 INTGPR22;
+  VUint32 INTGPR23;
+  VUint32 INTGPR24;
+  VUint32 INTGPR25;
+  VUint32 INTGPR26;
+  VUint32 INTGPR27;
+  VUint32 INTGPR28;
+  VUint32 INTGPR29;
+  VUint32 INTGPR30;
+  VUint32 INTGPR31;
+  VUint32 INTCTER0;
+  VUint32 INTCTER1;
+  VUint32 INTCTER2;
+  VUint32 INTCTER3;
+  VUint32 INTCTER4;
+  VUint32 INTCTER5;
+  VUint32 INTCTER6;
+  VUint32 INTCTER7;
+  VUint32 INTCTER8;
+  VUint32 INTCTER9;
+  VUint32 INTCTER10;
+  VUint32 INTCTER11;
+  VUint32 INTCTER12;
+  VUint32 INTCTER13;
+  VUint32 INTCTER14;
+  VUint32 INTCTER15;
+  VUint32 INTCTER16;
+  VUint32 INTCTER17;
+  VUint32 INTCTER18;
+  VUint32 INTCTER19;
+  VUint32 INTCTER20;
+  VUint32 INTCTER21;
+  VUint32 INTCTER22;
+  VUint32 INTCTER23;
+  VUint32 INTCTER24;
+  VUint32 INTCTER25;
+  VUint32 INTCTER26;
+  VUint32 INTCTER27;
+  VUint32 INTCTER28;
+  VUint32 INTCTER29;
+  VUint32 INTCTER30;
+  VUint32 INTCTER31;
+}
+DEVICE_PRUCtrlRegs;
+
+#define PRU0 ((DEVICE_PRUCtrlRegs *) 0x01C37000)
+#define PRU1 ((DEVICE_PRUCtrlRegs *) 0x01C37800)
+
+#define DEVICE_PRU_CONTROL_COUNTENABLE_MASK       (0x00000008u)
+#define DEVICE_PRU_CONTROL_COUNTENABLE_SHIFT      (3)
+#define DEVICE_PRU_CONTROL_ENABLE_MASK            (0x00000002u)
+#define DEVICE_PRU_CONTROL_ENABLE_SHIFT           (1)
+#define DEVICE_PRU_CONTROL_SOFTRESET_MASK         (0x00000001u)
+#define DEVICE_PRU_CONTROL_SOFTRESET_SHIFT        (0)
+#define DEVICE_PRU_CONTROL_RUNSTATE_MASK          (0x00008000u)
+#define DEVICE_PRU_CONTROL_RUNSTATE_SHIFT         (15)
+
+
+// PLL Register structure
+typedef struct _DEVICE_PLL_REGS_
+{
+  VUint32 PID;            // 0x000
+  VUint8 RSVD0[204];      // 0x004
+  VUint32 SHIFTDIV;       // 0x0D0
+  VUint32 CS0;            // 0x0D4
+  VUint32 DFTCNTR;        // 0x0D8
+  VUint32 DFTCNTRCTRL;    // 0x0DC
+  VUint32 FUSERR;         // 0x0E0
+  VUint32 RSTYPE;         // 0x0E4
+  VUint32 RSTCTRL;        // 0x0E8
+  VUint32 RSTCFG;         // 0x0EC
+  VUint32 RSISO;          // 0x0F0
+  VUint8 RSVD1[12];       // 0x0F4
+  VUint32 PLLCTL;         // 0x100
+  VUint32 OCSEL;          // 0x104
+  VUint32 SECCTL;         // 0x108
+  VUint8 RSVD2[4];        // 0x10C
+  VUint32 PLLM;           // 0x110
+  VUint32 PREDIV;
+  VUint32 PLLDIV1;
+  VUint32 PLLDIV2;
+  VUint32 PLLDIV3;
+  VUint32 OSCDIV1;
+  VUint32 POSTDIV;
+  VUint32 BPDIV;
+  VUint32 WAKEUP;
+  VUint8 RSVD3[4];
+  VUint32 PLLCMD;
+  VUint32 PLLSTAT;
+  VUint32 ALNCTL;
+  VUint32 DCHANGE;
+  VUint32 CKEN;
+  VUint32 CKSTAT;
+  VUint32 SYSTAT;
+  VUint8 RSVD4[12];
+  VUint32 PLLDIV4;
+  VUint32 PLLDIV5;
+  VUint32 PLLDIV6;
+  VUint32 PLLDIV7;
+  VUint32 PLLDIV8;
+  VUint32 PLLDIV9;
+  VUint32 PLLDIV10;
+  VUint32 PLLDIV11;
+  VUint32 PLLDIV12;
+  VUint32 PLLDIV13;
+  VUint32 PLLDIV14;
+  VUint8 RSVD5[4];
+  VUint32 PLLDIV15;
+  VUint8 RSVD6[88];
+  VUint32 PLLHDIVEN;
+  VUint32 EMUCNT0;
+  VUint32 EMUCNT1;
+}
+DEVICE_PLLRegs;
+
+#define PLL0 ((DEVICE_PLLRegs*) 0x01C11000)
+
+#define DEVICE_PLLCTL_PLLEN_MASK    (0x00000001)
+#define DEVICE_PLLCTL_PLLPWRDN_MASK (0x00000002)
+#define DEVICE_PLLCTL_PLLRST_MASK   (0x00000008)
+#define DEVICE_PLLCTL_PLLDIS_MASK   (0x00000010)
+#define DEVICE_PLLCTL_PLLENSRC_MASK (0x00000020)
+#define DEVICE_PLLCTL_CLKMODE_MASK  (0x00000100)
+
+#define DEVICE_PLLCMD_GOSET_MASK    (0x00000001)
+#define DEVICE_PLLSTAT_GOSTAT_MASK  (0x00000001)
+#define DEVICE_PLLDIV_EN_MASK       (0x00008000)
+
+// Power/Sleep Ctrl Register structure
+typedef struct _DEVICE_PSC_REGS_
+{
+  VUint32 PID;        // 0x000
+  VUint8 RSVD0[16];   // 0x004
+  VUint8 RSVD1[4];    // 0x014
+  VUint32 INTEVAL;    // 0x018
+  VUint8 RSVD2[36];   // 0x01C
+  VUint32 MERRPR0;    // 0x040
+  VUint32 MERRPR1;    // 0x044
+  VUint8 RSVD3[8];    // 0x048
+  VUint32 MERRCR0;    // 0x050
+  VUint32 MERRCR1;    // 0x054
+  VUint8 RSVD4[8];    // 0x058
+  VUint32 PERRPR;     // 0x060
+  VUint8 RSVD5[4];    // 0x064
+  VUint32 PERRCR;     // 0x068
+  VUint8 RSVD6[4];    // 0x06C
+  VUint32 EPCPR;      // 0x070
+  VUint8 RSVD7[4];    // 0x074
+  VUint32 EPCCR;      // 0x078
+  VUint8 RSVD8[144];  // 0x07C
+  VUint8 RSVD9[20];   // 0x10C
+  VUint32 PTCMD;      // 0x120
+  VUint8 RSVD10[4];   // 0x124
+  VUint32 PTSTAT;     // 0x128
+  VUint8 RSVD11[212]; // 0x12C
+  VUint32 PDSTAT0;    // 0x200
+  VUint32 PDSTAT1;    // 0x204
+  VUint8 RSVD12[248]; // 0x208
+  VUint32 PDCTL0;     // 0x300
+  VUint32 PDCTL1;     // 0x304
+  VUint8 RSVD13[536]; // 0x308
+  VUint32 MCKOUT0;    // 0x520
+  VUint32 MCKOUT1;    // 0x524
+  VUint8 RSVD14[728]; // 0x528
+  VUint32 MDSTAT[41]; // 0x800
+  VUint8 RSVD15[348]; // 0x8A4
+  VUint32 MDCTL[41];  // 0xA00
+}
+DEVICE_PSCRegs;
+
+#define PSC0 ((DEVICE_PSCRegs*) 0x01C10000)
+#define PSC1 ((DEVICE_PSCRegs*) 0x01E27000)
+
+#define EMURSTIE_MASK       (0x00000200)
+
+#define PSC_ENABLE          (0x3)
+#define PSC_DISABLE         (0x2)
+#define PSC_SYNCRESET       (0x1)
+#define PSC_SWRSTDISABLE    (0x0)
+
+#define PSC_MDCTL_LRSTZ_MASK     (0x00000100u)
+#define PSC_MDCTL_LRSTZ_SHIFT    (0x00000008u)
+
+#define PSCNUM0             (0x0)
+#define PSCNUM1             (0x1)
+
+#define PD0                 (0x0)
+#define PD1                 (0x1)
+
+// PSC0 (Matrix) defines
+#define LPSC_TPCC           (0)
+#define LPSC_TPTC0          (1)
+#define LPSC_TPTC1          (2)
+#define LPSC_EMIFA          (3)
+#define LPSC_SPI0           (4)
+#define LPSC_MMCSD0         (5)
+#define LPSC_ARMINTC        (6)
+#define LPSC_ARMRAM         (7)
+#define LPSC_SCnKM          (8)
+#define LPSC_UART0          (9)
+#define LPSC_PRU            (13)
+#define LPSC_ARM            (14)
+#define LPSC_DSP            (15)
+
+// PSC1 (Subchip) defines
+#define LPSC_USB0           (1)
+#define LPSC_USB1           (2)
+#define LPSC_GPIO           (3)
+#define LPSC_UHPI0          (4)
+#define LPSC_EMAC           (5)
+#define LPSC_EMIFB          (6)
+#define LPSC_McASP0         (7)
+#define LPSC_McASP1         (8)
+#define LPSC_McASP2         (9)
+#define LPSC_SPI1           (10)
+#define LPSC_I2C1           (11)
+#define LPSC_UART1          (12)
+#define LPSC_UART2          (13)
+#define LPSC_L3CBA          (31)
+// AEMIF Register structure - From EMIF 2.5 Spec
+typedef struct _DEVICE_EMIF25_REGS_
+{
+  VUint32 ERCSR;              // 0x00
+  VUint32 AWCCR;              // 0x04
+  VUint32 SDBCR;              // 0x08
+  VUint32 SDRCR;              // 0x0C
+
+  VUint32 A1CR;               // 0x10
+  VUint32 A2CR;               // 0x14
+  VUint32 A3CR;               // 0x18
+  VUint32 A4CR;               // 0x1C
+
+  VUint32 SDTIMR;             // 0x20
+  VUint32 SDRSTAT;            // 0x24
+  VUint32 DDRPHYCR;           // 0x28
+  VUint32 DDRPHYSR;           // 0x2C
+
+  VUint32 SDRACCR;            // 0x30
+  VUint32 SDRACT;             // 0x34
+  VUint32 DDRPHYREV;          // 0x38
+  VUint32 SDRSRPDEXIT;        // 0x3C
+
+  VUint32 EIRR;               // 0x40
+  VUint32 EIMR;               // 0x44
+  VUint32 EIMSR;              // 0x48
+  VUint32 EIMCR;              // 0x4C
+
+  VUint32 IOCR;               // 0x50
+  VUint32 IOSR;               // 0x54
+  VUint8 RSVD0[4];            // 0x58
+  VUint32 ONENANDCTL;         // 0x5C  
+
+  VUint32 NANDFCR;            // 0x60
+  VUint32 NANDFSR;            // 0x64
+  VUint32 PMCR;               // 0x68
+  VUint8 RSVD1[4];            // 0x6C
+
+  VUint32 NANDF1ECC;          // 0x70
+  VUint32 NANDF2ECC;          // 0x74
+  VUint32 NANDF3ECC;          // 0x78
+  VUint32 NANDF4ECC;          // 0x7C
+
+  VUint8 RSVD2[4];            // 0x80
+  VUint32 IODFTEXECNT;        // 0x84
+  VUint32 IODFTGBLCTRL;       // 0x88
+  VUint8 RSVD3[4];            // 0x8C
+
+  VUint32 IODFTMISRLSB;       // 0x90
+  VUint32 IODFTMISRMID;       // 0x94
+  VUint32 IODFTMISRMSB;       // 0x98
+  VUint8 RSVD4[20];           // 0x9C
+
+  VUint32 MODRELNUM;          // 0xB0
+  VUint8 RSVD5[8];            // 0xB4
+  VUint32 NAND4BITECCLOAD;    // 0xBC
+
+  VUint32 NAND4BITECC1;       // 0xC0
+  VUint32 NAND4BITECC2;       // 0xC4
+  VUint32 NAND4BITECC3;       // 0xC8
+  VUint32 NAND4BITECC4;       // 0xCC
+
+  VUint32 NANDERRADD1;        // 0xD0
+  VUint32 NANDERRADD2;        // 0xD4
+  VUint32 NANDERRVAL1;        // 0xD8
+  VUint32 NANDERRVAL2;        // 0xDC
+}
+DEVICE_Emif25Regs;
+
+#define AEMIF ((DEVICE_Emif25Regs*) 0x68000000u)
+
+#define DEVICE_EMIF_NUMBER_CE_REGION        (4)
+#define DEVICE_EMIF_FIRST_CE_START_ADDR                   (0x60000000u)
+#define DEVICE_EMIF_INTER_CE_REGION_SIZE                  (0x02000000u)
+#define DEVICE_EMIF_NAND_BOOT_BASE                                               (0x62000000u)
+#define DEVICE_EMIF_NOR_BOOT_BASE                                                (0x60000000u)
+
+#define DEVICE_EMIF_AxCR_SS_MASK                          (0x80000000u)
+#define DEVICE_EMIF_AxCR_SS_SHIFT                         (31)
+#define DEVICE_EMIF_AxCR_EW_MASK                          (0x40000000u)
+#define DEVICE_EMIF_AxCR_EW_SHIFT                         (30)
+#define DEVICE_EMIF_AxCR_WSETUP_MASK                      (0x3C000000u)
+#define DEVICE_EMIF_AxCR_WSETUP_SHIFT                     (26)
+#define DEVICE_EMIF_AxCR_WSTROBE_MASK                     (0x03F00000u)
+#define DEVICE_EMIF_AxCR_WSTROBE_SHIFT                    (20)
+#define DEVICE_EMIF_AxCR_WHOLD_MASK                       (0x000E0000u)
+#define DEVICE_EMIF_AxCR_WHOLD_SHIFT                      (17)
+#define DEVICE_EMIF_AxCR_RSETUP_MASK                      (0x0001E000u)
+#define DEVICE_EMIF_AxCR_RSETUP_SHIFT                     (13)
+#define DEVICE_EMIF_AxCR_RSTROBE_MASK                     (0x00001F80u)
+#define DEVICE_EMIF_AxCR_RSTROBE_SHIFT                    (7)
+#define DEVICE_EMIF_AxCR_RHOLD_MASK                       (0x00000070u)
+#define DEVICE_EMIF_AxCR_RHOLD_SHIFT                      (4)
+#define DEVICE_EMIF_AxCR_TA_MASK                          (0x0000000Cu)
+#define DEVICE_EMIF_AxCR_TA_SHIFT                         (2)
+#define DEVICE_EMIF_AxCR_ASIZE_MASK                       (0x00000003u)
+#define DEVICE_EMIF_AxCR_ASIZE_SHIFT                      (0)
+
+#define DEVICE_EMIF_AWCC_WAITSTATE_MASK                   (0x000000FF)
+
+#define DEVICE_EMIF_NANDFCR_4BITECC_SEL_MASK            (0x00000030)
+#define DEVICE_EMIF_NANDFCR_4BITECC_SEL_SHIFT           (4)
+
+#define DEVICE_EMIF_NANDFCR_4BITECC_START_MASK           (0x00001000)
+#define DEVICE_EMIF_NANDFCR_4BITECC_START_SHIFT          (12)
+#define DEVICE_EMIF_NANDFCR_4BITECC_ADD_CALC_START_MASK  (0x00002000)
+#define DEVICE_EMIF_NANDFCR_4BITECC_ADD_CALC_START_SHIFT (13)
+
+#define DEVICE_EMIF_NANDFSR_READY_MASK                    (0x00000001)
+#define DEVICE_EMIF_NANDFSR_READY_SHIFT                   (0)
+
+#define DEVICE_EMIF_NANDFSR_ECC_STATE_MASK              (0x00000F00)
+#define DEVICE_EMIF_NANDFSR_ECC_STATE_SHIFT             (8)
+#define DEVICE_EMIF_NANDFSR_ECC_ERRNUM_MASK             (0x00030000)
+#define DEVICE_EMIF_NANDFSR_ECC_ERRNUM_SHIFT            (16)
+
+
+typedef struct _DEVICE_EMIF3C_REGS_
+{
+  VUint32 ERCSR;
+  VUint32 SDRSTAT;
+  VUint32 SDCR;
+  VUint32 SDRCR;
+  VUint32 SDTIMR;
+  VUint32 SDTIMR2;
+  VUint8 RSVD0[4];
+  VUint32 SDCR2;
+  VUint32 PBBPR;
+  VUint8 RSVD1[4];
+  VUint32 VBCFG1;
+  VUint32 VBCFG2;
+  VUint8 RSVD2[16];
+  VUint32 PERFC1R;
+  VUint32 PERFC2R;
+  VUint32 PCCR;
+  VUint32 PCMRSR;
+  VUint32 PCTR;
+  VUint8 RSVD3[12];
+  VUint32 IODFTGBLCTRL;
+  VUint32 IODFTMISRR;
+  VUint32 IODFTMISADDRRR;
+  VUint32 IODFTMISR1R;
+  VUint32 IODFTMISR2R;
+  VUint32 IODFTMISR3R;
+  VUint8 RSVD4[8];
+  VUint32 ASYNCCS2CR;
+  VUint32 ASYNCCS3CR;
+  VUint32 ASYNCCS4CR;
+  VUint32 ASYNCCS5CR;
+  VUint8 RSVD5[16];
+  VUint32 AWCCR;
+  VUint8 RSVD6[28];
+  VUint32 IRR;
+  VUint32 IMR;
+  VUint32 IMSR;
+  VUint32 IMCR;
+  VUint8 RSVD7[16];
+  VUint32 DDRPHYREV;
+  VUint32 DDRPHYC1R;
+  VUint32 DDRPHYC2R;
+  VUint32 DDRPHYC3R;
+}
+DEVICE_Emif3Regs;
+
+#define EMIF3C ((DEVICE_Emif3Regs*) 0xB0000000u)
+
+#define DEVICE_SDCR_NM_MASK     (0x00004000u)
+#define DEVICE_SDCR_NM_SHIFT    (14)
+
+
+
+
+// UART Register structure - See sprued9b.pdf for more details.
+typedef struct _DEVICE_UART_REGS_
+{
+  VUint32 RBR;
+  VUint32 IER;
+  VUint32 IIR;
+  VUint32 LCR;
+  VUint32 MCR;
+  VUint32 LSR;
+  VUint32 MSR;
+  VUint32 SCR;
+  VUint8  DLL;
+  VUint8  RSVD1[3];
+  VUint8  DLH;
+  VUint8  RSVD2[3];  
+  VUint32 PID1;
+  VUint32 PID2;
+  VUint32 PWREMU_MGMT;
+  VUint32 MDR;
+}
+DEVICE_UARTRegs;
+
+#define THR RBR
+#define FCR IIR
+
+#define UART_PERIPHERAL_CNT (3)
+
+#define UART0 ((DEVICE_UARTRegs*) 0x01C42000)
+#define UART1 ((DEVICE_UARTRegs*) 0x01D0C000)
+#define UART2 ((DEVICE_UARTRegs*) 0x01D0D000)
+
+#define DEVICE_UART0_DESIRED_BAUD   (115200)
+#define DEVICE_UART0_OVERSAMPLE_CNT (16)
+
+#define DEVICE_UART_DLL_MASK                  (0x000000FFu)
+#define DEVICE_UART_DLL_SHIFT                 (0)
+#define DEVICE_UART_DLH_MASK                  (0x000000FFu)
+#define DEVICE_UART_DLH_SHIFT                 (0)
+
+#define DEVICE_UART_PWREMU_MGMT_URST_MASK     (0x00008000u)
+#define DEVICE_UART_PWREMU_MGMT_URST_SHIFT    (15)
+#define DEVICE_UART_PWREMU_MGMT_UTRST_MASK    (0x00004000u)
+#define DEVICE_UART_PWREMU_MGMT_UTRST_SHIFT   (14)
+#define DEVICE_UART_PWREMU_MGMT_URRST_MASK    (0x00002000u)
+#define DEVICE_UART_PWREMU_MGMT_URRST_SHIFT   (13)
+
+#define DEVICE_UART_FCR_RXFIFTL_MASK          (0x000000C0u)
+#define DEVICE_UART_FCR_RXFIFTL_SHIFT         (6)
+#define DEVICE_UART_FCR_DMAMODE1_MASK         (0x00000008u)
+#define DEVICE_UART_FCR_DMAMODE1_SHIFT        (3)
+#define DEVICE_UART_FCR_TXCLR_MASK            (0x00000004u)
+#define DEVICE_UART_FCR_TXCLR_SHIFT           (2)
+#define DEVICE_UART_FCR_RXCLR_MASK            (0x00000002u)
+#define DEVICE_UART_FCR_RXCLR_SHIFT           (1)
+#define DEVICE_UART_FCR_FIFOEN_MASK           (0x00000001u)
+#define DEVICE_UART_FCR_FIFOEN_SHIFT          (0)
+
+#define DEVICE_UART_LSR_RXFIFOE_MASK          (0x00000080u)
+#define DEVICE_UART_LSR_RXFIFOE_SHIFT         (7)
+#define DEVICE_UART_LSR_TEMT_MASK             (0x00000040u)
+#define DEVICE_UART_LSR_TEMT_SHIFT            (6)
+#define DEVICE_UART_LSR_THRE_MASK             (0x00000020u)
+#define DEVICE_UART_LSR_THRE_SHIFT            (5)
+#define DEVICE_UART_LSR_BI_MASK               (0x00000010u)
+#define DEVICE_UART_LSR_BI_SHIFT              (4)
+#define DEVICE_UART_LSR_FE_MASK               (0x00000008u)
+#define DEVICE_UART_LSR_FE_SHIFT              (3)
+#define DEVICE_UART_LSR_PE_MASK               (0x00000004u)
+#define DEVICE_UART_LSR_PE_SHIFT              (2)
+#define DEVICE_UART_LSR_OE_MASK               (0x00000002u)
+#define DEVICE_UART_LSR_OE_SHIFT              (1)
+#define DEVICE_UART_LSR_DR_MASK               (0x00000001u)
+#define DEVICE_UART_LSR_DR_SHIFT              (0)
+
+
+// Timer Register structure - See spruee5a.pdf for more details.
+typedef struct _DEVICE_TIMER_REGS_
+{
+    VUint32 PID12;          // 0x00
+    VUint32 EMUMGT_CLKSPD;  // 0x04
+    VUint8  RSVD0[8];       // 0x08
+    VUint32 TIM12;          // 0x10
+    VUint32 TIM34;          // 0x14
+    VUint32 PRD12;          // 0x18
+    VUint32 PRD34;          // 0x1C
+    VUint32 TCR;            // 0x20
+    VUint32 TGCR;           // 0x24
+    VUint32 WDTCR;          // 0x28
+    VUint8  RSVD1[12];      // 0x2C
+    VUint32 REL12;          // 0x34
+    VUint32 REL34;          // 0x38
+    VUint32 CAP12;          // 0x3C
+    VUint32 CAP34;          // 0x40
+    VUint32 INTCTL_STAT;    // 0x44
+}
+DEVICE_TimerRegs;
+
+#define TIMER0 ((DEVICE_TimerRegs*) 0x01C21400)
+
+// I2C Register structure - See spruee0a.pdf for more details.
+typedef struct _DEVICE_I2C_REGS_
+{
+    VUint32 ICOAR;      // 0x00
+    VUint32 ICIMR;      // 0x04
+    VUint32 ICSTR;      // 0x08
+    VUint32 ICCLKL;     // 0x0C
+    VUint32 ICCLKH;     // 0x10
+    VUint32 ICCNT;      // 0x14
+    VUint32 ICDRR;      // 0x18
+    VUint32 ICSAR;      // 0x1C
+    VUint32 ICDXR;      // 0x20
+    VUint32 ICMDR;      // 0x24
+    VUint32 ICIVR;      // 0x28
+    VUint32 ICEMDR;     // 0x2C
+    VUint32 ICPSC;      // 0x30
+    VUint32 ICPID1;     // 0x34
+    VUint32 ICPID2;     // 0x38
+}
+DEVICE_I2CRegs;
+
+#define I2C0 ((DEVICE_I2CRegs*) 0x01C22000u)
+#define I2C1 ((DEVICE_I2CRegs*) 0x01E28000u)
+
+#define I2C_PERIPHERAL_CNT (2)
+
+#define DEVICE_I2C_TARGET_FREQ      (200000u)
+#define DEVICE_I2C_OWN_ADDRESS      (0x10)
+
+#define I2C_ICMDR_NACKMOD       (0x00008000)
+#define I2C_ICMDR_FRE           (0x00004000)
+#define I2C_ICMDR_STT           (0x00002000)
+#define I2C_ICMDR_STP           (0x00000800)
+#define I2C_ICMDR_MST           (0x00000400)
+#define I2C_ICMDR_TRX           (0x00000200)
+#define I2C_ICMDR_XA            (0x00000100)
+#define I2C_ICMDR_RM            (0x00000080)
+#define I2C_ICMDR_DLB           (0x00000040)
+#define I2C_ICMDR_IRS           (0x00000020)
+#define I2C_ICMDR_STB           (0x00000010)
+#define I2C_ICMDR_FDF           (0x00000008)
+#define I2C_ICMDR_BC8           (0x00000007)
+
+#define I2C_ICSTR_AL_MSK        (0x00000001)
+#define I2C_ICSTR_NACK_MSK      (0x00000002)
+#define I2C_ICSTR_ARDY_MSK      (0x00000004)
+#define I2C_ICSTR_ICRRDY_MSK    (0x00000008)
+#define I2C_ICSTR_ICXRDY_MSK    (0x00000010)
+#define I2C_ICSTR_SCD_MSK       (0x00000020)
+#define I2C_ICSTR_BB_MSK        (0x00001000)
+
+#define I2C_ICEMDR_EXTMODE      (0x00000000)
+
+// SPI Register structure
+typedef struct _DEVICE_SPI_REGS_
+{
+  VUint32 SPIGCR0;          // 0x00
+  VUint32 SPIGCR1;          // 0x04
+  VUint32 SPIINT;           // 0x08
+  VUint32 SPILVL;           // 0x0C
+  VUint32 SPIFLG;           // 0x10
+  VUint32 SPIPC0;           // 0x14
+  VUint32 SPIPC1;           // 0x18
+  VUint32 SPIPC2;           // 0x1C
+  VUint32 SPIPC3;           // 0x20
+  VUint32 SPIPC4;           // 0x24
+  VUint32 SPIPC5;           // 0x28
+  VUint32 SPIPC6;           // 0x2C
+  VUint32 SPIPC7;           // 0x30
+  VUint32 SPIPC8;           // 0x34
+  VUint32 SPIDAT[2];        // 0x38
+  VUint32 SPIBUF;           // 0x40
+  VUint32 SPIEMU;           // 0x44
+  VUint32 SPIDELAY;         // 0x48
+  VUint32 SPIDEF;           // 0x4C
+  VUint32 SPIFMT[4];        // 0x50
+  VUint32 TGINTVEC[2];      // 0x60
+  VUint32 RSVD0[2];         // 0x68
+  VUint32 MIBSPIE;          // 0x70
+}
+DEVICE_SPIRegs;
+
+#define SPI0 ((DEVICE_SPIRegs *) 0x01C41000u)
+#define SPI1 ((DEVICE_SPIRegs *) 0x01E12000u)
+
+#define SPI_PERIPHERAL_CNT      (2)
+
+#define DEVICE_SPI_SPIGCR1_SPIEN_MASK     (0x01000000u)
+#define DEVICE_SPI_SPIGCR1_SPIEN_SHIFT    (24)
+
+typedef struct _DEVICE_SDMMC_REGS_
+{
+  VUint32 MMCCTL;
+  VUint32 MMCCLK;
+  VUint32 MMCST0;
+  VUint32 MMCST1;
+  VUint32 MMCIM;
+  VUint32 MMCTOR;
+  VUint32 MMCTOD;
+  VUint32 MMCBLEN;
+  VUint32 MMCNBLK;
+  VUint32 MMCNBLC;
+  VUint32 MMCDRR;
+  VUint32 MMCDXR;
+  VUint32 MMCCMD;
+  VUint32 MMCARGHL;
+  VUint32 MMCRSP01;
+  VUint32 MMCRSP23;
+  VUint32 MMCRSP45;
+  VUint32 MMCRSP67;
+  VUint32 MMCDRSP;
+  VUint8 RSVD0[4];
+  VUint32 MMCCIDX;
+  VUint8 RSVD1[16];
+  VUint32 SDIOCTL;
+  VUint32 SDIOST0;
+  VUint32 SDIOIEN;
+  VUint32 SDIOIST;
+  VUint32 MMCFIFOCTL;
+}
+DEVICE_SDMMCRegs;
+
+#define SDMMC0 ((DEVICE_SDMMCRegs *) 0x01C40000)
+#define SDMMC1 ((DEVICE_SDMMCRegs *) 0x01E1B000)
+
+#define SDMMC_PERIPHERAL_CNT (2)
+
+
+// GPIO Register structures
+typedef struct _DEVICE_GPIO_BANK_REGS_
+{
+  VUint16 DIR[2];
+  VUint16 OUT_DATA[2];
+  VUint16 SET_DATA[2];
+  VUint16 CLR_DATA[2];
+  VUint16 IN_DATA[2];
+  VUint16 SET_RIS_TRIG[2];
+  VUint16 CLR_RIS_TRIG[2];
+  VUint16 SET_FAL_TRIG[2];
+  VUint16 CLR_FAL_TRIG[2];
+  VUint16 INTSTAT[2];
+}
+DEVICE_GPIOBankRegs;
+
+typedef struct _DEVICE_GPIO_REGS_
+{
+  VUint32 PID;
+  VUint32 PCR;
+  VUint32 BINTEN;
+  VUint8 RSVD0[4];
+  DEVICE_GPIOBankRegs BANKPAIR[4];
+} DEVICE_GPIORegs;
+
+#define GPIO ((DEVICE_GPIORegs *) 0x01E26000u)
+
+
+
+/***********************************************************
+* Global Function Declarations                             *
+***********************************************************/
+
+// Execute LPSC state transition
+extern __FAR__ void    DEVICE_LPSCTransition(Uint8 pscnum, Uint8 module, Uint8 domain, Uint8 state);
+
+// Pinmux control function
+extern __FAR__ void    DEVICE_pinmuxControl(Uint32 regOffset, Uint32 mask, Uint32 value);
+
+// Kick register lock/unlock functions
+extern __FAR__ void    DEVICE_kickUnlock(void);
+extern __FAR__ void    DEVICE_kickLock(void);
+
+// Initialization prototypes
+extern __FAR__ Uint32  DEVICE_init(void);
+extern __FAR__ void    DEVICE_PSCInit();
+extern __FAR__ Uint32  DEVICE_PLL0Init(Uint8 clk_src,Uint8 pllm, Uint8 postdiv, Uint8 div3, Uint8 div5, Uint8 div7, Uint16 lock_time );
+extern __FAR__ Uint32  DEVICE_ExternalMemInit(Uint32 sdcr, Uint32 sdtimr1, Uint32 sdtimr2, Uint32 sdrcr, Bool use45Div);
+
+// Peripheral Initialization prototypes
+extern __FAR__ Uint32  DEVICE_UARTInit(Uint8 periphNum);
+extern __FAR__ Uint32  DEVICE_SPIInit(Uint8 periphNum);
+extern __FAR__ Uint32  DEVICE_I2CInit(Uint8 periphNum);
+extern __FAR__ Uint32  DEVICE_AsyncMemInit(Uint8 interfaceNum);
+extern __FAR__ Uint32  DEVICE_TIMER0Init(void);
+
+// Device boot status functions
+extern __FAR__ DEVICE_BootMode      DEVICE_bootMode( void );
+extern __FAR__ DEVICE_BootPeripheral DEVICE_bootPeripheral(void);
+extern __FAR__ DEVICE_BusWidth      DEVICE_emifBusWidth( void );
+extern __FAR__ DEVICE_ChipRevIDType DEVICE_chipRevIDType( void );
+
+extern __FAR__ void    DEVICE_TIMER0Start(void);
+extern __FAR__ void    DEVICE_TIMER0Stop(void);
+extern __FAR__ Uint32  DEVICE_TIMER0Status(void);
+
+
+/***********************************************************
+* End file                                                 *
+***********************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // End _DEVICE_H_
+
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/Common/include/device_async_mem.h b/tools/omapl13x_boot_utils/OMAP-L137/Common/include/device_async_mem.h
new file mode 100644 (file)
index 0000000..5c6c416
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * device_async_mem.h
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+/* --------------------------------------------------------------------------
+  FILE        : device_async_mem.h
+  PROJECT     : TI Booting and Flashing Utilities
+  AUTHOR      : Daniel Allred
+  DESC        : Provides device differentiation for the project files. This
+                file MUST be modified to match the device/platform specifics.
+----------------------------------------------------------------------------- */
+
+#ifndef _DEVICE_ASYNC_MEM_H_
+#define _DEVICE_ASYNC_MEM_H_
+
+#include "tistdtypes.h"
+#include "async_mem.h"
+
+// Prevent C++ name mangling
+#ifdef __cplusplus
+extern far "c" {
+#endif
+
+/***********************************************************
+* Global Macro Declarations                                *
+***********************************************************/
+
+#define DEVICE_ASYNC_MEM_INTERFACE_CNT  (1)
+#define DEVICE_ASYNC_MEM0_REGION_CNT    (4)
+
+#define DEVICE_ASYNC_MEM_NORBOOT_INTERFACE    (0)
+#define DEVICE_ASYNC_MEM_NORBOOT_REGION       (0)
+
+#define DEVICE_ASYNC_MEM_NANDBOOT_INTERFACE   (0)
+#define DEVICE_ASYNC_MEM_NANDBOOT_REGION      (1)
+#define DEVICE_ASYNC_MEM_NANDBOOT_BUSWIDTH    (DEVICE_BUSWIDTH_8BIT)
+
+#define DEVICE_ASYNC_MEM_ONENAND_INTERFACE    (0)
+#define DEVICE_ASYNC_MEM_ONENAND_REGION       (0)
+
+
+/***********************************************************
+* Global Typedef Declarations                              *
+***********************************************************/
+
+
+/***********************************************************
+* Global Variable Declarations                             *
+***********************************************************/
+
+extern __FAR__ const ASYNC_MEM_DEVICE_InterfaceObj DEVICE_ASYNC_MEM_interfaces[];
+extern __FAR__ const ASYNC_MEM_DEVICE_InfoObj DEVICE_ASYNC_MEM_info;
+
+
+/***********************************************************
+* Global Function Declarations                             *
+***********************************************************/
+
+
+/***********************************************************
+* End file                                                 *
+***********************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // End _DEVICE_ASYNC_MEM_H_
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/Common/include/device_nand.h b/tools/omapl13x_boot_utils/OMAP-L137/Common/include/device_nand.h
new file mode 100644 (file)
index 0000000..04e5758
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * device_nand.h
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+/* --------------------------------------------------------------------------
+  FILE        : device_nand.h
+  PROJECT     : TI Booting and Flashing Utilities
+  AUTHOR      : Daniel Allred
+  DESC        : Provides device differentiation for the project files. This
+                file MUST be modified to match the device specifics.
+----------------------------------------------------------------------------- */
+
+#ifndef _DEVICE_NAND_H_
+#define _DEVICE_NAND_H_
+
+#include "tistdtypes.h"
+
+// Prevent C++ name mangling
+#ifdef __cplusplus
+extern far "c" {
+#endif
+
+/***********************************************************
+* Global Macro Declarations                                *
+***********************************************************/
+
+#define DEVICE_NAND_DATA_OFFSET        (0x00000000u)
+#define DEVICE_NAND_ALE_OFFSET         (0x00000008u)
+#define DEVICE_NAND_CLE_OFFSET         (0x00000010u)
+#define DEVICE_NAND_TIMEOUT            (10240)
+
+#define DEVICE_NAND_MAX_BYTES_PER_OP       (512)   // Max Bytes per operation (EMIF IP constrained)
+#define DEVICE_NAND_MAX_SPAREBYTES_PER_OP  (16)    // Max Spare Bytes per operation
+#define DEVICE_NAND_MIN_SPAREBYTES_PER_OP  (10)    // Min Spare Bytes per operation (ECC operation constrained)
+
+// Defines which NAND blocks the RBL will search in for a UBL image
+#define DEVICE_NAND_RBL_SEARCH_START_BLOCK     (1)
+#define DEVICE_NAND_RBL_SEARCH_END_BLOCK       (5)
+
+
+#define DEVICE_NAND_UBL_SEARCH_START_BLOCK     (6)  //FIX Me;temporary memory addr wrong
+#define DEVICE_NAND_UBL_SEARCH_END_BLOCK       (50) //FIX Me;temporary memory addr wrong
+#define DEVICE_NAND_ARMUBL_SEARCH_START_BLOCK  (2)
+#define DEVICE_NAND_ARMUBL_SEARCH_END_BLOCK    (24)
+#define DEVICE_NAND_UBOOT_SEARCH_START_BLOCK   (4)
+#define DEVICE_NAND_UBOOT_SEARCH_END_BLOCK     (24)
+/******************************************************
+* Global Typedef declarations                         *
+******************************************************/
+
+
+/***********************************************************
+* Global Function Declarations                             *
+***********************************************************/
+
+
+/***********************************************************
+* End file                                                 *
+***********************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // End _DEVICE_NAND_H_
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/Common/include/device_spi.h b/tools/omapl13x_boot_utils/OMAP-L137/Common/include/device_spi.h
new file mode 100644 (file)
index 0000000..ce27651
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * device_spi.h
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+/* --------------------------------------------------------------------------
+  FILE        : device_spi.h
+  PROJECT     : TI Booting and Flashing Utilities
+  AUTHOR      : Daniel Allred
+  DESC        : Provides device differentiation for the project files. This
+                file MUST be modified to match the device/platform specifics.
+----------------------------------------------------------------------------- */
+
+#ifndef _DEVICE_SPI_H_
+#define _DEVICE_SPI_H_
+
+#include "tistdtypes.h"
+#include "spi_mem.h"
+#include "spi.h"
+
+// Prevent C++ name mangling
+#ifdef __cplusplus
+extern far "c" {
+#endif
+
+/***********************************************************
+* Global Macro Declarations                                *
+***********************************************************/
+
+#define DEVICE_SPI_TIMEOUT            (10240)
+#define DEVICE_SPI_DATOFFSET          (1)
+
+#define DEVICE_SPIBOOT_PERIPHNUM          (0)
+#define DEVICE_SPIBOOT_CSNUM              (0)
+
+#define DEVICE_SPI_UBL_HDR_OFFSET     (0*1024)
+#define DEVICE_SPI_APP_HDR_OFFSET     (64*1024)
+
+
+/***********************************************************
+* Global Typedef Declarations                              *
+***********************************************************/
+
+
+/***********************************************************
+* Global Variable Declarations                             *
+***********************************************************/
+
+extern __FAR__ SPI_ConfigHandle const hDEVICE_SPI_config;
+extern __FAR__ SPI_MEM_ParamsHandle const hDEVICE_SPI_MEM_params;
+
+
+/***********************************************************
+* Global Function Declarations                             *
+***********************************************************/
+
+
+/***********************************************************
+* End file                                                 *
+***********************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // End _DEVICE_SPI_H_
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/Common/include/device_uart.h b/tools/omapl13x_boot_utils/OMAP-L137/Common/include/device_uart.h
new file mode 100644 (file)
index 0000000..9af06ae
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * device_uart.h
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+/* --------------------------------------------------------------------------
+  FILE        : device_uart.h
+  PROJECT     : TI Booting and Flashing Utilities
+  AUTHOR      : Daniel Allred
+  DESC        : Provides device differentiation for the project files. This
+                file MUST be modified to match the device specifics.
+----------------------------------------------------------------------------- */
+
+#ifndef _DEVICE_UART_H_
+#define _DEVICE_UART_H_
+
+#include "tistdtypes.h"
+#include "uart.h"
+
+// Prevent C++ name mangling
+#ifdef __cplusplus
+extern far "c" {
+#endif
+
+/***********************************************************
+* Global Macro Declarations                                *
+***********************************************************/
+
+#define DEVICE_UART_TIMEOUT           (10240)
+#define DEVICE_UART_PERIPHNUM         (2)
+
+
+/***********************************************************
+* Global Typedef Declarations                              *
+***********************************************************/
+
+
+/***********************************************************
+* Global Variable Declarations                             *
+***********************************************************/
+
+extern __FAR__ UART_ConfigHandle const hDEVICE_UART_config;
+
+
+/***********************************************************
+* Global Function Declarations                             *
+***********************************************************/
+
+
+/***********************************************************
+* End file                                                 *
+***********************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // End _DEVICE_SPI_H_
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/Common/include/tps65023.h b/tools/omapl13x_boot_utils/OMAP-L137/Common/include/tps65023.h
new file mode 100644 (file)
index 0000000..5d56c2c
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * tps65023.h
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+/*
+ * TI Booting and Flashing Utilities
+ *
+ * Provides device differentiation for the project files. This file MUST be
+ * modified to match the device specifics.
+ *
+ * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as 
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+/* --------------------------------------------------------------------------
+  AUTHOR      : Platform Support Group
+ --------------------------------------------------------------------------- */
+//I2C functions
+#include "i2c.h"
+
+/******************************************************
+* Global Typedef declarations                         *
+******************************************************/
+//Structure to hold the TPS 65023 related details
+typedef struct tps65023_pmic {
+    I2C_ConfigObj i2cConfig;
+    I2C_InfoHandle       hI2cInfo;
+}TPS_ConfigObj;
+
+#define TPS_MAX_NUM_DEVICES     1u
+#define TPS_REG_OFFSET_VERSION  0x00u
+#define TPS_REG_OFFSET_PGOODZ   0x01u
+#define TPS_REG_OFFSET_MASK     0x02u
+#define TPS_REG_OFFSET_REGCTRL  0x03u
+#define TPS_REG_OFFSET_CONCTRL  0x04u
+#define TPS_REG_OFFSET_CONCTRL2 0x05u
+#define TPS_REG_OFFSET_DEFCORE  0x06u
+#define TPS_REG_OFFSET_DEFSLEW  0x07u
+#define TPS_REG_OFFSET_LDOCTRL  0x08u
+
+/* Valid voltage ranges for DEFCORE VDCDC1 */
+#define TPS_VDCDC1_MILLIVOLT_800    0x00u
+#define TPS_VDCDC1_MILLIVOLT_825    0x01u
+#define TPS_VDCDC1_MILLIVOLT_850    0x02u
+#define TPS_VDCDC1_MILLIVOLT_875    0x03u
+#define TPS_VDCDC1_MILLIVOLT_900    0x04u
+#define TPS_VDCDC1_MILLIVOLT_925    0x05u
+#define TPS_VDCDC1_MILLIVOLT_950    0x06u
+#define TPS_VDCDC1_MILLIVOLT_975    0x07u
+#define TPS_VDCDC1_MILLIVOLT_1000   0x08u
+#define TPS_VDCDC1_MILLIVOLT_1025   0x09u
+#define TPS_VDCDC1_MILLIVOLT_1050   0x0Au
+#define TPS_VDCDC1_MILLIVOLT_1075   0x0Bu
+#define TPS_VDCDC1_MILLIVOLT_1100   0x0Cu
+#define TPS_VDCDC1_MILLIVOLT_1125   0x0Du
+#define TPS_VDCDC1_MILLIVOLT_1150   0x0Eu
+#define TPS_VDCDC1_MILLIVOLT_1175   0x0Fu
+#define TPS_VDCDC1_MILLIVOLT_1200   0x10u
+#define TPS_VDCDC1_MILLIVOLT_1225   0x11u
+#define TPS_VDCDC1_MILLIVOLT_1250   0x12u
+#define TPS_VDCDC1_MILLIVOLT_1275   0x13u
+#define TPS_VDCDC1_MILLIVOLT_1300   0x14u
+#define TPS_VDCDC1_MILLIVOLT_1325   0x15u
+#define TPS_VDCDC1_MILLIVOLT_1350   0x16u
+#define TPS_VDCDC1_MILLIVOLT_1375   0x17u
+#define TPS_VDCDC1_MILLIVOLT_1400   0x18u
+#define TPS_VDCDC1_MILLIVOLT_1425   0x19u
+#define TPS_VDCDC1_MILLIVOLT_1450   0x1Au
+#define TPS_VDCDC1_MILLIVOLT_1475   0x1Bu
+#define TPS_VDCDC1_MILLIVOLT_1500   0x1Cu
+#define TPS_VDCDC1_MILLIVOLT_1525   0x1Du
+#define TPS_VDCDC1_MILLIVOLT_1550   0x1Eu
+#define TPS_VDCDC1_MILLIVOLT_1600   0x1Fu
+
+
+
+
+/***********************************************************
+* Global Function Declarations                             *
+***********************************************************/
+Uint32                    TPS65023_open(Uint32 instance);
+Uint8          TPS65023_reg_read(Uint32 instance, Uint8 regOffset, Uint8 *buf );
+Uint32         TPS65023_reg_write(Uint32 instance, Uint8 regOffset, Uint8 regVal);
+Uint32                    TPS65023_set_DCDC1_voltage(Uint32 instance, Uint16 volt);
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/Common/src/device_name.cs b/tools/omapl13x_boot_utils/OMAP-L137/Common/src/device_name.cs
new file mode 100644 (file)
index 0000000..02781d4
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * device_name.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+/* --------------------------------------------------------------------------
+    FILE        : device_name.cs
+    PROJECT     : TI Booting and Flashing Utilities
+    AUTHOR      : Daniel Allred
+    DESC        : Name adaptor
+ ----------------------------------------------------------------------------- */
+
+using System;
+using System.Text;
+namespace TIBootAndFlash
+{
+  partial class Program
+  {
+    public static String devString = "OMAP-L137";
+    
+    public static UInt32 externalRAMStart = 0xC0000000;
+    
+    public static String[] deviceTypes = { "OMAPL137_v2", "OMAPL137_v1", "C6747", "AM1707"};
+    
+    public static String[] flashTypes = { "SPI_MEM", "NAND" , "NOR"};
+  }
+}
\ No newline at end of file
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/AISextra/makefile b/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/AISextra/makefile
new file mode 100644 (file)
index 0000000..7dd27fa
--- /dev/null
@@ -0,0 +1,47 @@
+###########################################################################
+#                                                                         #
+#   Copyright (C) 2012 Texas Instruments Incorporated                     #
+#     http://www.ti.com/                                                  #
+#                                                                         #
+###########################################################################
+
+
+
+#############################################################################
+#                                                                           #
+#  Redistribution and use in source and binary forms, with or without       #
+#  modification, are permitted provided that the following conditions       #
+#  are met:                                                                 #
+#                                                                           #
+#    Redistributions of source code must retain the above copyright         #
+#    notice, this list of conditions and the following disclaimer.          #
+#                                                                           #
+#    Redistributions in binary form must reproduce the above copyright      #
+#    notice, this list of conditions and the following disclaimer in the    #
+#    documentation and/or other materials provided with the                 #
+#    distribution.                                                          #
+#                                                                           #
+#    Neither the name of Texas Instruments Incorporated nor the names of    #
+#    its contributors may be used to endorse or promote products derived    #
+#    from this software without specific prior written permission.          #
+#                                                                           #
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS      #
+#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT        #
+#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR    #
+#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT     #
+#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    #
+#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT         #
+#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,    #
+#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY    #
+#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT      #
+#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE    #
+#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     #
+#                                                                           #
+#############################################################################
+all:
+               $(MAKE) -C src
+clean:
+               $(MAKE) -C src clean
+%::
+               $(MAKE) -C src $@
+               
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/AISextra/src/ARM_AISExtra.lds b/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/AISextra/src/ARM_AISExtra.lds
new file mode 100644 (file)
index 0000000..3b39f67
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ *  Desc: Linker command file sft application program.
+ *  Auth: Daniel Allred
+ */
+
+ENTRY(start)
+SECTIONS 
+{
+  
+  EXTERNAL_RAM_SIZE   = 0x10000000;  
+  EXTERNAL_RAM_START  = 0xC0000000;
+  EXTERNAL_RAM_END    = EXTERNAL_RAM_START + EXTERNAL_RAM_SIZE;
+  
+  ASYNC_MEM_START     = 0x02000000;
+
+  IRAM_START          = 0x80000000;
+  IRAM_SIZE           = 0x00008000;
+
+  INTERNAL_RAM_START = 0x80000000;
+  INTERNAL_RAM_SIZE  = 0x00008000;
+  
+  STACK_START         = 0x80008800;
+  STACK_SIZE          = 0x00000800;
+  
+  . = IRAM_START;
+  .text    : 
+  {
+    *(.text:.start)
+    *(.text)
+    . = ALIGN(4);
+
+  }
+  
+  /* Move into DRAM for placing const and data sections */
+  .rodata    :
+  {
+    *(.rodata*)
+    *(.rodata)
+    . = ALIGN(4);
+  }  
+  .data    : 
+  {
+    *(.data)
+    . = ALIGN(4);
+  }
+        
+  .bss    :
+  {
+    *(.bss) *(COMMON)
+    . = ALIGN(4);
+  }
+}
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/AISextra/src/DSP_AISExtra.cmd b/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/AISextra/src/DSP_AISExtra.cmd
new file mode 100644 (file)
index 0000000..e1296bd
--- /dev/null
@@ -0,0 +1,31 @@
+
+MEMORY
+{
+    L1D_PARAM   org=0x00F00000 len=0x00000040 /* Function Args */
+    L2RAM              org=0x00800000 len=0x00002000 /* L2 RAM/Cache */
+    EMIFB_MEM   org=0xC0000000 len=0x10000000 /* DDR EMIF3a memory */
+}
+
+SECTIONS
+{
+       .params         > L1D_PARAM
+       .cinit      > L2RAM
+       .text       > L2RAM
+       .const      > L2RAM
+       .bss        > L2RAM
+       .far            > L2RAM
+       .switch         > L2RAM
+       .data       > L2RAM
+       .stack      > L2RAM
+    .fardata    > L2RAM
+    .fardata    > L2RAM
+    .neardata   > L2RAM
+    .rodata     > L2RAM
+
+  .sdram
+  {
+    . += 0x10000000;
+  } load=EMIFB_MEM, type=DSECT, FILL=0x00000000, START(_EXTERNAL_RAM_START)  
+}
+
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/AISextra/src/aisextra.c b/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/AISextra/src/aisextra.c
new file mode 100644 (file)
index 0000000..a8ebc13
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * aisextra.c
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+/* --------------------------------------------------------------------------
+    FILE        : aisxtra.c                                                                            
+    PURPOSE     : AIS Extra commands for use in AIS Scripts
+    PROJECT     : TI Boot and Flash Utilities
+    AUTHOR      : Daniel Allred
+ ----------------------------------------------------------------------------- */
+
+/************************************************************
+* Include Files                                             *
+************************************************************/
+#include "tistdtypes.h"
+#include "device.h"
+
+
+/************************************************************
+* Explicit External Declarations                            *
+************************************************************/
+
+
+/************************************************************
+* Local Macro Declarations                                  *
+************************************************************/
+
+
+/************************************************************
+* Local Typedef Declarations                                *
+************************************************************/
+
+
+/************************************************************
+* Local Function Declarations                               *
+************************************************************/
+
+
+/************************************************************
+* Local Variable Definitions                                *
+************************************************************/
+
+
+/************************************************************
+* Global Variable Definitions                               *
+************************************************************/
+#if defined(__TMS320C6X__)
+  
+       #pragma DATA_SECTION(paramTable,".params")
+       Uint32 paramTable[16];
+
+#elif defined(__GNUC__)
+       Uint32 paramTable[16] __attribute__((,section(".params")));
+#endif
+
+/************************************************************
+* Global Function Definitions                               *
+************************************************************/
+#if defined(__TMS320C6X__)
+  #pragma CODE_SECTION(setEmifA45Div,".text")
+  void setEmifA45Div()
+#elif defined(__GNUC__)
+  void setEmifA45Div() __attribute__((,section(".text")));
+  void setEmifA45Div()
+#endif
+{
+  SYSTEM->CFGCHIP[3] = SYSTEM->CFGCHIP[3] | 0x6;
+}
+
+#if defined(__TMS320C6X__)
+  #pragma CODE_SECTION(setEmifB45Div,".text")
+  void setEmifB45Div()
+#elif defined(__GNUC__)
+  void setEmifB45Div() __attribute__((,section(".text")));
+  void setEmifB45Div()
+#endif
+{
+  SYSTEM->CFGCHIP[3] = SYSTEM->CFGCHIP[3] | 0x5;
+}
+
+
+/************************************************************
+* End File                                                  *
+************************************************************/
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/AISextra/src/makefile b/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/AISextra/src/makefile
new file mode 100644 (file)
index 0000000..a6e6882
--- /dev/null
@@ -0,0 +1,99 @@
+###########################################################################
+#                                                                         #
+#   Copyright (C) 2012-2017 Texas Instruments Incorporated                #
+#     http://www.ti.com/                                                  #
+#                                                                         #
+###########################################################################
+
+
+
+#############################################################################
+#                                                                           #
+#  Redistribution and use in source and binary forms, with or without       #
+#  modification, are permitted provided that the following conditions       #
+#  are met:                                                                 #
+#                                                                           #
+#    Redistributions of source code must retain the above copyright         #
+#    notice, this list of conditions and the following disclaimer.          #
+#                                                                           #
+#    Redistributions in binary form must reproduce the above copyright      #
+#    notice, this list of conditions and the following disclaimer in the    #
+#    documentation and/or other materials provided with the                 #
+#    distribution.                                                          #
+#                                                                           #
+#    Neither the name of Texas Instruments Incorporated nor the names of    #
+#    its contributors may be used to endorse or promote products derived    #
+#    from this software without specific prior written permission.          #
+#                                                                           #
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS      #
+#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT        #
+#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR    #
+#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT     #
+#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    #
+#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT         #
+#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,    #
+#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY    #
+#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT      #
+#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE    #
+#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     #
+#                                                                           #
+#############################################################################
+#############################################################
+# Makefile for TI AISExtra project.                         #
+#   Generates the COFF AISExtra file which is used to       #
+#   supplement the AIS ROM bootloader                       #
+#############################################################
+#
+
+# CROSSCOMPILE definition for entire tree
+include ../../../../../Common/build.mak
+include ../../../../device.mak
+
+PROGRAM:=AISExtra
+
+DSP_CC=$(DSP_CROSSCOMPILE)cl6x
+ARM_CC=$(CROSSCOMPILE)gcc
+
+SOURCES=aisextra.c
+
+DSP_OBJECTS:=$(patsubst %.c,./dsp_obj/%.obj,$(SOURCES))
+DSP_EXECUTABLE:=../DSP_$(PROGRAM)_$(DEVSTRING).out
+DSP_LINKERSCRIPT:=DSP_AISExtra.cmd
+
+DSP_CFLAGS=-O=2 -c --obj_directory=./dsp_obj -I=../../../../../Common/include -I=../../../../Common/include -I=../../../Common/include -I=../include -ms3 -mo -mv6740 --symdebug:none
+DSP_LNKFLAGS=-z -a -usetEmifA45Div -usetEmifB45Div -w -x
+
+ARM_OBJECTS:=$(patsubst %.c,./arm_obj/%.obj,$(SOURCES))
+ARM_EXECUTABLE:=../ARM_$(PROGRAM)_$(DEVSTRING).out
+ARM_LINKERSCRIPT:=ARM_AISExtra.lds
+
+ARM_CFLAGS= -I../../../../../Common/include -I../../../../Common/include -I../../../Common/include -I../include -c -Os -Wall -ffreestanding -o $@
+ARM_LNKFLAGS=-Wl,-T$(ARM_LINKERSCRIPT) -nostdlib -u setEmifA45Div -u setEmifB45Div 
+
+
+all: $(DSP_EXECUTABLE) $(ARM_EXECUTABLE) $(DSP_OBJECTS) $(ARM_OBJECTS) 
+
+.PHONY : clean objclean
+clean:
+               -rm -f -v $(DSP_OBJECTS) $(ARM_OBJECTS) $(DSP_EXECUTABLE) $(ARM_EXECUTABLE)
+               
+objclean:
+               -rm -f -v $(DSP_OBJECTS) $(ARM_OBJECTS)
+
+$(DSP_EXECUTABLE): $(DSP_OBJECTS) $(DSP_LINKERSCRIPT) 
+               $(DSP_CC) $(DSP_LNKFLAGS) -o=$@ $(DSP_LINKERSCRIPT) $(DSP_OBJECTS)
+               
+./dsp_obj/%.obj : %.c
+               @mkdir -p dsp_obj
+               $(DSP_CC) $(DSP_CFLAGS) $<
+    
+$(ARM_EXECUTABLE): $(ARM_OBJECTS) $(ARM_LINKERSCRIPT)
+               $(ARM_CC) $(ARM_LNKFLAGS) $(ARM_OBJECTS) -o $@ 
+
+./arm_obj/%.obj : %.c
+               @mkdir -p arm_obj
+               $(ARM_CC) $(ARM_CFLAGS) $<
+
+vpath %.c ../../../../../Common/src:../../../../Common/src:../../../Common/src:../../Common/src:../src        
+vpath %.h ../../../../../Common/include:../../../../Common/include:../../../Common/include:../../Common/include:../include       
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/HexAIS/HexAIS.cs b/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/HexAIS/HexAIS.cs
new file mode 100644 (file)
index 0000000..57066da
--- /dev/null
@@ -0,0 +1,431 @@
+/*
+ * HexAIS.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+/* --------------------------------------------------------------------------
+    FILE        : HexAIS.cs
+    PURPOSE     : TI Booting and Flashing Utilities
+    DESC        : Non-secure AIS generator
+ ----------------------------------------------------------------------------- */
+
+using System;
+using System.Text;
+using System.IO;
+using System.Globalization;
+using System.Reflection;
+using System.Collections;
+using System.Collections.Generic;
+
+using TI.AISLib;
+using TI.UtilLib;
+using TI.UtilLib.IO;
+using TI.UtilLib.Ini;
+using TI.UtilLib.HexConv;
+
+namespace TIBootAndFlash
+{
+  partial class Program
+  {
+    private enum ConvType: uint
+    {
+      Exec2Bin    = 0,
+      Exec2CArray = 1,
+      Exec2Srec   = 2,
+      Exec2Text   = 3
+    };
+
+    private struct ProgramCmdParams
+    {
+      // Program conversion type
+      public ConvType convType;
+
+      public List<String> inputFileName;
+
+      public String iniFileName;
+
+      public String outFileName;
+      
+      public String cArrayName;
+      
+      public UInt64 srecAddr;
+      
+      public UInt64 entryPoint; 
+
+      public Boolean valid;
+    }
+      
+    /// <summary>
+    /// Function to display help in case command-line is invalid
+    /// </summary>
+    static void DispHelp()
+    {
+      Console.Write("Usage:\n\n");
+      Console.Write("HexAIS_"+devString+"[Options] [Input File Names]\n");
+      Console.Write("\t" + "<Option> can be any of the following:\n");
+      Console.Write("\t\t" + "-h                   \tShow this help screen.\n");
+      Console.Write("\t\t" + "-entrypoint <Addr>   \tForce specified entry point for AIS boot image.\n");        
+      Console.Write("\t\t" + "-ini <INI file name> \tSpecify the ini file (default is " + devString + ".ini).\n");            
+      Console.Write("\t\t" + "-otype <Output Type> \tSpecify type of output file, from following:.\n");
+      Console.Write("\t\t" + "     binary          \t     Create a binary AIS file (.bin), default.\n");
+      Console.Write("\t\t" + "     carray[:name]   \t     Create a text file with AIS data in a C array (with optional name).\n");
+      Console.Write("\t\t" + "     srecord@addr    \t     Create a Motorola S-record format (.srec) at addr.\n");
+      Console.Write("\t\t" + "     text            \t     Create a text file with AIS data as ASCII text (.txt).\n");
+      Console.Write("\t\t" + "-o <Output File Name>\tExplicitly specify the output filename.\n");
+      Console.Write("\t\t" + "                     \tDefault is input file name with extension based on\n");
+      Console.Write("\t\t" + "                     \toutput type.\n");
+      Console.Write("\n");
+    }
+
+    /// <summary>
+    /// Function to parse the command line
+    /// </summary>
+    /// <param name="args">Array of command-line arguments</param>
+    /// <returns>Struct of the filled in program arguments</returns>
+    static ProgramCmdParams ParseCmdLine(String[] args)
+    {
+      ProgramCmdParams myCmdParams = new ProgramCmdParams();
+      Boolean[] argsHandled = new Boolean[args.Length];
+
+      Int32 numUnhandledArgs, numHandledArgs = 0;
+      String defaultExtension;
+
+      // Set Defaults
+      myCmdParams.valid = true;
+      myCmdParams.outFileName = null;
+      myCmdParams.iniFileName = null;
+      myCmdParams.inputFileName = null;
+      myCmdParams.srecAddr = 0xFFFFFFFF;
+      myCmdParams.entryPoint = 0xFFFFFFFF;
+      myCmdParams.convType = ConvType.Exec2Bin;
+      defaultExtension = ".bin";
+
+      // Initialize array of handled argument booleans to false
+      for (int i = 0; i < argsHandled.Length; i++)
+      {
+        argsHandled[i] = false;
+      }
+      
+      // For loop to check for all dash options
+      for (int i = 0; i < args.Length; i++)
+      {
+        if (args[i].StartsWith("-"))
+        {
+          switch (args[i].Substring(1).ToLower())
+          {
+            case "entrypoint":
+            {
+              UInt32 temp;
+              if (args[i + 1].StartsWith("0x") || args[i + 1].StartsWith("0X"))
+              {
+                if (!UInt32.TryParse(args[i + 1].Replace("0x", ""), NumberStyles.HexNumber, null, out temp))
+                {
+                  Console.WriteLine("WARNING: Invalid entrypoint address, {0}. Ignoring...", args[i + 1]);
+                }
+                else
+                {
+                  myCmdParams.entryPoint = temp;
+                }
+              }
+              else if (UInt32.TryParse(args[i + 1], out temp))
+              {
+                myCmdParams.entryPoint = temp;
+              }
+              else
+              {
+                Console.WriteLine("WARNING: Invalid entrypoint address, {0}. Ignoring...", args[i + 1]);
+              }
+              
+              argsHandled[i + 1] = true;
+              numHandledArgs++;
+              break;
+            }
+            case "otype":
+            {
+              // Handle possible srecord@addr, carray:name case
+              String[] otype = args[i + 1].Split(new Char [] {'@',':'});
+              
+              if (otype[0].ToLower().Equals("binary"))
+              {
+                myCmdParams.convType = ConvType.Exec2Bin;
+                defaultExtension = ".bin";
+              }
+              else if (otype[0].ToLower().Equals("carray"))
+              {
+                myCmdParams.convType = ConvType.Exec2CArray;
+                defaultExtension = ".c";
+                if (otype.Length == 1)
+                {
+                  myCmdParams.cArrayName = "data_array";
+                }
+                else if (otype.Length == 2)
+                {
+                  myCmdParams.cArrayName = otype[1];
+                }
+                else
+                {
+                  myCmdParams.valid = false;
+                }
+              }
+              else if (otype[0].ToLower().Equals("text"))
+              {
+                myCmdParams.convType = ConvType.Exec2Text;
+                defaultExtension = ".txt";
+              }
+              else if (otype[0].ToLower().Equals("srecord"))
+              {
+                if (otype.Length == 2)
+                {
+                  UInt32 temp;
+                  otype[1] = otype[1].ToLower();
+                  if (otype[1].StartsWith("0x"))
+                  {
+                    if (!UInt32.TryParse(otype[1].Replace("0x", ""), NumberStyles.HexNumber, null, out temp))
+                    {
+                      Console.WriteLine("ERROR: Invalid S-record address, {0}. Aborting...", otype[1]);
+                      myCmdParams.valid = false;
+                    }
+                    else
+                    {
+                      myCmdParams.srecAddr = temp;
+                    }
+                  }
+                  else if (UInt32.TryParse(otype[1], out temp))
+                  {
+                    myCmdParams.srecAddr = temp;
+                  }
+                  else
+                  {
+                    Console.WriteLine("ERROR: Invalid S-record address, {0}. Aborting...", otype[1]);
+                    myCmdParams.valid = false;
+                  }
+                  myCmdParams.convType = ConvType.Exec2Srec;
+                  defaultExtension = ".srec";
+                }
+                else
+                {
+                  myCmdParams.valid = false;
+                }
+              }
+              else
+              {
+                myCmdParams.valid = false;
+              }
+              argsHandled[i + 1] = true;
+              numHandledArgs++;
+              break;
+            }
+            case "ini":
+            {
+              myCmdParams.iniFileName = args[i + 1];
+              argsHandled[i + 1] = true;
+              numHandledArgs++;
+              break;
+            }
+            case "o":
+            {
+              myCmdParams.outFileName = args[i + 1];
+              argsHandled[i + 1] = true;
+              numHandledArgs++;
+              break;
+            }
+            default:
+            {
+              myCmdParams.valid = false;
+              break;
+            }
+          }
+          argsHandled[i] = true;
+          numHandledArgs++;
+          
+          // If we've seen any error, bug out
+          if (!myCmdParams.valid)
+          {
+            break;
+          }
+        }
+      }
+      numUnhandledArgs = args.Length - numHandledArgs;
+      
+      // Check to make sure we are still valid
+      if (!myCmdParams.valid)
+      {
+        return myCmdParams;
+      }
+       
+      // Get optional input files in order (all unhandled args, if any, are input files)
+      if (numUnhandledArgs != 0)
+      {
+        myCmdParams.inputFileName = new List<String>(numUnhandledArgs);
+      }
+      for (int i=numUnhandledArgs; i>0; i--)
+      {
+        String[] file = args[args.Length-i].Split('@');
+        myCmdParams.inputFileName.Add(args[args.Length-i]);
+      }
+      
+      // Set output filename to match input filename, if needed
+      if (myCmdParams.outFileName == null)
+      {
+        if  (myCmdParams.inputFileName != null)
+        {
+          String lastFileName = ((String) myCmdParams.inputFileName[myCmdParams.inputFileName.Count - 1]).Split('@')[0];
+          myCmdParams.outFileName = Path.GetFileNameWithoutExtension(lastFileName) + defaultExtension;
+        }
+        else
+        {
+          myCmdParams.outFileName = "ais_output" + defaultExtension;
+        }
+      }
+  
+      return myCmdParams;
+    }
+      
+    /// <summary>
+    /// Main program.
+    /// </summary>
+    /// <param name="args">Input commandline arguments</param>
+    /// <returns>Return code</returns>
+    static Int32 Main(String[] args)
+    {          
+      IniFile myIniFile;
+    
+      // From Common/AIS/HexAIS_version.cs
+      System.Version v = GetVersion();
+      
+      // From Common/AIS/HexAIS_version.cs
+      Int32 buildYear = GetBuildYear();
+      
+      // Begin main code
+      Console.WriteLine("-----------------------------------------------------");
+      Console.WriteLine("   TI AIS Hex File Generator for " + devString   );
+      Console.WriteLine("   (C) "+buildYear+", Texas Instruments, Inc."        );
+      Console.WriteLine("   Ver. "+v.Major+"."+v.Minor.ToString("D2")          );
+      Console.WriteLine("-----------------------------------------------------");
+      Console.Write("\n\n");            
+      
+
+      // Parse the input command line parameters
+      ProgramCmdParams cmdParams = ParseCmdLine(args);
+      if (!cmdParams.valid)
+      {
+        DispHelp();
+        return -1;
+      }
+      
+      // Now proceed with main program
+      FileStream tempAIS_fs = null;
+      Byte[] AISData, convertedData;
+        
+      AISGen_OMAP_L137 generator = new AISGen_OMAP_L137();
+       
+      // Update the default INI file name to the one supplied on the command line
+      if (cmdParams.iniFileName == null)
+      {
+        Console.WriteLine("No ini file provided. Using default, {0}", generator.DeviceNameShort + ".ini");
+        cmdParams.iniFileName = generator.DeviceNameShort + ".ini";
+      }
+      
+      // Read the INI data from file
+      if (File.Exists(cmdParams.iniFileName))
+      {
+        myIniFile = new IniFile(new FileStream(cmdParams.iniFileName, FileMode.Open, FileAccess.Read), cmdParams.iniFileName);
+      }
+      else
+      {
+        Console.WriteLine("File {0} not found.",cmdParams.iniFileName);
+        return -1;
+      }
+      
+      // Put entryPoint in General Ini section (may be overridden by INI InputFile sections)
+      myIniFile.InsertValue("General","EntryPoint","0x"+cmdParams.entryPoint.ToString("X8"));
+      
+      // Force section-by-section CRC checks (may be overridden in INI file)
+      generator.AISCRCType = AisCRCCheckType.SECTION_CRC;
+
+      // Do the AIS generation
+      try
+      {
+        AISData = AISGen.GenAIS(generator, cmdParams.inputFileName, myIniFile);
+      }
+      catch (Exception e)
+      {
+        System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace(e, true);
+      
+        Console.WriteLine(e.StackTrace);
+        Console.WriteLine(e.Message);
+        Console.WriteLine("Unhandled Exception!!! Application will now exit.");
+        return -1;
+      }
+      
+      // Check if SecureAISGen completed successfully
+      if (AISData == null)
+      {
+        Console.WriteLine("AIS generation failed.");
+        return -1;
+      }
+      
+      using (tempAIS_fs = new FileStream(cmdParams.outFileName, FileMode.Create, FileAccess.Write))
+      {
+      
+        // Convert the AIS data to the correct output format
+        switch ( cmdParams.convType )
+        {
+          case ConvType.Exec2Bin:
+            tempAIS_fs.Write(AISData, 0, (int)AISData.Length);
+            Console.WriteLine("Wrote {0} bytes to file {1}.",AISData.Length,cmdParams.outFileName);
+            break;
+          case ConvType.Exec2CArray:
+            convertedData = CArray.bin2CArray(cmdParams.cArrayName, AISData, 4);
+            tempAIS_fs.Write(convertedData, 0, (int)convertedData.Length);
+            Console.WriteLine("Wrote {0} bytes to file {1}.",convertedData.Length,cmdParams.outFileName);
+            break;
+          case ConvType.Exec2Srec:
+            convertedData = SRecord.bin2srec(AISData, (UInt32)cmdParams.srecAddr, 32);
+            tempAIS_fs.Write(convertedData, 0, (int)convertedData.Length);
+            Console.WriteLine("Wrote {0} bytes to file {1}.",convertedData.Length,cmdParams.outFileName);
+            break;
+          case ConvType.Exec2Text:
+            Console.WriteLine("Mode Not supported.");
+            break;            
+        }
+      }
+              
+      Console.WriteLine("Conversion is complete.");
+      return 0;
+    }
+  }
+}
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/HexAIS/makefile b/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/HexAIS/makefile
new file mode 100644 (file)
index 0000000..00d0605
--- /dev/null
@@ -0,0 +1,92 @@
+###########################################################################
+#                                                                         #
+#   Copyright (C) 2012 Texas Instruments Incorporated                     #
+#     http://www.ti.com/                                                  #
+#                                                                         #
+###########################################################################
+
+
+
+#############################################################################
+#                                                                           #
+#  Redistribution and use in source and binary forms, with or without       #
+#  modification, are permitted provided that the following conditions       #
+#  are met:                                                                 #
+#                                                                           #
+#    Redistributions of source code must retain the above copyright         #
+#    notice, this list of conditions and the following disclaimer.          #
+#                                                                           #
+#    Redistributions in binary form must reproduce the above copyright      #
+#    notice, this list of conditions and the following disclaimer in the    #
+#    documentation and/or other materials provided with the                 #
+#    distribution.                                                          #
+#                                                                           #
+#    Neither the name of Texas Instruments Incorporated nor the names of    #
+#    its contributors may be used to endorse or promote products derived    #
+#    from this software without specific prior written permission.          #
+#                                                                           #
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS      #
+#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT        #
+#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR    #
+#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT     #
+#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    #
+#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT         #
+#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,    #
+#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY    #
+#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT      #
+#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE    #
+#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     #
+#                                                                           #
+#############################################################################
+#############################################################
+# Makefile for TI Non-Secure HexAIS project.                #
+#############################################################
+# Auth: Daniel Allred
+#          
+include ../../../device.mak
+
+PROGRAM:=HexAIS
+
+MONOCOMPILE=gmcs
+DOTNETCOMPILE=csc
+LOCALSOURCES=$(PROGRAM).cs
+REMOTESOURCES=device_name.cs AISGen_$(DEVSTRING).cs Ini.cs CRC.cs Endian.cs $(PROGRAM)_version.cs \
+              EmbeddedFileIO.cs Debug.cs HexConv.cs AIS.cs AISGen.cs SerialIO.cs ObjectFile.cs \
+              CoffFile.cs ElfFile.cs BinaryFile.cs
+OBJECTS:=$(patsubst %.cs,%.module,$(REMOTESOURCES))
+EXECUTABLE:=../$(PROGRAM)_$(DEVSTRING).exe
+
+COMMONPATH:=../../../../Common
+ICON:=$(COMMONPATH)/ti.ico
+UTILLIBPATH:=$(COMMONPATH)/UtilLib
+AISGENLIBPATH:=$(COMMONPATH)/AIS
+
+DEVCOMMONPATH:=../../../Common
+GNUCOMMONPATH:=../../Common
+DEVAISGENLIBPATH:=$(GNUCOMMONPATH)/AISGenLib
+
+AISEXTRAPATH:=../AISextra
+ARM_AISEXTRAIMAGE:=$(AISEXTRAPATH)/ARM_AISExtra_$(DEVSTRING).out
+DSP_AISEXTRAIMAGE:=$(AISEXTRAPATH)/DSP_AISExtra_$(DEVSTRING).out
+
+# Target definitions
+all: $(EXECUTABLE) $(OBJECTS) $(LOCALSOURCES) $(REMOTESOURCES) 
+
+.PHONY : clean
+clean:
+               -rm -f -v $(EXECUTABLE) $(OBJECTS)
+
+$(ARM_AISEXTRAIMAGE) $(DSP_AISEXTRAIMAGE):
+               make -C $(AISEXTRAPATH) all
+        
+$(EXECUTABLE): $(ARM_AISEXTRAIMAGE) $(DSP_AISEXTRAIMAGE) $(LOCALSOURCES) $(OBJECTS) $(REMOTESOURCES) makefile
+ifeq ($(shell uname),Linux)
+               @$(MONOCOMPILE) -t:exe -resource:$(ARM_AISEXTRAIMAGE) -resource:$(DSP_AISEXTRAIMAGE) -out:$(EXECUTABLE) $(LOCALSOURCES) $(OBJECTS)
+else
+               @$(DOTNETCOMPILE) /t:exe /resource:$(ARM_AISEXTRAIMAGE) /resource:$(DSP_AISEXTRAIMAGE) /out:$(EXECUTABLE) /win32icon:$(ICON) $(LOCALSOURCES) $(OBJECTS)
+endif
+
+%.module: %.cs
+               @cp $< $@
+
+vpath %.cs $(UTILLIBPATH)/:$(DEVAISGENLIBPATH)/:$(AISGENLIBPATH)/:$(DEVCOMMONPATH)/src/
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/HexAIS_OMAP-L137.exe b/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/HexAIS_OMAP-L137.exe
new file mode 100644 (file)
index 0000000..eb827c3
Binary files /dev/null and b/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/HexAIS_OMAP-L137.exe differ
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/OMAP-L137-uart.ini b/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/OMAP-L137-uart.ini
new file mode 100644 (file)
index 0000000..53f1082
--- /dev/null
@@ -0,0 +1,11 @@
+; General settings that can be overwritten in the host code
+; that calls the AISGen library.
+[General]
+
+; EMIFA,NONE
+BootMode=NONE
+
+; NO_CRC,SECTION_CRC,SINGLE_CRC
+crcCheckType=NO_CRC
+
+[AIS_SeqReadEnable]
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/OMAP-L137.ini b/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/OMAP-L137.ini
new file mode 100644 (file)
index 0000000..394874e
--- /dev/null
@@ -0,0 +1,123 @@
+; General settings that can be overwritten in the host code
+; that calls the AISGen library.
+[General]
+
+; Can be 8 or 16 - used in emifa
+busWidth=8            
+
+; EMIFA,NONE
+; EMIFA required for NOR boot modes, along with busWidth field
+BootMode=none
+
+; NO_CRC,SECTION_CRC,SINGLE_CRC
+crcCheckType=SECTION_CRC
+
+
+; Enable sequential read mode for boot modes that support it.
+; Does not impact boot modes that don't use it.
+[AIS_SeqReadEnable]
+
+
+; This section allows setting the PLL system clock with a  
+; specified multiplier and divider as shown. The clock source
+; can also be chosen for internal or external.
+;           |------24|------16|-------8|-------0|
+; PLLCFG0:  |    PLLM| POSTDIV| PLLDIV3| PLLDIV5|
+; PLLCFG1:  | CLKMODE| PLLDIV7|PLL_LOCK_TIME_CNT|
+;[PLLCONFIG]
+;PLLCFG0 = 0x18010202
+;PLLCFG1 = 0x00050800
+
+; This section lets us configure the peripheral interface
+; of the current booting peripheral (I2C, SPI, or UART).
+; Use with caution. The format of the PERIPHCLKCFG field 
+; is as follows:
+; SPI:        |------24|------16|-------8|-------0|
+;             |           RSVD           |PRESCALE|
+;
+; I2C:        |------24|------16|-------8|-------0|
+;             |  RSVD  |PRESCALE|  CLKL  |  CLKH  |
+;
+; UART:       |------24|------16|-------8|-------0|
+;             | RSVD   |  OSR   |  DLH   |  DLL   |
+;[PERIPHCLKCFG]
+;PERIPHCLKCFG = 0x00000000
+
+; This section can be used to configure the PLL1 and the EMIF3a registers
+; for starting the DDR2 interface. 
+; See PLL1CONFIG section for the format of the PLL1CFG fields.
+;            |------24|------16|-------8|-------0|
+; SDCR:      |              SDCR                 |
+; SDTIMR:    |              SDTIMR               |
+; SDTIMR2:   |              SDTIMR2              |
+; SDRCR:     |              SDRCR                |
+;[EMIF3SDRAM]
+;SDCR     = 0x00008621
+;SDTIMR   = 0x0A492148
+;SDTIMR2  = 0x70060004
+;SDRCR    = 0x0000030E
+
+; This section can be used to configure the EMIFA to use 
+; CS0 as an SDRAM interface.  The fields required to do this
+; are given below.
+;                     |------24|------16|-------8|-------0|
+; SDBCR:              |               SDBCR               |
+; SDTIMR:             |               SDTIMR              |
+; SDRSRPDEXIT:        |             SDRSRPDEXIT           |
+; SDRCR:              |               SDRCR               |
+;[EMIF25SDRAM]
+;SDBCR        = 0x00004721
+;SDTIMR       = 0x29114510
+;SDRSRPDEXIT  = 0x00000006
+;SDRCR        = 0x0000030E
+
+; This section can be used to configure the async chip selects
+; of the EMIFA (CS2-CS5).  The fields required to do this
+; are given below.
+;           |------24|------16|-------8|-------0|
+; A1CR:     |                A1CR               |
+; A2CR:     |                A2CR               |
+; A3CR:     |                A3CR               |
+; A4CR:     |                A4CR               |
+;[EMIF25ASYNC]
+;A1CR = 0x00000000
+;A2CR = 0x00000000
+;A3CR = 0x00000000
+;A4CR = 0x00000000
+
+; This section should be used in place of PLL0CONFIG when
+; the I2C, SPI, or UART modes are being used.  This ensures that 
+; the system PLL and the peripheral's clocks are changed together.
+; See PLL0CONFIG section for the format of the PLL0CFG fields.
+; See PERIPHCLKCFG section for the format of the CLKCFG field.
+;               |------24|------16|-------8|-------0|
+; PLLCFG0:      |              PLL0CFG              |
+; PLLCFG1:      |              PLL0CFG              |
+; PERIPHCLKCFG: |              CLKCFG               |
+;[PLLANDCLOCKCONFIG]
+;PLLCFG0 = 0x00000000
+;PLLCFG1 = 0x00000000
+;PERIPHCLKCFG = 0x00000000
+
+; This section should be used to setup the power state of modules
+; of the two PSCs.  This section can be included multiple times to
+; allow the configuration of any or all of the device modules.
+;           |------24|------16|-------8|-------0|
+; LPSCCFG:  | PSCNUM | MODULE |   PD   | STATE  |
+;[PSCCONFIG]
+;LPSCCFG = 0x01030003
+
+; This section allows setting of a single PINMUX register.
+; This section can be included multiple times to allow setting
+; as many PINMUX registers as needed.
+;         |------24|------16|-------8|-------0|
+; REGNUM: |              regNum               |
+; MASK:   |               mask                |
+; VALUE:  |              value                |
+;[PINMUX]
+;REGNUM = 5
+;MASK = 0x00FF0000
+;VALUE = 0x00880000
+
+; No Params required - simply include this section for the fast boot function to be called
+;[FASTBOOT]
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/makefile b/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/makefile
new file mode 100644 (file)
index 0000000..e0d10fe
--- /dev/null
@@ -0,0 +1,48 @@
+###########################################################################
+#                                                                         #
+#   Copyright (C) 2012 Texas Instruments Incorporated                     #
+#     http://www.ti.com/                                                  #
+#                                                                         #
+###########################################################################
+
+
+
+#############################################################################
+#                                                                           #
+#  Redistribution and use in source and binary forms, with or without       #
+#  modification, are permitted provided that the following conditions       #
+#  are met:                                                                 #
+#                                                                           #
+#    Redistributions of source code must retain the above copyright         #
+#    notice, this list of conditions and the following disclaimer.          #
+#                                                                           #
+#    Redistributions in binary form must reproduce the above copyright      #
+#    notice, this list of conditions and the following disclaimer in the    #
+#    documentation and/or other materials provided with the                 #
+#    distribution.                                                          #
+#                                                                           #
+#    Neither the name of Texas Instruments Incorporated nor the names of    #
+#    its contributors may be used to endorse or promote products derived    #
+#    from this software without specific prior written permission.          #
+#                                                                           #
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS      #
+#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT        #
+#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR    #
+#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT     #
+#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    #
+#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT         #
+#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,    #
+#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY    #
+#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT      #
+#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE    #
+#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     #
+#                                                                           #
+#############################################################################
+DIRS:=$(wildcard *)
+
+all:
+%::
+               @for i in $(DIRS); do \
+                               if [ -d $${i} ]; then if [ -e $${i}/makefile ]; then make -C $${i} $@; fi; fi; \
+               done
+               
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/readme.txt b/tools/omapl13x_boot_utils/OMAP-L137/GNU/AISUtils/readme.txt
new file mode 100644 (file)
index 0000000..95bd8c2
--- /dev/null
@@ -0,0 +1,284 @@
+ /***************************************************************
+ *  TI OMAP-L137 AIS Utilities                                  *
+ *  (C) 2009-2017 Texas Instruments, Inc.                       *
+ *                                                              *
+ ***************************************************************/
+This directory contains the source and build files for various utilities 
+associated with booting flashing the OMAP-L137 SoC device. These utilities 
+include 
+  HexAIS          - Command-line AIS generation utility for non-secure OMAP-L137 devices
+
+Running
+=======
+
+These applications are built on the Microsoft's .Net framework.  To use them, you 
+must run them on a system that has the Microsoft .Net framework v3.5 installed.  
+Alternatively, you can run them using the open-source Mono framework v2.4 or later.
+This may allow the applications to be run under Linux, since Mono exists and runs on 
+that platform.
+
+NOTE: On windows, using the mono framework requires you to use the mono executable.  With
+      Mono in your path, the usage is as follows:
+        mono <ApplicationName> <ApplicationParams>
+      If the mono command is left off, the Microsoft framework will be used instead.
+      
+
+HexAIS tool
+===========
+The HexAIS and tool relies on its input parameters to be provided in INI files, 
+example of which are included in the package.  The ini files are processed in order and are 
+primarily used to specify what AIS Function Execute commands you want to use to initialize the 
+system. The comments in the INI file themselves provide a rough documentation.
+
+The tools have a number of options that can be specified on the command line.  You can run the 
+program with the -h option to see the help screen for each program.
+
+Command Syntax
+==============
+
+HexAIS_OMAP-L137[Options] [Input File Names]
+        <Option> can be any of the following:
+                -h                      Show this help screen.
+                -entrypoint <Addr>      Force specified entry point for AIS boot image.
+                -ini <INI file name>    Specify the ini file (default is OMAP-L137.ini).
+                -otype <Output Type>    Specify type of output file, from following:.
+                     binary                  Create a binary AIS file (.bin), default.
+                     carray                  Create a text file with AIS data in a C array (.c).
+                     srecord@addr            Create a Motorola S-record format (.srec) at addr.
+                     text                    Create a text file with AIS data as ASCII text (.txt).
+                -o <Output File Name>   Explicitly specify the output filename.
+                                        Default is input file name with extension based on
+                                        output type.
+                                        
+Input files (ELF or COFF object files OR Binary files) can be supplied on the command line 
+or via the INI file.  Binary files must be supplied with a load address, so they are specified
+in the following manner:
+  <Binary File Name>@<Hex Load Address>
+
+It is recommended to use the INI file syntax for placing and including files since 
+that provides greater flexibility (see below).
+
+
+Complete INI Syntax
+===================
+
+The INI file consists of a collection of INI sections.  Except for the [General] sections,
+which describe configuration information for the AIS file, the INI sections are processed
+in order and result in contents being added to the generated AIS output.  Each INI section
+contains a collection of fields which are described below:
+
+  Configuration
+  -------------
+  [GENERAL]
+  ; Can be 8 or 16 - used in emifa (NOR boot mode)
+  busWidth=8            
+
+  ; EMIFA,NONE
+  BootMode=Specify boot mode (typically use NONE).  Some boot modes can require 
+           certain extra information beyond the actual AIS data. The tools
+           may support generating this information depending on the boot mode selection.
+
+  ; TRUE/ON or FALSE/OFF
+  seqReadEn=Specify that sequential read should be used for I2C or SPI master modes. This
+            is equivalent to using the [AIS_SeqReadEnable] section (see below).
+
+  Include a file
+  --------------  
+  The INPUTFILE section allows including a binary or object file into the AIS boot
+  image.  The result of this INI section will be one or more AIS SectionLoad or 
+  EncryptedSectionLoad commands inserted into the AIS output.  Note that input files
+  can be specified on the command line, but using individual [INPUTFILE] sections
+  offer more control over placement and content.
+  
+
+  [INPUTFILE]
+  FILENAME=Filename of the binary or object file to include in the AIS iamge
+  LOADADDRESS=Address to which file contents are loaded. If specified, input file is treated as a
+              binary file. For object files, the load address for loadable sections is embedded
+              in the object file itself.
+  ENTRYPOINTADDRESS=Allows specifying the entry point for this module. This is typically used
+                    with binary files since object files embed the entry point.
+  USEENTRYPOINT=Set to YES or TRUE to ensure that the entrypoint is taken from this input file
+                for the JUMP_CLOSE command
+
+                
+  Insert ROM Function Calls (AIS Function Execute)
+  ------------------------------------------------
+  These INI sections are used to insert specific AIS Function Execute
+  commands into the AIS output.
+  
+  ; This section allows setting the PLL system clock with a  
+  ; specified multiplier and divider as shown. The clock source
+  ; can also be chosen for internal or external.
+  ;           |------24|------16|-------8|-------0|
+  ; PLLCFG0:  |    PLLM| POSTDIV| PLLDIV3| PLLDIV5|
+  ; PLLCFG1:  | CLKMODE| PLLDIV7|PLL_LOCK_TIME_CNT|
+  [PLLCONFIG]
+  PLLCFG0 =
+  PLLCFG1 =
+
+  ; This section lets us configure the peripheral interface
+  ; of the current booting peripheral (I2C, SPI, or UART).
+  ; Use with caution. The format of the PERIPHCLKCFG field 
+  ; is as follows:
+  ; SPI:        |------24|------16|-------8|-------0|
+  ;             |           RSVD           |PRESCALE|
+  ;
+  ; I2C:        |------24|------16|-------8|-------0|
+  ;             |  RSVD  |PRESCALE|  CLKL  |  CLKH  |
+  ;
+  ; UART:       |------24|------16|-------8|-------0|
+  ;             | RSVD   |  OSR   |  DLH   |  DLL   |  
+  [PERIPHCLKCFG]
+  PERIPHCLKCFG=
+
+  ; This section can be used to configure the PLL1 and the EMIF3a registers
+  ; for starting the DDR2 interface. 
+  ; See PLL1CONFIG section for the format of the PLL1CFG fields.
+  ;            |------24|------16|-------8|-------0|
+  ; SDCR:      |              SDCR                 |
+  ; SDTIMR:    |              SDTIMR               |
+  ; SDTIMR2:   |              SDTIMR2              |
+  ; SDRCR:     |              SDRCR                |
+  [EMIF3SDRAM]
+  SDCR=
+  SDTIMR=
+  SDTIMR2=
+  SDRCR=
+  
+  ; This section can be used to configure the EMIFA to use 
+  ; CS0 as an SDRAM interface.  The fields required to do this
+  ; are given below.
+  ;                     |------24|------16|-------8|-------0|
+  ; SDBCR:              |               SDBCR               |
+  ; SDTIMR:             |               SDTIMR              |
+  ; SDRSRPDEXIT:        |             SDRSRPDEXIT           |
+  ; SDRCR:              |               SDRCR               |
+  [EMIF25SDRAM]
+  SDBCR=
+  SDTIMR=
+  SDRSRPDEXIT=
+  SDRCR=
+
+  ; This section can be used to configure the async chip selects
+  ; of the EMIFA (CS2-CS5).  The fields required to do this
+  ; are given below.
+  ;           |------24|------16|-------8|-------0|
+  ; A1CR:     |                A1CR               |
+  ; A2CR:     |                A2CR               |
+  ; A3CR:     |                A3CR               |
+  ; A4CR:     |                A4CR               |
+  [EMIF25ASYNC]
+  A1CR=
+  A2CR=
+  A3CR=
+  A4CR=
+  
+  ; This section should be used in place of PLL0CONFIG when
+  ; the I2C, SPI, or UART modes are being used.  This ensures that 
+  ; the system PLL and the peripheral's clocks are changed together.
+  ; See PLLCONFIG section for the format of the PLLCFG fields.
+  ; See PERIPHCLKCFG section for the format of the CLKCFG field.
+  ;               |------24|------16|-------8|-------0|
+  ; PLLCFG0:      |              PLLCFG               |
+  ; PLLCFG1:      |              PLLCFG               |
+  ; PERIPHCLKCFG: |              CLKCFG               |
+  [PLLANDCLOCKCONFIG]
+  PLLCFG0=
+  PLLCFG1=
+  PERIPHCLKCFG=
+
+  ; This section should be used to setup the power state of modules
+  ; of the two PSCs.  This section can be included multiple times to
+  ; allow the configuration of any or all of the device modules.
+  ;           |------24|------16|-------8|-------0|
+  ; LPSCCFG:  | PSCNUM | MODULE |   PD   | STATE  |  
+  [PSCCONFIG]
+  LPSCCFG=
+
+  ; This section allows setting of a single PINMUX register.
+  ; This section can be included multiple times to allow setting
+  ; as many PINMUX registers as needed.
+  ;         |------24|------16|-------8|-------0|
+  ; REGNUM: |              regNum               |
+  ; MASK:   |               mask                |
+  ; VALUE:  |              value                |  
+  [PINMUX]
+  REGNUM=
+  MASK=
+  VALUE=
+  
+  Insert AIS commands
+  -------------------
+  
+  ; Requires no fields, simply inserts AIS Enable CRC command
+  [AIS_EnableCRC]
+  
+  ; Requires no fields, simply inserts AIS Disable CRC command
+  [AIS_DisableCRC] 
+  
+  ; Requires no fields, simply inserts AIS Disable CRC command
+  [AIS_RequestCRC] 
+  CRCVALUE=CRC value for comparison for the Request CRC command
+  SEEKVALUE=Seek value for the the Request CRC command
+  
+  [AIS_Jump]
+  LOCATION=Raw address or symbol to which to jump
+  
+  [AIS_JumpClose]              
+  ENTRYPOINT=Raw address or symbol to which to jump upon close boot.  
+  
+  NOTE: The AIS JumpClose command is automatically inserted at the end of the boot
+  with the currently specified entry point.  Manually inserting this command will 
+  cause all commands following it to be ignored during boot, though the AIS file 
+  generated will still include all those extra commands.
+  
+  [AIS_Set]
+  TYPE=Type field for AIS SET/BOOT_TABLE command
+  ADDRESS=Address field for AIS SET/BOOT_TABLE command
+  DATA=Data field for AIS SET/BOOT_TABLE command
+  SLEEP=Sleep field for AIS SET/BOOT_TABLE command
+  
+  [AIS_SectionFill]
+  ADDRESS=Address field for AIS SECTION_FILL command
+  SIZE=Size field for AIS SECTION_FILL command
+  TYPE=Type field for AIS SECTION_FILL command
+  PATTERN=Pattern field for AIS SECTION_FILL command
+  
+  [AIS_ReadWait]
+  ADDRESS=Address field for READWAIT command
+  MASK=Mask field for READWAIT command
+  DATA=Data field for READWAIT command
+  
+  ; Requires no fields, simply inserts AIS Sequential Read command
+  [AIS_SeqReadEnable] 
+  
+  [AIS_FinalFunctionReg]
+  FINALFXNSYMBOLNAME=Symbol name of function that should be called after boot loading
+                     completes but before the ROM boot loader exits.
+
+
+
+Source
+======
+
+The source for each app will be in the application directory and in the top-level 
+Common directory (in Common/AIS and Common/UtilLib).  The makefiles in each directory
+give the names of all dependent source files.
+
+Compiling
+=========
+
+- Under Windows - 
+The currently supported method is to use the Cygwin enviroment and put the 
+C sharp compiler's (the csc.exe executable) install location in the user's
+path.  This compiler comes with the .NET Framework installation and can
+usually be found in C:\WINDOWS\Microsoft.NET\Framework\<version number>.
+
+In addition, the location of the C6000 and ARM Codegen tools should be in the 
+path.
+
+Then go to the top level directory of the package and run:
+       
+       make
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/GNU/Common/AISGenLib/AISGen_OMAP-L137.cs b/tools/omapl13x_boot_utils/OMAP-L137/GNU/Common/AISGenLib/AISGen_OMAP-L137.cs
new file mode 100644 (file)
index 0000000..cb425ae
--- /dev/null
@@ -0,0 +1,213 @@
+/*
+ * AISGen_OMAP-L137.cs
+*/
+
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 
+*/
+
+/* 
+ *  Redistribution and use in source and binary forms, with or without 
+ *  modification, are permitted provided that the following conditions 
+ *  are met:
+ *
+ *    Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *    Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the   
+ *    distribution.
+ *
+ *    Neither the name of Texas Instruments Incorporated nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
+ *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
+ *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+*/
+ /* --------------------------------------------------------------------------
+    FILE        : AISGen_OMAP-L137.cs
+    PROJECT     : TI Booting and Flashing Utilities
+    AUTHOR      : Daniel Allred
+    DESC        : Concrete AISGen class implemenatation for OMAP-L137
+ ----------------------------------------------------------------------------- */
+
+using System;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.IO;
+using System.IO.Ports;
+using System.Reflection;
+using System.Threading;
+using System.Globalization;
+using System.Collections;
+using TI.UtilLib.IO;
+using TI.UtilLib.CRC;
+
+namespace TI.AISLib
+{
+  /// <summary>
+  /// AISGen class that is specific to the device (inherits from abtract base class AISGen)
+  /// </summary>
+  public class AISGen_OMAP_L137:AISGen
+  {
+    /// <summary>
+    /// String definitions for built-in ROM functions
+    /// </summary>
+    public struct ROMFunctionNames
+    {
+      public const String PLLConfig           = "PLLConfig";
+      public const String PeriphClockConfig   = "PeriphClockConfig";
+      public const String EMIF3CConfigSDRAM   = "EMIF3CConfigSDRAM";
+      public const String EMIF25ConfigSDRAM   = "EMIF25ConfigSDRAM";
+      public const String EMIF25ConfigAsync   = "EMIF25ConfigAsync";
+      public const String PLLandClockConfig   = "PLLandClockConfig";
+      public const String PSCConfig           = "PSCConfig";
+      public const String PINMUXConfig        = "PinMuxConfig";
+      public const String FastBoot            = "FastBoot";
+    }
+    
+    /// <summary>
+    /// The public constructor for the OMAP_L137 device AIS generator.
+    /// The constructor is where the device differentiation is defined.
+    /// </summary>
+    public AISGen_OMAP_L137() : base()
+    {
+      // Define the device name - used for default file names
+      devNameShort = "OMAP-L137";
+      devNameLong = "OMAPL137";
+            
+      // Define OMAP-L138 ROM boot loader functions
+      ROMFunc = new AisROMFunction[9];
+      
+      ROMFunc[0].funcName = ROMFunctionNames.PLLConfig;
+      ROMFunc[0].iniSectionName = "PLLCONFIG";
+      ROMFunc[0].numParams = 2;
+      ROMFunc[0].paramNames = new String[2] { "PLLCFG0", "PLLCFG1" };
+      
+      ROMFunc[1].funcName = ROMFunctionNames.PeriphClockConfig;
+      ROMFunc[1].iniSectionName = "PERIPHCLKCFG";
+      ROMFunc[1].numParams = 1;
+      ROMFunc[1].paramNames = new String[1] { "PERIPHCLKCFG" };
+
+      ROMFunc[2].funcName = ROMFunctionNames.EMIF3CConfigSDRAM;
+      ROMFunc[2].iniSectionName = "EMIF3SDRAM";
+      ROMFunc[2].numParams = 4;
+      ROMFunc[2].paramNames = new String[4] { "SDCR", "SDTIMR", "SDTIMR2", "SDRCR" };
+
+      ROMFunc[3].funcName = ROMFunctionNames.EMIF25ConfigSDRAM;
+      ROMFunc[3].iniSectionName = "EMIF25SDRAM";
+      ROMFunc[3].numParams = 4;
+      ROMFunc[3].paramNames = new String[4] { "SDBCR", "SDTIMR", "SDRSRPDEXIT", "SDRCR"};
+      
+      ROMFunc[4].funcName = ROMFunctionNames.EMIF25ConfigAsync;
+      ROMFunc[4].iniSectionName = "EMIF25ASYNC";
+      ROMFunc[4].numParams = 4;
+      ROMFunc[4].paramNames = new String[4] { "A1CR", "A2CR", "A3CR", "A4CR" };
+      
+      ROMFunc[5].funcName = ROMFunctionNames.PLLandClockConfig;
+      ROMFunc[5].iniSectionName = "PLLANDCLOCKCONFIG";
+      ROMFunc[5].numParams = 3;
+      ROMFunc[5].paramNames = new String[3] { "PLLCFG0", "PLLCFG1", "PERIPHCLKCFG" };
+      
+      ROMFunc[6].funcName = ROMFunctionNames.PSCConfig;
+      ROMFunc[6].iniSectionName = "PSCCONFIG";
+      ROMFunc[6].numParams = 1;
+      ROMFunc[6].paramNames = new String[1] { "LPSCCFG" };
+
+      ROMFunc[7].funcName = ROMFunctionNames.PINMUXConfig;
+      ROMFunc[7].iniSectionName = "PINMUX";
+      ROMFunc[7].numParams = 3;
+      ROMFunc[7].paramNames = new String[3] { "REGNUM", "MASK", "VALUE" };
+      
+      ROMFunc[8].funcName = ROMFunctionNames.FastBoot;
+      ROMFunc[8].iniSectionName = "FASTBOOT";
+      ROMFunc[8].numParams = 0;
+      ROMFunc[8].paramNames = null;
+      
+      AISExtraFunc = new AisExtraFunction[4];
+      AISExtraFunc[0].funcName = "setEmifB45Div";
+      AISExtraFunc[0].aisExtraFileName = "DSP_AISExtra_"+devNameShort+".out";
+      AISExtraFunc[0].iniSectionName = "DSP_SET_EMIFB_45DIV";
+      AISExtraFunc[0].numParams = 0;      
+      AISExtraFunc[0].paramNames = null;
+      AISExtraFunc[0].isInitFunc = false;
+      
+      AISExtraFunc[1].funcName = "setEmifB45Div";
+      AISExtraFunc[1].aisExtraFileName = "ARM_AISExtra_"+devNameShort+".out";
+      AISExtraFunc[1].iniSectionName = "ARM_SET_EMIFB_45DIV";
+      AISExtraFunc[1].numParams = 0;      
+      AISExtraFunc[1].paramNames = null;
+      AISExtraFunc[1].isInitFunc = false;
+      
+      AISExtraFunc[2].funcName = "setEmifA45Div";
+      AISExtraFunc[2].aisExtraFileName = "DSP_AISExtra_"+devNameShort+".out";
+      AISExtraFunc[2].iniSectionName = "DSP_SET_EMIFA_45DIV";
+      AISExtraFunc[2].numParams = 0;      
+      AISExtraFunc[2].paramNames = null;
+      AISExtraFunc[2].isInitFunc = false;
+      
+      AISExtraFunc[3].funcName = "setEmifA45Div";
+      AISExtraFunc[3].aisExtraFileName = "ARM_AISExtra_"+devNameShort+".out";
+      AISExtraFunc[3].iniSectionName = "ARM_SET_EMIFA_45DIV";
+      AISExtraFunc[3].numParams = 0;      
+      AISExtraFunc[3].paramNames = null;
+      AISExtraFunc[3].isInitFunc = false;      
+
+      // OMAP-L137 is little endian
+      devEndian = Endian.LittleEndian;
+      
+      // OMAP-L137 AIS data is little endian;
+      devAISEndian = Endian.LittleEndian;
+
+      // Create default CRC object for this device
+      devCRC = new CRC32(0x04C11DB7, 0x00000000, 0x00000000, false, 1, UtilLib.CRC.CRCType.INCREMENTAL, UtilLib.CRC.CRCCalcMethod.BITWISE);
+    } 
+    
+    public override retType InsertAISPreamble()
+    {
+      EndianBinaryWriter ebw = new EndianBinaryWriter( this.devAISStream, this.devEndian);
+    
+      switch (this.bootMode)
+      {
+        case AisBootModes.EMIFA:
+        {
+          if (this.busWidth == 16)
+          {
+            this.writer.Write((UInt32)(0x1 << 0)|(0x2 << 4));
+          }
+          else
+          {
+            this.writer.Write((UInt32)(0x0 << 0)|(0x2 << 4));
+          }
+          this.writer.Write((UInt32)AisOps.MagicNumber);
+          break;
+        }
+        default:
+        {
+          this.writer.Write((UInt32)AisOps.MagicNumber);
+          break;
+        }
+      }
+      
+      // Add the AIS magic number to signature buffer if a secure boot image
+      if ( this.SecureType != AisSecureType.NONE )
+      {
+        sigWriter.Write((UInt32)AisOps.MagicNumber);
+      }
+      
+      return retType.SUCCESS;
+    }
+  }
+} //end of AISGenLib namespace
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/GNU/makefile b/tools/omapl13x_boot_utils/OMAP-L137/GNU/makefile
new file mode 100644 (file)
index 0000000..da39bcc
--- /dev/null
@@ -0,0 +1,47 @@
+###########################################################################
+#                                                                         #
+#   Copyright (C) 2012 Texas Instruments Incorporated                     #
+#     http://www.ti.com/                                                  #
+#                                                                         #
+###########################################################################
+
+
+
+#############################################################################
+#                                                                           #
+#  Redistribution and use in source and binary forms, with or without       #
+#  modification, are permitted provided that the following conditions       #
+#  are met:                                                                 #
+#                                                                           #
+#    Redistributions of source code must retain the above copyright         #
+#    notice, this list of conditions and the following disclaimer.          #
+#                                                                           #
+#    Redistributions in binary form must reproduce the above copyright      #
+#    notice, this list of conditions and the following disclaimer in the    #
+#    documentation and/or other materials provided with the                 #
+#    distribution.                                                          #
+#                                                                           #
+#    Neither the name of Texas Instruments Incorporated nor the names of    #
+#    its contributors may be used to endorse or promote products derived    #
+#    from this software without specific prior written permission.          #
+#                                                                           #
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS      #
+#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT        #
+#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR    #
+#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT     #
+#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    #
+#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT         #
+#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,    #
+#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY    #
+#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT      #
+#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE    #
+#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     #
+#                                                                           #
+#############################################################################
+DIRS:=$(wildcard *)
+
+all:
+%::
+               @for i in $(DIRS); do \
+                               if [ -d $${i} ]; then if [ -e $${i}/makefile ]; then make -C $${i} $@; fi; fi; \
+               done
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/device.mak b/tools/omapl13x_boot_utils/OMAP-L137/device.mak
new file mode 100644 (file)
index 0000000..3e17309
--- /dev/null
@@ -0,0 +1,16 @@
+#############################################################
+# Device and Flash types for Makefile use                   #
+#############################################################
+#
+
+# Generic string for device family
+DEVSTRING=OMAP-L137
+
+# Particular device types of the family
+ARM_DEVICETYPES:=AM1707
+DSP_DEVICETYPES:=OMAPL137_v2 OMAPL137_v1 C6747
+
+DEVICETYPES:= $(ARM_DEVICETYPES) $(DSP_DEVICETYPES)
+
+# Supported flash memory types for booting
+FLASHTYPES:=SPI_MEM NAND 
diff --git a/tools/omapl13x_boot_utils/OMAP-L137/makefile b/tools/omapl13x_boot_utils/OMAP-L137/makefile
new file mode 100644 (file)
index 0000000..51899e1
--- /dev/null
@@ -0,0 +1,50 @@
+###########################################################################
+#                                                                         #
+#   Copyright (C) 2012 Texas Instruments Incorporated                     #
+#     http://www.ti.com/                                                  #
+#                                                                         #
+###########################################################################
+
+
+
+#############################################################################
+#                                                                           #
+#  Redistribution and use in source and binary forms, with or without       #
+#  modification, are permitted provided that the following conditions       #
+#  are met:                                                                 #
+#                                                                           #
+#    Redistributions of source code must retain the above copyright         #
+#    notice, this list of conditions and the following disclaimer.          #
+#                                                                           #
+#    Redistributions in binary form must reproduce the above copyright      #
+#    notice, this list of conditions and the following disclaimer in the    #
+#    documentation and/or other materials provided with the                 #
+#    distribution.                                                          #
+#                                                                           #
+#    Neither the name of Texas Instruments Incorporated nor the names of    #
+#    its contributors may be used to endorse or promote products derived    #
+#    from this software without specific prior written permission.          #
+#                                                                           #
+#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS      #
+#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT        #
+#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR    #
+#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT     #
+#  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    #
+#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT         #
+#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,    #
+#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY    #
+#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT      #
+#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE    #
+#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     #
+#                                                                           #
+#############################################################################
+DIRS:=$(wildcard *)
+
+all:
+%::
+# Make sure GNU stuff gets built first
+               make -C GNU $@
+#          make -C CCS $@
+#              @for i in $(DIRS); do \
+#                              if [ -d $${i} ]; then if [ -e $${i}/makefile ]; then make -C $${i} $@; fi; fi; \
+#              done
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/Common/include/device.h b/tools/omapl13x_boot_utils/OMAP-L138/Common/include/device.h
new file mode 100644 (file)
index 0000000..21d3125
--- /dev/null
@@ -0,0 +1,1253 @@
+/* --------------------------------------------------------------------------
+  FILE        : device.h                                                   
+  PROJECT     : DA8xx/OMAP-L138 ROM Boot Loader
+  AUTHOR      : Daniel Allred
+  DESC        : Provides device differentiation for the project files. This
+                file MUST be modified to match the device specifics.
+----------------------------------------------------------------------------- */
+
+#ifndef _DEVICE_H_
+#define _DEVICE_H_
+
+#include "tistdtypes.h"
+
+// Prevent C++ name mangling
+#ifdef __cplusplus
+extern far "c" {
+#endif
+
+/***********************************************************
+* Global Macro Declarations                                *
+***********************************************************/
+
+
+/************************************************************
+* Global Variable Declarations                              *
+************************************************************/
+
+extern const char devString[];
+
+
+/******************************************************
+* Global Typedef declarations                         *
+******************************************************/
+
+typedef enum _DEVICE_CacheType_
+{
+  DEVICE_CACHETYPE_L1P = 0x0,
+  DEVICE_CACHETYPE_L1D = 0x1,
+  DEVICE_CACHETYPE_L2  = 0x2
+}
+DEVICE_CacheType;
+
+// Supported buswidth
+typedef enum _DEVICE_BUSWIDTH_
+{
+  DEVICE_BUSWIDTH_8BIT  = BUS_8BIT,
+  DEVICE_BUSWIDTH_16BIT = BUS_16BIT
+}
+DEVICE_BusWidth;
+
+typedef enum _DEVICE_CHIPREVID_TYPE_
+{
+  DEVICE_CHIPREVID_TYPE_DSPONLY = 0x0, 
+  DEVICE_CHIPREVID_TYPE_ARMONLY = 0x1,
+  DEVICE_CHIPREVID_TYPE_DSPBOOT = 0x2,
+  DEVICE_CHIPREVID_TYPE_ARMBOOT = 0x3
+}
+DEVICE_ChipRevIDType;
+
+typedef enum _DEVICE_BOOTPERIPHERAL_
+{
+  DEVICE_BOOTPERIPHERAL_NONE = 0,
+  DEVICE_BOOTPERIPHERAL_NOR,
+  DEVICE_BOOTPERIPHERAL_UHPI,
+  DEVICE_BOOTPERIPHERAL_SPI,
+  DEVICE_BOOTPERIPHERAL_I2C,
+  DEVICE_BOOTPERIPHERAL_NAND,
+  DEVICE_BOOTPERIPHERAL_USB,
+  DEVICE_BOOTPERIPHERAL_UART,
+  DEVICE_BOOTPERIPHERAL_SDMMC,
+  DEVICE_BOOTPERIPHERAL_RMII,
+  DEVICE_BOOTPERIPHERAL_ESF
+}
+DEVICE_BootPeripheral;
+
+typedef enum _DEVICE_BOOTMODE_
+{
+  DEVICE_BOOTMODE_NONE = 0,
+  DEVICE_BOOTMODE_EMU_DEBUG,  
+  DEVICE_BOOTMODE_NOR_EMIFA,
+  DEVICE_BOOTMODE_NAND_EMIFA_8BIT,
+  DEVICE_BOOTMODE_NAND_EMIFA_16BIT,
+  DEVICE_BOOTMODE_UHPI,                       // 16 bit
+  DEVICE_BOOTMODE_SPI0_FLASH,                 // 24 bit address
+  DEVICE_BOOTMODE_SPI0_EEPROM,                // 16 bit address
+  DEVICE_BOOTMODE_SPI0_SLAVE,                 // 16 bit data
+  DEVICE_BOOTMODE_SPI1_FLASH,                 // 24 bit address
+  DEVICE_BOOTMODE_SPI1_EEPROM,                // 16 bit address
+  DEVICE_BOOTMODE_SPI1_SLAVE,                 // 16 bit data
+  DEVICE_BOOTMODE_I2C0_MASTER,                // 16 bit address
+  DEVICE_BOOTMODE_I2C0_SLAVE,                 // 16 bit data
+  DEVICE_BOOTMODE_I2C1_MASTER,                // 16 bit address
+  DEVICE_BOOTMODE_I2C1_SLAVE,                 // 16 bit data
+  DEVICE_BOOTMODE_UART0,
+  DEVICE_BOOTMODE_UART1,
+  DEVICE_BOOTMODE_UART2,
+  DEVICE_BOOTMODE_ESF,
+  DEVICE_BOOTMODE_SDMMC0,
+  DEVICE_BOOTMODE_SDMMC1,
+  DEVICE_BOOTMODE_USB11,                      // Not supported
+  DEVICE_BOOTMODE_USB20,                      // Not supported
+  DEVICE_BOOTMODE_THB = 0xAA  
+}
+DEVICE_BootMode;
+
+// C6740 Megamodule Power Down Controller 
+typedef struct _DEVICE_C6740_PDC_
+{
+  VUint32 PDCCMD;
+}
+DEVICE_C6740_PDCRegs;
+
+#define PDC ((DEVICE_C6740_PDCRegs *) 0x01810000)
+
+// C6740 IDMA
+typedef struct _DEVICE_C6740_IDMA_
+{
+  VUint32 STAT;
+  VUint32 MASK;
+  VUint32 SOURCE;  
+  VUint32 DEST;
+  VUint32 CNT;  
+}
+DEVICE_C6740_IDMARegs;
+
+#define IDMA0 ((DEVICE_C6740_IDMARegs *) 0x01820000)
+#define IDMA1 ((DEVICE_C6740_IDMARegs *) 0x01820100)
+
+// C6740 L1P Control
+typedef struct _DEVICE_C6740_L1P_
+{
+  VUint8  RSVD0[0x20];    // 0x0000
+  VUint32 L1PCFG;         // 0x0020
+  VUint32 L1PCC;          // 0x0024
+  VUint8  RSVD1[0x3FF8];  // 0x0028
+  VUint32 L1PIBAR;        // 0x4020
+  VUint32 L1PIWC;         // 0x4024
+  VUint8  RSVD2[0x1000];  // 0x4028
+  VUint32 L1PINV;         // 0x5028
+}
+DEVICE_C6740_L1PRegs;
+
+#define L1PCTL ((DEVICE_C6740_L1PRegs *) 0x01840000)
+
+// C6740 L1D Control
+typedef struct _DEVICE_C6740_L1D_
+{
+  VUint8  RSVD0[0x40];    // 0x0000
+  VUint32 L1DCFG;         // 0x0040
+  VUint32 L1DCC;          // 0x0044
+  VUint8  RSVD1[0x3FE8];  // 0x0048
+  VUint32 L1DWIBAR;       // 0x4030
+  VUint32 L1DWIWC;        // 0x4034
+  VUint8  RSVD2[0x08];    // 0x4038
+  VUint32 L1DWBAR;        // 0x4040
+  VUint32 L1DWWC;         // 0x4044
+  VUint32 L1DIBAR;        // 0x4048
+  VUint32 L1DIWC;         // 0x404C
+  VUint8  RSVD3[0xFF0];   // 0x4050
+  VUint32 L1DWB;          // 0x5040
+  VUint32 L1DWBINV;       // 0x5044
+  VUint32 L1DINV;         // 0x5048
+}
+DEVICE_C6740_L1DRegs;
+
+#define L1DCTL ((DEVICE_C6740_L1DRegs *) 0x01840000)
+
+
+// C6740 L2 Control
+typedef struct _DEVICE_C6740_L2_
+{
+  VUint32 L2CFG;          // 0x0000
+  VUint8  RSVD0[0x3FFC];  // 0x0004
+  VUint32 L2WBAR;         // 0x4000
+  VUint32 L2WWC;          // 0x4004
+  VUint8  RSVD1[0x08];    // 0x4008
+  VUint32 L2WIBAR;        // 0x4010
+  VUint32 L2WIWC;         // 0x4014
+  VUint32 L2IBAR;         // 0x4018
+  VUint32 L2IWC;          // 0x401C
+  VUint8  RSVD2[0xFE0];   // 0x4020
+  VUint32 L2WB;           // 0x5000
+  VUint32 L2WBINV;        // 0x5004
+  VUint32 L2INV;          // 0x5008
+}
+DEVICE_C6740_L2Regs;
+
+#define L2CTL ((DEVICE_C6740_L2Regs *) 0x01840000)
+
+
+// C6740 Megamodule memory error controller
+typedef struct _DEVICE_C6740_EDC_
+{
+  VUint8  RSVD0[4];     // 0x000
+  VUint32 L2EDSTAT;     // 0x004
+  VUint32 L2EDCMD;      // 0x008
+  VUint32 L2EDADDR;     // 0x00C
+  VUint32 L2EDPEN0;     // 0x010
+  VUint32 L2EDPEN1;     // 0x014
+  VUint32 L2EDCPEC;     // 0x018
+  VUint32 L2EDNPEC;     // 0x01C
+  VUint8  RSVD1[0x3E4]; // 0x020
+  VUint32 L1PEDSTAT;    // 0x404
+  VUint32 L1PEDCMD;     // 0x408
+  VUint32 L1PEDADDR;    // 0x40C
+}
+DEVICE_C6740_EDCRegs;
+
+#define DSP_EDC ((DEVICE_C6740_EDCRegs *) 0x01846000)
+
+
+// C6740 Megamodule Interrupt Controller
+typedef struct _DEVICE_C6740_INTC_
+{
+  VUint32 EVTFLAG[4];     // 0x000
+  VUint8 RSVD0[16];       // 0x010
+  VUint32 EVTSET[4];      // 0x020
+  VUint8 RSVD1[16];       // 0x030
+  VUint32 EVTCLR[4];      // 0x040
+  VUint8 RSVD2[48];       // 0x050
+  VUint32 EVTMASK[4];     // 0x080
+  VUint8 RSVD3[16];       // 0x090
+  VUint32 MEVTFLAG[4];    // 0x0A0
+  VUint8 RSVD4[16];       // 0x0B0
+  VUint32 EXPMASK[4];     // 0x0C0
+  VUint8 RSVD5[16];
+  VUint32 MEXPFLAG[4];
+  VUint8 RSVD6[20];
+  VUint32 INTMUX1;
+  VUint32 INTMUX2;
+  VUint32 INTMUX3;
+  VUint8 RSVD7[48];
+  VUint32 AEGMUX0;
+  VUint32 AEGMUX1;
+  VUint8 RSVD8[56];
+  VUint32 INTXSTAT;
+  VUint32 INTXCLR;
+  VUint32 INTDMASK;
+  VUint8 RSVD9[52];
+  VUint32 EVTASRT;
+}
+DEVICE_C6740_INTCRegs;
+
+#define DSP_INTC ((DEVICE_C6740_INTCRegs *) 0x01800000)
+
+
+// System Control Module register structure
+typedef struct _DEVICE_SYS_MODULE_REGS_
+{
+  VUint32 REVID;              //0x00
+  VUint8  RSVD0[4];           //0x04
+  VUint32 DIEIDR[4];          //0x08
+  VUint32 DEVIDD[2];          //0x18
+  VUint32 BOOTCFG;            //0x20
+  VUint32 CHIPREVID;          //0x24
+  VUint32 FEATURE_ENA;        //0x28
+  VUint32 L2ROMDIV;           //0x2C
+  VUint8  RSVD1[8];           //0x30
+  VUint32 KICKR[2];           //0x38
+  VUint32 HOSTCFG[2];         //0x40
+  VUint8  RSVD2[152];         //0x48
+  VUint32 IRAWSTRAT;          //0xE0
+  VUint32 IENSTAT;            //0xE4
+  VUint32 IENSET;             //0xE8
+  VUint32 IENCLR;             //0xEC
+  VUint32 EOI;                //0xF0
+  VUint32 FLTADDRR;           //0xF4  
+  VUint32 FLTSTAT;            //0xF8
+  VUint32 FLTCLR;             //0xFC
+  VUint8  RSVD3[16];          //0x100
+  VUint32 MSTPRI[3];          //0x110
+  VUint8  RSVD4[4];           //0x11C
+  VUint32 PINMUX[20];         //0x120
+  VUint32 SUSPSRC;            //0x170
+  VUint32 CHIPSIG;            //0x174
+  VUint32 CHIPSIG_CLR;        //0x178
+  VUint32 CFGCHIP[5];         //0x17C
+  VUint8  RSVD5[5];           //0x190
+  VUint32 ROMCHECKSUM[2];     //0x1A0
+}
+DEVICE_SysModuleRegs;
+
+#define SYSTEM ((DEVICE_SysModuleRegs*) 0x01C14000)
+
+#define DEVICE_BOOTCFG_BOOTMODE_MASK    (0x000000FFu)
+#define DEVICE_BOOTCFG_BOOTMODE_SHIFT   (0)
+
+#define DEVICE_CHIPREVID_TYPE_MASK      (0x00000030u)
+#define DEVICE_CHIPREVID_TYPE_SHIFT     (4)
+
+#define DEVICE_CFGCHIP0_PLL0MASTERLOCK_MASK    (0x00000010u)
+#define DEVICE_CFGCHIP0_PLL0MASTERLOCK_SHIFT   (4)
+
+#define DEVICE_CFGCHIP1_HPIBYTEAD_MASK  (0x00010000u)
+#define DEVICE_CFGCHIP1_HPIBYTEAD_SHIFT (16)
+#define DEVICE_CFGCHIP1_HPIENA_MASK     (0x00008000u)
+#define DEVICE_CFGCHIP1_HPIENA_SHIFT    (15)
+
+#define DEVICE_CFGCHIP3_RMII_MODE_MASK        (0x00000100u)
+#define DEVICE_CFGCHIP3_RMII_MODE_SHIFT       (8)
+#define DEVICE_CFGCHIP3_EMB_2XCLKSRC_MASK     (0x00000080u)
+#define DEVICE_CFGCHIP3_EMB_2XCLKSRC_SHIFT    (7)
+#define DEVICE_CFGCHIP3_RPI_TXCLKSRC_MASK     (0x00000040u)
+#define DEVICE_CFGCHIP3_RPI_TXCLKSRC_SHIFT    (6)
+#define DEVICE_CFGCHIP3_PLL1MASTERLOCK_MASK   (0x00000020u)
+#define DEVICE_CFGCHIP3_PLL1MASTERLOCK_SHIFT  (5)
+#define DEVICE_CFGCHIP3_ASYNC3_CLKSRC_MASK    (0x00000010u)
+#define DEVICE_CFGCHIP3_ASYNC3_CLKSRC_SHIFT   (4)
+#define DEVICE_CFGCHIP3_PRUEVTSEL_MASK        (0x00000008u)
+#define DEVICE_CFGCHIP3_PRUEVTSEL_SHIFT       (3)
+#define DEVICE_CFGCHIP3_DIV4p5ENA_MASK        (0x00000004u)
+#define DEVICE_CFGCHIP3_DIV4p5ENA_SHIFT       (2)
+#define DEVICE_CFGCHIP3_EMA_CLKSRC_MASK       (0x00000002u)
+#define DEVICE_CFGCHIP3_EMA_CLKSRC_SHIFT      (1)
+
+#define DEVICE_L2ROMDIV_ADDRLINE_MASK   (0x000003FFu)
+#define DEVICE_L2ROMDIV_ADDRLINE_SHIFT  (0)
+
+typedef struct _DEVICE_SUBSCHIP_CONFIG_REGS_
+{
+  VUint32 VTPIO_CTL;
+  VUint32 DDR_SLEW;
+  VUint32 DEEPSLEEP;
+  VUint32 PUPD_ENA;
+  VUint32 PUPD_SEL;
+  VUint32 RXACTIVE;
+  VUint32 RSVD0[2];
+}
+DEVICE_SubchipConfigRegs;
+
+#define SUBCHIPCFG ((DEVICE_SubchipConfigRegs*) 0x01E2C000)
+
+#define DEVICE_VTPIO_CTL_READY_MASK       (0x00008000u)
+#define DEVICE_VTPIO_CTL_READY_SHIFT      (15)
+#define DEVICE_VTPIO_CTL_IOPWRDN_MASK     (0x00004000u)
+#define DEVICE_VTPIO_CTL_IOPWRDN_SHIFT    (14)
+#define DEVICE_VTPIO_CTL_CLKRZ_MASK       (0x00002000u)
+#define DEVICE_VTPIO_CTL_CLKRZ_SHIFT      (13)
+#define DEVICE_VTPIO_CTL_PWRSAVE_MASK     (0x00000100u)
+#define DEVICE_VTPIO_CTL_PWRSAVE_SHIFT    (8)
+#define DEVICE_VTPIO_CTL_LOCK_MASK        (0x00000080u)
+#define DEVICE_VTPIO_CTL_LOCK_SHIFT       (7)
+#define DEVICE_VTPIO_CTL_POWERDN_MASK     (0x00000040u)
+#define DEVICE_VTPIO_CTL_POWERDN_SHIFT    (6)
+
+
+// ARM Interrupt Controller register structure
+typedef struct _DEVICE_AINTC_REGS_
+{
+    VUint32 FIQ0;
+    VUint32 FIQ1;
+    VUint32 IRQ0;
+    VUint32 IRQ1;
+    VUint32 FIQENTRY;
+    VUint32 IRQENTRY;
+    VUint32 EINT0;
+    VUint32 EINT1;
+    VUint32 INTCTL;
+    VUint32 EABASE;
+    VUint8 RSVD0[8];
+    VUint32 INTPRI0;
+    VUint32 INTPRI1;
+    VUint32 INTPRI2;
+    VUint32 INTPRI3;
+    VUint32 INTPRI4;
+    VUint32 INTPRI5;
+    VUint32 INTPRI6;
+    VUint32 INTPRI7;
+}
+DEVICE_AIntcRegs;
+
+#define AINTC ((DEVICE_AIntcRegs*) 0xFFFEE000)
+
+
+// PRU Control register structure
+typedef struct _DEVICE_PRU_CTRL_REGS_
+{
+  VUint32 CONTROL;
+  VUint32 STATUS;
+  VUint32 WAKEUP;
+  VUint32 CYCLECNT;
+  VUint32 STALLCNT;
+  VUint8 RSVD0[12];
+  VUint32 CONTABBLKIDX0;
+  VUint32 CONTABBLKIDX1;
+  VUint32 CONTABPROPTR0;
+  VUint32 CONTABPROPTR1;
+  VUint8 RSVD1[976];
+  VUint32 INTGPR0;
+  VUint32 INTGPR1;
+  VUint32 INTGPR2;
+  VUint32 INTGPR3;
+  VUint32 INTGPR4;
+  VUint32 INTGPR5;
+  VUint32 INTGPR6;
+  VUint32 INTGPR7;
+  VUint32 INTGPR8;
+  VUint32 INTGPR9;
+  VUint32 INTGPR10;
+  VUint32 INTGPR11;
+  VUint32 INTGPR12;
+  VUint32 INTGPR13;
+  VUint32 INTGPR14;
+  VUint32 INTGPR15;
+  VUint32 INTGPR16;
+  VUint32 INTGPR17;
+  VUint32 INTGPR18;
+  VUint32 INTGPR19;
+  VUint32 INTGPR20;
+  VUint32 INTGPR21;
+  VUint32 INTGPR22;
+  VUint32 INTGPR23;
+  VUint32 INTGPR24;
+  VUint32 INTGPR25;
+  VUint32 INTGPR26;
+  VUint32 INTGPR27;
+  VUint32 INTGPR28;
+  VUint32 INTGPR29;
+  VUint32 INTGPR30;
+  VUint32 INTGPR31;
+  VUint32 INTCTER0;
+  VUint32 INTCTER1;
+  VUint32 INTCTER2;
+  VUint32 INTCTER3;
+  VUint32 INTCTER4;
+  VUint32 INTCTER5;
+  VUint32 INTCTER6;
+  VUint32 INTCTER7;
+  VUint32 INTCTER8;
+  VUint32 INTCTER9;
+  VUint32 INTCTER10;
+  VUint32 INTCTER11;
+  VUint32 INTCTER12;
+  VUint32 INTCTER13;
+  VUint32 INTCTER14;
+  VUint32 INTCTER15;
+  VUint32 INTCTER16;
+  VUint32 INTCTER17;
+  VUint32 INTCTER18;
+  VUint32 INTCTER19;
+  VUint32 INTCTER20;
+  VUint32 INTCTER21;
+  VUint32 INTCTER22;
+  VUint32 INTCTER23;
+  VUint32 INTCTER24;
+  VUint32 INTCTER25;
+  VUint32 INTCTER26;
+  VUint32 INTCTER27;
+  VUint32 INTCTER28;
+  VUint32 INTCTER29;
+  VUint32 INTCTER30;
+  VUint32 INTCTER31;
+}
+DEVICE_PRUCtrlRegs;
+
+#define PRU0 ((DEVICE_PRUCtrlRegs *) 0x01C37000)
+#define PRU1 ((DEVICE_PRUCtrlRegs *) 0x01C37800)
+
+#define DEVICE_PRU_CONTROL_COUNTENABLE_MASK       (0x00000008u)
+#define DEVICE_PRU_CONTROL_COUNTENABLE_SHIFT      (3)
+#define DEVICE_PRU_CONTROL_ENABLE_MASK            (0x00000002u)
+#define DEVICE_PRU_CONTROL_ENABLE_SHIFT           (1)
+#define DEVICE_PRU_CONTROL_SOFTRESET_MASK         (0x00000001u)
+#define DEVICE_PRU_CONTROL_SOFTRESET_SHIFT        (0)
+#define DEVICE_PRU_CONTROL_RUNSTATE_MASK          (0x00008000u)
+#define DEVICE_PRU_CONTROL_RUNSTATE_SHIFT         (15)
+
+
+// PLL Register structure
+typedef struct _DEVICE_PLL_REGS_
+{
+  VUint32 PID;            // 0x000
+  VUint8 RSVD0[204];      // 0x004
+  VUint32 SHIFTDIV;       // 0x0D0
+  VUint32 CS0;            // 0x0D4
+  VUint32 DFTCNTR;        // 0x0D8
+  VUint32 DFTCNTRCTRL;    // 0x0DC
+  VUint32 FUSERR;         // 0x0E0
+  VUint32 RSTYPE;         // 0x0E4
+  VUint32 RSTCTRL;        // 0x0E8
+  VUint32 RSTCFG;         // 0x0EC
+  VUint32 RSISO;          // 0x0F0
+  VUint8 RSVD1[12];       // 0x0F4
+  VUint32 PLLCTL;         // 0x100
+  VUint32 OCSEL;          // 0x104
+  VUint32 SECCTL;         // 0x108
+  VUint8 RSVD2[4];        // 0x10C
+  VUint32 PLLM;           // 0x110
+  VUint32 PREDIV;
+  VUint32 PLLDIV1;
+  VUint32 PLLDIV2;
+  VUint32 PLLDIV3;
+  VUint32 OSCDIV1;
+  VUint32 POSTDIV;
+  VUint32 BPDIV;
+  VUint32 WAKEUP;
+  VUint8 RSVD3[4];
+  VUint32 PLLCMD;
+  VUint32 PLLSTAT;
+  VUint32 ALNCTL;
+  VUint32 DCHANGE;
+  VUint32 CKEN;
+  VUint32 CKSTAT;
+  VUint32 SYSTAT;
+  VUint8 RSVD4[12];
+  VUint32 PLLDIV4;
+  VUint32 PLLDIV5;
+  VUint32 PLLDIV6;
+  VUint32 PLLDIV7;
+  VUint32 PLLDIV8;
+  VUint32 PLLDIV9;
+  VUint32 PLLDIV10;
+  VUint32 PLLDIV11;
+  VUint32 PLLDIV12;
+  VUint32 PLLDIV13;
+  VUint32 PLLDIV14;
+  VUint8 RSVD5[4];
+  VUint32 PLLDIV15;
+  VUint8 RSVD6[88];
+  VUint32 PLLHDIVEN;
+  VUint32 EMUCNT0;
+  VUint32 EMUCNT1;
+}
+DEVICE_PLLRegs;
+
+#define PLL0 ((DEVICE_PLLRegs*) 0x01C11000)
+#define PLL1 ((DEVICE_PLLRegs*) 0x01E1A000)
+
+#define DEVICE_PLLCTL_PLLEN_MASK      (0x00000001)
+#define DEVICE_PLLCTL_PLLPWRDN_MASK   (0x00000002)
+#define DEVICE_PLLCTL_PLLRST_MASK     (0x00000008)
+#define DEVICE_PLLCTL_PLLDIS_MASK     (0x00000010)
+#define DEVICE_PLLCTL_PLLENSRC_MASK   (0x00000020)
+#define DEVICE_PLLCTL_EXTCLKSRC_MASK  (0x00000200)
+#define DEVICE_PLLCTL_CLKMODE_MASK    (0x00000100)
+
+#define DEVICE_PLLCMD_GOSET_MASK      (0x00000001)
+#define DEVICE_PLLSTAT_GOSTAT_MASK    (0x00000001)
+#define DEVICE_PLLDIV_EN_MASK         (0x00008000)
+
+// Power/Sleep Ctrl Register structure
+typedef struct _DEVICE_PSC_REGS_
+{
+  VUint32 PID;        // 0x000
+  VUint8 RSVD0[16];   // 0x004
+  VUint8 RSVD1[4];    // 0x014
+  VUint32 INTEVAL;    // 0x018
+  VUint8 RSVD2[36];   // 0x01C
+  VUint32 MERRPR0;    // 0x040
+  VUint32 MERRPR1;    // 0x044
+  VUint8 RSVD3[8];    // 0x048
+  VUint32 MERRCR0;    // 0x050
+  VUint32 MERRCR1;    // 0x054
+  VUint8 RSVD4[8];    // 0x058
+  VUint32 PERRPR;     // 0x060
+  VUint8 RSVD5[4];    // 0x064
+  VUint32 PERRCR;     // 0x068
+  VUint8 RSVD6[4];    // 0x06C
+  VUint32 EPCPR;      // 0x070
+  VUint8 RSVD7[4];    // 0x074
+  VUint32 EPCCR;      // 0x078
+  VUint8 RSVD8[144];  // 0x07C
+  VUint8 RSVD9[20];   // 0x10C
+  VUint32 PTCMD;      // 0x120
+  VUint8 RSVD10[4];   // 0x124
+  VUint32 PTSTAT;     // 0x128
+  VUint8 RSVD11[212]; // 0x12C
+  VUint32 PDSTAT0;    // 0x200
+  VUint32 PDSTAT1;    // 0x204
+  VUint8 RSVD12[248]; // 0x208
+  VUint32 PDCTL0;     // 0x300
+  VUint32 PDCTL1;     // 0x304
+  VUint8 RSVD13[536]; // 0x308
+  VUint32 MCKOUT0;    // 0x520
+  VUint32 MCKOUT1;    // 0x524
+  VUint8 RSVD14[728]; // 0x528
+  VUint32 MDSTAT[41]; // 0x800
+  VUint8 RSVD15[348]; // 0x8A4
+  VUint32 MDCTL[41];  // 0xA00
+}
+DEVICE_PSCRegs;
+
+#define PSC0 ((DEVICE_PSCRegs*) 0x01C10000)
+#define PSC1 ((DEVICE_PSCRegs*) 0x01E27000)
+
+#define EMURSTIE_MASK       (0x00000200)
+
+#define PSC_ENABLE          (0x3)
+#define PSC_DISABLE         (0x2)
+#define PSC_SYNCRESET       (0x1)
+#define PSC_SWRSTDISABLE    (0x0)
+
+#define PSC_MDCTL_LRSTZ_MASK     (0x00000100u)
+#define PSC_MDCTL_LRSTZ_SHIFT    (0x00000008u)
+
+#define PSCNUM0             (0x0)
+#define PSCNUM1             (0x1)
+
+#define PD0                 (0x0)
+#define PD1                 (0x1)
+
+// PSC0 (Matrix) defines
+#define LPSC_TPCC           (0)
+#define LPSC_TPTC0          (1)
+#define LPSC_TPTC1          (2)
+#define LPSC_EMIFA          (3)
+#define LPSC_SPI0           (4)
+#define LPSC_SDMMC0         (5)
+#define LPSC_ARMINTC        (6)
+#define LPSC_ARMRAM         (7)
+#define LPSC_SCnKM          (8)
+#define LPSC_UART0          (9)
+#define LPSC_PRU           (13)
+#define LPSC_ARM            (14)
+#define LPSC_DSP            (15)
+
+// PSC1 (Subchip) defines
+#define LPSC_TPCC1          (0)
+#define LPSC_USB0           (1)
+#define LPSC_USB1           (2)
+#define LPSC_GPIO           (3)
+#define LPSC_UHPI0          (4)
+#define LPSC_EMAC           (5)
+#define LPSC_EMIFB          (6)
+#define LPSC_McASP0         (7)
+#define LPSC_SATA           (8)
+#define LPSC_VPIF           (9)
+#define LPSC_SPI1           (10)
+#define LPSC_I2C1           (11)
+#define LPSC_UART1          (12)
+#define LPSC_UART2          (13)
+#define LPSC_McBSP0         (14)
+#define LPSC_McBSP1         (15)
+#define LPSC_LCDC           (16)
+#define LPSC_HR_EPWM        (17)
+#define LPSC_SDMMC1         (18)
+#define LPSC_UPP            (19)
+#define LPSC_ECAP           (20)
+#define LPSC_TPTC2          (21)
+#define LPSC_L3CBA          (31)
+
+
+// AEMIF Register structure - From EMIF 2.5 Spec
+typedef struct _DEVICE_EMIF25_REGS_
+{
+  VUint32 ERCSR;              // 0x00
+  VUint32 AWCCR;              // 0x04
+  VUint32 SDBCR;              // 0x08
+  VUint32 SDRCR;              // 0x0C
+
+  VUint32 A1CR;               // 0x10
+  VUint32 A2CR;               // 0x14
+  VUint32 A3CR;               // 0x18
+  VUint32 A4CR;               // 0x1C
+
+  VUint32 SDTIMR;             // 0x20
+  VUint32 SDRSTAT;            // 0x24
+  VUint32 DDRPHYCR;           // 0x28
+  VUint32 DDRPHYSR;           // 0x2C
+
+  VUint32 SDRACCR;            // 0x30
+  VUint32 SDRACT;             // 0x34
+  VUint32 DDRPHYREV;          // 0x38
+  VUint32 SDRSRPDEXIT;        // 0x3C
+
+  VUint32 EIRR;               // 0x40
+  VUint32 EIMR;               // 0x44
+  VUint32 EIMSR;              // 0x48
+  VUint32 EIMCR;              // 0x4C
+
+  VUint32 IOCR;               // 0x50
+  VUint32 IOSR;               // 0x54
+  VUint8 RSVD0[4];            // 0x58
+  VUint32 ONENANDCTL;         // 0x5C  
+
+  VUint32 NANDFCR;            // 0x60
+  VUint32 NANDFSR;            // 0x64
+  VUint32 PMCR;               // 0x68
+  VUint8 RSVD1[4];            // 0x6C
+
+  VUint32 NANDF1ECC;          // 0x70
+  VUint32 NANDF2ECC;          // 0x74
+  VUint32 NANDF3ECC;          // 0x78
+  VUint32 NANDF4ECC;          // 0x7C
+
+  VUint8 RSVD2[4];            // 0x80
+  VUint32 IODFTEXECNT;        // 0x84
+  VUint32 IODFTGBLCTRL;       // 0x88
+  VUint8 RSVD3[4];            // 0x8C
+
+  VUint32 IODFTMISRLSB;       // 0x90
+  VUint32 IODFTMISRMID;       // 0x94
+  VUint32 IODFTMISRMSB;       // 0x98
+  VUint8 RSVD4[20];           // 0x9C
+
+  VUint32 MODRELNUM;          // 0xB0
+  VUint8 RSVD5[8];            // 0xB4
+  VUint32 NAND4BITECCLOAD;    // 0xBC
+
+  VUint32 NAND4BITECC1;       // 0xC0
+  VUint32 NAND4BITECC2;       // 0xC4
+  VUint32 NAND4BITECC3;       // 0xC8
+  VUint32 NAND4BITECC4;       // 0xCC
+
+  VUint32 NANDERRADD1;        // 0xD0
+  VUint32 NANDERRADD2;        // 0xD4
+  VUint32 NANDERRVAL1;        // 0xD8
+  VUint32 NANDERRVAL2;        // 0xDC
+}
+DEVICE_Emif25Regs;
+
+#define AEMIF ((DEVICE_Emif25Regs*) 0x68000000u)
+
+#define DEVICE_EMIF_NUMBER_CE_REGION                      (4)
+#define DEVICE_EMIF_FIRST_CE_START_ADDR                   (0x60000000u)
+#define DEVICE_EMIF_INTER_CE_REGION_SIZE                  (0x02000000u)
+#define DEVICE_EMIF_NAND_BUS_WIDTH                                               DEVICE_BUSWIDTH_8BIT
+#define DEVICE_EMIF_NAND_BOOT_BASE                                               (0X62000000u)
+#define DEVICE_EMIF_NAND_BOOT_CE                                                 (3)
+#define DEVICE_EMIF_NOR_BOOT_CE                                                          (0x60000000u)
+
+#define DEVICE_EMIF_AxCR_SS_MASK                          (0x80000000u)
+#define DEVICE_EMIF_AxCR_SS_SHIFT                         (31)
+#define DEVICE_EMIF_AxCR_EW_MASK                          (0x40000000u)
+#define DEVICE_EMIF_AxCR_EW_SHIFT                         (30)
+#define DEVICE_EMIF_AxCR_WSETUP_MASK                      (0x3C000000u)
+#define DEVICE_EMIF_AxCR_WSETUP_SHIFT                     (26)
+#define DEVICE_EMIF_AxCR_WSTROBE_MASK                     (0x03F00000u)
+#define DEVICE_EMIF_AxCR_WSTROBE_SHIFT                    (20)
+#define DEVICE_EMIF_AxCR_WHOLD_MASK                       (0x000E0000u)
+#define DEVICE_EMIF_AxCR_WHOLD_SHIFT                      (17)
+#define DEVICE_EMIF_AxCR_RSETUP_MASK                      (0x0001E000u)
+#define DEVICE_EMIF_AxCR_RSETUP_SHIFT                     (13)
+#define DEVICE_EMIF_AxCR_RSTROBE_MASK                     (0x00001F80u)
+#define DEVICE_EMIF_AxCR_RSTROBE_SHIFT                    (7)
+#define DEVICE_EMIF_AxCR_RHOLD_MASK                       (0x00000070u)
+#define DEVICE_EMIF_AxCR_RHOLD_SHIFT                      (4)
+#define DEVICE_EMIF_AxCR_TA_MASK                          (0x0000000Cu)
+#define DEVICE_EMIF_AxCR_TA_SHIFT                         (2)
+#define DEVICE_EMIF_AxCR_ASIZE_MASK                       (0x00000003u)
+#define DEVICE_EMIF_AxCR_ASIZE_SHIFT                      (0)
+
+#define DEVICE_EMIF_AWCC_WAITSTATE_MASK                   (0x000000FF)
+
+#define DEVICE_EMIF_NANDFCR_4BITECC_SEL_MASK              (0x00000030)
+#define DEVICE_EMIF_NANDFCR_4BITECC_SEL_SHIFT              (4)
+
+#define DEVICE_EMIF_NANDFCR_4BITECC_START_MASK            (0x00001000)
+#define DEVICE_EMIF_NANDFCR_4BITECC_START_SHIFT           (12)
+#define DEVICE_EMIF_NANDFCR_4BITECC_ADD_CALC_START_MASK   (0x00002000)
+#define DEVICE_EMIF_NANDFCR_4BITECC_ADD_CALC_START_SHIFT  (13)
+
+#define DEVICE_EMIF_NANDFSR_READY_MASK                    (0x00000001)
+#define DEVICE_EMIF_NANDFSR_READY_SHIFT                   (0)
+
+#define DEVICE_EMIF_NANDFSR_ECC_STATE_MASK                (0x00000F00)
+#define DEVICE_EMIF_NANDFSR_ECC_STATE_SHIFT               (8)
+#define DEVICE_EMIF_NANDFSR_ECC_ERRNUM_MASK               (0x00030000)
+#define DEVICE_EMIF_NANDFSR_ECC_ERRNUM_SHIFT              (16)
+
+
+typedef struct _DEVICE_EMIF3A_REGS_
+{
+  VUint32 ERCSR;
+  VUint32 SDRSTAT;
+  VUint32 SDCR;
+  VUint32 SDRCR;
+  VUint32 SDTIMR;
+  VUint32 SDTIMR2;
+  VUint8 RSVD0[4];
+  VUint32 SDCR2;
+  VUint32 PBBPR;
+  VUint8 RSVD1[4];
+  VUint32 VBCFG1;
+  VUint32 VBCFG2;
+  VUint8 RSVD2[16];
+  VUint32 PERFC1R;
+  VUint32 PERFC2R;
+  VUint32 PCCR;
+  VUint32 PCMRSR;
+  VUint32 PCTR;
+  VUint8 RSVD3[12];
+  VUint32 IODFTGBLCTRL;
+  VUint32 IODFTMISRR;
+  VUint32 IODFTMISADDRRR;
+  VUint32 IODFTMISR1R;
+  VUint32 IODFTMISR2R;
+  VUint32 IODFTMISR3R;
+  VUint8 RSVD4[8];
+  VUint32 ASYNCCS2CR;
+  VUint32 ASYNCCS3CR;
+  VUint32 ASYNCCS4CR;
+  VUint32 ASYNCCS5CR;
+  VUint8 RSVD5[16];
+  VUint32 AWCCR;
+  VUint8 RSVD6[28];
+  VUint32 IRR;
+  VUint32 IMR;
+  VUint32 IMSR;
+  VUint32 IMCR;
+  VUint8 RSVD7[16];
+  VUint32 DDRPHYREV;
+  VUint32 DDRPHYC1R;
+  VUint32 DDRPHYC2R;
+  VUint32 DDRPHYC3R;
+}
+DEVICE_Emif3Regs;
+
+#define EMIF3A ((DEVICE_Emif3Regs*) 0xB0000000u)
+
+#define DEVICE_SDCR_MSDRAMEN_MASK       (0x02000000u)
+#define DEVICE_SDCR_MSDRAMEN_SHIFT      (25)
+#define DEVICE_SDCR_BOOTUNLOCK_MASK     (0x00800000u)
+#define DEVICE_SDCR_BOOTUNLOCK_SHIFT    (23)
+#define DEVICE_SDCR_TIMUNLOCK_MASK      (0x00008000u)
+#define DEVICE_SDCR_TIMUNLOCK_SHIFT     (15)
+#define DEVICE_SDCR_NM_SHIFT            (14)
+#define DEVICE_SDCR_NM_MASK             (0x00004000u)
+
+
+typedef struct _DEVICE_UHPI_REGS
+{
+  VUint32 PID;                // 0x00
+  VUint32 PWREMU_MGMT;        // 0x04
+  VUint32 GPIOINT;            // 0x08
+  VUint32 GPIOEN;             // 0x0C
+  VUint32 GPIODIR1;           // 0x10
+  VUint32 GPIODAT1;           // 0x14
+  VUint32 GPIODIR2;           // 0x18
+  VUint32 GPIODAT2;           // 0x1C
+  VUint32 GPIODIR3;           // 0x20
+  VUint32 GPIODAT3;           // 0x24
+  VUint32 RSVD0[2];           // 0x28
+  VUint32 HPIC;               // 0x30
+  VUint32 HPIAW;              // 0x34
+  VUint32 HPIAR;              // 0x38
+  VUint32 XHPIAW;             // 0x3C
+  VUint32 XHPIAR;             // 0x40
+}
+DEVICE_UHPIRegs;
+
+#define UHPI ((DEVICE_UHPIRegs*) 0x01E10000u)
+
+#define DEVICE_HPIC_HPIRST_MASK     (0x00000080u)
+#define DEVICE_HPIC_HPIRST_SHIFT    (7)
+
+#define DEVICE_HPIC_HINT_MASK       (0x00000004u)
+#define DEVICE_HPIC_HINT_SHIFT      (2)
+
+#define DEVICE_HPIC_DSPINT_MASK     (0x00000002u)
+#define DEVICE_HPIC_DSPINT_SHIFT    (1)
+
+
+
+// UART Register structure - See sprued9b.pdf for more details.
+typedef struct _DEVICE_UART_REGS_
+{
+  VUint32 RBR;
+  VUint32 IER;
+  VUint32 IIR;
+  VUint32 LCR;
+  VUint32 MCR;
+  VUint32 LSR;
+  VUint32 MSR;
+  VUint32 SCR;
+  VUint8  DLL;
+  VUint8  RSVD1[3];
+  VUint8  DLH;
+  VUint8  RSVD2[3];  
+  VUint32 PID1;
+  VUint32 PID2;
+  VUint32 PWREMU_MGMT;
+  VUint32 MDR;
+}
+DEVICE_UARTRegs;
+
+#define THR RBR
+#define FCR IIR
+
+#define UART_PERIPHERAL_CNT (3)
+
+#define UART0 ((DEVICE_UARTRegs*) 0x01C42000)
+#define UART1 ((DEVICE_UARTRegs*) 0x01D0C000)
+#define UART2 ((DEVICE_UARTRegs*) 0x01D0D000)
+
+#define DEVICE_UART0_DESIRED_BAUD   (115200)
+#define DEVICE_UART0_OVERSAMPLE_CNT (16)
+
+#define DEVICE_UART_DLL_MASK                  (0x000000FFu)
+#define DEVICE_UART_DLL_SHIFT                 (0)
+#define DEVICE_UART_DLH_MASK                  (0x000000FFu)
+#define DEVICE_UART_DLH_SHIFT                 (0)
+
+#define DEVICE_UART_PWREMU_MGMT_URST_MASK     (0x00008000u)
+#define DEVICE_UART_PWREMU_MGMT_URST_SHIFT    (15)
+#define DEVICE_UART_PWREMU_MGMT_UTRST_MASK    (0x00004000u)
+#define DEVICE_UART_PWREMU_MGMT_UTRST_SHIFT   (14)
+#define DEVICE_UART_PWREMU_MGMT_URRST_MASK    (0x00002000u)
+#define DEVICE_UART_PWREMU_MGMT_URRST_SHIFT   (13)
+
+#define DEVICE_UART_FCR_RXFIFTL_MASK          (0x000000C0u)
+#define DEVICE_UART_FCR_RXFIFTL_SHIFT         (6)
+#define DEVICE_UART_FCR_DMAMODE1_MASK         (0x00000008u)
+#define DEVICE_UART_FCR_DMAMODE1_SHIFT        (3)
+#define DEVICE_UART_FCR_TXCLR_MASK            (0x00000004u)
+#define DEVICE_UART_FCR_TXCLR_SHIFT           (2)
+#define DEVICE_UART_FCR_RXCLR_MASK            (0x00000002u)
+#define DEVICE_UART_FCR_RXCLR_SHIFT           (1)
+#define DEVICE_UART_FCR_FIFOEN_MASK           (0x00000001u)
+#define DEVICE_UART_FCR_FIFOEN_SHIFT          (0)
+
+#define DEVICE_UART_LSR_RXFIFOE_MASK          (0x00000080u)
+#define DEVICE_UART_LSR_RXFIFOE_SHIFT         (7)
+#define DEVICE_UART_LSR_TEMT_MASK             (0x00000040u)
+#define DEVICE_UART_LSR_TEMT_SHIFT            (6)
+#define DEVICE_UART_LSR_THRE_MASK             (0x00000020u)
+#define DEVICE_UART_LSR_THRE_SHIFT            (5)
+#define DEVICE_UART_LSR_BI_MASK               (0x00000010u)
+#define DEVICE_UART_LSR_BI_SHIFT              (4)
+#define DEVICE_UART_LSR_FE_MASK               (0x00000008u)
+#define DEVICE_UART_LSR_FE_SHIFT              (3)
+#define DEVICE_UART_LSR_PE_MASK               (0x00000004u)
+#define DEVICE_UART_LSR_PE_SHIFT              (2)
+#define DEVICE_UART_LSR_OE_MASK               (0x00000002u)
+#define DEVICE_UART_LSR_OE_SHIFT              (1)
+#define DEVICE_UART_LSR_DR_MASK               (0x00000001u)
+#define DEVICE_UART_LSR_DR_SHIFT              (0)
+
+
+// Timer Register structure - See spruee5a.pdf for more details.
+typedef struct _DEVICE_TIMER_REGS_
+{
+    VUint32 PID12;          // 0x00
+    VUint32 EMUMGT_CLKSPD;  // 0x04
+    VUint8  RSVD0[8];       // 0x08
+    VUint32 TIM12;          // 0x10
+    VUint32 TIM34;          // 0x14
+    VUint32 PRD12;          // 0x18
+    VUint32 PRD34;          // 0x1C
+    VUint32 TCR;            // 0x20
+    VUint32 TGCR;           // 0x24
+    VUint32 WDTCR;          // 0x28
+    VUint8  RSVD1[12];      // 0x2C
+    VUint32 REL12;          // 0x34
+    VUint32 REL34;          // 0x38
+    VUint32 CAP12;          // 0x3C
+    VUint32 CAP34;          // 0x40
+    VUint32 INTCTL_STAT;    // 0x44
+}
+DEVICE_TimerRegs;
+
+#define TIMER0 ((DEVICE_TimerRegs*) 0x01C21400)
+
+// I2C Register structure
+typedef struct _DEVICE_I2C_REGS_
+{
+    VUint32 ICOAR;      // 0x00
+    VUint32 ICIMR;      // 0x04
+    VUint32 ICSTR;      // 0x08
+    VUint32 ICCLKL;     // 0x0C
+    VUint32 ICCLKH;     // 0x10
+    VUint32 ICCNT;      // 0x14
+    VUint32 ICDRR;      // 0x18
+    VUint32 ICSAR;      // 0x1C
+    VUint32 ICDXR;      // 0x20
+    VUint32 ICMDR;      // 0x24
+    VUint32 ICIVR;      // 0x28
+    VUint32 ICEMDR;     // 0x2C
+    VUint32 ICPSC;      // 0x30
+    VUint32 ICPID1;     // 0x34
+    VUint32 ICPID2;     // 0x38
+}
+DEVICE_I2CRegs;
+
+#define I2C0 ((DEVICE_I2CRegs*) 0x01C22000u)
+#define I2C1 ((DEVICE_I2CRegs*) 0x01E28000u)
+
+#define I2C_PERIPHERAL_CNT (2)
+
+#define DEVICE_I2C_TARGET_FREQ      (200000u)
+#define DEVICE_I2C_OWN_ADDRESS      (0x10)
+
+#define I2C_ICMDR_NACKMOD       (0x00008000)
+#define I2C_ICMDR_FRE           (0x00004000)
+#define I2C_ICMDR_STT           (0x00002000)
+#define I2C_ICMDR_STP           (0x00000800)
+#define I2C_ICMDR_MST           (0x00000400)
+#define I2C_ICMDR_TRX           (0x00000200)
+#define I2C_ICMDR_XA            (0x00000100)
+#define I2C_ICMDR_RM            (0x00000080)
+#define I2C_ICMDR_DLB           (0x00000040)
+#define I2C_ICMDR_IRS           (0x00000020)
+#define I2C_ICMDR_STB           (0x00000010)
+#define I2C_ICMDR_FDF           (0x00000008)
+#define I2C_ICMDR_BC8           (0x00000007)
+
+#define I2C_ICSTR_AL_MSK        (0x00000001)
+#define I2C_ICSTR_NACK_MSK      (0x00000002)
+#define I2C_ICSTR_ARDY_MSK      (0x00000004)
+#define I2C_ICSTR_ICRRDY_MSK    (0x00000008)
+#define I2C_ICSTR_ICXRDY_MSK    (0x00000010)
+#define I2C_ICSTR_SCD_MSK       (0x00000020)
+#define I2C_ICSTR_BB_MSK        (0x00001000)
+
+#define I2C_ICEMDR_EXTMODE      (0x00000000)
+
+// SPI Register structure
+typedef struct _DEVICE_SPI_REGS_
+{
+  VUint32 SPIGCR0;          // 0x00
+  VUint32 SPIGCR1;          // 0x04
+  VUint32 SPIINT;           // 0x08
+  VUint32 SPILVL;           // 0x0C
+  VUint32 SPIFLG;           // 0x10
+  VUint32 SPIPC0;           // 0x14
+  VUint32 SPIPC1;           // 0x18
+  VUint32 SPIPC2;           // 0x1C
+  VUint32 SPIPC3;           // 0x20
+  VUint32 SPIPC4;           // 0x24
+  VUint32 SPIPC5;           // 0x28
+  VUint32 SPIPC6;           // 0x2C
+  VUint32 SPIPC7;           // 0x30
+  VUint32 SPIPC8;           // 0x34
+  VUint32 SPIDAT[2];        // 0x38
+  VUint32 SPIBUF;           // 0x40
+  VUint32 SPIEMU;           // 0x44
+  VUint32 SPIDELAY;         // 0x48
+  VUint32 SPIDEF;           // 0x4C
+  VUint32 SPIFMT[4];        // 0x50
+  VUint32 TGINTVEC[2];      // 0x60
+  VUint32 SPIDUMMY[51];
+  VUint32 SPIIOLPBK;
+}
+DEVICE_SPIRegs;
+
+#define SPI0 ((DEVICE_SPIRegs *) 0x01C41000u)
+#define SPI1 ((DEVICE_SPIRegs *) 0x01F0E000u)
+
+#define SPI_PERIPHERAL_CNT (2)
+
+#define DEVICE_SPI_SPIGCR1_SPIEN_MASK     (0x01000000u)
+#define DEVICE_SPI_SPIGCR1_SPIEN_SHIFT    (24)
+
+typedef struct _DEVICE_SDMMC_REGS_
+{
+  VUint32 MMCCTL;
+  VUint32 MMCCLK;
+  VUint32 MMCST0;
+  VUint32 MMCST1;
+  VUint32 MMCIM;
+  VUint32 MMCTOR;
+  VUint32 MMCTOD;
+  VUint32 MMCBLEN;
+  VUint32 MMCNBLK;
+  VUint32 MMCNBLC;
+  VUint32 MMCDRR;
+  VUint32 MMCDXR;
+  VUint32 MMCCMD;
+  VUint32 MMCARGHL;
+  VUint32 MMCRSP01;
+  VUint32 MMCRSP23;
+  VUint32 MMCRSP45;
+  VUint32 MMCRSP67;
+  VUint32 MMCDRSP;
+  VUint8 RSVD0[4];
+  VUint32 MMCCIDX;
+  VUint8 RSVD1[16];
+  VUint32 SDIOCTL;
+  VUint32 SDIOST0;
+  VUint32 SDIOIEN;
+  VUint32 SDIOIST;
+  VUint32 MMCFIFOCTL;
+}
+DEVICE_SDMMCRegs;
+
+#define SDMMC0 ((DEVICE_SDMMCRegs*) 0x01C40000)
+#define SDMMC1 ((DEVICE_SDMMCRegs*) 0x01E1B000)
+#define SDMMC_PERIPHERAL_CNT      (2)
+
+#define SDMMC_MMCCTL_DATRST_MASK   (0x00000001u)
+#define SDMMC_MMCCTL_DATRST_SHIFT  (0)
+#define SDMMC_MMCCTL_CMDRST_MASK   (0x00000002u)
+#define SDMMC_MMCCTL_CMDRST_SHIFT  (1)
+#define SDMMC_MMCCTL_WIDTH0_MASK   (0x00000004u)
+#define SDMMC_MMCCTL_WIDTH0_SHIFT  (2)
+#define SDMMC_MMCCTL_DATEG_MASK    (0x00000C0u)
+#define SDMMC_MMCCTL_DATEG_SHIFT   (6)
+#define SDMMC_MMCCTL_WIDTH1_MASK   (0x00000100u)
+#define SDMMC_MMCCTL_WIDTH1_SHIFT  (8)
+#define SDMMC_MMCCTL_PERMDR_MASK   (0x00000200u)
+#define SDMMC_MMCCTL_PERMDR_SHIFT  (9)
+#define SDMMC_MMCCTL_PERMDX_MASK   (0x00000400u)
+#define SDMMC_MMCCTL_PERMDX_SHIFT  (10)
+
+#define SDMMC_MMCCLK_CLKEN_MASK     (0x00000100u)
+#define SDMMC_MMCCLK_CLKEN_SHIFT    (8)
+#define SDMMC_MMCCLK_CLKRT_MASK     (0x000000FFu)
+#define SDMMC_MMCCLK_CLKRT_SHIFT    (0)
+
+#define SDMMC_MMCTOR_TOR_MASK         (0x000000FFu)
+#define SDMMC_MMCTOR_TOR_SHIFT        (0)
+#define SDMMC_MMCTOR_TOD_25_16_MASK   (0x0003FF00u)
+#define SDMMC_MMCTOR_TOD_25_16_SHIFT  (8)
+
+#define SDMMC_MMCTOD_TOD_15_0_MASK   (0x0000FFFFu)
+#define SDMMC_MMCTOD_TOD_15_0_SHIFT  (0)
+
+#define SDMMC_MMCBLEN_BLEN_MASK     (0x00000FFFu)
+#define SDMMC_MMCBLEN_BLEN_SHIFT    (0)
+
+#define SDMMC_MMCNBLK_NBLK_MASK     (0x0000FFFFu)
+#define SDMMC_MMCNBLK_NBLK_SHIFT    (0)
+
+#define SDMMC_MMCST0_DATDNE_MASK    (0x00000001u)
+#define SDMMC_MMCST0_DATDNE_SHIFT   (0)
+#define SDMMC_MMCST0_BSYDNE_MASK    (0x00000002u)
+#define SDMMC_MMCST0_BSYDNE_SHIFT   (1)
+#define SDMMC_MMCST0_RSPDNE_MASK    (0x00000004u)
+#define SDMMC_MMCST0_RSPDNE_SHIFT   (2)
+#define SDMMC_MMCST0_TOUTRD_MASK    (0x00000008u)
+#define SDMMC_MMCST0_TOUTRD_SHIFT   (3)
+#define SDMMC_MMCST0_TOUTRS_MASK    (0x00000010u)
+#define SDMMC_MMCST0_TOUTRS_SHIFT   (4)
+#define SDMMC_MMCST0_CRCWR_MASK     (0x00000020u)
+#define SDMMC_MMCST0_CRCWR_SHIFT    (5)
+#define SDMMC_MMCST0_CRCRD_MASK     (0x00000040u)
+#define SDMMC_MMCST0_CRCRD_SHIFT    (6)
+#define SDMMC_MMCST0_CRCRS_MASK     (0x00000080u)
+#define SDMMC_MMCST0_CRCRS_SHIFT    (7)
+#define SDMMC_MMCST0_DXRDY_MASK     (0x00000200u)
+#define SDMMC_MMCST0_DXRDY_SHIFT    (9)
+#define SDMMC_MMCST0_DRRDY_MASK     (0x00000400u)
+#define SDMMC_MMCST0_DRRDY_SHIFT    (10)
+
+
+#define SDMMC_MMCCMD_DMATRIG_MASK   (0x00010000u)
+#define SDMMC_MMCCMD_DMATRIG_SHIFT  (16)
+#define SDMMC_MMCCMD_DCLR_MASK      (0x00008000u)
+#define SDMMC_MMCCMD_DCLR_SHIFT     (15)
+#define SDMMC_MMCCMD_INITCK_MASK    (0x00004000u)
+#define SDMMC_MMCCMD_INITCK_SHIFT   (14)
+#define SDMMC_MMCCMD_WDATX_MASK     (0x00002000u)
+#define SDMMC_MMCCMD_WDATX_SHIFT    (13)
+#define SDMMC_MMCCMD_STRMTP_MASK    (0x00001000u)
+#define SDMMC_MMCCMD_STRMTP_SHIFT   (12)
+#define SDMMC_MMCCMD_DTRW_MASK      (0x00000800u)
+#define SDMMC_MMCCMD_DTRW_SHIFT     (11)
+#define SDMMC_MMCCMD_RSPFMT_MASK    (0x00000600u)
+#define SDMMC_MMCCMD_RSPFMT_SHIFT   (9)
+#define SDMMC_MMCCMD_RSPFMT_NONE    (0)
+#define SDMMC_MMCCMD_RSPFMT_R1      (1)
+#define SDMMC_MMCCMD_RSPFMT_R2      (2)
+#define SDMMC_MMCCMD_RSPFMT_R3      (3)
+#define SDMMC_MMCCMD_RSPFMT_R4      SDMMC_MMCCMD_RSPFMT_R1
+#define SDMMC_MMCCMD_RSPFMT_R5      SDMMC_MMCCMD_RSPFMT_R1
+#define SDMMC_MMCCMD_RSPFMT_R6      SDMMC_MMCCMD_RSPFMT_R1
+#define SDMMC_MMCCMD_BSYEXP_MASK    (0x00000100u)
+#define SDMMC_MMCCMD_BSYEXP_SHIFT   (8)
+#define SDMMC_MMCCMD_PPLEN_MASK     (0x00000080u)
+#define SDMMC_MMCCMD_PPLEN_SHIFT    (7)
+#define SDMMC_MMCCMD_CMD_MASK       (0x0000003Fu)
+#define SDMMC_MMCCMD_CMD_SHIFT      (0)
+
+#define SDMMC_MMCFIFOCTL_FIFORST_MASK   (0x00000001u)
+#define SDMMC_MMCFIFOCTL_FIFORST_SHIFT  (0)
+#define SDMMC_MMCFIFOCTL_FIFODIR_MASK   (0x00000002u)
+#define SDMMC_MMCFIFOCTL_FIFODIR_SHIFT  (1)
+#define SDMMC_MMCFIFOCTL_FIFOLEV_MASK   (0x00000004u)
+#define SDMMC_MMCFIFOCTL_FIFOLEV_SHIFT  (2)
+#define SDMMC_MMCFIFOCTL_ACCWD_MASK     (0x00000018u)
+#define SDMMC_MMCFIFOCTL_ACCWD_SHIFT    (3)
+
+
+
+// GPIO Register structures
+typedef struct _DEVICE_GPIO_BANK_REGS_
+{
+  VUint16 DIR[2];
+  VUint16 OUT_DATA[2];
+  VUint16 SET_DATA[2];
+  VUint16 CLR_DATA[2];
+  VUint16 IN_DATA[2];
+  VUint16 SET_RIS_TRIG[2];
+  VUint16 CLR_RIS_TRIG[2];
+  VUint16 SET_FAL_TRIG[2];
+  VUint16 CLR_FAL_TRIG[2];
+  VUint16 INTSTAT[2];
+}
+DEVICE_GPIOBankRegs;
+
+typedef struct _DEVICE_GPIO_REGS_
+{
+  VUint32 PID;
+  VUint32 PCR;
+  VUint32 BINTEN;
+  VUint8 RSVD0[4];
+  DEVICE_GPIOBankRegs BANKPAIR[4];
+} DEVICE_GPIORegs;
+
+#define GPIO ((DEVICE_GPIORegs *) 0x01E26000u)
+
+
+
+/***********************************************************
+* Global Function Declarations                             *
+***********************************************************/
+
+// Execute LPSC state transition
+extern __FAR__ void DEVICE_LPSCTransition(Uint8 pscnum, Uint8 module, Uint8 domain, Uint8 state);
+
+// Pinmux control function
+extern __FAR__ void DEVICE_pinmuxControl(Uint32 regOffset, Uint32 mask, Uint32 value);
+
+// Kick register lock/unlock functions
+extern __FAR__ void    DEVICE_kickUnlock(void);
+extern __FAR__ void    DEVICE_kickLock(void);
+
+// System Initialization prototypes
+extern __FAR__ Uint32  DEVICE_init(void);
+extern __FAR__ void    DEVICE_PSCInit();
+extern __FAR__ Uint32  DEVICE_PLL0Init(Uint8 clk_src, Uint8 pllm, Uint8 prediv, Uint8 postdiv, Uint8 div1 ,Uint8 div3, Uint8 div7);
+extern __FAR__ Uint32  DEVICE_PLL1Init(Uint8 pllm, Uint8 postdiv, Uint8 div1, Uint8 div2, Uint8 div3);
+extern __FAR__ Uint32  DEVICE_ExternalMemInit(Uint32 ddrphycr, Uint32 sdcr, Uint32 sdtimr, Uint32 sdtimr2, Uint32 sdrcr, Uint32 sdcr2);
+
+// Peripheral Initialization prototypes
+extern __FAR__ Uint32  DEVICE_UARTInit(Uint8 periphNum);
+extern __FAR__ Uint32  DEVICE_SPIInit(Uint8 periphNum);
+extern __FAR__ Uint32  DEVICE_I2CInit(Uint8 periphNum);
+extern __FAR__ Uint32  DEVICE_AsyncMemInit(Uint8 interfaceNum);
+extern __FAR__ Uint32  DEVICE_TIMER0Init(void);
+
+// Device boot status functions
+extern __FAR__ DEVICE_BootMode      DEVICE_bootMode( void );
+extern __FAR__ DEVICE_BootPeripheral DEVICE_bootPeripheral(void);
+extern __FAR__ DEVICE_BusWidth      DEVICE_emifBusWidth( void );
+extern __FAR__ DEVICE_ChipRevIDType DEVICE_chipRevIDType( void );
+
+extern __FAR__ void    DEVICE_TIMER0Start(void);
+extern __FAR__ void    DEVICE_TIMER0Stop(void);
+extern __FAR__ Uint32  DEVICE_TIMER0Status(void);
+
+
+/***********************************************************
+* End file                                                 *
+***********************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // End _DEVICE_H_
+
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/Common/include/device_async_mem.h b/tools/omapl13x_boot_utils/OMAP-L138/Common/include/device_async_mem.h
new file mode 100644 (file)
index 0000000..b99b35a
--- /dev/null
@@ -0,0 +1,72 @@
+/* --------------------------------------------------------------------------
+  FILE        : device_async_mem.h
+  PROJECT     : TI Booting and Flashing Utilities
+  AUTHOR      : Daniel Allred
+  DESC        : Provides device differentiation for the project files. This
+                file MUST be modified to match the device/platform specifics.
+----------------------------------------------------------------------------- */
+
+#ifndef _DEVICE_ASYNC_MEM_H_
+#define _DEVICE_ASYNC_MEM_H_
+
+#include "tistdtypes.h"
+#include "async_mem.h"
+
+// Prevent C++ name mangling
+#ifdef __cplusplus
+extern far "c" {
+#endif
+
+/***********************************************************
+* Global Macro Declarations                                *
+***********************************************************/
+
+#define DEVICE_ASYNC_MEM_INTERFACE_CNT  (1)
+#define DEVICE_ASYNC_MEM0_REGION_CNT    (4)
+
+#define DEVICE_ASYNC_MEM_NORBOOT_INTERFACE    (0)
+#define DEVICE_ASYNC_MEM_NORBOOT_REGION       (0)
+
+#define DEVICE_ASYNC_MEM_NANDBOOT_INTERFACE   (0)
+#define DEVICE_ASYNC_MEM_NANDBOOT_REGION      (1)
+
+#if defined(OMAPL138_LCDK)
+  #define DEVICE_ASYNC_MEM_NANDBOOT_BUSWIDTH    (DEVICE_BUSWIDTH_16BIT)
+#elif defined(C6748_LCDK)
+  #define DEVICE_ASYNC_MEM_NANDBOOT_BUSWIDTH    (DEVICE_BUSWIDTH_16BIT)
+#else
+  #define DEVICE_ASYNC_MEM_NANDBOOT_BUSWIDTH    (DEVICE_BUSWIDTH_8BIT)
+#endif
+
+#define DEVICE_ASYNC_MEM_ONENAND_INTERFACE    (0)
+#define DEVICE_ASYNC_MEM_ONENAND_REGION       (0)
+
+
+/***********************************************************
+* Global Typedef Declarations                              *
+***********************************************************/
+
+
+/***********************************************************
+* Global Variable Declarations                             *
+***********************************************************/
+
+extern __FAR__ const ASYNC_MEM_DEVICE_InterfaceObj DEVICE_ASYNC_MEM_interfaces[];
+extern __FAR__ const ASYNC_MEM_DEVICE_InfoObj DEVICE_ASYNC_MEM_info;
+
+
+/***********************************************************
+* Global Function Declarations                             *
+***********************************************************/
+
+
+/***********************************************************
+* End file                                                 *
+***********************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // End _DEVICE_ASYNC_MEM_H_
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/Common/include/device_nand.h b/tools/omapl13x_boot_utils/OMAP-L138/Common/include/device_nand.h
new file mode 100644 (file)
index 0000000..03088ff
--- /dev/null
@@ -0,0 +1,70 @@
+/* --------------------------------------------------------------------------
+  FILE        : device_nand.h
+  PROJECT     : TI Booting and Flashing Utilities
+  AUTHOR      : Daniel Allred
+  DESC        : Provides device differentiation for the project files. This
+                file MUST be modified to match the device specifics.
+----------------------------------------------------------------------------- */
+
+#ifndef _DEVICE_NAND_H_
+#define _DEVICE_NAND_H_
+
+#include "tistdtypes.h"
+
+// Prevent C++ name mangling
+#ifdef __cplusplus
+extern far "c" {
+#endif
+
+/***********************************************************
+* Global Macro Declarations                                *
+***********************************************************/
+
+#define DEVICE_NAND_DATA_OFFSET        (0x00000000u)
+#define DEVICE_NAND_ALE_OFFSET         (0x00000008u)
+#define DEVICE_NAND_CLE_OFFSET         (0x00000010u)
+#define DEVICE_NAND_TIMEOUT            (10240)
+
+#define DEVICE_NAND_MAX_BYTES_PER_OP       (512)   // Max Bytes per operation (EMIF IP constrained)
+#define DEVICE_NAND_MAX_SPAREBYTES_PER_OP  (16)    // Max Spare Bytes per operation
+#define DEVICE_NAND_MIN_SPAREBYTES_PER_OP  (10)    // Min Spare Bytes per operation (ECC operation constrained)
+
+// Defines which NAND blocks the RBL will search in for a UBL image
+#define DEVICE_NAND_RBL_SEARCH_START_BLOCK     (1)
+#define DEVICE_NAND_RBL_SEARCH_END_BLOCK       (5)
+#define DEVICE_NAND_DSPUBL_SEARCH_START_BLOCK  (1)
+#define DEVICE_NAND_DSPUBL_SEARCH_END_BLOCK    (24)
+#define DEVICE_NAND_ARMUBL_SEARCH_START_BLOCK  (2)
+#define DEVICE_NAND_ARMUBL_SEARCH_END_BLOCK    (24)
+#define DEVICE_NAND_UBOOT_SEARCH_START_BLOCK   (4)
+#define DEVICE_NAND_UBOOT_SEARCH_END_BLOCK     (24)
+
+// Defines which NAND blocks are valid for writing the APP data
+#define DEVICE_NAND_UBL_SEARCH_START_BLOCK     (6)
+#define DEVICE_NAND_UBL_SEARCH_END_BLOCK       (50)
+
+// Defines EMIF type used 
+#define EMIF_TYPE_NAND (0)
+#define DEVICE_EMIF_CS_REGION (3)
+#define NAND_BASE_ADDR 0x62000000u
+
+/******************************************************
+* Global Typedef declarations                         *
+******************************************************/
+
+
+/***********************************************************
+* Global Function Declarations                             *
+***********************************************************/
+
+
+/***********************************************************
+* End file                                                 *
+***********************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // End _DEVICE_NAND_H_
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/Common/include/device_sdmmc.h b/tools/omapl13x_boot_utils/OMAP-L138/Common/include/device_sdmmc.h
new file mode 100644 (file)
index 0000000..1851fef
--- /dev/null
@@ -0,0 +1,60 @@
+/* --------------------------------------------------------------------------
+  FILE        : device_sdmmc.h
+  PROJECT     : TI Booting and Flashing Utilities
+  AUTHOR      : Daniel Allred
+  DESC        : Provides device differentiation for the project files. This
+                file MUST be modified to match the device specifics.
+----------------------------------------------------------------------------- */
+
+#ifndef _DEVICE_SDMMC_H_
+#define _DEVICE_SDMMC_H_
+
+#include "tistdtypes.h"
+#include "sdmmc.h"
+
+// Prevent C++ name mangling
+#ifdef __cplusplus
+extern far "c" {
+#endif
+
+/***********************************************************
+* Global Macro Declarations                                *
+***********************************************************/
+
+#define DEVICE_SDMMC_TIMEOUT            (10240)
+#define DEVICE_SDMMCBOOT_PERIPHNUM          (0)
+
+// Define the size of the FIFO for high and low levels
+#define DEVICE_SDMMC_FIFO_LEVEL_LOW_COUNT     (32)
+#define DEVICE_SDMMC_FIFO_LEVEL_LOW_SHIFT     (5)
+#define DEVICE_SDMMC_FIFO_LEVEL_HIGH_COUNT    (64)
+#define DEVICE_SDMMC_FIFO_LEVEL_HIGH_SHIFT    (6)
+
+
+/***********************************************************
+* Global Typedef Declarations                              *
+***********************************************************/
+
+
+/***********************************************************
+* Global Variable Declarations                             *
+***********************************************************/
+
+extern __FAR__ SDMMC_ConfigHandle const hDEVICE_SDMMC_config;
+
+
+/***********************************************************
+* Global Function Declarations                             *
+***********************************************************/
+
+
+/***********************************************************
+* End file                                                 *
+***********************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // End _DEVICE_SDMMC_H_
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/Common/include/device_spi.h b/tools/omapl13x_boot_utils/OMAP-L138/Common/include/device_spi.h
new file mode 100644 (file)
index 0000000..06d462b
--- /dev/null
@@ -0,0 +1,62 @@
+/* --------------------------------------------------------------------------
+  FILE        : device_spi.h
+  PROJECT     : TI Booting and Flashing Utilities
+  AUTHOR      : Daniel Allred
+  DESC        : Provides device differentiation for the project files. This
+                file MUST be modified to match the device specifics.
+----------------------------------------------------------------------------- */
+
+#ifndef _DEVICE_SPI_H_
+#define _DEVICE_SPI_H_
+
+#include "tistdtypes.h"
+#include "spi_mem.h"
+#include "spi.h"
+
+// Prevent C++ name mangling
+#ifdef __cplusplus
+extern far "c" {
+#endif
+
+/***********************************************************
+* Global Macro Declarations                                *
+***********************************************************/
+
+#define DEVICE_SPI_TIMEOUT            (10240)
+#define DEVICE_SPI_DATOFFSET          (1)
+
+#define DEVICE_SPIBOOT_PERIPHNUM          (1)
+#define DEVICE_SPIBOOT_CSNUM              (0)
+
+#define DEVICE_SPI_UBL_HDR_OFFSET     (0*1024)
+#define DEVICE_SPI_APP_HDR_OFFSET     (64*1024)
+
+
+/***********************************************************
+* Global Typedef Declarations                              *
+***********************************************************/
+
+
+/***********************************************************
+* Global Variable Declarations                             *
+***********************************************************/
+
+extern __FAR__ SPI_ConfigHandle const hDEVICE_SPI_config;
+extern __FAR__ SPI_MEM_ParamsHandle const hDEVICE_SPI_MEM_params;
+
+
+/***********************************************************
+* Global Function Declarations                             *
+***********************************************************/
+
+
+/***********************************************************
+* End file                                                 *
+***********************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // End _DEVICE_SPI_H_
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/Common/include/device_uart.h b/tools/omapl13x_boot_utils/OMAP-L138/Common/include/device_uart.h
new file mode 100644 (file)
index 0000000..a22b066
--- /dev/null
@@ -0,0 +1,54 @@
+/* --------------------------------------------------------------------------
+  FILE        : device_uart.h
+  PROJECT     : TI Booting and Flashing Utilities
+  AUTHOR      : Daniel Allred
+  DESC        : Provides device differentiation for the project files. This
+                file MUST be modified to match the device specifics.
+----------------------------------------------------------------------------- */
+
+#ifndef _DEVICE_UART_H_
+#define _DEVICE_UART_H_
+
+#include "tistdtypes.h"
+#include "uart.h"
+
+// Prevent C++ name mangling
+#ifdef __cplusplus
+extern far "c" {
+#endif
+
+/***********************************************************
+* Global Macro Declarations                                *
+***********************************************************/
+
+#define DEVICE_UART_TIMEOUT           (10240)
+#define DEVICE_UART_PERIPHNUM         (2)
+
+
+/***********************************************************
+* Global Typedef Declarations                              *
+***********************************************************/
+
+
+/***********************************************************
+* Global Variable Declarations                             *
+***********************************************************/
+
+extern __FAR__ UART_ConfigHandle const hDEVICE_UART_config;
+
+
+/***********************************************************
+* Global Function Declarations                             *
+***********************************************************/
+
+
+/***********************************************************
+* End file                                                 *
+***********************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // End _DEVICE_SPI_H_
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/Common/include/tps65070.h b/tools/omapl13x_boot_utils/OMAP-L138/Common/include/tps65070.h
new file mode 100644 (file)
index 0000000..feec680
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * TI Booting and Flashing Utilities
+ *
+ * Provides device differentiation for the project files. This file MUST be
+ * modified to match the device specifics.
+ *
+ * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as 
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+/* --------------------------------------------------------------------------
+  AUTHOR      : Platform Support Group
+ --------------------------------------------------------------------------- */
+//I2C functions
+#include "i2c.h"
+
+/******************************************************
+* Global Typedef declarations                         *
+******************************************************/
+//Structure to hold the TPS 65023 related details
+typedef struct tps65070_pmic {
+    I2C_ConfigObj i2cConfig;
+    I2C_InfoHandle       hI2cInfo;
+}TPS_ConfigObj;
+
+#define TPS_MAX_NUM_DEVICES             1u
+#define TPS_REG_OFFSET_PPATH1           0x01u
+#define TPS_REG_OFFSET_INT              0x02u
+#define TPS_REG_OFFSET_CHGCONFIG0       0x03u
+#define TPS_REG_OFFSET_CHGCONFIG1       0x04u
+#define TPS_REG_OFFSET_CHGCONFIG2       0x05u
+#define TPS_REG_OFFSET_CHGCONFIG3       0x06u
+#define TPS_REG_OFFSET_ADCCONFIG        0x07u
+#define TPS_REG_OFFSET_TSCMODE          0x08u
+#define TPS_REG_OFFSET_ADRESULT_1       0x09u
+#define TPS_REG_OFFSET_ADRESULT_2       0x0Au
+#define TPS_REG_OFFSET_PGOOD            0x0Bu
+#define TPS_REG_OFFSET_PGOODMASK        0x0Cu
+#define TPS_REG_OFFSET_CONCTRL1         0x0Du
+#define TPS_REG_OFFSET_CONCTRL2         0x0Eu
+#define TPS_REG_OFFSET_CONCTRL3         0x0Fu
+#define TPS_REG_OFFSET_DEFDCDC1         0x10u
+#define TPS_REG_OFFSET_DEFDCDC2_LOW     0x11u
+#define TPS_REG_OFFSET_DEFDCDC2_HIGH    0x12u
+#define TPS_REG_OFFSET_DEFDCDC3_LOW     0x13u
+#define TPS_REG_OFFSET_DEFDCDC3_HIGH    0x14u
+#define TPS_REG_OFFSET_DEFSLEW          0x15u
+#define TPS_REG_OFFSET_LDOCTRL1         0x16u
+#define TPS_REG_OFFSET_DEFLDO2          0x17u
+#define TPS_REG_OFFSET_WLED_CTRL1       0x18u
+#define TPS_REG_OFFSET_WLED_CTRL2       0x19u
+
+
+
+
+/* Valid voltage ranges for DEFCORE VDCDC1 */
+#define TPS_VDCDC3_MILLIVOLT_725    0x00u
+#define TPS_VDCDC3_MILLIVOLT_750    0x01u
+#define TPS_VDCDC3_MILLIVOLT_775    0x02u
+#define TPS_VDCDC3_MILLIVOLT_800    0x03u
+#define TPS_VDCDC3_MILLIVOLT_825    0x04u
+#define TPS_VDCDC3_MILLIVOLT_850    0x05u
+#define TPS_VDCDC3_MILLIVOLT_875    0x06u
+#define TPS_VDCDC3_MILLIVOLT_900    0x07u
+#define TPS_VDCDC3_MILLIVOLT_925    0x08u
+#define TPS_VDCDC3_MILLIVOLT_950    0x09u
+#define TPS_VDCDC3_MILLIVOLT_975    0x0Au
+#define TPS_VDCDC3_MILLIVOLT_1000   0x0Bu
+#define TPS_VDCDC3_MILLIVOLT_1025   0x0Cu
+#define TPS_VDCDC3_MILLIVOLT_1050   0x0Du
+#define TPS_VDCDC3_MILLIVOLT_1075   0x0Eu
+#define TPS_VDCDC3_MILLIVOLT_1100   0x0Fu
+#define TPS_VDCDC3_MILLIVOLT_1125   0x10u
+#define TPS_VDCDC3_MILLIVOLT_1150   0x11u
+#define TPS_VDCDC3_MILLIVOLT_1175   0x12u
+#define TPS_VDCDC3_MILLIVOLT_1200   0x13u
+#define TPS_VDCDC3_MILLIVOLT_1225   0x14u
+#define TPS_VDCDC3_MILLIVOLT_1250   0x15u
+#define TPS_VDCDC3_MILLIVOLT_1275   0x16u
+#define TPS_VDCDC3_MILLIVOLT_1300   0x17u
+#define TPS_VDCDC3_MILLIVOLT_1325   0x18u
+#define TPS_VDCDC3_MILLIVOLT_1350   0x19u
+#define TPS_VDCDC3_MILLIVOLT_1375   0x1Au
+#define TPS_VDCDC3_MILLIVOLT_1400   0x1Bu
+#define TPS_VDCDC3_MILLIVOLT_1425   0x1Cu
+#define TPS_VDCDC3_MILLIVOLT_1450   0x1Du
+#define TPS_VDCDC3_MILLIVOLT_1475   0x1Eu
+#define TPS_VDCDC3_MILLIVOLT_1500   0x1Fu
+#define TPS_VDCDC3_MILLIVOLT_1550   0x20u
+#define TPS_VDCDC3_MILLIVOLT_1600   0x21u
+#define TPS_VDCDC3_MILLIVOLT_1650   0x22u
+#define TPS_VDCDC3_MILLIVOLT_1700   0x23u
+#define TPS_VDCDC3_MILLIVOLT_1750   0x24u
+#define TPS_VDCDC3_MILLIVOLT_1800   0x25u
+#define TPS_VDCDC3_MILLIVOLT_1850   0x26u
+#define TPS_VDCDC3_MILLIVOLT_1900   0x27u
+#define TPS_VDCDC3_MILLIVOLT_1950   0x28u
+#define TPS_VDCDC3_MILLIVOLT_2000   0x29u
+#define TPS_VDCDC3_MILLIVOLT_2050   0x2Au
+#define TPS_VDCDC3_MILLIVOLT_2100   0x2Bu
+#define TPS_VDCDC3_MILLIVOLT_2150   0x2Cu
+#define TPS_VDCDC3_MILLIVOLT_2200   0x2Du
+#define TPS_VDCDC3_MILLIVOLT_2250   0x2Eu
+#define TPS_VDCDC3_MILLIVOLT_2300   0x2Fu
+#define TPS_VDCDC3_MILLIVOLT_2350   0x30u
+#define TPS_VDCDC3_MILLIVOLT_2400   0x31u
+#define TPS_VDCDC3_MILLIVOLT_2450   0x32u
+#define TPS_VDCDC3_MILLIVOLT_2500   0x33u
+#define TPS_VDCDC3_MILLIVOLT_2550   0x34u
+#define TPS_VDCDC3_MILLIVOLT_2600   0x35u
+#define TPS_VDCDC3_MILLIVOLT_2650   0x36u
+#define TPS_VDCDC3_MILLIVOLT_2700   0x37u
+#define TPS_VDCDC3_MILLIVOLT_2750   0x38u
+#define TPS_VDCDC3_MILLIVOLT_2800   0x39u
+#define TPS_VDCDC3_MILLIVOLT_2850   0x3Au
+#define TPS_VDCDC3_MILLIVOLT_2900   0x3Bu
+#define TPS_VDCDC3_MILLIVOLT_3000   0x3Cu
+#define TPS_VDCDC3_MILLIVOLT_3100   0x3Du
+#define TPS_VDCDC3_MILLIVOLT_3200   0x3Eu
+#define TPS_VDCDC3_MILLIVOLT_3300   0x3Fu
+
+
+
+
+
+
+
+
+/***********************************************************
+* Global Function Declarations                             *
+***********************************************************/
+Uint32                    TPS65070_open(Uint32 instance);
+Uint8          TPS65070_reg_read(Uint32 instance, Uint8 regOffset, Uint8 *buf );
+Uint32         TPS65070_reg_write(Uint32 instance, Uint8 regOffset, Uint8 regVal);
+Uint32                    TPS65070_set_DCDC3_voltage(Uint32 instance, Uint16 volt);
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/Common/src/device_name.cs b/tools/omapl13x_boot_utils/OMAP-L138/Common/src/device_name.cs
new file mode 100644 (file)
index 0000000..d799d65
--- /dev/null
@@ -0,0 +1,23 @@
+/* --------------------------------------------------------------------------
+    FILE        : device_name.cs
+    PROJECT     : TI Booting and Flashing Utilities
+    AUTHOR      : Daniel Allred
+    DESC        : Name adaptor
+ ----------------------------------------------------------------------------- */
+
+using System;
+using System.Text;
+namespace TIBootAndFlash
+{
+  partial class Program
+  {
+    public static String devString = "OMAP-L138";
+    
+    public static UInt32 externalRAMStart = 0xC0000000;
+    
+    public static String[] deviceTypes = { "OMAPL138", "OMAPL138_LCDK", "AM1808", "AM1810", "C6748", "C6746", "C6748_LCDK" };
+    
+    public static String[] flashTypes = { "SPI_MEM", "NAND" , "NOR"};
+  }
+}
\ No newline at end of file
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/AISGen.csproj b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/AISGen.csproj
new file mode 100644 (file)
index 0000000..3e5f222
--- /dev/null
@@ -0,0 +1,160 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProductVersion>9.0.30729</ProductVersion>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{A790903C-C1C8-410F-9D27-7169115E5B09}</ProjectGuid>
+    <OutputType>WinExe</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>AISGen_GUI</RootNamespace>
+    <AssemblyName>AISgen</AssemblyName>
+    <ApplicationIcon>..\..\..\..\Common\ti.ico</ApplicationIcon>
+    <FileUpgradeFlags>
+    </FileUpgradeFlags>
+    <UpgradeBackupLocation>
+    </UpgradeBackupLocation>
+    <OldToolsVersion>3.5</OldToolsVersion>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <PublishUrl>publish\</PublishUrl>
+    <Install>true</Install>
+    <InstallFrom>Disk</InstallFrom>
+    <UpdateEnabled>false</UpdateEnabled>
+    <UpdateMode>Foreground</UpdateMode>
+    <UpdateInterval>7</UpdateInterval>
+    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+    <UpdatePeriodically>false</UpdatePeriodically>
+    <UpdateRequired>false</UpdateRequired>
+    <MapFileExtensions>true</MapFileExtensions>
+    <ApplicationRevision>0</ApplicationRevision>
+    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+    <IsWebBootstrapper>false</IsWebBootstrapper>
+    <UseApplicationTrust>false</UseApplicationTrust>
+    <BootstrapperEnabled>true</BootstrapperEnabled>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>none</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>..</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Deployment" />
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Windows.Forms" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="AboutForm.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="AboutForm.Designer.cs">
+      <DependentUpon>AboutForm.cs</DependentUpon>
+    </Compile>
+    <EmbeddedResource Include="AboutForm.resx">
+      <SubType>Designer</SubType>
+      <DependentUpon>AboutForm.cs</DependentUpon>
+    </EmbeddedResource>
+    <Compile Include="BootMode.cs" />
+    <Compile Include="BootOptions.cs" />
+    <Compile Include="Consts.cs" />
+    <Compile Include="MainForm.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="MainForm.Designer.cs">
+      <DependentUpon>MainForm.cs</DependentUpon>
+    </Compile>
+    <Compile Include="ParamError.cs" />
+    <Compile Include="Program.cs" />
+    <Compile Include="..\..\..\..\Common\AIS\AIS.cs" />
+    <Compile Include="..\..\..\..\Common\AIS\AISGen.cs" />
+    <Compile Include="..\..\Common\AISGenLib\AISGen_OMAP-L138.cs" />
+    <Compile Include="..\..\..\..\Common\UtilLib\ObjectFile.cs" />
+    <Compile Include="..\..\..\..\Common\UtilLib\BinaryFile.cs" />
+    <Compile Include="..\..\..\..\Common\UtilLib\CoffFile.cs" />
+    <Compile Include="..\..\..\..\Common\UtilLib\ElfFile.cs" />
+    <Compile Include="..\..\..\..\Common\UtilLib\CRC.cs" />
+    <Compile Include="..\..\..\..\Common\UtilLib\Debug.cs" />
+    <Compile Include="..\..\..\..\Common\UtilLib\EmbeddedFileIO.cs" />
+    <Compile Include="..\..\..\..\Common\UtilLib\Endian.cs" />
+    <Compile Include="..\..\..\..\Common\UtilLib\HexConv.cs" />
+    <Compile Include="..\..\..\..\Common\UtilLib\Ini.cs" />
+    <Compile Include="..\..\..\..\Common\UtilLib\SerialIO.cs" />
+    <EmbeddedResource Include="MainForm.resx">
+      <SubType>Designer</SubType>
+      <DependentUpon>MainForm.cs</DependentUpon>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Properties\Resources.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+      <SubType>Designer</SubType>
+    </EmbeddedResource>
+    <Compile Include="Properties\Resources.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Resources.resx</DependentUpon>
+      <DesignTime>True</DesignTime>
+    </Compile>
+    <EmbeddedResource Include="..\NAND_ECC_Patch\ARM_nand_ecc_patch_OMAP-L138.out" />
+    <EmbeddedResource Include="..\NAND_ECC_Patch\DSP_nand_ecc_patch_OMAP-L138.out" />
+    <EmbeddedResource Include="..\AISextra\ARM_AISExtra_OMAP-L138.out" />
+    <EmbeddedResource Include="..\AISextra\DSP_AISExtra_OMAP-L138.out" />
+    <None Include="Properties\Settings.settings">
+      <Generator>SettingsSingleFileGenerator</Generator>
+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+    </None>
+    <Compile Include="Properties\Settings.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Settings.settings</DependentUpon>
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
+    </Compile>
+    <Compile Include="Settings.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework Client Profile</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 2.0 %28x86%29</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.0 %28x86%29</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+    <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
+      <Visible>False</Visible>
+      <ProductName>Windows Installer 3.1</ProductName>
+      <Install>true</Install>
+    </BootstrapperPackage>
+  </ItemGroup>
+  <ItemGroup>
+    <Content Include="..\..\..\..\Common\ti.ico" />
+  </ItemGroup>
+  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/AISGen_GUI.sln b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/AISGen_GUI.sln
new file mode 100644 (file)
index 0000000..c315bf5
--- /dev/null
@@ -0,0 +1,17 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual C# Express 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AISGen", "AISGen.csproj", "{A790903C-C1C8-410F-9D27-7169115E5B09}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Release|Any CPU = Release|Any CPU
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {A790903C-C1C8-410F-9D27-7169115E5B09}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {A790903C-C1C8-410F-9D27-7169115E5B09}.Release|Any CPU.Build.0 = Release|Any CPU
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/AboutForm.Designer.cs b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/AboutForm.Designer.cs
new file mode 100644 (file)
index 0000000..332cf6c
--- /dev/null
@@ -0,0 +1,104 @@
+namespace TIBootAndFlash
+{
+    partial class AboutForm
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AboutForm));
+            this.label1 = new System.Windows.Forms.Label();
+            this.label2 = new System.Windows.Forms.Label();
+            this.labelVersion = new System.Windows.Forms.Label();
+            this.button1 = new System.Windows.Forms.Button();
+            this.SuspendLayout();
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Location = new System.Drawing.Point(44, 9);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(165, 13);
+            this.label1.TabIndex = 0;
+            this.label1.Text = "AISgen for D800K008 Bootloader";
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Location = new System.Drawing.Point(48, 55);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(153, 13);
+            this.label2.TabIndex = 1;
+            this.label2.Text = "© 2011 Texas Instruments Inc.";
+            // 
+            // labelVersion
+            // 
+            this.labelVersion.AutoSize = true;
+            this.labelVersion.Location = new System.Drawing.Point(44, 22);
+            this.labelVersion.Name = "labelVersion";
+            this.labelVersion.Size = new System.Drawing.Size(60, 13);
+            this.labelVersion.TabIndex = 2;
+            this.labelVersion.Text = "Version 0.1";
+            // 
+            // button1
+            // 
+            this.button1.Location = new System.Drawing.Point(86, 90);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(80, 24);
+            this.button1.TabIndex = 3;
+            this.button1.Text = "OK";
+            this.button1.UseVisualStyleBackColor = true;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
+            // 
+            // AboutForm
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(252, 126);
+            this.Controls.Add(this.button1);
+            this.Controls.Add(this.labelVersion);
+            this.Controls.Add(this.label2);
+            this.Controls.Add(this.label1);
+            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
+            this.MaximizeBox = false;
+            this.MaximumSize = new System.Drawing.Size(260, 160);
+            this.MinimizeBox = false;
+            this.MinimumSize = new System.Drawing.Size(260, 160);
+            this.Name = "AboutForm";
+            this.Text = "About AISgen";
+            this.Load += new System.EventHandler(this.AboutForm_Load);
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.Label labelVersion;
+        private System.Windows.Forms.Button button1;
+    }
+}
\ No newline at end of file
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/AboutForm.cs b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/AboutForm.cs
new file mode 100644 (file)
index 0000000..9f1422a
--- /dev/null
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Text;
+using System.Windows.Forms;
+
+namespace TIBootAndFlash
+{
+    public partial class AboutForm : Form
+    {
+        private int x, y;
+
+        public AboutForm(int hx, int hy)
+        {
+            InitializeComponent();
+
+            x = hx;
+            y = hy;
+        }
+
+        private void button1_Click(object sender, EventArgs e)
+        {
+            this.Close();
+        }
+
+        private void AboutForm_Load(object sender, EventArgs e)
+        {
+            this.SetDesktopLocation(x, y);
+
+            labelVersion.Text = String.Format("Version {0}.{1}", Consts.majorRev, Consts.minorRev) + Consts.twitchRev;
+        }
+    }
+}
\ No newline at end of file
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/AboutForm.resx b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/AboutForm.resx
new file mode 100644 (file)
index 0000000..c97adf1
--- /dev/null
@@ -0,0 +1,366 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+  <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        AAABAAEAPDoAAAEAIABYOAAAFgAAACgAAAA8AAAAdAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wEAAP9BAAD/mwAA/9UAAP/xAAD/9AAA/90AAP+qAAD/SQAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAD/OAAA/8gAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD/mQAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAA/wIAAP9/AAD/+wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD/NwAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/BQAA/6UAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP/uAAD/AwAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAP8CAAD/oQAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP/DAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAP94AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP+qAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        /zUAAP/7AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP+fAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AwAA
+        /80AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP+tAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/YAAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP/ZAAD/AAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8IAAD/3wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD/KAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP9nAAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD/kQAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wQAAP/dAAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD/9wAA
+        /yQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/1gAAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        /78AAP8EAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AQAA/8wAAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+JAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/RAAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP/+AAD/cQAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8AAAD/vAAA//8AAP//AAD//wAA
+        //8AAP/+AAD/1AAA/5kAAP95AAD/ZwAA/14AAP9eAAD/XgAA/14AAP9eAAD/XgAA/14AAP9sAAD//wAA
+        //8AAP//AAD//gAA/3wAAP8BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8+AAD//gAA//8AAP//AAD//wAA
+        /+YAAP9BAAD/AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8BAAD/6gAA
+        //8AAP//AAD//wAA//8AAP+lAAD/DgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAA/0sAAP/IAAD/9gAA
+        /9gAAP9RAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wIAAP/IAAD//wAA//8AAP//AAD//wAA
+        /0gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/uAAA
+        //8AAP//AAD//wAA//8AAP//AAD/3gAA/0cAAP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/ZQAA//0AAP//AAD//wAA
+        //8AAP/8AAD/VwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/20AAP//AAD//wAA//8AAP//AAD/9AAA
+        /wUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/hgAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//4AAP+vAAD/KwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8rAAD/+AAA//8AAP//AAD//wAA
+        //8AAP//AAD/+AAA/00AAAAAAAAAAAAAAAAAAAAAAAD/RAAA//gAAP//AAD//wAA//8AAP//AAD/7gAA
+        /wIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/UgAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//AAA/6sAAP85AAD/AAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wAAAP+1AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//wAAP+hAAD/UwAA/0YAAP+NAAD/+QAA//8AAP//AAD//wAA//8AAP//AAD//gAA
+        /xQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/HwAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD/0QAA/3QAAP8gAAD/AAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/y8AAP/+AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        /0kAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AgAA
+        /+kAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP/+AAD/0QAA
+        /40AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/5gAAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        /4MAAAAAAAAAAAAA/3sAAP+HAAD/hwAA/4cAAP+HAAD/ZwAAAAAAAAAAAAD/DQAA/2oAAP+FAAD/hwAA
+        /+QAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/DQAA//AAAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        /7YAAAAAAAAAAAAA/8IAAP//AAD//wAA//8AAP//AAD/6AAA/wIAAAAAAAD/fwAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/ZgAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        /+gAAP8AAAAAAAAA/5AAAP//AAD//wAA//8AAP//AAD//gAA/x4AAAAAAAD/fgAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8IAAD/2wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP8bAAAAAAAA/10AAP//AAD//wAA//8AAP//AAD//wAA/08AAAAAAAD/TgAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wAAAP+TAAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP9OAAAAAAAA/ykAAP//AAD//wAA//8AAP//AAD//wAA/4MAAAAAAAD/GQAA//4AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAAAAAAAAAAAAAAAAAAAAAAD/AAAA/3oAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+AAAAAAAAA/wMAAP/zAAD//wAA//8AAP//AAD//wAA/7YAAAAAAAD/AQAA/+QAAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAAAAAAAAAAAAAAAAAP8CAAD/jAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+yAAAAAAAAAAAAAP/DAAD//wAA//8AAP//AAD//wAA/+YAAP8CAAAAAAAA/7MAAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAAAAAAAAAAAA/wcAAP+pAAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP/jAAD/AAAAAAAAAP+QAAD//wAA//8AAP//AAD//wAA//8AAP8cAAAAAAAA/38AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAAAAAAD/BQAA/7AAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP/9AAD/GQAAAAAAAP9dAAD//wAA//8AAP//AAD//wAA//8AAP9PAAAAAAAA/0wAAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP8AAAD/iQAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD/SQAAAAAAAP8rAAD//wAA//8AAP//AAD//wAA//8AAP+CAAAAAAAA/xoAAP/+AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP8sAAD/+wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP/+AAD//AAA
+        //wAAP/8AAD/egAAAAAAAP8EAAD/8gAA//8AAP//AAD//wAA//8AAP+0AAAAAAAA/wEAAP/hAAD//AAA
+        //wAAP/8AAD//gAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+WAAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP+tAAD/DgAA
+        /w4AAP8OAAD/CAAAAAAAAAAAAAD/wwAA//8AAP//AAD//wAA//8AAP/nAAAAAAAAAAAAAP8LAAD/DgAA
+        /w4AAP8OAAD/hwAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//gAA
+        /4sAAP/aAAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP/aAAD/AAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAD/kQAA//8AAP//AAD//wAA//8AAP//AAD/HAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/TgAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD/gQAA
+        /wAAAP+rAAD/rgAA/64AAP+uAAD/rgAA/64AAP+uAAD/rgAA/64AAP+uAAD/rgAA/64AAP+uAAD/rgAA
+        /64AAP+uAAD/ygAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP/8AAD/EgAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAD/XgAA//8AAP//AAD//wAA//8AAP//AAD/TgAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/GwAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP/IAAD/AwAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD/QgAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAD/KwAA//8AAP//AAD//wAA//8AAP//AAD/gQAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/AQAA/+YAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP9OAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD/dQAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAD/BQAA//IAAP//AAD//wAA//8AAP//AAD/tAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAA/7UAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//MAAP8GAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD/qAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/8UAAP//AAD//wAA//8AAP//AAD/5gAA/wEAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAA/4IAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA/8gAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD/4AAA
+        /0YAAP9GAAD/RgAA/0MAAP8AAAAAAAAA/5IAAP//AAD//wAA//8AAP//AAD//gAA/xsAAAAAAAD/HQAA
+        /0YAAP9GAAD/RgAA/4QAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA/7IAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP8WAAAAAAAA/18AAP//AAD//wAA//8AAP//AAD//wAA/00AAAAAAAD/SwAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA/68AAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP9JAAAAAAAA/y0AAP//AAD//wAA//8AAP//AAD//wAA/4EAAAAAAAD/GAAA
+        //4AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA/68AAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP98AAAAAAAA/wUAAP/0AAD//wAA//8AAP//AAD//wAA/7MAAAAAAAD/AQAA
+        /+IAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA/68AAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP+wAAAAAAAAAAAAAP/FAAD//wAA//8AAP//AAD//wAA/+QAAP8BAAAAAAAA
+        /7AAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA/68AAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP/jAAD/AAAAAAAAAP+SAAD//wAA//8AAP//AAD//wAA//4AAP8bAAAAAAAA
+        /30AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA/68AAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP/+AAD/GQAAAAAAAP9gAAD//wAA//8AAP//AAD//wAA//8AAP9NAAAAAAAA
+        /0kAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA/68AAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP/+AAD//AAA//wAAP/8AAD/SwAAAAAAAP8tAAD//AAA//wAAP/8AAD//AAA//wAAP99AAAAAAAA
+        /xgAAP/6AAD//AAA//wAAP/8AAD//AAA//wAAP/8AAD//AAA//wAAP/8AAD//AAA/60AAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+mAAD/DAAA/wwAAP8MAAD/BQAAAAAAAP8BAAD/DAAA/wwAAP8MAAD/DAAA/wwAAP8HAAAAAAAA
+        /wAAAP8MAAD/DAAA/wwAAP8MAAD/DAAA/wwAAP8MAAD/DAAA/wwAAP8MAAD/DAAA/wgAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/YAAA/6gAAP+oAAD/qAAA/6gAAP+oAAD/EQAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/aAAA//8AAP//AAD//wAA//8AAP//AAD/RAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/NgAA//8AAP//AAD//wAA//8AAP//AAD/dwAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/CgAA//gAAP//AAD//wAA//8AAP//AAD/qQAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/88AAP//AAD//wAA//8AAP//AAD/3AAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/4AAAP/KAAD/ygAA/8oAAP/KAAD/yAAA
+        /wsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAD/////+B//8P/////gD//w/////8Af//D/////AB//8P////4AH//w/////gAf//D////8AB//8P//
+        //gAH//w////+AAf//D////wAB//8P////AAD//w////4AAP//D////gAAf/8P///8AAA//w////wAAD
+        //D///+Af+H/8P///4P/4H/w//H/B//gP/D/4P8H/+AP8P/Afgf/8APw/4AYB//wAPD/gAAH//AAAP8A
+        AAOHwAAA/wAAAwOAAAD/AAADA4AAAP4AAAODgAAA/AAAA4GAAAD8AAABgYAAAPAAAAGBgAAA4AAAAYHA
+        AADAAAABwcAAAIAAAAHAwAAAgAAAAcDAAAAAAAAPwPwAAAAAAA/A/gAQAAAAD+D+ADD//4AP4H4AcP//
+        gA/gfgBw//+AB+B+AHD//4AH4H4AcP//gABwcABw//+AAHAwAHD//4AAcDAAcP//gAAwMABw//+AADA4
+        AHD//4AAODgAcP//gAA4OABw//+AAf////D//4AB////8P//gAH8H//w//+AAfwf//D//4AB/B//8P//
+        gAH8D//w//+AAfwP//D//4AB/A//8P//gAH////w//+AAf////D//4AB////8A==
+</value>
+  </data>
+</root>
\ No newline at end of file
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/BootMode.cs b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/BootMode.cs
new file mode 100644 (file)
index 0000000..30f3eb8
--- /dev/null
@@ -0,0 +1,217 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TIBootAndFlash
+{
+    class BootMode
+    {
+        // constants
+        private const double SPEED_i2c = 100.0;
+        private const double SPEED_spi = 1.0;
+        private const double SPEED_uart = 115200.0;
+        private const double SPEED_mmcsd = 5.0;
+        private const uint TIMING_default = 0x3FFFFFFC;
+        private const uint TIMING_mask = 0xFFFFFFFC;
+        private const uint TIMING_8bit = 0x0;
+        private const uint TIMING_16bit = 0x1;
+
+        // public members
+        public String name, peripheralName, speedName;
+        public int psc, div, flashWidth;
+        public uint flashTiming, savedNORtiming, savedNANDtiming;
+        public double minSpeed, maxSpeed, targetSpeed, savedI2cSpeed,
+            savedSpiSpeed, savedUartSpeed, savedMmcsdSpeed;
+        public bool isConfigurable, allowSeqRead, allowSpeedChange, isI2c,
+            isSpi, isUart, isMmcsd, isFlash, isNOR, isNAND;
+
+        public BootMode(String givenName)
+        {
+            isConfigurable = false;
+            isFlash = false;
+            allowSeqRead = false;
+            allowSpeedChange = false;
+
+            psc = 1;
+            div = 1;
+
+            // save default peripheral speeds
+            savedI2cSpeed = SPEED_i2c;
+            savedSpiSpeed = SPEED_spi;
+            savedUartSpeed = SPEED_uart;
+            savedMmcsdSpeed = SPEED_mmcsd;
+
+            // default flash settings
+            flashTiming = TIMING_default;
+            savedNORtiming = TIMING_default;
+            savedNANDtiming = TIMING_default;
+            flashWidth = (int)Consts.FlashWidth.eightbit;
+
+            select(givenName);
+        }
+
+        public void select(String newName)
+        {
+            name = newName;
+
+            isI2c = false;
+            isSpi = false;
+            isUart = false;
+            isMmcsd = false;
+            isNAND = false;
+            isNOR = false;
+            isFlash = false;
+
+            // determine peripheral type
+            if (name.Contains("I2C"))
+            {
+                peripheralName = "I2C";
+                speedName = "kHz";
+                minSpeed = 1.0;
+                maxSpeed = 400.0;
+                targetSpeed = savedI2cSpeed;
+                isI2c = true;
+            }
+            else if (name.Contains("SPI"))
+            {
+                peripheralName = "SPI";
+                speedName = "MHz";
+                minSpeed = 1.0;
+                maxSpeed = 50.0;
+                targetSpeed = savedSpiSpeed;
+                isSpi = true;
+            }
+            else if (name.Contains("UART"))
+            {
+                peripheralName = "UART";
+                speedName = "baud";
+                minSpeed = 110.0;
+                maxSpeed = 230400.0;
+                targetSpeed = savedUartSpeed;
+                isUart = true;
+            }
+            else if (name.Contains("MMC"))
+            {
+                peripheralName = "MMC/SD";
+                speedName = "MHz";
+                minSpeed = 1.0;
+                maxSpeed = 50.0;
+                targetSpeed = savedMmcsdSpeed;
+                isMmcsd = true;
+            }
+            else
+            {
+                // other peripherals shouldn't be configurable
+                peripheralName = "Invalid";
+                speedName = "mph";
+                minSpeed = 15.0;
+                maxSpeed = 70.0;
+            }
+
+            // display tab for EEPROM cases, UART, and MMC (above)
+            if (name.Contains("EEPROM") || (isSpi && name.Contains("Flash")))
+            {
+                isConfigurable = true;
+                allowSpeedChange = true;
+                allowSeqRead = true;
+            }
+            else if (isUart)
+            {
+                isConfigurable = true;
+                allowSpeedChange = true;
+                allowSeqRead = false;
+            }
+            else if (isMmcsd)
+            {
+                isConfigurable = true;
+                allowSpeedChange = true;
+                allowSeqRead = false;
+            }
+            else
+            {
+                isConfigurable = false;
+                allowSeqRead = false;
+                allowSpeedChange = false;
+            }
+
+            // display flash tab for NOR, NAND
+            if (name.Contains("NOR"))
+            {
+                isFlash = true;
+                isNOR = true;
+                flashTiming = savedNORtiming;
+            }
+            else if (name.Contains("NAND"))
+            {
+                isFlash = true;
+                isNAND = true;
+                flashTiming = savedNANDtiming;
+            }
+        }
+
+        public void saveSpeed()
+        {
+            if (isI2c)
+                savedI2cSpeed = targetSpeed;
+            else if (isSpi)
+                savedSpiSpeed = targetSpeed;
+            else if (isUart)
+                savedUartSpeed = targetSpeed;
+            else if (isMmcsd)
+                savedMmcsdSpeed = targetSpeed;
+        }
+
+        public int getIndex()
+        {
+            // Returns index of combo box entry in main form.  Must be updated
+            // if combo box collection is modified or re-ordered.
+
+            switch (name)
+            {
+                case "NOR Flash":   return 0;
+                case "NAND Flash":  return 1;
+                case "MMC/SD0":     return 2;
+                case "SPI0 Flash":  return 3;
+                case "SPI1 Flash":  return 4;
+                case "I2C0 EEPROM": return 5;
+                case "I2C1 EEPROM": return 6;
+                case "SPI0 EEPROM": return 7;
+                case "SPI1 EEPROM": return 8;
+                case "I2C0 Slave":  return 9;
+                case "I2C1 Slave":  return 10;
+                case "SPI0 Slave":  return 11;
+                case "SPI1 Slave":  return 12;
+                case "UART0":       return 13;
+                case "UART1":       return 14;
+                case "UART2":       return 15;
+                default:            return 0;   // should never come here
+            }
+        }
+
+        public void saveFlash()
+        {
+            if (isNAND)
+                savedNANDtiming = flashTiming;
+            else if (isNOR)
+                savedNORtiming = flashTiming;
+        }
+
+        public void flashTimingUpdate()
+        {
+            // apply data width to timing value
+            flashTiming &= TIMING_mask;
+            if (flashWidth == (int)Consts.FlashWidth.eightbit)
+                flashTiming |= TIMING_8bit;
+            else
+                flashTiming |= TIMING_16bit;
+        }
+
+        public bool flashTimingIsSixteenBit()
+        {
+            if ((flashTiming & TIMING_16bit) == 1)
+                return true;
+            else
+                return false;
+        }
+    }
+}
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/BootOptions.cs b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/BootOptions.cs
new file mode 100644 (file)
index 0000000..b8c7d40
--- /dev/null
@@ -0,0 +1,514 @@
+using System;
+using System.IO;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TIBootAndFlash
+{
+    class BootOptions
+    {
+        // selected boot mode
+        public BootMode boot;
+
+        // numeric settings
+        public int romID, deviceType, clockType, pll0preDiv,
+            pll0Mult, pll0postDiv, pll0div1, pll0div3,
+            pll0div7, pll1Mult, pll1postDiv, pll1div1,
+            pll1div2, pll1div3;
+        public double inputClock;
+        public uint entrypoint, sdramSdbcr, sdramSdtmr, sdramSdrsrpdexit,
+            sdramSdrcr, ddr2Phy, ddr2Sdcr, ddr2Sdcr2, ddr2Sdtimr,
+            ddr2Sdtimr2, ddr2Sdrcr;
+
+        // boolean settings
+        public bool configPeriph, configPll0, configSdram, configPll1,
+            configDdr2, configLpsc, configPinmux, enableCRC,
+            specifyEntrypoint, enableSeqRead, sdramDiv45,
+            ddr2directClk, configFlash, useMDDR, useDuplicateMddrSetting;
+
+        // lpsc and pinmux lists
+        public int[] lpsc0enable, lpsc0disable, lpsc0syncRst, lpsc1enable,
+            lpsc1disable, lpsc1syncRst, pinmuxReg;
+        public uint[] pinmuxVal;
+        public bool[] pinmuxApply;
+
+        // file name settings
+        public String[] appFileName;
+        public uint[] appFileAddr;
+        public String aisFileName;
+        public String cfgFileName;
+
+        public BootOptions()
+        {
+            // Define defaults; most are applied when app starts
+
+            // boot mode
+            boot = new BootMode("NOR Flash");
+
+            // numeric
+            romID = (int)Consts.RomID.d800k008;
+            deviceType = 1;
+            clockType = 0;
+            inputClock = 24.00;
+            entrypoint = 0;
+            pll0preDiv = 1;
+            pll0Mult = 20;
+            pll0postDiv = 2;
+            pll0div1 = 1;
+            pll0div3 = 3;
+            pll0div7 = 6;
+            sdramSdbcr = 0;
+            sdramSdtmr = 0;
+            sdramSdrsrpdexit = 0;
+            sdramSdrcr = 0;
+            pll1Mult = 20;
+            pll1postDiv = 2;
+            pll1div1 = 1;
+            pll1div2 = 2;
+            pll1div3 = 3; 
+            ddr2Phy = 0;
+            ddr2Sdcr = 0;
+            ddr2Sdcr2 = 0;
+            ddr2Sdtimr = 0;
+            ddr2Sdtimr2 = 0;
+            ddr2Sdrcr = 0;
+            lpsc0enable = new int[0];
+            lpsc0disable = new int[0];
+            lpsc0syncRst = new int[0];
+            lpsc1enable = new int[0];
+            lpsc1disable = new int[0];
+            lpsc1syncRst = new int[0];
+            pinmuxReg = new int[20];
+            pinmuxVal = new uint[20];            
+
+            // boolean
+            configPeriph = false;
+            configPll0 = false;
+            configSdram = false;
+            configPll1 = false;
+            configDdr2 = false;
+            configLpsc = false;
+            configPinmux = false;
+            enableCRC = false;
+            specifyEntrypoint = false;
+            enableSeqRead = false;
+            sdramDiv45 = false;
+            ddr2directClk = false;
+            pinmuxApply = new bool[20];
+            for (int i = 0; i < 20; i++)
+                pinmuxApply[i] = false;
+            useMDDR = true;
+            useDuplicateMddrSetting = false;
+            // file settings
+            appFileName = new String[1];
+            appFileName[0] = "";
+            appFileAddr = new uint[1];
+            appFileAddr[0] = (uint)Consts.BinAddr.invalid;
+            aisFileName = "";
+            cfgFileName = "";
+        }
+
+        public void saveToFile(String fileName, String appFileString)
+        {
+            String tokens;
+            int i;
+
+            // save file name
+            cfgFileName = fileName;
+
+            StreamWriter s = new StreamWriter(fileName);
+
+            // save boot mode (name, target speed, and flash params will suffice)
+            s.WriteLine("Boot Mode=" + boot.name);
+            s.WriteLine(String.Format("Boot Speed={0}", boot.targetSpeed));
+            s.WriteLine("Flash Width=" + boot.flashWidth.ToString());
+            s.WriteLine("Flash Timing=" + Convert.ToString(boot.flashTiming, 16));
+            
+            // save boolean values
+            s.WriteLine("Configure Peripheral=" + configPeriph.ToString());
+            s.WriteLine("Configure PLL0=" + configPll0.ToString());
+            s.WriteLine("Configure SDRAM=" + configSdram.ToString());
+            s.WriteLine("Configure PLL1=" + configPll1.ToString());
+            s.WriteLine("Configure DDR2=" + configDdr2.ToString());
+            s.WriteLine("Configure LPSC=" + configLpsc.ToString());
+            s.WriteLine("Configure Pinmux=" + configPinmux.ToString());
+            s.WriteLine("Enable CRC=" + enableCRC.ToString());
+            s.WriteLine("Specify Entrypoint=" + specifyEntrypoint.ToString());
+            s.WriteLine("Enable Sequential Read=" + enableSeqRead.ToString());
+            s.WriteLine("Use 4.5 Clock Divider=" + sdramDiv45.ToString());
+            s.WriteLine("Use DDR2 Direct Clock=" + ddr2directClk.ToString());
+            s.WriteLine("Use mDDR=" + useMDDR.ToString());
+            s.WriteLine("Use DuplicateMddrSetting=" + useDuplicateMddrSetting.ToString());
+
+            // save numeric values
+            s.WriteLine("ROM ID=" + romID.ToString());
+            s.WriteLine("Device Type=" + deviceType.ToString());
+            s.WriteLine(String.Format("Input Clock Speed={0}", inputClock));
+            s.WriteLine("Clock Type=" + clockType.ToString());
+            s.WriteLine("PLL0 Pre Divider=" + pll0preDiv.ToString());
+            s.WriteLine("PLL0 Multiplier=" + pll0Mult.ToString());
+            s.WriteLine("PLL0 Post Divider=" + pll0postDiv.ToString());
+            s.WriteLine("PLL0 Div1=" + pll0div1.ToString());
+            s.WriteLine("PLL0 Div3=" + pll0div3.ToString());
+            s.WriteLine("PLL0 Div7=" + pll0div7.ToString());
+            s.WriteLine("PLL1 Multiplier=" + pll1Mult.ToString());
+            s.WriteLine("PLL1 Post Divider=" + pll1postDiv.ToString());
+            s.WriteLine("PLL1 Div1=" + pll1div1.ToString());
+            s.WriteLine("PLL1 Div2=" + pll1div2.ToString());
+            s.WriteLine("PLL1 Div3=" + pll1div3.ToString());
+            s.WriteLine("Entrypoint=" + Convert.ToString(entrypoint, 16));
+            s.WriteLine("SDRAM SDBCR=" + Convert.ToString(sdramSdbcr, 16));
+            s.WriteLine("SDRAM SDTMR=" + Convert.ToString(sdramSdtmr, 16));
+            s.WriteLine("SDRAM SDRSRPDEXIT=" + Convert.ToString(sdramSdrsrpdexit, 16));
+            s.WriteLine("SDRAM SDRCR=" + Convert.ToString(sdramSdrcr, 16));
+            s.WriteLine("DDR2 PHY=" + Convert.ToString(ddr2Phy, 16));
+            s.WriteLine("DDR2 SDCR=" + Convert.ToString(ddr2Sdcr, 16));
+            s.WriteLine("DDR2 SDCR2=" + Convert.ToString(ddr2Sdcr2, 16));
+            s.WriteLine("DDR2 SDTIMR=" + Convert.ToString(ddr2Sdtimr, 16));
+            s.WriteLine("DDR2 SDTIMR2=" + Convert.ToString(ddr2Sdtimr2, 16));
+            s.WriteLine("DDR2 SDRCR=" + Convert.ToString(ddr2Sdrcr, 16));
+
+            // save lpsc and pinmux list
+            tokens = "";
+            for (i = 0; i < lpsc0enable.Length; i++)
+                tokens += lpsc0enable[i].ToString() + "+";
+            s.WriteLine("LPSC0 Enable=" + tokens);
+
+            tokens = "";
+            for (i = 0; i < lpsc0disable.Length; i++)
+                tokens += lpsc0disable[i].ToString() + "+";
+            s.WriteLine("LPSC0 Disable=" + tokens);
+
+            tokens = "";
+            for (i = 0; i < lpsc0syncRst.Length; i++)
+                tokens += lpsc0syncRst[i].ToString() + "+";
+            s.WriteLine("LPSC0 SyncRst=" + tokens);
+
+            tokens = "";
+            for (i = 0; i < lpsc1enable.Length; i++)
+                tokens += lpsc1enable[i].ToString() + "+";
+            s.WriteLine("LPSC1 Enable=" + tokens);
+
+            tokens = "";
+            for (i = 0; i < lpsc1disable.Length; i++)
+                tokens += lpsc1disable[i].ToString() + "+";
+            s.WriteLine("LPSC1 Disable=" + tokens);
+
+            tokens = "";
+            for (i = 0; i < lpsc1syncRst.Length; i++)
+                tokens += lpsc1syncRst[i].ToString() + "+";
+            s.WriteLine("LPSC1 SyncRst=" + tokens);
+
+            tokens = "";
+            for (i = 0; i < 20; i++)
+                if (pinmuxApply[i])
+                    tokens += pinmuxReg[i].ToString() + ":" + Convert.ToString(pinmuxVal[i], 16) + "+";
+            s.WriteLine("Pinmux=" + tokens);
+
+            // save strings (exclude cfgFileName)
+            s.WriteLine("App File String=" + appFileString);
+            s.WriteLine("AIS File Name=" + aisFileName);
+
+            // close file
+            s.Close();
+        }
+
+        public void loadFromFile(String fileName, out String appFileString)
+        {
+            String[] keyVal, subVal, subSubVal;
+
+            // set app file string initially in case it's not found in file
+            appFileString = "";
+
+            // save file name
+            cfgFileName = fileName;
+            char[] sep = { '=' };
+            char[] subSep = { '+' };
+            char[] subSubSep = { ':' };
+
+            // slurp file and separate by newlines,
+            // then look for strings containing "<name>="
+            String[] fileLines = File.ReadAllLines(fileName);
+
+            // check each line for "<key>=<value>" and apply settings
+            for (int i = 0; i < fileLines.Length; i++)
+            {
+                keyVal = fileLines[i].Split(sep, StringSplitOptions.None);
+                // skip to next line if there isn't exactly one '='
+                if (keyVal.Length != 2) continue;
+
+                switch (keyVal[0])
+                {
+                    case "Boot Mode":
+                        boot.select(keyVal[1]);
+                        break;
+
+                    case "Boot Speed":
+                        // note: may break if "Boot Speed" comes before "Boot Mode"
+                        boot.targetSpeed = Convert.ToDouble(keyVal[1]);
+                        boot.saveSpeed();
+                        break;
+
+                    case "Flash Width":
+                        // note: may break if "Flash Width" comes before "Boot Mode"
+                        boot.flashWidth = Convert.ToInt32(keyVal[1], 10);
+                        break;
+
+                    case "Flash Timing":
+                        // note: may break if "Flash Timing" comes before "Boot Mode"
+                        boot.flashTiming = Convert.ToUInt32(keyVal[1], 16);
+                        boot.saveFlash();
+                        break;
+
+                    // boolean
+                    case "Configure Peripheral":
+                        configPeriph = Convert.ToBoolean(keyVal[1]);
+                        break;
+
+                    case "Configure PLL0":
+                        configPll0 = Convert.ToBoolean(keyVal[1]);
+                        break;
+
+                    case "Configure SDRAM":
+                        configSdram = Convert.ToBoolean(keyVal[1]);
+                        break;
+
+                    case "Configure PLL1":
+                        configPll1 = Convert.ToBoolean(keyVal[1]);
+                        break;
+
+                    case "Configure DDR2":
+                        configDdr2 = Convert.ToBoolean(keyVal[1]);
+                        break;
+
+                    case "Configure LPSC":
+                        configLpsc = Convert.ToBoolean(keyVal[1]);
+                        break;
+
+                    case "Configure Pinmux":
+                        configPinmux = Convert.ToBoolean(keyVal[1]);
+                        break;
+
+                    case "Enable CRC":
+                        enableCRC = Convert.ToBoolean(keyVal[1]);
+                        break;
+
+                    case "Specify Entrypoint":
+                        specifyEntrypoint = Convert.ToBoolean(keyVal[1]);
+                        break;
+
+                    case "Enable Sequential Read":
+                        enableSeqRead = Convert.ToBoolean(keyVal[1]);
+                        break;
+
+                    case "Use 4.5 Clock Divider":
+                        sdramDiv45 = Convert.ToBoolean(keyVal[1]);
+                        break;
+
+                    case "Use DDR2 Direct Clock":
+                        ddr2directClk = Convert.ToBoolean(keyVal[1]);
+                        break;
+
+                    case "Use mDDR":
+                        useMDDR = Convert.ToBoolean(keyVal[1]);
+                        break;
+
+                    case "Use DuplicateMddrSetting":
+                        useDuplicateMddrSetting = Convert.ToBoolean(keyVal[1]);
+                        break;
+
+                    // numeric
+                    case "ROM ID":
+                        romID = Convert.ToInt32(keyVal[1], 10);
+                        break;
+
+                    case "Device Type":
+                        deviceType = Convert.ToInt32(keyVal[1], 10);
+                        break;
+
+                    case "Input Clock Speed":
+                        inputClock = Convert.ToDouble(keyVal[1]);
+                        break;
+
+                    case "Clock Type":
+                        clockType = Convert.ToInt32(keyVal[1], 10);
+                        break;
+
+                    case "PLL0 Pre Divider":
+                        pll0preDiv = Convert.ToInt32(keyVal[1], 10);
+                        break;
+
+                    case "PLL0 Multiplier":
+                        pll0Mult = Convert.ToInt32(keyVal[1], 10);
+                        break;
+
+                    case "PLL0 Post Divider":
+                        pll0postDiv = Convert.ToInt32(keyVal[1], 10);
+                        break;
+
+                    case "PLL0 Div1":
+                        pll0div1 = Convert.ToInt32(keyVal[1], 10);
+                        break;
+
+                    case "PLL0 Div3":
+                        pll0div3 = Convert.ToInt32(keyVal[1], 10);
+                        break;
+
+                    case "PLL0 Div7":
+                        pll0div7 = Convert.ToInt32(keyVal[1], 10);
+                        break;
+
+                    case "PLL1 Multiplier":
+                        pll1Mult = Convert.ToInt32(keyVal[1], 10);
+                        break;
+
+                    case "PLL1 Post Divider":
+                        pll1postDiv = Convert.ToInt32(keyVal[1], 10);
+                        break;
+
+                    case "PLL1 Div1":
+                        pll1div1 = Convert.ToInt32(keyVal[1], 10);
+                        break;
+
+                    case "PLL1 Div2":
+                        pll1div2 = Convert.ToInt32(keyVal[1], 10);
+                        break;
+
+                    case "PLL1 Div3":
+                        pll1div3 = Convert.ToInt32(keyVal[1], 10);
+                        break;
+
+                    case "Entrypoint":
+                        entrypoint = Convert.ToUInt32(keyVal[1], 16);
+                        break;
+
+                    case "SDRAM SDBCR":
+                        sdramSdbcr = Convert.ToUInt32(keyVal[1], 16);
+                        break;
+
+                    case "SDRAM SDTMR":
+                        sdramSdtmr = Convert.ToUInt32(keyVal[1], 16);
+                        break;
+
+                    case "SDRAM SDRSRPDEXIT":
+                        sdramSdrsrpdexit = Convert.ToUInt32(keyVal[1], 16);
+                        break;
+
+                    case "SDRAM SDRCR":
+                        sdramSdrcr = Convert.ToUInt32(keyVal[1], 16);
+                        break;
+
+                    case "DDR2 PHY":
+                        ddr2Phy = Convert.ToUInt32(keyVal[1], 16);
+                        break;
+
+                    case "DDR2 SDCR":
+                        ddr2Sdcr = Convert.ToUInt32(keyVal[1], 16);
+                        break;
+
+                    case "DDR2 SDCR2":
+                        ddr2Sdcr2 = Convert.ToUInt32(keyVal[1], 16);
+                        break;
+
+                    case "DDR2 SDTIMR":
+                        ddr2Sdtimr = Convert.ToUInt32(keyVal[1], 16);
+                        break;
+
+                    case "DDR2 SDTIMR2":
+                        ddr2Sdtimr2 = Convert.ToUInt32(keyVal[1], 16);
+                        break;
+
+                    case "DDR2 SDRCR":
+                        ddr2Sdrcr = Convert.ToUInt32(keyVal[1], 16);
+                        break;
+
+                    // LPSC
+                    case "LPSC0 Enable":
+                        // break up into '+' separated numbers
+                        subVal = keyVal[1].Split(subSep, StringSplitOptions.RemoveEmptyEntries);
+                        lpsc0enable = new int[subVal.Length];
+                        for (int j = 0; j < subVal.Length; j++)
+                            lpsc0enable[j] = Convert.ToInt32(subVal[j], 10);
+                        break;
+
+                    case "LPSC0 Disable":
+                        // break up into '+' separated numbers
+                        subVal = keyVal[1].Split(subSep, StringSplitOptions.RemoveEmptyEntries);
+                        lpsc0disable = new int[subVal.Length];
+                        for (int j = 0; j < subVal.Length; j++)
+                            lpsc0disable[j] = Convert.ToInt32(subVal[j], 10);
+                        break;
+
+                    case "LPSC0 SyncRst":
+                        // break up into '+' separated numbers
+                        subVal = keyVal[1].Split(subSep, StringSplitOptions.RemoveEmptyEntries);
+                        lpsc0syncRst = new int[subVal.Length];
+                        for (int j = 0; j < subVal.Length; j++)
+                            lpsc0syncRst[j] = Convert.ToInt32(subVal[j], 10);
+                        break;
+
+                    case "LPSC1 Enable":
+                        // break up into '+' separated numbers
+                        subVal = keyVal[1].Split(subSep, StringSplitOptions.RemoveEmptyEntries);
+                        lpsc1enable = new int[subVal.Length];
+                        for (int j = 0; j < subVal.Length; j++)
+                            lpsc1enable[j] = Convert.ToInt32(subVal[j], 10);
+                        break;
+
+                    case "LPSC1 Disable":
+                        // break up into '+' separated numbers
+                        subVal = keyVal[1].Split(subSep, StringSplitOptions.RemoveEmptyEntries);
+                        lpsc1disable = new int[subVal.Length];
+                        for (int j = 0; j < subVal.Length; j++)
+                            lpsc1disable[j] = Convert.ToInt32(subVal[j], 10);
+                        break;
+
+                    case "LPSC1 SyncRst":
+                        // break up into '+' separated numbers
+                        subVal = keyVal[1].Split(subSep, StringSplitOptions.RemoveEmptyEntries);
+                        lpsc1syncRst = new int[subVal.Length];
+                        for (int j = 0; j < subVal.Length; j++)
+                            lpsc1syncRst[j] = Convert.ToInt32(subVal[j], 10);
+                        break;
+
+                    // Pinmux
+                    case "Pinmux":
+                        // break up into '+' separated register/value pairs
+                        subVal = keyVal[1].Split(subSep, StringSplitOptions.RemoveEmptyEntries);
+                        pinmuxApply = new bool[20];
+                        pinmuxReg = new int[20];
+                        pinmuxVal = new uint[20];
+                        for (int j = 0; j < subVal.Length; j++)
+                        {
+                            // break up into ':' separated values (register, then value)
+                            subSubVal = subVal[j].Split(subSubSep, StringSplitOptions.RemoveEmptyEntries);
+                            // proceed if we find a valid pair
+                            if (subSubVal.Length == 2)
+                            {
+                                pinmuxApply[j] = true;
+                                pinmuxReg[j] = Convert.ToInt32(subSubVal[0], 10);
+                                pinmuxVal[j] = Convert.ToUInt32(subSubVal[1], 16);
+                            }
+                            else
+                                pinmuxApply[j] = false;
+                        }
+                        for (int j = subVal.Length; j < 20; j++)
+                            pinmuxApply[j] = false;
+                        break;
+
+                    case "App File String":
+                        appFileString = keyVal[1];
+                        break;
+
+                    case "AIS File Name":
+                        aisFileName = keyVal[1];
+                        break;
+
+                    default:
+                        // unrecognized param; do nothing
+                        break;
+                }
+            }
+        }
+    }
+}
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/Consts.cs b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/Consts.cs
new file mode 100644 (file)
index 0000000..5f866f7
--- /dev/null
@@ -0,0 +1,143 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace TIBootAndFlash
+{
+    class Consts
+    {
+        public const int majorRev = 1;
+        public const int minorRev = 13;
+        public const String twitchRev = "";
+
+        public enum Tab
+        {
+            num_tabs = 9,
+            general = 0,
+            flash = 1,
+            peripheral = 2,
+            pll0 = 3,
+            sdram = 4,
+            pll1 = 5,
+            ddr2 = 6,
+            lpsc = 7,
+            pinmux = 8
+        }
+
+        // note: these values must match the index of their respective
+        //       options in the (first) "device type" combo box
+        public enum RomID
+        {
+            d800k002 = 0,
+            d800k004 = 1,
+            d800k006 = 2,
+            d800k008 = 3
+        }
+
+        // note: these values must match the index of their respective
+        //       options in the (second) "device type" combo box
+        public enum BootType
+        {
+            arm = 0,
+            dsp = 1
+        }
+
+        public enum BinAddr :uint
+        {
+            boilerplate = 0x80000000,   // default is a reserved word, so...
+            invalid = 0xFFFFFFFF
+        }
+
+        // note: these values must match the index of their respective
+        //       options in the "clock source" combo box
+        public enum ClockSrc
+        {
+            crystal = 0,
+            oscillator = 1
+        }
+
+        public enum ClockIn
+        {
+            min = 1,
+            max = 50
+        }
+
+        public enum ClockMult
+        {
+            min = 1,
+            max = 64
+        }
+        
+        public enum ClockDiv
+        {
+            min = 1,
+            max = 32
+        }
+        public enum ClockCPU
+        {
+            min = 1,
+            max = 1000
+        }
+        
+        public enum ClockEMAC
+        {
+            min = 1,
+            max = 50
+        }
+        
+        public enum ClockSDRAM
+        {
+            min = 1,
+            max = 250
+        }
+        
+        public enum ClockDDR2
+        {
+            min = 1,
+            max = 1000
+        }
+
+        public enum ClockI2Cmod
+        {
+            min = 7
+        }
+
+        public enum ClockAUX
+        {
+            max = 50
+        }
+
+        public enum ClockSYS2
+        {
+            max = 500
+        }
+
+        public enum ClockSYS4
+        {
+            max = 250
+        }
+
+        public enum FlashWidth
+        {
+            eightbit = 0,
+            sixteenbit = 1
+        }
+
+        public enum LpscDomain
+        {
+            min0 = 0,
+            max0 = 15,
+            min1 = 0,
+            max1 = 31,
+            enable = 3,
+            disable = 2,
+            syncRst = 1
+        }
+
+        public enum PinmuxReg
+        {
+            min = 0,
+            max = 19
+        }
+    }
+}
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/MainForm.Designer.cs b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/MainForm.Designer.cs
new file mode 100644 (file)
index 0000000..5ed1d5f
--- /dev/null
@@ -0,0 +1,2923 @@
+namespace TIBootAndFlash
+{
+    partial class MainForm
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.components = new System.ComponentModel.Container();
+            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
+            this.labelBootType = new System.Windows.Forms.Label();
+            this.labelBootMode = new System.Windows.Forms.Label();
+            this.labelClockSource = new System.Windows.Forms.Label();
+            this.comboBoxBootType = new System.Windows.Forms.ComboBox();
+            this.comboBoxBootMode = new System.Windows.Forms.ComboBox();
+            this.comboBoxClockSource = new System.Windows.Forms.ComboBox();
+            this.textBoxClockSpeed = new System.Windows.Forms.TextBox();
+            this.labelInputClockMHz = new System.Windows.Forms.Label();
+            this.checkBoxPLL0 = new System.Windows.Forms.CheckBox();
+            this.checkBoxDDR2 = new System.Windows.Forms.CheckBox();
+            this.checkBoxSDRAM = new System.Windows.Forms.CheckBox();
+            this.checkBoxCRC = new System.Windows.Forms.CheckBox();
+            this.menuStrip1 = new System.Windows.Forms.MenuStrip();
+            this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.restoreDefaultsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.saveConfigToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.loadConfigToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.tabControlConfig = new System.Windows.Forms.TabControl();
+            this.tabPageGeneral = new System.Windows.Forms.TabPage();
+            this.comboBoxROMid = new System.Windows.Forms.ComboBox();
+            this.checkBoxLPSC = new System.Windows.Forms.CheckBox();
+            this.checkBoxPinmux = new System.Windows.Forms.CheckBox();
+            this.checkBoxPLL1 = new System.Windows.Forms.CheckBox();
+            this.textBoxSpecifyEntrypoint = new System.Windows.Forms.TextBox();
+            this.checkBoxSpecifyEntrypoint = new System.Windows.Forms.CheckBox();
+            this.tabPageFlash = new System.Windows.Forms.TabPage();
+            this.textBoxFlashTiming = new System.Windows.Forms.TextBox();
+            this.labelFlashTiming = new System.Windows.Forms.Label();
+            this.labelFlashWidth = new System.Windows.Forms.Label();
+            this.comboBoxFlashWidth = new System.Windows.Forms.ComboBox();
+            this.tabPagePeripheral = new System.Windows.Forms.TabPage();
+            this.checkBoxPeriphSeqRead = new System.Windows.Forms.CheckBox();
+            this.textBoxPeriphClockActual = new System.Windows.Forms.TextBox();
+            this.labelPeriphClockHz = new System.Windows.Forms.Label();
+            this.labelPeriphClock = new System.Windows.Forms.Label();
+            this.textBoxPeriphClockIdeal = new System.Windows.Forms.TextBox();
+            this.labelPeriphModuleClockMHz = new System.Windows.Forms.Label();
+            this.labelPeriphModuleClock = new System.Windows.Forms.Label();
+            this.textBoxPeriphModuleClock = new System.Windows.Forms.TextBox();
+            this.tabPagePLL0 = new System.Windows.Forms.TabPage();
+            this.labelPLL0emacMHz = new System.Windows.Forms.Label();
+            this.labelPLL0sdramMHz = new System.Windows.Forms.Label();
+            this.labelPLL0cpuMHz = new System.Windows.Forms.Label();
+            this.labelPLL0emac = new System.Windows.Forms.Label();
+            this.textBoxPLL0emac = new System.Windows.Forms.TextBox();
+            this.labelPLL0sdram = new System.Windows.Forms.Label();
+            this.textBoxPLL0sdram = new System.Windows.Forms.TextBox();
+            this.labelPLL0cpu = new System.Windows.Forms.Label();
+            this.textBoxPLL0cpu = new System.Windows.Forms.TextBox();
+            this.labelPLL0div7 = new System.Windows.Forms.Label();
+            this.textBoxPLL0div7 = new System.Windows.Forms.TextBox();
+            this.labelPLL0div3 = new System.Windows.Forms.Label();
+            this.textBoxPLL0div3 = new System.Windows.Forms.TextBox();
+            this.label1 = new System.Windows.Forms.Label();
+            this.textBoxPLL0div1 = new System.Windows.Forms.TextBox();
+            this.labelPLL0postDiv = new System.Windows.Forms.Label();
+            this.textBoxPLL0postDiv = new System.Windows.Forms.TextBox();
+            this.labelPLL0preDiv = new System.Windows.Forms.Label();
+            this.textBoxPLL0preDiv = new System.Windows.Forms.TextBox();
+            this.labelPLL0mult = new System.Windows.Forms.Label();
+            this.textBoxPLL0mult = new System.Windows.Forms.TextBox();
+            this.tabPageSDRAM = new System.Windows.Forms.TabPage();
+            this.labelSDRAMsdrcr = new System.Windows.Forms.Label();
+            this.textBoxSDRAMsdrcr = new System.Windows.Forms.TextBox();
+            this.labelSDRAMsdrsrpdexit = new System.Windows.Forms.Label();
+            this.textBoxSDRAMsdrsrpdexit = new System.Windows.Forms.TextBox();
+            this.labelSDRAMsdtmr = new System.Windows.Forms.Label();
+            this.textBoxSDRAMsdtmr = new System.Windows.Forms.TextBox();
+            this.labelSDRAMsdbcr = new System.Windows.Forms.Label();
+            this.textBoxSDRAMsdbcr = new System.Windows.Forms.TextBox();
+            this.checkBoxSDRAMdiv = new System.Windows.Forms.CheckBox();
+            this.labelSDRAMclockMHz = new System.Windows.Forms.Label();
+            this.labelSDRAMclock = new System.Windows.Forms.Label();
+            this.textBoxSDRAMclock = new System.Windows.Forms.TextBox();
+            this.tabPagePLL1 = new System.Windows.Forms.TabPage();
+            this.labelPLL1ddr2MHz = new System.Windows.Forms.Label();
+            this.labelPLL1ddr2 = new System.Windows.Forms.Label();
+            this.textBoxPLL1ddr2 = new System.Windows.Forms.TextBox();
+            this.labelPLL1div3 = new System.Windows.Forms.Label();
+            this.textBoxPLL1div3 = new System.Windows.Forms.TextBox();
+            this.labelPLL1div2 = new System.Windows.Forms.Label();
+            this.textBoxPLL1div2 = new System.Windows.Forms.TextBox();
+            this.labelPLL1div1 = new System.Windows.Forms.Label();
+            this.textBoxPLL1div1 = new System.Windows.Forms.TextBox();
+            this.labelPLL1postDiv = new System.Windows.Forms.Label();
+            this.textBoxPLL1postDiv = new System.Windows.Forms.TextBox();
+            this.labelPLL1mult = new System.Windows.Forms.Label();
+            this.textBoxPLL1mult = new System.Windows.Forms.TextBox();
+            this.tabPageDDR2 = new System.Windows.Forms.TabPage();
+            this.labelDDR2sdcr2 = new System.Windows.Forms.Label();
+            this.textBoxDDR2sdcr2 = new System.Windows.Forms.TextBox();
+            this.groupBoxDDRtype = new System.Windows.Forms.GroupBox();
+            this.radioMDDR = new System.Windows.Forms.RadioButton();
+            this.radioDuplicateMddrSetting = new System.Windows.Forms.RadioButton();
+            this.radioDDR2 = new System.Windows.Forms.RadioButton();
+            this.labelDDR2phy = new System.Windows.Forms.Label();
+            this.textBoxDDR2phy = new System.Windows.Forms.TextBox();
+            this.labelDDR2sdrcr = new System.Windows.Forms.Label();
+            this.textBoxDDR2sdrcr = new System.Windows.Forms.TextBox();
+            this.labelDDR2sdtimr2 = new System.Windows.Forms.Label();
+            this.textBoxDDR2sdtimr2 = new System.Windows.Forms.TextBox();
+            this.labelDDR2sdtimr = new System.Windows.Forms.Label();
+            this.textBoxDDR2sdtimr = new System.Windows.Forms.TextBox();
+            this.labelDDR2sdcr = new System.Windows.Forms.Label();
+            this.textBoxDDR2sdcr = new System.Windows.Forms.TextBox();
+            this.checkBoxDDR2directClock = new System.Windows.Forms.CheckBox();
+            this.labelDDR2clockMHz = new System.Windows.Forms.Label();
+            this.labelDDR2clock = new System.Windows.Forms.Label();
+            this.textBoxDDR2clock = new System.Windows.Forms.TextBox();
+            this.tabPageLPSC = new System.Windows.Forms.TabPage();
+            this.labelLpsc1 = new System.Windows.Forms.Label();
+            this.labelLpsc0 = new System.Windows.Forms.Label();
+            this.textBoxLps1SyncRst = new System.Windows.Forms.TextBox();
+            this.textBoxLps1Disable = new System.Windows.Forms.TextBox();
+            this.textBoxLps1Enable = new System.Windows.Forms.TextBox();
+            this.textBoxLps0SyncRst = new System.Windows.Forms.TextBox();
+            this.textBoxLps0Disable = new System.Windows.Forms.TextBox();
+            this.textBoxLps0Enable = new System.Windows.Forms.TextBox();
+            this.labelLpsc0SyncRst = new System.Windows.Forms.Label();
+            this.labelLpsc0Disable = new System.Windows.Forms.Label();
+            this.labelLpsc0enable = new System.Windows.Forms.Label();
+            this.tabPagePinmux = new System.Windows.Forms.TabPage();
+            this.textBoxPinmuxVal19 = new System.Windows.Forms.TextBox();
+            this.labelPinmuxReg20 = new System.Windows.Forms.Label();
+            this.numericUpDownPinmux19 = new System.Windows.Forms.NumericUpDown();
+            this.textBoxPinmuxVal18 = new System.Windows.Forms.TextBox();
+            this.labelPinmuxReg19 = new System.Windows.Forms.Label();
+            this.numericUpDownPinmux18 = new System.Windows.Forms.NumericUpDown();
+            this.textBoxPinmuxVal17 = new System.Windows.Forms.TextBox();
+            this.labelPinmuxReg18 = new System.Windows.Forms.Label();
+            this.numericUpDownPinmux17 = new System.Windows.Forms.NumericUpDown();
+            this.textBoxPinmuxVal16 = new System.Windows.Forms.TextBox();
+            this.labelPinmuxReg17 = new System.Windows.Forms.Label();
+            this.numericUpDownPinmux16 = new System.Windows.Forms.NumericUpDown();
+            this.textBoxPinmuxVal15 = new System.Windows.Forms.TextBox();
+            this.labelPinmuxReg16 = new System.Windows.Forms.Label();
+            this.numericUpDownPinmux15 = new System.Windows.Forms.NumericUpDown();
+            this.textBoxPinmuxVal14 = new System.Windows.Forms.TextBox();
+            this.labelPinmuxReg15 = new System.Windows.Forms.Label();
+            this.numericUpDownPinmux14 = new System.Windows.Forms.NumericUpDown();
+            this.textBoxPinmuxVal13 = new System.Windows.Forms.TextBox();
+            this.labelPinmuxReg14 = new System.Windows.Forms.Label();
+            this.numericUpDownPinmux13 = new System.Windows.Forms.NumericUpDown();
+            this.textBoxPinmuxVal12 = new System.Windows.Forms.TextBox();
+            this.labelPinmuxReg13 = new System.Windows.Forms.Label();
+            this.numericUpDownPinmux12 = new System.Windows.Forms.NumericUpDown();
+            this.textBoxPinmuxVal11 = new System.Windows.Forms.TextBox();
+            this.labelPinmuxReg12 = new System.Windows.Forms.Label();
+            this.numericUpDownPinmux11 = new System.Windows.Forms.NumericUpDown();
+            this.textBoxPinmuxVal10 = new System.Windows.Forms.TextBox();
+            this.labelPinmuxReg11 = new System.Windows.Forms.Label();
+            this.numericUpDownPinmux10 = new System.Windows.Forms.NumericUpDown();
+            this.textBoxPinmuxVal9 = new System.Windows.Forms.TextBox();
+            this.labelPinmuxReg10 = new System.Windows.Forms.Label();
+            this.numericUpDownPinmux9 = new System.Windows.Forms.NumericUpDown();
+            this.textBoxPinmuxVal8 = new System.Windows.Forms.TextBox();
+            this.labelPinmuxReg9 = new System.Windows.Forms.Label();
+            this.numericUpDownPinmux8 = new System.Windows.Forms.NumericUpDown();
+            this.textBoxPinmuxVal7 = new System.Windows.Forms.TextBox();
+            this.labelPinmuxReg8 = new System.Windows.Forms.Label();
+            this.numericUpDownPinmux7 = new System.Windows.Forms.NumericUpDown();
+            this.textBoxPinmuxVal6 = new System.Windows.Forms.TextBox();
+            this.labelPinmuxReg7 = new System.Windows.Forms.Label();
+            this.numericUpDownPinmux6 = new System.Windows.Forms.NumericUpDown();
+            this.textBoxPinmuxVal5 = new System.Windows.Forms.TextBox();
+            this.labelPinmuxReg6 = new System.Windows.Forms.Label();
+            this.numericUpDownPinmux5 = new System.Windows.Forms.NumericUpDown();
+            this.textBoxPinmuxVal4 = new System.Windows.Forms.TextBox();
+            this.labelPinmuxReg5 = new System.Windows.Forms.Label();
+            this.numericUpDownPinmux4 = new System.Windows.Forms.NumericUpDown();
+            this.textBoxPinmuxVal3 = new System.Windows.Forms.TextBox();
+            this.labelPinmuxReg4 = new System.Windows.Forms.Label();
+            this.numericUpDownPinmux3 = new System.Windows.Forms.NumericUpDown();
+            this.textBoxPinmuxVal2 = new System.Windows.Forms.TextBox();
+            this.labelPinmuxReg3 = new System.Windows.Forms.Label();
+            this.numericUpDownPinmux2 = new System.Windows.Forms.NumericUpDown();
+            this.textBoxPinmuxVal1 = new System.Windows.Forms.TextBox();
+            this.labelPinmuxReg2 = new System.Windows.Forms.Label();
+            this.numericUpDownPinmux1 = new System.Windows.Forms.NumericUpDown();
+            this.textBoxPinmuxVal0 = new System.Windows.Forms.TextBox();
+            this.labelPinmuxReg1 = new System.Windows.Forms.Label();
+            this.numericUpDownPinmux0 = new System.Windows.Forms.NumericUpDown();
+            this.labelAppFile = new System.Windows.Forms.Label();
+            this.buttonBrowseFile = new System.Windows.Forms.Button();
+            this.textBoxAppFiles = new System.Windows.Forms.TextBox();
+            this.buttonAddFile = new System.Windows.Forms.Button();
+            this.textBoxAISfile = new System.Windows.Forms.TextBox();
+            this.labelAISfile = new System.Windows.Forms.Label();
+            this.buttonAISbrowseFile = new System.Windows.Forms.Button();
+            this.buttonGenerateAIS = new System.Windows.Forms.Button();
+            this.labelMessage = new System.Windows.Forms.Label();
+            this.tooltipMessage = new System.Windows.Forms.ToolTip(this.components);
+            this.menuStrip1.SuspendLayout();
+            this.tabControlConfig.SuspendLayout();
+            this.tabPageGeneral.SuspendLayout();
+            this.tabPageFlash.SuspendLayout();
+            this.tabPagePeripheral.SuspendLayout();
+            this.tabPagePLL0.SuspendLayout();
+            this.tabPageSDRAM.SuspendLayout();
+            this.tabPagePLL1.SuspendLayout();
+            this.tabPageDDR2.SuspendLayout();
+            this.groupBoxDDRtype.SuspendLayout();
+            this.tabPageLPSC.SuspendLayout();
+            this.tabPagePinmux.SuspendLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux19)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux18)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux17)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux16)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux15)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux14)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux13)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux12)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux11)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux10)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux9)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux8)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux7)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux6)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux5)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux4)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux3)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux2)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux1)).BeginInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux0)).BeginInit();
+            this.SuspendLayout();
+            // 
+            // labelBootType
+            // 
+            this.labelBootType.AutoSize = true;
+            this.labelBootType.Location = new System.Drawing.Point(100, 12);
+            this.labelBootType.Name = "labelBootType";
+            this.labelBootType.Size = new System.Drawing.Size(71, 13);
+            this.labelBootType.TabIndex = 0;
+            this.labelBootType.Text = "Device Type:";
+            // 
+            // labelBootMode
+            // 
+            this.labelBootMode.AutoSize = true;
+            this.labelBootMode.Location = new System.Drawing.Point(100, 39);
+            this.labelBootMode.Name = "labelBootMode";
+            this.labelBootMode.Size = new System.Drawing.Size(62, 13);
+            this.labelBootMode.TabIndex = 1;
+            this.labelBootMode.Text = "Boot Mode:";
+            // 
+            // labelClockSource
+            // 
+            this.labelClockSource.AutoSize = true;
+            this.labelClockSource.Location = new System.Drawing.Point(100, 66);
+            this.labelClockSource.Name = "labelClockSource";
+            this.labelClockSource.Size = new System.Drawing.Size(74, 13);
+            this.labelClockSource.TabIndex = 2;
+            this.labelClockSource.Text = "Clock Source:";
+            // 
+            // comboBoxBootType
+            // 
+            this.comboBoxBootType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.comboBoxBootType.FormattingEnabled = true;
+            this.comboBoxBootType.Items.AddRange(new object[] {
+            "ARM",
+            "DSP"});
+            this.comboBoxBootType.Location = new System.Drawing.Point(286, 9);
+            this.comboBoxBootType.Name = "comboBoxBootType";
+            this.comboBoxBootType.Size = new System.Drawing.Size(60, 21);
+            this.comboBoxBootType.TabIndex = 1;
+            this.comboBoxBootType.SelectedIndexChanged += new System.EventHandler(this.comboBoxBootType_SelectedIndexChanged);
+            // 
+            // comboBoxBootMode
+            // 
+            this.comboBoxBootMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.comboBoxBootMode.FormattingEnabled = true;
+            this.comboBoxBootMode.Items.AddRange(new object[] {
+            "NOR Flash",
+            "NAND Flash",
+            "MMC/SD0",
+            "SPI0 Flash",
+            "SPI1 Flash",
+            "I2C0 EEPROM",
+            "I2C1 EEPROM",
+            "SPI0 EEPROM",
+            "SPI1 EEPROM",
+            "I2C0 Slave",
+            "I2C1 Slave",
+            "SPI0 Slave",
+            "SPI1 Slave",
+            "UART0",
+            "UART1",
+            "UART2",
+            "(No Config)"});
+            this.comboBoxBootMode.Location = new System.Drawing.Point(180, 36);
+            this.comboBoxBootMode.MaxDropDownItems = 16;
+            this.comboBoxBootMode.Name = "comboBoxBootMode";
+            this.comboBoxBootMode.Size = new System.Drawing.Size(100, 21);
+            this.comboBoxBootMode.TabIndex = 2;
+            this.comboBoxBootMode.SelectedIndexChanged += new System.EventHandler(this.comboBoxBootMode_SelectedIndexChanged);
+            // 
+            // comboBoxClockSource
+            // 
+            this.comboBoxClockSource.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.comboBoxClockSource.FormattingEnabled = true;
+            this.comboBoxClockSource.Items.AddRange(new object[] {
+            "Crystal",
+            "Oscillator"});
+            this.comboBoxClockSource.Location = new System.Drawing.Point(180, 63);
+            this.comboBoxClockSource.Name = "comboBoxClockSource";
+            this.comboBoxClockSource.Size = new System.Drawing.Size(100, 21);
+            this.comboBoxClockSource.TabIndex = 3;
+            this.comboBoxClockSource.SelectedIndexChanged += new System.EventHandler(this.comboBoxClockSource_SelectedIndexChanged);
+            // 
+            // textBoxClockSpeed
+            // 
+            this.textBoxClockSpeed.Location = new System.Drawing.Point(286, 63);
+            this.textBoxClockSpeed.MaxLength = 6;
+            this.textBoxClockSpeed.Name = "textBoxClockSpeed";
+            this.textBoxClockSpeed.Size = new System.Drawing.Size(40, 20);
+            this.textBoxClockSpeed.TabIndex = 4;
+            this.textBoxClockSpeed.Text = "24.00";
+            this.textBoxClockSpeed.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxClockSpeed.TextChanged += new System.EventHandler(this.textBoxClockSpeed_TextChanged);
+            // 
+            // labelInputClockMHz
+            // 
+            this.labelInputClockMHz.AutoSize = true;
+            this.labelInputClockMHz.Location = new System.Drawing.Point(346, 66);
+            this.labelInputClockMHz.Name = "labelInputClockMHz";
+            this.labelInputClockMHz.Size = new System.Drawing.Size(29, 13);
+            this.labelInputClockMHz.TabIndex = 5;
+            this.labelInputClockMHz.Text = "MHz";
+            // 
+            // checkBoxPLL0
+            // 
+            this.checkBoxPLL0.AutoSize = true;
+            this.checkBoxPLL0.Location = new System.Drawing.Point(103, 90);
+            this.checkBoxPLL0.Name = "checkBoxPLL0";
+            this.checkBoxPLL0.Size = new System.Drawing.Size(99, 17);
+            this.checkBoxPLL0.TabIndex = 5;
+            this.checkBoxPLL0.Text = "Configure PLL0";
+            this.checkBoxPLL0.UseVisualStyleBackColor = true;
+            this.checkBoxPLL0.CheckedChanged += new System.EventHandler(this.checkBoxPLL0_CheckedChanged);
+            // 
+            // checkBoxDDR2
+            // 
+            this.checkBoxDDR2.AutoSize = true;
+            this.checkBoxDDR2.Location = new System.Drawing.Point(223, 112);
+            this.checkBoxDDR2.Name = "checkBoxDDR2";
+            this.checkBoxDDR2.Size = new System.Drawing.Size(98, 17);
+            this.checkBoxDDR2.TabIndex = 8;
+            this.checkBoxDDR2.Text = "Configure DDR";
+            this.checkBoxDDR2.UseVisualStyleBackColor = true;
+            this.checkBoxDDR2.CheckedChanged += new System.EventHandler(this.checkBoxDDR2_CheckedChanged);
+            // 
+            // checkBoxSDRAM
+            // 
+            this.checkBoxSDRAM.AutoSize = true;
+            this.checkBoxSDRAM.Location = new System.Drawing.Point(103, 113);
+            this.checkBoxSDRAM.Name = "checkBoxSDRAM";
+            this.checkBoxSDRAM.Size = new System.Drawing.Size(113, 17);
+            this.checkBoxSDRAM.TabIndex = 7;
+            this.checkBoxSDRAM.Text = "Configure SDRAM";
+            this.checkBoxSDRAM.UseVisualStyleBackColor = true;
+            this.checkBoxSDRAM.CheckedChanged += new System.EventHandler(this.checkBoxSDRAM_CheckedChanged);
+            // 
+            // checkBoxCRC
+            // 
+            this.checkBoxCRC.AutoSize = true;
+            this.checkBoxCRC.Location = new System.Drawing.Point(103, 159);
+            this.checkBoxCRC.Name = "checkBoxCRC";
+            this.checkBoxCRC.Size = new System.Drawing.Size(84, 17);
+            this.checkBoxCRC.TabIndex = 11;
+            this.checkBoxCRC.Text = "Enable CRC";
+            this.checkBoxCRC.UseVisualStyleBackColor = true;
+            this.checkBoxCRC.CheckedChanged += new System.EventHandler(this.checkBoxCRC_CheckedChanged);
+            // 
+            // menuStrip1
+            // 
+            this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.fileToolStripMenuItem,
+            this.helpToolStripMenuItem});
+            this.menuStrip1.Location = new System.Drawing.Point(0, 0);
+            this.menuStrip1.Name = "menuStrip1";
+            this.menuStrip1.Size = new System.Drawing.Size(506, 24);
+            this.menuStrip1.TabIndex = 13;
+            this.menuStrip1.Text = "menuStrip1";
+            // 
+            // fileToolStripMenuItem
+            // 
+            this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.restoreDefaultsToolStripMenuItem,
+            this.saveConfigToolStripMenuItem,
+            this.loadConfigToolStripMenuItem,
+            this.exitToolStripMenuItem});
+            this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
+            this.fileToolStripMenuItem.Size = new System.Drawing.Size(35, 20);
+            this.fileToolStripMenuItem.Text = "File";
+            // 
+            // restoreDefaultsToolStripMenuItem
+            // 
+            this.restoreDefaultsToolStripMenuItem.Name = "restoreDefaultsToolStripMenuItem";
+            this.restoreDefaultsToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
+            this.restoreDefaultsToolStripMenuItem.Text = "Restore Defaults";
+            this.restoreDefaultsToolStripMenuItem.Click += new System.EventHandler(this.restoreDefaultsToolStripMenuItem_Click);
+            // 
+            // saveConfigToolStripMenuItem
+            // 
+            this.saveConfigToolStripMenuItem.Name = "saveConfigToolStripMenuItem";
+            this.saveConfigToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
+            this.saveConfigToolStripMenuItem.Text = "Save Configuration";
+            this.saveConfigToolStripMenuItem.Click += new System.EventHandler(this.saveConfigToolStripMenuItem_Click);
+            // 
+            // loadConfigToolStripMenuItem
+            // 
+            this.loadConfigToolStripMenuItem.Name = "loadConfigToolStripMenuItem";
+            this.loadConfigToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
+            this.loadConfigToolStripMenuItem.Text = "Load Configuration";
+            this.loadConfigToolStripMenuItem.Click += new System.EventHandler(this.loadConfigToolStripMenuItem_Click);
+            // 
+            // exitToolStripMenuItem
+            // 
+            this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
+            this.exitToolStripMenuItem.Size = new System.Drawing.Size(177, 22);
+            this.exitToolStripMenuItem.Text = "Exit";
+            this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
+            // 
+            // helpToolStripMenuItem
+            // 
+            this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.aboutToolStripMenuItem});
+            this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
+            this.helpToolStripMenuItem.Size = new System.Drawing.Size(40, 20);
+            this.helpToolStripMenuItem.Text = "Help";
+            // 
+            // aboutToolStripMenuItem
+            // 
+            this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
+            this.aboutToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
+            this.aboutToolStripMenuItem.Text = "About";
+            this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
+            // 
+            // tabControlConfig
+            // 
+            this.tabControlConfig.Controls.Add(this.tabPageGeneral);
+            this.tabControlConfig.Controls.Add(this.tabPageFlash);
+            this.tabControlConfig.Controls.Add(this.tabPagePeripheral);
+            this.tabControlConfig.Controls.Add(this.tabPagePLL0);
+            this.tabControlConfig.Controls.Add(this.tabPageSDRAM);
+            this.tabControlConfig.Controls.Add(this.tabPagePLL1);
+            this.tabControlConfig.Controls.Add(this.tabPageDDR2);
+            this.tabControlConfig.Controls.Add(this.tabPageLPSC);
+            this.tabControlConfig.Controls.Add(this.tabPagePinmux);
+            this.tabControlConfig.Location = new System.Drawing.Point(12, 27);
+            this.tabControlConfig.Name = "tabControlConfig";
+            this.tabControlConfig.SelectedIndex = 0;
+            this.tabControlConfig.Size = new System.Drawing.Size(482, 235);
+            this.tabControlConfig.TabIndex = 0;
+            // 
+            // tabPageGeneral
+            // 
+            this.tabPageGeneral.Controls.Add(this.comboBoxROMid);
+            this.tabPageGeneral.Controls.Add(this.checkBoxLPSC);
+            this.tabPageGeneral.Controls.Add(this.checkBoxPinmux);
+            this.tabPageGeneral.Controls.Add(this.checkBoxPLL1);
+            this.tabPageGeneral.Controls.Add(this.comboBoxBootMode);
+            this.tabPageGeneral.Controls.Add(this.labelBootType);
+            this.tabPageGeneral.Controls.Add(this.checkBoxCRC);
+            this.tabPageGeneral.Controls.Add(this.labelBootMode);
+            this.tabPageGeneral.Controls.Add(this.textBoxSpecifyEntrypoint);
+            this.tabPageGeneral.Controls.Add(this.checkBoxSDRAM);
+            this.tabPageGeneral.Controls.Add(this.checkBoxSpecifyEntrypoint);
+            this.tabPageGeneral.Controls.Add(this.labelClockSource);
+            this.tabPageGeneral.Controls.Add(this.checkBoxDDR2);
+            this.tabPageGeneral.Controls.Add(this.comboBoxBootType);
+            this.tabPageGeneral.Controls.Add(this.checkBoxPLL0);
+            this.tabPageGeneral.Controls.Add(this.comboBoxClockSource);
+            this.tabPageGeneral.Controls.Add(this.labelInputClockMHz);
+            this.tabPageGeneral.Controls.Add(this.textBoxClockSpeed);
+            this.tabPageGeneral.Location = new System.Drawing.Point(4, 22);
+            this.tabPageGeneral.Name = "tabPageGeneral";
+            this.tabPageGeneral.Size = new System.Drawing.Size(474, 209);
+            this.tabPageGeneral.TabIndex = 5;
+            this.tabPageGeneral.Text = "General";
+            this.tabPageGeneral.UseVisualStyleBackColor = true;
+            // 
+            // comboBoxROMid
+            // 
+            this.comboBoxROMid.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.comboBoxROMid.FormattingEnabled = true;
+            this.comboBoxROMid.Items.AddRange(new object[] {
+            "d800k002",
+            "d800k004",
+            "d800k006",
+            "d800k008"});
+            this.comboBoxROMid.Location = new System.Drawing.Point(180, 9);
+            this.comboBoxROMid.Name = "comboBoxROMid";
+            this.comboBoxROMid.Size = new System.Drawing.Size(100, 21);
+            this.comboBoxROMid.TabIndex = 0;
+            this.comboBoxROMid.SelectedIndexChanged += new System.EventHandler(this.comboBoxROMid_SelectedIndexChanged);
+            // 
+            // checkBoxLPSC
+            // 
+            this.checkBoxLPSC.AutoSize = true;
+            this.checkBoxLPSC.Location = new System.Drawing.Point(103, 136);
+            this.checkBoxLPSC.Name = "checkBoxLPSC";
+            this.checkBoxLPSC.Size = new System.Drawing.Size(95, 17);
+            this.checkBoxLPSC.TabIndex = 9;
+            this.checkBoxLPSC.Text = "Configure PSC";
+            this.checkBoxLPSC.UseVisualStyleBackColor = true;
+            this.checkBoxLPSC.CheckedChanged += new System.EventHandler(this.checkBoxLPSC_CheckedChanged);
+            // 
+            // checkBoxPinmux
+            // 
+            this.checkBoxPinmux.AutoSize = true;
+            this.checkBoxPinmux.Location = new System.Drawing.Point(223, 135);
+            this.checkBoxPinmux.Name = "checkBoxPinmux";
+            this.checkBoxPinmux.Size = new System.Drawing.Size(108, 17);
+            this.checkBoxPinmux.TabIndex = 10;
+            this.checkBoxPinmux.Text = "Configure Pinmux";
+            this.checkBoxPinmux.UseVisualStyleBackColor = true;
+            this.checkBoxPinmux.CheckedChanged += new System.EventHandler(this.checkBoxPinmux_CheckedChanged);
+            // 
+            // checkBoxPLL1
+            // 
+            this.checkBoxPLL1.AutoSize = true;
+            this.checkBoxPLL1.Location = new System.Drawing.Point(223, 89);
+            this.checkBoxPLL1.Name = "checkBoxPLL1";
+            this.checkBoxPLL1.Size = new System.Drawing.Size(99, 17);
+            this.checkBoxPLL1.TabIndex = 6;
+            this.checkBoxPLL1.Text = "Configure PLL1";
+            this.checkBoxPLL1.UseVisualStyleBackColor = true;
+            this.checkBoxPLL1.CheckedChanged += new System.EventHandler(this.checkBoxPLL1_CheckedChanged);
+            // 
+            // textBoxSpecifyEntrypoint
+            // 
+            this.textBoxSpecifyEntrypoint.Enabled = false;
+            this.textBoxSpecifyEntrypoint.Location = new System.Drawing.Point(223, 179);
+            this.textBoxSpecifyEntrypoint.MaxLength = 10;
+            this.textBoxSpecifyEntrypoint.Name = "textBoxSpecifyEntrypoint";
+            this.textBoxSpecifyEntrypoint.Size = new System.Drawing.Size(80, 20);
+            this.textBoxSpecifyEntrypoint.TabIndex = 13;
+            this.textBoxSpecifyEntrypoint.Text = "0x00000000";
+            this.textBoxSpecifyEntrypoint.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxSpecifyEntrypoint.TextChanged += new System.EventHandler(this.textBoxSpecifyEntrypoint_TextChanged);
+            // 
+            // checkBoxSpecifyEntrypoint
+            // 
+            this.checkBoxSpecifyEntrypoint.AutoSize = true;
+            this.checkBoxSpecifyEntrypoint.Location = new System.Drawing.Point(103, 182);
+            this.checkBoxSpecifyEntrypoint.Name = "checkBoxSpecifyEntrypoint";
+            this.checkBoxSpecifyEntrypoint.Size = new System.Drawing.Size(114, 17);
+            this.checkBoxSpecifyEntrypoint.TabIndex = 12;
+            this.checkBoxSpecifyEntrypoint.Text = "Specify Entrypoint:";
+            this.checkBoxSpecifyEntrypoint.UseVisualStyleBackColor = true;
+            this.checkBoxSpecifyEntrypoint.CheckedChanged += new System.EventHandler(this.checkBoxSpecifyEntrypoint_CheckedChanged);
+            // 
+            // tabPageFlash
+            // 
+            this.tabPageFlash.Controls.Add(this.textBoxFlashTiming);
+            this.tabPageFlash.Controls.Add(this.labelFlashTiming);
+            this.tabPageFlash.Controls.Add(this.labelFlashWidth);
+            this.tabPageFlash.Controls.Add(this.comboBoxFlashWidth);
+            this.tabPageFlash.Location = new System.Drawing.Point(4, 22);
+            this.tabPageFlash.Name = "tabPageFlash";
+            this.tabPageFlash.Size = new System.Drawing.Size(474, 209);
+            this.tabPageFlash.TabIndex = 8;
+            this.tabPageFlash.Text = "Flash";
+            this.tabPageFlash.UseVisualStyleBackColor = true;
+            // 
+            // textBoxFlashTiming
+            // 
+            this.textBoxFlashTiming.Location = new System.Drawing.Point(232, 108);
+            this.textBoxFlashTiming.MaxLength = 10;
+            this.textBoxFlashTiming.Name = "textBoxFlashTiming";
+            this.textBoxFlashTiming.Size = new System.Drawing.Size(80, 20);
+            this.textBoxFlashTiming.TabIndex = 1;
+            this.textBoxFlashTiming.Text = "0x00000000";
+            this.textBoxFlashTiming.TextChanged += new System.EventHandler(this.textBoxFlashTiming_TextChanged);
+            // 
+            // labelFlashTiming
+            // 
+            this.labelFlashTiming.AutoSize = true;
+            this.labelFlashTiming.Location = new System.Drawing.Point(162, 111);
+            this.labelFlashTiming.Name = "labelFlashTiming";
+            this.labelFlashTiming.Size = new System.Drawing.Size(61, 13);
+            this.labelFlashTiming.TabIndex = 25;
+            this.labelFlashTiming.Text = "CS3 Setup:";
+            // 
+            // labelFlashWidth
+            // 
+            this.labelFlashWidth.AutoSize = true;
+            this.labelFlashWidth.Location = new System.Drawing.Point(162, 84);
+            this.labelFlashWidth.Name = "labelFlashWidth";
+            this.labelFlashWidth.Size = new System.Drawing.Size(64, 13);
+            this.labelFlashWidth.TabIndex = 4;
+            this.labelFlashWidth.Text = "Data Width:";
+            // 
+            // comboBoxFlashWidth
+            // 
+            this.comboBoxFlashWidth.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.comboBoxFlashWidth.FormattingEnabled = true;
+            this.comboBoxFlashWidth.Items.AddRange(new object[] {
+            "8-bit",
+            "16-bit"});
+            this.comboBoxFlashWidth.Location = new System.Drawing.Point(232, 81);
+            this.comboBoxFlashWidth.Name = "comboBoxFlashWidth";
+            this.comboBoxFlashWidth.Size = new System.Drawing.Size(80, 21);
+            this.comboBoxFlashWidth.TabIndex = 0;
+            this.comboBoxFlashWidth.SelectedIndexChanged += new System.EventHandler(this.comboBoxFlashWidth_SelectedIndexChanged);
+            // 
+            // tabPagePeripheral
+            // 
+            this.tabPagePeripheral.Controls.Add(this.checkBoxPeriphSeqRead);
+            this.tabPagePeripheral.Controls.Add(this.textBoxPeriphClockActual);
+            this.tabPagePeripheral.Controls.Add(this.labelPeriphClockHz);
+            this.tabPagePeripheral.Controls.Add(this.labelPeriphClock);
+            this.tabPagePeripheral.Controls.Add(this.textBoxPeriphClockIdeal);
+            this.tabPagePeripheral.Controls.Add(this.labelPeriphModuleClockMHz);
+            this.tabPagePeripheral.Controls.Add(this.labelPeriphModuleClock);
+            this.tabPagePeripheral.Controls.Add(this.textBoxPeriphModuleClock);
+            this.tabPagePeripheral.Location = new System.Drawing.Point(4, 22);
+            this.tabPagePeripheral.Name = "tabPagePeripheral";
+            this.tabPagePeripheral.Padding = new System.Windows.Forms.Padding(3);
+            this.tabPagePeripheral.Size = new System.Drawing.Size(474, 209);
+            this.tabPagePeripheral.TabIndex = 0;
+            this.tabPagePeripheral.Text = "Peripheral";
+            this.tabPagePeripheral.UseVisualStyleBackColor = true;
+            // 
+            // checkBoxPeriphSeqRead
+            // 
+            this.checkBoxPeriphSeqRead.AutoSize = true;
+            this.checkBoxPeriphSeqRead.Location = new System.Drawing.Point(193, 122);
+            this.checkBoxPeriphSeqRead.Name = "checkBoxPeriphSeqRead";
+            this.checkBoxPeriphSeqRead.Size = new System.Drawing.Size(141, 17);
+            this.checkBoxPeriphSeqRead.TabIndex = 1;
+            this.checkBoxPeriphSeqRead.Text = "Enable Sequential Read";
+            this.checkBoxPeriphSeqRead.UseVisualStyleBackColor = true;
+            this.checkBoxPeriphSeqRead.CheckedChanged += new System.EventHandler(this.checkBoxPeriphSeqRead_CheckedChanged);
+            // 
+            // textBoxPeriphClockActual
+            // 
+            this.textBoxPeriphClockActual.Location = new System.Drawing.Point(273, 96);
+            this.textBoxPeriphClockActual.Name = "textBoxPeriphClockActual";
+            this.textBoxPeriphClockActual.ReadOnly = true;
+            this.textBoxPeriphClockActual.Size = new System.Drawing.Size(60, 20);
+            this.textBoxPeriphClockActual.TabIndex = 25;
+            this.textBoxPeriphClockActual.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            // 
+            // labelPeriphClockHz
+            // 
+            this.labelPeriphClockHz.AutoSize = true;
+            this.labelPeriphClockHz.Location = new System.Drawing.Point(339, 99);
+            this.labelPeriphClockHz.Name = "labelPeriphClockHz";
+            this.labelPeriphClockHz.Size = new System.Drawing.Size(31, 13);
+            this.labelPeriphClockHz.TabIndex = 24;
+            this.labelPeriphClockHz.Text = "baud";
+            // 
+            // labelPeriphClock
+            // 
+            this.labelPeriphClock.AutoSize = true;
+            this.labelPeriphClock.Location = new System.Drawing.Point(105, 99);
+            this.labelPeriphClock.Name = "labelPeriphClock";
+            this.labelPeriphClock.Size = new System.Drawing.Size(76, 13);
+            this.labelPeriphClock.TabIndex = 23;
+            this.labelPeriphClock.Text = "[Periph] Clock:";
+            // 
+            // textBoxPeriphClockIdeal
+            // 
+            this.textBoxPeriphClockIdeal.Location = new System.Drawing.Point(193, 96);
+            this.textBoxPeriphClockIdeal.Name = "textBoxPeriphClockIdeal";
+            this.textBoxPeriphClockIdeal.Size = new System.Drawing.Size(60, 20);
+            this.textBoxPeriphClockIdeal.TabIndex = 0;
+            this.textBoxPeriphClockIdeal.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPeriphClockIdeal.TextChanged += new System.EventHandler(this.textBoxPeriphClockIdeal_TextChanged);
+            // 
+            // labelPeriphModuleClockMHz
+            // 
+            this.labelPeriphModuleClockMHz.AutoSize = true;
+            this.labelPeriphModuleClockMHz.Location = new System.Drawing.Point(273, 73);
+            this.labelPeriphModuleClockMHz.Name = "labelPeriphModuleClockMHz";
+            this.labelPeriphModuleClockMHz.Size = new System.Drawing.Size(29, 13);
+            this.labelPeriphModuleClockMHz.TabIndex = 21;
+            this.labelPeriphModuleClockMHz.Text = "MHz";
+            // 
+            // labelPeriphModuleClock
+            // 
+            this.labelPeriphModuleClock.AutoSize = true;
+            this.labelPeriphModuleClock.Location = new System.Drawing.Point(105, 73);
+            this.labelPeriphModuleClock.Name = "labelPeriphModuleClock";
+            this.labelPeriphModuleClock.Size = new System.Drawing.Size(75, 13);
+            this.labelPeriphModuleClock.TabIndex = 20;
+            this.labelPeriphModuleClock.Text = "Module Clock:";
+            // 
+            // textBoxPeriphModuleClock
+            // 
+            this.textBoxPeriphModuleClock.Location = new System.Drawing.Point(193, 70);
+            this.textBoxPeriphModuleClock.Name = "textBoxPeriphModuleClock";
+            this.textBoxPeriphModuleClock.ReadOnly = true;
+            this.textBoxPeriphModuleClock.Size = new System.Drawing.Size(60, 20);
+            this.textBoxPeriphModuleClock.TabIndex = 19;
+            this.textBoxPeriphModuleClock.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            // 
+            // tabPagePLL0
+            // 
+            this.tabPagePLL0.Controls.Add(this.labelPLL0emacMHz);
+            this.tabPagePLL0.Controls.Add(this.labelPLL0sdramMHz);
+            this.tabPagePLL0.Controls.Add(this.labelPLL0cpuMHz);
+            this.tabPagePLL0.Controls.Add(this.labelPLL0emac);
+            this.tabPagePLL0.Controls.Add(this.textBoxPLL0emac);
+            this.tabPagePLL0.Controls.Add(this.labelPLL0sdram);
+            this.tabPagePLL0.Controls.Add(this.textBoxPLL0sdram);
+            this.tabPagePLL0.Controls.Add(this.labelPLL0cpu);
+            this.tabPagePLL0.Controls.Add(this.textBoxPLL0cpu);
+            this.tabPagePLL0.Controls.Add(this.labelPLL0div7);
+            this.tabPagePLL0.Controls.Add(this.textBoxPLL0div7);
+            this.tabPagePLL0.Controls.Add(this.labelPLL0div3);
+            this.tabPagePLL0.Controls.Add(this.textBoxPLL0div3);
+            this.tabPagePLL0.Controls.Add(this.label1);
+            this.tabPagePLL0.Controls.Add(this.textBoxPLL0div1);
+            this.tabPagePLL0.Controls.Add(this.labelPLL0postDiv);
+            this.tabPagePLL0.Controls.Add(this.textBoxPLL0postDiv);
+            this.tabPagePLL0.Controls.Add(this.labelPLL0preDiv);
+            this.tabPagePLL0.Controls.Add(this.textBoxPLL0preDiv);
+            this.tabPagePLL0.Controls.Add(this.labelPLL0mult);
+            this.tabPagePLL0.Controls.Add(this.textBoxPLL0mult);
+            this.tabPagePLL0.Location = new System.Drawing.Point(4, 22);
+            this.tabPagePLL0.Name = "tabPagePLL0";
+            this.tabPagePLL0.Padding = new System.Windows.Forms.Padding(3);
+            this.tabPagePLL0.Size = new System.Drawing.Size(474, 209);
+            this.tabPagePLL0.TabIndex = 1;
+            this.tabPagePLL0.Text = "PLL0";
+            this.tabPagePLL0.UseVisualStyleBackColor = true;
+            // 
+            // labelPLL0emacMHz
+            // 
+            this.labelPLL0emacMHz.AutoSize = true;
+            this.labelPLL0emacMHz.Location = new System.Drawing.Point(362, 162);
+            this.labelPLL0emacMHz.Name = "labelPLL0emacMHz";
+            this.labelPLL0emacMHz.Size = new System.Drawing.Size(29, 13);
+            this.labelPLL0emacMHz.TabIndex = 20;
+            this.labelPLL0emacMHz.Text = "MHz";
+            // 
+            // labelPLL0sdramMHz
+            // 
+            this.labelPLL0sdramMHz.AutoSize = true;
+            this.labelPLL0sdramMHz.Location = new System.Drawing.Point(362, 136);
+            this.labelPLL0sdramMHz.Name = "labelPLL0sdramMHz";
+            this.labelPLL0sdramMHz.Size = new System.Drawing.Size(29, 13);
+            this.labelPLL0sdramMHz.TabIndex = 19;
+            this.labelPLL0sdramMHz.Text = "MHz";
+            // 
+            // labelPLL0cpuMHz
+            // 
+            this.labelPLL0cpuMHz.AutoSize = true;
+            this.labelPLL0cpuMHz.Location = new System.Drawing.Point(362, 110);
+            this.labelPLL0cpuMHz.Name = "labelPLL0cpuMHz";
+            this.labelPLL0cpuMHz.Size = new System.Drawing.Size(29, 13);
+            this.labelPLL0cpuMHz.TabIndex = 18;
+            this.labelPLL0cpuMHz.Text = "MHz";
+            // 
+            // labelPLL0emac
+            // 
+            this.labelPLL0emac.AutoSize = true;
+            this.labelPLL0emac.Location = new System.Drawing.Point(247, 162);
+            this.labelPLL0emac.Name = "labelPLL0emac";
+            this.labelPLL0emac.Size = new System.Drawing.Size(40, 13);
+            this.labelPLL0emac.TabIndex = 17;
+            this.labelPLL0emac.Text = "EMAC:";
+            // 
+            // textBoxPLL0emac
+            // 
+            this.textBoxPLL0emac.Location = new System.Drawing.Point(302, 159);
+            this.textBoxPLL0emac.Name = "textBoxPLL0emac";
+            this.textBoxPLL0emac.ReadOnly = true;
+            this.textBoxPLL0emac.Size = new System.Drawing.Size(40, 20);
+            this.textBoxPLL0emac.TabIndex = 16;
+            this.textBoxPLL0emac.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            // 
+            // labelPLL0sdram
+            // 
+            this.labelPLL0sdram.AutoSize = true;
+            this.labelPLL0sdram.Location = new System.Drawing.Point(247, 136);
+            this.labelPLL0sdram.Name = "labelPLL0sdram";
+            this.labelPLL0sdram.Size = new System.Drawing.Size(49, 13);
+            this.labelPLL0sdram.TabIndex = 15;
+            this.labelPLL0sdram.Text = "SDRAM:";
+            // 
+            // textBoxPLL0sdram
+            // 
+            this.textBoxPLL0sdram.Location = new System.Drawing.Point(302, 133);
+            this.textBoxPLL0sdram.Name = "textBoxPLL0sdram";
+            this.textBoxPLL0sdram.ReadOnly = true;
+            this.textBoxPLL0sdram.Size = new System.Drawing.Size(40, 20);
+            this.textBoxPLL0sdram.TabIndex = 14;
+            this.textBoxPLL0sdram.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            // 
+            // labelPLL0cpu
+            // 
+            this.labelPLL0cpu.AutoSize = true;
+            this.labelPLL0cpu.Location = new System.Drawing.Point(247, 110);
+            this.labelPLL0cpu.Name = "labelPLL0cpu";
+            this.labelPLL0cpu.Size = new System.Drawing.Size(32, 13);
+            this.labelPLL0cpu.TabIndex = 13;
+            this.labelPLL0cpu.Text = "CPU:";
+            // 
+            // textBoxPLL0cpu
+            // 
+            this.textBoxPLL0cpu.Location = new System.Drawing.Point(302, 107);
+            this.textBoxPLL0cpu.Name = "textBoxPLL0cpu";
+            this.textBoxPLL0cpu.ReadOnly = true;
+            this.textBoxPLL0cpu.Size = new System.Drawing.Size(40, 20);
+            this.textBoxPLL0cpu.TabIndex = 12;
+            this.textBoxPLL0cpu.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            // 
+            // labelPLL0div7
+            // 
+            this.labelPLL0div7.AutoSize = true;
+            this.labelPLL0div7.Location = new System.Drawing.Point(84, 162);
+            this.labelPLL0div7.Name = "labelPLL0div7";
+            this.labelPLL0div7.Size = new System.Drawing.Size(34, 13);
+            this.labelPLL0div7.TabIndex = 11;
+            this.labelPLL0div7.Text = "DIV7:";
+            // 
+            // textBoxPLL0div7
+            // 
+            this.textBoxPLL0div7.Location = new System.Drawing.Point(156, 159);
+            this.textBoxPLL0div7.Name = "textBoxPLL0div7";
+            this.textBoxPLL0div7.Size = new System.Drawing.Size(40, 20);
+            this.textBoxPLL0div7.TabIndex = 5;
+            this.textBoxPLL0div7.Text = "6";
+            this.textBoxPLL0div7.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPLL0div7.TextChanged += new System.EventHandler(this.textBoxPLL0div7_TextChanged);
+            // 
+            // labelPLL0div3
+            // 
+            this.labelPLL0div3.AutoSize = true;
+            this.labelPLL0div3.Location = new System.Drawing.Point(84, 136);
+            this.labelPLL0div3.Name = "labelPLL0div3";
+            this.labelPLL0div3.Size = new System.Drawing.Size(34, 13);
+            this.labelPLL0div3.TabIndex = 9;
+            this.labelPLL0div3.Text = "DIV3:";
+            // 
+            // textBoxPLL0div3
+            // 
+            this.textBoxPLL0div3.Location = new System.Drawing.Point(156, 133);
+            this.textBoxPLL0div3.Name = "textBoxPLL0div3";
+            this.textBoxPLL0div3.Size = new System.Drawing.Size(40, 20);
+            this.textBoxPLL0div3.TabIndex = 4;
+            this.textBoxPLL0div3.Text = "3";
+            this.textBoxPLL0div3.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPLL0div3.TextChanged += new System.EventHandler(this.textBoxPLL0div3_TextChanged);
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Location = new System.Drawing.Point(84, 110);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(34, 13);
+            this.label1.TabIndex = 7;
+            this.label1.Text = "DIV1:";
+            // 
+            // textBoxPLL0div1
+            // 
+            this.textBoxPLL0div1.Location = new System.Drawing.Point(156, 107);
+            this.textBoxPLL0div1.Name = "textBoxPLL0div1";
+            this.textBoxPLL0div1.Size = new System.Drawing.Size(40, 20);
+            this.textBoxPLL0div1.TabIndex = 3;
+            this.textBoxPLL0div1.Text = "1";
+            this.textBoxPLL0div1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPLL0div1.TextChanged += new System.EventHandler(this.textBoxPLL0div1_TextChanged);
+            // 
+            // labelPLL0postDiv
+            // 
+            this.labelPLL0postDiv.AutoSize = true;
+            this.labelPLL0postDiv.Location = new System.Drawing.Point(84, 84);
+            this.labelPLL0postDiv.Name = "labelPLL0postDiv";
+            this.labelPLL0postDiv.Size = new System.Drawing.Size(66, 13);
+            this.labelPLL0postDiv.TabIndex = 5;
+            this.labelPLL0postDiv.Text = "Post-Divisor:";
+            // 
+            // textBoxPLL0postDiv
+            // 
+            this.textBoxPLL0postDiv.Location = new System.Drawing.Point(156, 81);
+            this.textBoxPLL0postDiv.Name = "textBoxPLL0postDiv";
+            this.textBoxPLL0postDiv.Size = new System.Drawing.Size(40, 20);
+            this.textBoxPLL0postDiv.TabIndex = 2;
+            this.textBoxPLL0postDiv.Text = "2";
+            this.textBoxPLL0postDiv.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPLL0postDiv.TextChanged += new System.EventHandler(this.textBoxPLL0postDiv_TextChanged);
+            // 
+            // labelPLL0preDiv
+            // 
+            this.labelPLL0preDiv.AutoSize = true;
+            this.labelPLL0preDiv.Location = new System.Drawing.Point(84, 32);
+            this.labelPLL0preDiv.Name = "labelPLL0preDiv";
+            this.labelPLL0preDiv.Size = new System.Drawing.Size(61, 13);
+            this.labelPLL0preDiv.TabIndex = 3;
+            this.labelPLL0preDiv.Text = "Pre-Divisor:";
+            // 
+            // textBoxPLL0preDiv
+            // 
+            this.textBoxPLL0preDiv.Location = new System.Drawing.Point(156, 29);
+            this.textBoxPLL0preDiv.Name = "textBoxPLL0preDiv";
+            this.textBoxPLL0preDiv.Size = new System.Drawing.Size(40, 20);
+            this.textBoxPLL0preDiv.TabIndex = 0;
+            this.textBoxPLL0preDiv.Text = "1";
+            this.textBoxPLL0preDiv.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPLL0preDiv.TextChanged += new System.EventHandler(this.textBoxPLL0preDiv_TextChanged);
+            // 
+            // labelPLL0mult
+            // 
+            this.labelPLL0mult.AutoSize = true;
+            this.labelPLL0mult.Location = new System.Drawing.Point(84, 58);
+            this.labelPLL0mult.Name = "labelPLL0mult";
+            this.labelPLL0mult.Size = new System.Drawing.Size(51, 13);
+            this.labelPLL0mult.TabIndex = 1;
+            this.labelPLL0mult.Text = "Multiplier:";
+            // 
+            // textBoxPLL0mult
+            // 
+            this.textBoxPLL0mult.Location = new System.Drawing.Point(156, 55);
+            this.textBoxPLL0mult.Name = "textBoxPLL0mult";
+            this.textBoxPLL0mult.Size = new System.Drawing.Size(40, 20);
+            this.textBoxPLL0mult.TabIndex = 1;
+            this.textBoxPLL0mult.Text = "20";
+            this.textBoxPLL0mult.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPLL0mult.TextChanged += new System.EventHandler(this.textBoxPLL0mult_TextChanged);
+            // 
+            // tabPageSDRAM
+            // 
+            this.tabPageSDRAM.Controls.Add(this.labelSDRAMsdrcr);
+            this.tabPageSDRAM.Controls.Add(this.textBoxSDRAMsdrcr);
+            this.tabPageSDRAM.Controls.Add(this.labelSDRAMsdrsrpdexit);
+            this.tabPageSDRAM.Controls.Add(this.textBoxSDRAMsdrsrpdexit);
+            this.tabPageSDRAM.Controls.Add(this.labelSDRAMsdtmr);
+            this.tabPageSDRAM.Controls.Add(this.textBoxSDRAMsdtmr);
+            this.tabPageSDRAM.Controls.Add(this.labelSDRAMsdbcr);
+            this.tabPageSDRAM.Controls.Add(this.textBoxSDRAMsdbcr);
+            this.tabPageSDRAM.Controls.Add(this.checkBoxSDRAMdiv);
+            this.tabPageSDRAM.Controls.Add(this.labelSDRAMclockMHz);
+            this.tabPageSDRAM.Controls.Add(this.labelSDRAMclock);
+            this.tabPageSDRAM.Controls.Add(this.textBoxSDRAMclock);
+            this.tabPageSDRAM.Location = new System.Drawing.Point(4, 22);
+            this.tabPageSDRAM.Name = "tabPageSDRAM";
+            this.tabPageSDRAM.Size = new System.Drawing.Size(474, 209);
+            this.tabPageSDRAM.TabIndex = 4;
+            this.tabPageSDRAM.Text = "SDRAM";
+            this.tabPageSDRAM.UseVisualStyleBackColor = true;
+            // 
+            // labelSDRAMsdrcr
+            // 
+            this.labelSDRAMsdrcr.AutoSize = true;
+            this.labelSDRAMsdrcr.Location = new System.Drawing.Point(145, 161);
+            this.labelSDRAMsdrcr.Name = "labelSDRAMsdrcr";
+            this.labelSDRAMsdrcr.Size = new System.Drawing.Size(48, 13);
+            this.labelSDRAMsdrcr.TabIndex = 33;
+            this.labelSDRAMsdrcr.Text = "SDRCR:";
+            // 
+            // textBoxSDRAMsdrcr
+            // 
+            this.textBoxSDRAMsdrcr.Location = new System.Drawing.Point(230, 158);
+            this.textBoxSDRAMsdrcr.MaxLength = 10;
+            this.textBoxSDRAMsdrcr.Name = "textBoxSDRAMsdrcr";
+            this.textBoxSDRAMsdrcr.Size = new System.Drawing.Size(80, 20);
+            this.textBoxSDRAMsdrcr.TabIndex = 4;
+            this.textBoxSDRAMsdrcr.Text = "0x00000000";
+            this.textBoxSDRAMsdrcr.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxSDRAMsdrcr.TextChanged += new System.EventHandler(this.textBoxSDRAMsdrcr_TextChanged);
+            // 
+            // labelSDRAMsdrsrpdexit
+            // 
+            this.labelSDRAMsdrsrpdexit.AutoSize = true;
+            this.labelSDRAMsdrsrpdexit.Location = new System.Drawing.Point(145, 135);
+            this.labelSDRAMsdrsrpdexit.Name = "labelSDRAMsdrsrpdexit";
+            this.labelSDRAMsdrsrpdexit.Size = new System.Drawing.Size(62, 13);
+            this.labelSDRAMsdrsrpdexit.TabIndex = 31;
+            this.labelSDRAMsdrsrpdexit.Text = "SDSRETR:";
+            // 
+            // textBoxSDRAMsdrsrpdexit
+            // 
+            this.textBoxSDRAMsdrsrpdexit.Location = new System.Drawing.Point(230, 132);
+            this.textBoxSDRAMsdrsrpdexit.MaxLength = 10;
+            this.textBoxSDRAMsdrsrpdexit.Name = "textBoxSDRAMsdrsrpdexit";
+            this.textBoxSDRAMsdrsrpdexit.Size = new System.Drawing.Size(80, 20);
+            this.textBoxSDRAMsdrsrpdexit.TabIndex = 3;
+            this.textBoxSDRAMsdrsrpdexit.Text = "0x00000000";
+            this.textBoxSDRAMsdrsrpdexit.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxSDRAMsdrsrpdexit.TextChanged += new System.EventHandler(this.textBoxSDRAMsdrsrpdexit_TextChanged);
+            // 
+            // labelSDRAMsdtmr
+            // 
+            this.labelSDRAMsdtmr.AutoSize = true;
+            this.labelSDRAMsdtmr.Location = new System.Drawing.Point(145, 109);
+            this.labelSDRAMsdtmr.Name = "labelSDRAMsdtmr";
+            this.labelSDRAMsdtmr.Size = new System.Drawing.Size(49, 13);
+            this.labelSDRAMsdtmr.TabIndex = 29;
+            this.labelSDRAMsdtmr.Text = "SDTMR:";
+            // 
+            // textBoxSDRAMsdtmr
+            // 
+            this.textBoxSDRAMsdtmr.Location = new System.Drawing.Point(230, 106);
+            this.textBoxSDRAMsdtmr.MaxLength = 10;
+            this.textBoxSDRAMsdtmr.Name = "textBoxSDRAMsdtmr";
+            this.textBoxSDRAMsdtmr.Size = new System.Drawing.Size(80, 20);
+            this.textBoxSDRAMsdtmr.TabIndex = 2;
+            this.textBoxSDRAMsdtmr.Text = "0x00000000";
+            this.textBoxSDRAMsdtmr.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxSDRAMsdtmr.TextChanged += new System.EventHandler(this.textBoxSDRAMsdtmr_TextChanged);
+            // 
+            // labelSDRAMsdbcr
+            // 
+            this.labelSDRAMsdbcr.AutoSize = true;
+            this.labelSDRAMsdbcr.Location = new System.Drawing.Point(145, 83);
+            this.labelSDRAMsdbcr.Name = "labelSDRAMsdbcr";
+            this.labelSDRAMsdbcr.Size = new System.Drawing.Size(40, 13);
+            this.labelSDRAMsdbcr.TabIndex = 27;
+            this.labelSDRAMsdbcr.Text = "SDCR:";
+            // 
+            // textBoxSDRAMsdbcr
+            // 
+            this.textBoxSDRAMsdbcr.Location = new System.Drawing.Point(230, 80);
+            this.textBoxSDRAMsdbcr.MaxLength = 10;
+            this.textBoxSDRAMsdbcr.Name = "textBoxSDRAMsdbcr";
+            this.textBoxSDRAMsdbcr.Size = new System.Drawing.Size(80, 20);
+            this.textBoxSDRAMsdbcr.TabIndex = 1;
+            this.textBoxSDRAMsdbcr.Text = "0x00000000";
+            this.textBoxSDRAMsdbcr.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxSDRAMsdbcr.TextChanged += new System.EventHandler(this.textBoxSDRAMsdbcr_TextChanged);
+            // 
+            // checkBoxSDRAMdiv
+            // 
+            this.checkBoxSDRAMdiv.AutoSize = true;
+            this.checkBoxSDRAMdiv.Location = new System.Drawing.Point(148, 31);
+            this.checkBoxSDRAMdiv.Name = "checkBoxSDRAMdiv";
+            this.checkBoxSDRAMdiv.Size = new System.Drawing.Size(182, 17);
+            this.checkBoxSDRAMdiv.TabIndex = 0;
+            this.checkBoxSDRAMdiv.Text = "Use 4.5 divisor for SDRAM clock";
+            this.checkBoxSDRAMdiv.UseVisualStyleBackColor = true;
+            this.checkBoxSDRAMdiv.CheckedChanged += new System.EventHandler(this.checkBoxSDRAMdiv_CheckedChanged);
+            // 
+            // labelSDRAMclockMHz
+            // 
+            this.labelSDRAMclockMHz.AutoSize = true;
+            this.labelSDRAMclockMHz.Location = new System.Drawing.Point(290, 57);
+            this.labelSDRAMclockMHz.Name = "labelSDRAMclockMHz";
+            this.labelSDRAMclockMHz.Size = new System.Drawing.Size(29, 13);
+            this.labelSDRAMclockMHz.TabIndex = 24;
+            this.labelSDRAMclockMHz.Text = "MHz";
+            // 
+            // labelSDRAMclock
+            // 
+            this.labelSDRAMclock.AutoSize = true;
+            this.labelSDRAMclock.Location = new System.Drawing.Point(145, 57);
+            this.labelSDRAMclock.Name = "labelSDRAMclock";
+            this.labelSDRAMclock.Size = new System.Drawing.Size(79, 13);
+            this.labelSDRAMclock.TabIndex = 23;
+            this.labelSDRAMclock.Text = "SDRAM Clock:";
+            // 
+            // textBoxSDRAMclock
+            // 
+            this.textBoxSDRAMclock.Location = new System.Drawing.Point(230, 54);
+            this.textBoxSDRAMclock.Name = "textBoxSDRAMclock";
+            this.textBoxSDRAMclock.ReadOnly = true;
+            this.textBoxSDRAMclock.Size = new System.Drawing.Size(40, 20);
+            this.textBoxSDRAMclock.TabIndex = 22;
+            this.textBoxSDRAMclock.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            // 
+            // tabPagePLL1
+            // 
+            this.tabPagePLL1.Controls.Add(this.labelPLL1ddr2MHz);
+            this.tabPagePLL1.Controls.Add(this.labelPLL1ddr2);
+            this.tabPagePLL1.Controls.Add(this.textBoxPLL1ddr2);
+            this.tabPagePLL1.Controls.Add(this.labelPLL1div3);
+            this.tabPagePLL1.Controls.Add(this.textBoxPLL1div3);
+            this.tabPagePLL1.Controls.Add(this.labelPLL1div2);
+            this.tabPagePLL1.Controls.Add(this.textBoxPLL1div2);
+            this.tabPagePLL1.Controls.Add(this.labelPLL1div1);
+            this.tabPagePLL1.Controls.Add(this.textBoxPLL1div1);
+            this.tabPagePLL1.Controls.Add(this.labelPLL1postDiv);
+            this.tabPagePLL1.Controls.Add(this.textBoxPLL1postDiv);
+            this.tabPagePLL1.Controls.Add(this.labelPLL1mult);
+            this.tabPagePLL1.Controls.Add(this.textBoxPLL1mult);
+            this.tabPagePLL1.Location = new System.Drawing.Point(4, 22);
+            this.tabPagePLL1.Name = "tabPagePLL1";
+            this.tabPagePLL1.Size = new System.Drawing.Size(474, 209);
+            this.tabPagePLL1.TabIndex = 2;
+            this.tabPagePLL1.Text = "PLL1";
+            this.tabPagePLL1.UseVisualStyleBackColor = true;
+            // 
+            // labelPLL1ddr2MHz
+            // 
+            this.labelPLL1ddr2MHz.AutoSize = true;
+            this.labelPLL1ddr2MHz.Location = new System.Drawing.Point(364, 97);
+            this.labelPLL1ddr2MHz.Name = "labelPLL1ddr2MHz";
+            this.labelPLL1ddr2MHz.Size = new System.Drawing.Size(29, 13);
+            this.labelPLL1ddr2MHz.TabIndex = 26;
+            this.labelPLL1ddr2MHz.Text = "MHz";
+            // 
+            // labelPLL1ddr2
+            // 
+            this.labelPLL1ddr2.AutoSize = true;
+            this.labelPLL1ddr2.Location = new System.Drawing.Point(244, 97);
+            this.labelPLL1ddr2.Name = "labelPLL1ddr2";
+            this.labelPLL1ddr2.Size = new System.Drawing.Size(54, 13);
+            this.labelPLL1ddr2.TabIndex = 25;
+            this.labelPLL1ddr2.Text = "DDR (2x):";
+            // 
+            // textBoxPLL1ddr2
+            // 
+            this.textBoxPLL1ddr2.Location = new System.Drawing.Point(304, 94);
+            this.textBoxPLL1ddr2.Name = "textBoxPLL1ddr2";
+            this.textBoxPLL1ddr2.ReadOnly = true;
+            this.textBoxPLL1ddr2.Size = new System.Drawing.Size(40, 20);
+            this.textBoxPLL1ddr2.TabIndex = 24;
+            this.textBoxPLL1ddr2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            // 
+            // labelPLL1div3
+            // 
+            this.labelPLL1div3.AutoSize = true;
+            this.labelPLL1div3.Location = new System.Drawing.Point(81, 149);
+            this.labelPLL1div3.Name = "labelPLL1div3";
+            this.labelPLL1div3.Size = new System.Drawing.Size(34, 13);
+            this.labelPLL1div3.TabIndex = 23;
+            this.labelPLL1div3.Text = "DIV3:";
+            // 
+            // textBoxPLL1div3
+            // 
+            this.textBoxPLL1div3.Location = new System.Drawing.Point(153, 146);
+            this.textBoxPLL1div3.Name = "textBoxPLL1div3";
+            this.textBoxPLL1div3.Size = new System.Drawing.Size(40, 20);
+            this.textBoxPLL1div3.TabIndex = 4;
+            this.textBoxPLL1div3.Text = "3";
+            this.textBoxPLL1div3.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPLL1div3.TextChanged += new System.EventHandler(this.textBoxPLL1div3_TextChanged);
+            // 
+            // labelPLL1div2
+            // 
+            this.labelPLL1div2.AutoSize = true;
+            this.labelPLL1div2.Location = new System.Drawing.Point(81, 123);
+            this.labelPLL1div2.Name = "labelPLL1div2";
+            this.labelPLL1div2.Size = new System.Drawing.Size(34, 13);
+            this.labelPLL1div2.TabIndex = 21;
+            this.labelPLL1div2.Text = "DIV2:";
+            // 
+            // textBoxPLL1div2
+            // 
+            this.textBoxPLL1div2.Location = new System.Drawing.Point(153, 120);
+            this.textBoxPLL1div2.Name = "textBoxPLL1div2";
+            this.textBoxPLL1div2.Size = new System.Drawing.Size(40, 20);
+            this.textBoxPLL1div2.TabIndex = 3;
+            this.textBoxPLL1div2.Text = "2";
+            this.textBoxPLL1div2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPLL1div2.TextChanged += new System.EventHandler(this.textBoxPLL1div2_TextChanged);
+            // 
+            // labelPLL1div1
+            // 
+            this.labelPLL1div1.AutoSize = true;
+            this.labelPLL1div1.Location = new System.Drawing.Point(81, 97);
+            this.labelPLL1div1.Name = "labelPLL1div1";
+            this.labelPLL1div1.Size = new System.Drawing.Size(34, 13);
+            this.labelPLL1div1.TabIndex = 19;
+            this.labelPLL1div1.Text = "DIV1:";
+            // 
+            // textBoxPLL1div1
+            // 
+            this.textBoxPLL1div1.Location = new System.Drawing.Point(153, 94);
+            this.textBoxPLL1div1.Name = "textBoxPLL1div1";
+            this.textBoxPLL1div1.Size = new System.Drawing.Size(40, 20);
+            this.textBoxPLL1div1.TabIndex = 2;
+            this.textBoxPLL1div1.Text = "1";
+            this.textBoxPLL1div1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPLL1div1.TextChanged += new System.EventHandler(this.textBoxPLL1div1_TextChanged);
+            // 
+            // labelPLL1postDiv
+            // 
+            this.labelPLL1postDiv.AutoSize = true;
+            this.labelPLL1postDiv.Location = new System.Drawing.Point(81, 71);
+            this.labelPLL1postDiv.Name = "labelPLL1postDiv";
+            this.labelPLL1postDiv.Size = new System.Drawing.Size(66, 13);
+            this.labelPLL1postDiv.TabIndex = 17;
+            this.labelPLL1postDiv.Text = "Post-Divisor:";
+            // 
+            // textBoxPLL1postDiv
+            // 
+            this.textBoxPLL1postDiv.Location = new System.Drawing.Point(153, 68);
+            this.textBoxPLL1postDiv.Name = "textBoxPLL1postDiv";
+            this.textBoxPLL1postDiv.Size = new System.Drawing.Size(40, 20);
+            this.textBoxPLL1postDiv.TabIndex = 1;
+            this.textBoxPLL1postDiv.Text = "2";
+            this.textBoxPLL1postDiv.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPLL1postDiv.TextChanged += new System.EventHandler(this.textBoxPLL1postDiv_TextChanged);
+            // 
+            // labelPLL1mult
+            // 
+            this.labelPLL1mult.AutoSize = true;
+            this.labelPLL1mult.Location = new System.Drawing.Point(81, 45);
+            this.labelPLL1mult.Name = "labelPLL1mult";
+            this.labelPLL1mult.Size = new System.Drawing.Size(51, 13);
+            this.labelPLL1mult.TabIndex = 13;
+            this.labelPLL1mult.Text = "Multiplier:";
+            // 
+            // textBoxPLL1mult
+            // 
+            this.textBoxPLL1mult.Location = new System.Drawing.Point(153, 42);
+            this.textBoxPLL1mult.Name = "textBoxPLL1mult";
+            this.textBoxPLL1mult.Size = new System.Drawing.Size(40, 20);
+            this.textBoxPLL1mult.TabIndex = 0;
+            this.textBoxPLL1mult.Text = "20";
+            this.textBoxPLL1mult.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPLL1mult.TextChanged += new System.EventHandler(this.textBoxPLL1mult_TextChanged);
+            // 
+            // tabPageDDR2
+            // 
+            this.tabPageDDR2.Controls.Add(this.labelDDR2sdcr2);
+            this.tabPageDDR2.Controls.Add(this.textBoxDDR2sdcr2);
+            this.tabPageDDR2.Controls.Add(this.groupBoxDDRtype);
+            this.tabPageDDR2.Controls.Add(this.labelDDR2phy);
+            this.tabPageDDR2.Controls.Add(this.textBoxDDR2phy);
+            this.tabPageDDR2.Controls.Add(this.labelDDR2sdrcr);
+            this.tabPageDDR2.Controls.Add(this.textBoxDDR2sdrcr);
+            this.tabPageDDR2.Controls.Add(this.labelDDR2sdtimr2);
+            this.tabPageDDR2.Controls.Add(this.textBoxDDR2sdtimr2);
+            this.tabPageDDR2.Controls.Add(this.labelDDR2sdtimr);
+            this.tabPageDDR2.Controls.Add(this.textBoxDDR2sdtimr);
+            this.tabPageDDR2.Controls.Add(this.labelDDR2sdcr);
+            this.tabPageDDR2.Controls.Add(this.textBoxDDR2sdcr);
+            this.tabPageDDR2.Controls.Add(this.checkBoxDDR2directClock);
+            this.tabPageDDR2.Controls.Add(this.labelDDR2clockMHz);
+            this.tabPageDDR2.Controls.Add(this.labelDDR2clock);
+            this.tabPageDDR2.Controls.Add(this.textBoxDDR2clock);
+            this.tabPageDDR2.Location = new System.Drawing.Point(4, 22);
+            this.tabPageDDR2.Name = "tabPageDDR2";
+            this.tabPageDDR2.Size = new System.Drawing.Size(474, 209);
+            this.tabPageDDR2.TabIndex = 3;
+            this.tabPageDDR2.Text = "DDR";
+            this.tabPageDDR2.UseVisualStyleBackColor = true;
+            // 
+            // labelDDR2sdcr2
+            // 
+            this.labelDDR2sdcr2.AutoSize = true;
+            this.labelDDR2sdcr2.Location = new System.Drawing.Point(261, 84);
+            this.labelDDR2sdcr2.Name = "labelDDR2sdcr2";
+            this.labelDDR2sdcr2.Size = new System.Drawing.Size(46, 13);
+            this.labelDDR2sdcr2.TabIndex = 52;
+            this.labelDDR2sdcr2.Text = "SDCR2:";
+            // 
+            // textBoxDDR2sdcr2
+            // 
+            this.textBoxDDR2sdcr2.Location = new System.Drawing.Point(331, 81);
+            this.textBoxDDR2sdcr2.MaxLength = 10;
+            this.textBoxDDR2sdcr2.Name = "textBoxDDR2sdcr2";
+            this.textBoxDDR2sdcr2.Size = new System.Drawing.Size(80, 20);
+            this.textBoxDDR2sdcr2.TabIndex = 3;
+            this.textBoxDDR2sdcr2.Text = "0x00000000";
+            this.textBoxDDR2sdcr2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxDDR2sdcr2.TextChanged += new System.EventHandler(this.textBoxDDR2sdcr2_TextChanged);
+            // 
+            // groupBoxDDRtype
+            // 
+            this.groupBoxDDRtype.Controls.Add(this.radioMDDR);
+            this.groupBoxDDRtype.Controls.Add(this.radioDDR2);
+            this.groupBoxDDRtype.Controls.Add(this.radioDuplicateMddrSetting);
+            this.groupBoxDDRtype.Location = new System.Drawing.Point(66, 80);
+            this.groupBoxDDRtype.Name = "groupBoxDDRtype";
+            this.groupBoxDDRtype.Size = new System.Drawing.Size(150, 100);
+            this.groupBoxDDRtype.TabIndex = 50;
+            this.groupBoxDDRtype.TabStop = false;
+            this.groupBoxDDRtype.Text = "Memory Type";
+            // 
+            // radioMDDR
+            // 
+            this.radioMDDR.AutoSize = true;
+            this.radioMDDR.Checked = true;
+            this.radioMDDR.Location = new System.Drawing.Point(6, 19);
+            this.radioMDDR.Name = "radioMDDR";
+            this.radioMDDR.Size = new System.Drawing.Size(57, 17);
+            this.radioMDDR.TabIndex = 0;
+            this.radioMDDR.TabStop = true;
+            this.radioMDDR.Text = "mDDR";
+            this.radioMDDR.UseVisualStyleBackColor = true;
+            this.radioMDDR.CheckedChanged += new System.EventHandler(this.radioMDDR_CheckedChanged);
+            // 
+            // radioDDR2
+            // 
+            this.radioDDR2.AutoSize = true;
+            this.radioDDR2.Location = new System.Drawing.Point(69, 20);
+            this.radioDDR2.Name = "radioDDR2";
+            this.radioDDR2.Size = new System.Drawing.Size(55, 17);
+            this.radioDDR2.TabIndex = 1;
+            this.radioDDR2.Text = "DDR2";
+            this.radioDDR2.UseVisualStyleBackColor = true;
+            this.radioDDR2.CheckedChanged += new System.EventHandler(this.radioDDR2_CheckedChanged);
+            // 
+            // radioDuplicateMddrSetting
+            // 
+            this.radioDuplicateMddrSetting.AutoSize = true;
+            this.radioDuplicateMddrSetting.Checked = false;
+            this.radioDuplicateMddrSetting.Location = new System.Drawing.Point(6, 79);
+            this.radioDuplicateMddrSetting.Name = "radioDuplicateMddrSetting";
+            this.radioDuplicateMddrSetting.Size = new System.Drawing.Size(57, 17);
+            this.radioDuplicateMddrSetting.TabIndex = 0;
+            this.radioDuplicateMddrSetting.TabStop = true;
+            this.radioDuplicateMddrSetting.Text = "mDDR with SRR support";
+            this.radioDuplicateMddrSetting.UseVisualStyleBackColor = true;
+            this.radioDuplicateMddrSetting.CheckedChanged += new System.EventHandler(this.radioDuplicateMddrSetting_CheckedChanged);
+            // 
+            // labelDDR2phy
+            // 
+            this.labelDDR2phy.AutoSize = true;
+            this.labelDDR2phy.Location = new System.Drawing.Point(261, 32);
+            this.labelDDR2phy.Name = "labelDDR2phy";
+            this.labelDDR2phy.Size = new System.Drawing.Size(61, 13);
+            this.labelDDR2phy.TabIndex = 47;
+            this.labelDDR2phy.Text = "DRPYC1R:";
+            // 
+            // textBoxDDR2phy
+            // 
+            this.textBoxDDR2phy.Location = new System.Drawing.Point(331, 29);
+            this.textBoxDDR2phy.MaxLength = 10;
+            this.textBoxDDR2phy.Name = "textBoxDDR2phy";
+            this.textBoxDDR2phy.Size = new System.Drawing.Size(80, 20);
+            this.textBoxDDR2phy.TabIndex = 1;
+            this.textBoxDDR2phy.Text = "0x00000000";
+            this.textBoxDDR2phy.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxDDR2phy.TextChanged += new System.EventHandler(this.textBoxDDR2phy_TextChanged);
+            // 
+            // labelDDR2sdrcr
+            // 
+            this.labelDDR2sdrcr.AutoSize = true;
+            this.labelDDR2sdrcr.Location = new System.Drawing.Point(261, 162);
+            this.labelDDR2sdrcr.Name = "labelDDR2sdrcr";
+            this.labelDDR2sdrcr.Size = new System.Drawing.Size(48, 13);
+            this.labelDDR2sdrcr.TabIndex = 45;
+            this.labelDDR2sdrcr.Text = "SDRCR:";
+            // 
+            // textBoxDDR2sdrcr
+            // 
+            this.textBoxDDR2sdrcr.Location = new System.Drawing.Point(331, 159);
+            this.textBoxDDR2sdrcr.MaxLength = 10;
+            this.textBoxDDR2sdrcr.Name = "textBoxDDR2sdrcr";
+            this.textBoxDDR2sdrcr.Size = new System.Drawing.Size(80, 20);
+            this.textBoxDDR2sdrcr.TabIndex = 6;
+            this.textBoxDDR2sdrcr.Text = "0x00000000";
+            this.textBoxDDR2sdrcr.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxDDR2sdrcr.TextChanged += new System.EventHandler(this.textBoxDDR2sdrcr_TextChanged);
+            // 
+            // labelDDR2sdtimr2
+            // 
+            this.labelDDR2sdtimr2.AutoSize = true;
+            this.labelDDR2sdtimr2.Location = new System.Drawing.Point(261, 136);
+            this.labelDDR2sdtimr2.Name = "labelDDR2sdtimr2";
+            this.labelDDR2sdtimr2.Size = new System.Drawing.Size(58, 13);
+            this.labelDDR2sdtimr2.TabIndex = 43;
+            this.labelDDR2sdtimr2.Text = "SDTIMR2:";
+            // 
+            // textBoxDDR2sdtimr2
+            // 
+            this.textBoxDDR2sdtimr2.Location = new System.Drawing.Point(331, 133);
+            this.textBoxDDR2sdtimr2.MaxLength = 10;
+            this.textBoxDDR2sdtimr2.Name = "textBoxDDR2sdtimr2";
+            this.textBoxDDR2sdtimr2.Size = new System.Drawing.Size(80, 20);
+            this.textBoxDDR2sdtimr2.TabIndex = 5;
+            this.textBoxDDR2sdtimr2.Text = "0x00000000";
+            this.textBoxDDR2sdtimr2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxDDR2sdtimr2.TextChanged += new System.EventHandler(this.textBoxDDR2sdtimr2_TextChanged);
+            // 
+            // labelDDR2sdtimr
+            // 
+            this.labelDDR2sdtimr.AutoSize = true;
+            this.labelDDR2sdtimr.Location = new System.Drawing.Point(261, 110);
+            this.labelDDR2sdtimr.Name = "labelDDR2sdtimr";
+            this.labelDDR2sdtimr.Size = new System.Drawing.Size(58, 13);
+            this.labelDDR2sdtimr.TabIndex = 41;
+            this.labelDDR2sdtimr.Text = "SDTIMR1:";
+            // 
+            // textBoxDDR2sdtimr
+            // 
+            this.textBoxDDR2sdtimr.Location = new System.Drawing.Point(331, 107);
+            this.textBoxDDR2sdtimr.MaxLength = 10;
+            this.textBoxDDR2sdtimr.Name = "textBoxDDR2sdtimr";
+            this.textBoxDDR2sdtimr.Size = new System.Drawing.Size(80, 20);
+            this.textBoxDDR2sdtimr.TabIndex = 4;
+            this.textBoxDDR2sdtimr.Text = "0x00000000";
+            this.textBoxDDR2sdtimr.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxDDR2sdtimr.TextChanged += new System.EventHandler(this.textBoxDDR2sdtimr_TextChanged);
+            // 
+            // labelDDR2sdcr
+            // 
+            this.labelDDR2sdcr.AutoSize = true;
+            this.labelDDR2sdcr.Location = new System.Drawing.Point(261, 58);
+            this.labelDDR2sdcr.Name = "labelDDR2sdcr";
+            this.labelDDR2sdcr.Size = new System.Drawing.Size(40, 13);
+            this.labelDDR2sdcr.TabIndex = 39;
+            this.labelDDR2sdcr.Text = "SDCR:";
+            // 
+            // textBoxDDR2sdcr
+            // 
+            this.textBoxDDR2sdcr.Location = new System.Drawing.Point(331, 55);
+            this.textBoxDDR2sdcr.MaxLength = 10;
+            this.textBoxDDR2sdcr.Name = "textBoxDDR2sdcr";
+            this.textBoxDDR2sdcr.Size = new System.Drawing.Size(80, 20);
+            this.textBoxDDR2sdcr.TabIndex = 2;
+            this.textBoxDDR2sdcr.Text = "0x00000000";
+            this.textBoxDDR2sdcr.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxDDR2sdcr.TextChanged += new System.EventHandler(this.textBoxDDR2sdcr_TextChanged);
+            // 
+            // checkBoxDDR2directClock
+            // 
+            this.checkBoxDDR2directClock.AutoSize = true;
+            this.checkBoxDDR2directClock.Location = new System.Drawing.Point(66, 31);
+            this.checkBoxDDR2directClock.Name = "checkBoxDDR2directClock";
+            this.checkBoxDDR2directClock.Size = new System.Drawing.Size(154, 17);
+            this.checkBoxDDR2directClock.TabIndex = 0;
+            this.checkBoxDDR2directClock.Text = "Use direct clock from PLL1";
+            this.checkBoxDDR2directClock.UseVisualStyleBackColor = true;
+            this.checkBoxDDR2directClock.CheckedChanged += new System.EventHandler(this.checkBoxDDR2directClock_CheckedChanged);
+            // 
+            // labelDDR2clockMHz
+            // 
+            this.labelDDR2clockMHz.AutoSize = true;
+            this.labelDDR2clockMHz.Location = new System.Drawing.Point(210, 57);
+            this.labelDDR2clockMHz.Name = "labelDDR2clockMHz";
+            this.labelDDR2clockMHz.Size = new System.Drawing.Size(29, 13);
+            this.labelDDR2clockMHz.TabIndex = 36;
+            this.labelDDR2clockMHz.Text = "MHz";
+            // 
+            // labelDDR2clock
+            // 
+            this.labelDDR2clock.AutoSize = true;
+            this.labelDDR2clock.Location = new System.Drawing.Point(63, 57);
+            this.labelDDR2clock.Name = "labelDDR2clock";
+            this.labelDDR2clock.Size = new System.Drawing.Size(84, 13);
+            this.labelDDR2clock.TabIndex = 35;
+            this.labelDDR2clock.Text = "DDR Clock (2x):";
+            // 
+            // textBoxDDR2clock
+            // 
+            this.textBoxDDR2clock.Location = new System.Drawing.Point(150, 54);
+            this.textBoxDDR2clock.Name = "textBoxDDR2clock";
+            this.textBoxDDR2clock.ReadOnly = true;
+            this.textBoxDDR2clock.Size = new System.Drawing.Size(40, 20);
+            this.textBoxDDR2clock.TabIndex = 34;
+            this.textBoxDDR2clock.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            // 
+            // tabPageLPSC
+            // 
+            this.tabPageLPSC.Controls.Add(this.labelLpsc1);
+            this.tabPageLPSC.Controls.Add(this.labelLpsc0);
+            this.tabPageLPSC.Controls.Add(this.textBoxLps1SyncRst);
+            this.tabPageLPSC.Controls.Add(this.textBoxLps1Disable);
+            this.tabPageLPSC.Controls.Add(this.textBoxLps1Enable);
+            this.tabPageLPSC.Controls.Add(this.textBoxLps0SyncRst);
+            this.tabPageLPSC.Controls.Add(this.textBoxLps0Disable);
+            this.tabPageLPSC.Controls.Add(this.textBoxLps0Enable);
+            this.tabPageLPSC.Controls.Add(this.labelLpsc0SyncRst);
+            this.tabPageLPSC.Controls.Add(this.labelLpsc0Disable);
+            this.tabPageLPSC.Controls.Add(this.labelLpsc0enable);
+            this.tabPageLPSC.Location = new System.Drawing.Point(4, 22);
+            this.tabPageLPSC.Name = "tabPageLPSC";
+            this.tabPageLPSC.Size = new System.Drawing.Size(474, 209);
+            this.tabPageLPSC.TabIndex = 6;
+            this.tabPageLPSC.Text = "PSC";
+            this.tabPageLPSC.UseVisualStyleBackColor = true;
+            // 
+            // labelLpsc1
+            // 
+            this.labelLpsc1.AutoSize = true;
+            this.labelLpsc1.Location = new System.Drawing.Point(289, 60);
+            this.labelLpsc1.Name = "labelLpsc1";
+            this.labelLpsc1.Size = new System.Drawing.Size(34, 13);
+            this.labelLpsc1.TabIndex = 16;
+            this.labelLpsc1.Text = "PSC1";
+            // 
+            // labelLpsc0
+            // 
+            this.labelLpsc0.AutoSize = true;
+            this.labelLpsc0.Location = new System.Drawing.Point(163, 60);
+            this.labelLpsc0.Name = "labelLpsc0";
+            this.labelLpsc0.Size = new System.Drawing.Size(34, 13);
+            this.labelLpsc0.TabIndex = 15;
+            this.labelLpsc0.Text = "PSC0";
+            // 
+            // textBoxLps1SyncRst
+            // 
+            this.textBoxLps1SyncRst.Location = new System.Drawing.Point(292, 128);
+            this.textBoxLps1SyncRst.Name = "textBoxLps1SyncRst";
+            this.textBoxLps1SyncRst.Size = new System.Drawing.Size(106, 20);
+            this.textBoxLps1SyncRst.TabIndex = 5;
+            this.textBoxLps1SyncRst.TextChanged += new System.EventHandler(this.textBoxLps1SyncRst_TextChanged);
+            // 
+            // textBoxLps1Disable
+            // 
+            this.textBoxLps1Disable.Location = new System.Drawing.Point(292, 102);
+            this.textBoxLps1Disable.Name = "textBoxLps1Disable";
+            this.textBoxLps1Disable.Size = new System.Drawing.Size(106, 20);
+            this.textBoxLps1Disable.TabIndex = 3;
+            this.textBoxLps1Disable.TextChanged += new System.EventHandler(this.textBoxLps1Disable_TextChanged);
+            // 
+            // textBoxLps1Enable
+            // 
+            this.textBoxLps1Enable.Location = new System.Drawing.Point(292, 76);
+            this.textBoxLps1Enable.Name = "textBoxLps1Enable";
+            this.textBoxLps1Enable.Size = new System.Drawing.Size(106, 20);
+            this.textBoxLps1Enable.TabIndex = 1;
+            this.textBoxLps1Enable.TextChanged += new System.EventHandler(this.textBoxLps1Enable_TextChanged);
+            // 
+            // textBoxLps0SyncRst
+            // 
+            this.textBoxLps0SyncRst.Location = new System.Drawing.Point(166, 128);
+            this.textBoxLps0SyncRst.Name = "textBoxLps0SyncRst";
+            this.textBoxLps0SyncRst.Size = new System.Drawing.Size(106, 20);
+            this.textBoxLps0SyncRst.TabIndex = 4;
+            this.textBoxLps0SyncRst.TextChanged += new System.EventHandler(this.textBoxLps0SyncRst_TextChanged);
+            // 
+            // textBoxLps0Disable
+            // 
+            this.textBoxLps0Disable.Location = new System.Drawing.Point(166, 102);
+            this.textBoxLps0Disable.Name = "textBoxLps0Disable";
+            this.textBoxLps0Disable.Size = new System.Drawing.Size(106, 20);
+            this.textBoxLps0Disable.TabIndex = 2;
+            this.textBoxLps0Disable.TextChanged += new System.EventHandler(this.textBoxLps0Disable_TextChanged);
+            // 
+            // textBoxLps0Enable
+            // 
+            this.textBoxLps0Enable.Location = new System.Drawing.Point(166, 76);
+            this.textBoxLps0Enable.Name = "textBoxLps0Enable";
+            this.textBoxLps0Enable.Size = new System.Drawing.Size(106, 20);
+            this.textBoxLps0Enable.TabIndex = 0;
+            this.textBoxLps0Enable.TextChanged += new System.EventHandler(this.textBoxLps0Enable_TextChanged);
+            // 
+            // labelLpsc0SyncRst
+            // 
+            this.labelLpsc0SyncRst.AutoSize = true;
+            this.labelLpsc0SyncRst.Location = new System.Drawing.Point(77, 131);
+            this.labelLpsc0SyncRst.Name = "labelLpsc0SyncRst";
+            this.labelLpsc0SyncRst.Size = new System.Drawing.Size(83, 13);
+            this.labelLpsc0SyncRst.TabIndex = 8;
+            this.labelLpsc0SyncRst.Text = "Sync Rst LPSC:";
+            // 
+            // labelLpsc0Disable
+            // 
+            this.labelLpsc0Disable.AutoSize = true;
+            this.labelLpsc0Disable.Location = new System.Drawing.Point(77, 105);
+            this.labelLpsc0Disable.Name = "labelLpsc0Disable";
+            this.labelLpsc0Disable.Size = new System.Drawing.Size(75, 13);
+            this.labelLpsc0Disable.TabIndex = 7;
+            this.labelLpsc0Disable.Text = "Disable LPSC:";
+            // 
+            // labelLpsc0enable
+            // 
+            this.labelLpsc0enable.AutoSize = true;
+            this.labelLpsc0enable.Location = new System.Drawing.Point(77, 79);
+            this.labelLpsc0enable.Name = "labelLpsc0enable";
+            this.labelLpsc0enable.Size = new System.Drawing.Size(73, 13);
+            this.labelLpsc0enable.TabIndex = 6;
+            this.labelLpsc0enable.Text = "Enable LPSC:";
+            // 
+            // tabPagePinmux
+            // 
+            this.tabPagePinmux.AutoScroll = true;
+            this.tabPagePinmux.Controls.Add(this.textBoxPinmuxVal19);
+            this.tabPagePinmux.Controls.Add(this.labelPinmuxReg20);
+            this.tabPagePinmux.Controls.Add(this.numericUpDownPinmux19);
+            this.tabPagePinmux.Controls.Add(this.textBoxPinmuxVal18);
+            this.tabPagePinmux.Controls.Add(this.labelPinmuxReg19);
+            this.tabPagePinmux.Controls.Add(this.numericUpDownPinmux18);
+            this.tabPagePinmux.Controls.Add(this.textBoxPinmuxVal17);
+            this.tabPagePinmux.Controls.Add(this.labelPinmuxReg18);
+            this.tabPagePinmux.Controls.Add(this.numericUpDownPinmux17);
+            this.tabPagePinmux.Controls.Add(this.textBoxPinmuxVal16);
+            this.tabPagePinmux.Controls.Add(this.labelPinmuxReg17);
+            this.tabPagePinmux.Controls.Add(this.numericUpDownPinmux16);
+            this.tabPagePinmux.Controls.Add(this.textBoxPinmuxVal15);
+            this.tabPagePinmux.Controls.Add(this.labelPinmuxReg16);
+            this.tabPagePinmux.Controls.Add(this.numericUpDownPinmux15);
+            this.tabPagePinmux.Controls.Add(this.textBoxPinmuxVal14);
+            this.tabPagePinmux.Controls.Add(this.labelPinmuxReg15);
+            this.tabPagePinmux.Controls.Add(this.numericUpDownPinmux14);
+            this.tabPagePinmux.Controls.Add(this.textBoxPinmuxVal13);
+            this.tabPagePinmux.Controls.Add(this.labelPinmuxReg14);
+            this.tabPagePinmux.Controls.Add(this.numericUpDownPinmux13);
+            this.tabPagePinmux.Controls.Add(this.textBoxPinmuxVal12);
+            this.tabPagePinmux.Controls.Add(this.labelPinmuxReg13);
+            this.tabPagePinmux.Controls.Add(this.numericUpDownPinmux12);
+            this.tabPagePinmux.Controls.Add(this.textBoxPinmuxVal11);
+            this.tabPagePinmux.Controls.Add(this.labelPinmuxReg12);
+            this.tabPagePinmux.Controls.Add(this.numericUpDownPinmux11);
+            this.tabPagePinmux.Controls.Add(this.textBoxPinmuxVal10);
+            this.tabPagePinmux.Controls.Add(this.labelPinmuxReg11);
+            this.tabPagePinmux.Controls.Add(this.numericUpDownPinmux10);
+            this.tabPagePinmux.Controls.Add(this.textBoxPinmuxVal9);
+            this.tabPagePinmux.Controls.Add(this.labelPinmuxReg10);
+            this.tabPagePinmux.Controls.Add(this.numericUpDownPinmux9);
+            this.tabPagePinmux.Controls.Add(this.textBoxPinmuxVal8);
+            this.tabPagePinmux.Controls.Add(this.labelPinmuxReg9);
+            this.tabPagePinmux.Controls.Add(this.numericUpDownPinmux8);
+            this.tabPagePinmux.Controls.Add(this.textBoxPinmuxVal7);
+            this.tabPagePinmux.Controls.Add(this.labelPinmuxReg8);
+            this.tabPagePinmux.Controls.Add(this.numericUpDownPinmux7);
+            this.tabPagePinmux.Controls.Add(this.textBoxPinmuxVal6);
+            this.tabPagePinmux.Controls.Add(this.labelPinmuxReg7);
+            this.tabPagePinmux.Controls.Add(this.numericUpDownPinmux6);
+            this.tabPagePinmux.Controls.Add(this.textBoxPinmuxVal5);
+            this.tabPagePinmux.Controls.Add(this.labelPinmuxReg6);
+            this.tabPagePinmux.Controls.Add(this.numericUpDownPinmux5);
+            this.tabPagePinmux.Controls.Add(this.textBoxPinmuxVal4);
+            this.tabPagePinmux.Controls.Add(this.labelPinmuxReg5);
+            this.tabPagePinmux.Controls.Add(this.numericUpDownPinmux4);
+            this.tabPagePinmux.Controls.Add(this.textBoxPinmuxVal3);
+            this.tabPagePinmux.Controls.Add(this.labelPinmuxReg4);
+            this.tabPagePinmux.Controls.Add(this.numericUpDownPinmux3);
+            this.tabPagePinmux.Controls.Add(this.textBoxPinmuxVal2);
+            this.tabPagePinmux.Controls.Add(this.labelPinmuxReg3);
+            this.tabPagePinmux.Controls.Add(this.numericUpDownPinmux2);
+            this.tabPagePinmux.Controls.Add(this.textBoxPinmuxVal1);
+            this.tabPagePinmux.Controls.Add(this.labelPinmuxReg2);
+            this.tabPagePinmux.Controls.Add(this.numericUpDownPinmux1);
+            this.tabPagePinmux.Controls.Add(this.textBoxPinmuxVal0);
+            this.tabPagePinmux.Controls.Add(this.labelPinmuxReg1);
+            this.tabPagePinmux.Controls.Add(this.numericUpDownPinmux0);
+            this.tabPagePinmux.Location = new System.Drawing.Point(4, 22);
+            this.tabPagePinmux.Name = "tabPagePinmux";
+            this.tabPagePinmux.Size = new System.Drawing.Size(474, 209);
+            this.tabPagePinmux.TabIndex = 7;
+            this.tabPagePinmux.Text = "Pinmux";
+            this.tabPagePinmux.UseVisualStyleBackColor = true;
+            // 
+            // textBoxPinmuxVal19
+            // 
+            this.textBoxPinmuxVal19.Enabled = false;
+            this.textBoxPinmuxVal19.Location = new System.Drawing.Point(271, 497);
+            this.textBoxPinmuxVal19.MaxLength = 10;
+            this.textBoxPinmuxVal19.Name = "textBoxPinmuxVal19";
+            this.textBoxPinmuxVal19.Size = new System.Drawing.Size(80, 20);
+            this.textBoxPinmuxVal19.TabIndex = 39;
+            this.textBoxPinmuxVal19.Text = "0x00000000";
+            this.textBoxPinmuxVal19.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPinmuxVal19.TextChanged += new System.EventHandler(this.textBoxPinmuxVal_TextChanged);
+            // 
+            // labelPinmuxReg20
+            // 
+            this.labelPinmuxReg20.AutoSize = true;
+            this.labelPinmuxReg20.Location = new System.Drawing.Point(106, 499);
+            this.labelPinmuxReg20.Name = "labelPinmuxReg20";
+            this.labelPinmuxReg20.Size = new System.Drawing.Size(113, 13);
+            this.labelPinmuxReg20.TabIndex = 103;
+            this.labelPinmuxReg20.Text = "Pinmux Register (0-19)";
+            // 
+            // numericUpDownPinmux19
+            // 
+            this.numericUpDownPinmux19.Location = new System.Drawing.Point(225, 497);
+            this.numericUpDownPinmux19.Maximum = new decimal(new int[] {
+            19,
+            0,
+            0,
+            0});
+            this.numericUpDownPinmux19.Minimum = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux19.Name = "numericUpDownPinmux19";
+            this.numericUpDownPinmux19.Size = new System.Drawing.Size(40, 20);
+            this.numericUpDownPinmux19.TabIndex = 38;
+            this.numericUpDownPinmux19.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.numericUpDownPinmux19.Value = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux19.ValueChanged += new System.EventHandler(this.numericUpDownPinmux_ValueChanged);
+            // 
+            // textBoxPinmuxVal18
+            // 
+            this.textBoxPinmuxVal18.Enabled = false;
+            this.textBoxPinmuxVal18.Location = new System.Drawing.Point(271, 471);
+            this.textBoxPinmuxVal18.MaxLength = 10;
+            this.textBoxPinmuxVal18.Name = "textBoxPinmuxVal18";
+            this.textBoxPinmuxVal18.Size = new System.Drawing.Size(80, 20);
+            this.textBoxPinmuxVal18.TabIndex = 37;
+            this.textBoxPinmuxVal18.Text = "0x00000000";
+            this.textBoxPinmuxVal18.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPinmuxVal18.TextChanged += new System.EventHandler(this.textBoxPinmuxVal_TextChanged);
+            // 
+            // labelPinmuxReg19
+            // 
+            this.labelPinmuxReg19.AutoSize = true;
+            this.labelPinmuxReg19.Location = new System.Drawing.Point(106, 473);
+            this.labelPinmuxReg19.Name = "labelPinmuxReg19";
+            this.labelPinmuxReg19.Size = new System.Drawing.Size(113, 13);
+            this.labelPinmuxReg19.TabIndex = 100;
+            this.labelPinmuxReg19.Text = "Pinmux Register (0-19)";
+            // 
+            // numericUpDownPinmux18
+            // 
+            this.numericUpDownPinmux18.Location = new System.Drawing.Point(225, 471);
+            this.numericUpDownPinmux18.Maximum = new decimal(new int[] {
+            19,
+            0,
+            0,
+            0});
+            this.numericUpDownPinmux18.Minimum = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux18.Name = "numericUpDownPinmux18";
+            this.numericUpDownPinmux18.Size = new System.Drawing.Size(40, 20);
+            this.numericUpDownPinmux18.TabIndex = 36;
+            this.numericUpDownPinmux18.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.numericUpDownPinmux18.Value = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux18.ValueChanged += new System.EventHandler(this.numericUpDownPinmux_ValueChanged);
+            // 
+            // textBoxPinmuxVal17
+            // 
+            this.textBoxPinmuxVal17.Enabled = false;
+            this.textBoxPinmuxVal17.Location = new System.Drawing.Point(271, 445);
+            this.textBoxPinmuxVal17.MaxLength = 10;
+            this.textBoxPinmuxVal17.Name = "textBoxPinmuxVal17";
+            this.textBoxPinmuxVal17.Size = new System.Drawing.Size(80, 20);
+            this.textBoxPinmuxVal17.TabIndex = 35;
+            this.textBoxPinmuxVal17.Text = "0x00000000";
+            this.textBoxPinmuxVal17.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPinmuxVal17.TextChanged += new System.EventHandler(this.textBoxPinmuxVal_TextChanged);
+            // 
+            // labelPinmuxReg18
+            // 
+            this.labelPinmuxReg18.AutoSize = true;
+            this.labelPinmuxReg18.Location = new System.Drawing.Point(106, 447);
+            this.labelPinmuxReg18.Name = "labelPinmuxReg18";
+            this.labelPinmuxReg18.Size = new System.Drawing.Size(113, 13);
+            this.labelPinmuxReg18.TabIndex = 97;
+            this.labelPinmuxReg18.Text = "Pinmux Register (0-19)";
+            // 
+            // numericUpDownPinmux17
+            // 
+            this.numericUpDownPinmux17.Location = new System.Drawing.Point(225, 445);
+            this.numericUpDownPinmux17.Maximum = new decimal(new int[] {
+            19,
+            0,
+            0,
+            0});
+            this.numericUpDownPinmux17.Minimum = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux17.Name = "numericUpDownPinmux17";
+            this.numericUpDownPinmux17.Size = new System.Drawing.Size(40, 20);
+            this.numericUpDownPinmux17.TabIndex = 34;
+            this.numericUpDownPinmux17.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.numericUpDownPinmux17.Value = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux17.ValueChanged += new System.EventHandler(this.numericUpDownPinmux_ValueChanged);
+            // 
+            // textBoxPinmuxVal16
+            // 
+            this.textBoxPinmuxVal16.Enabled = false;
+            this.textBoxPinmuxVal16.Location = new System.Drawing.Point(271, 419);
+            this.textBoxPinmuxVal16.MaxLength = 10;
+            this.textBoxPinmuxVal16.Name = "textBoxPinmuxVal16";
+            this.textBoxPinmuxVal16.Size = new System.Drawing.Size(80, 20);
+            this.textBoxPinmuxVal16.TabIndex = 33;
+            this.textBoxPinmuxVal16.Text = "0x00000000";
+            this.textBoxPinmuxVal16.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPinmuxVal16.TextChanged += new System.EventHandler(this.textBoxPinmuxVal_TextChanged);
+            // 
+            // labelPinmuxReg17
+            // 
+            this.labelPinmuxReg17.AutoSize = true;
+            this.labelPinmuxReg17.Location = new System.Drawing.Point(106, 421);
+            this.labelPinmuxReg17.Name = "labelPinmuxReg17";
+            this.labelPinmuxReg17.Size = new System.Drawing.Size(113, 13);
+            this.labelPinmuxReg17.TabIndex = 94;
+            this.labelPinmuxReg17.Text = "Pinmux Register (0-19)";
+            // 
+            // numericUpDownPinmux16
+            // 
+            this.numericUpDownPinmux16.Location = new System.Drawing.Point(225, 419);
+            this.numericUpDownPinmux16.Maximum = new decimal(new int[] {
+            19,
+            0,
+            0,
+            0});
+            this.numericUpDownPinmux16.Minimum = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux16.Name = "numericUpDownPinmux16";
+            this.numericUpDownPinmux16.Size = new System.Drawing.Size(40, 20);
+            this.numericUpDownPinmux16.TabIndex = 32;
+            this.numericUpDownPinmux16.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.numericUpDownPinmux16.Value = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux16.ValueChanged += new System.EventHandler(this.numericUpDownPinmux_ValueChanged);
+            // 
+            // textBoxPinmuxVal15
+            // 
+            this.textBoxPinmuxVal15.Enabled = false;
+            this.textBoxPinmuxVal15.Location = new System.Drawing.Point(271, 393);
+            this.textBoxPinmuxVal15.MaxLength = 10;
+            this.textBoxPinmuxVal15.Name = "textBoxPinmuxVal15";
+            this.textBoxPinmuxVal15.Size = new System.Drawing.Size(80, 20);
+            this.textBoxPinmuxVal15.TabIndex = 31;
+            this.textBoxPinmuxVal15.Text = "0x00000000";
+            this.textBoxPinmuxVal15.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPinmuxVal15.TextChanged += new System.EventHandler(this.textBoxPinmuxVal_TextChanged);
+            // 
+            // labelPinmuxReg16
+            // 
+            this.labelPinmuxReg16.AutoSize = true;
+            this.labelPinmuxReg16.Location = new System.Drawing.Point(106, 395);
+            this.labelPinmuxReg16.Name = "labelPinmuxReg16";
+            this.labelPinmuxReg16.Size = new System.Drawing.Size(113, 13);
+            this.labelPinmuxReg16.TabIndex = 91;
+            this.labelPinmuxReg16.Text = "Pinmux Register (0-19)";
+            // 
+            // numericUpDownPinmux15
+            // 
+            this.numericUpDownPinmux15.Location = new System.Drawing.Point(225, 393);
+            this.numericUpDownPinmux15.Maximum = new decimal(new int[] {
+            19,
+            0,
+            0,
+            0});
+            this.numericUpDownPinmux15.Minimum = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux15.Name = "numericUpDownPinmux15";
+            this.numericUpDownPinmux15.Size = new System.Drawing.Size(40, 20);
+            this.numericUpDownPinmux15.TabIndex = 30;
+            this.numericUpDownPinmux15.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.numericUpDownPinmux15.Value = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux15.ValueChanged += new System.EventHandler(this.numericUpDownPinmux_ValueChanged);
+            // 
+            // textBoxPinmuxVal14
+            // 
+            this.textBoxPinmuxVal14.Enabled = false;
+            this.textBoxPinmuxVal14.Location = new System.Drawing.Point(271, 367);
+            this.textBoxPinmuxVal14.MaxLength = 10;
+            this.textBoxPinmuxVal14.Name = "textBoxPinmuxVal14";
+            this.textBoxPinmuxVal14.Size = new System.Drawing.Size(80, 20);
+            this.textBoxPinmuxVal14.TabIndex = 29;
+            this.textBoxPinmuxVal14.Text = "0x00000000";
+            this.textBoxPinmuxVal14.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPinmuxVal14.TextChanged += new System.EventHandler(this.textBoxPinmuxVal_TextChanged);
+            // 
+            // labelPinmuxReg15
+            // 
+            this.labelPinmuxReg15.AutoSize = true;
+            this.labelPinmuxReg15.Location = new System.Drawing.Point(106, 369);
+            this.labelPinmuxReg15.Name = "labelPinmuxReg15";
+            this.labelPinmuxReg15.Size = new System.Drawing.Size(113, 13);
+            this.labelPinmuxReg15.TabIndex = 88;
+            this.labelPinmuxReg15.Text = "Pinmux Register (0-19)";
+            // 
+            // numericUpDownPinmux14
+            // 
+            this.numericUpDownPinmux14.Location = new System.Drawing.Point(225, 367);
+            this.numericUpDownPinmux14.Maximum = new decimal(new int[] {
+            19,
+            0,
+            0,
+            0});
+            this.numericUpDownPinmux14.Minimum = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux14.Name = "numericUpDownPinmux14";
+            this.numericUpDownPinmux14.Size = new System.Drawing.Size(40, 20);
+            this.numericUpDownPinmux14.TabIndex = 28;
+            this.numericUpDownPinmux14.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.numericUpDownPinmux14.Value = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux14.ValueChanged += new System.EventHandler(this.numericUpDownPinmux_ValueChanged);
+            // 
+            // textBoxPinmuxVal13
+            // 
+            this.textBoxPinmuxVal13.Enabled = false;
+            this.textBoxPinmuxVal13.Location = new System.Drawing.Point(271, 341);
+            this.textBoxPinmuxVal13.MaxLength = 10;
+            this.textBoxPinmuxVal13.Name = "textBoxPinmuxVal13";
+            this.textBoxPinmuxVal13.Size = new System.Drawing.Size(80, 20);
+            this.textBoxPinmuxVal13.TabIndex = 27;
+            this.textBoxPinmuxVal13.Text = "0x00000000";
+            this.textBoxPinmuxVal13.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPinmuxVal13.TextChanged += new System.EventHandler(this.textBoxPinmuxVal_TextChanged);
+            // 
+            // labelPinmuxReg14
+            // 
+            this.labelPinmuxReg14.AutoSize = true;
+            this.labelPinmuxReg14.Location = new System.Drawing.Point(106, 343);
+            this.labelPinmuxReg14.Name = "labelPinmuxReg14";
+            this.labelPinmuxReg14.Size = new System.Drawing.Size(113, 13);
+            this.labelPinmuxReg14.TabIndex = 85;
+            this.labelPinmuxReg14.Text = "Pinmux Register (0-19)";
+            // 
+            // numericUpDownPinmux13
+            // 
+            this.numericUpDownPinmux13.Location = new System.Drawing.Point(225, 341);
+            this.numericUpDownPinmux13.Maximum = new decimal(new int[] {
+            19,
+            0,
+            0,
+            0});
+            this.numericUpDownPinmux13.Minimum = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux13.Name = "numericUpDownPinmux13";
+            this.numericUpDownPinmux13.Size = new System.Drawing.Size(40, 20);
+            this.numericUpDownPinmux13.TabIndex = 26;
+            this.numericUpDownPinmux13.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.numericUpDownPinmux13.Value = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux13.ValueChanged += new System.EventHandler(this.numericUpDownPinmux_ValueChanged);
+            // 
+            // textBoxPinmuxVal12
+            // 
+            this.textBoxPinmuxVal12.Enabled = false;
+            this.textBoxPinmuxVal12.Location = new System.Drawing.Point(271, 315);
+            this.textBoxPinmuxVal12.MaxLength = 10;
+            this.textBoxPinmuxVal12.Name = "textBoxPinmuxVal12";
+            this.textBoxPinmuxVal12.Size = new System.Drawing.Size(80, 20);
+            this.textBoxPinmuxVal12.TabIndex = 25;
+            this.textBoxPinmuxVal12.Text = "0x00000000";
+            this.textBoxPinmuxVal12.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPinmuxVal12.TextChanged += new System.EventHandler(this.textBoxPinmuxVal_TextChanged);
+            // 
+            // labelPinmuxReg13
+            // 
+            this.labelPinmuxReg13.AutoSize = true;
+            this.labelPinmuxReg13.Location = new System.Drawing.Point(106, 317);
+            this.labelPinmuxReg13.Name = "labelPinmuxReg13";
+            this.labelPinmuxReg13.Size = new System.Drawing.Size(113, 13);
+            this.labelPinmuxReg13.TabIndex = 82;
+            this.labelPinmuxReg13.Text = "Pinmux Register (0-19)";
+            // 
+            // numericUpDownPinmux12
+            // 
+            this.numericUpDownPinmux12.Location = new System.Drawing.Point(225, 315);
+            this.numericUpDownPinmux12.Maximum = new decimal(new int[] {
+            19,
+            0,
+            0,
+            0});
+            this.numericUpDownPinmux12.Minimum = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux12.Name = "numericUpDownPinmux12";
+            this.numericUpDownPinmux12.Size = new System.Drawing.Size(40, 20);
+            this.numericUpDownPinmux12.TabIndex = 24;
+            this.numericUpDownPinmux12.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.numericUpDownPinmux12.Value = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux12.ValueChanged += new System.EventHandler(this.numericUpDownPinmux_ValueChanged);
+            // 
+            // textBoxPinmuxVal11
+            // 
+            this.textBoxPinmuxVal11.Enabled = false;
+            this.textBoxPinmuxVal11.Location = new System.Drawing.Point(271, 289);
+            this.textBoxPinmuxVal11.MaxLength = 10;
+            this.textBoxPinmuxVal11.Name = "textBoxPinmuxVal11";
+            this.textBoxPinmuxVal11.Size = new System.Drawing.Size(80, 20);
+            this.textBoxPinmuxVal11.TabIndex = 23;
+            this.textBoxPinmuxVal11.Text = "0x00000000";
+            this.textBoxPinmuxVal11.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPinmuxVal11.TextChanged += new System.EventHandler(this.textBoxPinmuxVal_TextChanged);
+            // 
+            // labelPinmuxReg12
+            // 
+            this.labelPinmuxReg12.AutoSize = true;
+            this.labelPinmuxReg12.Location = new System.Drawing.Point(106, 291);
+            this.labelPinmuxReg12.Name = "labelPinmuxReg12";
+            this.labelPinmuxReg12.Size = new System.Drawing.Size(113, 13);
+            this.labelPinmuxReg12.TabIndex = 79;
+            this.labelPinmuxReg12.Text = "Pinmux Register (0-19)";
+            // 
+            // numericUpDownPinmux11
+            // 
+            this.numericUpDownPinmux11.Location = new System.Drawing.Point(225, 289);
+            this.numericUpDownPinmux11.Maximum = new decimal(new int[] {
+            19,
+            0,
+            0,
+            0});
+            this.numericUpDownPinmux11.Minimum = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux11.Name = "numericUpDownPinmux11";
+            this.numericUpDownPinmux11.Size = new System.Drawing.Size(40, 20);
+            this.numericUpDownPinmux11.TabIndex = 22;
+            this.numericUpDownPinmux11.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.numericUpDownPinmux11.Value = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux11.ValueChanged += new System.EventHandler(this.numericUpDownPinmux_ValueChanged);
+            // 
+            // textBoxPinmuxVal10
+            // 
+            this.textBoxPinmuxVal10.Enabled = false;
+            this.textBoxPinmuxVal10.Location = new System.Drawing.Point(271, 263);
+            this.textBoxPinmuxVal10.MaxLength = 10;
+            this.textBoxPinmuxVal10.Name = "textBoxPinmuxVal10";
+            this.textBoxPinmuxVal10.Size = new System.Drawing.Size(80, 20);
+            this.textBoxPinmuxVal10.TabIndex = 21;
+            this.textBoxPinmuxVal10.Text = "0x00000000";
+            this.textBoxPinmuxVal10.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPinmuxVal10.TextChanged += new System.EventHandler(this.textBoxPinmuxVal_TextChanged);
+            // 
+            // labelPinmuxReg11
+            // 
+            this.labelPinmuxReg11.AutoSize = true;
+            this.labelPinmuxReg11.Location = new System.Drawing.Point(106, 265);
+            this.labelPinmuxReg11.Name = "labelPinmuxReg11";
+            this.labelPinmuxReg11.Size = new System.Drawing.Size(113, 13);
+            this.labelPinmuxReg11.TabIndex = 76;
+            this.labelPinmuxReg11.Text = "Pinmux Register (0-19)";
+            // 
+            // numericUpDownPinmux10
+            // 
+            this.numericUpDownPinmux10.Location = new System.Drawing.Point(225, 263);
+            this.numericUpDownPinmux10.Maximum = new decimal(new int[] {
+            19,
+            0,
+            0,
+            0});
+            this.numericUpDownPinmux10.Minimum = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux10.Name = "numericUpDownPinmux10";
+            this.numericUpDownPinmux10.Size = new System.Drawing.Size(40, 20);
+            this.numericUpDownPinmux10.TabIndex = 20;
+            this.numericUpDownPinmux10.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.numericUpDownPinmux10.Value = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux10.ValueChanged += new System.EventHandler(this.numericUpDownPinmux_ValueChanged);
+            // 
+            // textBoxPinmuxVal9
+            // 
+            this.textBoxPinmuxVal9.Enabled = false;
+            this.textBoxPinmuxVal9.Location = new System.Drawing.Point(271, 237);
+            this.textBoxPinmuxVal9.MaxLength = 10;
+            this.textBoxPinmuxVal9.Name = "textBoxPinmuxVal9";
+            this.textBoxPinmuxVal9.Size = new System.Drawing.Size(80, 20);
+            this.textBoxPinmuxVal9.TabIndex = 19;
+            this.textBoxPinmuxVal9.Text = "0x00000000";
+            this.textBoxPinmuxVal9.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPinmuxVal9.TextChanged += new System.EventHandler(this.textBoxPinmuxVal_TextChanged);
+            // 
+            // labelPinmuxReg10
+            // 
+            this.labelPinmuxReg10.AutoSize = true;
+            this.labelPinmuxReg10.Location = new System.Drawing.Point(106, 239);
+            this.labelPinmuxReg10.Name = "labelPinmuxReg10";
+            this.labelPinmuxReg10.Size = new System.Drawing.Size(113, 13);
+            this.labelPinmuxReg10.TabIndex = 73;
+            this.labelPinmuxReg10.Text = "Pinmux Register (0-19)";
+            // 
+            // numericUpDownPinmux9
+            // 
+            this.numericUpDownPinmux9.Location = new System.Drawing.Point(225, 237);
+            this.numericUpDownPinmux9.Maximum = new decimal(new int[] {
+            19,
+            0,
+            0,
+            0});
+            this.numericUpDownPinmux9.Minimum = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux9.Name = "numericUpDownPinmux9";
+            this.numericUpDownPinmux9.Size = new System.Drawing.Size(40, 20);
+            this.numericUpDownPinmux9.TabIndex = 18;
+            this.numericUpDownPinmux9.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.numericUpDownPinmux9.Value = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux9.ValueChanged += new System.EventHandler(this.numericUpDownPinmux_ValueChanged);
+            // 
+            // textBoxPinmuxVal8
+            // 
+            this.textBoxPinmuxVal8.Enabled = false;
+            this.textBoxPinmuxVal8.Location = new System.Drawing.Point(271, 211);
+            this.textBoxPinmuxVal8.MaxLength = 10;
+            this.textBoxPinmuxVal8.Name = "textBoxPinmuxVal8";
+            this.textBoxPinmuxVal8.Size = new System.Drawing.Size(80, 20);
+            this.textBoxPinmuxVal8.TabIndex = 17;
+            this.textBoxPinmuxVal8.Text = "0x00000000";
+            this.textBoxPinmuxVal8.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPinmuxVal8.TextChanged += new System.EventHandler(this.textBoxPinmuxVal_TextChanged);
+            // 
+            // labelPinmuxReg9
+            // 
+            this.labelPinmuxReg9.AutoSize = true;
+            this.labelPinmuxReg9.Location = new System.Drawing.Point(106, 213);
+            this.labelPinmuxReg9.Name = "labelPinmuxReg9";
+            this.labelPinmuxReg9.Size = new System.Drawing.Size(113, 13);
+            this.labelPinmuxReg9.TabIndex = 70;
+            this.labelPinmuxReg9.Text = "Pinmux Register (0-19)";
+            // 
+            // numericUpDownPinmux8
+            // 
+            this.numericUpDownPinmux8.Location = new System.Drawing.Point(225, 211);
+            this.numericUpDownPinmux8.Maximum = new decimal(new int[] {
+            19,
+            0,
+            0,
+            0});
+            this.numericUpDownPinmux8.Minimum = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux8.Name = "numericUpDownPinmux8";
+            this.numericUpDownPinmux8.Size = new System.Drawing.Size(40, 20);
+            this.numericUpDownPinmux8.TabIndex = 16;
+            this.numericUpDownPinmux8.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.numericUpDownPinmux8.Value = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux8.ValueChanged += new System.EventHandler(this.numericUpDownPinmux_ValueChanged);
+            // 
+            // textBoxPinmuxVal7
+            // 
+            this.textBoxPinmuxVal7.Enabled = false;
+            this.textBoxPinmuxVal7.Location = new System.Drawing.Point(271, 185);
+            this.textBoxPinmuxVal7.MaxLength = 10;
+            this.textBoxPinmuxVal7.Name = "textBoxPinmuxVal7";
+            this.textBoxPinmuxVal7.Size = new System.Drawing.Size(80, 20);
+            this.textBoxPinmuxVal7.TabIndex = 15;
+            this.textBoxPinmuxVal7.Text = "0x00000000";
+            this.textBoxPinmuxVal7.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPinmuxVal7.TextChanged += new System.EventHandler(this.textBoxPinmuxVal_TextChanged);
+            // 
+            // labelPinmuxReg8
+            // 
+            this.labelPinmuxReg8.AutoSize = true;
+            this.labelPinmuxReg8.Location = new System.Drawing.Point(106, 187);
+            this.labelPinmuxReg8.Name = "labelPinmuxReg8";
+            this.labelPinmuxReg8.Size = new System.Drawing.Size(113, 13);
+            this.labelPinmuxReg8.TabIndex = 67;
+            this.labelPinmuxReg8.Text = "Pinmux Register (0-19)";
+            // 
+            // numericUpDownPinmux7
+            // 
+            this.numericUpDownPinmux7.Location = new System.Drawing.Point(225, 185);
+            this.numericUpDownPinmux7.Maximum = new decimal(new int[] {
+            19,
+            0,
+            0,
+            0});
+            this.numericUpDownPinmux7.Minimum = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux7.Name = "numericUpDownPinmux7";
+            this.numericUpDownPinmux7.Size = new System.Drawing.Size(40, 20);
+            this.numericUpDownPinmux7.TabIndex = 14;
+            this.numericUpDownPinmux7.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.numericUpDownPinmux7.Value = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux7.ValueChanged += new System.EventHandler(this.numericUpDownPinmux_ValueChanged);
+            // 
+            // textBoxPinmuxVal6
+            // 
+            this.textBoxPinmuxVal6.Enabled = false;
+            this.textBoxPinmuxVal6.Location = new System.Drawing.Point(271, 159);
+            this.textBoxPinmuxVal6.MaxLength = 10;
+            this.textBoxPinmuxVal6.Name = "textBoxPinmuxVal6";
+            this.textBoxPinmuxVal6.Size = new System.Drawing.Size(80, 20);
+            this.textBoxPinmuxVal6.TabIndex = 13;
+            this.textBoxPinmuxVal6.Text = "0x00000000";
+            this.textBoxPinmuxVal6.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPinmuxVal6.TextChanged += new System.EventHandler(this.textBoxPinmuxVal_TextChanged);
+            // 
+            // labelPinmuxReg7
+            // 
+            this.labelPinmuxReg7.AutoSize = true;
+            this.labelPinmuxReg7.Location = new System.Drawing.Point(106, 161);
+            this.labelPinmuxReg7.Name = "labelPinmuxReg7";
+            this.labelPinmuxReg7.Size = new System.Drawing.Size(113, 13);
+            this.labelPinmuxReg7.TabIndex = 64;
+            this.labelPinmuxReg7.Text = "Pinmux Register (0-19)";
+            // 
+            // numericUpDownPinmux6
+            // 
+            this.numericUpDownPinmux6.Location = new System.Drawing.Point(225, 159);
+            this.numericUpDownPinmux6.Maximum = new decimal(new int[] {
+            19,
+            0,
+            0,
+            0});
+            this.numericUpDownPinmux6.Minimum = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux6.Name = "numericUpDownPinmux6";
+            this.numericUpDownPinmux6.Size = new System.Drawing.Size(40, 20);
+            this.numericUpDownPinmux6.TabIndex = 12;
+            this.numericUpDownPinmux6.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.numericUpDownPinmux6.Value = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux6.ValueChanged += new System.EventHandler(this.numericUpDownPinmux_ValueChanged);
+            // 
+            // textBoxPinmuxVal5
+            // 
+            this.textBoxPinmuxVal5.Enabled = false;
+            this.textBoxPinmuxVal5.Location = new System.Drawing.Point(271, 133);
+            this.textBoxPinmuxVal5.MaxLength = 10;
+            this.textBoxPinmuxVal5.Name = "textBoxPinmuxVal5";
+            this.textBoxPinmuxVal5.Size = new System.Drawing.Size(80, 20);
+            this.textBoxPinmuxVal5.TabIndex = 11;
+            this.textBoxPinmuxVal5.Text = "0x00000000";
+            this.textBoxPinmuxVal5.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPinmuxVal5.TextChanged += new System.EventHandler(this.textBoxPinmuxVal_TextChanged);
+            // 
+            // labelPinmuxReg6
+            // 
+            this.labelPinmuxReg6.AutoSize = true;
+            this.labelPinmuxReg6.Location = new System.Drawing.Point(106, 135);
+            this.labelPinmuxReg6.Name = "labelPinmuxReg6";
+            this.labelPinmuxReg6.Size = new System.Drawing.Size(113, 13);
+            this.labelPinmuxReg6.TabIndex = 61;
+            this.labelPinmuxReg6.Text = "Pinmux Register (0-19)";
+            // 
+            // numericUpDownPinmux5
+            // 
+            this.numericUpDownPinmux5.Location = new System.Drawing.Point(225, 133);
+            this.numericUpDownPinmux5.Maximum = new decimal(new int[] {
+            19,
+            0,
+            0,
+            0});
+            this.numericUpDownPinmux5.Minimum = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux5.Name = "numericUpDownPinmux5";
+            this.numericUpDownPinmux5.Size = new System.Drawing.Size(40, 20);
+            this.numericUpDownPinmux5.TabIndex = 10;
+            this.numericUpDownPinmux5.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.numericUpDownPinmux5.Value = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux5.ValueChanged += new System.EventHandler(this.numericUpDownPinmux_ValueChanged);
+            // 
+            // textBoxPinmuxVal4
+            // 
+            this.textBoxPinmuxVal4.Enabled = false;
+            this.textBoxPinmuxVal4.Location = new System.Drawing.Point(271, 107);
+            this.textBoxPinmuxVal4.MaxLength = 10;
+            this.textBoxPinmuxVal4.Name = "textBoxPinmuxVal4";
+            this.textBoxPinmuxVal4.Size = new System.Drawing.Size(80, 20);
+            this.textBoxPinmuxVal4.TabIndex = 9;
+            this.textBoxPinmuxVal4.Text = "0x00000000";
+            this.textBoxPinmuxVal4.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPinmuxVal4.TextChanged += new System.EventHandler(this.textBoxPinmuxVal_TextChanged);
+            // 
+            // labelPinmuxReg5
+            // 
+            this.labelPinmuxReg5.AutoSize = true;
+            this.labelPinmuxReg5.Location = new System.Drawing.Point(106, 109);
+            this.labelPinmuxReg5.Name = "labelPinmuxReg5";
+            this.labelPinmuxReg5.Size = new System.Drawing.Size(113, 13);
+            this.labelPinmuxReg5.TabIndex = 58;
+            this.labelPinmuxReg5.Text = "Pinmux Register (0-19)";
+            // 
+            // numericUpDownPinmux4
+            // 
+            this.numericUpDownPinmux4.Location = new System.Drawing.Point(225, 107);
+            this.numericUpDownPinmux4.Maximum = new decimal(new int[] {
+            19,
+            0,
+            0,
+            0});
+            this.numericUpDownPinmux4.Minimum = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux4.Name = "numericUpDownPinmux4";
+            this.numericUpDownPinmux4.Size = new System.Drawing.Size(40, 20);
+            this.numericUpDownPinmux4.TabIndex = 8;
+            this.numericUpDownPinmux4.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.numericUpDownPinmux4.Value = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux4.ValueChanged += new System.EventHandler(this.numericUpDownPinmux_ValueChanged);
+            // 
+            // textBoxPinmuxVal3
+            // 
+            this.textBoxPinmuxVal3.Enabled = false;
+            this.textBoxPinmuxVal3.Location = new System.Drawing.Point(271, 81);
+            this.textBoxPinmuxVal3.MaxLength = 10;
+            this.textBoxPinmuxVal3.Name = "textBoxPinmuxVal3";
+            this.textBoxPinmuxVal3.Size = new System.Drawing.Size(80, 20);
+            this.textBoxPinmuxVal3.TabIndex = 7;
+            this.textBoxPinmuxVal3.Text = "0x00000000";
+            this.textBoxPinmuxVal3.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPinmuxVal3.TextChanged += new System.EventHandler(this.textBoxPinmuxVal_TextChanged);
+            // 
+            // labelPinmuxReg4
+            // 
+            this.labelPinmuxReg4.AutoSize = true;
+            this.labelPinmuxReg4.Location = new System.Drawing.Point(106, 83);
+            this.labelPinmuxReg4.Name = "labelPinmuxReg4";
+            this.labelPinmuxReg4.Size = new System.Drawing.Size(113, 13);
+            this.labelPinmuxReg4.TabIndex = 55;
+            this.labelPinmuxReg4.Text = "Pinmux Register (0-19)";
+            // 
+            // numericUpDownPinmux3
+            // 
+            this.numericUpDownPinmux3.Location = new System.Drawing.Point(225, 81);
+            this.numericUpDownPinmux3.Maximum = new decimal(new int[] {
+            19,
+            0,
+            0,
+            0});
+            this.numericUpDownPinmux3.Minimum = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux3.Name = "numericUpDownPinmux3";
+            this.numericUpDownPinmux3.Size = new System.Drawing.Size(40, 20);
+            this.numericUpDownPinmux3.TabIndex = 6;
+            this.numericUpDownPinmux3.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.numericUpDownPinmux3.Value = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux3.ValueChanged += new System.EventHandler(this.numericUpDownPinmux_ValueChanged);
+            // 
+            // textBoxPinmuxVal2
+            // 
+            this.textBoxPinmuxVal2.Enabled = false;
+            this.textBoxPinmuxVal2.Location = new System.Drawing.Point(271, 55);
+            this.textBoxPinmuxVal2.MaxLength = 10;
+            this.textBoxPinmuxVal2.Name = "textBoxPinmuxVal2";
+            this.textBoxPinmuxVal2.Size = new System.Drawing.Size(80, 20);
+            this.textBoxPinmuxVal2.TabIndex = 5;
+            this.textBoxPinmuxVal2.Text = "0x00000000";
+            this.textBoxPinmuxVal2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPinmuxVal2.TextChanged += new System.EventHandler(this.textBoxPinmuxVal_TextChanged);
+            // 
+            // labelPinmuxReg3
+            // 
+            this.labelPinmuxReg3.AutoSize = true;
+            this.labelPinmuxReg3.Location = new System.Drawing.Point(106, 57);
+            this.labelPinmuxReg3.Name = "labelPinmuxReg3";
+            this.labelPinmuxReg3.Size = new System.Drawing.Size(113, 13);
+            this.labelPinmuxReg3.TabIndex = 52;
+            this.labelPinmuxReg3.Text = "Pinmux Register (0-19)";
+            // 
+            // numericUpDownPinmux2
+            // 
+            this.numericUpDownPinmux2.Location = new System.Drawing.Point(225, 55);
+            this.numericUpDownPinmux2.Maximum = new decimal(new int[] {
+            19,
+            0,
+            0,
+            0});
+            this.numericUpDownPinmux2.Minimum = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux2.Name = "numericUpDownPinmux2";
+            this.numericUpDownPinmux2.Size = new System.Drawing.Size(40, 20);
+            this.numericUpDownPinmux2.TabIndex = 4;
+            this.numericUpDownPinmux2.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.numericUpDownPinmux2.Value = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux2.ValueChanged += new System.EventHandler(this.numericUpDownPinmux_ValueChanged);
+            // 
+            // textBoxPinmuxVal1
+            // 
+            this.textBoxPinmuxVal1.Enabled = false;
+            this.textBoxPinmuxVal1.Location = new System.Drawing.Point(271, 29);
+            this.textBoxPinmuxVal1.MaxLength = 10;
+            this.textBoxPinmuxVal1.Name = "textBoxPinmuxVal1";
+            this.textBoxPinmuxVal1.Size = new System.Drawing.Size(80, 20);
+            this.textBoxPinmuxVal1.TabIndex = 3;
+            this.textBoxPinmuxVal1.Text = "0x00000000";
+            this.textBoxPinmuxVal1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPinmuxVal1.TextChanged += new System.EventHandler(this.textBoxPinmuxVal_TextChanged);
+            // 
+            // labelPinmuxReg2
+            // 
+            this.labelPinmuxReg2.AutoSize = true;
+            this.labelPinmuxReg2.Location = new System.Drawing.Point(106, 31);
+            this.labelPinmuxReg2.Name = "labelPinmuxReg2";
+            this.labelPinmuxReg2.Size = new System.Drawing.Size(113, 13);
+            this.labelPinmuxReg2.TabIndex = 49;
+            this.labelPinmuxReg2.Text = "Pinmux Register (0-19)";
+            // 
+            // numericUpDownPinmux1
+            // 
+            this.numericUpDownPinmux1.Location = new System.Drawing.Point(225, 29);
+            this.numericUpDownPinmux1.Maximum = new decimal(new int[] {
+            19,
+            0,
+            0,
+            0});
+            this.numericUpDownPinmux1.Minimum = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux1.Name = "numericUpDownPinmux1";
+            this.numericUpDownPinmux1.Size = new System.Drawing.Size(40, 20);
+            this.numericUpDownPinmux1.TabIndex = 2;
+            this.numericUpDownPinmux1.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.numericUpDownPinmux1.Value = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux1.ValueChanged += new System.EventHandler(this.numericUpDownPinmux_ValueChanged);
+            // 
+            // textBoxPinmuxVal0
+            // 
+            this.textBoxPinmuxVal0.Enabled = false;
+            this.textBoxPinmuxVal0.Location = new System.Drawing.Point(271, 3);
+            this.textBoxPinmuxVal0.MaxLength = 10;
+            this.textBoxPinmuxVal0.Name = "textBoxPinmuxVal0";
+            this.textBoxPinmuxVal0.Size = new System.Drawing.Size(80, 20);
+            this.textBoxPinmuxVal0.TabIndex = 1;
+            this.textBoxPinmuxVal0.Text = "0x00000000";
+            this.textBoxPinmuxVal0.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.textBoxPinmuxVal0.TextChanged += new System.EventHandler(this.textBoxPinmuxVal_TextChanged);
+            // 
+            // labelPinmuxReg1
+            // 
+            this.labelPinmuxReg1.AutoSize = true;
+            this.labelPinmuxReg1.Location = new System.Drawing.Point(106, 5);
+            this.labelPinmuxReg1.Name = "labelPinmuxReg1";
+            this.labelPinmuxReg1.Size = new System.Drawing.Size(113, 13);
+            this.labelPinmuxReg1.TabIndex = 6;
+            this.labelPinmuxReg1.Text = "Pinmux Register (0-19)";
+            // 
+            // numericUpDownPinmux0
+            // 
+            this.numericUpDownPinmux0.Location = new System.Drawing.Point(225, 3);
+            this.numericUpDownPinmux0.Maximum = new decimal(new int[] {
+            19,
+            0,
+            0,
+            0});
+            this.numericUpDownPinmux0.Minimum = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux0.Name = "numericUpDownPinmux0";
+            this.numericUpDownPinmux0.Size = new System.Drawing.Size(40, 20);
+            this.numericUpDownPinmux0.TabIndex = 0;
+            this.numericUpDownPinmux0.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
+            this.numericUpDownPinmux0.Value = new decimal(new int[] {
+            1,
+            0,
+            0,
+            -2147483648});
+            this.numericUpDownPinmux0.ValueChanged += new System.EventHandler(this.numericUpDownPinmux_ValueChanged);
+            // 
+            // labelAppFile
+            // 
+            this.labelAppFile.AutoSize = true;
+            this.labelAppFile.Location = new System.Drawing.Point(12, 272);
+            this.labelAppFile.Name = "labelAppFile";
+            this.labelAppFile.Size = new System.Drawing.Size(112, 13);
+            this.labelAppFile.TabIndex = 15;
+            this.labelAppFile.Text = "[Core] Application File:";
+            // 
+            // buttonBrowseFile
+            // 
+            this.buttonBrowseFile.Location = new System.Drawing.Point(439, 268);
+            this.buttonBrowseFile.Name = "buttonBrowseFile";
+            this.buttonBrowseFile.Size = new System.Drawing.Size(25, 20);
+            this.buttonBrowseFile.TabIndex = 2;
+            this.buttonBrowseFile.Text = "...";
+            this.buttonBrowseFile.UseVisualStyleBackColor = true;
+            this.buttonBrowseFile.Click += new System.EventHandler(this.buttonBrowseFile_Click);
+            // 
+            // textBoxAppFiles
+            // 
+            this.textBoxAppFiles.Location = new System.Drawing.Point(132, 269);
+            this.textBoxAppFiles.Name = "textBoxAppFiles";
+            this.textBoxAppFiles.Size = new System.Drawing.Size(288, 20);
+            this.textBoxAppFiles.TabIndex = 1;
+            this.textBoxAppFiles.Text = "C:\\dsp_app.out";
+            this.textBoxAppFiles.TextChanged += new System.EventHandler(this.textBoxAppFiles_TextChanged);
+            // 
+            // buttonAddFile
+            // 
+            this.buttonAddFile.Location = new System.Drawing.Point(470, 268);
+            this.buttonAddFile.Name = "buttonAddFile";
+            this.buttonAddFile.Size = new System.Drawing.Size(25, 20);
+            this.buttonAddFile.TabIndex = 3;
+            this.buttonAddFile.Text = "+";
+            this.buttonAddFile.UseVisualStyleBackColor = true;
+            this.buttonAddFile.Click += new System.EventHandler(this.buttonBrowseFile_Click);
+            // 
+            // textBoxAISfile
+            // 
+            this.textBoxAISfile.Location = new System.Drawing.Point(132, 295);
+            this.textBoxAISfile.Name = "textBoxAISfile";
+            this.textBoxAISfile.Size = new System.Drawing.Size(288, 20);
+            this.textBoxAISfile.TabIndex = 4;
+            this.textBoxAISfile.Text = "C:\\oh_my.h";
+            this.textBoxAISfile.TextChanged += new System.EventHandler(this.textBoxAISfile_TextChanged);
+            // 
+            // labelAISfile
+            // 
+            this.labelAISfile.AutoSize = true;
+            this.labelAISfile.Location = new System.Drawing.Point(13, 298);
+            this.labelAISfile.Name = "labelAISfile";
+            this.labelAISfile.Size = new System.Drawing.Size(81, 13);
+            this.labelAISfile.TabIndex = 22;
+            this.labelAISfile.Text = "AIS Output File:";
+            // 
+            // buttonAISbrowseFile
+            // 
+            this.buttonAISbrowseFile.Location = new System.Drawing.Point(439, 295);
+            this.buttonAISbrowseFile.Name = "buttonAISbrowseFile";
+            this.buttonAISbrowseFile.Size = new System.Drawing.Size(25, 20);
+            this.buttonAISbrowseFile.TabIndex = 5;
+            this.buttonAISbrowseFile.Text = "...";
+            this.buttonAISbrowseFile.UseVisualStyleBackColor = true;
+            this.buttonAISbrowseFile.Click += new System.EventHandler(this.buttonAISbrowseFile_Click);
+            // 
+            // buttonGenerateAIS
+            // 
+            this.buttonGenerateAIS.Location = new System.Drawing.Point(375, 321);
+            this.buttonGenerateAIS.Name = "buttonGenerateAIS";
+            this.buttonGenerateAIS.Size = new System.Drawing.Size(120, 24);
+            this.buttonGenerateAIS.TabIndex = 6;
+            this.buttonGenerateAIS.Text = "Generate AIS";
+            this.buttonGenerateAIS.UseVisualStyleBackColor = true;
+            this.buttonGenerateAIS.Click += new System.EventHandler(this.buttonGenerateAIS_Click);
+            // 
+            // labelMessage
+            // 
+            this.labelMessage.AutoSize = true;
+            this.labelMessage.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+            this.labelMessage.Location = new System.Drawing.Point(13, 327);
+            this.labelMessage.Name = "labelMessage";
+            this.labelMessage.Size = new System.Drawing.Size(51, 13);
+            this.labelMessage.TabIndex = 25;
+            this.labelMessage.Text = "[Ready]";
+            this.tooltipMessage.SetToolTip(this.labelMessage, "[Ready]");
+            // 
+            // tooltipMessage
+            // 
+            this.tooltipMessage.AutoPopDelay = 5000;
+            this.tooltipMessage.InitialDelay = 0;
+            this.tooltipMessage.ReshowDelay = 0;
+            // 
+            // MainForm
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(506, 356);
+            this.Controls.Add(this.labelMessage);
+            this.Controls.Add(this.buttonGenerateAIS);
+            this.Controls.Add(this.buttonAISbrowseFile);
+            this.Controls.Add(this.labelAISfile);
+            this.Controls.Add(this.textBoxAISfile);
+            this.Controls.Add(this.buttonAddFile);
+            this.Controls.Add(this.textBoxAppFiles);
+            this.Controls.Add(this.buttonBrowseFile);
+            this.Controls.Add(this.labelAppFile);
+            this.Controls.Add(this.tabControlConfig);
+            this.Controls.Add(this.menuStrip1);
+            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
+            this.MainMenuStrip = this.menuStrip1;
+            this.MaximumSize = new System.Drawing.Size(514, 390);
+            this.MinimumSize = new System.Drawing.Size(514, 390);
+            this.Name = "MainForm";
+            this.Text = "AISgen for D800K008";
+            this.Load += new System.EventHandler(this.FormLoad);
+            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
+            this.menuStrip1.ResumeLayout(false);
+            this.menuStrip1.PerformLayout();
+            this.tabControlConfig.ResumeLayout(false);
+            this.tabPageGeneral.ResumeLayout(false);
+            this.tabPageGeneral.PerformLayout();
+            this.tabPageFlash.ResumeLayout(false);
+            this.tabPageFlash.PerformLayout();
+            this.tabPagePeripheral.ResumeLayout(false);
+            this.tabPagePeripheral.PerformLayout();
+            this.tabPagePLL0.ResumeLayout(false);
+            this.tabPagePLL0.PerformLayout();
+            this.tabPageSDRAM.ResumeLayout(false);
+            this.tabPageSDRAM.PerformLayout();
+            this.tabPagePLL1.ResumeLayout(false);
+            this.tabPagePLL1.PerformLayout();
+            this.tabPageDDR2.ResumeLayout(false);
+            this.tabPageDDR2.PerformLayout();
+            this.groupBoxDDRtype.ResumeLayout(false);
+            this.groupBoxDDRtype.PerformLayout();
+            this.tabPageLPSC.ResumeLayout(false);
+            this.tabPageLPSC.PerformLayout();
+            this.tabPagePinmux.ResumeLayout(false);
+            this.tabPagePinmux.PerformLayout();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux19)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux18)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux17)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux16)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux15)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux14)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux13)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux12)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux11)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux10)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux9)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux8)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux7)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux6)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux5)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux4)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux3)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux2)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux1)).EndInit();
+            ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPinmux0)).EndInit();
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.Label labelBootType;
+        private System.Windows.Forms.Label labelBootMode;
+        private System.Windows.Forms.Label labelClockSource;
+        private System.Windows.Forms.ComboBox comboBoxBootType;
+        private System.Windows.Forms.ComboBox comboBoxClockSource;
+        private System.Windows.Forms.Label labelInputClockMHz;
+        private System.Windows.Forms.CheckBox checkBoxPLL0;
+        private System.Windows.Forms.CheckBox checkBoxDDR2;
+        private System.Windows.Forms.CheckBox checkBoxSDRAM;
+        private System.Windows.Forms.CheckBox checkBoxCRC;
+        private System.Windows.Forms.MenuStrip menuStrip1;
+        private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
+        private System.Windows.Forms.ToolStripMenuItem saveConfigToolStripMenuItem;
+        private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
+        private System.Windows.Forms.ToolStripMenuItem loadConfigToolStripMenuItem;
+        private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
+        private System.Windows.Forms.TabControl tabControlConfig;
+        private System.Windows.Forms.TabPage tabPagePeripheral;
+        private System.Windows.Forms.TabPage tabPagePLL0;
+        private System.Windows.Forms.TabPage tabPagePLL1;
+        private System.Windows.Forms.TabPage tabPageDDR2;
+        private System.Windows.Forms.TabPage tabPageSDRAM;
+        private System.Windows.Forms.Label labelPLL0postDiv;
+        private System.Windows.Forms.Label labelPLL0preDiv;
+        private System.Windows.Forms.Label labelPLL0mult;
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.Label labelPLL0div7;
+        private System.Windows.Forms.Label labelPLL0div3;
+        private System.Windows.Forms.TabPage tabPageGeneral;
+        private System.Windows.Forms.CheckBox checkBoxPLL1;
+        private System.Windows.Forms.Label labelPLL1div3;
+        private System.Windows.Forms.Label labelPLL1div2;
+        private System.Windows.Forms.Label labelPLL1div1;
+        private System.Windows.Forms.Label labelPLL1postDiv;
+        private System.Windows.Forms.Label labelPLL1mult;
+        private System.Windows.Forms.Label labelPLL0emac;
+        private System.Windows.Forms.Label labelPLL0sdram;
+        private System.Windows.Forms.Label labelPLL0cpu;
+        private System.Windows.Forms.Label labelPLL0emacMHz;
+        private System.Windows.Forms.Label labelPLL0sdramMHz;
+        private System.Windows.Forms.Label labelPLL0cpuMHz;
+        private System.Windows.Forms.Label labelPLL1ddr2MHz;
+        private System.Windows.Forms.Label labelPLL1ddr2;
+        private System.Windows.Forms.Label labelPeriphClockHz;
+        private System.Windows.Forms.Label labelPeriphClock;
+        private System.Windows.Forms.Label labelPeriphModuleClockMHz;
+        private System.Windows.Forms.Label labelPeriphModuleClock;
+        private System.Windows.Forms.TextBox textBoxPeriphClockActual;
+        private System.Windows.Forms.Label labelSDRAMsdbcr;
+        private System.Windows.Forms.CheckBox checkBoxSDRAMdiv;
+        private System.Windows.Forms.Label labelSDRAMclockMHz;
+        private System.Windows.Forms.Label labelSDRAMclock;
+        private System.Windows.Forms.Label labelSDRAMsdrcr;
+        private System.Windows.Forms.Label labelSDRAMsdrsrpdexit;
+        private System.Windows.Forms.Label labelSDRAMsdtmr;
+        private System.Windows.Forms.Label labelDDR2sdrcr;
+        private System.Windows.Forms.Label labelDDR2sdtimr2;
+        private System.Windows.Forms.Label labelDDR2sdtimr;
+        private System.Windows.Forms.Label labelDDR2sdcr;
+        private System.Windows.Forms.CheckBox checkBoxDDR2directClock;
+        private System.Windows.Forms.Label labelDDR2clockMHz;
+        private System.Windows.Forms.Label labelDDR2clock;
+        private System.Windows.Forms.Label labelDDR2phy;
+        private System.Windows.Forms.Label labelAppFile;
+        private System.Windows.Forms.Button buttonBrowseFile;
+        private System.Windows.Forms.Button buttonAddFile;
+        private System.Windows.Forms.CheckBox checkBoxSpecifyEntrypoint;
+        private System.Windows.Forms.Label labelAISfile;
+        private System.Windows.Forms.Button buttonAISbrowseFile;
+        private System.Windows.Forms.Button buttonGenerateAIS;
+        private System.Windows.Forms.Label labelMessage;
+        private System.Windows.Forms.ToolTip tooltipMessage;
+        private System.Windows.Forms.CheckBox checkBoxPeriphSeqRead;
+        public System.Windows.Forms.TextBox textBoxClockSpeed;
+        public System.Windows.Forms.TextBox textBoxPLL0mult;
+        public System.Windows.Forms.TextBox textBoxPLL0postDiv;
+        public System.Windows.Forms.TextBox textBoxPLL0preDiv;
+        public System.Windows.Forms.TextBox textBoxPLL0div1;
+        public System.Windows.Forms.TextBox textBoxPLL0div7;
+        public System.Windows.Forms.TextBox textBoxPLL0div3;
+        public System.Windows.Forms.TextBox textBoxPLL1div3;
+        public System.Windows.Forms.TextBox textBoxPLL1div2;
+        public System.Windows.Forms.TextBox textBoxPLL1div1;
+        public System.Windows.Forms.TextBox textBoxPLL1postDiv;
+        public System.Windows.Forms.TextBox textBoxPLL1mult;
+        public System.Windows.Forms.TextBox textBoxPLL0emac;
+        public System.Windows.Forms.TextBox textBoxPLL0sdram;
+        public System.Windows.Forms.TextBox textBoxPLL0cpu;
+        public System.Windows.Forms.TextBox textBoxPLL1ddr2;
+        public System.Windows.Forms.TextBox textBoxPeriphClockIdeal;
+        public System.Windows.Forms.TextBox textBoxPeriphModuleClock;
+        public System.Windows.Forms.TextBox textBoxSDRAMsdbcr;
+        public System.Windows.Forms.TextBox textBoxSDRAMclock;
+        public System.Windows.Forms.TextBox textBoxSDRAMsdrcr;
+        public System.Windows.Forms.TextBox textBoxSDRAMsdrsrpdexit;
+        public System.Windows.Forms.TextBox textBoxSDRAMsdtmr;
+        public System.Windows.Forms.TextBox textBoxDDR2sdrcr;
+        public System.Windows.Forms.TextBox textBoxDDR2sdtimr2;
+        public System.Windows.Forms.TextBox textBoxDDR2sdtimr;
+        public System.Windows.Forms.TextBox textBoxDDR2sdcr;
+        public System.Windows.Forms.TextBox textBoxDDR2clock;
+        public System.Windows.Forms.TextBox textBoxDDR2phy;
+        public System.Windows.Forms.TextBox textBoxAppFiles;
+        public System.Windows.Forms.TextBox textBoxSpecifyEntrypoint;
+        public System.Windows.Forms.TextBox textBoxAISfile;
+        private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
+        private System.Windows.Forms.CheckBox checkBoxLPSC;
+        private System.Windows.Forms.CheckBox checkBoxPinmux;
+        private System.Windows.Forms.TabPage tabPageLPSC;
+        private System.Windows.Forms.TabPage tabPagePinmux;
+        private System.Windows.Forms.Label labelLpsc0SyncRst;
+        private System.Windows.Forms.Label labelLpsc0Disable;
+        private System.Windows.Forms.Label labelLpsc0enable;
+        private System.Windows.Forms.Label labelLpsc1;
+        private System.Windows.Forms.Label labelLpsc0;
+        private System.Windows.Forms.NumericUpDown numericUpDownPinmux0;
+        public System.Windows.Forms.TextBox textBoxPinmuxVal3;
+        private System.Windows.Forms.Label labelPinmuxReg4;
+        private System.Windows.Forms.NumericUpDown numericUpDownPinmux3;
+        public System.Windows.Forms.TextBox textBoxPinmuxVal2;
+        private System.Windows.Forms.Label labelPinmuxReg3;
+        private System.Windows.Forms.NumericUpDown numericUpDownPinmux2;
+        public System.Windows.Forms.TextBox textBoxPinmuxVal1;
+        private System.Windows.Forms.Label labelPinmuxReg2;
+        private System.Windows.Forms.NumericUpDown numericUpDownPinmux1;
+        public System.Windows.Forms.TextBox textBoxPinmuxVal0;
+        private System.Windows.Forms.Label labelPinmuxReg1;
+        public System.Windows.Forms.TextBox textBoxPinmuxVal4;
+        private System.Windows.Forms.Label labelPinmuxReg5;
+        private System.Windows.Forms.NumericUpDown numericUpDownPinmux4;
+        public System.Windows.Forms.TextBox textBoxPinmuxVal19;
+        private System.Windows.Forms.Label labelPinmuxReg20;
+        private System.Windows.Forms.NumericUpDown numericUpDownPinmux19;
+        public System.Windows.Forms.TextBox textBoxPinmuxVal18;
+        private System.Windows.Forms.Label labelPinmuxReg19;
+        private System.Windows.Forms.NumericUpDown numericUpDownPinmux18;
+        public System.Windows.Forms.TextBox textBoxPinmuxVal17;
+        private System.Windows.Forms.Label labelPinmuxReg18;
+        private System.Windows.Forms.NumericUpDown numericUpDownPinmux17;
+        public System.Windows.Forms.TextBox textBoxPinmuxVal16;
+        private System.Windows.Forms.Label labelPinmuxReg17;
+        private System.Windows.Forms.NumericUpDown numericUpDownPinmux16;
+        public System.Windows.Forms.TextBox textBoxPinmuxVal15;
+        private System.Windows.Forms.Label labelPinmuxReg16;
+        private System.Windows.Forms.NumericUpDown numericUpDownPinmux15;
+        public System.Windows.Forms.TextBox textBoxPinmuxVal14;
+        private System.Windows.Forms.Label labelPinmuxReg15;
+        private System.Windows.Forms.NumericUpDown numericUpDownPinmux14;
+        public System.Windows.Forms.TextBox textBoxPinmuxVal13;
+        private System.Windows.Forms.Label labelPinmuxReg14;
+        private System.Windows.Forms.NumericUpDown numericUpDownPinmux13;
+        public System.Windows.Forms.TextBox textBoxPinmuxVal12;
+        private System.Windows.Forms.Label labelPinmuxReg13;
+        private System.Windows.Forms.NumericUpDown numericUpDownPinmux12;
+        public System.Windows.Forms.TextBox textBoxPinmuxVal11;
+        private System.Windows.Forms.Label labelPinmuxReg12;
+        private System.Windows.Forms.NumericUpDown numericUpDownPinmux11;
+        public System.Windows.Forms.TextBox textBoxPinmuxVal10;
+        private System.Windows.Forms.Label labelPinmuxReg11;
+        private System.Windows.Forms.NumericUpDown numericUpDownPinmux10;
+        public System.Windows.Forms.TextBox textBoxPinmuxVal9;
+        private System.Windows.Forms.Label labelPinmuxReg10;
+        private System.Windows.Forms.NumericUpDown numericUpDownPinmux9;
+        public System.Windows.Forms.TextBox textBoxPinmuxVal8;
+        private System.Windows.Forms.Label labelPinmuxReg9;
+        private System.Windows.Forms.NumericUpDown numericUpDownPinmux8;
+        public System.Windows.Forms.TextBox textBoxPinmuxVal7;
+        private System.Windows.Forms.Label labelPinmuxReg8;
+        private System.Windows.Forms.NumericUpDown numericUpDownPinmux7;
+        public System.Windows.Forms.TextBox textBoxPinmuxVal6;
+        private System.Windows.Forms.Label labelPinmuxReg7;
+        private System.Windows.Forms.NumericUpDown numericUpDownPinmux6;
+        public System.Windows.Forms.TextBox textBoxPinmuxVal5;
+        private System.Windows.Forms.Label labelPinmuxReg6;
+        private System.Windows.Forms.NumericUpDown numericUpDownPinmux5;
+        public System.Windows.Forms.TextBox textBoxLps1SyncRst;
+        public System.Windows.Forms.TextBox textBoxLps1Disable;
+        public System.Windows.Forms.TextBox textBoxLps1Enable;
+        public System.Windows.Forms.TextBox textBoxLps0SyncRst;
+        public System.Windows.Forms.TextBox textBoxLps0Disable;
+        public System.Windows.Forms.TextBox textBoxLps0Enable;
+        private System.Windows.Forms.ToolStripMenuItem restoreDefaultsToolStripMenuItem;
+        private System.Windows.Forms.TabPage tabPageFlash;
+        public System.Windows.Forms.TextBox textBoxFlashTiming;
+        private System.Windows.Forms.Label labelFlashTiming;
+        private System.Windows.Forms.Label labelFlashWidth;
+        private System.Windows.Forms.ComboBox comboBoxFlashWidth;
+        private System.Windows.Forms.RadioButton radioDDR2;
+        private System.Windows.Forms.RadioButton radioMDDR;
+        private System.Windows.Forms.RadioButton radioDuplicateMddrSetting;
+        private System.Windows.Forms.GroupBox groupBoxDDRtype;
+        private System.Windows.Forms.Label labelDDR2sdcr2;
+        public System.Windows.Forms.TextBox textBoxDDR2sdcr2;
+        private System.Windows.Forms.ComboBox comboBoxROMid;
+        public System.Windows.Forms.ComboBox comboBoxBootMode;
+    }
+}
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/MainForm.cs b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/MainForm.cs
new file mode 100644 (file)
index 0000000..44b104d
--- /dev/null
@@ -0,0 +1,2656 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.IO;
+using System.Text;
+using System.Windows.Forms;
+using TI.UtilLib;
+using TI.UtilLib.Ini;
+using TI.UtilLib.HexConv;
+using TI.UtilLib.ObjectFile;
+using TI.AISLib;
+
+namespace TIBootAndFlash
+{
+    public partial class MainForm : Form
+    {
+        #region Data Members
+
+        // boot options
+        private BootOptions options;
+
+        // arrays to better handle pinmux tab
+        public NumericUpDown[] numericUpDownPinmux;
+        public TextBox[] textBoxPinmux;
+
+        // instance variables for tab workaround
+        private bool[] tabVisible;
+        private TabPage[] tab;
+
+        // error manager
+        private ParamError error;
+
+        // log stream
+        private StreamWriter log;
+
+        // command line usage
+        private bool cmdSingleRun;
+        private String cmdFileName;
+
+        #endregion
+
+        #region Methods - Initialization
+
+        public MainForm(bool cmd, String fileName)
+        {
+            // save command line arg specified
+            cmdSingleRun = cmd;
+            cmdFileName = fileName;
+
+            InitializeComponent();
+        }
+
+        private void FormLoad(object sender, EventArgs e)
+        {
+            // setup log file
+            log = new StreamWriter("AIGgen_log.txt");
+            Console.SetOut(log);
+
+            // initialize dumb tab workaround and turn off all but first tab
+            tab = new TabPage[(int)Consts.Tab.num_tabs];
+            tabVisible = new bool[(int)Consts.Tab.num_tabs];
+            for (int i = 0; i < (int)Consts.Tab.num_tabs; i++)
+            {
+                tab[i] = (TabPage)tabControlConfig.GetControl(i);
+                tabVisible[i] = true;
+            }
+            for (int i = 1; i < (int)Consts.Tab.num_tabs; i++)
+                UTIL_tabHide(i);
+
+            // setup pinmux control arrays
+            UTIL_setupPinmuxArrays();
+
+            // create error icons
+            error = new ParamError(this);
+
+            // initialize boot options and apply to forms
+            options = new BootOptions();
+
+            // command line mode: load cfg file, generate AIS, and close form
+            if (cmdSingleRun)
+            {
+                // load configuration file
+                try
+                {
+                    String loadFileList;
+                    options.loadFromFile(cmdFileName, out loadFileList);
+                    VAL_checkAppFileNames(loadFileList);
+                    CLOCK_updatePLL0clk();
+
+                    LOG_msg("Loaded configuration from file " + cmdFileName);
+                }
+                catch (Exception ex)
+                {
+                    LOG_msg("Error loading configuration: " + ex.Message);
+                    this.Close();
+                }
+
+                // generate AIS file
+                buttonGenerateAIS_Click(sender, e);
+
+                // close app
+                this.Close();
+            }
+            else
+            {
+                // normal operation; load GUI
+                UTIL_refreshFields();
+            }
+        }
+
+        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
+        {
+            // close log file
+            log.Close();
+        }
+
+        #endregion
+
+        #region Methods - Menu Command Handlers
+
+        private void restoreDefaultsToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            // reset active tab to General
+            tabControlConfig.SelectedIndex = 0;
+
+            // initialize boot options and apply to forms
+            options = new BootOptions();
+
+            UTIL_refreshFields();
+        }
+
+        private void saveConfigToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            // get new CFG file name
+            bool ok;
+            String cfgFileName = UTIL_getSaveFileName("Save Configuration to File",
+                "Configuration files|*.cfg|All files|*.*",
+                true, out ok);
+
+            // save file name if user clicked OK
+            if (ok)
+                try
+                {
+                    options.saveToFile(cfgFileName, textBoxAppFiles.Text);
+                    LOG_msg("Saved configuration to file " + cfgFileName);
+                }
+                catch (Exception ex)
+                {
+                    LOG_msg("Error saving configuration: " + ex.Message);
+                }
+        }
+
+        private void loadConfigToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            // get existing CFG file name
+            bool ok;
+            String cfgFileName = UTIL_getFileName("Load Configuration from File",
+                "Configuration files|*.cfg|All files|*.*",
+                false, out ok);
+
+            // save file name if user clicked OK
+            if (ok)
+                try
+                {
+                    String loadFileList;
+                    options.loadFromFile(cfgFileName, out loadFileList);
+                    textBoxAppFiles.Text = loadFileList;
+                    LOG_msg("Loaded configuration from file " + cfgFileName);
+                }
+                catch (Exception ex)
+                {
+                    LOG_msg("Error loading configuration: " + ex.Message);
+                }
+
+            // reset active tab to General
+            tabControlConfig.SelectedIndex = 0;
+
+            // refresh form
+            UTIL_refreshFields();
+        }
+
+        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            this.Close();
+        }
+
+        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            AboutForm about = new AboutForm(this.DesktopLocation.X + 120, this.DesktopLocation.Y + 100);
+            about.ShowDialog();
+        }
+
+        #endregion
+
+        #region Methods - Check Box Handlers
+
+        private void checkBoxPLL0_CheckedChanged(object sender, EventArgs e)
+        {
+            options.configPll0 = checkBoxPLL0.Checked;
+
+            // show or hide the PLL0 tab
+            if (options.configPll0)
+                UTIL_tabShow((int)Consts.Tab.pll0);
+            else
+                UTIL_tabHide((int)Consts.Tab.pll0);
+
+            // update clock calculations
+            CLOCK_updatePLL0clk();
+        }
+
+        private void checkBoxPLL1_CheckedChanged(object sender, EventArgs e)
+        {
+            options.configPll1 = checkBoxPLL1.Checked;
+
+            // show or hide the PLL1 tab
+            if (options.configPll1)
+                UTIL_tabShow((int)Consts.Tab.pll1);
+            else
+                UTIL_tabHide((int)Consts.Tab.pll1);
+
+            // update clock calculations
+            CLOCK_updatePLL1clk();
+        }
+
+        private void checkBoxSDRAM_CheckedChanged(object sender, EventArgs e)
+        {
+            options.configSdram = checkBoxSDRAM.Checked;
+
+            // show or hide the SDRAM tab
+            if (options.configSdram)
+                UTIL_tabShow((int)Consts.Tab.sdram);
+            else
+                UTIL_tabHide((int)Consts.Tab.sdram);
+
+            // update clock calculations
+            CLOCK_updateSDRAMclk();
+        }
+
+        private void checkBoxSpecifyEntrypoint_CheckedChanged(object sender, EventArgs e)
+        {
+            options.specifyEntrypoint = checkBoxSpecifyEntrypoint.Checked;
+
+            // enable or disable entrypoint text box and associated error check
+            if (options.specifyEntrypoint)
+            {
+                textBoxSpecifyEntrypoint.Enabled = true;
+                textBoxSpecifyEntrypoint_TextChanged(sender, e);
+            }
+            else
+            {
+                textBoxSpecifyEntrypoint.Enabled = false;
+                error.generalEntryPoint.Clear();
+            }
+        }
+
+        private void checkBoxDDR2_CheckedChanged(object sender, EventArgs e)
+        {
+            options.configDdr2 = checkBoxDDR2.Checked;
+
+            // show or hide the DDR2 tab
+            if (options.configDdr2)
+            {
+                UTIL_tabShow((int)Consts.Tab.ddr2);
+                // force check PLL1
+                checkBoxPLL1.Checked = true;
+                checkBoxPLL1.Enabled = false;
+            }
+            else
+            {
+                UTIL_tabHide((int)Consts.Tab.ddr2);
+                // force un-check PLL1
+                checkBoxPLL1.Checked = false;
+                checkBoxPLL1.Enabled = true;
+            }
+
+            // update clock calculations
+            CLOCK_updateDDR2clk();
+        }
+
+        private void checkBoxCRC_CheckedChanged(object sender, EventArgs e)
+        {
+            options.enableCRC = checkBoxCRC.Checked;
+        }
+
+        private void checkBoxSDRAMdiv_CheckedChanged(object sender, EventArgs e)
+        {
+            options.sdramDiv45 = checkBoxSDRAMdiv.Checked;
+            
+            // refresh SDRAM clock calculation
+            CLOCK_updateSDRAMclk();
+        }
+
+        private void checkBoxDDR2directClock_CheckedChanged(object sender, EventArgs e)
+        {
+            options.ddr2directClk = checkBoxDDR2directClock.Checked;
+
+            // refresh DDR2 clock calculation
+            CLOCK_updateDDR2clk();
+        }
+
+        private void checkBoxPeriphSeqRead_CheckedChanged(object sender, EventArgs e)
+        {
+            options.enableSeqRead = checkBoxPeriphSeqRead.Checked;
+        }
+
+        private void checkBoxLPSC_CheckedChanged(object sender, EventArgs e)
+        {
+            options.configLpsc = checkBoxLPSC.Checked;
+
+            // show or hide the SDRAM tab
+            if (options.configLpsc)
+                UTIL_tabShow((int)Consts.Tab.lpsc);
+            else
+                UTIL_tabHide((int)Consts.Tab.lpsc);
+        }
+
+        private void checkBoxPinmux_CheckedChanged(object sender, EventArgs e)
+        {
+            options.configPinmux = checkBoxPinmux.Checked;
+
+            // show or hide the SDRAM tab
+            if (options.configPinmux)
+                UTIL_tabShow((int)Consts.Tab.pinmux);
+            else
+                UTIL_tabHide((int)Consts.Tab.pinmux);
+        }
+
+        #endregion
+
+        #region Methods - Radio Selection Handlers
+
+        private void radioMDDR_CheckedChanged(object sender, EventArgs e)
+        {
+            // note: one radio button handler is technically sufficient
+            options.useMDDR = radioMDDR.Checked;
+
+            // enable or disable DDR SDCR2 text box (only used for mDDR)
+            textBoxDDR2sdcr2.Enabled = options.useMDDR;
+        }
+
+        private void radioDDR2_CheckedChanged(object sender, EventArgs e)
+        {
+            // note: one radio button handler is technically sufficient
+            options.useMDDR = !(radioDDR2.Checked);
+            options.useDuplicateMddrSetting = !(radioDDR2.Checked);
+
+            // enable or disable DDR SDCR2 text box (only used for mDDR)
+            textBoxDDR2sdcr2.Enabled = options.useMDDR;
+        }
+
+        private void radioDuplicateMddrSetting_CheckedChanged(object sender, EventArgs e)
+        {
+            // note: one radio button handler is technically sufficient
+            options.useDuplicateMddrSetting = radioDuplicateMddrSetting.Checked;
+            options.useMDDR = radioDuplicateMddrSetting.Checked;
+
+            // enable or disable DDR SDCR2 text box (only used for mDDR)
+            textBoxDDR2sdcr2.Enabled = options.useDuplicateMddrSetting;
+        }
+
+
+        #endregion
+
+        #region Methods - Combo Box Handlers
+
+        private void comboBoxBootMode_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            // change selected boot mode
+            options.boot.select((String)comboBoxBootMode.SelectedItem);
+
+            // validate input (new boot mode must already be applied)
+            VAL_checkBootMode();
+
+            // update peripheral tab
+            if (options.boot.isConfigurable)
+            {
+                // show or hide sequential read checkbox
+                if (options.boot.allowSeqRead)
+                    checkBoxPeriphSeqRead.Show();
+                else
+                    checkBoxPeriphSeqRead.Hide();
+
+                // allow or disallow speed changes
+                if (options.boot.allowSpeedChange)
+                    textBoxPeriphClockIdeal.Enabled = true;
+                else
+                    textBoxPeriphClockIdeal.Enabled = false;
+
+                // update ideal clock speed selection
+                textBoxPeriphClockIdeal.Text = Convert.ToString(options.boot.targetSpeed);
+                // force clock update (may not be called in transition from I2C0 to I2C1, etc.)
+                CLOCK_updatePeriphClk();
+
+                // change labels
+                labelPeriphClock.Text = options.boot.peripheralName + " Clock:";
+                labelPeriphClockHz.Text = options.boot.speedName;
+
+                options.configPeriph = true;
+                UTIL_tabShow((int)Consts.Tab.peripheral);
+            }
+            else
+            {
+                options.configPeriph = false;
+                UTIL_tabHide((int)Consts.Tab.peripheral);
+            }
+
+            // update flash tab
+            if (options.boot.isFlash)
+            {
+                // update timing
+                textBoxFlashTiming.Text = FORMAT_32bHexString(options.boot.flashTiming);
+
+                // allow or disallow 16-bit NAND depending on ROM ID
+                UTIL_setNandFeatures();
+
+                // change labels
+                if (options.boot.isNOR)
+                    labelFlashTiming.Text = "CS2 Setup:";
+                else if (options.boot.isNAND)
+                    labelFlashTiming.Text = "CS3 Setup:";
+
+                options.configFlash = true;
+                UTIL_tabShow((int)Consts.Tab.flash);
+            }
+            else
+            {
+                options.configFlash = false;
+                UTIL_tabHide((int)Consts.Tab.flash);
+            }
+        }
+
+        private void comboBoxBootType_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            if (((String)comboBoxBootType.SelectedItem).Contains("DSP"))
+            {
+                options.deviceType = (int)Consts.BootType.dsp;
+                labelAppFile.Text = "DSP Application File:";
+            }
+            else
+            {
+                options.deviceType = (int)Consts.BootType.arm;
+                labelAppFile.Text = "ARM Application File:";
+            }
+        }
+
+        private void comboBoxROMid_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            options.romID = comboBoxROMid.SelectedIndex;
+
+            // NOTE: Assumes that the items in the drop-down list are arranged
+            //       as follows (index -> item):
+            //
+            //       0 -> d800k002
+            //       1 -> d800k004
+            //       2 -> d800k006
+            //       3 -> d800k008
+            //
+            //       This should also be reflected in Consts.RomID.
+
+            // update flash tab (allow or disallow NAND-16)
+            if (options.boot.isNAND)
+                UTIL_setNandFeatures();
+
+            // don't allow MMC/SD boot mode for early ROM revisions
+            VAL_checkBootMode();
+        }
+
+        private void comboBoxClockSource_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            if (((String)comboBoxClockSource.SelectedItem).Contains("Crystal"))
+                options.clockType = (int)Consts.ClockSrc.crystal;
+            else
+                options.clockType = (int)Consts.ClockSrc.oscillator;
+        }
+
+        private void comboBoxFlashWidth_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            //  apply setting
+            options.boot.flashWidth = comboBoxFlashWidth.SelectedIndex;
+
+            // update timing value and refresh
+            options.boot.flashTimingUpdate();
+            textBoxFlashTiming.Text = FORMAT_32bHexString(options.boot.flashTiming);
+        }
+
+        #endregion
+
+        #region Methods - Numeric Up/Down Handlers
+
+        private void numericUpDownPinmux_ValueChanged(object sender, EventArgs e)
+        {
+            // identify caller (fall out and do nothing if not recognized)
+            for (int i = 0; i < 20; i++)
+                if (sender == numericUpDownPinmux[i])
+                {
+                    // turn on text box if a valid pinmux register is selected
+                    if (numericUpDownPinmux[i].Value >= (int)Consts.PinmuxReg.min &&
+                        numericUpDownPinmux[i].Value <= (int)Consts.PinmuxReg.max)
+                    {
+                        options.pinmuxApply[i] = true;
+                        options.pinmuxReg[i] = (int)numericUpDownPinmux[i].Value;
+
+                        textBoxPinmux[i].Enabled = true;
+                        // validate text box
+                        if (!VAL_isHexNum(textBoxPinmux[i].Text) ||
+                            !VAL_isPinmuxDigits(textBoxPinmux[i].Text))
+                            error.pinmux[i].SetError(textBoxPinmux[i],
+                                "Must be a 32-bit hexadecimal number with digits 0, 1, 2, 4, or 8."); 
+                    }
+                    else
+                    {
+                        options.pinmuxApply[i] = false;
+                        textBoxPinmux[i].Enabled = false;
+                        // clear error
+                        error.pinmux[i].Clear();
+                    }
+                    break;
+                }
+        }
+
+        #endregion
+
+        #region Methods - Button Handlers
+
+        private void buttonBrowseFile_Click(object sender, EventArgs e)
+        {
+            // get app file name
+            bool ok;
+            String appFileName = UTIL_getFileName("Open Application File",
+                "Application files|*.out|Binary Files|*.bin|All files|*.*",
+                false, out ok);
+
+            // proceed if user clicked OK
+            if (ok)
+            {
+                // add on address if this is not an obj file
+                appFileName = UTIL_addBinFileAddress(appFileName, (uint)Consts.BinAddr.boilerplate);
+
+                // save file name (overwrite for browse button, but append for add button)
+                if (sender == buttonAddFile && textBoxAppFiles.Text.Length > 0)
+                    textBoxAppFiles.Text += (";" + appFileName);
+                else
+                    textBoxAppFiles.Text = appFileName;
+            }
+        }
+
+        private void buttonAISbrowseFile_Click(object sender, EventArgs e)
+        {
+            // get new AIS file name
+            bool ok;
+            String aisFileName = UTIL_getFileName("Output AIS File",
+                "AIS binary files|*.bin;*.ais|C header files|*.h;*.c|All files|*.*",
+                true, out ok);
+
+            // save file name if user clicked OK
+            if (ok)
+                textBoxAISfile.Text = aisFileName;
+        }
+
+        private void buttonGenerateAIS_Click(object sender, EventArgs e)
+        {
+            Byte[] ais;
+
+            // clear message log
+            LOG_clear();
+
+            // check for other errors
+            if (VAL_errorsRaised())
+            {
+                LOG_msg("One or more parameter error must be corrected.");
+                return;
+            }
+
+            // check that either 1) at least one obj file is specified, or 2) an entrypoint is specified
+            if (!options.specifyEntrypoint && VAL_appFilesAllBinary())
+            {
+                LOG_msg("Must specify an entrypoint or at least one object file.");
+                return;
+            }
+
+            // don't allow user to specify entrypoint without at least one binary input file
+            if (options.specifyEntrypoint && VAL_appFilesAllObj())
+            {
+                LOG_msg("Cannot specify an entrypoint without at least one binary file.");
+                return;
+            }
+
+            // set busy cursor for main processing
+            this.Cursor = Cursors.WaitCursor;
+
+            // create INI array with appropriate sections and hash entries
+            IniFile ini = INI_assemble(options.appFileName, options.appFileAddr);
+            
+            // generate AIS contents and save to file
+            try
+            {
+                AISGen_OMAP_L138 devAISgen = new AISGen_OMAP_L138();
+
+                // generate AIS
+                ais = AISGen.GenAIS(devAISgen, null, ini);
+                if (ais == null)
+                    throw new Exception("AIS generation failed.");
+
+                // add NOR config word
+                if (options.boot.isNOR)
+                    ais = FORMAT_insertConfigWord(ais);
+
+                // convert to C array if AIS file ends in .h or .c
+                if (options.aisFileName.ToLower().EndsWith(".h") || options.aisFileName.ToLower().EndsWith(".c"))
+                    ais = CArray.bin2CArray(ais, 4);
+
+                // save
+                File.WriteAllBytes(options.aisFileName, ais);
+                LOG_msg(String.Format("Wrote {0} bytes to file " + options.aisFileName, ais.Length));
+            }
+            catch (Exception ex)
+            {
+                // report error and abort
+                LOG_msg("AIS generation aborted. " + ex.Message);
+            }
+
+            // reset cursor
+            this.Cursor = Cursors.Default;
+        }
+
+        #endregion
+
+        #region Methods - Text Box Handlers
+
+        private void textBoxClockSpeed_TextChanged(object sender, EventArgs e)
+        {
+            // validate input
+            VAL_checkRange(textBoxClockSpeed, (double)Consts.ClockIn.min, (double)Consts.ClockIn.max,
+                error.generalClock, out options.inputClock);
+
+            // update all clock calculations
+            CLOCK_updatePeriphClk();
+            CLOCK_updatePLL0clk();
+            CLOCK_updatePLL1clk();
+        }
+
+        private void textBoxSpecifyEntrypoint_TextChanged(object sender, EventArgs e)
+        {
+            uint n;
+
+            // validate input
+            if (VAL_isHexNum(textBoxSpecifyEntrypoint.Text, out n))
+            {
+                // clear error
+                error.generalEntryPoint.Clear();
+
+                // save new entrypoint
+                options.entrypoint = n;
+            }
+            else
+            {
+                // raise error
+                error.generalEntryPoint.SetError(textBoxSpecifyEntrypoint,
+                    "Must be a 32-bit hexadecimal number.");
+            }
+        }
+
+        private void textBoxFlashTiming_TextChanged(object sender, EventArgs e)
+        {
+            uint n;
+
+            // validate input
+            if (VAL_isHexNum(textBoxFlashTiming.Text, out n))
+            {
+                // clear error
+                error.flashTiming.Clear();
+
+                // save new value
+                options.boot.flashTiming = n;
+                options.boot.saveFlash();
+            }
+            else
+            {
+                // raise error
+                error.flashTiming.SetError(textBoxFlashTiming,
+                    "Must be a 32-bit hexadecimal number.");
+            }
+        }
+        
+        private void textBoxPeriphClockIdeal_TextChanged(object sender, EventArgs e)
+        {
+            // validate input
+            VAL_checkRange(textBoxPeriphClockIdeal, (double)options.boot.minSpeed, (double)options.boot.maxSpeed,
+                error.periphIdealClock, out options.boot.targetSpeed);
+
+            // save new input
+            options.boot.saveSpeed();
+
+            // update peripheral clock calculations
+            CLOCK_updatePeriphClk();
+        }
+
+        private void textBoxPLL0preDiv_TextChanged(object sender, EventArgs e)
+        {
+            // validate input
+            VAL_checkRange(textBoxPLL0preDiv, (int)Consts.ClockDiv.min, (int)Consts.ClockDiv.max,
+                error.pll0preDiv, out options.pll0preDiv);
+
+            // update PLL0 calculations
+            CLOCK_updatePLL0clk();
+        }
+
+        private void textBoxPLL0mult_TextChanged(object sender, EventArgs e)
+        {
+            // validate input
+            VAL_checkRange(textBoxPLL0mult, (int)Consts.ClockMult.min, (int)Consts.ClockMult.max,
+                error.pll0mult, out options.pll0Mult);
+
+            // update PLL0 calculations
+            CLOCK_updatePLL0clk();
+        }
+
+        private void textBoxPLL0postDiv_TextChanged(object sender, EventArgs e)
+        {
+            // validate input
+            VAL_checkRange(textBoxPLL0postDiv, (int)Consts.ClockDiv.min, (int)Consts.ClockDiv.max,
+                error.pll0postDiv, out options.pll0postDiv);
+
+            // update PLL0 calculations
+            CLOCK_updatePLL0clk();
+        }
+
+        private void textBoxPLL0div1_TextChanged(object sender, EventArgs e)
+        {
+            // validate input
+            VAL_checkRange(textBoxPLL0div1, (int)Consts.ClockDiv.min, (int)Consts.ClockDiv.max,
+                error.pll0div1, out options.pll0div1);
+
+            // update PLL0 calculations
+            CLOCK_updatePLL0clk();
+        }
+
+        private void textBoxPLL0div3_TextChanged(object sender, EventArgs e)
+        {
+            // validate input
+            VAL_checkRange(textBoxPLL0div3, (int)Consts.ClockDiv.min, (int)Consts.ClockDiv.max,
+                error.pll0div3, out options.pll0div3);
+
+            // update PLL0 calculations
+            CLOCK_updatePLL0clk();
+        }
+
+        private void textBoxPLL0div7_TextChanged(object sender, EventArgs e)
+        {
+            // validate input
+            VAL_checkRange(textBoxPLL0div7, (int)Consts.ClockDiv.min, (int)Consts.ClockDiv.max,
+                error.pll0div7, out options.pll0div7);
+
+            // update PLL0 calculations
+            CLOCK_updatePLL0clk();
+        }
+
+        private void textBoxSDRAMsdbcr_TextChanged(object sender, EventArgs e)
+        {
+            uint n;
+
+            // validate input
+            if (VAL_isHexNum(textBoxSDRAMsdbcr.Text, out n))
+            {
+                // clear error
+                error.sdramSdbcr.Clear();
+
+                // save new entrypoint
+                options.sdramSdbcr = n;
+            }
+            else
+            {
+                // raise error
+                error.sdramSdbcr.SetError(textBoxSDRAMsdbcr,
+                    "Must be a 32-bit hexadecimal number.");
+            }
+        }
+
+        private void textBoxSDRAMsdtmr_TextChanged(object sender, EventArgs e)
+        {
+            uint n;
+
+            // validate input
+            if (VAL_isHexNum(textBoxSDRAMsdtmr.Text, out n))
+            {
+                // clear error
+                error.sdramSdtmr.Clear();
+
+                // save new entrypoint
+                options.sdramSdtmr = n;
+            }
+            else
+            {
+                // raise error
+                error.sdramSdtmr.SetError(textBoxSDRAMsdtmr,
+                    "Must be a 32-bit hexadecimal number.");
+            }
+        }
+
+        private void textBoxSDRAMsdrsrpdexit_TextChanged(object sender, EventArgs e)
+        {
+            uint n;
+
+            // validate input
+            if (VAL_isHexNum(textBoxSDRAMsdrsrpdexit.Text, out n))
+            {
+                // clear error
+                error.sdramSdrsrpdexit.Clear();
+
+                // save new entrypoint
+                options.sdramSdrsrpdexit = n;
+            }
+            else
+            {
+                // raise error
+                error.sdramSdrsrpdexit.SetError(textBoxSDRAMsdrsrpdexit,
+                    "Must be a 32-bit hexadecimal number.");
+            }
+        }
+
+        private void textBoxSDRAMsdrcr_TextChanged(object sender, EventArgs e)
+        {
+            uint n;
+
+            // validate input
+            if (VAL_isHexNum(textBoxSDRAMsdrcr.Text, out n))
+            {
+                // clear error
+                error.sdramSdrcr.Clear();
+
+                // save new entrypoint
+                options.sdramSdrcr = n;
+            }
+            else
+            {
+                // raise error
+                error.sdramSdrcr.SetError(textBoxSDRAMsdrcr,
+                    "Must be a 32-bit hexadecimal number.");
+            }
+        }
+
+        private void textBoxPLL1mult_TextChanged(object sender, EventArgs e)
+        {
+            // validate input
+            VAL_checkRange(textBoxPLL1mult, (int)Consts.ClockMult.min, (int)Consts.ClockMult.max,
+                error.pll1mult, out options.pll1Mult);
+
+            // update PLL1 calculations
+            CLOCK_updatePLL1clk();
+        }
+
+        private void textBoxPLL1postDiv_TextChanged(object sender, EventArgs e)
+        {
+            // validate input
+            VAL_checkRange(textBoxPLL1postDiv, (int)Consts.ClockDiv.min, (int)Consts.ClockDiv.max,
+                error.pll1postDiv, out options.pll1postDiv);
+
+            // update PLL1 calculations
+            CLOCK_updatePLL1clk();
+        }
+
+        private void textBoxPLL1div1_TextChanged(object sender, EventArgs e)
+        {
+            // validate input
+            VAL_checkRange(textBoxPLL1div1, (int)Consts.ClockDiv.min, (int)Consts.ClockDiv.max,
+                error.pll1div1, out options.pll1div1);
+
+            // update PLL1 calculations
+            CLOCK_updatePLL1clk();
+        }
+
+        private void textBoxPLL1div2_TextChanged(object sender, EventArgs e)
+        {
+            // validate input
+            VAL_checkRange(textBoxPLL1div2, (int)Consts.ClockDiv.min, (int)Consts.ClockDiv.max,
+                error.pll1div2, out options.pll1div2);
+
+            // update PLL1 calculations
+            CLOCK_updatePLL1clk();
+        }
+
+        private void textBoxPLL1div3_TextChanged(object sender, EventArgs e)
+        {
+            // validate input
+            VAL_checkRange(textBoxPLL1div3, (int)Consts.ClockDiv.min, (int)Consts.ClockDiv.max,
+                error.pll1div3, out options.pll1div3);
+
+            // update PLL1 calculations
+            CLOCK_updatePLL1clk();
+        }
+
+        private void textBoxDDR2phy_TextChanged(object sender, EventArgs e)
+        {
+            uint n;
+
+            // validate input
+            if (VAL_isHexNum(textBoxDDR2phy.Text, out n))
+            {
+                // clear error
+                error.ddr2phy.Clear();
+
+                // save new entrypoint
+                options.ddr2Phy = n;
+            }
+            else
+            {
+                // raise error
+                error.ddr2phy.SetError(textBoxDDR2phy,
+                    "Must be a 32-bit hexadecimal number.");
+            }
+        }
+
+        private void textBoxDDR2sdcr_TextChanged(object sender, EventArgs e)
+        {
+            uint n;
+
+            // validate input
+            if (VAL_isHexNum(textBoxDDR2sdcr.Text, out n))
+            {
+                // clear error
+                error.ddr2sdcr.Clear();
+
+                // save new entrypoint
+                options.ddr2Sdcr = n;
+            }
+            else
+            {
+                // raise error
+                error.ddr2sdcr.SetError(textBoxDDR2sdcr,
+                    "Must be a 32-bit hexadecimal number.");
+            }
+        }
+
+        private void textBoxDDR2sdcr2_TextChanged(object sender, EventArgs e)
+        {
+            uint n;
+
+            // validate input
+            if (VAL_isHexNum(textBoxDDR2sdcr2.Text, out n))
+            {
+                // clear error
+                error.ddr2sdcr2.Clear();
+
+                // save new entrypoint
+                options.ddr2Sdcr2 = n;
+            }
+            else
+            {
+                // raise error
+                error.ddr2sdcr2.SetError(textBoxDDR2sdcr2,
+                    "Must be a 32-bit hexadecimal number.");
+            }
+        }
+
+        private void textBoxDDR2sdtimr_TextChanged(object sender, EventArgs e)
+        {
+            uint n;
+
+            // validate input
+            if (VAL_isHexNum(textBoxDDR2sdtimr.Text, out n))
+            {
+                // clear error
+                error.ddr2sdtimr.Clear();
+
+                // save new entrypoint
+                options.ddr2Sdtimr = n;
+            }
+            else
+            {
+                // raise error
+                error.ddr2sdtimr.SetError(textBoxDDR2sdtimr,
+                    "Must be a 32-bit hexadecimal number.");
+            }
+        }
+
+        private void textBoxDDR2sdtimr2_TextChanged(object sender, EventArgs e)
+        {
+            uint n;
+
+            // validate input
+            if (VAL_isHexNum(textBoxDDR2sdtimr2.Text, out n))
+            {
+                // clear error
+                error.ddr2sdtimr2.Clear();
+
+                // save new entrypoint
+                options.ddr2Sdtimr2 = n;
+            }
+            else
+            {
+                // raise error
+                error.ddr2sdtimr2.SetError(textBoxDDR2sdtimr2,
+                    "Must be a 32-bit hexadecimal number.");
+            }
+        }
+
+        private void textBoxDDR2sdrcr_TextChanged(object sender, EventArgs e)
+        {
+            uint n;
+
+            // validate input
+            if (VAL_isHexNum(textBoxDDR2sdrcr.Text, out n))
+            {
+                // clear error
+                error.ddr2sdrcr.Clear();
+
+                // save new entrypoint
+                options.ddr2Sdrcr = n;
+            }
+            else
+            {
+                // raise error
+                error.ddr2sdrcr.SetError(textBoxDDR2sdrcr,
+                    "Must be a 32-bit hexadecimal number.");
+            }
+        }
+
+        private void textBoxLps0Enable_TextChanged(object sender, EventArgs e)
+        {
+            VAL_checkLpscBox(textBoxLps0Enable, error.lpsc0enable, out options.lpsc0enable, 0);
+        }
+
+        private void textBoxLps0Disable_TextChanged(object sender, EventArgs e)
+        {
+            VAL_checkLpscBox(textBoxLps0Disable, error.lpsc0disable, out options.lpsc0disable, 0);
+        }
+
+        private void textBoxLps0SyncRst_TextChanged(object sender, EventArgs e)
+        {
+            VAL_checkLpscBox(textBoxLps0SyncRst, error.lpsc0syncRst, out options.lpsc0syncRst, 0);
+        }
+
+        private void textBoxLps1Enable_TextChanged(object sender, EventArgs e)
+        {
+            VAL_checkLpscBox(textBoxLps1Enable, error.lpsc1enable, out options.lpsc1enable, 1);
+
+            // don't perform additional checking if an error has already occurred
+            if (error.lpsc1enable.GetError(textBoxLps1Enable) != "")
+                return;
+
+            // special case: do not allow SATA (PSC1 8) to be enabled
+            foreach (int psc in options.lpsc1enable)
+                if (psc == 8)
+                    error.lpsc1enable.SetError(textBoxLps1Enable, "Cannot enable PSC1 module 8 because it requires forced transition");
+        }
+
+        private void textBoxLps1Disable_TextChanged(object sender, EventArgs e)
+        {
+            VAL_checkLpscBox(textBoxLps1Disable, error.lpsc1disable, out options.lpsc1disable, 1);
+        }
+
+        private void textBoxLps1SyncRst_TextChanged(object sender, EventArgs e)
+        {
+            VAL_checkLpscBox(textBoxLps1SyncRst, error.lpsc1syncRst, out options.lpsc1syncRst, 1);
+        }
+
+        private void textBoxPinmuxVal_TextChanged(object sender, EventArgs e)
+        {
+            uint n;
+
+            // identify caller (fall out and do nothing if not recognized)
+            for (int i = 0; i < 20; i++)
+                if (sender == textBoxPinmux[i])
+                {
+                    // validate input
+                    if (VAL_isHexNum(textBoxPinmux[i].Text, out n) && VAL_isPinmuxDigits(textBoxPinmux[i].Text))
+                    {
+                        // save value
+                        options.pinmuxVal[i] = Convert.ToUInt32(textBoxPinmux[i].Text, 16);
+
+                        // clear error
+                        error.pinmux[i].Clear();
+                    }
+                    else
+                    {
+                        // raise error
+                        error.pinmux[i].SetError(textBoxPinmux[i],
+                            "Must be a 32-bit hexadecimal number with digits 0, 1, 2, 4, or 8.");
+                    }
+
+                    break;
+                }
+        }
+
+        private void textBoxAppFiles_TextChanged(object sender, EventArgs e)
+        {
+            VAL_checkAppFileNames(textBoxAppFiles.Text);
+        }
+
+        private void textBoxAISfile_TextChanged(object sender, EventArgs e)
+        {
+            options.aisFileName = textBoxAISfile.Text;
+            VAL_checkAisFileName(options.aisFileName);
+        }
+
+        #endregion
+
+        #region Methods - Clock Calculation
+
+        private void CLOCK_updatePeriphClk()
+        {
+            int psc, div;
+            double modClk, maxModClk, pscClk, actualClk;
+
+            // check for input errors before beginning (check pll0 errors only if pll0 configured)
+            if ( error.anyInputPeriph() || (options.configPll0 && error.anyInputPLL0()) )
+            {
+                // clear calculated fields
+                textBoxPeriphModuleClock.Clear();
+                textBoxPeriphClockActual.Clear();
+
+                // clear calculation errors and return (input errors already prevent AIS generation)
+                error.periphModuleClock.Clear();
+                return;
+            }
+            else
+            {
+                // find module clock; use PLL0 configuration or assume bypass
+                CLOCK_findModuleClk(out modClk, out maxModClk);
+            }
+
+            // display module clock
+            textBoxPeriphModuleClock.Text = modClk.ToString("f2");
+            // raise error if out of range (and abort divisor calculation)
+            VAL_checkRange(textBoxPeriphModuleClock, (double)Consts.ClockI2Cmod.min, maxModClk,
+                error.periphModuleClock, out modClk);
+            if (error.periphModuleClock.GetError(textBoxPeriphModuleClock) != "")
+            {
+                textBoxPeriphClockActual.Clear();
+                return;
+            }
+
+            // find divisor(s) and actual speed
+            if (options.boot.isI2c)
+            {
+                CLOCK_findI2Cdivs(modClk, out psc, out div, out pscClk, out actualClk);
+
+                // raise error and abort if pre-scaled module clock falls outside 7-13 MHz range
+                if (pscClk < 7.0 || pscClk > 13.0)
+                {
+                    error.periphModuleClock.SetError(textBoxPeriphModuleClock,
+                        "Must allow division to 7-13 MHz range with integer divisor.");
+                    textBoxPeriphClockActual.Clear();
+                    return;
+                }
+            }
+            else if (options.boot.isSpi)
+                CLOCK_findSPIdivs(modClk, out psc, out div, out actualClk);
+            else if (options.boot.isUart)
+            {
+                CLOCK_findUARTdivs(modClk, out psc, out div, out actualClk);
+
+                // raise error if specified and actual clocks are > 10% different
+                if (VAL_percentDiff(options.boot.targetSpeed, actualClk) > 10)
+                {
+                    error.periphIdealClock.SetError(textBoxPeriphClockIdeal,
+                        "Cannot find UART divisor to reach speed within 10% of target.");
+                }
+            }
+            else if (options.boot.isMmcsd)
+                CLOCK_findMMCSDdivs(modClk, out psc, out div, out actualClk);
+            else
+                return; // invalid mode; should never come here
+
+            // show actual speed
+            textBoxPeriphClockActual.Text = actualClk.ToString("f2");
+
+            // save divisors
+            options.boot.psc = psc;
+            options.boot.div = div;
+
+            // DEBUG: display divisor values we arrived at
+            //LOG_msg(String.Format("Using (psc, div) = ({0}, {1})", psc, div));
+        }
+
+        public void CLOCK_findModuleClk(out double modClk, out double maxModClk)
+        {
+            // find sys clocks for bypass clock or configured pll0
+            double sysClk2, sysClk4, auxClk;
+
+            try
+            {
+                sysClk2 = (options.configPll0) ? (Convert.ToDouble(textBoxPLL0cpu.Text) / 2.0) :
+                    (Convert.ToDouble(textBoxClockSpeed.Text) / 2.0);
+                sysClk4 = (options.configPll0) ? (Convert.ToDouble(textBoxPLL0cpu.Text) / 4.0) :
+                    (Convert.ToDouble(textBoxClockSpeed.Text) / 4.0);
+                auxClk = (options.configPll0) ? Convert.ToDouble(textBoxClockSpeed.Text) :
+                    (Convert.ToDouble(textBoxClockSpeed.Text));
+            }
+            catch
+            {
+                // most likely error: pll0 text boxes are not set yet.  Abort and let pll0 update
+                // re-call this function
+                modClk = 0.0;
+                maxModClk = 0.0;
+                return;
+            }
+
+            // find module clock
+            if (options.boot.name.Contains("I2C0"))
+            {
+                modClk = auxClk;
+                maxModClk = (double)Consts.ClockAUX.max;
+            }
+            else if (options.boot.name.Contains("I2C1"))
+            {
+                modClk = sysClk4;
+                maxModClk = (double)Consts.ClockSYS4.max;
+            }
+            else if (options.boot.isSpi || options.boot.isUart || options.boot.isMmcsd)
+            {
+                modClk = sysClk2;
+                maxModClk = (double)Consts.ClockSYS2.max;
+            }
+            else
+            {
+                modClk = 0.0; // invalid boot mode
+                maxModClk = 0.0;
+            }
+        }
+
+        public void CLOCK_findI2Cdivs(double modClk, out int psc, out int div, out double pscClk, out double actualClk)
+        {
+            int divAdd;
+
+            // find psc (target 10 MHz psc clk)
+            psc = Convert.ToInt32(modClk / 10.0);
+            // enforce minimum 1
+            if (psc < 1) psc = 1;
+            // enforce maximum of 256
+            if (psc > 256) psc = 256;
+            pscClk = modClk / (double)psc;
+
+            // find div
+            if (psc > 2)
+                divAdd = 5;
+            else if (psc == 2)
+                divAdd = 6;
+            else
+                divAdd = 7;
+
+            div = (int)(1000.0 * pscClk / options.boot.targetSpeed / 2.0 - divAdd);
+            // enforce minimum 1
+            if (div < 1) div = 1;
+
+            // find actual speed
+            actualClk = 1000.0 * pscClk / (2.0 * (div + divAdd));
+
+            // don't allow actual speed > target speed
+            while (actualClk > options.boot.targetSpeed && div < 0xFF)
+            {
+                div++;
+                actualClk = 1000.0 * pscClk / (2.0 * (div + divAdd));
+            }
+
+            // enforce maximum of 255
+            if (div > 255)
+            {
+                div = 255;
+                actualClk = 1000.0 * pscClk / (2.0 * (div + divAdd));
+            }
+        }
+
+        public void CLOCK_findSPIdivs(double modClk, out int psc, out int div, out double actualClk)
+        {
+            // find psc
+            psc = (int)(modClk / options.boot.targetSpeed);
+            // enforce minimum 2
+            if (psc < 2) psc = 2;
+
+            // force div to 1 (not used)
+            div = 1;
+
+            // find actual speed
+            actualClk = modClk / (double)psc;
+
+            // don't allow actual speed > target speed
+            while (actualClk > options.boot.targetSpeed && psc < 0xFF)
+            {
+                psc++;
+                actualClk = modClk / (double)psc;
+            }
+
+            // enforce maximum of 256
+            if (psc > 256)
+            {
+                psc = 256;
+                actualClk = modClk / (double)psc;
+            }
+        }
+
+        public void CLOCK_findUARTdivs(double modClk, out int psc, out int div, out double actualClk)
+        {
+            // force psc to 1 (not used)
+            psc = 1;
+
+            // find div
+            div = (int)(modClk * 1000000.0 / (options.boot.targetSpeed * 13.0));
+            // enforce minimum 1
+            if (div < 1) div = 1;
+
+            // enforce maximum of 65535 (0xFFFF)
+            if (div > 65535) div = 65535;
+
+            // find actual speed
+            actualClk = modClk * 1000000.0 / (div * 13.0);
+        }
+
+        public void CLOCK_findMMCSDdivs(double modClk, out int psc, out int div, out double actualClk)
+        {
+            // psc represents DIV4; always use 0 for finer control
+            psc = 0;
+
+            // find div
+            div = (int)(modClk / (options.boot.targetSpeed * 2.0)) - 1;
+
+            // enforce minimum 0, maximum 255 (0xFF)
+            if (div < 0)   div = 0;
+            if (div > 255) div = 255;
+
+            // find actual speed
+            actualClk = modClk  / (2.0 * (div + 1));
+        }
+
+        private void CLOCK_updatePLL0clk()
+        {
+            // check for input errors before beginning
+            if (error.anyInputPLL0())
+            {
+                // clear calculated fields
+                textBoxPLL0cpu.Clear();
+                textBoxPLL0emac.Clear();
+
+                // clear calculation errors (input errors already prevent AIS generation)
+                error.pll0cpu.Clear();
+                error.pll0emac.Clear();
+            }
+            else
+            {
+                // compute fields and fill in text boxes
+                double pllCore = options.inputClock / (double)options.pll0preDiv
+                    * (double)options.pll0Mult / (double)options.pll0postDiv;
+                double sysClk1 = pllCore / (double)options.pll0div1;
+                double sysClk7 = pllCore / (double)options.pll0div7;
+
+                textBoxPLL0cpu.Text = sysClk1.ToString("f2");
+                // raise error if out of range
+                VAL_checkRange(textBoxPLL0cpu, (double)Consts.ClockCPU.min,
+                    (double)Consts.ClockCPU.max, error.pll0cpu, out sysClk1);
+
+                textBoxPLL0emac.Text = sysClk7.ToString("f2");
+                // raise error if out of range
+                VAL_checkRange(textBoxPLL0emac, (double)Consts.ClockEMAC.min,
+                    (double)Consts.ClockEMAC.max, error.pll0emac, out sysClk7);
+            }
+
+            // update SDRAM clock and peripheral clocks
+            CLOCK_updateSDRAMclk();
+            CLOCK_updatePeriphClk();
+        }
+
+        private void CLOCK_updatePLL1clk()
+        {
+            // note: no PLL1 clocks calculated except DDR2
+            
+            // update DDR2 clock
+            CLOCK_updateDDR2clk();
+        }
+
+        private void CLOCK_updateSDRAMclk()
+        {
+            // check for input errors before beginning
+            if (error.anyInputSDRAM())
+            {
+                // clear calculated fields
+                textBoxPLL0sdram.Clear();
+                textBoxSDRAMclock.Clear();
+                
+                // clear calculation errors (input errors already prevent AIS generation)
+                error.pll0sdram.Clear();
+                error.sdramClock.Clear();
+            }
+            else
+            {
+                // compute fields and fill in text boxes
+                double pllCore = options.inputClock;
+                if (options.configPll0)
+                    pllCore = pllCore / (double)options.pll0preDiv
+                        * (double)options.pll0Mult / (double)options.pll0postDiv;
+
+                // divide by div3 or 4.5 depending on checkbox
+                double sysClk3 = (checkBoxSDRAMdiv.Checked) ? (pllCore / 4.5)
+                    : (pllCore / (double)options.pll0div3);
+
+                textBoxPLL0sdram.Text = sysClk3.ToString("f2");
+                // raise error if out of range
+                VAL_checkRange(textBoxPLL0sdram, (double)Consts.ClockSDRAM.min,
+                    (double)Consts.ClockSDRAM.max, error.pll0sdram, out sysClk3);
+
+                textBoxSDRAMclock.Text = sysClk3.ToString("f2");
+                // raise error if out of range
+                VAL_checkRange(textBoxSDRAMclock, (double)Consts.ClockSDRAM.min,
+                    (double)Consts.ClockSDRAM.max, error.sdramClock, out sysClk3);
+            }
+        }
+
+        private void CLOCK_updateDDR2clk()
+        {
+            // check for input errors before beginning
+            if (error.anyInputDDR2())
+            {
+                // clear calculated fields
+                textBoxPLL1ddr2.Clear();
+                textBoxDDR2clock.Clear();
+
+                // clear calculation errors (input errors already prevent AIS generation)
+                error.pll1ddr2.Clear();
+                error.ddr2Clock.Clear();
+            }
+            else
+            {
+                // compute fields and fill in text boxes
+                double pllCore = options.inputClock * (double)options.pll1Mult;
+                // skip division if checkbox says so
+                double sysClk1 = (checkBoxDDR2directClock.Checked) ? pllCore :
+                    (pllCore / (double)options.pll1postDiv / (double)options.pll1div1);
+
+                textBoxPLL1ddr2.Text = sysClk1.ToString("f2");
+                // raise error if out of range
+                VAL_checkRange(textBoxPLL1ddr2, (double)Consts.ClockDDR2.min,
+                    (double)Consts.ClockDDR2.max, error.pll1ddr2, out sysClk1);
+
+                textBoxDDR2clock.Text = sysClk1.ToString("f2");
+                // raise error if out of range
+                VAL_checkRange(textBoxDDR2clock, (double)Consts.ClockDDR2.min,
+                    (double)Consts.ClockDDR2.max, error.ddr2Clock, out sysClk1);
+            }
+        }
+
+        #endregion
+
+        #region Methods - AIS Generation
+
+        private IniFile INI_assemble(String[] appFileName, uint[] appFileAddr)
+        {
+            List<IniSection> streamSections = new List<IniSection>();
+            bool entryPointSet = false;
+
+            // 1. General section
+            streamSections.Add(INI_generalSection(ref entryPointSet));
+            
+            // 2. Insert seqread enable section command
+            if (options.enableSeqRead)
+            {
+                streamSections.Add(INI_seqReadEnableSection());
+            }
+            
+            // 3. NAND ECC Patch function
+            if (options.boot.isNAND)
+            {
+                /* The patch has only been written to comprehend PG2.0 or later */
+                if ((options.romID == (int)Consts.RomID.d800k006) ||
+                    (options.romID == (int)Consts.RomID.d800k008))
+                {
+                    streamSections.Add(INI_nandEccPatchSection());
+                }
+            }
+
+            // 4. PLL0 and peripheral config
+            if (options.configPeriph && options.configPll0)
+                streamSections.Add(INI_pll0andPeriphConfigSection());
+            else if (options.configPeriph && !options.boot.isUart)
+                streamSections.Add(INI_periphConfigSection());
+            else if (options.configPll0)
+                streamSections.Add(INI_pll0configSection());
+
+            // 5. PLL1 and DDR2 config
+            if (options.romID == (int)Consts.RomID.d800k002)
+            {
+                if (options.configDdr2)
+                {
+                    streamSections.Add(INI_pll1configSection());
+                    streamSections.Add(INI_ddr2patchConfigSection());
+                    if (options.useMDDR)
+                    {
+                               streamSections.Add(INI_mddrSlewConfigSection());
+                    }
+                }
+                else if (options.configPll1)
+                {
+                    streamSections.Add(INI_pll1configSection());
+                }
+            }
+            else
+            {
+                if (options.configDdr2)
+                {
+                    streamSections.Add(INI_ddr2configSection());
+                    if (options.useMDDR)
+                    {
+                       if(options.useDuplicateMddrSetting)
+                       {
+                          streamSections.Add(INI_ddr2configSection());     // work around for Winbond mDDR interface issue
+                       }
+                            //streamSections.Add(INI_mddrpatchConfigSection()); // work around for Winbond mDDR interface issue
+                       streamSections.Add(INI_mddrSlewConfigSection());
+                    }
+                }
+                else if (options.configPll1)
+                {
+                    streamSections.Add(INI_pll1configSection());
+                }
+            }
+
+            // 5. SDRAM config
+            if (options.configSdram)
+                streamSections.Add(INI_sdramConfigSection());
+
+            // 6. SDRAM chip select config?
+            if (options.boot.isFlash)
+                streamSections.Add(INI_sdramCsSection());
+
+            // 7. LPSC config
+            if (options.configLpsc)
+            {
+                for (int i = 0; i < options.lpsc0enable.Length; i++)
+                    streamSections.Add(INI_lpscConfigSection(0, options.lpsc0enable[i], (int)Consts.LpscDomain.enable));
+                for (int i = 0; i < options.lpsc0disable.Length; i++)
+                    streamSections.Add(INI_lpscConfigSection(0, options.lpsc0disable[i], (int)Consts.LpscDomain.disable));
+                for (int i = 0; i < options.lpsc0syncRst.Length; i++)
+                    streamSections.Add(INI_lpscConfigSection(0, options.lpsc0syncRst[i], (int)Consts.LpscDomain.syncRst));
+                for (int i = 0; i < options.lpsc1enable.Length; i++)
+                    streamSections.Add(INI_lpscConfigSection(1, options.lpsc1enable[i], (int)Consts.LpscDomain.enable));
+                for (int i = 0; i < options.lpsc1disable.Length; i++)
+                    streamSections.Add(INI_lpscConfigSection(1, options.lpsc1disable[i], (int)Consts.LpscDomain.disable));
+                for (int i = 0; i < options.lpsc1syncRst.Length; i++)
+                    streamSections.Add(INI_lpscConfigSection(1, options.lpsc1syncRst[i], (int)Consts.LpscDomain.syncRst));
+            }
+
+            // 8. Pinmux config
+            if (options.configPinmux)
+                for (int i = 0; i < 20; i++)
+                    if (options.pinmuxApply[i])
+                        streamSections.Add(INI_pinmuxConfigSection(options.pinmuxReg[i], options.pinmuxVal[i]));
+
+            // 9. Binary/Object file sections
+            for (int i = 0; i < appFileName.Length; i++)
+            {
+                if (VAL_appFileIsObj(appFileName[i]))
+                    streamSections.Add(INI_objectInputFileSection(appFileName[i], ref entryPointSet));
+                else
+                    streamSections.Add(INI_binaryInputFileSection(appFileName[i], appFileAddr[i], ref entryPointSet));
+            }
+
+            // return ini sections in array
+            return new IniFile(streamSections, "OMAP-L138_generated.ini");
+        }
+
+        private IniSection INI_generalSection(ref bool entryPointSet)
+        {
+            IniSection section = new IniSection();
+            section.sectionValues = new Hashtable();
+
+            section.sectionName = "GENERAL";
+            section.sectionValues["BUSWIDTH"] = (uint)8;  // TODO: make configurable (NOR, NAND)
+            section.sectionValues["BOOTMODE"] = "NONE";  // TODO: make configurable (NOR)
+            if (options.enableCRC)
+                section.sectionValues["CRCCHECKTYPE"] = "SECTION_CRC";
+            else
+                section.sectionValues["CRCCHECKTYPE"] = "NO_CRC";
+
+            if (options.specifyEntrypoint)
+            {
+                section.sectionValues["ENTRYPOINT"] = options.entrypoint;
+                entryPointSet = true;
+            }
+
+            return section;
+        }
+        
+        private IniSection INI_seqReadEnableSection()
+        {
+            IniSection section = new IniSection();
+            section.sectionName = "AIS_SeqReadEnable";
+            section.sectionValues = null;
+
+            return section;
+        }
+
+        private IniSection INI_binaryInputFileSection(String fileName, uint addr, ref bool entryPointSet)
+        {
+            IniSection section = new IniSection();
+            section.sectionValues = new Hashtable();
+
+            section.sectionName = "INPUTFILE";
+
+            section.sectionValues["FILENAME"] = fileName;
+            section.sectionValues["LOADADDRESS"] = addr;
+
+            return section;
+        }
+
+        private IniSection INI_objectInputFileSection(String fileName, ref bool entryPointSet)
+        {
+            IniSection section = new IniSection();
+            section.sectionValues = new Hashtable();
+
+            section.sectionName = "INPUTFILE";
+
+            section.sectionValues["FILENAME"] = fileName;
+            if (!entryPointSet && !options.specifyEntrypoint)
+            {
+                // only use entrypoint from first obj file
+                section.sectionValues["USEENTRYPOINT"] = "TRUE";
+                entryPointSet = true;
+            }
+
+            return section;
+        }
+
+        private IniSection INI_pll0configSection()
+        {
+            IniSection section = new IniSection();
+            section.sectionValues = new Hashtable();
+            uint cfg0, cfg1;
+
+            section.sectionName = "PLL0CONFIG";
+
+            // assemble config words
+            cfg0 = FORMAT_configWordBlob(options.clockType, options.pll0Mult - 1,
+                options.pll0preDiv - 1, options.pll0postDiv - 1);
+            cfg1 = FORMAT_configWordBlob(0, options.pll0div1 - 1,
+                options.pll0div3 - 1, options.pll0div7 - 1);
+
+            section.sectionValues["PLL0CFG0"] = cfg0;
+            section.sectionValues["PLL0CFG1"] = cfg1;
+
+            return section;
+
+            //; PLL0CFG0: | CLKMODE| PLLM   | PREDIV | POSTDIV|
+            //; PLL0CFG1: | RSVD   | PLLDIV1| PLLDIV3| PLLDIV7|
+            //[PLL0CONFIG]
+            //PLL0CFG0 = 0x00130001
+            //PLL0CFG1 = 0x00000104
+        }
+
+        private IniSection INI_periphConfigSection()
+        {
+            IniSection section = new IniSection();
+            section.sectionValues = new Hashtable();
+            uint cfg;
+
+            section.sectionName = "PERIPHCLKCFG";
+
+            // assemble config word
+            if (options.boot.isI2c)
+                cfg = FORMAT_configWordBlob(0, options.boot.psc - 1,
+                    options.boot.div, options.boot.div);
+            else if (options.boot.isSpi)
+                cfg = FORMAT_configWordBlob(0, 0, 0, options.boot.psc - 1);
+            else if (options.boot.isUart)
+                cfg = FORMAT_configWordBlob(0, 1, options.boot.div >> 8, options.boot.div);
+            else if (options.boot.isMmcsd)
+                cfg = FORMAT_configWordBlob(0, 0, options.boot.psc, options.boot.div);
+            else
+                cfg = 0; // should never reach here
+
+            section.sectionValues["PERIPHCLKCFG"] = cfg;
+
+            return section;
+
+            //; SPI:        |------24|------16|-------8|-------0|
+            //;             |           RSVD           |PRESCALE|
+            //;
+            //; I2C:        |------24|------16|-------8|-------0|
+            //;             |  RSVD  |PRESCALE|  CLKL  |  CLKH  |
+            //;
+            //; UART:       |------24|------16|-------8|-------0|
+            //;             | RSVD   |  OSR   |  DLH   |  DLL   |
+            //[PERIPHCLKCFG]
+            //PERIPHCLKCFG = 0x00000000
+        }
+
+        private IniSection INI_pll0andPeriphConfigSection()
+        {
+            // combine pll0 and periph config sections
+            IniSection sectionA = INI_pll0configSection();
+            IniSection sectionB = INI_periphConfigSection();
+
+            sectionA.sectionName = "PLLANDCLOCKCONFIG";
+            sectionA.sectionValues["PERIPHCLKCFG"] = sectionB.sectionValues["PERIPHCLKCFG"];
+
+            return sectionA;
+        }
+
+        private IniSection INI_pll1configSection()
+        {
+            IniSection section = new IniSection();
+            section.sectionValues = new Hashtable();
+            uint cfg0, cfg1;
+
+            section.sectionName = "PLL1CONFIG";
+
+            // assemble config words
+            cfg0 = FORMAT_configWordBlob(options.pll1Mult - 1, options.pll1postDiv - 1,
+                options.pll1div1 - 1, options.pll1div2 - 1);
+            cfg1 = FORMAT_configWordBlob(0, 0, 0, options.pll1div3 - 1);
+
+            section.sectionValues["PLL1CFG0"] = cfg0;
+            section.sectionValues["PLL1CFG1"] = cfg1;
+
+            return section;
+
+            //;           |------24|------16|-------8|-------0|
+            //; PLL1CFG0: |    PLLM| POSTDIV| PLLDIV1| PLLDIV2|
+            //; PLL1CFG1: |           RSVD           | PLLDIV3|
+            //[PLL1CONFIG]
+            //PLL1CFG0 = 0x00000000
+            //PLL1CFG1 = 0x00000000
+        }
+
+        private IniSection INI_ddr2configSection()
+        {
+            // start with PLL1 config section
+            IniSection section = INI_pll1configSection();
+
+            // only apply sdcr2 value for mDDR
+            uint temp_sdcr2 = options.useMDDR ? options.ddr2Sdcr2 : 0;
+
+            section.sectionName = "EMIF3DDR";
+
+            section.sectionValues["DDRPHYC1R"] = options.ddr2Phy;
+            section.sectionValues["SDCR"] = options.ddr2Sdcr;
+            section.sectionValues["SDTIMR"] = options.ddr2Sdtimr;
+            section.sectionValues["SDTIMR2"] = options.ddr2Sdtimr2;
+            section.sectionValues["SDRCR"] = options.ddr2Sdrcr;
+            if (options.ddr2directClk)
+            {
+                section.sectionValues["CLK2XSRC"] = (temp_sdcr2 & 0x00FF0000) |
+                                                    ((temp_sdcr2 & 0xFF) << 8) |
+                                                    (uint)1;
+            }
+            else
+            {
+                section.sectionValues["CLK2XSRC"] = (temp_sdcr2 & 0x00FF0000) |
+                                                    ((temp_sdcr2 & 0xFF) << 8) |
+                                                    (uint)0;
+            }
+            return section;
+
+            //[EMIF3DDR]
+            //PLL1CFG0 = 0x13010001
+            //PLL1CFG1 = 0x00000002
+            //DDRPHYC1R = 0x000000C4
+            //SDCR = 0x08134632
+            //SDCR2 = 0x00000000
+            //SDTIMR = 0x26922A09
+            //SDTIMR2 = 0x0014C722
+            //SDRCR = 0x00000492
+            //CLK2XSRC = 0x00000000
+        }
+
+        // Function to set DDR_PDENA and CMOSEN in DDR_SLEW register of SYSCFG1 module
+        // This is needed when using mDDR memory.
+        private IniSection INI_mddrSlewConfigSection()
+        {
+            IniSection section = new IniSection();
+            section.sectionValues = new Hashtable();
+
+            section.sectionName = "AIS_Set";
+
+            section.sectionValues["TYPE"]     = (uint) 0x00050404;
+            section.sectionValues["ADDRESS"]  = (uint) 0x01E2C004;
+            section.sectionValues["DATA"]     = (uint) 0x00000003;
+            section.sectionValues["SLEEP"]    = (uint) 0x00000000;
+
+            return section;
+        }
+
+        private IniSection INI_ddr2patchConfigSection()
+        {
+            // start with PLL1 config section
+            IniSection section = INI_pll1configSection();
+
+            // only apply sdcr2 value for mDDR
+            uint temp_sdcr2 = options.useMDDR ? options.ddr2Sdcr2 : 0;
+
+            if (options.deviceType == (int)Consts.BootType.dsp)
+            {
+                section.sectionName = "DSP_EMIF3DDR_PATCHFXN";
+            }
+            else if (options.deviceType == (int)Consts.BootType.arm)
+            {
+                section.sectionName = "ARM_EMIF3DDR_PATCHFXN";
+            }
+
+            section.sectionValues["DDRPHYC1R"] = options.ddr2Phy;
+            section.sectionValues["SDCR"] = options.ddr2Sdcr;
+            section.sectionValues["SDTIMR"] = options.ddr2Sdtimr;
+            section.sectionValues["SDTIMR2"] = options.ddr2Sdtimr2;
+            section.sectionValues["SDRCR"] = options.ddr2Sdrcr;
+            if (options.ddr2directClk)
+            {
+                section.sectionValues["CLK2XSRC"] = (temp_sdcr2 & 0x00FF0000) |
+                                                    ((temp_sdcr2 & 0xFF) << 8) |
+                                                    (uint)1;
+            }
+            else
+            {
+                section.sectionValues["CLK2XSRC"] = (temp_sdcr2 & 0x00FF0000) |
+                                                    ((temp_sdcr2 & 0xFF) << 8) |
+                                                    (uint)0;
+            }
+
+            return section;
+        }
+        
+        private IniSection INI_mddrpatchConfigSection()
+        {
+            IniSection section = new IniSection();
+            section.sectionValues = new Hashtable();
+            // Write to SDCR forces DDR controller to resend signals to mDDR which support SRR command.
+            section.sectionName = "AIS_Set";
+
+            section.sectionValues["TYPE"]     = (uint) 0x00000002;
+            section.sectionValues["ADDRESS"]  = (uint) 0xB0000008;
+            section.sectionValues["DATA"]     = (uint) options.ddr2Sdcr;
+            section.sectionValues["SLEEP"]    = (uint) 0x00000000;
+
+            return section;
+
+        }
+
+        private IniSection INI_nandEccPatchSection()
+        {
+            IniSection section = new IniSection();
+
+            if (options.deviceType == (int)Consts.BootType.dsp)
+            {
+                section.sectionName = "DSP_NAND_ECC_PATCHFXN";
+            }
+            else if (options.deviceType == (int)Consts.BootType.arm)
+            {
+                section.sectionName = "ARM_NAND_ECC_PATCHFXN";
+            }
+            
+            return section;
+        }
+
+        private IniSection INI_sdramConfigSection()
+        {
+            IniSection section = new IniSection();
+            section.sectionValues = new Hashtable();
+
+            section.sectionName = "EMIF25SDRAM";
+
+            section.sectionValues["SDBCR"] = options.sdramSdbcr;
+            section.sectionValues["SDTIMR"] = options.sdramSdtmr;
+            section.sectionValues["SDRSRPDEXIT"] = options.sdramSdrsrpdexit;
+            section.sectionValues["SDRCR"] = options.sdramSdrcr;
+            if (options.sdramDiv45)
+                section.sectionValues["DIV4P5_CLK_ENABLE"] = (uint)1;
+            else
+                section.sectionValues["DIV4P5_CLK_ENABLE"] = (uint)0;
+
+            return section;
+
+            //[EMIF25SDRAM]
+            //SDBCR = 0x00004421
+            //SDTIMR = 0x42215810
+            //SDRSRPDEXIT = 0x00000009
+            //SDRCR = 0x00000410
+            //DIV4p5_CLK_ENABLE = 0x00000001
+        }
+
+        private IniSection INI_sdramCsSection()
+        {
+            IniSection section = new IniSection();
+            section.sectionValues = new Hashtable();
+
+            section.sectionName = "EMIF25ASYNC";
+
+            if (options.boot.isNOR)
+            {
+                section.sectionValues["A1CR"] = options.boot.flashTiming;
+                section.sectionValues["A2CR"] = (uint)0;
+            }
+            else if (options.boot.isNAND)
+            {
+                section.sectionValues["A1CR"] = (uint)0;
+                section.sectionValues["A2CR"] = options.boot.flashTiming;
+            }
+            else
+            {
+                section.sectionValues["A1CR"] = (uint)0;
+                section.sectionValues["A2CR"] = (uint)0;
+            }
+
+            section.sectionValues["A3CR"] = (uint)0;
+            section.sectionValues["A4CR"] = (uint)0;
+
+            if (options.boot.isNAND)
+                section.sectionValues["NANDFCR"] = (uint)0x00000002;
+            else
+                section.sectionValues["NANDFCR"] = (uint)0;
+
+            return section;
+
+            //[EMIF25ASYNC]
+            //A1CR = 0x00000000
+            //A2CR = 0x00000000
+            //A3CR = 0x00000000
+            //A4CR = 0x00000000
+            //NANDFCR = 0x00000000
+        }
+
+        private IniSection INI_lpscConfigSection(int psc, int module, int state)
+        {
+            IniSection section = new IniSection();
+            section.sectionValues = new Hashtable();
+            uint cfg;
+            int pd;
+
+            // set pd to 1 for special cases: (psc, module) = (0, 15) or (1, 31)
+            if ((psc == 0 && module == 15) || (psc == 1 && module == 31))
+                pd = 1;
+            else
+                pd = 0;
+
+            section.sectionName = "PSCCONFIG";
+
+            cfg = FORMAT_configWordBlob(psc, module, pd, state);
+            section.sectionValues["LPSCCFG"] = cfg;
+
+            return section;
+
+            //;           |------24|------16|-------8|-------0|
+            //; LPSCCFG:  | PSCNUM | MODULE |   PD   | STATE  |
+            //[PSCCONFIG]
+            //LPSCCFG = 0x01030003
+        }
+
+        private IniSection INI_pinmuxConfigSection(int reg, uint val)
+        {
+            IniSection section = new IniSection();
+            section.sectionValues = new Hashtable();
+
+            section.sectionName = "PINMUX";
+
+            section.sectionValues["REGNUM"] = (uint)reg;
+            section.sectionValues["VALUE"] = val;
+            section.sectionValues["MASK"] = FORMAT_pinmuxMask(val);
+
+            return section;
+
+            //[PINMUX]
+            //REGNUM = 5
+            //MASK = 0x00FF0000
+            //VALUE = 0x00880000
+        }
+
+        #endregion
+
+        #region Methods - Input Validation and Formatting
+
+        private void VAL_checkRange(TextBox box, int min, int max, ErrorProvider err, out int y)
+        {
+            if (VAL_isRangeNum(box.Text, min, max, out y))
+            {
+                // clear error
+                err.Clear();
+            }
+            else
+            {
+                // raise error
+                err.SetError(box,
+                    String.Format("Must be a number between {0} and {1}.",
+                    min, max));
+            }
+        }
+
+        private void VAL_checkRange(TextBox box, double min, double max, ErrorProvider err, out double y)
+        {
+            if (VAL_isRangeNum(box.Text, min, max, out y))
+            {
+                // clear error
+                err.Clear();
+            }
+            else
+            {
+                // raise error
+                err.SetError(box,
+                    String.Format("Must be a number between {0:f2} and {1:f2}.",
+                    min, max));
+            }
+        }
+
+        private bool VAL_isRangeNum(String text, int min, int max, out int n)
+        {
+            // convert text to integer and check if it's in specified range
+
+            try
+            {
+                n = Convert.ToInt32(text);
+                if (n <= max && n >= min)
+                    return true;
+                else
+                    return false;
+            }
+            catch
+            {
+                // most likely exception: improperly formatted string
+                n = 0;
+                return false;
+            }
+        }
+
+        private bool VAL_isRangeNum(String text, double min, double max, out double n)
+        {
+            // convert text to integer and check if it's in specified range
+
+            try
+            {
+                n = Convert.ToDouble(text);
+                if (n <= max && n >= min)
+                    return true;
+                else
+                    return false;
+            }
+            catch
+            {
+                // most likely exception: improperly formatted string
+                n = 0;
+                return false;
+            }
+        }
+
+        private bool VAL_isHexNum(String text, out uint n)
+        {
+            // convert text to hex integer and check if it fits in 32-bit limit
+
+            try
+            {
+                n = Convert.ToUInt32(text, 16);
+                return true;
+            }
+            catch
+            {
+                // most likely exception: improperly formatted string OR out of bounds
+                n = 0;
+                return false;
+            }
+        }
+
+        private bool VAL_isHexNum(String text)
+        {
+            // convert text to hex integer and check if it fits in 32-bit limit
+            uint n;
+
+            try
+            {
+                n = Convert.ToUInt32(text, 16);
+                return true;
+            }
+            catch
+            {
+                // most likely exception: improperly formatted string OR out of bounds
+                n = 0;
+                return false;
+            }
+        }
+
+        private bool VAL_isPinmuxDigits(String text)
+        {
+            for (int i = 0; i < text.Length; i++)
+
+                if (text[i] != '0' && text[i] != '1' && text[i] != '2' && text[i] != '4'
+                    && text[i] != '8' && text[i] != 'x' && text[i] != 'X')
+                    return false;
+
+            return true;
+        }
+
+        private void VAL_checkLpscBox(TextBox box, ErrorProvider err, out int[] storage, int lpscNum)
+        {
+            char[] numSeparators = { ';' };
+            int min, max;
+
+            if (lpscNum == 0)
+            {
+                min = (int)Consts.LpscDomain.min0;
+                max = (int)Consts.LpscDomain.max0;
+            }
+            else if (lpscNum == 1)
+            {
+                min = (int)Consts.LpscDomain.min1;
+                max = (int)Consts.LpscDomain.max1;
+            }
+            else
+            {
+                // invalid
+                min = 2;
+                max = 1;
+            }
+
+            // clear error
+            err.Clear();
+
+            // break up text into ; separated strings
+            String[] domain = box.Text.Split(numSeparators, StringSplitOptions.RemoveEmptyEntries);
+            int domainCnt = domain.Length;
+
+            // create new array to store power domains
+            storage = new int[domainCnt];
+
+            // abort if no numbers
+            if (domainCnt < 1) return;
+
+            // validate substrings (numeric)
+            for (int i = 0; i < domainCnt; i++)
+            {
+                if (VAL_isRangeNum(domain[i], min, max, out storage[i]))
+                {
+                    // VAL_isRangeNum saves domain number to array
+                }
+                else
+                {
+                    // raise error
+                    err.SetError(box, String.Format(
+                        "Must list LPSC numbers between {0} and {1} separated by \';\'",
+                        min, max));
+
+                    break;
+                }
+            }
+        }
+
+        private void VAL_checkAppFileNames(String text)
+        {
+            int i, j, appFileCnt;
+            char[] fileNameSeparators = { ';' };
+            char fileAddrMarker = '@';
+
+            // clear error to start
+            error.appFiles.Clear();
+
+            // check for zero-length input first
+            if (text.Length == 0)
+            {
+                error.appFiles.SetError(textBoxAppFiles, "Must specify at least one application file.");
+                return;
+            }
+
+            // break up string into array of file names (separated by ";")
+            options.appFileName = text.Split(fileNameSeparators, StringSplitOptions.RemoveEmptyEntries);
+            appFileCnt = options.appFileName.Length;
+            options.appFileAddr = new uint[appFileCnt];
+
+            // fail if no file names found (i.e. textbox empty or all ";;;;")
+            if (appFileCnt < 1)
+            {
+                error.appFiles.SetError(textBoxAppFiles, "Must specify at least one application file.");
+                return;
+            }
+
+            // check files for specified load addresses ("file.bin@<hex addr>")
+            for (i = 0; i < appFileCnt; i++)
+            {
+                j = options.appFileName[i].IndexOf(fileAddrMarker);
+
+                // save address (and remove from file name) if one is present
+                if (j != -1)
+                {
+                    try
+                    {
+                        // save address
+                        options.appFileAddr[i] = Convert.ToUInt32(options.appFileName[i].Substring(j + 1), 16);
+                    }
+                    catch
+                    {
+                        // numeric conversion failed; invalid address specification
+                        
+                        error.appFiles.SetError(textBoxAppFiles,
+                            "Invalid address specified: " + options.appFileName[i].Substring(j + 1));
+                        return;
+                    }
+
+                    // remove address from file name
+                    options.appFileName[i] = options.appFileName[i].Remove(j);
+                }
+                else
+                    options.appFileAddr[i] = (uint)Consts.BinAddr.invalid;
+
+                // check if file exists; fail if it doesn't
+                if (!File.Exists(options.appFileName[i]))
+                {
+                    error.appFiles.SetError(textBoxAppFiles,
+                        "Cannot find application file " + options.appFileName[i]);
+                    return;
+                }
+            }
+        }
+
+        private bool VAL_appFileIsObj(String fileName)
+        {
+            if (ElfFile.IsElfFile(fileName) || CoffFile.IsCoffFile(fileName))
+                return true;
+            else
+                return false;
+        }
+
+        private bool VAL_appFileIsBin(String fileName)
+        {
+            return !VAL_appFileIsObj(fileName);
+        }
+
+        private bool VAL_appFilesAllObj()
+        {
+            for (int i = 0; i < options.appFileName.Length; i++)
+                if (!ElfFile.IsElfFile(options.appFileName[i]) &&
+                    !CoffFile.IsCoffFile(options.appFileName[i]))
+                {
+                    return false;
+                }
+
+            return true;
+        }
+
+        private bool VAL_appFilesAllBinary()
+        {
+            for (int i = 0; i < options.appFileName.Length; i++)
+                if (ElfFile.IsElfFile(options.appFileName[i]) ||
+                    CoffFile.IsCoffFile(options.appFileName[i]))
+                {
+                    return false;
+                }
+
+            return true;
+        }
+
+        private void VAL_checkAisFileName(String text)
+        {
+            // raise error on blank input
+            if (text.Length == 0)
+                error.aisFile.SetError(textBoxAISfile, "Must specify an output file.");
+            else
+                error.aisFile.Clear();
+        }
+
+        private void VAL_checkBootMode()
+        {
+            // raise error if MMC/SD boot is selected for older ROM revisions
+            if (options.boot.isMmcsd && 
+                (options.romID == (int)Consts.RomID.d800k002 ||
+                 options.romID == (int)Consts.RomID.d800k004 ||
+                 options.romID == (int)Consts.RomID.d800k006))
+                error.generalBootMode.SetError(comboBoxBootMode, "MMC/SD boot mode is not supported for this ROM revision.");
+            else
+                error.generalBootMode.Clear();
+        }
+
+        private bool VAL_errorsRaised()
+        {
+            // check for parameter errors in all active tabs
+            bool err = error.anyGeneral();
+
+            if (options.configPeriph)
+                err |= error.anyInputPeriph() | error.anyCalcPeriph();
+            if (options.configPll0)
+                err |= error.anyInputPLL0() | error.anyCalcPLL0();
+            if (options.configPll1)
+                err |= error.anyInputPLL1() | error.anyCalcPLL1();
+            if (options.configSdram)
+                err |= error.anyInputSDRAM() | error.anyCalcSDRAM();
+            if (options.configDdr2)
+                err |= error.anyInputDDR2() | error.anyCalcDDR2();
+            if (options.configLpsc)
+                err |= error.anyLpsc();
+            if (options.configPinmux)
+                err |= error.anyPinmux();
+
+            return err;
+        }
+
+        private double VAL_percentDiff(double x1, double x2)
+        {
+            return Math.Abs((x1 - x2) / x1 * 100);
+        }
+
+        private uint FORMAT_pinmuxMask(uint val)
+        {
+            uint maskVal = 0;
+
+            // note: input must be 32-bit hex value
+            for (int i = 0; i < 8; i++)
+                if (((val >> (i * 4)) & 0xF) != 0)
+                    maskVal |= ((uint)0xF << (i * 4));
+
+            return maskVal;
+        }
+
+        private String FORMAT_32bHexString(uint val)
+        {
+            String text = String.Format("0x{0:X}", val);
+            String zeros = "00000000";
+            int n = text.Length;
+
+            // insert leading zeros if necessary
+            if (n < 10)
+                text = text.Insert(2, zeros.Substring(0, 10 - n));
+            //for (int i = 0; i < 10 - n; i++)
+            //    text = text.Insert(2, "0");
+
+            return text;
+        }
+
+        private uint FORMAT_configWordBlob(uint b3, uint b2, uint b1, uint b0)
+        {
+            // saturate values
+            if (b0 > 0xFF) b0 = 0xFF;
+            if (b1 > 0xFF) b1 = 0xFF;
+            if (b2 > 0xFF) b2 = 0xFF;
+            if (b3 > 0xFF) b3 = 0xFF;
+
+            return ((b3 & 0xFF) << 24) |
+                ((b2 & 0xFF) << 16) |
+                ((b1 & 0xFF) << 8) |
+                (b0 & 0xFF);
+        }
+
+        private uint FORMAT_configWordBlob(int b3, int b2, int b1, int b0)
+        {
+            // saturate values
+            if (b0 > 0xFF) b0 = 0xFF;
+            if (b1 > 0xFF) b1 = 0xFF;
+            if (b2 > 0xFF) b2 = 0xFF;
+            if (b3 > 0xFF) b3 = 0xFF;
+
+            return (((uint)b3 & 0xFF) << 24) |
+                (((uint)b2 & 0xFF) << 16) |
+                (((uint)b1 & 0xFF) << 8) |
+                ((uint)b0 & 0xFF);
+        }
+
+        private String FORMAT_lpscListString(int[] list)
+        {
+            String listString = "";
+            for (int i = 0; i < list.Length; i++)
+                listString += list[i].ToString() + ";";
+
+            return listString;
+        }
+
+        private String FORMAT_appFileListString()
+        {
+            String text = "";
+
+            for (int i = 0; i < options.appFileName.Length; i++)
+                if (options.appFileName[i] != "")
+                {
+                    text += options.appFileName[i];
+                    if (options.appFileAddr[i] != (uint)Consts.BinAddr.invalid)
+                        text += "@" + FORMAT_32bHexString(options.appFileAddr[i]);
+                    text += ";";
+                }
+
+            return text;
+        }
+
+        private byte[] FORMAT_insertConfigWord(byte[] ais)
+        {
+            byte configByte = (byte)(0x20 | options.boot.flashWidth);
+            byte[] newAis = new byte[ais.Length + 4];
+            
+            newAis[0] = configByte;
+            newAis[1] = newAis[2] = newAis[3] = 0;
+            ais.CopyTo(newAis, 4);
+
+            return newAis;
+        }
+
+        #endregion
+
+        #region Methods - Message Logging
+
+        private void LOG_msg(String text)
+        {
+            log.WriteLine("***" + text);
+            labelMessage.Text = text;
+            tooltipMessage.SetToolTip(labelMessage, labelMessage.Text);
+
+            // trim message log to prevent covering button
+            if (labelMessage.Width > 350)
+            {
+                // first take best guess based on width
+                int idealLength = (int)((350.0 / labelMessage.Width) * text.Length);
+
+                // decrement as necessary to reach 350 width
+                while (labelMessage.Width > 350)
+                    labelMessage.Text = text.Substring(0, idealLength--) + "...";
+            }
+        }
+
+        private void LOG_clear()
+        {
+            labelMessage.Text = "";
+        }
+
+        #endregion
+
+        #region Methods - Miscellaneous Utility
+
+        private void UTIL_tabShow(int index)
+        {
+            int insertAt;
+
+            // do nothing if already visible
+            if (tabVisible[index]) return;
+
+            // correct index based on which preceding tabs are visible
+            insertAt = UTIL_correctTabIndex(index);
+
+            // insert tab to TabPageCollection
+            tabControlConfig.TabPages.Insert(insertAt, tab[index]);
+            tabVisible[index] = true;
+        }
+
+        private void UTIL_tabHide(int index)
+        {
+            int removeAt;
+
+            // do nothing if already hidden
+            if (!tabVisible[index]) return;
+
+            // correct index based on which preceding tabs are visible
+            removeAt = UTIL_correctTabIndex(index);
+
+            // remove tab from TabPagesCollection (note: RemoveAt method is unreliable)
+            tabControlConfig.TabPages.Remove(tab[index]);
+            //tabControlConfig.TabPages.RemoveAt(removeAt);
+            tabVisible[index] = false;            
+        }
+
+        private int UTIL_correctTabIndex(int index)
+        {
+            int correctIndex = index;
+            for (int i = 0; i < index; i++)
+                if (tabVisible[i] == false)
+                    correctIndex--;
+
+            return correctIndex;
+        }
+
+        private String UTIL_getFileName(String title_text, String filter_text, bool new_file, out bool ok)
+        {
+            // open file browser
+            OpenFileDialog fileOpenSel = new OpenFileDialog();
+
+            fileOpenSel.Filter = filter_text;
+            fileOpenSel.Title = title_text;
+            fileOpenSel.CheckFileExists = !new_file;
+            try
+            {
+                if (fileOpenSel.ShowDialog() == DialogResult.OK) ok = true;
+                else ok = false;
+                return fileOpenSel.FileName;
+            }
+            catch
+            {
+                LOG_msg("Error: Could not retrieve file name.");
+                ok = true;
+                return "";
+            }
+        }
+
+        private String UTIL_getSaveFileName(String title_text, String filter_text, bool new_file, out bool ok)
+        {
+            // open file browser
+            SaveFileDialog fileSaveSel = new SaveFileDialog();
+
+            fileSaveSel.Filter = filter_text;
+            fileSaveSel.Title = title_text;
+            fileSaveSel.CheckFileExists = !new_file;
+            try
+            {
+                if (fileSaveSel.ShowDialog() == DialogResult.OK) ok = true;
+                else ok = false;
+                return fileSaveSel.FileName;
+            }
+            catch
+            {
+                LOG_msg("Error: Could not retrieve file name.");
+                ok = true;
+                return "";
+            }
+        }
+
+        private String UTIL_addBinFileAddress(String fileName, uint addr)
+        {
+            // don't do anything to obj files
+            if (VAL_appFileIsObj(fileName))
+                return fileName;
+
+            return fileName.Insert(fileName.Length, "@0x" + Convert.ToString(addr, 16));
+        }
+
+        private void UTIL_setupPinmuxArrays()
+        {
+            numericUpDownPinmux = new NumericUpDown[20];
+            textBoxPinmux = new TextBox[20];
+
+            numericUpDownPinmux[0] = numericUpDownPinmux0;
+            numericUpDownPinmux[1] = numericUpDownPinmux1;
+            numericUpDownPinmux[2] = numericUpDownPinmux2;
+            numericUpDownPinmux[3] = numericUpDownPinmux3;
+            numericUpDownPinmux[4] = numericUpDownPinmux4;
+            numericUpDownPinmux[5] = numericUpDownPinmux5;
+            numericUpDownPinmux[6] = numericUpDownPinmux6;
+            numericUpDownPinmux[7] = numericUpDownPinmux7;
+            numericUpDownPinmux[8] = numericUpDownPinmux8;
+            numericUpDownPinmux[9] = numericUpDownPinmux9;
+            numericUpDownPinmux[10] = numericUpDownPinmux10;
+            numericUpDownPinmux[11] = numericUpDownPinmux11;
+            numericUpDownPinmux[12] = numericUpDownPinmux12;
+            numericUpDownPinmux[13] = numericUpDownPinmux13;
+            numericUpDownPinmux[14] = numericUpDownPinmux14;
+            numericUpDownPinmux[15] = numericUpDownPinmux15;
+            numericUpDownPinmux[16] = numericUpDownPinmux16;
+            numericUpDownPinmux[17] = numericUpDownPinmux17;
+            numericUpDownPinmux[18] = numericUpDownPinmux18;
+            numericUpDownPinmux[19] = numericUpDownPinmux19;
+            textBoxPinmux[0] = textBoxPinmuxVal0;
+            textBoxPinmux[1] = textBoxPinmuxVal1;
+            textBoxPinmux[2] = textBoxPinmuxVal2;
+            textBoxPinmux[3] = textBoxPinmuxVal3;
+            textBoxPinmux[4] = textBoxPinmuxVal4;
+            textBoxPinmux[5] = textBoxPinmuxVal5;
+            textBoxPinmux[6] = textBoxPinmuxVal6;
+            textBoxPinmux[7] = textBoxPinmuxVal7;
+            textBoxPinmux[8] = textBoxPinmuxVal8;
+            textBoxPinmux[9] = textBoxPinmuxVal9;
+            textBoxPinmux[10] = textBoxPinmuxVal10;
+            textBoxPinmux[11] = textBoxPinmuxVal11;
+            textBoxPinmux[12] = textBoxPinmuxVal12;
+            textBoxPinmux[13] = textBoxPinmuxVal13;
+            textBoxPinmux[14] = textBoxPinmuxVal14;
+            textBoxPinmux[15] = textBoxPinmuxVal15;
+            textBoxPinmux[16] = textBoxPinmuxVal16;
+            textBoxPinmux[17] = textBoxPinmuxVal17;
+            textBoxPinmux[18] = textBoxPinmuxVal18;
+            textBoxPinmux[19] = textBoxPinmuxVal19;
+        }
+
+        private void UTIL_setNandFeatures()
+        {
+            if (options.boot.isNAND && options.romID == (int)Consts.RomID.d800k002)
+            {
+                // force 8-bit for NAND and disable selection on d800k002
+                comboBoxFlashWidth.SelectedIndex = (int)Consts.FlashWidth.eightbit;
+                comboBoxFlashWidth.Enabled = false;
+            }
+            else
+            {
+                // allow 16-bit selection and restore previous setting
+                comboBoxFlashWidth.Enabled = true;
+                if (options.boot.flashTimingIsSixteenBit())
+                    comboBoxFlashWidth.SelectedIndex = (int)Consts.FlashWidth.sixteenbit;
+                else
+                    comboBoxFlashWidth.SelectedIndex = (int)Consts.FlashWidth.eightbit;
+            }
+        }
+
+        private void UTIL_refreshFields()
+        {
+            // select defaults in combo boxes
+            comboBoxBootType.SelectedIndex = options.deviceType;
+            comboBoxROMid.SelectedIndex = options.romID;
+            comboBoxBootMode.SelectedIndex = options.boot.getIndex();
+            comboBoxClockSource.SelectedIndex = options.clockType;
+            comboBoxFlashWidth.SelectedIndex = options.boot.flashWidth;
+
+            // numeric
+            textBoxClockSpeed.Text = Convert.ToString(options.inputClock);
+            textBoxSpecifyEntrypoint.Text = FORMAT_32bHexString(options.entrypoint);
+            textBoxPeriphClockIdeal.Text = Convert.ToString(options.boot.targetSpeed);
+            textBoxPLL0preDiv.Text = Convert.ToString(options.pll0preDiv);
+            textBoxPLL0mult.Text = Convert.ToString(options.pll0Mult);
+            textBoxPLL0postDiv.Text = Convert.ToString(options.pll0postDiv);
+            textBoxPLL0div1.Text = Convert.ToString(options.pll0div1);
+            textBoxPLL0div3.Text = Convert.ToString(options.pll0div3);
+            textBoxPLL0div7.Text = Convert.ToString(options.pll0div7);
+            textBoxSDRAMsdbcr.Text = FORMAT_32bHexString(options.sdramSdbcr);
+            textBoxSDRAMsdtmr.Text = FORMAT_32bHexString(options.sdramSdtmr);
+            textBoxSDRAMsdrsrpdexit.Text = FORMAT_32bHexString(options.sdramSdrsrpdexit);
+            textBoxSDRAMsdrcr.Text = FORMAT_32bHexString(options.sdramSdrcr);
+            textBoxPLL1mult.Text = Convert.ToString(options.pll1Mult);
+            textBoxPLL1postDiv.Text = Convert.ToString(options.pll1postDiv);
+            textBoxPLL1div1.Text = Convert.ToString(options.pll1div1);
+            textBoxPLL1div2.Text = Convert.ToString(options.pll1div2);
+            textBoxPLL1div3.Text = Convert.ToString(options.pll1div3);
+            textBoxDDR2phy.Text = FORMAT_32bHexString(options.ddr2Phy);
+            textBoxDDR2sdcr.Text = FORMAT_32bHexString(options.ddr2Sdcr);
+            textBoxDDR2sdcr2.Text = FORMAT_32bHexString(options.ddr2Sdcr2);
+            textBoxDDR2sdtimr.Text = FORMAT_32bHexString(options.ddr2Sdtimr);
+            textBoxDDR2sdtimr2.Text = FORMAT_32bHexString(options.ddr2Sdtimr2);
+            textBoxDDR2sdrcr.Text = FORMAT_32bHexString(options.ddr2Sdrcr);
+            textBoxFlashTiming.Text = FORMAT_32bHexString(options.boot.flashTiming);
+
+            // boolean
+            checkBoxPLL0.Checked = options.configPll0;
+            checkBoxSDRAM.Checked = options.configSdram;
+            checkBoxPLL1.Checked = options.configPll1;
+            checkBoxDDR2.Checked = options.configDdr2;
+            checkBoxLPSC.Checked = options.configLpsc;
+            checkBoxPinmux.Checked = options.configPinmux;
+            checkBoxCRC.Checked = options.enableCRC;
+            checkBoxSpecifyEntrypoint.Checked = options.specifyEntrypoint;
+            checkBoxPeriphSeqRead.Checked = options.enableSeqRead;
+            checkBoxSDRAMdiv.Checked = options.sdramDiv45;
+            checkBoxDDR2directClock.Checked = options.ddr2directClk;
+            radioMDDR.Checked = options.useMDDR;
+            radioDDR2.Checked = !options.useMDDR;
+            radioDuplicateMddrSetting.Checked = options.useDuplicateMddrSetting;
+
+            // lpsc
+            textBoxLps0Enable.Text = FORMAT_lpscListString(options.lpsc0enable);
+            textBoxLps0Disable.Text = FORMAT_lpscListString(options.lpsc0disable);
+            textBoxLps0SyncRst.Text = FORMAT_lpscListString(options.lpsc0syncRst);
+            textBoxLps1Enable.Text = FORMAT_lpscListString(options.lpsc1enable);
+            textBoxLps1Disable.Text = FORMAT_lpscListString(options.lpsc1disable);
+            textBoxLps1SyncRst.Text = FORMAT_lpscListString(options.lpsc1syncRst);
+
+            // pinmux
+            for (int i = 0; i < 20; i++)
+                if (options.pinmuxApply[i])
+                {
+                    numericUpDownPinmux[i].Value = options.pinmuxReg[i];
+                    textBoxPinmux[i].Text = FORMAT_32bHexString(options.pinmuxVal[i]);
+                }
+                else
+                {
+                    numericUpDownPinmux[i].Value = -1;
+                    textBoxPinmux[i].Text = "0x00000000";
+                }
+
+            // string
+            textBoxAppFiles.Text = FORMAT_appFileListString();
+            textBoxAISfile.Text = options.aisFileName;
+        }
+
+        #endregion
+    }
+}
\ No newline at end of file
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/MainForm.resx b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/MainForm.resx
new file mode 100644 (file)
index 0000000..bcef02a
--- /dev/null
@@ -0,0 +1,372 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>142, 17</value>
+  </metadata>
+  <metadata name="tooltipMessage.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>17, 17</value>
+  </metadata>
+  <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+  <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        AAABAAEAPDoAAAEAIABYOAAAFgAAACgAAAA8AAAAdAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wEAAP9BAAD/mwAA/9UAAP/xAAD/9AAA/90AAP+qAAD/SQAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAD/OAAA/8gAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD/mQAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAA/wIAAP9/AAD/+wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD/NwAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/BQAA/6UAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP/uAAD/AwAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAP8CAAD/oQAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP/DAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAP94AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP+qAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        /zUAAP/7AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP+fAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AwAA
+        /80AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP+tAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/YAAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP/ZAAD/AAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8IAAD/3wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD/KAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP9nAAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD/kQAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wQAAP/dAAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD/9wAA
+        /yQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/1gAAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        /78AAP8EAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AQAA/8wAAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+JAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/RAAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP/+AAD/cQAA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8AAAD/vAAA//8AAP//AAD//wAA
+        //8AAP/+AAD/1AAA/5kAAP95AAD/ZwAA/14AAP9eAAD/XgAA/14AAP9eAAD/XgAA/14AAP9sAAD//wAA
+        //8AAP//AAD//gAA/3wAAP8BAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8+AAD//gAA//8AAP//AAD//wAA
+        /+YAAP9BAAD/AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8BAAD/6gAA
+        //8AAP//AAD//wAA//8AAP+lAAD/DgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AAAA/0sAAP/IAAD/9gAA
+        /9gAAP9RAAD/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wIAAP/IAAD//wAA//8AAP//AAD//wAA
+        /0gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/uAAA
+        //8AAP//AAD//wAA//8AAP//AAD/3gAA/0cAAP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/ZQAA//0AAP//AAD//wAA
+        //8AAP/8AAD/VwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/20AAP//AAD//wAA//8AAP//AAD/9AAA
+        /wUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/hgAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//4AAP+vAAD/KwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8rAAD/+AAA//8AAP//AAD//wAA
+        //8AAP//AAD/+AAA/00AAAAAAAAAAAAAAAAAAAAAAAD/RAAA//gAAP//AAD//wAA//8AAP//AAD/7gAA
+        /wIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/UgAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//AAA/6sAAP85AAD/AAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wAAAP+1AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//wAAP+hAAD/UwAA/0YAAP+NAAD/+QAA//8AAP//AAD//wAA//8AAP//AAD//gAA
+        /xQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/HwAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD/0QAA/3QAAP8gAAD/AAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/y8AAP/+AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        /0kAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/AgAA
+        /+kAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP/+AAD/0QAA
+        /40AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/5gAAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        /4MAAAAAAAAAAAAA/3sAAP+HAAD/hwAA/4cAAP+HAAD/ZwAAAAAAAAAAAAD/DQAA/2oAAP+FAAD/hwAA
+        /+QAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/DQAA//AAAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        /7YAAAAAAAAAAAAA/8IAAP//AAD//wAA//8AAP//AAD/6AAA/wIAAAAAAAD/fwAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/ZgAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        /+gAAP8AAAAAAAAA/5AAAP//AAD//wAA//8AAP//AAD//gAA/x4AAAAAAAD/fgAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP8IAAD/2wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP8bAAAAAAAA/10AAP//AAD//wAA//8AAP//AAD//wAA/08AAAAAAAD/TgAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA/wAAAP+TAAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP9OAAAAAAAA/ykAAP//AAD//wAA//8AAP//AAD//wAA/4MAAAAAAAD/GQAA//4AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAAAAAAAAAAAAAAAAAAAAAAD/AAAA/3oAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+AAAAAAAAA/wMAAP/zAAD//wAA//8AAP//AAD//wAA/7YAAAAAAAD/AQAA/+QAAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAAAAAAAAAAAAAAAAAP8CAAD/jAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+yAAAAAAAAAAAAAP/DAAD//wAA//8AAP//AAD//wAA/+YAAP8CAAAAAAAA/7MAAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAAAAAAAAAAAA/wcAAP+pAAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP/jAAD/AAAAAAAAAP+QAAD//wAA//8AAP//AAD//wAA//8AAP8cAAAAAAAA/38AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAAAAAAD/BQAA/7AAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP/9AAD/GQAAAAAAAP9dAAD//wAA//8AAP//AAD//wAA//8AAP9PAAAAAAAA/0wAAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP8AAAD/iQAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD/SQAAAAAAAP8rAAD//wAA//8AAP//AAD//wAA//8AAP+CAAAAAAAA/xoAAP/+AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP8sAAD/+wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP/+AAD//AAA
+        //wAAP/8AAD/egAAAAAAAP8EAAD/8gAA//8AAP//AAD//wAA//8AAP+0AAAAAAAA/wEAAP/hAAD//AAA
+        //wAAP/8AAD//gAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+WAAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP+tAAD/DgAA
+        /w4AAP8OAAD/CAAAAAAAAAAAAAD/wwAA//8AAP//AAD//wAA//8AAP/nAAAAAAAAAAAAAP8LAAD/DgAA
+        /w4AAP8OAAD/hwAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//gAA
+        /4sAAP/aAAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP/aAAD/AAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAD/kQAA//8AAP//AAD//wAA//8AAP//AAD/HAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/TgAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD/gQAA
+        /wAAAP+rAAD/rgAA/64AAP+uAAD/rgAA/64AAP+uAAD/rgAA/64AAP+uAAD/rgAA/64AAP+uAAD/rgAA
+        /64AAP+uAAD/ygAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP/8AAD/EgAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAD/XgAA//8AAP//AAD//wAA//8AAP//AAD/TgAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/GwAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP/IAAD/AwAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD/QgAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAD/KwAA//8AAP//AAD//wAA//8AAP//AAD/gQAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/AQAA/+YAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP9OAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD/dQAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAD/BQAA//IAAP//AAD//wAA//8AAP//AAD/tAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAA/7UAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//MAAP8GAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD/qAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/8UAAP//AAD//wAA//8AAP//AAD/5gAA/wEAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAA/4IAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA/8gAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD/4AAA
+        /0YAAP9GAAD/RgAA/0MAAP8AAAAAAAAA/5IAAP//AAD//wAA//8AAP//AAD//gAA/xsAAAAAAAD/HQAA
+        /0YAAP9GAAD/RgAA/4QAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA/7IAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP8WAAAAAAAA/18AAP//AAD//wAA//8AAP//AAD//wAA/00AAAAAAAD/SwAA
+        //8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA/68AAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP9JAAAAAAAA/y0AAP//AAD//wAA//8AAP//AAD//wAA/4EAAAAAAAD/GAAA
+        //4AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA/68AAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP98AAAAAAAA/wUAAP/0AAD//wAA//8AAP//AAD//wAA/7MAAAAAAAD/AQAA
+        /+IAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA/68AAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP+wAAAAAAAAAAAAAP/FAAD//wAA//8AAP//AAD//wAA/+QAAP8BAAAAAAAA
+        /7AAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA/68AAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP/jAAD/AAAAAAAAAP+SAAD//wAA//8AAP//AAD//wAA//4AAP8bAAAAAAAA
+        /30AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA/68AAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP//AAD//wAA//8AAP/+AAD/GQAAAAAAAP9gAAD//wAA//8AAP//AAD//wAA//8AAP9NAAAAAAAA
+        /0kAAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA/68AAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP/+AAD//AAA//wAAP/8AAD/SwAAAAAAAP8tAAD//AAA//wAAP/8AAD//AAA//wAAP99AAAAAAAA
+        /xgAAP/6AAD//AAA//wAAP/8AAD//AAA//wAAP/8AAD//AAA//wAAP/8AAD//AAA/60AAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+mAAD/DAAA/wwAAP8MAAD/BQAAAAAAAP8BAAD/DAAA/wwAAP8MAAD/DAAA/wwAAP8HAAAAAAAA
+        /wAAAP8MAAD/DAAA/wwAAP8MAAD/DAAA/wwAAP8MAAD/DAAA/wwAAP8MAAD/DAAA/wgAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/YAAA/6gAAP+oAAD/qAAA/6gAAP+oAAD/EQAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/aAAA//8AAP//AAD//wAA//8AAP//AAD/RAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/NgAA//8AAP//AAD//wAA//8AAP//AAD/dwAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/CgAA//gAAP//AAD//wAA//8AAP//AAD/qQAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/88AAP//AAD//wAA//8AAP//AAD/3AAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/4AAAP/KAAD/ygAA/8oAAP/KAAD/yAAA
+        /wsAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAD/WAAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA//8AAP//AAD//wAA
+        //8AAP+hAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+        AAD/////+B//8P/////gD//w/////8Af//D/////AB//8P////4AH//w/////gAf//D////8AB//8P//
+        //gAH//w////+AAf//D////wAB//8P////AAD//w////4AAP//D////gAAf/8P///8AAA//w////wAAD
+        //D///+Af+H/8P///4P/4H/w//H/B//gP/D/4P8H/+AP8P/Afgf/8APw/4AYB//wAPD/gAAH//AAAP8A
+        AAOHwAAA/wAAAwOAAAD/AAADA4AAAP4AAAODgAAA/AAAA4GAAAD8AAABgYAAAPAAAAGBgAAA4AAAAYHA
+        AADAAAABwcAAAIAAAAHAwAAAgAAAAcDAAAAAAAAPwPwAAAAAAA/A/gAQAAAAD+D+ADD//4AP4H4AcP//
+        gA/gfgBw//+AB+B+AHD//4AH4H4AcP//gABwcABw//+AAHAwAHD//4AAcDAAcP//gAAwMABw//+AADA4
+        AHD//4AAODgAcP//gAA4OABw//+AAf////D//4AB////8P//gAH8H//w//+AAfwf//D//4AB/B//8P//
+        gAH8D//w//+AAfwP//D//4AB/A//8P//gAH////w//+AAf////D//4AB////8A==
+</value>
+  </data>
+</root>
\ No newline at end of file
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/ParamError.cs b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/ParamError.cs
new file mode 100644 (file)
index 0000000..792cfe2
--- /dev/null
@@ -0,0 +1,460 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+
+namespace TIBootAndFlash
+{
+    class ParamError
+    {
+        // constants
+        private const int PINMUX_cnt = 20;
+
+        // error providers
+        public ErrorProvider appFiles, aisFile, generalClock, generalEntryPoint, generalBootMode,
+            periphIdealClock, periphModuleClock, pll0preDiv, pll0postDiv,
+            pll0mult, pll0div1, pll0div3, pll0div7,
+            pll0cpu, pll0sdram, pll0emac, sdramClock,
+            sdramSdbcr, sdramSdtmr, sdramSdrsrpdexit, sdramSdrcr,
+            pll1postDiv, pll1mult, pll1div1, pll1div2,
+            pll1div3, pll1ddr2, ddr2Clock, ddr2phy,
+            ddr2sdcr, ddr2sdcr2, ddr2sdtimr, ddr2sdtimr2, ddr2sdrcr,
+            lpsc0enable, lpsc0disable, lpsc0syncRst, lpsc1enable,
+            lpsc1disable, lpsc1syncRst, flashTiming;
+        public ErrorProvider[] pinmux;
+
+        // ref to main form
+        private MainForm parent;
+
+        public ParamError(MainForm parentSpec)
+        {
+            parent = parentSpec;
+
+            // initialize all error objects
+
+            // un-tabbed errors
+            appFiles = new ErrorProvider();
+            appFiles.SetIconAlignment(parent.textBoxAppFiles, ErrorIconAlignment.MiddleRight);
+            appFiles.SetIconPadding(parent.textBoxAppFiles, 2);
+            appFiles.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            aisFile = new ErrorProvider();
+            aisFile.SetIconAlignment(parent.textBoxAISfile, ErrorIconAlignment.MiddleRight);
+            aisFile.SetIconPadding(parent.textBoxAISfile, 2);
+            aisFile.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            // general tab errors
+            generalClock = new ErrorProvider();
+            generalClock.SetIconAlignment(parent.textBoxClockSpeed, ErrorIconAlignment.MiddleRight);
+            generalClock.SetIconPadding(parent.textBoxClockSpeed, 2);
+            generalClock.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            generalEntryPoint = new ErrorProvider();
+            generalEntryPoint.SetIconAlignment(parent.textBoxSpecifyEntrypoint, ErrorIconAlignment.MiddleRight);
+            generalEntryPoint.SetIconPadding(parent.textBoxSpecifyEntrypoint, 2);
+            generalEntryPoint.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            generalBootMode = new ErrorProvider();
+            generalBootMode.SetIconAlignment(parent.comboBoxBootMode, ErrorIconAlignment.MiddleRight);
+            generalBootMode.SetIconPadding(parent.comboBoxBootMode, 2);
+            generalBootMode.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            // peripheral tab errors
+            periphIdealClock = new ErrorProvider();
+            periphIdealClock.SetIconAlignment(parent.textBoxPeriphClockIdeal, ErrorIconAlignment.MiddleRight);
+            periphIdealClock.SetIconPadding(parent.textBoxPeriphClockIdeal, 2);
+            periphIdealClock.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            periphModuleClock = new ErrorProvider();
+            periphModuleClock.SetIconAlignment(parent.textBoxPeriphModuleClock, ErrorIconAlignment.MiddleRight);
+            periphModuleClock.SetIconPadding(parent.textBoxPeriphModuleClock, 2);
+            periphModuleClock.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+            
+            // pll0 tab errors
+            pll0preDiv = new ErrorProvider();
+            pll0preDiv.SetIconAlignment(parent.textBoxPLL0preDiv, ErrorIconAlignment.MiddleRight);
+            pll0preDiv.SetIconPadding(parent.textBoxPLL0preDiv, 2);
+            pll0preDiv.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            pll0postDiv = new ErrorProvider();
+            pll0postDiv.SetIconAlignment(parent.textBoxPLL0postDiv, ErrorIconAlignment.MiddleRight);
+            pll0postDiv.SetIconPadding(parent.textBoxPLL0postDiv, 2);
+            pll0postDiv.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            pll0mult = new ErrorProvider();
+            pll0mult.SetIconAlignment(parent.textBoxPLL0mult, ErrorIconAlignment.MiddleRight);
+            pll0mult.SetIconPadding(parent.textBoxPLL0mult, 2);
+            pll0mult.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            pll0div1 = new ErrorProvider();
+            pll0div1.SetIconAlignment(parent.textBoxPLL0div1, ErrorIconAlignment.MiddleRight);
+            pll0div1.SetIconPadding(parent.textBoxPLL0div1, 2);
+            pll0div1.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            pll0div3 = new ErrorProvider();
+            pll0div3.SetIconAlignment(parent.textBoxPLL0div3, ErrorIconAlignment.MiddleRight);
+            pll0div3.SetIconPadding(parent.textBoxPLL0div3, 2);
+            pll0div3.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            pll0div7 = new ErrorProvider();
+            pll0div7.SetIconAlignment(parent.textBoxPLL0div7, ErrorIconAlignment.MiddleRight);
+            pll0div7.SetIconPadding(parent.textBoxPLL0div7, 2);
+            pll0div7.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            pll0cpu = new ErrorProvider();
+            pll0cpu.SetIconAlignment(parent.textBoxPLL0cpu, ErrorIconAlignment.MiddleRight);
+            pll0cpu.SetIconPadding(parent.textBoxPLL0cpu, 2);
+            pll0cpu.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            pll0sdram = new ErrorProvider();
+            pll0sdram.SetIconAlignment(parent.textBoxPLL0sdram, ErrorIconAlignment.MiddleRight);
+            pll0sdram.SetIconPadding(parent.textBoxPLL0sdram, 2);
+            pll0sdram.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            pll0emac = new ErrorProvider();
+            pll0emac.SetIconAlignment(parent.textBoxPLL0emac, ErrorIconAlignment.MiddleRight);
+            pll0emac.SetIconPadding(parent.textBoxPLL0emac, 2);
+            pll0emac.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+            
+            // sdram tab errors
+            sdramClock = new ErrorProvider();
+            sdramClock.SetIconAlignment(parent.textBoxSDRAMclock, ErrorIconAlignment.MiddleRight);
+            sdramClock.SetIconPadding(parent.textBoxSDRAMclock, 2);
+            sdramClock.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            sdramSdbcr = new ErrorProvider();
+            sdramSdbcr.SetIconAlignment(parent.textBoxSDRAMsdbcr, ErrorIconAlignment.MiddleRight);
+            sdramSdbcr.SetIconPadding(parent.textBoxSDRAMsdbcr, 2);
+            sdramSdbcr.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            sdramSdtmr = new ErrorProvider();
+            sdramSdtmr.SetIconAlignment(parent.textBoxSDRAMsdtmr, ErrorIconAlignment.MiddleRight);
+            sdramSdtmr.SetIconPadding(parent.textBoxSDRAMsdtmr, 2);
+            sdramSdtmr.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            sdramSdrsrpdexit = new ErrorProvider();
+            sdramSdrsrpdexit.SetIconAlignment(parent.textBoxSDRAMsdrsrpdexit, ErrorIconAlignment.MiddleRight);
+            sdramSdrsrpdexit.SetIconPadding(parent.textBoxSDRAMsdrsrpdexit, 2);
+            sdramSdrsrpdexit.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            sdramSdrcr = new ErrorProvider();
+            sdramSdrcr.SetIconAlignment(parent.textBoxSDRAMsdrcr, ErrorIconAlignment.MiddleRight);
+            sdramSdrcr.SetIconPadding(parent.textBoxSDRAMsdrcr, 2);
+            sdramSdrcr.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            // pll1 tab errors
+            pll1postDiv = new ErrorProvider();
+            pll1postDiv.SetIconAlignment(parent.textBoxPLL1postDiv, ErrorIconAlignment.MiddleRight);
+            pll1postDiv.SetIconPadding(parent.textBoxPLL1postDiv, 2);
+            pll1postDiv.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            pll1mult = new ErrorProvider();
+            pll1mult.SetIconAlignment(parent.textBoxPLL1mult, ErrorIconAlignment.MiddleRight);
+            pll1mult.SetIconPadding(parent.textBoxPLL1mult, 2);
+            pll1mult.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            pll1div1 = new ErrorProvider();
+            pll1div1.SetIconAlignment(parent.textBoxPLL1div1, ErrorIconAlignment.MiddleRight);
+            pll1div1.SetIconPadding(parent.textBoxPLL1div1, 2);
+            pll1div1.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            pll1div2 = new ErrorProvider();
+            pll1div2.SetIconAlignment(parent.textBoxPLL1div2, ErrorIconAlignment.MiddleRight);
+            pll1div2.SetIconPadding(parent.textBoxPLL1div2, 2);
+            pll1div2.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            pll1div3 = new ErrorProvider();
+            pll1div3.SetIconAlignment(parent.textBoxPLL1div3, ErrorIconAlignment.MiddleRight);
+            pll1div3.SetIconPadding(parent.textBoxPLL1div3, 2);
+            pll1div3.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            pll1ddr2 = new ErrorProvider();
+            pll1ddr2.SetIconAlignment(parent.textBoxPLL1ddr2, ErrorIconAlignment.MiddleRight);
+            pll1ddr2.SetIconPadding(parent.textBoxPLL1ddr2, 2);
+            pll1ddr2.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+            
+            // ddr2 tab errors
+            ddr2Clock = new ErrorProvider();
+            ddr2Clock.SetIconAlignment(parent.textBoxDDR2clock, ErrorIconAlignment.MiddleRight);
+            ddr2Clock.SetIconPadding(parent.textBoxDDR2clock, 2);
+            ddr2Clock.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            ddr2phy = new ErrorProvider();
+            ddr2phy.SetIconAlignment(parent.textBoxDDR2phy, ErrorIconAlignment.MiddleRight);
+            ddr2phy.SetIconPadding(parent.textBoxDDR2phy, 2);
+            ddr2phy.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            ddr2sdcr = new ErrorProvider();
+            ddr2sdcr.SetIconAlignment(parent.textBoxDDR2sdcr, ErrorIconAlignment.MiddleRight);
+            ddr2sdcr.SetIconPadding(parent.textBoxDDR2sdcr, 2);
+            ddr2sdcr.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            ddr2sdcr2 = new ErrorProvider();
+            ddr2sdcr2.SetIconAlignment(parent.textBoxDDR2sdcr2, ErrorIconAlignment.MiddleRight);
+            ddr2sdcr2.SetIconPadding(parent.textBoxDDR2sdcr2, 2);
+            ddr2sdcr2.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            ddr2sdtimr = new ErrorProvider();
+            ddr2sdtimr.SetIconAlignment(parent.textBoxDDR2sdtimr, ErrorIconAlignment.MiddleRight);
+            ddr2sdtimr.SetIconPadding(parent.textBoxDDR2sdtimr, 2);
+            ddr2sdtimr.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            ddr2sdtimr2 = new ErrorProvider();
+            ddr2sdtimr2.SetIconAlignment(parent.textBoxDDR2sdtimr2, ErrorIconAlignment.MiddleRight);
+            ddr2sdtimr2.SetIconPadding(parent.textBoxDDR2sdtimr2, 2);
+            ddr2sdtimr2.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            ddr2sdrcr = new ErrorProvider();
+            ddr2sdrcr.SetIconAlignment(parent.textBoxDDR2sdrcr, ErrorIconAlignment.MiddleRight);
+            ddr2sdrcr.SetIconPadding(parent.textBoxDDR2sdrcr, 2);
+            ddr2sdrcr.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            // lpsc tab errors
+            lpsc0enable = new ErrorProvider();
+            lpsc0enable.SetIconAlignment(parent.textBoxLps0Enable, ErrorIconAlignment.MiddleRight);
+            lpsc0enable.SetIconPadding(parent.textBoxLps0Enable, 2);
+            lpsc0enable.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            lpsc0disable = new ErrorProvider();
+            lpsc0disable.SetIconAlignment(parent.textBoxLps0Disable, ErrorIconAlignment.MiddleRight);
+            lpsc0disable.SetIconPadding(parent.textBoxLps0Disable, 2);
+            lpsc0disable.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            lpsc0syncRst = new ErrorProvider();
+            lpsc0syncRst.SetIconAlignment(parent.textBoxLps0SyncRst, ErrorIconAlignment.MiddleRight);
+            lpsc0syncRst.SetIconPadding(parent.textBoxLps0SyncRst, 2);
+            lpsc0syncRst.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            lpsc1enable = new ErrorProvider();
+            lpsc1enable.SetIconAlignment(parent.textBoxLps1Enable, ErrorIconAlignment.MiddleRight);
+            lpsc1enable.SetIconPadding(parent.textBoxLps1Enable, 2);
+            lpsc1enable.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            lpsc1disable = new ErrorProvider();
+            lpsc1disable.SetIconAlignment(parent.textBoxLps1Disable, ErrorIconAlignment.MiddleRight);
+            lpsc1disable.SetIconPadding(parent.textBoxLps1Disable, 2);
+            lpsc1disable.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            lpsc1syncRst = new ErrorProvider();
+            lpsc1syncRst.SetIconAlignment(parent.textBoxLps1SyncRst, ErrorIconAlignment.MiddleRight);
+            lpsc1syncRst.SetIconPadding(parent.textBoxLps1SyncRst, 2);
+            lpsc1syncRst.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+
+            // pinmux tab errors
+            pinmux = new ErrorProvider[PINMUX_cnt];
+            for (int i = 0; i < PINMUX_cnt; i++)
+            {
+                pinmux[i] = new ErrorProvider();
+                pinmux[i].SetIconAlignment(parent.textBoxPinmux[i], ErrorIconAlignment.MiddleRight);
+                pinmux[i].SetIconPadding(parent.textBoxPinmux[i], 2);
+                pinmux[i].BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+            }
+
+            // flash tab errors
+            flashTiming = new ErrorProvider();
+            flashTiming.SetIconAlignment(parent.textBoxFlashTiming, ErrorIconAlignment.MiddleRight);
+            flashTiming.SetIconPadding(parent.textBoxFlashTiming, 2);
+            flashTiming.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+        }
+
+        //public bool any()
+        //{
+        //    // return true if any error currently unresolved (unused)
+        //    if (appFiles.GetError(parent.textBoxAppFiles) == "" &&
+        //        aisFile.GetError(parent.textBoxAISfile) == "" &&
+        //        generalClock.GetError(parent.textBoxClockSpeed) == "" &&
+        //        generalEntryPoint.GetError(parent.textBoxSpecifyEntrypoint) == "" &&
+        //        periphIdealClock.GetError(parent.textBoxPeriphClockIdeal) == "" &&
+        //        periphModuleClock.GetError(parent.textBoxPeriphModuleClock) == "" &&
+        //        pll0preDiv.GetError(parent.textBoxPLL0preDiv) == "" &&
+        //        pll0postDiv.GetError(parent.textBoxPLL0postDiv) == "" &&
+        //        pll0mult.GetError(parent.textBoxPLL0mult) == "" &&
+        //        pll0div1.GetError(parent.textBoxPLL0div1) == "" &&
+        //        pll0div3.GetError(parent.textBoxPLL0div3) == "" &&
+        //        pll0div7.GetError(parent.textBoxPLL0div7) == "" &&
+        //        pll0cpu.GetError(parent.textBoxPLL0cpu) == "" &&
+        //        pll0sdram.GetError(parent.textBoxPLL0sdram) == "" &&
+        //        pll0emac.GetError(parent.textBoxPLL0emac) == "" &&
+        //        sdramClock.GetError(parent.textBoxSDRAMclock) == "" &&
+        //        sdramSdbcr.GetError(parent.textBoxSDRAMsdbcr) == "" &&
+        //        sdramSdtmr.GetError(parent.textBoxSDRAMsdtmr) == "" &&
+        //        sdramSdrsrpdexit.GetError(parent.textBoxSDRAMsdrsrpdexit) == "" &&
+        //        sdramSdrcr.GetError(parent.textBoxSDRAMsdrcr) == "" &&
+        //        pll1postDiv.GetError(parent.textBoxPLL1postDiv) == "" &&
+        //        pll1mult.GetError(parent.textBoxPLL1mult) == "" &&
+        //        pll1div1.GetError(parent.textBoxPLL1div1) == "" &&
+        //        pll1div2.GetError(parent.textBoxPLL1div2) == "" &&
+        //        pll1div3.GetError(parent.textBoxPLL1div3) == "" &&
+        //        pll1ddr2.GetError(parent.textBoxPLL1ddr2) == "" &&
+        //        ddr2Clock.GetError(parent.textBoxDDR2clock) == "" &&
+        //        ddr2phy.GetError(parent.textBoxDDR2phy) == "" &&
+        //        ddr2sdcr.GetError(parent.textBoxDDR2sdcr) == "" &&
+        //        ddr2sdtimr.GetError(parent.textBoxDDR2sdtimr) == "" &&
+        //        ddr2sdtimr2.GetError(parent.textBoxDDR2sdtimr2) == "" &&
+        //        ddr2sdrcr.GetError(parent.textBoxDDR2sdrcr) == "")
+        //        return false;
+        //    else
+        //        return true;
+        //}
+
+        public bool anyGeneral()
+        {
+            // return true if any general tab param error currently unresolved
+            if (appFiles.GetError(parent.textBoxAppFiles) == "" &&
+                aisFile.GetError(parent.textBoxAISfile) == "" &&
+                generalClock.GetError(parent.textBoxClockSpeed) == "" &&
+                generalEntryPoint.GetError(parent.textBoxSpecifyEntrypoint) == "" &&
+                generalBootMode.GetError(parent.comboBoxBootMode) == "")
+                return false;
+            else
+                return true;
+        }
+
+        public bool anyInputPLL0()
+        {
+            // return true if any PLL0 input param error currently unresolved
+            if (generalClock.GetError(parent.textBoxClockSpeed) == "" &&
+                pll0preDiv.GetError(parent.textBoxPLL0preDiv) == "" &&
+                pll0postDiv.GetError(parent.textBoxPLL0postDiv) == "" &&
+                pll0mult.GetError(parent.textBoxPLL0mult) == "" &&
+                pll0div1.GetError(parent.textBoxPLL0div1) == "" &&
+                pll0div3.GetError(parent.textBoxPLL0div3) == "" &&
+                pll0div7.GetError(parent.textBoxPLL0div7) == "")
+                return false;
+            else
+                return true;
+        }
+
+        public bool anyCalcPLL0()
+        {
+            // return true if any PLL0 calculated param error currently unresolved
+            if (pll0cpu.GetError(parent.textBoxPLL0cpu) == "" &&
+                pll0sdram.GetError(parent.textBoxPLL0sdram) == "" &&
+                pll0emac.GetError(parent.textBoxPLL0emac) == "")
+                return false;
+            else
+                return true;
+        }
+
+        public bool anyInputPLL1()
+        {
+            // return true if any PLL1 input param error currently unresolved
+            if (generalClock.GetError(parent.textBoxClockSpeed) == "" &&
+                pll1postDiv.GetError(parent.textBoxPLL1postDiv) == "" &&
+                pll1mult.GetError(parent.textBoxPLL1mult) == "" &&
+                pll1div1.GetError(parent.textBoxPLL1div1) == "" &&
+                pll1div2.GetError(parent.textBoxPLL1div2) == "" &&
+                pll1div3.GetError(parent.textBoxPLL1div3) == "")
+                return false;
+            else
+                return true;
+        }
+
+        public bool anyCalcPLL1()
+        {
+            // return true if any PLL1 calculated param error currently unresolved
+            if (pll1ddr2.GetError(parent.textBoxPLL1ddr2) == "")
+                return false;
+            else
+                return true;
+        }
+
+        public bool anyInputPeriph()
+        {
+            // return true if any periph clock or flash input param error currently unresolved
+            if (generalClock.GetError(parent.textBoxClockSpeed) == "" &&
+                periphIdealClock.GetError(parent.textBoxPeriphClockIdeal) == "" &&
+                flashTiming.GetError(parent.textBoxFlashTiming) == "")
+                return false;
+            else
+                return true;
+        }
+
+        public bool anyCalcPeriph()
+        {
+            // return true if any periph clock calculated param error currently unresolved
+            if (periphModuleClock.GetError(parent.textBoxPeriphModuleClock) == "")
+                return false;
+            else
+                return true;
+        }
+
+        public bool anyInputSDRAM()
+        {
+            // return true if any SDRAM clock input param error currently unresolved
+            if (generalClock.GetError(parent.textBoxClockSpeed) == "" &&
+                pll0preDiv.GetError(parent.textBoxPLL0preDiv) == "" &&
+                pll0postDiv.GetError(parent.textBoxPLL0postDiv) == "" &&
+                pll0mult.GetError(parent.textBoxPLL0mult) == "" &&
+                pll0div1.GetError(parent.textBoxPLL0div1) == "" &&
+                pll0div1.GetError(parent.textBoxPLL0div3) == "" &&
+                sdramSdbcr.GetError(parent.textBoxSDRAMsdbcr) == "" &&
+                sdramSdtmr.GetError(parent.textBoxSDRAMsdtmr) == "" &&
+                sdramSdrsrpdexit.GetError(parent.textBoxSDRAMsdrsrpdexit) == "" &&
+                sdramSdrcr.GetError(parent.textBoxSDRAMsdrcr) == "")
+                return false;
+            else
+                return true;
+        }
+
+        public bool anyCalcSDRAM()
+        {
+            // return true if any SDRAM clock calculated param error currently unresolved
+            if (sdramClock.GetError(parent.textBoxSDRAMclock) == "")
+                return false;
+            else
+                return true;
+        }
+
+        public bool anyInputDDR2()
+        {
+            // return true if any DDR2 input param error currently unresolved
+            if (generalClock.GetError(parent.textBoxClockSpeed) == "" &&
+                pll1postDiv.GetError(parent.textBoxPLL1postDiv) == "" &&
+                pll1mult.GetError(parent.textBoxPLL1mult) == "" &&
+                pll1div1.GetError(parent.textBoxPLL1div1) == "" &&
+                ddr2phy.GetError(parent.textBoxDDR2phy) == "" &&
+                ddr2sdcr.GetError(parent.textBoxDDR2sdcr) == "" &&
+                ddr2sdcr2.GetError(parent.textBoxDDR2sdcr2) == "" &&
+                ddr2sdtimr.GetError(parent.textBoxDDR2sdtimr) == "" &&
+                ddr2sdtimr2.GetError(parent.textBoxDDR2sdtimr2) == "" &&
+                ddr2sdrcr.GetError(parent.textBoxDDR2sdrcr) == "")
+                return false;
+            else
+                return true;
+        }
+
+        public bool anyCalcDDR2()
+        {
+            // return true if any DDR2 calculated param error currently unresolved
+            if (ddr2Clock.GetError(parent.textBoxDDR2clock) == "")
+                return false;
+            else
+                return true;
+        }
+
+        public bool anyLpsc()
+        {
+            // return true if any lpsc list error currently unresolved
+            if (lpsc0enable.GetError(parent.textBoxLps0Enable) == "" &&
+                lpsc0disable.GetError(parent.textBoxLps0Disable) == "" &&
+                lpsc0syncRst.GetError(parent.textBoxLps0SyncRst) == "" &&
+                lpsc1enable.GetError(parent.textBoxLps1Enable) == "" &&
+                lpsc1disable.GetError(parent.textBoxLps1Disable) == "" &&
+                lpsc1syncRst.GetError(parent.textBoxLps1SyncRst) == "")
+                return false;
+            else
+                return true;
+        }
+
+        public bool anyPinmux()
+        {
+            // return true if any pinmux error currently unresolved
+            for (int i = 0; i < PINMUX_cnt; i++)
+                if (pinmux[i].GetError(parent.textBoxPinmux[i]) != "")
+                    return true;
+            
+            return false;
+        }
+    }
+}
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/Program.cs b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/Program.cs
new file mode 100644 (file)
index 0000000..500d0ca
--- /dev/null
@@ -0,0 +1,69 @@
+using System;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Collections.Generic;
+using System.Windows.Forms;
+using System.Runtime.CompilerServices;
+
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("AISGen")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Texas Instruments, Inc")]
+[assembly: AssemblyProduct("AISGen")]
+[assembly: AssemblyCopyright("Copyright Â© Texas Instruments, Inc 2009-2012")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("59711dcf-3d1c-44c5-a331-f05e7fe0bf04")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+[assembly: AssemblyVersion("1.12.*")]
+[assembly: AssemblyFileVersion("1.12.0.0")]
+
+namespace TIBootAndFlash
+{
+    static class Program
+    {
+        /// <summary>
+        /// The main entry point for the application.
+        /// </summary>
+        [STAThread]
+        static void Main(string[] args)
+        {
+            bool runOnce = false;
+            string cfgFileName = "";
+
+            // detect command line usage
+            foreach (string arg in args)
+            {
+                if (arg.Substring(0, 5) == "-cfg=")
+                {
+                    runOnce = true;
+                    cfgFileName = arg.Substring(5);
+                    break;
+                }
+            }
+
+            // launch GUI
+            Application.EnableVisualStyles();
+            Application.SetCompatibleTextRenderingDefault(false);
+            Application.Run(new MainForm(runOnce, cfgFileName));
+        }
+    }
+}
\ No newline at end of file
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/Properties/Resources.Designer.cs b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/Properties/Resources.Designer.cs
new file mode 100644 (file)
index 0000000..8887040
--- /dev/null
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.239
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace OMAP_L138_AIS_GUI.Properties {
+    using System;
+    
+    
+    /// <summary>
+    ///   A strongly-typed resource class, for looking up localized strings, etc.
+    /// </summary>
+    // This class was auto-generated by the StronglyTypedResourceBuilder
+    // class via a tool like ResGen or Visual Studio.
+    // To add or remove a member, edit your .ResX file then rerun ResGen
+    // with the /str option, or rebuild your VS project.
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    internal class Resources {
+        
+        private static global::System.Resources.ResourceManager resourceMan;
+        
+        private static global::System.Globalization.CultureInfo resourceCulture;
+        
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal Resources() {
+        }
+        
+        /// <summary>
+        ///   Returns the cached ResourceManager instance used by this class.
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Resources.ResourceManager ResourceManager {
+            get {
+                if (object.ReferenceEquals(resourceMan, null)) {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OMAP_L138_AIS_GUI.Properties.Resources", typeof(Resources).Assembly);
+                    resourceMan = temp;
+                }
+                return resourceMan;
+            }
+        }
+        
+        /// <summary>
+        ///   Overrides the current thread's CurrentUICulture property for all
+        ///   resource lookups using this strongly typed resource class.
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Globalization.CultureInfo Culture {
+            get {
+                return resourceCulture;
+            }
+            set {
+                resourceCulture = value;
+            }
+        }
+    }
+}
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/Properties/Resources.resx b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/Properties/Resources.resx
new file mode 100644 (file)
index 0000000..af7dbeb
--- /dev/null
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>
\ No newline at end of file
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/Properties/Settings.Designer.cs b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/Properties/Settings.Designer.cs
new file mode 100644 (file)
index 0000000..55608c7
--- /dev/null
@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     This code was generated by a tool.
+//     Runtime Version:4.0.30319.239
+//
+//     Changes to this file may cause incorrect behavior and will be lost if
+//     the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace OMAP_L138_AIS_GUI.Properties {
+    
+    
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
+    internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+        
+        private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+        
+        public static Settings Default {
+            get {
+                return defaultInstance;
+            }
+        }
+    }
+}
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/Properties/Settings.settings b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/Properties/Settings.settings
new file mode 100644 (file)
index 0000000..3964565
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
+  <Profiles>
+    <Profile Name="(Default)" />
+  </Profiles>
+  <Settings />
+</SettingsFile>
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/README.txt b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/README.txt
new file mode 100644 (file)
index 0000000..0326050
--- /dev/null
@@ -0,0 +1,202 @@
+================================================================================
+ README.txt - AISgen GUI for d800k008/6/4/2 Bootloader
+
+ April 12, 2012
+--------------------------------------------------------------------------------
+This file lists changes between versions of the AISgen GUI.  For information
+on how to use the GUI, please see the application reports on your device's
+webpage on www.ti.com.
+--------------------------------------------------------------------------------
+
+Changes in version 1.12
+Bug Fixes
+---------
+-> Enabled duplication of DDR configuration in boot images to support mDDR with support for SRR commands.
+
+
+Changes in version 1.11
+
+Bug Fixes
+---------
+-> Fixes multiple possible issues with ELF executable parsing.
+
+Enhancements
+------------
+-> Renaming project, adding it to FlashAndBootUtils package.
+
+
+--------------------------------------------------------------------------------
+Changes in version 1.10
+
+Bug Fixes
+---------
+-> Fixed an issue that could cause tabs to display incorrectly in certain
+   circumstances.
+
+Enhancements
+------------
+-> Added "(2x)" to the DDR clock label to make it more clear that this is the
+   2X_CLK signal (i.e. PLL1_SYSCLK1), not the clock output by the DDR module.
+
+
+--------------------------------------------------------------------------------
+Changes in version 1.9
+
+Bug Fixes
+---------
+-> Added a check to prevent users from enabling PSC1 module 8.  This module
+   requires a forced transition that is not supported by the bootloader.
+
+Enhancements
+------------
+-> Added support for d800k008 ROM bootloader.  Selected by default in
+   "device type" drop down box.
+-> Added support for MMC/SD0 boot mode (d800k008 ROM only)
+
+
+--------------------------------------------------------------------------------
+Changes in version 1.8
+
+Bug Fixes
+---------
+-> Corrected an issue that could prevent UART boot mode from working when PLL0
+   was not configured
+
+
+--------------------------------------------------------------------------------
+Changes in version 1.7
+
+Bug Fixes
+---------
+-> Corrected CFG file parsing issue that prevented PLL1 post divider settings
+   from being applied.
+-> Set tab order of UI elements to be more intuitive
+
+Enhancements
+------------
+-> PLL0 can now be configured to reach CPU speeds above 300 MHz.  Check
+   your part's datasheet to see its maximum CPU frequency.  All other
+   speed limits (ex. peripheral clocks) are unchanged.
+
+
+--------------------------------------------------------------------------------
+Changes in version 1.6
+
+Bug Fixes
+---------
+-> Corrected issue with peripheral clocks when running the tool from
+   the command line.
+
+Enhancements
+------------
+-> Section load opcodes are now sorted from lowest to highest memory
+   address (ex. section at 0x80000000 loaded before section at
+   0x80000100).
+
+
+--------------------------------------------------------------------------------
+Changes in version 1.5
+
+Bug Fixes
+---------
+-> Corrected issue with very large input files.
+-> The utility will no longer attempt to use peripheral clock dividers
+   (or prescale dividers) that do not fit in the appropriate field.  For
+   instance, the maximum UART clock divider is 65,535 (0xFFFF).
+
+Enhancements
+------------
+-> Added support for d800k006 ROM bootloader.  Selected by default in
+   "device type" drop down box.
+-> UART boot modes: the baud rate is now configurable in the Peripheral
+   tab.  This allows UART boot to be used when the input clock is not
+   24 MHz.  See the app note for information on the UART clock
+   selection pins (not applicable to the d800k002 ROM).
+-> UART clock dividers must obtain an actual UART baud rate within 10%
+   of the user-specified baud.  AIS generation will fail if a suitable
+   divider can't be found.
+-> I2C and SPI master boot modes: the actual peripheral speed is now
+   allowed to exceed the specified value in the special case that the
+   peripheral clock divider is set to its maximum value and the clock
+   is still faster than the specified value.  (This should only ever
+   happen for very low speeds in I2C master boot modes.)
+
+
+--------------------------------------------------------------------------------
+Changes in version 1.4
+
+Bug Fixes
+---------
+(none)
+
+Enhancements
+------------
+-> Added support for d800k004 ROM bootloader.  Selected by default in
+   "device type" drop down box.
+-> Added "no config" option under boot mode selection.  This option
+   explicitly disabled peripheral clock configuration to produce a
+   simpler AIS file.  Note: using this option with PLL configuration
+   selected is dangerous and can cause your boot process to freeze.
+-> I2C and SPI master boot modes: the actual peripheral clock is now
+   chosen to be as close as possible without exceeding the user-
+   specified value.
+
+
+--------------------------------------------------------------------------------
+Changes in version 1.3
+
+Bug Fixes
+---------
+-> Fixed miscellaneous issues with ELF file parsing
+-> Fixed issues when specifying an application entrypoint with various
+   combinations of object and binary files.
+
+Enhancements
+------------
+-> Application object files no longer need the extension .out to be
+   recognized.  Also, files with the .out extension that don't contain
+   valid COFF or ELF headers will be treated as binary files.
+
+
+--------------------------------------------------------------------------------
+Changes in version 1.2
+
+Bug Fixes
+---------
+-> Fixed issue with binary input files (previously did not save entire
+   contents of file to AIS)
+
+Enhancements
+------------
+-> Added support for ELF files (in addition to COFF and simple binary)
+-> Added command line usage: AISgen_d800k002.exe -cfg="<CFG file name>"
+   (uses CFG file previously generated using GUI)
+-> Added ability to configure mDDR via bootloader patch function
+-> Renamed "DDR2" tab to "DDR" and added DDR2/mDDR selection on that tab
+-> Added SDCR2 register to DDR tab
+
+
+--------------------------------------------------------------------------------
+Changes in version 1.1
+
+Bug Fixes
+---------
+-> The SDRAM tab will now display the correct clock when PLL0 is left
+   in bypass mode (it previously always assumed PLL0 was configured)
+-> Fixed an exception caused by saving SDRAM configuration to a CFG
+   file (caused by format error in CFG file itself)
+
+Enhancements
+------------
+-> Changed label text from "LPSC" to "PSC" and "Domain" to "LPSC" to be
+   consistent with PSC documentation
+-> Disallowed creating AIS files when only binary files are given with
+   no entrypoint
+-> Clarified some DDR and SDRAM register names:
+        SDTIMR      -> SDTIMR1
+        DDRPHYC1R   -> DRPYC1R
+        SDBCR       -> SDCR
+        SDRSRPDEXIT -> SDSRETR 
+
+--------------------------------------------------------------------------------
+End of README.TXT
\ No newline at end of file
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/Settings.cs b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/Settings.cs
new file mode 100644 (file)
index 0000000..fa5ef94
--- /dev/null
@@ -0,0 +1,28 @@
+namespace OMAP_L138_AIS_GUI.Properties {
+    
+    
+    // This class allows you to handle specific events on the settings class:
+    //  The SettingChanging event is raised before a setting's value is changed.
+    //  The PropertyChanged event is raised after a setting's value is changed.
+    //  The SettingsLoaded event is raised after the setting values are loaded.
+    //  The SettingsSaving event is raised before the setting values are saved.
+    internal sealed partial class Settings {
+        
+        public Settings() {
+            // // To add event handlers for saving and changing settings, uncomment the lines below:
+            //
+            // this.SettingChanging += this.SettingChangingEventHandler;
+            //
+            // this.SettingsSaving += this.SettingsSavingEventHandler;
+            //
+        }
+        
+        private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
+            // Add code to handle the SettingChangingEvent event here.
+        }
+        
+        private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
+            // Add code to handle the SettingsSaving event here.
+        }
+    }
+}
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/makefile b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISGen_GUI/makefile
new file mode 100644 (file)
index 0000000..be9a051
--- /dev/null
@@ -0,0 +1,18 @@
+PROGRAM:=AISGen_GUI
+
+AISEXTRAPATH:=../AISextra
+ARM_AISEXTRAIMAGE:=$(AISEXTRAPATH)/ARM_AISExtra_$(DEVSTRING).out
+DSP_AISEXTRAIMAGE:=$(AISEXTRAPATH)/DSP_AISExtra_$(DEVSTRING).out
+
+.PHONY : all clean
+
+$(ARM_AISEXTRAIMAGE) $(DSP_AISEXTRAIMAGE):
+               make -C $(AISEXTRAPATH) all
+
+all: 
+%:: $(ARM_AISEXTRAIMAGE) $(DSP_AISEXTRAIMAGE)
+    # Build all required flash writers
+               MSBuild.exe $(PROGRAM).sln /t:Rebuild
+
+clean:
+               MSBuild.exe $(PROGRAM).sln /t:Clean
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISextra/makefile b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISextra/makefile
new file mode 100644 (file)
index 0000000..e7df776
--- /dev/null
@@ -0,0 +1,7 @@
+all:
+               $(MAKE) -C src
+clean:
+               $(MAKE) -C src clean
+%::
+               $(MAKE) -C src $@
+               
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISextra/src/ARM_AISExtra.lds b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISextra/src/ARM_AISExtra.lds
new file mode 100644 (file)
index 0000000..d1a024e
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ *  Desc: Linker command file sft application program.
+ */
+MEMORY 
+{
+  L3RAM       : o = 0x80000000, l = 128K
+  PARAM_RAM   : o = 0xFFFF0020, l = 64
+}
+
+SECTIONS 
+{
+  
+  EXTERNAL_RAM_SIZE   = 0x10000000;  
+  EXTERNAL_RAM_START  = 0xC0000000;
+  EXTERNAL_RAM_END    = EXTERNAL_RAM_START + EXTERNAL_RAM_SIZE;
+  
+  ASYNC_MEM_START     = 0x02000000;
+
+  IRAM_START          = 0x80000000;
+  IRAM_SIZE           = 0x00008000;
+
+  INTERNAL_RAM_START = 0x80000000;
+  INTERNAL_RAM_SIZE  = 0x00008000;
+  
+  STACK_START         = 0x80008800;
+  STACK_SIZE          = 0x00000800;
+  
+  PARAMS_RAM          = 0xFFFF0020;
+  
+  .text    : 
+  {
+    *(.text:.start)
+    *(.text)
+    . = ALIGN(4);
+  } > L3RAM
+  
+  /* Move into DRAM for placing const and data sections */
+  .rodata    :
+  {
+    *(.rodata*)
+    *(.rodata)
+    . = ALIGN(4);
+  } > L3RAM
+  .data    : 
+  {
+    *(.data)
+    . = ALIGN(4);
+  } > L3RAM
+        
+  .bss    :
+  {
+    *(.bss) *(COMMON)
+    . = ALIGN(4);
+  } > L3RAM
+  
+  .params (NOLOAD) :
+  {
+    *(.params)
+  } > PARAM_RAM
+}
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISextra/src/DSP_AISExtra.cmd b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISextra/src/DSP_AISExtra.cmd
new file mode 100644 (file)
index 0000000..a45e085
--- /dev/null
@@ -0,0 +1,32 @@
+-m aisextra_dsp.map
+
+MEMORY
+{
+  L1D_PARAM   org=0x00F00000 len=0x00000040 /* Function Args */
+       L2RAM               org=0x00801000 len=0x00002000 /* L2 RAM/Cache */
+  EMIFB_MEM   org=0xC0000000 len=0x10000000 /* DDR EMIF3a memory */
+}
+
+SECTIONS
+{
+       .params           > L1D_PARAM
+       .cinit      > L2RAM
+       .text       > L2RAM
+       .const      > L2RAM
+       .bss        > L2RAM
+       .far                > L2RAM
+       .switch           > L2RAM
+       .data       > L2RAM
+       .stack      > L2RAM
+    .fardata    > L2RAM
+    .fardata    > L2RAM
+    .neardata   > L2RAM
+    .rodata     > L2RAM
+    
+  .sdram
+  {
+    . += 0x10000000;
+  } load=EMIFB_MEM, type=DSECT, FILL=0x00000000, START(EXTERNAL_RAM_START)  
+}
+
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISextra/src/aisextra.c b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISextra/src/aisextra.c
new file mode 100644 (file)
index 0000000..be008b4
--- /dev/null
@@ -0,0 +1,188 @@
+/* --------------------------------------------------------------------------
+    FILE        : aisxtra.c                                                                            
+    PURPOSE     : AIS Extra commands for use in AIS Scripts
+    PROJECT     : TI Boot and Flash Utilities
+    AUTHOR      : Daniel Allred
+ ----------------------------------------------------------------------------- */
+
+/************************************************************
+* Include Files                                             *
+************************************************************/
+#include "tistdtypes.h"
+#include "device.h"
+
+
+/************************************************************
+* Explicit External Declarations                            *
+************************************************************/
+
+extern __FAR__ Uint32 EXTERNAL_RAM_START;
+
+
+/************************************************************
+* Local Macro Declarations                                  *
+************************************************************/
+
+
+/************************************************************
+* Local Typedef Declarations                                *
+************************************************************/
+
+
+/************************************************************
+* Local Function Declarations                               *
+************************************************************/
+
+
+/************************************************************
+* Local Variable Definitions                                *
+************************************************************/
+
+
+/************************************************************
+* Global Variable Definitions                               *
+************************************************************/
+#if defined(__TMS320C6X__)
+  
+       #pragma DATA_SECTION(paramTable,".params")
+       Uint32 paramTable[16];
+
+#elif defined(__GNUC__)
+       Uint32 paramTable[16] __attribute__((,section(".params")));
+#endif
+
+/************************************************************
+* Global Function Definitions                               *
+************************************************************/
+
+#if defined(__TMS320C6X__)
+  #pragma CODE_SECTION(PatchDDRConfig,".text")
+  void PatchDDRConfig()  {
+#elif defined(__GNUC__)
+  void PatchDDRConfig() __attribute__((,section(".text")));
+  void PatchDDRConfig() {
+#endif
+  VUint32 data_tmp;
+  VUint32 *DDRStart = (VUint32 *) ((Uint32 *) EXTERNAL_RAM_START);
+  Uint32 ddrphycr = paramTable[0];
+  Uint32 sdcr = paramTable[1];
+  Uint32 sdtimr = paramTable[2];
+  Uint32 sdtimr2 = paramTable[3];
+  Uint32 sdrcr = paramTable[4];
+  Uint32 sdcr2 = paramTable[5];
+  
+  // Set the DDR2 to enable
+  {  
+    // Wait for any outstanding transition to complete
+    while ( (PSC1->PTSTAT) & (0x00000001 << PD0) );
+    
+    // If we are already in that state, just return
+    if (((PSC1->MDSTAT[LPSC_EMIFB]) & 0x1F) == PSC_ENABLE) return;
+      
+    // Perform transition
+    PSC1->MDCTL[LPSC_EMIFB] = ((PSC1->MDCTL[LPSC_EMIFB]) & (0xFFFFFFE0)) | (PSC_ENABLE);
+    PSC1->PTCMD |= (0x00000001 << PD0);
+
+    // Wait for transition to complete
+    while ( (PSC1->PTSTAT) & (0x00000001 << PD0) );
+    
+    // Wait and verify the state
+    while (((PSC1->MDSTAT[LPSC_EMIFB]) & 0x1F) != PSC_ENABLE);
+  }
+
+  // Begin VTP Calibration
+  // If VTP claiberation enabled, then skip the VTP calibration
+  if (SUBCHIPCFG->VTPIO_CTL & 0x00000040)
+  {
+    SUBCHIPCFG->VTPIO_CTL |= DEVICE_VTPIO_CTL_IOPWRDN_MASK;     // Set IOPWRDN bit to enable input buffer powerdown enable mode
+    SUBCHIPCFG->VTPIO_CTL &= ~(DEVICE_VTPIO_CTL_POWERDN_MASK);  // Clear POWERDN bit (enable VTP)
+    
+    SUBCHIPCFG->VTPIO_CTL &= ~(DEVICE_VTPIO_CTL_LOCK_MASK);     // Clear LOCK bit
+
+    // Pulse (low) CLRZ to initiate VTP IO Calibration
+    SUBCHIPCFG->VTPIO_CTL |= DEVICE_VTPIO_CTL_CLKRZ_MASK;       // Set CLRZ bit 
+    SUBCHIPCFG->VTPIO_CTL &= ~(DEVICE_VTPIO_CTL_CLKRZ_MASK);    // Clear CLRZ bit (CLRZ should be low for at least 2ns)
+    SUBCHIPCFG->VTPIO_CTL |= DEVICE_VTPIO_CTL_CLKRZ_MASK;       // Set CLRZ bit 
+
+    // Polling READY bit to see when VTP calibration is done
+    while(!((SUBCHIPCFG->VTPIO_CTL & DEVICE_VTPIO_CTL_READY_MASK)>>DEVICE_VTPIO_CTL_READY_SHIFT));
+
+    SUBCHIPCFG->VTPIO_CTL |= DEVICE_VTPIO_CTL_LOCK_MASK;        // Set LOCK bit for static mode
+    SUBCHIPCFG->VTPIO_CTL |= DEVICE_VTPIO_CTL_PWRSAVE_MASK;     // Set PWRSAVE bit to save power
+  }
+  // End VTP Calibration
+  
+  // Config DDR timings
+  EMIF3A->DDRPHYC1R   = ddrphycr;
+
+  // Clear the unlock bits (in case user accidentally set them)
+  sdcr = sdcr & (~DEVICE_SDCR_BOOTUNLOCK_MASK) & (~DEVICE_SDCR_TIMUNLOCK_MASK);
+  
+  // Set SDCR with BOOTUNLOCK Set and TIMUNLOCK cleared
+  EMIF3A->SDCR        = sdcr | ((0x1 << DEVICE_SDCR_BOOTUNLOCK_SHIFT) & DEVICE_SDCR_BOOTUNLOCK_MASK);
+  
+  // Set SDCR with BOOTUNLOCK cleared and TIMUNLOCK set
+  EMIF3A->SDCR        = sdcr | ((0x1 << DEVICE_SDCR_TIMUNLOCK_SHIFT) & DEVICE_SDCR_TIMUNLOCK_MASK);
+  
+  // Check if this init is for mDDR
+  if (sdcr & DEVICE_SDCR_MSDRAMEN_MASK)
+  {
+    // If it is, set SDCR2 with PASR and ROWSIZE PARAMS
+    EMIF3A->SDCR2     = sdcr2;
+  }
+                        
+  EMIF3A->SDTIMR      = sdtimr;
+  EMIF3A->SDTIMR2     = sdtimr2;
+
+  // Clear TIMUNLOCK bit
+  EMIF3A->SDCR        &= (~DEVICE_SDCR_TIMUNLOCK_MASK); 
+  EMIF3A->SDRCR       = sdrcr;
+
+  // Set the DDR2 to syncreset
+  {
+    EMIF3A->SDRCR |= 0xC0000000;  // Set to self-refresh, enable mclkstop
+    // Wait for any outstanding transition to complete
+    while ( (PSC1->PTSTAT) & (0x00000001 << PD0) );
+    
+    // If we are already in that state, just return
+    if (((PSC1->MDSTAT[LPSC_EMIFB]) & 0x1F) == PSC_SYNCRESET) return;
+      
+    // Perform transition
+    PSC1->MDCTL[LPSC_EMIFB] = ((PSC1->MDCTL[LPSC_EMIFB]) & (0xFFFFFFE0)) | (PSC_SYNCRESET);
+    PSC1->PTCMD |= (0x00000001 << PD0);
+
+    // Wait for transition to complete
+    while ( (PSC1->PTSTAT) & (0x00000001 << PD0) );
+    
+    // Wait and verify the state
+    while (((PSC1->MDSTAT[LPSC_EMIFB]) & 0x1F) != PSC_SYNCRESET);
+  }
+
+  // Set the DDR2 to enable
+  {
+    // Wait for any outstanding transition to complete
+    while ( (PSC1->PTSTAT) & (0x00000001 << PD0) );
+    
+    // If we are already in that state, just return
+    if (((PSC1->MDSTAT[LPSC_EMIFB]) & 0x1F) == PSC_ENABLE) return;
+      
+    // Perform transition
+    PSC1->MDCTL[LPSC_EMIFB] = ((PSC1->MDCTL[LPSC_EMIFB]) & (0xFFFFFFE0)) | (PSC_ENABLE);
+    PSC1->PTCMD |= (0x00000001 << PD0);
+
+    // Wait for transition to complete
+    while ( (PSC1->PTSTAT) & (0x00000001 << PD0) );
+    
+    // Wait and verify the state
+    while (((PSC1->MDSTAT[LPSC_EMIFB]) & 0x1F) != PSC_ENABLE);
+    EMIF3A->SDRCR &= ~(0xC0000000);  // disable self-refresh
+  }
+  
+  // Dummy write/read to apply timing settings
+  *DDRStart = 0xA55AA55A;               // write
+  data_tmp = *DDRStart;                 // read
+  *DDRStart = data_tmp;
+}
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISextra/src/makefile b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISextra/src/makefile
new file mode 100644 (file)
index 0000000..1894258
--- /dev/null
@@ -0,0 +1,59 @@
+#############################################################
+# Makefile for TI AISExtra project.                         #
+#   Generates the COFF AISExtra file which is used to       #
+#   supplement the AIS ROM bootloader                       #
+#############################################################
+#
+
+# CROSSCOMPILE definition for entire tree
+include ../../../../../Common/build.mak
+include ../../../../device.mak
+
+PROGRAM:=AISExtra
+
+DSP_CC=$(DSP_CROSSCOMPILE)cl6x
+ARM_CC=$(CROSSCOMPILE)gcc
+
+SOURCES=aisextra.c
+
+DSP_OBJECTS:=$(patsubst %.c,./dsp_obj/%.obj,$(SOURCES))
+DSP_EXECUTABLE:=../DSP_$(PROGRAM)_$(DEVSTRING).out
+DSP_LINKERSCRIPT:=DSP_AISExtra.cmd
+
+DSP_CFLAGS=-O=2 -c --obj_directory=./dsp_obj -I=../../../../../Common/include -I=../../../../Common/include -I=../../../Common/include -I=../include -ms3 -mo -mv6740 --symdebug:none
+DSP_LNKFLAGS=-z -a -uPatchDDRConfig -w -x
+
+ARM_OBJECTS:=$(patsubst %.c,./arm_obj/%.obj,$(SOURCES))
+ARM_EXECUTABLE:=../ARM_$(PROGRAM)_$(DEVSTRING).out
+ARM_LINKERSCRIPT:=ARM_AISExtra.lds
+
+ARM_CFLAGS= -I../../../../../Common/include -I../../../../Common/include -I../../../Common/include -I../include -c -Os -Wall -ffreestanding -o $@
+ARM_LNKFLAGS=-Wl,-T$(ARM_LINKERSCRIPT) -nostdlib -u PatchDDRConfig
+
+
+all: $(DSP_EXECUTABLE) $(ARM_EXECUTABLE) $(DSP_OBJECTS) $(ARM_OBJECTS) 
+
+.PHONY : clean objclean
+clean:
+               -rm -f -v $(DSP_OBJECTS) $(ARM_OBJECTS) $(DSP_EXECUTABLE) $(ARM_EXECUTABLE)
+               
+objclean:
+               -rm -f -v $(DSP_OBJECTS) $(ARM_OBJECTS)
+
+$(DSP_EXECUTABLE): $(DSP_OBJECTS) $(DSP_LINKERSCRIPT) 
+               $(DSP_CC) $(DSP_LNKFLAGS) -o=$@ $(DSP_LINKERSCRIPT) $(DSP_OBJECTS)
+               
+./dsp_obj/%.obj : %.c
+               @mkdir -p dsp_obj  
+               $(DSP_CC) $(DSP_CFLAGS) $<
+    
+$(ARM_EXECUTABLE): $(ARM_OBJECTS) $(ARM_LINKERSCRIPT)
+               $(ARM_CC) $(ARM_LNKFLAGS) $(ARM_OBJECTS) -o $@ 
+
+./arm_obj/%.obj : %.c
+               @mkdir -p arm_obj
+               $(ARM_CC) $(ARM_CFLAGS) $<
+
+vpath %.c ../../../../../Common/src:../../../../Common/src:../../../Common/src:../../Common/src:../src        
+vpath %.h ../../../../../Common/include:../../../../Common/include:../../../Common/include:../../Common/include:../include       
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISgen.exe b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISgen.exe
new file mode 100644 (file)
index 0000000..06333eb
Binary files /dev/null and b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/AISgen.exe differ
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/NAND_ECC_Patch/makefile b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/NAND_ECC_Patch/makefile
new file mode 100644 (file)
index 0000000..e7df776
--- /dev/null
@@ -0,0 +1,7 @@
+all:
+               $(MAKE) -C src
+clean:
+               $(MAKE) -C src clean
+%::
+               $(MAKE) -C src $@
+               
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/NAND_ECC_Patch/src/ARM.cmd b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/NAND_ECC_Patch/src/ARM.cmd
new file mode 100644 (file)
index 0000000..cdfff7c
--- /dev/null
@@ -0,0 +1,22 @@
+-m patch_arm.map
+
+MEMORY
+{
+  PATCH_RAM       org=0xffff0b00 len=0x00000500 /* Small unused portion of ARM internal memory */
+}
+
+SECTIONS
+{
+    .data:nand_ecc_patch > 0xffff0b00
+    .text:nand_ecc_patch > PATCH_RAM
+    .text:bl1_nand_abort > PATCH_RAM
+    .text:close_boot     > PATCH_RAM
+    .const                      > PATCH_RAM
+    .bss                        > PATCH_RAM
+    .far                        > PATCH_RAM
+    .switch                     > PATCH_RAM
+    .data                       > PATCH_RAM
+    .stack                      > PATCH_RAM
+}
+
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/NAND_ECC_Patch/src/ARM.lds b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/NAND_ECC_Patch/src/ARM.lds
new file mode 100644 (file)
index 0000000..d1a024e
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ *  Desc: Linker command file sft application program.
+ */
+MEMORY 
+{
+  L3RAM       : o = 0x80000000, l = 128K
+  PARAM_RAM   : o = 0xFFFF0020, l = 64
+}
+
+SECTIONS 
+{
+  
+  EXTERNAL_RAM_SIZE   = 0x10000000;  
+  EXTERNAL_RAM_START  = 0xC0000000;
+  EXTERNAL_RAM_END    = EXTERNAL_RAM_START + EXTERNAL_RAM_SIZE;
+  
+  ASYNC_MEM_START     = 0x02000000;
+
+  IRAM_START          = 0x80000000;
+  IRAM_SIZE           = 0x00008000;
+
+  INTERNAL_RAM_START = 0x80000000;
+  INTERNAL_RAM_SIZE  = 0x00008000;
+  
+  STACK_START         = 0x80008800;
+  STACK_SIZE          = 0x00000800;
+  
+  PARAMS_RAM          = 0xFFFF0020;
+  
+  .text    : 
+  {
+    *(.text:.start)
+    *(.text)
+    . = ALIGN(4);
+  } > L3RAM
+  
+  /* Move into DRAM for placing const and data sections */
+  .rodata    :
+  {
+    *(.rodata*)
+    *(.rodata)
+    . = ALIGN(4);
+  } > L3RAM
+  .data    : 
+  {
+    *(.data)
+    . = ALIGN(4);
+  } > L3RAM
+        
+  .bss    :
+  {
+    *(.bss) *(COMMON)
+    . = ALIGN(4);
+  } > L3RAM
+  
+  .params (NOLOAD) :
+  {
+    *(.params)
+  } > PARAM_RAM
+}
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/NAND_ECC_Patch/src/DSP.cmd b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/NAND_ECC_Patch/src/DSP.cmd
new file mode 100644 (file)
index 0000000..a0995f9
--- /dev/null
@@ -0,0 +1,28 @@
+-m patch_dsp.map
+
+MEMORY
+{
+  L2RAM       org=0x00800000 len=0x00001000 /* Use start of DSP L2 RAM */
+}
+
+SECTIONS
+{
+    .data:nand_ecc_patch > 0x00800000
+    .text:nand_ecc_patch > L2RAM
+    .text:bl1_nand_abort > L2RAM
+    .text       > L2RAM
+    .const      > L2RAM
+    .bss        > L2RAM
+    .far        > L2RAM
+    .switch     > L2RAM
+    .data       > L2RAM
+    .stack      > L2RAM
+    .fardata    > L2RAM
+    .fardata    > L2RAM
+    .neardata   > L2RAM
+    .rodata     > L2RAM
+    
+    
+}
+
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/NAND_ECC_Patch/src/makefile b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/NAND_ECC_Patch/src/makefile
new file mode 100644 (file)
index 0000000..e6cfa7d
--- /dev/null
@@ -0,0 +1,60 @@
+#############################################################
+# Makefile for TI AISExtra project.                         #
+#   Generates the COFF AISExtra file which is used to       #
+#   supplement the AIS ROM bootloader                       #
+#############################################################
+#
+
+# CROSSCOMPILE definition for entire tree
+include ../../../../../Common/build.mak
+include ../../../../device.mak
+
+PROGRAM:=nand_ecc_patch
+
+DSP_CC=$(DSP_CROSSCOMPILE)cl6x
+ARM_CC=$(TI_ARM_CROSSCOMPILE)gcc
+
+SOURCES=nand_ecc_patch.c
+
+DSP_OBJECTS:=$(patsubst %.c,./dsp_obj/%.obj,$(SOURCES))
+DSP_EXECUTABLE:=../DSP_$(PROGRAM)_$(DEVSTRING).out
+DSP_LINKERSCRIPT:=DSP.cmd
+
+DSP_CFLAGS=-O=2 -c --obj_directory=./dsp_obj -I=$(DSP_INC_PATH) -I=../include -ms3 -mo -mv6740 --symdebug:none
+DSP_LNKFLAGS=-z -a -uNAND_ECC_info -uNAND_ECC_patchApply -w -x -l$(DSP_LIB_PATH)/rts6740_elf.lib
+
+
+ARM_OBJECTS:=$(patsubst %.c,./arm_obj/%.obj,$(SOURCES))
+ARM_EXECUTABLE:=../ARM_$(PROGRAM)_$(DEVSTRING).out
+ARM_LINKERSCRIPT:=ARM.lds
+
+ARM_CFLAGS= -I=$(TI_ARM_INC_PATH) -I=../include -c -Os -Wall -ffreestanding -o $@
+ARM_LNKFLAGS= -uNAND_ECC_info -nostdlib -uNAND_ECC_patchApply
+
+
+all: $(DSP_EXECUTABLE) $(ARM_EXECUTABLE) $(DSP_OBJECTS) $(ARM_OBJECTS) 
+
+.PHONY : clean objclean
+clean:
+               -rm -f -v $(DSP_OBJECTS) $(ARM_OBJECTS) $(DSP_EXECUTABLE) $(ARM_EXECUTABLE)
+               
+objclean:
+               -rm -f -v $(DSP_OBJECTS) $(ARM_OBJECTS)
+
+$(DSP_EXECUTABLE): $(DSP_OBJECTS) $(DSP_LINKERSCRIPT) 
+               $(DSP_CC) $(DSP_LNKFLAGS) -o=$@ $(DSP_LINKERSCRIPT) $(DSP_OBJECTS)
+               
+./dsp_obj/%.obj : %.c
+               @mkdir -p dsp_obj  
+               $(DSP_CC) $(DSP_CFLAGS) $<
+    
+$(ARM_EXECUTABLE): $(ARM_OBJECTS) $(ARM_LINKERSCRIPT)
+               $(ARM_CC) $(ARM_LNKFLAGS) -T$(ARM_LINKERSCRIPT) $(ARM_OBJECTS) -o $@ 
+
+./arm_obj/%.obj : %.c
+               @mkdir -p arm_obj
+               $(ARM_CC) $(ARM_CFLAGS) $<
+
+vpath %.c ../../../../../Common/src:../../../../Common/src:../../../Common/src:../../Common/src:../src        
+vpath %.h ../../../../../Common/include:../../../../Common/include:../../../Common/include:../../Common/include:../include       
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/NAND_ECC_Patch/src/nand_ecc_patch.c b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/NAND_ECC_Patch/src/nand_ecc_patch.c
new file mode 100644 (file)
index 0000000..4d1b49e
--- /dev/null
@@ -0,0 +1,540 @@
+/* --------------------------------------------------------------------------
+    FILE        : nand_ecc_patch.c                                                                             
+    PROJECT     : Catalog boot and flash utils
+    AUTHOR      : Daniel Allred
+    DESC        : Patch to correct ECC correction functionality for ROM boot
+                  loader
+-------------------------------------------------------------------------- */ 
+
+
+/************************************************************
+* Include Files                                             *
+************************************************************/
+
+#include <stdint.h>
+
+
+/************************************************************
+* Explicit External Declarations                            *
+************************************************************/
+
+
+/************************************************************
+* Local Typedef/Enum Definitions                            *
+************************************************************/
+
+// NAND ECC function typedefs
+typedef uint32_t (*NAND_ECC_Correct)(void *unused, uint8_t *data, uint8_t *readECC);
+
+// NAND_INFO structure - holds pertinent info for open driver instance
+typedef struct _NAND_INFO_
+{
+  uint32_t    flashBase;          // Base address of CS memory space where NAND is connected
+  uint8_t     busWidth;           // NAND bus width
+  uint8_t     manfID;             // NAND manufacturer ID (just for informational purposes)
+  uint8_t     devID;              // NAND_TABLE_Devices index (device ID)
+  uint32_t    numBlocks;          // block count per device
+  uint16_t    pagesPerBlock;      // page count per block
+  uint16_t    pagesPerBlockPower2;     // power of 2 shift for page count per block
+  uint16_t    dataBytesPerPage;   // Number of bytes in a page
+  uint16_t    dataBytesPerPagePower2;  // power of 2 shift for number of bytes in a page
+  uint16_t    spareBytesPerPage;  // Number of spare bytes in a page  
+  uint16_t    dataBytesPerOp;     // Number of bytes per operation
+  uint16_t    spareBytesPerOp;    // Number of spare bytes per operation
+  uint8_t     numOpsPerPage;      // Number of operations to complete a page read/write  
+  uint8_t     numColAddrBytes;    // Number of Column address cycles
+  uint8_t     numRowAddrBytes;    // Number of Row address cycles
+  uint8_t     CSOffset;           // 0 for CS2 space, 1 for CS3 space, 2 for CS4 space, 3 for CS5 space  
+  uint16_t    isLargePage;        // TRUE = Big block device, FALSE = small block device
+  uint16_t    isONFI;             // TRUE = ONFI-compatible device, FALSE = non-ONFI device
+  int32_t     currBlock;          // current Block in use
+  uint16_t    isBlockGood;        // TRUE=current block is good, FALSE=block is bad
+  void        *hPageLayout;
+  struct _NAND_ECC_INFO_ *hEccInfo;
+  void        *hBbInfo;
+  void        *hChipInfo;
+} 
+NAND_InfoObj, *NAND_InfoHandle;
+
+typedef struct _NAND_ECC_INFO_
+{
+  volatile uint16_t ECCEnable;                 // Error correction enable (should be on by default)  
+  volatile uint16_t calcECCByteCnt;            // Count of ECC bytes per op as read from HW registers
+  volatile uint16_t storedECCByteCnt;          // Count of ECC bytes per op as stored in the NAND page
+  volatile uint16_t unused;                    // Filler
+  volatile uint32_t pFxnCalculate;
+  volatile uint32_t pFxnStore;
+  volatile uint32_t pFxnEnable;
+  volatile uint32_t pFxnDisable;
+  volatile uint32_t pFxnRead;
+  volatile NAND_ECC_Correct pFxnCorrect;
+}
+NAND_ECC_InfoObj;
+
+// AEMIF Register structure - From EMIF 2.5 Spec
+typedef struct _DEVICE_EMIF25_REGS_
+{
+  volatile uint32_t ERCSR;              // 0x00
+  volatile uint32_t AWCCR;              // 0x04
+  volatile uint32_t SDBCR;              // 0x08
+  volatile uint32_t SDRCR;              // 0x0C
+
+  volatile uint32_t A1CR;               // 0x10
+  volatile uint32_t A2CR;               // 0x14
+  volatile uint32_t A3CR;               // 0x18
+  volatile uint32_t A4CR;               // 0x1C
+
+  volatile uint32_t SDTIMR;             // 0x20
+  volatile uint32_t SDRSTAT;            // 0x24
+  volatile uint32_t DDRPHYCR;           // 0x28
+  volatile uint32_t DDRPHYSR;           // 0x2C
+
+  volatile uint32_t SDRACCR;            // 0x30
+  volatile uint32_t SDRACT;             // 0x34
+  volatile uint32_t DDRPHYREV;          // 0x38
+  volatile uint32_t SDRSRPDEXIT;        // 0x3C
+
+  volatile uint32_t EIRR;               // 0x40
+  volatile uint32_t EIMR;               // 0x44
+  volatile uint32_t EIMSR;              // 0x48
+  volatile uint32_t EIMCR;              // 0x4C
+
+  volatile uint32_t IOCR;               // 0x50
+  volatile uint32_t IOSR;               // 0x54
+  volatile uint8_t RSVD0[4];            // 0x58
+  volatile uint32_t ONENANDCTL;         // 0x5C  
+
+  volatile uint32_t NANDFCR;            // 0x60
+  volatile uint32_t NANDFSR;            // 0x64
+  volatile uint32_t PMCR;               // 0x68
+  volatile uint8_t RSVD1[4];            // 0x6C
+
+  volatile uint32_t NANDF1ECC;          // 0x70
+  volatile uint32_t NANDF2ECC;          // 0x74
+  volatile uint32_t NANDF3ECC;          // 0x78
+  volatile uint32_t NANDF4ECC;          // 0x7C
+
+  volatile uint8_t RSVD2[4];            // 0x80
+  volatile uint32_t IODFTEXECNT;        // 0x84
+  volatile uint32_t IODFTGBLCTRL;       // 0x88
+  volatile uint8_t RSVD3[4];            // 0x8C
+
+  volatile uint32_t IODFTMISRLSB;       // 0x90
+  volatile uint32_t IODFTMISRMID;       // 0x94
+  volatile uint32_t IODFTMISRMSB;       // 0x98
+  volatile uint8_t RSVD4[20];           // 0x9C
+
+  volatile uint32_t MODRELNUM;          // 0xB0
+  volatile uint8_t RSVD5[8];            // 0xB4
+  volatile uint32_t NAND4BITECCLOAD;    // 0xBC
+
+  volatile uint32_t NAND4BITECC1;       // 0xC0
+  volatile uint32_t NAND4BITECC2;       // 0xC4
+  volatile uint32_t NAND4BITECC3;       // 0xC8
+  volatile uint32_t NAND4BITECC4;       // 0xCC
+
+  volatile uint32_t NANDERRADD1;        // 0xD0
+  volatile uint32_t NANDERRADD2;        // 0xD4
+  volatile uint32_t NANDERRVAL1;        // 0xD8
+  volatile uint32_t NANDERRVAL2;        // 0xDC
+}
+DEVICE_Emif25Regs;
+
+// D800K008 boot loader struct definition (for patching abort function)
+
+// Dummy declaration
+struct _BOOTLOADER_CONFIG_;
+
+typedef void (*voidFxnPtr) (void);
+typedef uint32_t (*blProtocolImplementFn) (struct _BOOTLOADER_CONFIG_ *bl1Handle, uint32_t state);
+typedef uint32_t (*blOpenFn)              (struct _BOOTLOADER_CONFIG_ *bl1Handle);
+typedef uint32_t (*blSyncWordExchangeFn)  (struct _BOOTLOADER_CONFIG_ *bl1Handle, uint32_t* syncWord);
+typedef uint32_t (*blReadFn)              (struct _BOOTLOADER_CONFIG_ *bl1Handle, uint8_t *dest, uint32_t byteCnt);
+typedef uint32_t (*blWriteFn)             (struct _BOOTLOADER_CONFIG_ *bl1Handle, uint8_t *src, uint32_t byteCnt);
+typedef uint32_t (*blCloseFn)             (struct _BOOTLOADER_CONFIG_ *bl1Handle);
+typedef uint32_t (*blPatchFn)             (struct _BOOTLOADER_CONFIG_ *bl1Handle);
+typedef void     (*blAbortFn)             (struct _BOOTLOADER_CONFIG_ *bl1Handle, uint32_t statusValue);
+
+typedef struct _BOOTLOADER_CONFIG_
+{
+    // 0x00
+    uint8_t                 state;
+    uint8_t                 errorCode;
+    uint16_t                isMaster;    //unsigned short
+
+    //0x04
+    uint8_t                 crcEnabled;
+    uint8_t                 bootPeripheral;
+    uint8_t                 devNumber;
+    uint8_t                 bitsPerShot;
+
+    //0x08
+    uint8_t                 seqRead;
+    uint8_t                 crcErrorCount;
+    uint16_t                isSecure; //unsigned short
+
+    //0x0C
+    uint8_t                 unused0C;
+    uint8_t                 keyInstalled;
+    uint16_t                bootPins;
+  
+    //0x10
+    uint16_t                bootMode;
+    uint8_t                 unused12[2];
+    uint32_t                secureType;
+
+    //0x18
+    uint32_t                exitType;
+    uint16_t                skStarted;  // unsigned short
+    //0x1E
+    uint8_t                 unused1E[2];
+
+    //0x20
+    uint32_t                bitsPerShotShift;
+    uint32_t                signatureByteCnt;
+
+    //0x28
+    uint16_t                addressBits;
+    uint16_t                unused2A;
+    uint16_t                unused2C;
+    uint16_t                unused2E;
+
+    //0x30
+    uint32_t                addr;                    // hpiJumpAddr
+    uint32_t                data;
+    uint32_t                opcode;
+    uint32_t                crc;
+
+    //0x40
+    voidFxnPtr              entryPoint;
+    uint32_t                seqRdAddr;
+    uint32_t                bootSearchOffset;
+    volatile uint32_t       *bootSearchOffsetAddr;
+
+    //0x50
+    uint32_t                crcReturnAddress;
+    uint32_t                robustMode;
+    blSyncWordExchangeFn    syncWordExchange;
+    void *REGS;
+
+    //0x60
+    blOpenFn                openPeripheral;
+    blReadFn                readBytes;
+    blWriteFn               writeBytes;
+    blCloseFn               closePeripheral;
+
+    //0x70
+    blPatchFn               patch;
+    blProtocolImplementFn   protocolImplement;
+    voidFxnPtr              finalFxn;
+    blAbortFn               abortFxn;
+
+    //0x80 - Used by NAND and SDMMC driver
+    void                    *nandInfo;
+    void                    *sdmmcMemInfo;
+    uint32_t                nandCurrPage;
+    uint32_t                nandCurrBlock;
+  
+    //0x90
+    uint8_t                 *memBuffer;
+    uint32_t                memCurrAddr;
+    uint32_t                memBufferPtr;
+    uint32_t                bytesLeftInBuff;  
+}
+BL_CfgObject, *BL_CfgHandle;
+
+// NAND function types
+typedef uint32_t (* NAND_readPage) (struct _NAND_INFO_ *nandInfo, uint32_t block, uint32_t page, uint8_t *dest);
+typedef uint32_t (* NAND_badBlockCheck) (struct _NAND_INFO_ *nandInfo, uint32_t block);
+
+// Secure boot function types
+typedef uint32_t (* SBL1_init) (struct  _BOOTLOADER_CONFIG_ *bl1Handle);
+
+/************************************************************
+* Local Macro Declarations                                  *
+************************************************************/
+
+#define AEMIF ((DEVICE_Emif25Regs*) 0x68000000u)
+#define BL_MST_KEYWORD_CHECK        (1)
+#define BL_ERROR_NONE               (0)
+#define BL_ERROR_NAND_READ_FAIL     (26)
+#define NAND_MAX_UBL_SEARCH_BLOCK   (32)
+#define E_PASS (0x00000000u)
+
+#define TRUE    ((unsigned short) 1)
+
+/************************************************************
+* Local Function Declarations                               *
+************************************************************/
+
+static uint32_t NAND_ECC_correct(void *unused, uint8_t *data, uint8_t *readECC);
+
+
+/************************************************************
+* Local Variable Definitions                                *
+************************************************************/
+
+
+/************************************************************
+* Global Variable Definitions                               *
+************************************************************/
+
+#pragma DATA_SECTION(NAND_ECC_info,".data:nand_ecc_patch")
+NAND_ECC_InfoObj NAND_ECC_info;
+
+
+/************************************************************
+* Global Function Definitions                               *
+************************************************************/
+
+#pragma CODE_SECTION (BL_NAND_abortBoot, ".text:bl1_nand_abort")
+void BL_NAND_abortBoot(BL_CfgHandle bl1Handle, uint32_t statusValue)
+{
+ #if defined(__TMS320C6X__)
+    NAND_readPage pNAND_rp = (NAND_readPage) 0x00714aac;
+    NAND_badBlockCheck pNAND_BBCheck = (NAND_badBlockCheck) 0x0071494c;
+    blAbortFn  pBL1_abortBoot = (blAbortFn) 0x00712100;
+ #else
+    NAND_readPage pNAND_rp = (NAND_readPage) 0xfffd0534;
+    NAND_badBlockCheck pNAND_BBCheck = (NAND_badBlockCheck) 0xfffd039c;
+    blAbortFn  pBL1_abortBoot = (blAbortFn) 0xfffd45b0;
+ #endif
+    bl1Handle->errorCode = statusValue;
+    while ( (BL_ERROR_NAND_READ_FAIL == bl1Handle->errorCode) &&
+            (bl1Handle->nandCurrBlock < NAND_MAX_UBL_SEARCH_BLOCK) )
+    {
+        // Previous block failed. Move to start of the next.
+        bl1Handle->nandCurrBlock +=1;
+        bl1Handle->nandCurrPage = 0;
+
+        // Check if the block is good, if not let's skip
+        if ((*pNAND_BBCheck)(bl1Handle->nandInfo,bl1Handle->nandCurrBlock) != E_PASS)
+        {
+            continue;
+        }
+
+        // Try to buffer up the first page
+        if ((*pNAND_rp)(bl1Handle->nandInfo, bl1Handle->nandCurrBlock, bl1Handle->nandCurrPage, bl1Handle->memBuffer) != E_PASS) 
+        {
+            bl1Handle->errorCode = BL_ERROR_NAND_READ_FAIL;
+            continue;
+        }
+
+#if defined(__TMS320C6X__)
+       if  ( bl1Handle->isSecure == TRUE)
+       {
+        SBL1_init pSbl_init= (SBL1_init)0x007fc600;
+
+        // Secure boot loader init (needed for booting both types of secure devices)
+        (*pSbl_init)(bl1Handle);
+       }
+#endif
+
+        // Get back into the AIS parsing routine
+        bl1Handle->signatureByteCnt = 0;
+        bl1Handle->addr = 0;
+        bl1Handle->memCurrAddr = 0;
+        bl1Handle->memBufferPtr = 0;
+        bl1Handle->bytesLeftInBuff = ((NAND_InfoHandle)bl1Handle->nandInfo)->dataBytesPerPage;
+        
+        bl1Handle->errorCode = (*(bl1Handle->protocolImplement)) (bl1Handle, BL_MST_KEYWORD_CHECK);
+        if (BL_ERROR_NONE == bl1Handle->errorCode)
+        {
+            // Boot image was completely parsed, so we can exit this patched abort function and finish the boot.
+            // We should be returning to the BL1_startBoot function in bl1.c
+            return;
+        }
+    }
+        
+    // For all other errors, or if we run out of blocks, it's crash and burn time in the original ROM abort fxn
+    pBL1_abortBoot(bl1Handle, statusValue);
+}
+
+#pragma CODE_SECTION(NAND_ECC_patchApply,".text:nand_ecc_patch")
+void NAND_ECC_patchApply( void )
+{
+#if defined(__TMS320C6X__)
+    uint8_t *rev = (uint8_t *) 0x0070000F;
+       BL_CfgHandle bl1Handle = (BL_CfgHandle) 0x00F00700;
+#else
+    uint8_t *rev = (uint8_t *) 0xFFFD000F;
+       BL_CfgHandle bl1Handle = (BL_CfgHandle) 0xFFFF0700;
+#endif
+    NAND_ECC_info.ECCEnable         = 1;
+    NAND_ECC_info.calcECCByteCnt    = 16;
+    NAND_ECC_info.storedECCByteCnt  = 10;
+    NAND_ECC_info.pFxnCorrect       = &NAND_ECC_correct;
+    
+    if ((*rev) == 0x36)
+    {
+        /* ROM Version D800K006 */
+#if defined(__TMS320C6X__)
+        /* DSP ROM addresses */
+        NAND_ECC_info.pFxnCalculate   = 0x00715920;   // &(DEVICE_NAND_ECC_calculate)
+        NAND_ECC_info.pFxnStore       = 0x007159b0;   // &(DEVICE_NAND_ECC_store)
+        NAND_ECC_info.pFxnEnable      = 0x00715af8;   // &(DEVICE_NAND_ECC_enable)
+        NAND_ECC_info.pFxnDisable     = 0x00715b60;   // &(DEVICE_NAND_ECC_disable)
+        NAND_ECC_info.pFxnRead        = 0x00715bc0;   // &(DEVICE_NAND_ECC_read)
+        
+        /* Replace the NAND_ECC_Info pointer in the NAND_Info structure in RAM */
+        *((NAND_ECC_InfoObj **) 0x00F007C4) = &NAND_ECC_info;        
+#else
+        /* ARM ROM addresses */
+        NAND_ECC_info.pFxnCalculate   = 0xFFFD4358;   // &(DEVICE_NAND_ECC_calculate),
+        NAND_ECC_info.pFxnStore       = 0xFFFD43D8;   // &(DEVICE_NAND_ECC_store),
+        NAND_ECC_info.pFxnEnable      = 0xFFFD4540;   // &(DEVICE_NAND_ECC_enable),
+        NAND_ECC_info.pFxnDisable     = 0xFFFD459C;   // &(DEVICE_NAND_ECC_disable),
+        NAND_ECC_info.pFxnRead        = 0xFFFD45F8;   // &(DEVICE_NAND_ECC_read),
+        
+        /* Replace the NAND_ECC_Info pointer in the NAND_Info structure in RAM */
+        *((NAND_ECC_InfoObj **) 0xFFFF07C4) = &NAND_ECC_info;
+               
+#endif
+    }
+    else if ((*rev) == 0x38)
+    {
+        /* ROM Version D800K008 */
+               bl1Handle->abortFxn = &BL_NAND_abortBoot;
+#if defined(__TMS320C6X__)
+        /* DSP ROM addresses */
+        NAND_ECC_info.pFxnCalculate   = 0x00716260;   // &(DEVICE_NAND_ECC_calculate)
+        NAND_ECC_info.pFxnStore       = 0x007162e4;   // &(DEVICE_NAND_ECC_store)
+        NAND_ECC_info.pFxnEnable      = 0x00716410;   // &(DEVICE_NAND_ECC_enable)
+        NAND_ECC_info.pFxnDisable     = 0x00716468;   // &(DEVICE_NAND_ECC_disable)
+        NAND_ECC_info.pFxnRead        = 0x007164b8;   // &(DEVICE_NAND_ECC_read)
+        
+        /* Replace the NAND_ECC_Info pointer in the NAND_Info structure in RAM */
+        *((NAND_ECC_InfoObj **) 0x00F007D0) = &NAND_ECC_info;
+#else
+        /* ARM ROM addresses */
+        NAND_ECC_info.pFxnCalculate   = 0xFFFD5B00;   // &(DEVICE_NAND_ECC_calculate)
+        NAND_ECC_info.pFxnStore       = 0xFFFD5B80;   // &(DEVICE_NAND_ECC_store)
+        NAND_ECC_info.pFxnEnable      = 0xFFFD5CE8;   // &(DEVICE_NAND_ECC_enable)
+        NAND_ECC_info.pFxnDisable     = 0xFFFD5D44;   // &(DEVICE_NAND_ECC_disable)
+        NAND_ECC_info.pFxnRead        = 0xFFFD5DA0;   // &(DEVICE_NAND_ECC_read)
+        
+        /* Replace the NAND_ECC_Info pointer in the NAND_Info structure in RAM */
+        *((NAND_ECC_InfoObj **) 0xFFFF07D0) = &NAND_ECC_info;
+#endif
+    }
+}
+
+
+
+/************************************************************
+* Local Function Definitions                                *
+************************************************************/
+
+#pragma CODE_SECTION(NAND_ECC_correct,".text:nand_ecc_patch")
+static uint32_t NAND_ECC_correct(void *unused, uint8_t *data, uint8_t *readECC)
+{
+  volatile uint32_t temp, corrState, numE;
+  int i;
+  uint16_t addOffset, corrValue;
+  uint16_t* syndrome10 = (uint16_t *)readECC;
+
+  // Clear bit13 of NANDFCR
+  temp = AEMIF->NANDERRADD1;
+  
+  // Load the syndrome10 (from 7 to 0) values
+  for(i=8;i>0;i--)
+  {
+    AEMIF->NAND4BITECCLOAD = (syndrome10[i-1] & 0x000003FF);
+  }
+  
+  // Read the EMIF status and version (dummy call) 
+  temp = AEMIF->ERCSR;
+  
+  // Check if error is detected
+  temp = (AEMIF->NAND4BITECC1 & 0x03FF03FF) | (AEMIF->NAND4BITECC2 & 0x03FF03FF) |
+         (AEMIF->NAND4BITECC3 & 0x03FF03FF) | (AEMIF->NAND4BITECC4 & 0x03FF03FF);
+  if(temp == 0)
+  {
+    return 0;
+  }
+
+  // Start calcuating the correction addresses and values
+  AEMIF->NANDFCR |= (0x1U << 13);
+
+  // Read the EMIF status and version (dummy call to allow previous write to complete) 
+  temp = AEMIF->ERCSR;
+  
+  // Loop until timeout or the ECC calculations are complete (bit 11:10 == 00b)
+  i = 1000;
+  do
+  {
+    temp = (AEMIF->NANDFSR & 0x00000F00)>>10;
+    i--;
+  }
+  while((i>0) && (temp != 0x0));
+
+  // Read final correction state (should be 0x0, 0x1, 0x2, or 0x3)
+  corrState = (AEMIF->NANDFSR & 0x00000F00) >> 8;
+
+  if ((corrState == 1) || (corrState > 3))
+  {
+    temp = AEMIF->NANDERRVAL1;
+    return 1;
+  }
+  else if (corrState == 0)
+  {
+    return 0;
+  }
+  else
+  {
+    // Error detected and address calculated
+    // Number of errors corrected 17:16
+    numE = (AEMIF->NANDFSR & 0x00030000) >> 16;
+
+    switch( numE )
+    {
+      case 3:     // Four errors
+        addOffset = 519 - ( (AEMIF->NANDERRADD2 & (0x03FF0000))>>16 );
+        if (addOffset < 512)
+        {
+            // Error in the user data region can be corrected
+            corrValue = (AEMIF->NANDERRVAL2 & (0x03FF0000))>>16;
+            data[addOffset] ^= (uint8_t)corrValue;
+        }
+        // Fall through to case 2
+      case 2:     // Three errors
+        addOffset = 519 - (AEMIF->NANDERRADD2 & (0x000003FF));
+        if (addOffset < 512)
+        {
+            // Error in the user data region can be corrected
+            corrValue = AEMIF->NANDERRVAL2 & (0x000003FF);
+            data[addOffset] ^= (uint8_t)corrValue;
+        }
+        // Fall through to case 1
+      case 1:     // Two errors
+        addOffset = 519 - ( (AEMIF->NANDERRADD1 & (0x03FF0000))>>16 );
+        if (addOffset < 512)
+        {
+            // Error in the user data region can be corrected
+            corrValue = (AEMIF->NANDERRVAL1 & (0x03FF0000))>>16;
+            data[addOffset] ^= (uint8_t)corrValue;
+        }
+        // Fall through to case 0
+      case 0:     // One error
+        addOffset = 519 - (AEMIF->NANDERRADD1 & (0x000003FF));
+        if (addOffset < 512)
+        {
+            // Error in the user data region can be corrected
+            corrValue = AEMIF->NANDERRVAL1 & (0x3FF);
+            data[addOffset] ^= (uint8_t)corrValue;
+        }
+        break;
+    }
+    return 0;
+  }
+}
+
+
+
+/***********************************************************
+* End file                                                 *
+***********************************************************/
+
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/makefile b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/makefile
new file mode 100644 (file)
index 0000000..738cabf
--- /dev/null
@@ -0,0 +1,8 @@
+DIRS:=$(wildcard *)
+
+all:
+%::
+               @for i in $(DIRS); do \
+                               if [ -d $${i} ]; then if [ -e $${i}/makefile ]; then make -C $${i} $@; fi; fi; \
+               done
+               
\ No newline at end of file
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/readme.txt b/tools/omapl13x_boot_utils/OMAP-L138/GNU/AISUtils/readme.txt
new file mode 100644 (file)
index 0000000..321468f
--- /dev/null
@@ -0,0 +1,308 @@
+ /***************************************************************
+ *  TI OMAP-L138 AIS Utilities                                  *
+ *  (C) 2009-2010 Texas Instruments, Inc.                       *
+ *                                                              *
+ ***************************************************************/
+This directory contains the source and build files for various utilities 
+associated with booting flashing the OMAP-L138 SoC device. These utilities 
+include 
+  HexAIS          - Command-line AIS generation utility for non-secure OMAP-L138 devices
+  UartHost        - GUI application to boot non-secure AIS images over the serial port
+
+Running
+=======
+
+These applications are built on the Microsoft's .Net framework.  To use them, you 
+must run them on a system that has the Microsoft .Net framework v3.5 installed.  
+Alternatively, you can run them using the open-source Mono framework v2.4 or later.
+This may allow the applications to be run under Linux, since Mono exists and runs on 
+that platform.
+
+NOTE: On windows, using the mono framework requires you to use the mono executable.  With
+      Mono in your path, the usage is as follows:
+        mono <ApplicationName> <ApplicationParams>
+      If the mono command is left off, the Microsoft framework will be used instead.
+      
+
+HexAIS tool
+===========
+The HexAIS and tool relies on its input parameters to be provided in INI files, 
+example of which are included in the package.  The ini files are processed in order and are 
+primarily used to specify what AIS Function Execute commands you want to use to initialize the 
+system. The comments in the INI file themselves provide a rough documentation.
+
+The tools have a number of options that can be specified on the command line.  You can run the 
+program with the -h option to see the help screen for each program.
+
+Command Syntax
+==============
+
+HexAIS_OMAP-L138 [Options] [Input File Names]
+        <Option> can be any of the following:
+                -h                      Show this help screen.
+                -entrypoint <Addr>      Force specified entry point for AIS boot image.
+                -ini <INI file name>    Specify the ini file (default is OMAP-L138.ini).
+                -otype <Output Type>    Specify type of output file, from following:.
+                     binary                  Create a binary AIS file (.bin), default.
+                     carray                  Create a text file with AIS data in a C array (.c).
+                     srecord@addr            Create a Motorola S-record format (.srec) at addr.
+                     text                    Create a text file with AIS data as ASCII text (.txt).
+                -o <Output File Name>   Explicitly specify the output filename.
+                                        Default is input file name with extension based on
+                                        output type.
+                                        
+Input files (ELF or COFF object files OR Binary files) can be supplied on the command line 
+or via the INI file.  Binary files must be supplied with a load address, so they are specified
+in the following manner:
+  <Binary File Name>@<Hex Load Address>
+
+It is recommended to use the INI file syntax for placing and including files since 
+that provides greater flexibility (see below).
+
+
+Complete INI Syntax
+===================
+
+The INI file consists of a collection of INI sections.  Except for the [General] sections,
+which describe configuration information for the AIS file, the INI sections are processed
+in order and result in contents being added to the generated AIS output.  Each INI section
+contains a collection of fields which are described below:
+
+  Configuration
+  -------------
+  [GENERAL]
+  ; Can be 8 or 16 - used in emifa (NOR boot mode)
+  busWidth=8            
+
+  ; SPIMASTER,I2CMASTER,EMIFA,NAND,EMAC,UART,PCI,HPI,USB,MMC_SD,VLYNQ,RAW
+  BootMode=Specify boot mode (typically use NONE).  Some boot modes can require 
+           certain extra information beyond the actual AIS data. The tools
+           may support generating this information depending on the boot mode selection.
+
+  ; TRUE/ON or FALSE/OFF
+  seqReadEn=Specify that sequential read should be used for I2C or SPI master modes. This
+            is equivalent to using the [AIS_SeqReadEnable] section (see below).
+
+  Include a file
+  --------------  
+  The INPUTFILE section allows including a binary or object file into the AIS boot
+  image.  The result of this INI section will be one or more AIS SectionLoad or 
+  EncryptedSectionLoad commands inserted into the AIS output.  Note that input files
+  can be specified on the command line, but using individual [INPUTFILE] sections
+  offer more control over placement and content.
+  
+
+  [INPUTFILE]
+  FILENAME=Filename of the binary or object file to include in the AIS iamge
+  LOADADDRESS=Address to which file contents are loaded. If specified, input file is treated as a
+              binary file. For object files, the load address for loadable sections is embedded
+              in the object file itself.
+  ENTRYPOINTADDRESS=Allows specifying the entry point for this module. This is typically used
+                    with binary files since object files embed the entry point.
+  USEENTRYPOINT=Set to YES or TRUE to ensure that the entrypoint is taken from this input file
+                for the JUMP_CLOSE command
+
+                
+  Insert ROM Function Calls (AIS Function Execute)
+  ------------------------------------------------
+  These INI sections are used to insert specific AIS Function Execute
+  commands into the AIS output.
+  
+  ; This section allows setting the PLL0 system clock with a  
+  ; specified multiplier and divider as shown. The clock source
+  ; can also be chosen for internal or external.
+  ;           |------24|------16|-------8|-------0|
+  ; PLL0CFG0: | CLKMODE| PLLM   | PREDIV | POSTDIV|
+  ; PLL0CFG1: | RSVD   | PLLDIV1| PLLDIV3| PLLDIV7|
+  [PLL0CONFIG]
+  PLL0CFG0=
+  PLL0CFG1=
+
+  ; This section allows setting up the PLL1. Usually this will 
+  ; take place as part of the EMIF3a DDR setup. The format of
+  ; the input args is as follows:
+  ;           |------24|------16|-------8|-------0|
+  ; PLL1CFG0: |    PLLM| POSTDIV| PLLDIV1| PLLDIV2|
+  ; PLL1CFG1: |           RSVD           | PLLDIV3|  
+  [PLL1CONFIG]
+  PLL1CFG0=
+  PLL1CFG1=
+
+  ; This section lets us configure the peripheral interface
+  ; of the current booting peripheral (I2C, SPI, or UART).
+  ; Use with caution. The format of the PERIPHCLKCFG field 
+  ; is as follows:
+  ; SPI:        |------24|------16|-------8|-------0|
+  ;             |           RSVD           |PRESCALE|
+  ;
+  ; I2C:        |------24|------16|-------8|-------0|
+  ;             |  RSVD  |PRESCALE|  CLKL  |  CLKH  |
+  ;
+  ; UART:       |------24|------16|-------8|-------0|
+  ;             | RSVD   |  OSR   |  DLH   |  DLL   |  
+  [PERIPHCLKCFG]
+  PERIPHCLKCFG=
+
+  ; This section can be used to configure the PLL1 and the EMIF3a registers
+  ; for starting the DDR2 interface. 
+  ; See PLL1CONFIG section for the format of the PLL1CFG fields.
+  ;            |------24|------16|-------8|-------0|
+  ; PLL1CFG0:  |              PLL1CFG              |
+  ; PLL1CFG1:  |              PLL1CFG              |
+  ; DDRPHYC1R: |             DDRPHYC1R             |
+  ; SDCR:      |              SDCR                 |
+  ; SDTIMR:    |              SDTIMR               |
+  ; SDTIMR2:   |              SDTIMR2              |
+  ; SDRCR:     |              SDRCR                |
+  ; CLK2XSRC:  |             CLK2XSRC              |
+  [EMIF3DDR]
+  PLL1CFG0=
+  PLL1CFG1=
+  DDRPHYC1R=
+  SDCR=
+  SDTIMR=
+  SDTIMR2=
+  SDRCR=
+  CLK2XSRC=
+  
+  ; This section can be used to configure the EMIFA to use 
+  ; CS0 as an SDRAM interface.  The fields required to do this
+  ; are given below.
+  ;                     |------24|------16|-------8|-------0|
+  ; SDBCR:              |               SDBCR               |
+  ; SDTIMR:             |               SDTIMR              |
+  ; SDRSRPDEXIT:        |             SDRSRPDEXIT           |
+  ; SDRCR:              |               SDRCR               |
+  ; DIV4p5_CLK_ENABLE:  |         DIV4p5_CLK_ENABLE         |
+  [EMIF25SDRAM]
+  SDBCR=
+  SDTIMR=
+  SDRSRPDEXIT=
+  SDRCR=
+  DIV4p5_CLK_ENABLE=
+
+  ; This section can be used to configure the async chip selects
+  ; of the EMIFA (CS2-CS5).  The fields required to do this
+  ; are given below.
+  ;           |------24|------16|-------8|-------0|
+  ; A1CR:     |                A1CR               |
+  ; A2CR:     |                A2CR               |
+  ; A3CR:     |                A3CR               |
+  ; A4CR:     |                A4CR               |
+  ; NANDFCR:  |              NANDFCR              |  
+  [EMIF25ASYNC]
+  A1CR=
+  A2CR=
+  A3CR=
+  A4CR=
+  NANDFCR=
+  
+  ; This section should be used in place of PLL0CONFIG when
+  ; the I2C, SPI, or UART modes are being used.  This ensures that 
+  ; the system PLL and the peripheral's clocks are changed together.
+  ; See PLL0CONFIG section for the format of the PLL0CFG fields.
+  ; See PERIPHCLKCFG section for the format of the CLKCFG field.
+  ;               |------24|------16|-------8|-------0|
+  ; PLL0CFG0:     |              PLL0CFG              |
+  ; PLL0CFG1:     |              PLL0CFG              |
+  ; PERIPHCLKCFG: |              CLKCFG               |
+  [PLLANDCLOCKCONFIG]
+  PLL0CFG0=
+  PLL0CFG1=
+  PERIPHCLKCFG=
+
+  ; This section should be used to setup the power state of modules
+  ; of the two PSCs.  This section can be included multiple times to
+  ; allow the configuration of any or all of the device modules.
+  ;           |------24|------16|-------8|-------0|
+  ; LPSCCFG:  | PSCNUM | MODULE |   PD   | STATE  |  
+  [PSCCONFIG]
+  LPSCCFG=
+
+  ; This section allows setting of a single PINMUX register.
+  ; This section can be included multiple times to allow setting
+  ; as many PINMUX registers as needed.
+  ;         |------24|------16|-------8|-------0|
+  ; REGNUM: |              regNum               |
+  ; MASK:   |               mask                |
+  ; VALUE:  |              value                |  
+  [PINMUX]
+  REGNUM=
+  MASK=
+  VALUE=
+  
+  Insert AIS commands
+  -------------------
+  
+  ; Requires no fields, simply inserts AIS Enable CRC command
+  [AIS_EnableCRC]
+  
+  ; Requires no fields, simply inserts AIS Disable CRC command
+  [AIS_DisableCRC] 
+  
+  ; Requires no fields, simply inserts AIS Disable CRC command
+  [AIS_RequestCRC] 
+  CRCVALUE=CRC value for comparison for the Request CRC command
+  SEEKVALUE=Seek value for the the Request CRC command
+  
+  [AIS_Jump]
+  LOCATION=Raw address or symbol to which to jump
+  
+  [AIS_JumpClose]              
+  ENTRYPOINT=Raw address or symbol to which to jump upon close boot.  
+  
+  NOTE: The AIS JumpClose command is automatically inserted at the end of the boot
+  with the currently specified entry point.  Manually inserting this command will 
+  cause all commands following it to be ignored during boot, though the AIS file 
+  generated will still include all those extra commands.
+  
+  [AIS_Set]
+  TYPE=Type field for AIS SET/BOOT_TABLE command
+  ADDRESS=Address field for AIS SET/BOOT_TABLE command
+  DATA=Data field for AIS SET/BOOT_TABLE command
+  SLEEP=Sleep field for AIS SET/BOOT_TABLE command
+  
+  [AIS_SectionFill]
+  ADDRESS=Address field for AIS SECTION_FILL command
+  SIZE=Size field for AIS SECTION_FILL command
+  TYPE=Type field for AIS SECTION_FILL command
+  PATTERN=Pattern field for AIS SECTION_FILL command
+  
+  [AIS_ReadWait]
+  ADDRESS=Address field for READWAIT command
+  MASK=Mask field for READWAIT command
+  DATA=Data field for READWAIT command
+  
+  ; Requires no fields, simply inserts AIS Sequential Read command
+  [AIS_SeqReadEnable] 
+  
+  [AIS_FinalFunctionReg]
+  FINALFXNSYMBOLNAME=Symbol name of function that should be called after boot loading
+                     completes but before the ROM boot loader exits.
+
+
+
+Source
+======
+
+The source for each app will be in the application directory and in the top-level 
+Common directory (in Common/AIS and Common/UtilLib).  The makefiles in each directory
+give the names of all dependent source files.
+
+Compiling
+=========
+
+- Under Windows - 
+The currently supported method is to use the Cygwin enviroment and put the 
+C sharp compiler's (the csc.exe executable) install location in the user's
+path.  This compiler comes with the .NET Framework installation and can
+usually be found in C:\WINDOWS\Microsoft.NET\Framework\<version number>.
+
+In addition, the location of the C6000 Codegen tools should be in the 
+path (usually something like C:\CCStudio_v3.3\C6000\cgtools\bin). The TMS470
+build tools may also be required.
+
+Then go to the top level directory of the package and run:
+       
+       make
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/Common/AISGenLib/AISGen_OMAP-L138.cs b/tools/omapl13x_boot_utils/OMAP-L138/GNU/Common/AISGenLib/AISGen_OMAP-L138.cs
new file mode 100644 (file)
index 0000000..36fd493
--- /dev/null
@@ -0,0 +1,198 @@
+ /* --------------------------------------------------------------------------
+    FILE        : AISGen_OMAP-L138.cs
+    PROJECT     : TI Booting and Flashing Utilities
+    AUTHOR      : Daniel Allred
+    DESC        : Concrete AISGen class implemenatation for OMAP-L138
+ ----------------------------------------------------------------------------- */
+
+using System;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.IO;
+using System.IO.Ports;
+using System.Reflection;
+using System.Threading;
+using System.Globalization;
+using System.Collections;
+using TI.UtilLib.IO;
+using TI.UtilLib.CRC;
+
+namespace TI.AISLib
+{
+  /// <summary>
+  /// AISGen class that is specific to the device (inherits from abtract base class AISGen)
+  /// </summary>
+  public class AISGen_OMAP_L138:AISGen
+  {
+    /// <summary>
+    /// String definitions for built-in ROM functions
+    /// </summary>
+    public struct ROMFunctionNames
+    {
+      public const String PLL0Config          = "PLL0Config";
+      public const String PLL1Config          = "PLL1Config";
+      public const String PeriphClockConfig   = "PeriphClockConfig";
+      public const String EMIF3AConfigDDR     = "EMIF3AConfigDDR";
+      public const String EMIF25ConfigSDRAM   = "EMIF25ConfigSDRAM";
+      public const String EMIF25ConfigAsync   = "EMIF25ConfigAsync";
+      public const String PLLandClockConfig   = "PLLandClockConfig";
+      public const String PSCConfig           = "PSCConfig";
+      public const String PINMUXConfig        = "PinMuxConfig";
+      public const String FastBoot            = "FastBoot";
+      public const String IOPUConfig          = "IOPUConfig";
+      public const String MPUConfig           = "MPUConfig";
+      public const String TAPSConfig          = "TAPSConfig";
+    }
+    
+    /// <summary>
+    /// The public constructor for the DM637x device AIS generator.
+    /// The constructor is where the device differentiation is defined.
+    /// </summary>
+    public AISGen_OMAP_L138() : base()
+    {
+      // Define the device name - used for default file names
+      devNameShort = "OMAP-L138";
+      devNameLong = "OMAPL138";
+            
+      // Define OMAP-L138 ROM boot loader functions
+      ROMFunc = new AisROMFunction[13];
+      ROMFunc[0].funcName = ROMFunctionNames.PLL0Config;
+      ROMFunc[0].iniSectionName = "PLL0CONFIG";
+      ROMFunc[0].numParams = 2;
+      ROMFunc[0].paramNames = new String[2] { "PLL0CFG0", "PLL0CFG1" };
+      
+      ROMFunc[1].funcName = ROMFunctionNames.PLL1Config;
+      ROMFunc[1].iniSectionName = "PLL1CONFIG";
+      ROMFunc[1].numParams = 2;
+      ROMFunc[1].paramNames = new String[2] { "PLL1CFG0", "PLL1CFG1" };
+      
+      ROMFunc[2].funcName = ROMFunctionNames.PeriphClockConfig;
+      ROMFunc[2].iniSectionName = "PERIPHCLKCFG";
+      ROMFunc[2].numParams = 1;
+      ROMFunc[2].paramNames = new String[1] { "PERIPHCLKCFG" };
+
+      ROMFunc[3].funcName = ROMFunctionNames.EMIF3AConfigDDR;
+      ROMFunc[3].iniSectionName = "EMIF3DDR";
+      ROMFunc[3].numParams = 8;
+      ROMFunc[3].paramNames = new String[8] { "PLL1CFG0", "PLL1CFG1", "DDRPHYC1R", "SDCR", "SDTIMR", "SDTIMR2", "SDRCR", "CLK2XSRC" };
+
+      ROMFunc[4].funcName = ROMFunctionNames.EMIF25ConfigSDRAM;
+      ROMFunc[4].iniSectionName = "EMIF25SDRAM";
+      ROMFunc[4].numParams = 5;
+      ROMFunc[4].paramNames = new String[5] { "SDBCR", "SDTIMR", "SDRSRPDEXIT", "SDRCR", "DIV4p5_CLK_ENABLE" };
+      
+      ROMFunc[5].funcName = ROMFunctionNames.EMIF25ConfigAsync;
+      ROMFunc[5].iniSectionName = "EMIF25ASYNC";
+      ROMFunc[5].numParams = 5;
+      ROMFunc[5].paramNames = new String[5] { "A1CR", "A2CR", "A3CR", "A4CR", "NANDFCR" };
+      
+      ROMFunc[6].funcName = ROMFunctionNames.PLLandClockConfig;
+      ROMFunc[6].iniSectionName = "PLLANDCLOCKCONFIG";
+      ROMFunc[6].numParams = 3;
+      ROMFunc[6].paramNames = new String[3] { "PLL0CFG0", "PLL0CFG1", "PERIPHCLKCFG" };
+      
+      ROMFunc[7].funcName = ROMFunctionNames.PSCConfig;
+      ROMFunc[7].iniSectionName = "PSCCONFIG";
+      ROMFunc[7].numParams = 1;
+      ROMFunc[7].paramNames = new String[1] { "LPSCCFG" };
+
+      ROMFunc[8].funcName = ROMFunctionNames.PINMUXConfig;
+      ROMFunc[8].iniSectionName = "PINMUX";
+      ROMFunc[8].numParams = 3;
+      ROMFunc[8].paramNames = new String[3] { "REGNUM", "MASK", "VALUE" };
+      
+      ROMFunc[9].funcName = ROMFunctionNames.FastBoot;
+      ROMFunc[9].iniSectionName = "FASTBOOT";
+      ROMFunc[9].numParams = 0;
+      ROMFunc[9].paramNames = null;
+      
+      ROMFunc[10].funcName = ROMFunctionNames.IOPUConfig;
+      ROMFunc[10].iniSectionName = "IOPUCONFIG";
+      ROMFunc[10].numParams = 2;
+      ROMFunc[10].paramNames = new String[2] { "IOPUSELECT", "MPPAVALUE" };
+      
+      ROMFunc[11].funcName = ROMFunctionNames.MPUConfig;
+      ROMFunc[11].iniSectionName = "MPUCONFIG";
+      ROMFunc[11].numParams = 4;
+      ROMFunc[11].paramNames = new String[4] { "MPUSELECT", "STARTADDR" ,"ENDADDR" ,"MPPAVALUE" };
+      
+      ROMFunc[12].funcName = ROMFunctionNames.TAPSConfig;
+      ROMFunc[12].iniSectionName = "TAPSCONFIG";
+      ROMFunc[12].numParams = 1;
+      ROMFunc[12].paramNames = new String[1] { "TAPSCFG" };
+      
+      AISExtraFunc = new AisExtraFunction[4];
+      AISExtraFunc[0].funcName = "PatchDDRConfig";
+      AISExtraFunc[0].aisExtraFileName = "ARM_AISExtra_"+devNameShort+".out";
+      AISExtraFunc[0].iniSectionName = "ARM_EMIF3DDR_PATCHFXN";
+      AISExtraFunc[0].numParams = 6;
+      AISExtraFunc[0].paramNames = new String[6] { "DDRPHYC1R", "SDCR", "SDTIMR", "SDTIMR2", "SDRCR", "CLK2XSRC" };
+      AISExtraFunc[0].isInitFunc = false;
+      
+      AISExtraFunc[1].funcName = "PatchDDRConfig";
+      AISExtraFunc[1].aisExtraFileName = "DSP_AISExtra_"+devNameShort+".out";
+      AISExtraFunc[1].iniSectionName = "DSP_EMIF3DDR_PATCHFXN";
+      AISExtraFunc[1].numParams = 6;
+      AISExtraFunc[1].paramNames = new String[6] { "DDRPHYC1R", "SDCR", "SDTIMR", "SDTIMR2", "SDRCR", "CLK2XSRC" };
+      AISExtraFunc[1].isInitFunc = false;
+      
+      AISExtraFunc[2].funcName = "NAND_ECC_patchApply";
+      AISExtraFunc[2].aisExtraFileName = "ARM_nand_ecc_patch_"+devNameShort+".out";
+      AISExtraFunc[2].iniSectionName = "ARM_NAND_ECC_PATCHFXN";
+      AISExtraFunc[2].numParams = 0;
+      AISExtraFunc[2].paramNames = null;
+      AISExtraFunc[2].isInitFunc = false;
+      
+      AISExtraFunc[3].funcName = "NAND_ECC_patchApply";
+      AISExtraFunc[3].aisExtraFileName = "DSP_nand_ecc_patch_"+devNameShort+".out";
+      AISExtraFunc[3].iniSectionName = "DSP_NAND_ECC_PATCHFXN";
+      AISExtraFunc[3].numParams = 0;
+      AISExtraFunc[3].paramNames = null;
+      AISExtraFunc[3].isInitFunc = false;
+
+      // OMAP-L138 is little endian
+      devEndian = Endian.LittleEndian;
+      
+      // OMAP-L138 AIS data is little endian;
+      devAISEndian = Endian.LittleEndian;
+
+      // Create default CRC object for this device
+      devCRC = new CRC32(0x04C11DB7, 0xFFFFFFFF, 0xFFFFFFFF, true, 1, CRCType.INCREMENTAL, CRCCalcMethod.LUT);
+    } 
+    
+    public override retType InsertAISPreamble()
+    {
+      EndianBinaryWriter ebw = new EndianBinaryWriter( this.devAISStream, this.devEndian);
+    
+      switch (this.bootMode)
+      {
+        case AisBootModes.EMIFA:
+        {
+          if (this.busWidth == 16)
+          {
+            this.writer.Write((UInt32)(0x1 << 0)|(0x2 << 4));
+          }
+          else
+          {
+            this.writer.Write((UInt32)(0x0 << 0)|(0x2 << 4));
+          }
+          this.writer.Write((UInt32)AisOps.MagicNumber);
+          break;
+        }
+        default:
+        {
+          this.writer.Write((UInt32)AisOps.MagicNumber);
+          break;
+        }
+      }
+      
+      // Add the AIS magic number to signature buffer if a secure boot image
+      if ( this.SecureType != AisSecureType.NONE )
+      {
+        sigWriter.Write((UInt32)AisOps.MagicNumber);
+      }
+      
+      return retType.SUCCESS;
+    }
+  }
+} //end of AISGenLib namespace
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/GNU/makefile b/tools/omapl13x_boot_utils/OMAP-L138/GNU/makefile
new file mode 100644 (file)
index 0000000..a4aeaa8
--- /dev/null
@@ -0,0 +1,7 @@
+DIRS:=$(wildcard *)
+
+all:
+%::
+               @for i in $(DIRS); do \
+                               if [ -d $${i} ]; then if [ -e $${i}/makefile ]; then make -C $${i} $@; fi; fi; \
+               done
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/device.mak b/tools/omapl13x_boot_utils/OMAP-L138/device.mak
new file mode 100644 (file)
index 0000000..4048cb4
--- /dev/null
@@ -0,0 +1,16 @@
+#############################################################
+# Device and Flash types for Makefile use                   #
+#############################################################
+#
+
+# Generic string for device family
+DEVSTRING=OMAP-L138
+
+# Particular device types of the family
+ARM_DEVICETYPES:=OMAPL138 AM1808 AM1810 OMAPL138_LCDK
+DSP_DEVICETYPES:=C6748 C6748_LCDK
+DEVICETYPES:=$(ARM_DEVICETYPES) $(DSP_DEVICETYPES)
+
+# Supported flash memory types for booting
+FLASHTYPES:=SPI_MEM NAND NOR
+
diff --git a/tools/omapl13x_boot_utils/OMAP-L138/makefile b/tools/omapl13x_boot_utils/OMAP-L138/makefile
new file mode 100644 (file)
index 0000000..0fa8ddf
--- /dev/null
@@ -0,0 +1,10 @@
+DIRS:=$(wildcard *)
+
+all:
+%::
+# Make sure GNU stuff gets built first
+               make -C GNU $@
+#          make -C CCS $@
+#              @for i in $(DIRS); do \
+#                              if [ -d $${i} ]; then if [ -e $${i}/makefile ]; then make -C $${i} $@; fi; fi; \
+#              done
diff --git a/tools/omapl13x_sd_card_format/create-sdcard-omapl13x.sh b/tools/omapl13x_sd_card_format/create-sdcard-omapl13x.sh
new file mode 100644 (file)
index 0000000..a989ac0
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+user=`whoami`
+if [[ $user != "root" ]];
+then
+echo "Should run by root only ! (use : sudo)"
+exit 1
+fi
+
+if [ $# -eq 0 ]
+  then
+    echo "No arguments supplied ! (e.g, usage : sudo sh create-sdcard-omapl13x.sh /dev/sdb "
+exit 1
+fi
+
+DRIVE=$1
+
+# Un mount all the partitions.
+echo "Un mounting all the partitions..."
+
+sudo umount $DRIVE"1"
+
+dd if=/dev/zero of=$DRIVE bs=1024 count=1024
+
+SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`
+
+echo DISK SIZE - $SIZE bytes
+
+CYLINDERS=`echo $SIZE/255/63/512 | bc`
+
+# Start single partition starting at 2MB offset. First 2MB is used for boot image loading
+sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE << EOF
+2,,,*
+EOF
+
+mkfs.vfat -F 32 -n "boot" ${DRIVE}1
+umount ${DRIVE}1
+
+echo "Done !"