summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e0b55f2)
raw | patch | inline | side by side (parent: e0b55f2)
author | Bill Mills <wmills@ti.com> | |
Tue, 14 Sep 2010 22:02:49 +0000 (18:02 -0400) | ||
committer | Bill Mills <wmills@ti.com> | |
Tue, 14 Sep 2010 22:02:49 +0000 (18:02 -0400) |
Signed-off-by: Bill Mills <wmills@ti.com>
152 files changed:
diff --git a/.gitignore b/.gitignore
index 7d18c5e5a219cd60c72af2176818a214ba9bcd03..4d3f8bd8e5a228732c24ae8d9fcde67268e908a8 100644 (file)
--- a/.gitignore
+++ b/.gitignore
junk/
logs/
hacky-stuff/cgtools
-
-
diff --git a/src/arch/c64x/types.h b/src/arch/c64x/types.h
--- /dev/null
+++ b/src/arch/c64x/types.h
@@ -0,0 +1,68 @@
+#ifndef _TYPES_H
+#define _TYPES_H
+/*******************************************************************************
+ * FILE PURPOSE: DSP specific C type definitions.
+ *******************************************************************************
+ * FILE NAME: swpform.h
+ *
+ * DESCRIPTION: Defines general use types for DSP.
+ *
+ * @file types.h
+ *
+ * @brief
+ * This file provides architecture specific typedefs
+ *
+ ******************************************************************************/
+
+
+#include <stdlib.h> /* Defines NULL */
+
+/* a signed 16-bit integer */
+typedef short int16;
+typedef unsigned short uint16;
+
+typedef int int32;
+typedef unsigned int uint32;
+
+typedef char char8;
+typedef unsigned char uchar8;
+
+typedef char int8;
+typedef unsigned char uint8;
+
+
+typedef unsigned char word;
+
+typedef short BOOL;
+typedef short bool;
+typedef short Bool;
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+
+
+/* tistdtypes.h types used from the emac driver */
+typedef unsigned char Uint8;
+typedef char Int8;
+typedef int Int32;
+typedef unsigned short Uint16;
+typedef unsigned int Uint32;
+
+/* TI boot types */
+typedef unsigned char UINT8;
+typedef unsigned short UINT16;
+typedef unsigned int UINT32;
+
+
+/* Types from evm driver */
+typedef volatile unsigned int VUint32;
+typedef volatile unsigned char VUint8;
+
+/* Types from the ethernet driver */
+typedef unsigned int IPN;
+
+#endif /* types.h */
diff --git a/src/cfg/c6455/iblcfg.h b/src/cfg/c6455/iblcfg.h
--- /dev/null
+++ b/src/cfg/c6455/iblcfg.h
@@ -0,0 +1,47 @@
+/**************************************************************************
+ * FILE PURPOSE: Provide build time configurations for the IBL
+ **************************************************************************
+ * FILE NAME: iblcfg.h
+ *
+ * DESCRIPTION: Build time configuration
+ *
+ * @file iblcfg.h
+ *
+ * @brief
+ * Build time configurations for the c6455 ibl are defined
+ *
+ ***************************************************************************/
+#ifndef IBLCFG_H
+#define IBLCFG_H
+
+/**
+ * @brief The maximum number of UDP sockets in the system
+ */
+#define MAX_UDP_SOCKET 3
+
+
+/**
+ * @brief The maximum number of timers in the system
+ */
+#define MAX_TIMER_BLOCKS 5
+
+
+/**
+ * @brief The size in bytes of the internal stream buffer
+ */
+#define MAX_SIZE_STREAM_BUFFER 1024
+
+
+/**
+ * @brief The maximum number of functions supported for BIS mode
+ */
+#define MAX_BIS_FUNCTION_SUPPORT 3
+
+
+
+
+
+
+#endif
+
+
diff --git a/src/cfg/c6472/iblcfg.h b/src/cfg/c6472/iblcfg.h
--- /dev/null
+++ b/src/cfg/c6472/iblcfg.h
@@ -0,0 +1,62 @@
+/**************************************************************************
+ * FILE PURPOSE: Provide build time configurations for the IBL
+ **************************************************************************
+ * FILE NAME: iblcfg.h
+ *
+ * DESCRIPTION: Build time configuration
+ *
+ * @file iblcfg.h
+ *
+ * @brief
+ * Build time configurations for the c6472 ibl are defined
+ *
+ ***************************************************************************/
+#ifndef IBLCFG_H
+#define IBLCFG_H
+
+/**
+ * @brief The maximum number of UDP sockets in the system
+ */
+#define MAX_UDP_SOCKET 3
+
+
+/**
+ * @brief The maximum number of timers in the system
+ */
+#define MAX_TIMER_BLOCKS 5
+
+
+/**
+ * @brief The size in bytes of the internal stream buffer
+ */
+#define MAX_SIZE_STREAM_BUFFER 1024
+
+
+/**
+ * @brief The maximum number of functions supported for BIS mode
+ */
+#define MAX_BIS_FUNCTION_SUPPORT 3
+
+
+/**
+ * @brief No I/O sections accepted in boot table format
+ */
+#define BOOTCONFIG_NO_BTBL_IO
+
+/**
+ * @brief The I2C bus address and data address of the ibl table.
+ */
+#define IBL_I2C_DEV_FREQ_MHZ 625
+#define IBL_I2C_CLK_FREQ_KHZ 100
+#define IBL_I2C_OWN_ADDR 10
+#define IBL_I2C_CFG_ADDR_DELAY 0x100 /* Delay between sending the address and reading data */
+#define IBL_I2C_CFG_EEPROM_BUS_ADDR 0x50
+#define IBL_I2C_CFG_TABLE_DATA_ADDR (0x10000 - 0x300)
+
+
+
+
+
+#endif
+
+
diff --git a/src/device/c6455/c6455.c b/src/device/c6455/c6455.c
--- /dev/null
+++ b/src/device/c6455/c6455.c
@@ -0,0 +1,41 @@
+/************************************************************************************
+ * FILE PURPOSE: C6455 Device Specific functions
+ ************************************************************************************
+ * FILE NAME: c6455.c
+ *
+ * DESCRIPTION: Implements the device specific functions for the IBL
+ *
+ * @file c6455.c
+ *
+ * @brief
+ * This file implements the device specific functions for the IBL
+ *
+ ************************************************************************************/
+#include "ibl.h"
+#include "device.h"
+
+
+/**
+ * @brief The default boot configuration table is filled in
+ *
+ * @details
+ * A default ibl configuraiton table is provided when one is not found
+ * preloaded.
+ */
+void deviceLoadDefaultIblTable (void)
+{
+
+ ibl.ethConfig.ethPriority = ibl_HIGHEST_PRIORITY;
+ ibl.ethConfig.port = 0;
+ ibl.ethConfig.doBootp = TRUE;
+ ibl.ethConfig.bootFormat = ibl_BOOT_FORMAT_AUTO;
+
+ memset (ibl.ethConfig.ethInfo, 0, sizeof(ibl.ethConfig.ethInfo));
+}
+
+
+
+
+
+
+
diff --git a/src/device/c6455/target.h b/src/device/c6455/target.h
--- /dev/null
@@ -0,0 +1,32 @@
+/**************************************************************************
+ * FILE PURPOSE: Target specific definitions
+ **************************************************************************
+ * FILE NAME: target.h
+ *
+ * DESCRIPTION: This file defines target specific values used by low level
+ * drivers.
+ *
+ * @file target.h
+ *
+ * @brief
+ * Low level target specific values are defined
+ *
+ ***************************************************************************/
+
+
+#define EMAC_BASE_ADDRESS 0x02C80000u
+#define _EMAC_DSC_BASE_ADDR 0x02c82000u
+#define TIMER0_BASE 0x02940000u
+
+
+#define TIMER_INPUT_DIVIDER 6 /* Timer driven from cpu clock / 6 */
+
+
+/* Leave mdio disabled */
+#define dev_mdio_open() 1
+
+
+
+
+
+
diff --git a/src/device/c6472/c6472.c b/src/device/c6472/c6472.c
--- /dev/null
+++ b/src/device/c6472/c6472.c
@@ -0,0 +1,299 @@
+/************************************************************************************
+ * FILE PURPOSE: C6472 Device Specific functions
+ ************************************************************************************
+ * FILE NAME: c6472.c
+ *
+ * DESCRIPTION: Implements the device specific functions for the IBL
+ *
+ * @file c6472.c
+ *
+ * @brief
+ * This file implements the device specific functions for the IBL
+ *
+ ************************************************************************************/
+#include "ibl.h"
+#include "device.h"
+#include "pllapi.h"
+#include "emif31api.h"
+#include "pscapi.h"
+#include "gpio.h"
+#include <string.h>
+
+extern cregister unsigned int DNUM;
+
+
+/**
+ * @brief The default boot configuration table is filled in
+ *
+ * @details
+ * A default ibl configuraiton table is provided when one is not found
+ * preloaded.
+ */
+void deviceLoadDefaultIblTable (void)
+{
+ uint32 macA, macB;
+
+#if 0 /* This is really the default. Switching to a direct tftp boot until I have a bootp server
+ * on a private lan for test */
+ ibl.ethConfig[0].ethPriority = ibl_LOWEST_PRIORITY;
+ ibl.ethConfig[0].port = 0;
+ ibl.ethConfig[0].doBootp = TRUE;
+ ibl.ethConfig[0].bootFormat = ibl_BOOT_FORMAT_AUTO;
+
+ memset (&ibl.ethConfig[0].ethInfo, 0, sizeof(ibl.ethConfig[0].ethInfo));
+#endif
+
+ /* This is the temporary code */
+ ibl.ethConfig[0].ethPriority = ibl_LOWEST_PRIORITY;
+ ibl.ethConfig[0].port = 0;
+ ibl.ethConfig[0].doBootp = FALSE;
+ ibl.ethConfig[0].useBootpServerIp = FALSE;
+ ibl.ethConfig[0].useBootpFileName = FALSE;
+ ibl.ethConfig[0].bootFormat = ibl_BOOT_FORMAT_NAME;
+
+ memset (&ibl.ethConfig[0].ethInfo, 0, sizeof(ibl.ethConfig[0].ethInfo));
+
+ ibl.ethConfig[0].ethInfo.ipAddr[0] = 10;
+ ibl.ethConfig[0].ethInfo.ipAddr[1] = 218;
+ ibl.ethConfig[0].ethInfo.ipAddr[2] = 109;
+ ibl.ethConfig[0].ethInfo.ipAddr[3] = 21;
+
+ ibl.ethConfig[0].ethInfo.serverIp[0] = 10;
+ ibl.ethConfig[0].ethInfo.serverIp[1] = 218;
+ ibl.ethConfig[0].ethInfo.serverIp[2] = 109;
+ ibl.ethConfig[0].ethInfo.serverIp[3] = 196;
+
+ ibl.ethConfig[0].ethInfo.gatewayIp[0] = 10;
+ ibl.ethConfig[0].ethInfo.gatewayIp[1] = 218;
+ ibl.ethConfig[0].ethInfo.gatewayIp[2] = 109;
+ ibl.ethConfig[0].ethInfo.gatewayIp[3] = 1;
+
+ /* Leave hw address as 0 */
+
+ strcpy (ibl.ethConfig[0].ethInfo.fileName, "test2_little.out");
+
+ ibl.ethConfig[0].blob.startAddress = 0x00200000; /* Base address of SL2 */
+ ibl.ethConfig[0].blob.sizeBytes = 0x000c0000; /* All of SL2 */
+ ibl.ethConfig[0].blob.branchAddress = 0x00200000; /* Base of SL2 */
+
+
+
+ macA = *((uint32 *)0x2a80700);
+ macB = *((uint32 *)0x2a80704);
+
+ ibl.ethConfig[0].ethInfo.hwAddress[0] = (macA >> 24) & 0xff;
+ ibl.ethConfig[0].ethInfo.hwAddress[1] = (macA >> 16) & 0xff;
+ ibl.ethConfig[0].ethInfo.hwAddress[2] = (macA >> 8) & 0xff;
+ ibl.ethConfig[0].ethInfo.hwAddress[3] = (macA >> 0) & 0xff;
+ ibl.ethConfig[0].ethInfo.hwAddress[4] = (macB >> 24) & 0xff;
+ ibl.ethConfig[0].ethInfo.hwAddress[5] = (macB >> 16) & 0xff;
+
+
+ ibl.ethConfig[1].ethPriority = ibl_DEVICE_NOBOOT;
+
+
+ /* MDIO configuration */
+ ibl.mdioConfig.nMdioOps = 8;
+ ibl.mdioConfig.mdioClkDiv = 0x20;
+ ibl.mdioConfig.interDelay = 1400; /* ~2ms at 700 MHz */
+
+ ibl.mdioConfig.mdio[0] = (1 << 30) | (27 << 21) | (24 << 16) | 0x848b;
+ ibl.mdioConfig.mdio[1] = (1 << 30) | (20 << 21) | (24 << 16) | 0x0ce0;
+ ibl.mdioConfig.mdio[2] = (1 << 30) | (24 << 21) | (24 << 16) | 0x4101;
+ ibl.mdioConfig.mdio[3] = (1 << 30) | ( 0 << 21) | (24 << 16) | 0x9140;
+
+ ibl.mdioConfig.mdio[4] = (1 << 30) | (27 << 21) | (25 << 16) | 0x848b;
+ ibl.mdioConfig.mdio[5] = (1 << 30) | (20 << 21) | (25 << 16) | 0x0ce0;
+ ibl.mdioConfig.mdio[6] = (1 << 30) | (24 << 21) | (25 << 16) | 0x4101;
+ ibl.mdioConfig.mdio[7] = (1 << 30) | ( 0 << 21) | (25 << 16) | 0x9140;
+
+
+ /* Main Pll configuration */
+ ibl.pllConfig[ibl_MAIN_PLL].doEnable = TRUE;
+ ibl.pllConfig[ibl_MAIN_PLL].prediv = 1;
+ ibl.pllConfig[ibl_MAIN_PLL].mult = 28;
+ ibl.pllConfig[ibl_MAIN_PLL].postdiv = 1;
+
+ ibl.pllConfig[ibl_MAIN_PLL].pllOutFreqMhz = 500;
+
+ /* The DDR PLL. The multipliers/dividers are fixed, so are really dont cares */
+ ibl.pllConfig[ibl_DDR_PLL].doEnable = TRUE;
+
+ /* The network PLL. The multipliers/dividers are fixed */
+ ibl.pllConfig[ibl_NET_PLL].doEnable = TRUE;
+
+ /* EMIF configuration */
+ ibl.ddrConfig.uEmif.emif3p1.sdcfg = 0x00538832; /* timing, 32bit wide */
+ ibl.ddrConfig.uEmif.emif3p1.sdrfc = 0x0000073B; /* Refresh 533Mhz */
+ ibl.ddrConfig.uEmif.emif3p1.sdtim1 = 0x47245BD2; /* Timing 1 */
+ ibl.ddrConfig.uEmif.emif3p1.sdtim2 = 0x0125DC44; /* Timing 2 */
+ ibl.ddrConfig.uEmif.emif3p1.dmcctl = 0x50001906; /* PHY read latency for CAS 5 is 5 + 2 - 1 */
+
+
+ /* NAND configuration for the MT29F1G08 flash */
+ ibl.nandConfig.nandPriority = ibl_HIGHEST_PRIORITY;
+ ibl.nandConfig.bootFormat = ibl_BOOT_FORMAT_COFF;
+
+ ibl.nandConfig.nandInfo.busWidthBits = 8;
+ ibl.nandConfig.nandInfo.pageSizeBytes = 2048;
+ ibl.nandConfig.nandInfo.pageEccBytes = 64;
+ ibl.nandConfig.nandInfo.pagesPerBlock = 64;
+ ibl.nandConfig.nandInfo.totalBlocks = 1024;
+
+ ibl.nandConfig.nandInfo.addressBytes = 4;
+ ibl.nandConfig.nandInfo.lsbFirst = TRUE;
+ ibl.nandConfig.nandInfo.blockOffset = 22;
+ ibl.nandConfig.nandInfo.pageOffset = 16;
+ ibl.nandConfig.nandInfo.columnOffset = 0;
+
+ ibl.nandConfig.nandInfo.resetCommand = 0xff;
+ ibl.nandConfig.nandInfo.readCommandPre = 0;
+ ibl.nandConfig.nandInfo.readCommandPost = 0x30;
+ ibl.nandConfig.nandInfo.postCommand = TRUE;
+
+
+}
+
+/**
+ * @brief Determine if an address is local
+ *
+ * @details
+ * Examines an input address to determine if it is a local address
+ */
+bool address_is_local (Uint32 addr)
+{
+ /* L2 */
+ if ((addr >= 0x00800000) && (addr < 0x00898000))
+ return (TRUE);
+
+ /* L1P */
+ if ((addr >= 0x00e00000) && (addr < 0x00e08000))
+ return (TRUE);
+
+ /* L2D */
+ if ((addr >= 0x00f00000) && (addr < 0x00f08000))
+ return (TRUE);
+
+ return (FALSE);
+
+}
+
+
+/**
+ * @brief Convert a local l1d, l1p or l2 address to a global address
+ *
+ * @details
+ * The global address is formed. If the address is not local then
+ * the input address is returned
+ */
+Uint32 deviceLocalAddrToGlobal (Uint32 addr)
+{
+
+ if (address_is_local (addr))
+ addr = (1 << 28) | (DNUM << 24) | addr;
+
+ return (addr);
+
+}
+
+
+/**
+ * @brief Configure the PLLs
+ *
+ * @details
+ * The three PLLs are enabled. Only the main PLL has the ability to configure
+ * the multiplier and dividers.
+ */
+void devicePllConfig (void)
+{
+ if (ibl.pllConfig[ibl_MAIN_PLL].doEnable == TRUE)
+ hwPllSetPll (MAIN_PLL,
+ ibl.pllConfig[ibl_MAIN_PLL].prediv,
+ ibl.pllConfig[ibl_MAIN_PLL].mult,
+ ibl.pllConfig[ibl_MAIN_PLL].postdiv);
+
+ if (ibl.pllConfig[ibl_DDR_PLL].doEnable == TRUE)
+ hwPllEnable (DDR_PLL);
+
+ if (ibl.pllConfig[ibl_NET_PLL].doEnable == TRUE)
+ hwPllEnable (NET_PLL);
+
+
+}
+
+/**
+ * @brief
+ * Enable the DDR
+ *
+ * @details
+ * The DDR controller on the c6472 is an emif 3.1. The controller is
+ * initialized directly with the supplied values
+ */
+void deviceDdrConfig (void)
+{
+ if (ibl.ddrConfig.configDdr != 0)
+ hwEmif3p1Enable (&ibl.ddrConfig.uEmif.emif3p1);
+
+}
+
+
+/**
+ * @brief Power up a peripheral
+ *
+ * @details
+ * Boot peripherals are powered up
+ */
+int32 devicePowerPeriph (int32 modNum)
+{
+ /* If the input value is < 0 there is nothing to power up */
+ if (modNum < 0)
+ return (0);
+
+
+ if (modNum >= TARGET_PWR_MAX_MOD)
+ return (-1);
+
+ return ((int32)pscEnableModule(modNum));
+
+}
+
+
+/**
+ * @brief Enable the pass through version of the nand controller
+ *
+ * @details On the evm the nand controller is enabled by setting
+ * gpio 14 high
+ */
+int32 deviceConfigureForNand(void)
+{
+ hwGpioSetDirection(NAND_MODE_GPIO, GPIO_OUT);
+ hwGpioSetOutput(NAND_MODE_GPIO);
+ return (0);
+
+}
+
+
+/**
+ * @brief
+ * The e-fuse mac address is loaded
+ */
+void deviceLoadDefaultEthAddress (uint8 *maddr)
+{
+ uint32 macA, macB;
+
+ /* Read the e-fuse mac address */
+ macA = *((uint32 *)0x2a80700);
+ macB = *((uint32 *)0x2a80704);
+
+ maddr[0] = (macA >> 24) & 0xff;
+ maddr[1] = (macA >> 16) & 0xff;
+ maddr[2] = (macA >> 8) & 0xff;
+ maddr[3] = (macA >> 0) & 0xff;
+ maddr[4] = (macB >> 24) & 0xff;
+ maddr[5] = (macB >> 16) & 0xff;
+}
+
+
+
+
+
diff --git a/src/device/c6472/target.h b/src/device/c6472/target.h
--- /dev/null
@@ -0,0 +1,142 @@
+/**************************************************************************
+ * FILE PURPOSE: Target specific definitions
+ **************************************************************************
+ * FILE NAME: target.h
+ *
+ * DESCRIPTION: This file defines target specific values used by low level
+ * drivers.
+ *
+ * @file target.h
+ *
+ * @brief
+ * Low level target specific values are defined
+ *
+ ***************************************************************************/
+
+
+/**
+ * @brief
+ * Device EMAC definitions
+ */
+#define TARGET_DEVICE_CPMAC
+
+#define TARGET_EMAC_N_PORTS 2
+
+#define TARGET_EMAC_BASE_ADDRESSES { 0x02c80000u, 0x02cc0000u }
+#define TARGET_EMAC_DSC_BASE_ADDR { 0x02c82000u, 0x02cc2000u }
+
+/* Leave mdio disabled */
+#define dev_mdio_open() 1
+
+
+/**
+ * @brief
+ * Device Timer definitions
+ */
+#define TIMER0_BASE 0x025e0000u
+
+#define TIMER_INPUT_DIVIDER 6 /* Timer driven from cpu clock / 6 */
+
+
+/**
+ * @def MAIN_PLL
+ */
+#define MAIN_PLL 0 /**< The index to the main PLL */
+
+/**
+ * @def NET_PLL
+ */
+#define NET_PLL 1 /**< The index to the network PLL */
+
+/**
+ * @def DDR_PLL
+ */
+#define DDR_PLL 2 /**< The index to the DDR PLL */
+
+
+/**
+ * @brief
+ * Device PLL definitions
+ */
+#define DEVICE_PLL_BASE(x) ((x) == MAIN_PLL ? 0x29a0000 : ((x) == NET_PLL ? 0x29c0000 : 0x29c0400))
+
+
+/**
+ * @brief
+ * Device PSC definitions
+ */
+#define DEVICE_PSC_BASE 0x02ae0000u
+
+/**
+ * @brief
+ * The PSC number for ethernet port 0 is 7, and for port 1 it is 8 */
+#define TARGET_PWR_ETH(x) ((x) == 0 ? 7 : 8)
+
+/**
+ * @brief
+ * The nand is done through gpio, which is always powered up.
+ * A value < 0 tells the low level psc driver to simply return success
+ */
+#define TARGET_PWR_NAND -1
+
+
+/**
+ * @brief
+ * Device DDR controller definitions
+ */
+#define DEVICE_DDR_BASE 0x78000000
+
+/**
+ * @brief
+ * The highest module number
+ */
+#define TARGET_PWR_MAX_MOD 13
+
+
+/**
+ * @brief
+ * The base address of MDIO
+ */
+#define TARGET_MDIO_BASE 0x2c81800
+
+/**
+ * @brief
+ * GPIO address
+ */
+#define GPIO_GPIOPID_REG 0x02B00000
+#define GPIO_GPIOEMU_REG 0x02B00004
+#define GPIO_BINTEN_REG 0x02B00008
+#define GPIO_DIR_REG 0x02B00010
+#define GPIO_OUT_DATA_REG 0x02B00014
+#define GPIO_SET_DATA_REG 0x02B00018
+#define GPIO_CLEAR_DATA_REG 0x02B0001C
+#define GPIO_IN_DATA_REG 0x02B00020
+#define GPIO_SET_RIS_TRIG_REG 0x02B00024
+#define GPIO_CLR_RIS_TRIG_REG 0x02B00028
+#define GPIO_SET_FAL_TRIG_REG 0x02B0002C
+#define GPIO_CLR_FAL_TRIG_REG 0x02B00030
+
+/**
+ * @brief
+ * GPIO pin mapping
+ */
+#define NAND_CLE_GPIO_PIN GPIO_8 // High: Command Cycle occuring
+#define NAND_ALE_GPIO_PIN GPIO_9 // High: Address input cycle oddcuring
+#define NAND_NWE_GPIO_PIN GPIO_10
+#define NAND_NRE_GPIO_PIN GPIO_12
+#define NAND_NCE_GPIO_PIN GPIO_13
+#define NAND_MODE_GPIO GPIO_14
+
+/**
+ * @brief
+ * The standard NAND delay must be big enough to handle the highest possible
+ * operating frequency of the device */
+#define TARGET_NAND_STD_DELAY 25 // In cpu cycles
+
+/**
+ * @brief
+ * The base address of the I2C peripheral, and the module divisor of the cpu clock
+ */
+#define DEVICE_I2C_BASE 0x02b04000
+#define DEVICE_I2C_MODULE_DIVISOR 6
+
diff --git a/src/device/c64x/make/makefile b/src/device/c64x/make/makefile
--- /dev/null
@@ -0,0 +1,57 @@
+#*************************************************************************
+#* FILE PURPOSE: Build the IBL device specific module
+#*************************************************************************
+#* FILE NAME: makefile
+#*
+#* DESCRIPTION: Makes the device specific modules
+#*
+#*************************************************************************
+
+ifndef IBL_ROOT
+ export IBL_ROOT=../../..
+endif
+
+ECODIR= $(IBL_ROOT)/device
+
+ifeq ($(TARGET),c6472)
+ CSRC= c6472.c
+endif
+
+ifeq ($(TARGET),c6455)
+ CSRC= c6455.c
+endif
+
+.PHONY: device
+
+
+include $(IBL_ROOT)/make/$(ARCH)/makeeco.mk
+
+
+C6X_C_DIR= $(IBL_ROOT)/device/$(TARGET)
+C6X_C_DIR+= ;$(IBL_ROOT)/device
+C6X_C_DIR+= ;$(IBL_ROOT)
+C6X_C_DIR+= ;$(IBL_ROOT)/arch/$(ARCH)
+C6X_C_DIR+= ;$(STDINC)
+C6X_C_DIR+= ;$(IBL_ROOT)/hw/plls
+C6X_C_DIR+= ;$(IBL_ROOT)/hw/pscs
+C6X_C_DIR+= ;$(IBL_ROOT)/hw/gpio
+C6X_C_DIR+= ;$(IBL_ROOT)/hw/ddrs/emif31
+export C6X_C_DIR
+
+vpath % $(IBL_ROOT)/device/$(TARGET)
+
+
+device: gen_cdefdep makefile $(OBJS)
+
+
+$(OBJS): cdefdep
+
+
+gen_cdefdep:
+ @echo CSRC= $(CSRC)
+ @echo Checking command line dependencies
+ @echo $(ENDIAN) $(TARGET) $(ARCH) > cdefdep.tmp
+ @sh -c 'if diff -q cdefdep.tmp cdefdep ; then echo same ; else $(CP) cdefdep.tmp cdefdep ; fi '
+
+
+
diff --git a/src/device/device.h b/src/device/device.h
--- /dev/null
+++ b/src/device/device.h
@@ -0,0 +1,95 @@
+/**********************************************************************************
+ * FILE PURPOSE: Define the device interface
+ **********************************************************************************
+ * FILE NAME: device.h
+ *
+ * DESCRIPTION: This file defines the device wrapper used by IBL modules
+ *
+ * @file device.h
+ *
+ * @brief
+ * The device wrapper API is defined
+ *
+ ***********************************************************************************/
+#ifndef DEVICE_H
+#define DEVICE_H
+
+#include "types.h"
+
+
+/* The target specific file is pointed to via make control. There will be a different
+ target.h file for each platform */
+#include "target.h"
+
+
+
+/**
+ * @brief
+ * Fill in the ibl structure with default values
+ *
+ * @details
+ * If the ibl table is not pre-loaded during the initial boot, then
+ * each device will load a default table.
+ */
+void deviceLoadDefaultIblTable(void);
+
+
+/**
+ * @brief
+ * Convert a local address to a global address
+ *
+ * @details
+ * a local memory address (l1d, l1p, l2) is converted to a global address
+ */
+Uint32 deviceLocalAddrToGlobal (Uint32 local);
+
+
+/**
+ * @brief Configure the PLLs
+ *
+ * @details
+ * The three PLLs are enabled. Only the main PLL has the ability to configure
+ * the multiplier and dividers.
+ */
+void devicePllConfig (void);
+
+
+/**
+ * @brief
+ * Power up a peripheral
+ *
+ * @details
+ * The specified module (and domain if required) is power up
+ */
+int32 devicePowerPeriph (int32 modNum);
+
+
+/**
+ * @brief Enable the DDR controller
+ *
+ * @details
+ * The DDR controller is enabled (optionally)
+ */
+void deviceDdrConfig (void);
+
+
+/**
+ * @brief
+ * Perform device level configuration for nand boot
+ *
+ * @detials
+ * Board/chip specific initializations
+ */
+int32 deviceConfigureForNand(void);
+
+/**
+ * @brief
+ * Load the default ethernet address
+ *
+ * @details
+ * The mac address from e-fuse is loaded
+ */
+void deviceLoadDefaultEthAddress (uint8 *maddr);
+
+#endif
+
diff --git a/src/driver/c64x/make/makefile b/src/driver/c64x/make/makefile
--- /dev/null
@@ -0,0 +1,68 @@
+#*******************************************************************
+#* FILE NAME: makefile
+#*
+#* DESCRIPTION: Makes the peripheral driver modules
+#*
+#*******************************************************************
+
+ifndef IBL_ROOT
+ export IBL_ROOT=../../..
+endif
+
+ECODIR= $(IBL_ROOT)/driver
+
+
+# The ethernet driver
+ETHDIR= eth
+ETHSRC= net.c arp.c ip.c udp.c bootp.c tftp.c
+
+# The stream driver
+STRMDIR= stream
+STRMSRC= stream.c
+
+# The timer driver
+TIMDIR= timer
+TIMSRC= timer.c
+
+# The nand driver
+NANDDIR= nand
+NANDSRC= nand.c
+
+CSRC= $(ETHSRC) $(STRMSRC) $(TIMSRC) $(NANDSRC)
+
+.PHONY: driver
+
+
+include $(IBL_ROOT)/make/$(ARCH)/makeeco.mk
+
+
+C6X_C_DIR= $(IBL_ROOT)
+C6X_C_DIR+= ;$(IBL_ROOT)/arch/$(ARCH)
+C6X_C_DIR+= ;$(ECODIR)
+C6X_C_DIR+= ;$(STDINC)
+C6X_C_DIR+= ;$(IBL_ROOT)/driver/timer
+C6X_C_DIR+= ;$(IBL_ROOT)/driver/stream
+C6X_C_DIR+= ;$(IBL_ROOT)/driver/nand
+C6X_C_DIR+= ;$(IBL_ROOT)/cfg/$(TARGET)
+C6X_C_DIR+= ;$(IBL_ROOT)/hw/timer
+C6X_C_DIR+= ;$(IBL_ROOT)/hw/nands
+export C6X_C_DIR
+
+vpath % $(ECODIR)/$(ETHDIR); $(ECODIR)/$(STRMDIR); $(ECODIR)/$(TIMDIR); $(ECODIR)/$(NANDDIR)
+
+
+driver: gen_cdefdep makefile $(OBJS)
+
+$(OBJS): cdefdep
+
+
+gen_cdefdep:
+ @echo Checking command line dependencies
+ @echo $(ENDIAN) $(TARGET) > cdefdep.tmp
+ @sh -c 'if diff -q cdefdep.tmp cdefdep ; then echo same ; else $(CP) cdefdep.tmp cdefdep ; fi '
+
+
+
+
+
+
diff --git a/src/driver/eth/arp.c b/src/driver/eth/arp.c
--- /dev/null
+++ b/src/driver/eth/arp.c
@@ -0,0 +1,313 @@
+/**
+ * @file arp.c
+ *
+ * @brief
+ * The file implements the NET Module ARP functionality.
+ *
+ * \par
+ * NOTE:
+ * (C) Copyright 2008, Texas Instruments, Inc.
+ *
+ * \par
+ */
+#include "types.h"
+#include "iblloc.h"
+#include "net.h"
+#include "netif.h"
+#include <string.h>
+
+
+/**********************************************************************
+ *************************** LOCAL Structures *************************
+ **********************************************************************/
+
+/**
+ * @brief
+ * The structure describes the ARP Cache
+ *
+ * @details
+ * This describes the ARP Cache which keeps track of the IPv4 address and
+ * the corresponding Layer2 MAC Address.
+ */
+typedef struct NET_ARP_CACHE
+{
+ /**
+ * @brief This is the MAC Address i.e. Layer2 address matching the
+ * corresponding IP Address.
+ */
+ Uint8 mac_address[6];
+
+ /**
+ * @brief This is the IP Address stored in network order.
+ */
+ IPN ip_address;
+
+ /**
+ * @brief When the upper layers tries to send a packet and
+ * the MAC Address is not resolved; packets are stored in this
+ * temporary area. The ARP stack sends out an ARP request packet
+ * and resolves the IP address. Once the resolution is done pending
+ * packets are transmitted.
+ */
+ Uint8 pending_packet[NET_MAX_MTU];
+
+ /**
+ * @brief This is the length of the pending packet. A value of 0
+ * indicates that there is no pending packet in the ARP cache.
+ */
+ Uint16 pending_packet_len;
+}NET_ARP_CACHE;
+
+/**********************************************************************
+ *************************** GLOBAL Variables *************************
+ **********************************************************************/
+
+/**
+ * @brief This is the ARP cache; which keeps track of the IP Address to
+ * MAC Address mapping.
+ */
+NET_ARP_CACHE net_arp_cache;
+
+/**********************************************************************
+ **************************** ARP Functions ***************************
+ **********************************************************************/
+
+/**
+ * @b Description
+ * @n
+ * This function is called by the IP Layer to resolve the layer3
+ * address to a layer2 MAC address. The function checks the ARP cache
+ * for a match but if no entry exists then the functions sends out
+ * an ARP request and it places this packet into the pending queue.
+ *
+ * @param[in] dst_ip
+ * This is the destination IP address of the packet.
+ * @param[in] ptr_iphdr
+ * This is the pointer to the IP header
+ * @param[in] l3_pkt_size
+ * This is the size of the packet (including the IP Header)
+ *
+ * @retval
+ * Not Applicable.
+ */
+void arp_resolve (IPN dst_ip, IPHDR* ptr_iphdr, Uint16 l3_pkt_size)
+{
+ ARPHDR* ptr_arphdr;
+ ETHHDR* ptr_ethhdr;
+ Uint8 BroadcastMac[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
+
+ /* Special Case: Are we sending the packet to 255.255.255.255? */
+ if (dst_ip == (IPN)0xFFFFFFFF)
+ {
+ /* YES. This implies that the destination MAC Address in the packet is the Broadcast address
+ * We dont need to lookup the cache. */
+ ptr_ethhdr = net_create_eth_header ((Uint8 *)ptr_iphdr, (void *)&BroadcastMac[0], 0x800);
+ if (ptr_ethhdr == NULL)
+ return;
+
+ /* We now have a completed Ethernet packet; send it across. */
+ net_send_packet (ptr_ethhdr, sizeof(ETHHDR) + l3_pkt_size);
+
+ /* The packet has been transmitted and we can clean it up now. */
+ net_free_tx_packet ((Uint8 *)ptr_iphdr);
+ return;
+ }
+
+ /* Check if the destination IP Address matches the ARP cache */
+ if (net_arp_cache.ip_address == dst_ip)
+ {
+ /* Make sure the MAC Address in the CACHE has been resolved i.e. Non-Zero. */
+ if ( (net_arp_cache.mac_address[0] != 0x00) || (net_arp_cache.mac_address[1] != 0x00) ||
+ (net_arp_cache.mac_address[2] != 0x00) || (net_arp_cache.mac_address[3] != 0x00) ||
+ (net_arp_cache.mac_address[4] != 0x00) || (net_arp_cache.mac_address[5] != 0x00) )
+ {
+ /* Perfect; the MAC Address is already resolved.
+ * We can simply use the ARP CACHE MAC address to create the layer2 header. */
+ ptr_ethhdr = net_create_eth_header ((Uint8 *)ptr_iphdr, (void *)&net_arp_cache.mac_address[0], 0x800);
+ if (ptr_ethhdr == NULL)
+ return;
+
+ /* We now have a completed Ethernet packet; send it across. */
+ net_send_packet (ptr_ethhdr, sizeof(ETHHDR) + l3_pkt_size);
+
+ /* The packet has been transmitted and we can clean it up now. */
+ net_free_tx_packet ((Uint8 *)ptr_iphdr);
+ return;
+ }
+ }
+
+ /* Initialize the ARP Cache: The cache did not have information for the resolution to work
+ * Reset the cache and start again. */
+ memset ((void *)&net_arp_cache, 0, sizeof(NET_ARP_CACHE));
+
+ /* Populate the ARP Cache */
+ net_arp_cache.ip_address = dst_ip;
+ net_arp_cache.pending_packet_len = l3_pkt_size;
+ memcpy ((void *)&net_arp_cache.pending_packet[0], (void *)ptr_iphdr, l3_pkt_size);
+
+ /* Free up the packet now; we have already stored it in the ARP cache. */
+ net_free_tx_packet ((Uint8 *)ptr_iphdr);
+
+ /* Allocate a new packet to send out the ARP request. */
+ ptr_arphdr = (ARPHDR *)net_alloc_tx_packet(sizeof(ARPHDR));
+ if (ptr_arphdr == NULL)
+ return;
+
+ /* Populate the ARP Header. */
+ ptr_arphdr->HardType = htons(0x1);
+ ptr_arphdr->ProtocolType = htons(0x800);
+ ptr_arphdr->HardSize = 0x6;
+ ptr_arphdr->ProtocolSize = 0x4;
+ ptr_arphdr->Op = htons(0x1);
+
+ /* Populate the Source IP/MAC Address */
+ memcpy ((void *)&ptr_arphdr->SrcAddr[0], (void *)&netmcb.net_device.mac_address[0], 6);
+ memcpy ((void *)&ptr_arphdr->IPSrc[0], (void *)&netmcb.net_device.ip_address, 4);
+
+ /* Populate the Target IP/MAC Address: This is set to 0 since the cache has been reset above. */
+ memcpy ((void *)&ptr_arphdr->DstAddr[0], (void *)&net_arp_cache.mac_address[0], 6);
+ memcpy ((void *)&ptr_arphdr->IPDst[0], (void *)&dst_ip, 4);
+
+ /* Create the Ethernet header. */
+ ptr_ethhdr = net_create_eth_header ((Uint8 *)ptr_arphdr, &BroadcastMac[0], 0x806);
+ if (ptr_ethhdr == NULL)
+ return;
+
+ /* Send the packet out. */
+ net_send_packet (ptr_ethhdr, sizeof(ETHHDR) + sizeof(ARPHDR));
+
+ /* The packet has been transmitted and we can clean it up now. */
+ net_free_tx_packet ((Uint8 *)ptr_arphdr);
+ return;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function handles the reception and processing of ARP packets.
+ *
+ * @param[in] ptr_arphdr
+ * This is the pointer to the received ARP header.
+ * @param[in] num_bytes
+ * This is the size of the ARP packet.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+Int32 arp_receive (ARPHDR* ptr_arphdr, Int32 num_bytes)
+{
+ Uint32 IPAddress;
+ Uint8* ptr_pending_pkt;
+ ETHHDR* ptr_ethhdr;
+
+ /* Extract the intended target and convert it to host format. */
+ IPAddress = READ32(ptr_arphdr->IPDst);
+
+ /* Ensure that the packet has not been looped back and we received our own frame. */
+ if ((ptr_arphdr->SrcAddr[0] == netmcb.net_device.mac_address[0]) &&
+ (ptr_arphdr->SrcAddr[1] == netmcb.net_device.mac_address[1]) &&
+ (ptr_arphdr->SrcAddr[2] == netmcb.net_device.mac_address[2]) &&
+ (ptr_arphdr->SrcAddr[3] == netmcb.net_device.mac_address[3]) &&
+ (ptr_arphdr->SrcAddr[4] == netmcb.net_device.mac_address[4]) &&
+ (ptr_arphdr->SrcAddr[5] == netmcb.net_device.mac_address[5]))
+ {
+ /* We received our own frame; ignore this. */
+ return -1;
+ }
+
+ /* Check if the packet is meant for us? If it not meant for us we drop the packet. */
+ if (IPAddress != netmcb.net_device.ip_address)
+ return -1;
+
+ /* The ARP packet was meant for us; we need to update the ARP cache with the request. */
+ net_arp_cache.ip_address = READ32(ptr_arphdr->IPSrc);
+ memcpy ((void *)&net_arp_cache.mac_address[0], (void *)&ptr_arphdr->SrcAddr[0], 6);
+
+ /* Check if the packet is an ARP request? */
+ if (ptr_arphdr->Op == htons(0x1))
+ {
+ /* YES. We need to send out an ARP Reply; so create the packet.
+ * Ensure that the Layer3 headers are aligned on the 4 byte boundary
+ * and yet we have sufficient space for the Ethernet header. */
+ ptr_arphdr = (ARPHDR *)net_alloc_tx_packet(sizeof(ARPHDR));
+ if (ptr_arphdr == NULL)
+ return -1;
+
+ /* Populate the ARP Header. */
+ ptr_arphdr->HardType = htons(0x1);
+ ptr_arphdr->ProtocolType = htons(0x800);
+ ptr_arphdr->HardSize = 0x6;
+ ptr_arphdr->ProtocolSize = 0x4;
+ ptr_arphdr->Op = htons(0x2);
+
+ /* Populate the Source IP/MAC Address in the ARP Header */
+ memcpy ((void *)&ptr_arphdr->SrcAddr[0], (void *)&netmcb.net_device.mac_address[0], 6);
+ memcpy ((void *)&ptr_arphdr->IPSrc[0], (void *)&netmcb.net_device.ip_address, 4);
+
+ /* Populate the Target IP/MAC Address in the ARP Header */
+ memcpy ((void *)&ptr_arphdr->DstAddr[0], (void *)&net_arp_cache.mac_address[0], 6);
+ memcpy ((void *)&ptr_arphdr->IPDst[0], (void *)&net_arp_cache.ip_address, 4);
+
+ /* Create the Ethernet header. */
+ ptr_ethhdr = net_create_eth_header ((Uint8 *)ptr_arphdr, &net_arp_cache.mac_address[0], 0x806);
+ if (ptr_ethhdr == NULL)
+ return -1;
+
+ /* Send the packet out. */
+ net_send_packet (ptr_ethhdr, sizeof(ETHHDR) + sizeof(ARPHDR));
+
+ /* The packet has been transmitted and we can clean it up now. */
+ net_free_tx_packet ((Uint8 *)ptr_arphdr);
+ }
+
+ /* Check if there are any packet awaiting resolution? */
+ if (net_arp_cache.pending_packet_len != 0)
+ {
+ /* There was a packet in the ARP cache which was awaiting resolution.
+ * We need to send out the packet now. */
+ ptr_pending_pkt = net_alloc_tx_packet(net_arp_cache.pending_packet_len);
+ if (ptr_pending_pkt == NULL)
+ return -1;
+
+ /* We now copy the contents of this packet from the ARP cache */
+ memcpy ((void *)ptr_pending_pkt, (void *)&net_arp_cache.pending_packet[0],
+ net_arp_cache.pending_packet_len);
+
+ /* We create the Ethernet header.
+ * Only IPv4 packets await resolution. */
+ ptr_ethhdr = net_create_eth_header ((Uint8 *)ptr_pending_pkt, &net_arp_cache.mac_address[0], 0x800);
+ if (ptr_ethhdr == NULL)
+ return -1;
+
+ /* Send the packet out. */
+ net_send_packet (ptr_ethhdr, sizeof(ETHHDR) + net_arp_cache.pending_packet_len);
+
+ /* The pending packet in the cache has been sent out. */
+ net_arp_cache.pending_packet_len = 0;
+
+ /* The packet has been transmitted and can be cleaned up. */
+ net_free_tx_packet (ptr_pending_pkt);
+ }
+
+ /* ARP Packet has been successfully processed. */
+ return 0;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function initializes the ARP Module in the NET Boot module.
+ *
+ * @retval
+ * Not Applicable
+ */
+void arp_init (void)
+{
+ memset (&net_arp_cache, 0, sizeof(NET_ARP_CACHE));
+ return;
+}
+
+
+
diff --git a/src/driver/eth/arp.pretimer.c b/src/driver/eth/arp.pretimer.c
--- /dev/null
@@ -0,0 +1,313 @@
+/**
+ * @file arp.c
+ *
+ * @brief
+ * The file implements the NET Module ARP functionality.
+ *
+ * \par
+ * NOTE:
+ * (C) Copyright 2008, Texas Instruments, Inc.
+ *
+ * \par
+ */
+#include "types.h"
+#include "iblloc.h"
+#include "net.h"
+#include "netif.h"
+#include <string.h>
+
+
+/**********************************************************************
+ *************************** LOCAL Structures *************************
+ **********************************************************************/
+
+/**
+ * @brief
+ * The structure describes the ARP Cache
+ *
+ * @details
+ * This describes the ARP Cache which keeps track of the IPv4 address and
+ * the corresponding Layer2 MAC Address.
+ */
+typedef struct NET_ARP_CACHE
+{
+ /**
+ * @brief This is the MAC Address i.e. Layer2 address matching the
+ * corresponding IP Address.
+ */
+ Uint8 mac_address[6];
+
+ /**
+ * @brief This is the IP Address stored in network order.
+ */
+ IPN ip_address;
+
+ /**
+ * @brief When the upper layers tries to send a packet and
+ * the MAC Address is not resolved; packets are stored in this
+ * temporary area. The ARP stack sends out an ARP request packet
+ * and resolves the IP address. Once the resolution is done pending
+ * packets are transmitted.
+ */
+ Uint8 pending_packet[NET_MAX_MTU];
+
+ /**
+ * @brief This is the length of the pending packet. A value of 0
+ * indicates that there is no pending packet in the ARP cache.
+ */
+ Uint16 pending_packet_len;
+}NET_ARP_CACHE;
+
+/**********************************************************************
+ *************************** GLOBAL Variables *************************
+ **********************************************************************/
+
+/**
+ * @brief This is the ARP cache; which keeps track of the IP Address to
+ * MAC Address mapping.
+ */
+NET_ARP_CACHE net_arp_cache;
+
+/**********************************************************************
+ **************************** ARP Functions ***************************
+ **********************************************************************/
+
+/**
+ * @b Description
+ * @n
+ * This function is called by the IP Layer to resolve the layer3
+ * address to a layer2 MAC address. The function checks the ARP cache
+ * for a match but if no entry exists then the functions sends out
+ * an ARP request and it places this packet into the pending queue.
+ *
+ * @param[in] dst_ip
+ * This is the destination IP address of the packet.
+ * @param[in] ptr_iphdr
+ * This is the pointer to the IP header
+ * @param[in] l3_pkt_size
+ * This is the size of the packet (including the IP Header)
+ *
+ * @retval
+ * Not Applicable.
+ */
+void arp_resolve (IPN dst_ip, IPHDR* ptr_iphdr, Uint16 l3_pkt_size)
+{
+ ARPHDR* ptr_arphdr;
+ ETHHDR* ptr_ethhdr;
+ Uint8 BroadcastMac[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
+
+ /* Special Case: Are we sending the packet to 255.255.255.255? */
+ if (dst_ip == (IPN)0xFFFFFFFF)
+ {
+ /* YES. This implies that the destination MAC Address in the packet is the Broadcast address
+ * We dont need to lookup the cache. */
+ ptr_ethhdr = net_create_eth_header ((Uint8 *)ptr_iphdr, (void *)&BroadcastMac[0], 0x800);
+ if (ptr_ethhdr == NULL)
+ return;
+
+ /* We now have a completed Ethernet packet; send it across. */
+ net_send_packet (ptr_ethhdr, sizeof(ETHHDR) + l3_pkt_size);
+
+ /* The packet has been transmitted and we can clean it up now. */
+ net_free_tx_packet ((Uint8 *)ptr_iphdr);
+ return;
+ }
+
+ /* Check if the destination IP Address matches the ARP cache */
+ if (net_arp_cache.ip_address == dst_ip)
+ {
+ /* Make sure the MAC Address in the CACHE has been resolved i.e. Non-Zero. */
+ if ( (net_arp_cache.mac_address[0] != 0x00) || (net_arp_cache.mac_address[1] != 0x00) ||
+ (net_arp_cache.mac_address[2] != 0x00) || (net_arp_cache.mac_address[3] != 0x00) ||
+ (net_arp_cache.mac_address[4] != 0x00) || (net_arp_cache.mac_address[5] != 0x00) )
+ {
+ /* Perfect; the MAC Address is already resolved.
+ * We can simply use the ARP CACHE MAC address to create the layer2 header. */
+ ptr_ethhdr = net_create_eth_header ((Uint8 *)ptr_iphdr, (void *)&net_arp_cache.mac_address[0], 0x800);
+ if (ptr_ethhdr == NULL)
+ return;
+
+ /* We now have a completed Ethernet packet; send it across. */
+ net_send_packet (ptr_ethhdr, sizeof(ETHHDR) + l3_pkt_size);
+
+ /* The packet has been transmitted and we can clean it up now. */
+ net_free_tx_packet ((Uint8 *)ptr_iphdr);
+ return;
+ }
+ }
+
+ /* Initialize the ARP Cache: The cache did not have information for the resolution to work
+ * Reset the cache and start again. */
+ memset ((void *)&net_arp_cache, 0, sizeof(NET_ARP_CACHE));
+
+ /* Populate the ARP Cache */
+ net_arp_cache.ip_address = dst_ip;
+ net_arp_cache.pending_packet_len = l3_pkt_size;
+ memcpy ((void *)&net_arp_cache.pending_packet[0], (void *)ptr_iphdr, l3_pkt_size);
+
+ /* Free up the packet now; we have already stored it in the ARP cache. */
+ net_free_tx_packet ((Uint8 *)ptr_iphdr);
+
+ /* Allocate a new packet to send out the ARP request. */
+ ptr_arphdr = (ARPHDR *)net_alloc_tx_packet(sizeof(ARPHDR));
+ if (ptr_arphdr == NULL)
+ return;
+
+ /* Populate the ARP Header. */
+ ptr_arphdr->HardType = htons(0x1);
+ ptr_arphdr->ProtocolType = htons(0x800);
+ ptr_arphdr->HardSize = 0x6;
+ ptr_arphdr->ProtocolSize = 0x4;
+ ptr_arphdr->Op = htons(0x1);
+
+ /* Populate the Source IP/MAC Address */
+ memcpy ((void *)&ptr_arphdr->SrcAddr[0], (void *)&netmcb.net_device.mac_address[0], 6);
+ memcpy ((void *)&ptr_arphdr->IPSrc[0], (void *)&netmcb.net_device.ip_address, 4);
+
+ /* Populate the Target IP/MAC Address: This is set to 0 since the cache has been reset above. */
+ memcpy ((void *)&ptr_arphdr->DstAddr[0], (void *)&net_arp_cache.mac_address[0], 6);
+ memcpy ((void *)&ptr_arphdr->IPDst[0], (void *)&dst_ip, 4);
+
+ /* Create the Ethernet header. */
+ ptr_ethhdr = net_create_eth_header ((Uint8 *)ptr_arphdr, &BroadcastMac[0], 0x806);
+ if (ptr_ethhdr == NULL)
+ return;
+
+ /* Send the packet out. */
+ net_send_packet (ptr_ethhdr, sizeof(ETHHDR) + sizeof(ARPHDR));
+
+ /* The packet has been transmitted and we can clean it up now. */
+ net_free_tx_packet ((Uint8 *)ptr_arphdr);
+ return;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function handles the reception and processing of ARP packets.
+ *
+ * @param[in] ptr_arphdr
+ * This is the pointer to the received ARP header.
+ * @param[in] num_bytes
+ * This is the size of the ARP packet.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+Int32 arp_receive (ARPHDR* ptr_arphdr, Int32 num_bytes)
+{
+ Uint32 IPAddress;
+ Uint8* ptr_pending_pkt;
+ ETHHDR* ptr_ethhdr;
+
+ /* Extract the intended target and convert it to host format. */
+ IPAddress = READ32(ptr_arphdr->IPDst);
+
+ /* Ensure that the packet has not been looped back and we received our own frame. */
+ if ((ptr_arphdr->SrcAddr[0] == netmcb.net_device.mac_address[0]) &&
+ (ptr_arphdr->SrcAddr[1] == netmcb.net_device.mac_address[1]) &&
+ (ptr_arphdr->SrcAddr[2] == netmcb.net_device.mac_address[2]) &&
+ (ptr_arphdr->SrcAddr[3] == netmcb.net_device.mac_address[3]) &&
+ (ptr_arphdr->SrcAddr[4] == netmcb.net_device.mac_address[4]) &&
+ (ptr_arphdr->SrcAddr[5] == netmcb.net_device.mac_address[5]))
+ {
+ /* We received our own frame; ignore this. */
+ return -1;
+ }
+
+ /* Check if the packet is meant for us? If it not meant for us we drop the packet. */
+ if (IPAddress != netmcb.net_device.ip_address)
+ return -1;
+
+ /* The ARP packet was meant for us; we need to update the ARP cache with the request. */
+ net_arp_cache.ip_address = READ32(ptr_arphdr->IPSrc);
+ memcpy ((void *)&net_arp_cache.mac_address[0], (void *)&ptr_arphdr->SrcAddr[0], 6);
+
+ /* Check if the packet is an ARP request? */
+ if (ptr_arphdr->Op == htons(0x1))
+ {
+ /* YES. We need to send out an ARP Reply; so create the packet.
+ * Ensure that the Layer3 headers are aligned on the 4 byte boundary
+ * and yet we have sufficient space for the Ethernet header. */
+ ptr_arphdr = (ARPHDR *)net_alloc_tx_packet(sizeof(ARPHDR));
+ if (ptr_arphdr == NULL)
+ return -1;
+
+ /* Populate the ARP Header. */
+ ptr_arphdr->HardType = htons(0x1);
+ ptr_arphdr->ProtocolType = htons(0x800);
+ ptr_arphdr->HardSize = 0x6;
+ ptr_arphdr->ProtocolSize = 0x4;
+ ptr_arphdr->Op = htons(0x2);
+
+ /* Populate the Source IP/MAC Address in the ARP Header */
+ memcpy ((void *)&ptr_arphdr->SrcAddr[0], (void *)&netmcb.net_device.mac_address[0], 6);
+ memcpy ((void *)&ptr_arphdr->IPSrc[0], (void *)&netmcb.net_device.ip_address, 4);
+
+ /* Populate the Target IP/MAC Address in the ARP Header */
+ memcpy ((void *)&ptr_arphdr->DstAddr[0], (void *)&net_arp_cache.mac_address[0], 6);
+ memcpy ((void *)&ptr_arphdr->IPDst[0], (void *)&net_arp_cache.ip_address, 4);
+
+ /* Create the Ethernet header. */
+ ptr_ethhdr = net_create_eth_header ((Uint8 *)ptr_arphdr, &net_arp_cache.mac_address[0], 0x806);
+ if (ptr_ethhdr == NULL)
+ return -1;
+
+ /* Send the packet out. */
+ net_send_packet (ptr_ethhdr, sizeof(ETHHDR) + sizeof(ARPHDR));
+
+ /* The packet has been transmitted and we can clean it up now. */
+ net_free_tx_packet ((Uint8 *)ptr_arphdr);
+ }
+
+ /* Check if there are any packet awaiting resolution? */
+ if (net_arp_cache.pending_packet_len != 0)
+ {
+ /* There was a packet in the ARP cache which was awaiting resolution.
+ * We need to send out the packet now. */
+ ptr_pending_pkt = net_alloc_tx_packet(net_arp_cache.pending_packet_len);
+ if (ptr_pending_pkt == NULL)
+ return -1;
+
+ /* We now copy the contents of this packet from the ARP cache */
+ memcpy ((void *)ptr_pending_pkt, (void *)&net_arp_cache.pending_packet[0],
+ net_arp_cache.pending_packet_len);
+
+ /* We create the Ethernet header.
+ * Only IPv4 packets await resolution. */
+ ptr_ethhdr = net_create_eth_header ((Uint8 *)ptr_pending_pkt, &net_arp_cache.mac_address[0], 0x800);
+ if (ptr_ethhdr == NULL)
+ return -1;
+
+ /* Send the packet out. */
+ net_send_packet (ptr_ethhdr, sizeof(ETHHDR) + net_arp_cache.pending_packet_len);
+
+ /* The pending packet in the cache has been sent out. */
+ net_arp_cache.pending_packet_len = 0;
+
+ /* The packet has been transmitted and can be cleaned up. */
+ net_free_tx_packet (ptr_pending_pkt);
+ }
+
+ /* ARP Packet has been successfully processed. */
+ return 0;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function initializes the ARP Module in the NET Boot module.
+ *
+ * @retval
+ * Not Applicable
+ */
+void arp_init (void)
+{
+ memset (&net_arp_cache, 0, sizeof(NET_ARP_CACHE));
+ return;
+}
+
+
+
diff --git a/src/driver/eth/arp.timer.c b/src/driver/eth/arp.timer.c
--- /dev/null
@@ -0,0 +1,352 @@
+/**
+ * @file arp.c
+ *
+ * @brief
+ * The file implements the NET Module ARP functionality.
+ *
+ * \par
+ * NOTE:
+ * (C) Copyright 2008, Texas Instruments, Inc.
+ *
+ * \par
+ */
+#include "types.h"
+#include "iblloc.h"
+#include "net.h"
+#include "netif.h"
+#include "timer.h"
+#include <string.h>
+
+
+/**********************************************************************
+ *************************** LOCAL Structures *************************
+ **********************************************************************/
+
+/**
+ * @brief
+ * The structure describes the ARP Cache
+ *
+ * @details
+ * This describes the ARP Cache which keeps track of the IPv4 address and
+ * the corresponding Layer2 MAC Address.
+ */
+typedef struct NET_ARP_CACHE
+{
+ /**
+ * @brief This is the MAC Address i.e. Layer2 address matching the
+ * corresponding IP Address.
+ */
+ Uint8 mac_address[6];
+
+ /**
+ * @brief This is the IP Address stored in network order.
+ */
+ IPN ip_address;
+
+ /**
+ * @brief When the upper layers tries to send a packet and
+ * the MAC Address is not resolved; packets are stored in this
+ * temporary area. The ARP stack sends out an ARP request packet
+ * and resolves the IP address. Once the resolution is done pending
+ * packets are transmitted.
+ */
+ Uint8 pending_packet[NET_MAX_MTU];
+
+ /**
+ * @brief This is the length of the pending packet. A value of 0
+ * indicates that there is no pending packet in the ARP cache.
+ */
+ Uint16 pending_packet_len;
+
+ /**
+ * @brief The timer used to handle arp request timeouts
+ */
+ Int32 timer;
+
+ /**
+ * @brief The number of times an arp request was resent
+ */
+ Uint32 resend_count;
+
+}NET_ARP_CACHE;
+
+/**********************************************************************
+ *************************** GLOBAL Variables *************************
+ **********************************************************************/
+
+/**
+ * @brief This is the ARP cache; which keeps track of the IP Address to
+ * MAC Address mapping.
+ */
+NET_ARP_CACHE net_arp_cache;
+
+/**********************************************************************
+ **************************** ARP Functions ***************************
+ **********************************************************************/
+
+void arp_send (void)
+{
+ ARPHDR* ptr_arphdr;
+ ETHHDR* ptr_ethhdr;
+ Uint8 BroadcastMac[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
+
+ /* If the address has been resolved then the arp reply was received, despite the timeout */
+ if ( (net_arp_cache.mac_address[0] != 0x00) || (net_arp_cache.mac_address[1] != 0x00) ||
+ (net_arp_cache.mac_address[2] != 0x00) || (net_arp_cache.mac_address[3] != 0x00) ||
+ (net_arp_cache.mac_address[4] != 0x00) || (net_arp_cache.mac_address[5] != 0x00) )
+ return;
+
+ /* Allocate a new packet to send out the ARP request. */
+ ptr_arphdr = (ARPHDR *)net_alloc_tx_packet(sizeof(ARPHDR));
+ if (ptr_arphdr == NULL)
+ return;
+
+ /* Populate the ARP Header. */
+ ptr_arphdr->HardType = htons(0x1);
+ ptr_arphdr->ProtocolType = htons(0x800);
+ ptr_arphdr->HardSize = 0x6;
+ ptr_arphdr->ProtocolSize = 0x4;
+ ptr_arphdr->Op = htons(0x1);
+
+ /* Populate the Source IP/MAC Address */
+ memcpy ((void *)&ptr_arphdr->SrcAddr[0], (void *)&netmcb.net_device.mac_address[0], 6);
+ memcpy ((void *)&ptr_arphdr->IPSrc[0], (void *)&netmcb.net_device.ip_address, 4);
+
+ /* Populate the Target IP/MAC Address: This is likely set to 0 since the cache has been reset on the first send. */
+ memcpy ((void *)&ptr_arphdr->DstAddr[0], (void *)&net_arp_cache.mac_address[0], 6);
+ memcpy ((void *)&ptr_arphdr->IPDst[0], (void *)&net_arp_cache.ip_address, 4);
+
+ /* Create the Ethernet header. */
+ ptr_ethhdr = net_create_eth_header ((Uint8 *)ptr_arphdr, &BroadcastMac[0], 0x806);
+ if (ptr_ethhdr == NULL)
+ return;
+
+ /* Send the packet out. */
+ net_send_packet (ptr_ethhdr, sizeof(ETHHDR) + sizeof(ARPHDR));
+
+ /* The packet has been transmitted and we can clean it up now. */
+ net_free_tx_packet ((Uint8 *)ptr_arphdr);
+
+}
+
+void arp_timer_expiry (void)
+{
+ /* ARP request timeout. Resend */
+ arp_send();
+
+ net_arp_cache.resend_count += 1;
+}
+
+/**
+ * @b Description
+ * @n
+ * This function is called by the IP Layer to resolve the layer3
+ * address to a layer2 MAC address. The function checks the ARP cache
+ * for a match but if no entry exists then the functions sends out
+ * an ARP request and it places this packet into the pending queue.
+ *
+ * @param[in] dst_ip
+ * This is the destination IP address of the packet.
+ * @param[in] ptr_iphdr
+ * This is the pointer to the IP header
+ * @param[in] l3_pkt_size
+ * This is the size of the packet (including the IP Header)
+ *
+ * @retval
+ * Not Applicable.
+ */
+void arp_resolve (IPN dst_ip, IPHDR* ptr_iphdr, Uint16 l3_pkt_size)
+{
+ ETHHDR* ptr_ethhdr;
+ Uint8 BroadcastMac[] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
+
+ /* Special Case: Are we sending the packet to 255.255.255.255? */
+ if (dst_ip == (IPN)0xFFFFFFFF)
+ {
+ /* YES. This implies that the destination MAC Address in the packet is the Broadcast address
+ * We dont need to lookup the cache. */
+ ptr_ethhdr = net_create_eth_header ((Uint8 *)ptr_iphdr, (void *)&BroadcastMac[0], 0x800);
+ if (ptr_ethhdr == NULL)
+ return;
+
+ /* We now have a completed Ethernet packet; send it across. */
+ net_send_packet (ptr_ethhdr, sizeof(ETHHDR) + l3_pkt_size);
+
+ /* The packet has been transmitted and we can clean it up now. */
+ net_free_tx_packet ((Uint8 *)ptr_iphdr);
+ return;
+ }
+
+ /* Check if the destination IP Address matches the ARP cache */
+ if (net_arp_cache.ip_address == dst_ip)
+ {
+ /* Make sure the MAC Address in the CACHE has been resolved i.e. Non-Zero. */
+ if ( (net_arp_cache.mac_address[0] != 0x00) || (net_arp_cache.mac_address[1] != 0x00) ||
+ (net_arp_cache.mac_address[2] != 0x00) || (net_arp_cache.mac_address[3] != 0x00) ||
+ (net_arp_cache.mac_address[4] != 0x00) || (net_arp_cache.mac_address[5] != 0x00) )
+ {
+ /* Perfect; the MAC Address is already resolved.
+ * We can simply use the ARP CACHE MAC address to create the layer2 header. */
+ ptr_ethhdr = net_create_eth_header ((Uint8 *)ptr_iphdr, (void *)&net_arp_cache.mac_address[0], 0x800);
+ if (ptr_ethhdr == NULL)
+ return;
+
+ /* We now have a completed Ethernet packet; send it across. */
+ net_send_packet (ptr_ethhdr, sizeof(ETHHDR) + l3_pkt_size);
+
+ /* The packet has been transmitted and we can clean it up now. */
+ net_free_tx_packet ((Uint8 *)ptr_iphdr);
+ return;
+ }
+ }
+
+ /* Initialize the ARP Cache: The cache did not have information for the resolution to work
+ * Reset the cache and start again. */
+ memset ((void *)&net_arp_cache, 0, sizeof(NET_ARP_CACHE));
+
+ /* Populate the ARP Cache */
+ net_arp_cache.ip_address = dst_ip;
+ net_arp_cache.pending_packet_len = l3_pkt_size;
+ memcpy ((void *)&net_arp_cache.pending_packet[0], (void *)ptr_iphdr, l3_pkt_size);
+
+ /* Free up the packet now; we have already stored it in the ARP cache. */
+ net_free_tx_packet ((Uint8 *)ptr_iphdr);
+
+ net_arp_cache.timer = timer_add (ARP_TIMEOUT, arp_timer_expiry);
+
+ arp_send ();
+
+}
+
+/**
+ * @b Description
+ * @n
+ * The function handles the reception and processing of ARP packets.
+ *
+ * @param[in] ptr_arphdr
+ * This is the pointer to the received ARP header.
+ * @param[in] num_bytes
+ * This is the size of the ARP packet.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+Int32 arp_receive (ARPHDR* ptr_arphdr, Int32 num_bytes)
+{
+ Uint32 IPAddress;
+ Uint8* ptr_pending_pkt;
+ ETHHDR* ptr_ethhdr;
+
+ /* Extract the intended target and convert it to host format. */
+ IPAddress = READ32(ptr_arphdr->IPDst);
+
+ /* Ensure that the packet has not been looped back and we received our own frame. */
+ if ((ptr_arphdr->SrcAddr[0] == netmcb.net_device.mac_address[0]) &&
+ (ptr_arphdr->SrcAddr[1] == netmcb.net_device.mac_address[1]) &&
+ (ptr_arphdr->SrcAddr[2] == netmcb.net_device.mac_address[2]) &&
+ (ptr_arphdr->SrcAddr[3] == netmcb.net_device.mac_address[3]) &&
+ (ptr_arphdr->SrcAddr[4] == netmcb.net_device.mac_address[4]) &&
+ (ptr_arphdr->SrcAddr[5] == netmcb.net_device.mac_address[5]))
+ {
+ /* We received our own frame; ignore this. */
+ return -1;
+ }
+
+ /* Check if the packet is meant for us? If it not meant for us we drop the packet. */
+ if (IPAddress != netmcb.net_device.ip_address)
+ return -1;
+
+ /* The ARP packet was meant for us; we need to update the ARP cache with the request. */
+ net_arp_cache.ip_address = READ32(ptr_arphdr->IPSrc);
+ memcpy ((void *)&net_arp_cache.mac_address[0], (void *)&ptr_arphdr->SrcAddr[0], 6);
+
+ /* Check if the packet is an ARP request? */
+ if (ptr_arphdr->Op == htons(0x1))
+ {
+ /* YES. We need to send out an ARP Reply; so create the packet.
+ * Ensure that the Layer3 headers are aligned on the 4 byte boundary
+ * and yet we have sufficient space for the Ethernet header. */
+ ptr_arphdr = (ARPHDR *)net_alloc_tx_packet(sizeof(ARPHDR));
+ if (ptr_arphdr == NULL)
+ return -1;
+
+ /* Populate the ARP Header. */
+ ptr_arphdr->HardType = htons(0x1);
+ ptr_arphdr->ProtocolType = htons(0x800);
+ ptr_arphdr->HardSize = 0x6;
+ ptr_arphdr->ProtocolSize = 0x4;
+ ptr_arphdr->Op = htons(0x2);
+
+ /* Populate the Source IP/MAC Address in the ARP Header */
+ memcpy ((void *)&ptr_arphdr->SrcAddr[0], (void *)&netmcb.net_device.mac_address[0], 6);
+ memcpy ((void *)&ptr_arphdr->IPSrc[0], (void *)&netmcb.net_device.ip_address, 4);
+
+ /* Populate the Target IP/MAC Address in the ARP Header */
+ memcpy ((void *)&ptr_arphdr->DstAddr[0], (void *)&net_arp_cache.mac_address[0], 6);
+ memcpy ((void *)&ptr_arphdr->IPDst[0], (void *)&net_arp_cache.ip_address, 4);
+
+ /* Create the Ethernet header. */
+ ptr_ethhdr = net_create_eth_header ((Uint8 *)ptr_arphdr, &net_arp_cache.mac_address[0], 0x806);
+ if (ptr_ethhdr == NULL)
+ return -1;
+
+ /* Send the packet out. */
+ net_send_packet (ptr_ethhdr, sizeof(ETHHDR) + sizeof(ARPHDR));
+
+ /* The packet has been transmitted and we can clean it up now. */
+ net_free_tx_packet ((Uint8 *)ptr_arphdr);
+ }
+
+ /* Check if there are any packet awaiting resolution? */
+ if (net_arp_cache.pending_packet_len != 0)
+ {
+ /* There was a packet in the ARP cache which was awaiting resolution.
+ * We need to send out the packet now. */
+ ptr_pending_pkt = net_alloc_tx_packet(net_arp_cache.pending_packet_len);
+ if (ptr_pending_pkt == NULL)
+ return -1;
+
+ /* We now copy the contents of this packet from the ARP cache */
+ memcpy ((void *)ptr_pending_pkt, (void *)&net_arp_cache.pending_packet[0],
+ net_arp_cache.pending_packet_len);
+
+ /* We create the Ethernet header.
+ * Only IPv4 packets await resolution. */
+ ptr_ethhdr = net_create_eth_header ((Uint8 *)ptr_pending_pkt, &net_arp_cache.mac_address[0], 0x800);
+ if (ptr_ethhdr == NULL)
+ return -1;
+
+ /* Send the packet out. */
+ net_send_packet (ptr_ethhdr, sizeof(ETHHDR) + net_arp_cache.pending_packet_len);
+
+ /* The pending packet in the cache has been sent out. */
+ net_arp_cache.pending_packet_len = 0;
+
+ /* The packet has been transmitted and can be cleaned up. */
+ net_free_tx_packet (ptr_pending_pkt);
+
+ timer_delete (net_arp_cache.timer);
+ }
+
+ /* ARP Packet has been successfully processed. */
+ return 0;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function initializes the ARP Module in the NET Boot module.
+ *
+ * @retval
+ * Not Applicable
+ */
+void arp_init (void)
+{
+ memset (&net_arp_cache, 0, sizeof(NET_ARP_CACHE));
+ return;
+}
+
+
+
diff --git a/src/driver/eth/bootp.c b/src/driver/eth/bootp.c
--- /dev/null
+++ b/src/driver/eth/bootp.c
@@ -0,0 +1,377 @@
+/**
+ * @file bootp.c
+ *
+ * @brief
+ * The file implements the NET Module BOOTP functionality.
+ *
+ * \par
+ * NOTE:
+ * (C) Copyright 2008, Texas Instruments, Inc.
+ *
+ * \par
+ */
+#include "types.h"
+#include "iblloc.h"
+#include "net.h"
+#include "netif.h"
+#include "timer.h"
+#include "stream.h"
+#include <string.h>
+
+
+/**********************************************************************
+ *************************** LOCAL Structures *************************
+ **********************************************************************/
+
+/**
+ * @brief
+ * The structure describes the BOOTP Master Control Block.
+ *
+ * @details
+ * The BOOTP Master control block stores information used by the
+ * BOOTP module.
+ */
+typedef struct BOOTP_MCB
+{
+ /**
+ * @brief This is the BOOTP header which is populated and sent across
+ * to the server.
+ */
+ BOOTPHDR boothdr;
+
+ /**
+ * @brief This is the BOOTP handle to the UDP socket.
+ */
+ Int32 sock;
+
+ /**
+ * @brief This is the number of BOOTP requests sent out.
+ */
+ Int32 num_request;
+
+ /**
+ * @brief This is the BOOTP timer handle.
+ */
+ Int32 bootp_timer;
+
+ /**
+ * @brief The optional application call back when the
+ * bootp file name and IP address has been received.
+ */
+ void (*asyncComplete)(void *);
+
+}BOOTP_MCB;
+
+/**********************************************************************
+ *************************** GLOBAL Variables *************************
+ **********************************************************************/
+
+/**
+ * @brief This is the global master control block for the BOOTP module
+ * and stores all the necessary information.
+ */
+BOOTP_MCB bootpmcb;
+
+/**********************************************************************
+ **************************** BOOTP Functions *************************
+ **********************************************************************/
+
+/**
+ * @b Description
+ * @n
+ * This is a call back function registered with the TIMER module
+ * to be called if there is a timeout and no BOOTP reply is
+ * received.
+ *
+ * @retval
+ * Not Applicable.
+ */
+static void bootp_tmr_expiry (void)
+{
+ BOOTPHDR* ptr_bootphdr;
+
+ /* Get the pointer to the BOOTP Header. */
+ ptr_bootphdr = &bootpmcb.boothdr;
+
+ /* Populate the BOOTP header with all the information we have. */
+ ptr_bootphdr->op = BOOTP_OP_REQUEST;
+ ptr_bootphdr->htype = BOOTP_HTYPE_ETHERNET;
+ ptr_bootphdr->hlen = 6;
+ ptr_bootphdr->xid = htonl(0x1);
+ memcpy ((void *)&ptr_bootphdr->chaddr, (void *)&netmcb.net_device.mac_address[0], 6);
+
+ /* The packet has been populated; send it to the server. */
+ udp_sock_send (bootpmcb.sock, (Uint8 *)ptr_bootphdr, sizeof(BOOTPHDR));
+
+ /* Increment the number of requests sent out. */
+ bootpmcb.num_request++;
+
+ /* We need to delete the current timer and create another with the backoff strategy. */
+ timer_delete (bootpmcb.bootp_timer);
+
+ /* Check if we have exceeded the max. permissible? */
+ if (bootpmcb.num_request > BOOTP_MAX_RETRIES)
+ {
+ /* Error: Maximum retransmissions have been exceeded; indicate error. */
+ mprintf ("BOOTP Failure: Max Retransmissions exceeded\n");
+ net_set_error ();
+ udp_sock_close(bootpmcb.sock);
+ return;
+ }
+
+ /* Create the new backoff timer. */
+ bootpmcb.bootp_timer = timer_add (BOOTP_SEED_TIMEOUT*bootpmcb.num_request, bootp_tmr_expiry);
+ if (bootpmcb.bootp_timer < 0)
+ {
+ /* Error: Unable to create the new backoff timer; indicate error. */
+ mprintf ("BOOTP Failure: Backoff timer failed\n");
+ net_set_error ();
+ stream_close();
+ udp_sock_close(bootpmcb.sock);
+ return;
+ }
+ return;
+}
+
+/**
+ * @b Description
+ * @n
+ * This is a call back function registered with the UDP module to
+ * be invoked when a BOOTP packet is received.
+ *
+ * @param[in] sock
+ * This is the socket handle on which packet was received.
+ * @param[in] ptr_data
+ * This is the pointer to the BOOTP data payload.
+ * @param[in] num_bytes
+ * This is the number of bytes of BOOTP data received.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+static Int32 bootp_receive (Int32 sock, Uint8* ptr_data, Int32 num_bytes)
+{
+ BOOTPHDR* ptr_bootphdr;
+ Int32 index = 0;
+ IPN subnetmask = BOOTP_DEFAULT_MASK;
+ IPN defaultRouter = 0;
+ IPN serverIP = 0;
+
+ /* Received a BOOTP packet from the UDP stack. */
+ ptr_bootphdr = (BOOTPHDR *)ptr_data;
+
+ /* Check if this is a BOOTP reply packet? */
+ if (ptr_bootphdr->op != BOOTP_OP_REPLY)
+ return -1;
+
+ /* Ensure the transaction id matches the one we sent out. */
+ if (ptr_bootphdr->xid != bootpmcb.boothdr.xid)
+ return -1;
+
+ /* Ensure the MAC Address matches our MAC Address */
+ if ((ptr_bootphdr->chaddr[0] != netmcb.net_device.mac_address[0]) ||
+ (ptr_bootphdr->chaddr[1] != netmcb.net_device.mac_address[1]) ||
+ (ptr_bootphdr->chaddr[2] != netmcb.net_device.mac_address[2]) ||
+ (ptr_bootphdr->chaddr[3] != netmcb.net_device.mac_address[3]) ||
+ (ptr_bootphdr->chaddr[4] != netmcb.net_device.mac_address[4]) ||
+ (ptr_bootphdr->chaddr[5] != netmcb.net_device.mac_address[5]))
+ {
+ /* The MAC Address do not match. Ignore the reply packet */
+ return -1;
+ }
+
+ /* Cycle through the options; we are only interested in retreiving the SUBNET Mask option
+ * Since we need to configure the routing table. */
+ while (index < 64)
+ {
+ /* Get the option tag and process it appropriately. */
+ switch (ptr_bootphdr->options[index])
+ {
+ case 0x0:
+ {
+ /* Padding option. Skip this. */
+ index++;
+ break;
+ }
+ case 0x1:
+ {
+ /* SUBNET option. Got it! We dont need to parse anymore. */
+ subnetmask = ((ptr_bootphdr->options[index+2] << 24) |
+ (ptr_bootphdr->options[index+3] << 16) |
+ (ptr_bootphdr->options[index+4] << 8) |
+ (ptr_bootphdr->options[index+5]));
+
+ /* Jump to the next option. */
+ index = index + ptr_bootphdr->options[index + 1] + 2;
+ break;
+ }
+ case 0x3:
+ {
+ /* ROUTER option. Got it! We dont need to parse anymore. */
+ defaultRouter = ((ptr_bootphdr->options[index+2] << 24) |
+ (ptr_bootphdr->options[index+3] << 16) |
+ (ptr_bootphdr->options[index+4] << 8) |
+ (ptr_bootphdr->options[index+5]));
+
+ /* Jump to the next option. */
+ index = index + ptr_bootphdr->options[index + 1] + 2;
+ break;
+ }
+ case 150:
+ {
+ /* TFTP Server IP Address: */
+ serverIP = ((ptr_bootphdr->options[index+2] << 24) |
+ (ptr_bootphdr->options[index+3] << 16) |
+ (ptr_bootphdr->options[index+4] << 8) |
+ (ptr_bootphdr->options[index+5]));
+
+ /* Convert to host order; so that it is in SYNC with "siaddr" field below. */
+ serverIP = ntohl(serverIP);
+
+ /* Jump to the next option. */
+ index = index + ptr_bootphdr->options[index + 1] + 2;
+ break;
+ }
+ case 0xFF:
+ {
+ /* End option. Terminate the loop. */
+ index = 64;
+ break;
+ }
+ default:
+ {
+ /* Any other option is not handled; but we need to skip it */
+ index = index + ptr_bootphdr->options[index + 1] + 2;
+ break;
+ }
+ }
+ }
+
+ /* The BOOTP Reply looks good. Kill the BOOTP timer. */
+ timer_delete (bootpmcb.bootp_timer);
+
+ /* Check if we have received the TFTP Server IP address or not? If not we assume
+ * that the TFTP Server and BOOTP Server address are one and the same. */
+ if (serverIP == 0x0)
+ serverIP = ptr_bootphdr->siaddr;
+
+ /* We have all the information with us from the BOOTP Reply Packet.
+ * a) IP Address
+ * b) Subnet Mask
+ * c) TFTP File Name.
+ * d) TFTP Server IP
+ * Lets configure the IPv4 Routing Table with the appropriate information and
+ * also configure the global netdevice structure. */
+ netmcb.net_device.ip_address = ptr_bootphdr->yiaddr;
+
+ if (netmcb.net_device.use_bootp_server_ip == TRUE)
+ netmcb.net_device.server_ip = serverIP;
+
+ netmcb.net_device.net_mask = htonl(subnetmask);
+ ip_add_route (FLG_RT_NETWORK, netmcb.net_device.ip_address, netmcb.net_device.net_mask, 0);
+
+ if (netmcb.net_device.use_bootp_file_name == TRUE)
+ memcpy (netmcb.net_device.file_name, ptr_bootphdr->file, sizeof(netmcb.net_device.file_name));
+
+ /* Check if we had received a default router? */
+ if (defaultRouter != 0)
+ ip_add_route (FLG_RT_DEFAULT, 0x0, 0x0, htonl(defaultRouter));
+
+ /* DEBUG Message: */
+ mprintf ("*****************************\n");
+ mprintf ("BOOTP Complete\n");
+ mprintf (" IP Address : 0x%x\n", ntohl(netmcb.net_device.ip_address));
+ mprintf (" Net Mask : 0x%x\n", subnetmask);
+ mprintf (" Default Router: 0x%x\n", defaultRouter);
+ mprintf (" Server IP : 0x%x\n", ntohl(serverIP));
+ mprintf (" File Name : %s\n", ptr_bootphdr->file);
+ mprintf ("*****************************\n");
+
+ /* Close the BOOTP sockets. */
+ stream_close();
+ udp_sock_close (sock);
+
+ /* Optional call back with bootp params */
+ if (bootpmcb.asyncComplete != NULL)
+ (*bootpmcb.asyncComplete)((void *)&netmcb.net_device);
+
+ /* Initiate the TFTP Transfer. */
+ tftp_get_file (netmcb.net_device.server_ip, (char *)netmcb.net_device.file_name);
+
+ /* BOOTP Reply has been processed. */
+ return 0;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function is used to initialize the BOOTP client.
+ *
+ * @retval
+ * Not Applicable.
+ */
+void bootp_init (void (*asyncComplete)(void *))
+{
+ BOOTPHDR* ptr_bootphdr;
+ SOCKET socket;
+
+ /* Initialize the BOOT MCB */
+ memset ((void *)&bootpmcb, 0, sizeof(BOOTP_MCB));
+
+ bootpmcb.asyncComplete = asyncComplete;
+
+
+ /* Populate the socket structure and register this with the UDP module. */
+ socket.local_port = BOOTP_CLIENT_PORT;
+ socket.remote_port = BOOTP_SERVER_PORT;
+ socket.remote_address = 0xFFFFFFFF;
+ socket.app_fn = bootp_receive;
+
+ /* Open the BOOTP socket. */
+ bootpmcb.sock = udp_sock_open (&socket);
+ if (bootpmcb.sock < 0)
+ {
+ /* Error: Socket could not be opened. */
+ mprintf ("ERROR: BOOTP SOCK Open Failed\n");
+ net_set_error ();
+ return;
+ }
+
+ /* Open the stream to receive packets */
+ stream_open(TFTP_DATA_SIZE);
+
+ /* Get the pointer to the BOOTP Header. */
+ ptr_bootphdr = &bootpmcb.boothdr;
+
+ /* Populate the BOOTP header with all the information we have. */
+ ptr_bootphdr->op = BOOTP_OP_REQUEST;
+ ptr_bootphdr->htype = BOOTP_HTYPE_ETHERNET;
+ ptr_bootphdr->hlen = 6;
+ ptr_bootphdr->xid = htonl(0x1);
+ memcpy ((void *)&ptr_bootphdr->chaddr, (void *)&netmcb.net_device.mac_address[0], 6);
+
+ /* The packet has been populated; send it to the server. */
+ udp_sock_send (bootpmcb.sock, (Uint8 *)ptr_bootphdr, sizeof(BOOTPHDR));
+
+ /* Increment the number of requests sent out. */
+ bootpmcb.num_request++;
+
+ /* Create the BOOTP Timer; if timer creation fails then BOOTP Retransmissions
+ * will not work and so we treat this as a fatal error. */
+ bootpmcb.bootp_timer = timer_add (BOOTP_SEED_TIMEOUT, bootp_tmr_expiry);
+ if (bootpmcb.bootp_timer < 0)
+ {
+ /* Error: Timer could not be created; we need to close the socket and signal error. */
+ mprintf ("ERROR: BOOTP ADD Timer Failed\n");
+ stream_close();
+ udp_sock_close (bootpmcb.sock);
+ net_set_error ();
+ return;
+ }
+ return;
+}
+
+
+
diff --git a/src/driver/eth/icmp.c b/src/driver/eth/icmp.c
--- /dev/null
+++ b/src/driver/eth/icmp.c
@@ -0,0 +1,133 @@
+/**
+ * @file icmp.c
+ *
+ * @brief
+ * The file implements the NET Module ICMP functionality.
+ *
+ * \par
+ * NOTE:
+ * (C) Copyright 2008, Texas Instruments, Inc.
+ *
+ * \par
+ */
+#include <blf.h>
+#include "netif.h"
+
+#ifdef INCLUDE_BLF_NET_MODULE
+#ifdef INCLUDE_BLF_NET_ICMP
+
+/**
+ * @b Description
+ * @n
+ * The function computes the ICMP checksum and populates the ICMP
+ * Checksum field.
+ *
+ * @param[in] ptr_icmp_hdr
+ * This is the pointer to the ICMP header.
+ * @param[in] size
+ * This is the total size of the ICMP packet including header and data
+ * payload.
+ *
+ * @retval
+ * Not Applicable.
+ */
+static void icmp_checksum (ICMPHDR *ptr_icmp_hdr, Uint16 size)
+{
+ Int32 tmp1;
+ Uint16* pw;
+ Uint32 TSum;
+
+ /* Checksum field is NULL in checksum calculations */
+ ptr_icmp_hdr->Checksum = 0;
+
+ /* Checksum the header */
+ pw = (Uint16 *)ptr_icmp_hdr;
+ TSum = 0;
+ for( tmp1=size; tmp1 > 1; tmp1 -= 2 )
+ TSum += (Uint32)*pw++;
+#ifdef BIGENDIAN
+ if( tmp1 )
+ TSum += (Uint32)(*pw & 0xFF00);
+#else
+ if( tmp1 )
+ TSum += (Uint32)(*pw & 0x00FF);
+#endif
+ TSum = (TSum&0xFFFF) + (TSum>>16);
+ TSum = (TSum&0xFFFF) + (TSum>>16);
+ TSum = ~TSum;
+
+ /* Note checksum is Net/Host byte order independent */
+ ptr_icmp_hdr->Checksum = (Uint16)TSum;
+ return;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function handles the processing of ICMP packets.
+ *
+ * @param[in] ptr_iphdr
+ * This is the pointer to the IP header.
+ *
+ * @retval
+ * Not Applicable.
+ */
+void icmp_receive (IPHDR* ptr_iphdr)
+{
+ ICMPHDR* ptr_icmphdr;
+ Uint16 checksum;
+ Uint16 l4_pkt_size;
+ ICMPHDR* ptr_reply_hdr;
+ IPHDR* ptr_reply_iphdr;
+
+ /* Get the pointer to the ICMP header. */
+ ptr_icmphdr = (ICMPHDR *) ((Uint8 *)ptr_iphdr + IPHDR_SIZE);
+
+ /* Compute the l4 packet size. */
+ l4_pkt_size = ntohs(ptr_iphdr->TotalLen) - IPHDR_SIZE;
+
+ /* We only handle ICMP echo requests */
+ if (ptr_icmphdr->Type != ICMP_ECHO_REQUEST_TYPE)
+ return;
+
+ /* Validate the checksum */
+ checksum = ptr_icmphdr->Checksum;
+ if (checksum == 0xFFFF)
+ checksum = 0;
+ icmp_checksum (ptr_icmphdr, l4_pkt_size);
+ if( checksum != ptr_icmphdr->Checksum )
+ return;
+
+ /* OK; control comes here implies that a valid ICMP ECHO request
+ * packet was received. Now we send back the ECHO reply; so lets
+ * allocate a new transmit packet. */
+ ptr_reply_iphdr = (IPHDR *)net_alloc_tx_packet (l4_pkt_size + IPHDR_SIZE);
+ if (ptr_reply_iphdr == NULL)
+ return;
+
+ /* We can blindly copy the 'original' IP packet to the 'reply' IP packet. */
+ utl_memcpy ((void *)ptr_reply_iphdr, (void *)ptr_iphdr, (l4_pkt_size + IPHDR_SIZE));
+
+ /* Get the pointer to the new header.
+ * The new header starts after the IP header. */
+ ptr_reply_hdr = (ICMPHDR *)((Uint8 *)ptr_reply_iphdr + IPHDR_SIZE);
+
+ /* This is an ECHO reply packet; so lets overwrite the field. */
+ ptr_reply_hdr->Type = ICMP_ECHO_REPLY_TYPE;
+
+ /* Compute the new ICMP checksum and overwrite it in the header. */
+ icmp_checksum (ptr_reply_hdr, l4_pkt_size);
+
+ /* Swap the source and destination address in the REPLY packet. */
+ ptr_reply_iphdr->IPSrc = ptr_iphdr->IPDst;
+ ptr_reply_iphdr->IPDst = ptr_iphdr->IPSrc;
+
+ /* Packet looks good. Send to the IP layer for transmission. */
+ ip_send (ptr_reply_iphdr, l4_pkt_size + IPHDR_SIZE);
+ return;
+}
+
+#endif /* INCLUDE_BLF_NET_ICMP */
+#endif /* INCLUDE_BLF_NET_MODULE */
+
+
diff --git a/src/driver/eth/ip.c b/src/driver/eth/ip.c
--- /dev/null
+++ b/src/driver/eth/ip.c
@@ -0,0 +1,394 @@
+/**
+ * @file ip.c
+ *
+ * @brief
+ * The file implements the NET Module IPv4 functionality.
+ *
+ * \par
+ * NOTE:
+ * (C) Copyright 2008, Texas Instruments, Inc.
+ *
+ * \par
+ */
+#include "types.h"
+#include "iblloc.h"
+#include "net.h"
+#include "netif.h"
+#include <string.h>
+
+
+/**
+ * @brief This is the size of the NET Boot Module Routing table.
+ * This definition should never be modified. If changed then the API
+ * for adding/deleting routes will also need to be modified.
+ */
+#define MAX_RT_TABLE_SIZE 2
+
+/**
+ * @brief This is the global routing table which is used by
+ * the stack to determine the route on which the packet needs to
+ * be transmitted.
+ */
+RT_ENTRY rt_table[MAX_RT_TABLE_SIZE];
+
+/**********************************************************************
+ **************************** IP Functions ****************************
+ **********************************************************************/
+
+/**
+ * @b Description
+ * @n
+ * The function adds a route to the routing table. Default routes are
+ * always added to the last entry in the routing table. There is no
+ * duplicate route checking done here and if an entry exists it is
+ * overriden with the new values.
+ *
+ * @param[in] flag
+ * Flag properties associated with the route
+ * @param[in] ip_address
+ * IP Address associated with the route.
+ * @param[in] net_mask
+ * Network Mask associated with the route
+ * @param[in] next_hop
+ * Next Hop Address associated with the route. This is applicable
+ * for default gateways. For network routes this is ignored.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+Int32 ip_add_route (Uint32 flag, IPN ip_address, IPN net_mask, IPN next_hop)
+{
+ RT_ENTRY* ptr_rt;
+
+ /* Basic Sanity Check: The flag should be correct! */
+ if ((flag != FLG_RT_NETWORK) && (flag != FLG_RT_DEFAULT))
+ return -1;
+
+ /* Check if the flag is a network route being added? */
+ if (flag == FLG_RT_NETWORK)
+ {
+ /* Network route is being added. */
+ ptr_rt = &rt_table[0];
+
+ /* Populate the routing entry. */
+ ptr_rt->flags = FLG_RT_NETWORK;
+ ptr_rt->ip_addr = ip_address;
+ ptr_rt->net_mask = net_mask;
+ ptr_rt->net_addr = ip_address & net_mask;
+ ptr_rt->next_hop = ip_address;
+ }
+ else
+ {
+ /* Default route is being added. */
+ ptr_rt = &rt_table[1];
+
+ /* Populate the routing entry. */
+ ptr_rt->flags = FLG_RT_DEFAULT;
+ ptr_rt->ip_addr = 0x0;
+ ptr_rt->net_mask = 0x0;
+ ptr_rt->net_addr = 0x0;
+ ptr_rt->next_hop = next_hop;
+ }
+
+ /* Routes were added successfully. */
+ return 0;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function checks the routing table to determine a
+ * suitable route which needs to be taken to send out the
+ * packet.
+ *
+ * @param[in] ip_address
+ * IP Address for which the route is being looked up.
+ *
+ * @retval
+ * Success - Pointer to the routing entry being used.
+ * @retval
+ * Error - NULL (There is no route which can be used)
+ */
+RT_ENTRY* ip_lookup_route (IPN ip_address)
+{
+ Int32 index = 0;
+ RT_ENTRY* ptr_rt;
+ IPN network_address;
+
+ /* Cycle through the routing table. */
+ for (index = 0; index < MAX_RT_TABLE_SIZE; index++)
+ {
+ /* Get the pointer to the routing table entry. */
+ ptr_rt = &rt_table[index];
+
+ /* Check if there is a valid entry or not? */
+ if (ptr_rt->flags & (FLG_RT_NETWORK | FLG_RT_DEFAULT))
+ {
+ /* Valid routing entry was found; calculate the network address
+ * with respect to the route netmask and match it. */
+ network_address = ip_address & ptr_rt->net_mask;
+
+ /* Check if this matches the same network to which we are sending the packet. */
+ if (network_address == ptr_rt->net_addr)
+ {
+ /* YES. Perfect; we can return this routing entry. */
+ return ptr_rt;
+ }
+ }
+ }
+
+ /* Control comes here indicates that there was no routing entry which could be used. */
+ return NULL;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function deletes the routing table entry.
+ *
+ * @param[in] flag
+ * This is the routing entry which is being deleted.
+ *
+ * @retval
+ * Not Applicable.
+ */
+void ip_del_route (Uint32 flag)
+{
+ RT_ENTRY* ptr_rt;
+
+ /* Check if the flag is a network route being added? */
+ if (flag == FLG_RT_NETWORK)
+ {
+ /* Network route is being deleted. */
+ ptr_rt = &rt_table[0];
+ }
+ else
+ {
+ if (flag == FLG_RT_DEFAULT)
+ {
+ /* Default route is being deleted. */
+ ptr_rt = &rt_table[0];
+ }
+ else
+ {
+ /* Invalid Flag combination passed. */
+ return;
+ }
+ }
+
+ /* Simply reset all the fields */
+ memset ((void *)ptr_rt, 0, sizeof(RT_ENTRY));
+ return;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function computes the IP checksum. The computed checksum
+ * is populated in the IP header.
+ *
+ * @param[in] ptr_iphdr
+ * This is the pointer to the IPv4 header for which the checksum
+ * is computed.
+ *
+ * @retval
+ * Not Applicable.
+ */
+static void ip_checksum(IPHDR *ptr_iphdr)
+{
+ Int32 tmp1;
+ Uint16 *pw;
+ Uint32 TSum = 0;
+
+ /* Get header size in 4 byte chunks */
+ tmp1 = ptr_iphdr->VerLen & 0xF;
+
+ /* Checksum field is NULL in checksum calculations */
+ ptr_iphdr->Checksum = 0;
+
+ /* Checksum the header */
+ pw = (Uint16 *)ptr_iphdr;
+ do {
+ TSum += (Uint32)*pw++;
+ TSum += (Uint32)*pw++;
+ } while( --tmp1 );
+ TSum = (TSum&0xFFFF) + (TSum>>16);
+ TSum = (TSum&0xFFFF) + (TSum>>16);
+ TSum = ~TSum;
+
+ /* Note checksum is Net/Host byte order independent */
+ ptr_iphdr->Checksum = (Uint16)TSum;
+ return;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function handles the processing of IPv4 packets.
+ *
+ * @param[in] ptr_iphdr
+ * This is the pointer to the IPv4 header.
+ * @param[in] num_bytes
+ * This is the total number of bytes which includes the IPv4 header
+ * and data payload.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+Int32 ip_receive (IPHDR* ptr_iphdr, Int32 num_bytes)
+{
+ Uint32 checksum;
+
+ /* Basic IPv4 Packet Validations: Ensure that this is an IPv4 packet. */
+ if ((ptr_iphdr->VerLen & 0xF0) != 0x40)
+ return -1;
+
+ /* Validate the length of the received packet; it cannot be greater
+ * than the total length of the received packet. */
+ if (ntohs(ptr_iphdr->TotalLen) > num_bytes)
+ return -1;
+
+ /* Checksum validation. */
+ checksum = ptr_iphdr->Checksum;
+ if (checksum == 0xFFFF )
+ checksum = 0;
+ ip_checksum (ptr_iphdr);
+ if (checksum != ptr_iphdr->Checksum )
+ return -1;
+
+ /* We dont handle any IP option processing.
+ * Thus if the IP header length is greater than 20 bytes the packet is dropped. */
+ if (((ptr_iphdr->VerLen & 0xF) << 2) != IPHDR_SIZE)
+ return -1;
+
+ /* We accept only the following packets:-
+ * a) Destination Address is the address of the NET Boot module.
+ * b) Destination Address is the a special 255.255.255.255 address for BOOTP Reply*/
+ if ((ptr_iphdr->IPDst != netmcb.net_device.ip_address) && (ptr_iphdr->IPDst != 0xFFFFFFFF))
+ return -1;
+
+ /* Pass the packet to the layer4 receive handlers. */
+ switch (ptr_iphdr->Protocol)
+ {
+#ifdef INCLUDE_BLF_NET_ICMP
+ case IPPROTO_ICMP:
+ {
+ icmp_receive (ptr_iphdr);
+ break;
+ }
+#endif /* INCLUDE_BLF_NET_ICMP */
+ case IPPROTO_UDP:
+ {
+ /* UDP Packet. */
+ if (udp_receive (ptr_iphdr) < 0)
+ net_stats.rx_udp_dropped++;
+ break;
+ }
+ default:
+ {
+ /* No other protocol is handled. */
+ return -1;
+ }
+ }
+
+ /* Packet has been successfully processed at the IP layer. */
+ return 0;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function is called from the layer4 protocol to send
+ * out an IPv4 packet.
+ *
+ * @param[in] ptr_iphdr
+ * This is the pointer to the IPv4 header + payload which includes
+ * the layer4 header and actual data payload.
+ * The layer4 protocol is supposed to populate the following IPv4 fields:-
+ * - Protocol
+ * - Destination IP
+ * The rest of the fields in the IPv4 header are populated by this function.
+ *
+ * @param[in] size
+ * This is the total number of bytes which includes the layer4 header
+ * and data payload and the IPv4 header.
+ *
+ * @retval
+ * Not Applicable.
+ */
+void ip_send (IPHDR* ptr_iphdr, Uint16 size)
+{
+ RT_ENTRY* ptr_rt;
+ IPN next_hop_address;
+
+ /* Special Case: If the IP Address of the packet is 255.255.255.255
+ * we dont need to check the routing table. */
+ if (ptr_iphdr->IPDst != 0xFFFFFFFF)
+ {
+ /* Lookup the routing table for a routing entry. */
+ ptr_rt = ip_lookup_route (ptr_iphdr->IPDst);
+ if (ptr_rt == NULL)
+ {
+ /* There is no route which exists to send the packet. Drop it! */
+ net_free_tx_packet ((Uint8 *)ptr_iphdr);
+ return;
+ }
+
+ /* Control comes here indicating that a route exists and the packet
+ * can be sent out. There are 2 types of routes in the system:-
+ * a) Network Routes which are directly attached and in this case
+ * the next hop ip address is the same as the destination IP address
+ * b) Default Routes which is the address of the default gateway to which
+ * we need to send the packet since the destination network is not
+ * directly connected.
+ * So here we determine the next hop address based on the route type. */
+ if (ptr_rt->flags == FLG_RT_NETWORK)
+ next_hop_address = ptr_iphdr->IPDst;
+ else
+ next_hop_address = ptr_rt->next_hop;
+ }
+ else
+ {
+ /* This is a BOOTP request being sent out to 255.255.255.255. Set the
+ * next hop address to be the same. */
+ next_hop_address = ptr_iphdr->IPDst;
+ }
+
+ /* Ensure all the fields in the IPv4 header are populated correctly */
+ ptr_iphdr->VerLen = 0x45;
+ ptr_iphdr->Tos = 0;
+ ptr_iphdr->Id = netmcb.ipID++;
+ ptr_iphdr->FlagOff = 0;
+ ptr_iphdr->Ttl = 64;
+ ptr_iphdr->TotalLen = htons(size);
+ ptr_iphdr->IPSrc = netmcb.net_device.ip_address;
+
+ /* Here we recompute the IP Checksum. */
+ ip_checksum (ptr_iphdr);
+
+ /* Layer2 resolution is done on the Next hop address. */
+ arp_resolve (next_hop_address, ptr_iphdr, size);
+ return;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function initializes the IP Module in the NET Boot module.
+ *
+ * @retval
+ * Not Applicable
+ */
+void ip_init (void)
+{
+ /* Reset the routing table */
+ memset (&rt_table, 0, sizeof(rt_table));
+ return;
+}
+
+
+
diff --git a/src/driver/eth/net.c b/src/driver/eth/net.c
--- /dev/null
+++ b/src/driver/eth/net.c
@@ -0,0 +1,686 @@
+/**
+ * @file net.c
+ *
+ * @brief
+ * The file implements the NET Boot Module.
+ *
+ * \par
+ * NOTE:
+ * (C) Copyright 2008, Texas Instruments, Inc.
+ *
+ * \par
+ */
+#include "types.h"
+#include "iblloc.h"
+#include "net.h"
+#include "netif.h"
+#include "timer.h"
+#include "stream.h"
+#include <string.h>
+
+
+/**********************************************************************
+ *************************** Local Functions **************************
+ **********************************************************************/
+static Int32 net_open (void* ptr_driver, void (*asyncComplete)(void *));
+static Int32 net_close(void);
+static Int32 net_read (Uint8* ptr_buf, Uint32 num_bytes);
+static Int32 net_peek (Uint8* ptr_buf, Uint32 num_bytes);
+static Int32 net_seek (Int32 loc, Int32 from);
+static Int32 net_query (void);
+
+/**********************************************************************
+ *************************** GLOBAL Variables *************************
+ **********************************************************************/
+
+/**
+ * @defgroup net_op
+ *
+ * @ingroup net_op
+ * @{
+ *
+ * @brief
+ * Internal definition to distinguish a read from a peek
+ *
+ */
+
+/**
+ * @def NET_READ
+ */
+#define NET_READ 400 /**< Read from the net device */
+
+/**
+ * @def NET_PEEK
+ */
+#define NET_PEEK 420 /**< Peek from the net device */
+
+/* @} */
+
+
+/**
+ * @brief This is the NETWORK Master control block which keeps track
+ * of all the Network boot module related information.
+ */
+NET_MCB netmcb;
+
+/**
+ * @brief This keeps track of the network statistics.
+ */
+NET_STATS net_stats;
+
+/**
+ * @brief This is the global Network Boot Module function table which
+ * implements the Boot Module Interface with the kernel.
+ */
+BOOT_MODULE_FXN_TABLE net_boot_module =
+{
+ net_open, /* Open API */
+ net_close, /* Close API */
+ net_read, /* Read API */
+ NULL, /* Write API (NULL: This is not interactive) */
+ net_peek, /* Peek API */
+ net_seek, /* Seek API */
+ net_query /* Query API */
+};
+
+/**********************************************************************
+ **************************** NET Functions ***************************
+ **********************************************************************/
+
+/**
+ * @b Description
+ * @n
+ * The function is used to allocate a packet for transmission. This
+ * is called by the higher layer protocols when a packet needs to
+ * be transmitted. The function ensures there is sufficient space
+ * allocated at the beginning of the packet for the Ethernet header.
+ * Since the pointer returned by this API is used to store L3/L4 headers
+ * it always returns a 4 byte aligned buffer data pointer.
+ *
+ * @param[in] packet_len
+ * Length of the packet being transmitted.
+ *
+ * @retval
+ * Success - Pointer to the L3 header.
+ * @retval
+ * Error - NULL
+ */
+Uint8* net_alloc_tx_packet(Int32 packet_len)
+{
+ /* Sanity Check: Ensure the packet being allocated does not exceed the
+ * max buffer size that we have. */
+ if (packet_len > NET_MAX_MTU)
+ return NULL;
+
+ /* Sanity Check: Ensure that the packet is available for use. */
+ if (netmcb.txuse == 1)
+ return NULL;
+
+ /* Mark the packet as being in use. */
+ netmcb.txuse = 1;
+
+ /* Reset the contents of the packet */
+ memset ((void *)&netmcb.tx_packet[0], 0, sizeof(netmcb.tx_packet));
+
+ /* Reserve some space at the head of the packet for the Ethernet headers. */
+ return &netmcb.tx_packet[16];
+}
+
+/**
+ * @b Description
+ * @n
+ * The function is called to free up a previously allocated transmit
+ * packet.
+ *
+ * @param[in] ptr
+ * Pointer to the packet being cleaned.
+ *
+ * @retval
+ * Not Applicable.
+ */
+void net_free_tx_packet (Uint8* ptr)
+{
+ /* Sanity Checks: Ensure that the packet being cleaned is the same as the one
+ * which was allocated. */
+ if (ptr != &netmcb.tx_packet[16])
+ mprintf ("ERROR: NET Free Transmit packet detected corruption\n");
+
+ /* Sanity Checks: Ensure that there is no double free. */
+ if (netmcb.txuse == 0)
+ mprintf ("ERROR: NET Free Transmit packet detected double free\n");
+
+ /* Mark the transmit packet as free and available. */
+ netmcb.txuse = 0;
+ return;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function is used to append an Ethernet header on the packet.
+ * The source MAC Address in the packet is always the one which was
+ * registered by the driver. Higher layer protocol authors need to
+ * use the 'net_alloc_tx_packet' API to get a transmit buffer.
+ *
+ * @param[in] ptr_l3_hdr
+ * This is the pointer to the layer3 header.
+ * @param[in] dst_mac
+ * The destination MAC address
+ * @param[in] protocol
+ * The layer3 protocol version (passed in host order)
+ *
+ * @retval
+ * Success - Pointer to the start of the Ethernet header i.e. L2.
+ * @retval
+ * Error - NULL
+ */
+ETHHDR* net_create_eth_header (Uint8* ptr_l3_hdr, Uint8* dst_mac, Uint16 protocol)
+{
+ Int32 rsvd_space;
+
+ /* Compute the reserved space. */
+ rsvd_space = (Int32)ptr_l3_hdr - (Int32)&netmcb.tx_packet[0];
+
+ /* Ensure there is sufficient space to add the header. We dont want memory corruption
+ * to occur here. */
+ if ((rsvd_space < 0) || (rsvd_space > NET_MAX_MTU) || (rsvd_space < ETHHDR_SIZE))
+ return NULL;
+
+ /* Convert the protocol to network order. */
+ protocol = ntohs(protocol);
+
+ /* Start adding the Ethernet header.
+ * Move back the data pointer to account for the protocol. */
+ ptr_l3_hdr = ptr_l3_hdr - 2;
+ memcpy ((void *)ptr_l3_hdr, (void *)&protocol, sizeof(Uint16));
+
+ /* Move back the data pointer to account for the source MAC. */
+ ptr_l3_hdr = ptr_l3_hdr - 6;
+ memcpy ((void *)ptr_l3_hdr, (void *)&netmcb.net_device.mac_address[0], 6);
+
+ /* Move back the data pointer to account for the destination MAC. */
+ ptr_l3_hdr = ptr_l3_hdr - 6;
+ memcpy ((void *)ptr_l3_hdr, (void *)dst_mac, 6);
+
+ /* Return the pointer to the start of the Ethernet header. */
+ return (ETHHDR *)ptr_l3_hdr;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function is used to send a packet to the driver.
+ *
+ * @param[in] ptr_l2_hdr
+ * This is the pointer to the L2 header of the packet to be transmitted.
+ * All the headers need to be populated by the time comes to this API.
+ * @param[in] length
+ * Length of the packet being transmitted. This include the L2 header
+ * information.
+ *
+ * @retval
+ * Not Applicable.
+ */
+void net_send_packet (ETHHDR* ptr_l2_hdr, Uint16 length)
+{
+ /* Sanity Check: This is called after the LAYER3 and ETHER headers
+ * have been appended to the packet. Here we ensure that the layer3 header
+ * is aligned on the 4 byte boundary. */
+ if ( (((Uint32)ptr_l2_hdr+ETHHDR_SIZE) % 4) != 0)
+ mprintf ("ERROR: Misaligned Layer3 packet transmitted 0x%p.\n", ptr_l2_hdr);
+
+ /* Increment the stats. */
+ net_stats.num_pkt_txed++;
+
+ /* Pass the packet to the platform API for transmission. */
+ netmcb.net_device.send (&netmcb.net_device, (Uint8 *)ptr_l2_hdr, (Int32)length);
+ return;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function is called from any entity inside the NETWORK Boot Module
+ * to indicate that there has been a FATAL error and that the boot module
+ * processing needs to be aborted.
+ *
+ * @retval
+ * Not Applicable.
+ */
+void net_set_error (void)
+{
+ /* Set the Error Flag; */
+ netmcb.error_flag = 1;
+ return;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function opens the BLF NET Module. The function initializes
+ * the various internal components of the NET module and also
+ * initializes the peripheral driver controller
+ *
+ * @param[in] ptr_driver
+ * This is the pointer to the driver block which was passed to
+ * the BLF through the BOOT Mode descriptor. For the NET boot
+ * module this points to the NET_DRV_DEVICE object.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+static Int32 net_open (void* ptr_driver, void (*asyncComplete)(void *))
+{
+ NET_DRV_DEVICE* ptr_net_driver;
+
+ /* Get the pointer to the net driver. */
+ ptr_net_driver = (NET_DRV_DEVICE*)ptr_driver;
+
+ /* Basic Validation: Ensure there is a valid driver block being passed. */
+ if (ptr_net_driver == NULL)
+ return -1;
+
+ /* Basic Validation: Ensure that all the required API have been provided */
+ if ((ptr_net_driver->start == NULL) || (ptr_net_driver->send == NULL) ||
+ (ptr_net_driver->receive == NULL) || (ptr_net_driver->stop == NULL))
+ {
+ /* Error: Required API was not specified. */
+ return -1;
+ }
+
+ /* Initialize the NET MCB. */
+ memset (&netmcb, 0, sizeof(NET_MCB));
+
+ /* Initialize the Network Statistics. */
+ memset (&net_stats, 0, sizeof(NET_STATS));
+
+ /* Copy the driver information into the NET MCB */
+ memcpy ((void *)&netmcb.net_device, (void *)ptr_net_driver, sizeof(NET_DRV_DEVICE));
+
+ /* Initialize the ARP Module. */
+ arp_init ();
+
+ /* Initialize the IP Module. */
+ ip_init ();
+
+ /* Initialize the UDP Module. */
+ udp_init ();
+
+ /* Start the networking device */
+ if (netmcb.net_device.start(&netmcb.net_device) < 0)
+ return -1;
+
+ /* Determine if we need to execute BOOTP or not? */
+ if (netmcb.net_device.ip_address != 0)
+ {
+ /* IP Address was supplied by the device team. There is no need
+ * to execute the BOOTP protocol; manually create the network route also. */
+ ip_add_route (FLG_RT_NETWORK, netmcb.net_device.ip_address, netmcb.net_device.net_mask, 0);
+
+ /* Optional call back with boot server info */
+ if (asyncComplete != NULL)
+ (*asyncComplete)((void *)&netmcb.net_device);
+
+ /* Lets download the file from the TFTP Server. */
+ tftp_get_file (netmcb.net_device.server_ip, netmcb.net_device.file_name);
+ }
+ else
+ {
+ /* No IP Address was supplied we need to execute the BOOTP protocol. */
+ bootp_init (asyncComplete);
+ }
+
+ /* The network module is UP and running.. */
+ return 0;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function closes the BLF NET Module.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+static Int32 net_close (void)
+{
+ return 0;
+}
+
+
+/**
+ * @b Description
+ * @n
+ * If a waiting packet is found it is processed
+ */
+static void proc_packet (void)
+{
+ Uint8* ptr_data_packet;
+ Int32 packet_size;
+ Uint16 protocol;
+ Uint8 dst_mac_address[6];
+
+ /* Initialize the pointer in the received packet is stored.
+ * This is misaligned on the 2 byte boundary as this will ensure that
+ * the layer3 headers i.e. IPv4 and ARP are aligned correctly. */
+ ptr_data_packet = (Uint8 *)&netmcb.rx_packet[2];
+
+ /* Check if a packet has been received? */
+ packet_size = netmcb.net_device.receive(&netmcb.net_device, ptr_data_packet);
+ if (packet_size == 0)
+ return;
+
+ /* Increment the number of packets received. */
+ net_stats.num_pkt_rxed++;
+
+ /* Extract the destination MAC Address from the received packet. */
+ memcpy ((void *)&dst_mac_address[0], (void *)ptr_data_packet, 6);
+
+ /* Extract the protocol from the received packet. This is at offset 12 from the
+ * start of the packet. We need to skip the destination and source mac address. */
+ protocol = *((Uint16 *)(ptr_data_packet + 12));
+ protocol = ntohs(protocol);
+
+ /* Process the received data.
+ * Check the destination mac address to determine if the packet is
+ * meant for us or not? We accept only directed UNICAST & BROADCAST
+ * packets */
+ if(((dst_mac_address[0] != 0xFF) || (dst_mac_address[1] != 0xFF) ||
+ (dst_mac_address[2] != 0xFF) || (dst_mac_address[3] != 0xFF) ||
+ (dst_mac_address[4] != 0xFF) || (dst_mac_address[5] != 0xFF)) &&
+ ((dst_mac_address[0] != netmcb.net_device.mac_address[0]) ||
+ (dst_mac_address[1] != netmcb.net_device.mac_address[1]) ||
+ (dst_mac_address[2] != netmcb.net_device.mac_address[2]) ||
+ (dst_mac_address[3] != netmcb.net_device.mac_address[3]) ||
+ (dst_mac_address[4] != netmcb.net_device.mac_address[4]) ||
+ (dst_mac_address[5] != netmcb.net_device.mac_address[5])))
+ {
+ /* Packet is not meant for us; ignore this packet. */
+ net_stats.rx_l2_dropped++;
+ return;
+ }
+
+ /* Move the pointer to the data packet and skip the ethernet header. */
+ ptr_data_packet = ptr_data_packet + sizeof(ETHHDR);
+
+ /* Deduct the Ethernet header size from the total number of bytes received. */
+ packet_size = packet_size - sizeof(ETHHDR);
+
+ /* Sanity Check: We need to ensure that the Layer3 headers are aligned on the
+ * 4 byte boundary at this stage. */
+ if (((Uint32)ptr_data_packet % 4) != 0)
+ mprintf ("ERROR: Misaligned Layer3 packet received 0x%p.\n", ptr_data_packet);
+
+ /* Demux on the protocol basis and pass it to the upper layer. */
+ switch (protocol)
+ {
+ case ETH_IP:
+ {
+ /* IPv4 Packet. */
+ if (ip_receive ((IPHDR *)ptr_data_packet, packet_size) < 0)
+ net_stats.rx_ip_dropped++;
+ break;
+ }
+ case ETH_ARP:
+ {
+ /* ARP Packet. */
+ if (arp_receive ((ARPHDR *)ptr_data_packet, packet_size) < 0)
+ net_stats.rx_arp_dropped++;
+ break;
+ }
+ default:
+ {
+ /* Unexpected packet. Drop the packet! */
+ net_stats.rx_l2_dropped++;
+ break;
+ }
+ }
+
+}
+
+/**
+ * @b Description
+ * @n
+ * The function reads/peeks data from the BLF net module.
+ *
+ * @param[in] ptr_buf
+ * This points to the data buffer which needs to be populated
+ * with the received data.
+ *
+ * @param[in] num_bytes
+ * This is the number of bytes of data which need to be read.
+ *
+ * @param[in] op
+ * Determines if a read or peek operation is performed
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+static Int32 net_read_peek (Uint8* ptr_buf, Uint32 num_bytes, Int32 op)
+{
+ Int32 num_bytes_read = 0;
+ Int32 total_num_bytes_read = 0;
+
+ /* Basic Validations: Ensure that the parameters are valid. */
+ if ((ptr_buf == NULL) || (num_bytes == 0))
+ return -1;
+
+ /* Execute the network scheduler; till there is no error. */
+ while (netmcb.error_flag == 0)
+ {
+
+ /* If the stream is empty and closed return */
+ if (stream_level() < 0) {
+ if (total_num_bytes_read > 0)
+ return (0);
+ else
+ return (-1);
+ }
+
+
+ /* Call the timer scheduler. */
+ timer_run();
+
+ /* Check if there is data in the STREAM? */
+ if (stream_isempty() == FALSE)
+ {
+ /* STREAM indicates there is some data. Lets read it first. */
+ if (op == NET_READ) {
+ num_bytes_read = stream_read (((ptr_buf + total_num_bytes_read)), num_bytes);
+ netmcb.fileOffset = netmcb.fileOffset + num_bytes_read;
+ } else
+ num_bytes_read = stream_peek (((ptr_buf + total_num_bytes_read)), num_bytes);
+
+ /* Keep track of the total amount of data read till now. */
+ total_num_bytes_read = total_num_bytes_read + num_bytes_read;
+
+ /* How much more data do we need to read? */
+ num_bytes = num_bytes - num_bytes_read;
+
+ /* Check if we have read all the data that was requested? */
+ if (num_bytes == 0)
+ break;
+
+ /* Control comes here implies that there was more data to be read into
+ * the buffer. We need it to have it available before we can exit the loop.
+ * So lets fall through! */
+ }
+ else
+ {
+ /* STREAM Module is empty. */
+ }
+
+ /* Check for and process any received packets */
+ proc_packet ();
+
+ }
+
+ /* Did we come out because of error or not? */
+ if (netmcb.error_flag == 0)
+ return 0;
+
+ /* Return error */
+ return -1;
+}
+
+
+/**
+ * @b Description
+ * @n
+ * The function reads data from the BLF net module.
+ *
+ * @param[in] ptr_buf
+ * This points to the data buffer which needs to be populated
+ * with the received data.
+ *
+ * @param[in] num_bytes
+ * This is the number of bytes of data which need to be read.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+static Int32 net_read (Uint8* ptr_buf, Uint32 num_bytes)
+{
+ return (net_read_peek (ptr_buf, num_bytes, NET_READ));
+}
+
+
+/**
+ * @b Description
+ * @n
+ * The function peeks data from the BLF net module.
+ *
+ * @param[in] ptr_buf
+ * This points to the data buffer which needs to be populated
+ * with the received data.
+ *
+ * @param[in] num_bytes
+ * This is the number of bytes of data which need to be read.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+static Int32 net_peek (Uint8* ptr_buf, Uint32 num_bytes)
+{
+ return (net_read_peek (ptr_buf, num_bytes, NET_PEEK));
+}
+
+/**
+ * @b Description
+ * @n
+ * This function moves the read pointer in the stream.
+ * Because this is a tftp boot, only forward reads
+ * are permitted.
+ *
+ * @param[in] loc
+ * This points to where the stream should be
+ *
+ * @param[in] from
+ * This describes parameter loc.
+ * 0 = from the start of the file
+ * 1 = from the current position
+ * 2 = from the end of the file
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+static Int32 net_seek (Int32 loc, Int32 from)
+{
+ Uint32 num_bytes;
+ Int32 num_bytes_read = 0;
+ Int32 total_num_bytes_read = 0;
+ Uint32 desiredPos;
+
+
+ /* This driver can only seek forward, and cannot seek from the end of the file */
+ if (from == 0)
+ desiredPos = loc;
+ else if (from == 1)
+ desiredPos = netmcb.fileOffset + loc;
+ else
+ return (-1);
+
+ /* Check if already in the correct position */
+ if (desiredPos == netmcb.fileOffset)
+ return (0);
+
+ /* Check for an invalid position */
+ if (desiredPos < netmcb.fileOffset)
+ return (-1);
+
+ /* Read data from the file until the file position matches the desired one */
+ num_bytes = desiredPos - netmcb.fileOffset;
+
+
+ /* Execute the network scheduler; till there is no error. */
+ while (netmcb.error_flag == 0)
+ {
+ /* Call the timer scheduler. */
+ timer_run();
+
+ /* Check if there is data in the STREAM? */
+ if (stream_isempty() == FALSE)
+ {
+ /* STREAM indicates there is some data. Lets read it first. */
+ num_bytes_read = stream_read (NULL, num_bytes);
+ netmcb.fileOffset = netmcb.fileOffset + num_bytes_read;
+
+ /* Keep track of the total amount of data read till now. */
+ total_num_bytes_read = total_num_bytes_read + num_bytes_read;
+
+ /* How much more data do we need to read? */
+ num_bytes = num_bytes - num_bytes_read;
+
+ /* Check if we have read all the data that was requested? */
+ if (num_bytes == 0)
+ break;
+
+ /* Control comes here implies that there was more data to be read into
+ * the buffer. We need it to have it available before we can exit the loop.
+ * So lets fall through! */
+ }
+ else
+ {
+ /* STREAM Module is empty. */
+ }
+
+ /* Check for and process any received packets */
+ proc_packet ();
+
+ }
+
+ /* Did we come out because of error or not? */
+ if (netmcb.error_flag == 0)
+ return 0;
+
+ /* Return error */
+ return -1;
+}
+
+/**
+ * @b Description
+ * @n
+ * This function returns how many bytes of data
+ * are currently available for immediate read.
+ *
+ * @retval
+ * The number of bytes available
+ */
+static Int32 net_query (void)
+{
+ return (stream_level());
+}
+
+
diff --git a/src/driver/eth/net.h b/src/driver/eth/net.h
--- /dev/null
+++ b/src/driver/eth/net.h
@@ -0,0 +1,293 @@
+/**
+ * @file net.h
+ *
+ * @brief
+ * The file has data structures and API definitions for the
+ * NET Boot Module
+ *
+ * \par
+ * NOTE:
+ * (C) Copyright 2008, Texas Instruments, Inc.
+ *
+ * \par
+ */
+#ifndef __NET_H__
+#define __NET_H__
+
+/**
+ * @brief This is the MAX MTU of the packet that can be received in
+ * the network module. This is configured to Ethernet standards at 1518
+ */
+#define NET_MAX_MTU 1518
+
+/**
+ * @brief This field indicates that the route is a network route
+ * and any packet destined to the specific network is directly accessible.
+ * Network Routes have the Next Hop address and the IP address to be the
+ * same.
+ *
+ * @sa
+ * ip_add_route
+ * @sa
+ * ip_del_route
+ */
+#define FLG_RT_NETWORK 0x1
+
+/**
+ * @brief This field indicates that the route is a default route.
+ * This is a last entry in the routing table and is an indication that
+ * the IP address to which the packet is destined is not directly accessible
+ * but needs to be sent through a gateway (i.e. Next Hop)
+ *
+ * @sa
+ * ip_add_route
+ * @sa
+ * ip_del_route
+ */
+#define FLG_RT_DEFAULT 0x2
+
+/**
+ * @brief
+ * The structure describes the Network Device Configuration.
+ *
+ * @details
+ * This structures stores configuration data which is used populated
+ * by the Device layer and passed to the network boot module.
+ */
+typedef struct NET_DRV_DEVICE
+{
+ /**
+ * @brief The physical port number to use
+ */
+ Uint32 port_num;
+
+ /**
+ * @brief This is the MAC Address which is populated by the device
+ * team. All packets sent by the NET module will use this MAC Address.
+ */
+ Uint8 mac_address[6];
+
+ /**
+ * @brief This is the IP Address associated with the networking device
+ * Device team can specify an IP address which will be used for all
+ * further communications. If BOOTP is enabled and this is 0; then the
+ * BOOTP protocol kicks in to determine an IP Address to be used.
+ */
+ IPN ip_address;
+
+ /**
+ * @brief This is the network mask. This is only required to be specified
+ * if the device team has specified an IP address. If BOOTP is being used
+ * this should be set to 0.
+ */
+ IPN net_mask;
+
+ /**
+ * @brief This is the TFTP Server IP Address which is to be used to
+ * download the file. This can be retreived from the BOOTP options but if
+ * BOOTP is not being used; the Server IP address can be specified here.
+ * This is ignored by the NET Boot Module if BOOTP is being used.
+ */
+ IPN server_ip;
+
+ /**
+ * @brief Set this to TRUE to override the server IP received from
+ * the bootp server and use the server_ip value above.
+ */
+ Bool use_bootp_server_ip;
+
+ /**
+ * @brief This is the File Name which is to be downloaded from the TFTP
+ * server. This can be retreived by decoding the BOOTP options but if BOOTP
+ * is not being used then the file name can be specified here. This is ignored
+ * by the NET Boot Module if BOOTP is being used.
+ */
+ Int8 file_name[64];
+
+ /**
+ * @brief Set this to TRUE to override the file_name received from the
+ * bootp server and use the file_name value above.
+ */
+ Bool use_bootp_file_name;
+
+ /**
+ * @brief This API is used to start the Ethernet controller. This is a call
+ * back function which is invoked by the NET boot module when it has been opened.
+ */
+ Int32 (*start) (struct NET_DRV_DEVICE* ptr_device);
+
+ /**
+ * @brief This API is used to stop the Ethernet controller. This is a call
+ * back function which is invoked by the NET boot module when it has been closed.
+ */
+ Int32 (*stop) (struct NET_DRV_DEVICE* ptr_device);
+
+ /**
+ * @brief The API is invoked by the NET module to send data to the driver
+ * for transmission.
+ */
+ Int32 (*send) (struct NET_DRV_DEVICE* ptr_device, Uint8* buffer, Int32 buffer_size);
+
+ /**
+ * @brief The API is invoked by the NET module to receive data from the
+ * driver. The driver populates the buffer passed with the received data
+ * and returns the number of bytes received. If there is no data which
+ * has been received then the function returns 0
+ */
+ Int32 (*receive) (struct NET_DRV_DEVICE* ptr_device, Uint8* buffer);
+}NET_DRV_DEVICE;
+
+/**
+ * @brief
+ * The structure describes the SOCKET structure
+ *
+ * @details
+ * This is a very primitive 'SOCKET' layer structure which is populated
+ * by the application layer and registered with the UDP module. This is
+ * the basic interface through which packets are sent/received by the
+ * application layer and NET boot module. The structure is exported as it
+ * allows even device developers to write their own UDP application.
+ */
+typedef struct SOCKET
+{
+ /**
+ * @brief This is the local port on which the application is waiting
+ * for packets to arrive.
+ */
+ Uint16 local_port;
+
+ /**
+ * @brief This is the remote port to which the application will send
+ * data.
+ */
+ Uint16 remote_port;
+
+ /**
+ * @brief The remote IP address to which the application will send data.
+ */
+ IPN remote_address;
+
+ /**
+ * @brief This is the application supplied call back function which is
+ * invoked by the UDP module when a packet is received on the specific
+ * port.
+ */
+ Int32 (*app_fn) (Int32 sock, Uint8* ptr_data, Int32 num_bytes);
+}SOCKET;
+
+/**
+ * @brief
+ * The structure describes the NET Stats
+ *
+ * @details
+ * The structure keeps track of the network boot module statistics. This
+ * is useful for debugging the network boot operations and drivers
+ */
+typedef struct NET_STATS
+{
+ /**
+ * @brief Total number of packets received.
+ */
+ Uint32 num_pkt_rxed;
+
+ /**
+ * @brief Total number of received packets dropped at the the layer2.
+ * The stat is incremented because of the following reasons:-
+ * - Incorrect L2 Protocol received (Only IPv4 and ARP are handled)
+ * - Dst MAC Address is not directed unicast or broadcast.
+ */
+ Uint32 rx_l2_dropped;
+
+ /**
+ * @brief Total number of received packets dropped at the the ARP layer.
+ * The stat is incremented because of the following reasons:-
+ * - Source MAC Address in the ARP packet is not meant for the stack.
+ * - Source IP Address in the ARP packet is not meant for the stack.
+ */
+ Uint32 rx_arp_dropped;
+
+ /**
+ * @brief Total number of received packets dropped at the the IPv4 layer.
+ * The stat is incremented because of the following reasons:-
+ * - Invalid IP Header (Version 4 is only supported)
+ * - Incorrect Destination IP Address
+ * - Invalid IP checksum.
+ */
+ Uint32 rx_ip_dropped;
+
+ /**
+ * @brief Total number of received packets dropped at the the UDP layer.
+ * The stat is incremented because of the following reasons:-
+ * - Invalid UDP checksum.
+ * - Packet length is below min UDP size.
+ * - No application is registered to handle the packet.
+ */
+ Uint32 rx_udp_dropped;
+
+ /**
+ * @brief Total number of packets transmitted.
+ */
+ Uint32 num_pkt_txed;
+}NET_STATS;
+
+#ifdef _BIG_ENDIAN
+ #define ntohs(a) (a)
+ #define htons(a) (a)
+ #define htonl(a) (a)
+ #define ntohl(a) (a)
+ #define READ32(x) (((Uint32)(*(Uint16 *)(x))<<16)|(Uint32)(*(Uint16 *)(((Uint8 *)(x))+2)))
+#else
+ #define htons(a) ( (((a)>>8)&0xff) + (((a)<<8)&0xff00) )
+ #define ntohs(a) htons(a)
+ #define htonl(a) ( (((a)>>24)&0xff) + (((a)>>8)&0xff00) + \
+ (((a)<<8)&0xff0000) + (((a)<<24)&0xff000000) )
+ #define ntohl(a) htonl(a)
+ #define READ32(x) ((Uint32)(*(Uint16 *)(x))|((Uint32)(*(Uint16 *)(((Uint8 *)(x))+2))<<16))
+#endif
+
+/**********************************************************************
+ **************************** Exported Data ***************************
+ **********************************************************************/
+
+/**
+ * @brief This is the NET Boot Module function table which has been
+ * exported. Device developers who wish to use the NET Boot Module are
+ * advised to populate the address of this into the BOOT Mode descriptor.
+ */
+extern BOOT_MODULE_FXN_TABLE net_boot_module;
+
+/**
+ * @brief This is the NET Boot Module statistics.
+ */
+extern NET_STATS net_stats;
+
+/**********************************************************************
+ **************************** Exported Functions **********************
+ **********************************************************************/
+
+/* IPv4 Route Management Functions: Use these API to manually add/delete routes
+ * to the NET Boot Module. If BOOTP is being used the routes are automatically
+ * added; but if BOOTP is not used; the device layer needs to ensure that
+ * routes are correctly configured */
+extern Int32 ip_add_route (Uint32 flag, IPN ip_address, IPN net_mask, IPN next_hop);
+extern void ip_del_route (Uint32 flag);
+
+/* Socket Functions: These are a very primitive stripped down versions of the
+ * BSD socket API which are available to device authors to write their own
+ * UDP application if one is so desired. BOOTP and TFTP are two applications
+ * provided as a part of the NET Boot Module which use these. */
+extern Int32 udp_sock_open (SOCKET* ptr_socket);
+extern Int32 udp_sock_send (Int32 sock, Uint8* ptr_app_data, Int32 num_bytes);
+extern void udp_sock_close(Int32 sock);
+
+/* TFTP Functions: This is a TFTP exported API available to device authors to
+ * be able to retrieve a file from the TFTP Server. */
+extern Int32 tftp_get_file (IPN server_ip, Int8* filename);
+
+/* NET Core Functions: This function is useful if the device authors are writing
+ * their own application; this is an ERROR Signal to the NET Boot Module that something
+ * catastrophic has happened and that the application is not enable to proceed further. */
+extern void net_set_error(void);
+
+
+#endif /* __NET_H__ */
diff --git a/src/driver/eth/net_orig.c b/src/driver/eth/net_orig.c
--- /dev/null
@@ -0,0 +1,471 @@
+/**
+ * @file net.c
+ *
+ * @brief
+ * The file implements the NET Boot Module.
+ *
+ * \par
+ * NOTE:
+ * (C) Copyright 2008, Texas Instruments, Inc.
+ *
+ * \par
+ */
+#include "types.h"
+#include "iblloc.h"
+#include "net.h"
+#include "netif.h"
+#include "timer.h"
+#include "stream.h"
+#include <string.h>
+
+
+/**********************************************************************
+ *************************** Local Functions **************************
+ **********************************************************************/
+static Int32 net_open (void* ptr_net_driver);
+static Int32 net_close(void);
+static Int32 net_read (Uint8* ptr_buf, Uint32 num_bytes);
+
+/**********************************************************************
+ *************************** GLOBAL Variables *************************
+ **********************************************************************/
+
+/**
+ * @brief This is the NETWORK Master control block which keeps track
+ * of all the Network boot module related information.
+ */
+NET_MCB netmcb;
+
+/**
+ * @brief This keeps track of the network statistics.
+ */
+NET_STATS net_stats;
+
+/**
+ * @brief This is the global Network Boot Module function table which
+ * implements the Boot Module Interface with the kernel.
+ */
+BOOT_MODULE_FXN_TABLE net_boot_module =
+{
+ net_open, /* Open API */
+ net_close, /* Close API */
+ net_read, /* Read API */
+ NULL, /* Write API (NULL: This is not interactive) */
+ net_peek, /* Peek API (TBA) */
+};
+
+/**********************************************************************
+ **************************** NET Functions ***************************
+ **********************************************************************/
+
+/**
+ * @b Description
+ * @n
+ * The function is used to allocate a packet for transmission. This
+ * is called by the higher layer protocols when a packet needs to
+ * be transmitted. The function ensures there is sufficient space
+ * allocated at the beginning of the packet for the Ethernet header.
+ * Since the pointer returned by this API is used to store L3/L4 headers
+ * it always returns a 4 byte aligned buffer data pointer.
+ *
+ * @param[in] packet_len
+ * Length of the packet being transmitted.
+ *
+ * @retval
+ * Success - Pointer to the L3 header.
+ * @retval
+ * Error - NULL
+ */
+Uint8* net_alloc_tx_packet(Int32 packet_len)
+{
+ /* Sanity Check: Ensure the packet being allocated does not exceed the
+ * max buffer size that we have. */
+ if (packet_len > NET_MAX_MTU)
+ return NULL;
+
+ /* Sanity Check: Ensure that the packet is available for use. */
+ if (netmcb.txuse == 1)
+ return NULL;
+
+ /* Mark the packet as being in use. */
+ netmcb.txuse = 1;
+
+ /* Reset the contents of the packet */
+ memset ((void *)&netmcb.tx_packet[0], 0, sizeof(netmcb.tx_packet));
+
+ /* Reserve some space at the head of the packet for the Ethernet headers. */
+ return &netmcb.tx_packet[16];
+}
+
+/**
+ * @b Description
+ * @n
+ * The function is called to free up a previously allocated transmit
+ * packet.
+ *
+ * @param[in] ptr
+ * Pointer to the packet being cleaned.
+ *
+ * @retval
+ * Not Applicable.
+ */
+void net_free_tx_packet (Uint8* ptr)
+{
+ /* Sanity Checks: Ensure that the packet being cleaned is the same as the one
+ * which was allocated. */
+ if (ptr != &netmcb.tx_packet[16])
+ mprintf ("ERROR: NET Free Transmit packet detected corruption\n");
+
+ /* Sanity Checks: Ensure that there is no double free. */
+ if (netmcb.txuse == 0)
+ mprintf ("ERROR: NET Free Transmit packet detected double free\n");
+
+ /* Mark the transmit packet as free and available. */
+ netmcb.txuse = 0;
+ return;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function is used to append an Ethernet header on the packet.
+ * The source MAC Address in the packet is always the one which was
+ * registered by the driver. Higher layer protocol authors need to
+ * use the 'net_alloc_tx_packet' API to get a transmit buffer.
+ *
+ * @param[in] ptr_l3_hdr
+ * This is the pointer to the layer3 header.
+ * @param[in] dst_mac
+ * The destination MAC address
+ * @param[in] protocol
+ * The layer3 protocol version (passed in host order)
+ *
+ * @retval
+ * Success - Pointer to the start of the Ethernet header i.e. L2.
+ * @retval
+ * Error - NULL
+ */
+ETHHDR* net_create_eth_header (Uint8* ptr_l3_hdr, Uint8* dst_mac, Uint16 protocol)
+{
+ Int32 rsvd_space;
+
+ /* Compute the reserved space. */
+ rsvd_space = (Int32)ptr_l3_hdr - (Int32)&netmcb.tx_packet[0];
+
+ /* Ensure there is sufficient space to add the header. We dont want memory corruption
+ * to occur here. */
+ if ((rsvd_space < 0) || (rsvd_space > NET_MAX_MTU) || (rsvd_space < ETHHDR_SIZE))
+ return NULL;
+
+ /* Convert the protocol to network order. */
+ protocol = ntohs(protocol);
+
+ /* Start adding the Ethernet header.
+ * Move back the data pointer to account for the protocol. */
+ ptr_l3_hdr = ptr_l3_hdr - 2;
+ memcpy ((void *)ptr_l3_hdr, (void *)&protocol, sizeof(Uint16));
+
+ /* Move back the data pointer to account for the source MAC. */
+ ptr_l3_hdr = ptr_l3_hdr - 6;
+ memcpy ((void *)ptr_l3_hdr, (void *)&netmcb.net_device.mac_address[0], 6);
+
+ /* Move back the data pointer to account for the destination MAC. */
+ ptr_l3_hdr = ptr_l3_hdr - 6;
+ memcpy ((void *)ptr_l3_hdr, (void *)dst_mac, 6);
+
+ /* Return the pointer to the start of the Ethernet header. */
+ return (ETHHDR *)ptr_l3_hdr;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function is used to send a packet to the driver.
+ *
+ * @param[in] ptr_l2_hdr
+ * This is the pointer to the L2 header of the packet to be transmitted.
+ * All the headers need to be populated by the time comes to this API.
+ * @param[in] length
+ * Length of the packet being transmitted. This include the L2 header
+ * information.
+ *
+ * @retval
+ * Not Applicable.
+ */
+void net_send_packet (ETHHDR* ptr_l2_hdr, Uint16 length)
+{
+ /* Sanity Check: This is called after the LAYER3 and ETHER headers
+ * have been appended to the packet. Here we ensure that the layer3 header
+ * is aligned on the 4 byte boundary. */
+ if ( (((Uint32)ptr_l2_hdr+ETHHDR_SIZE) % 4) != 0)
+ mprintf ("ERROR: Misaligned Layer3 packet transmitted 0x%p.\n", ptr_l2_hdr);
+
+ /* Increment the stats. */
+ net_stats.num_pkt_txed++;
+
+ /* Pass the packet to the platform API for transmission. */
+ netmcb.net_device.send (&netmcb.net_device, (Uint8 *)ptr_l2_hdr, (Int32)length);
+ return;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function is called from any entity inside the NETWORK Boot Module
+ * to indicate that there has been a FATAL error and that the boot module
+ * processing needs to be aborted.
+ *
+ * @retval
+ * Not Applicable.
+ */
+void net_set_error (void)
+{
+ /* Set the Error Flag; */
+ netmcb.error_flag = 1;
+ return;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function opens the BLF NET Module. The function initializes
+ * the various internal components of the NET module and also
+ * initializes the peripheral driver controller
+ *
+ * @param[in] ptr_driver
+ * This is the pointer to the driver block which was passed to
+ * the BLF through the BOOT Mode descriptor. For the NET boot
+ * module this points to the NET_DRV_DEVICE object.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+static Int32 net_open (void* ptr_driver)
+{
+ NET_DRV_DEVICE* ptr_net_driver;
+
+ /* Get the pointer to the net driver. */
+ ptr_net_driver = (NET_DRV_DEVICE*)ptr_driver;
+
+ /* Basic Validation: Ensure there is a valid driver block being passed. */
+ if (ptr_net_driver == NULL)
+ return -1;
+
+ /* Basic Validation: Ensure that all the required API have been provided */
+ if ((ptr_net_driver->start == NULL) || (ptr_net_driver->send == NULL) ||
+ (ptr_net_driver->receive == NULL) || (ptr_net_driver->stop == NULL))
+ {
+ /* Error: Required API was not specified. */
+ return -1;
+ }
+
+ /* Initialize the NET MCB. */
+ memset (&netmcb, 0, sizeof(NET_MCB));
+
+ /* Initialize the Network Statistics. */
+ memset (&net_stats, 0, sizeof(NET_STATS));
+
+ /* Copy the driver information into the NET MCB */
+ memcpy ((void *)&netmcb.net_device, (void *)ptr_net_driver, sizeof(NET_DRV_DEVICE));
+
+ /* Initialize the ARP Module. */
+ arp_init ();
+
+ /* Initialize the IP Module. */
+ ip_init ();
+
+ /* Initialize the UDP Module. */
+ udp_init ();
+
+ /* Start the networking device */
+ if (netmcb.net_device.start(&netmcb.net_device) < 0)
+ return -1;
+
+ /* Determine if we need to execute BOOTP or not? */
+ if (netmcb.net_device.ip_address != 0)
+ {
+ /* IP Address was supplied by the device team. There is no need
+ * to execute the BOOTP protocol; manually create the network route also. */
+ ip_add_route (FLG_RT_NETWORK, netmcb.net_device.ip_address, netmcb.net_device.net_mask, 0);
+
+#ifdef INCLUDE_BLF_NET_TFTP
+ /* Lets download the file from the TFTP Server. */
+ tftp_get_file (netmcb.net_device.server_ip, netmcb.net_device.file_name);
+#endif /* INCLUDE_BLF_NET_TFTP */
+ }
+ else
+ {
+#ifdef INCLUDE_BLF_NET_BOOTP
+ /* No IP Address was supplied we need to execute the BOOTP protocol. */
+ bootp_init ();
+#endif
+ }
+
+ /* The network module is UP and running.. */
+ return 0;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function closes the BLF NET Module.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+static Int32 net_close (void)
+{
+ return 0;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function reads data from the BLF net module.
+ *
+ * @param[in] ptr_buf
+ * This points to the data buffer which needs to be populated
+ * with the received data.
+ *
+ * @param[in] num_bytes
+ * This is the number of bytes of data which need to be read.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+static Int32 net_read (Uint8* ptr_buf, Uint32 num_bytes)
+{
+ Int32 packet_size;
+ Uint16 protocol;
+ Uint8 dst_mac_address[6];
+ Uint8* ptr_data_packet;
+ Int32 num_bytes_read = 0;
+ Int32 total_num_bytes_read = 0;
+
+ /* Basic Validations: Ensure that the parameters are valid. */
+ if ((ptr_buf == NULL) || (num_bytes == 0))
+ return -1;
+
+ /* Execute the network scheduler; till there is no error. */
+ while (netmcb.error_flag == 0)
+ {
+ /* Call the timer scheduler. */
+ timer_run();
+
+ /* Check if there is data in the STREAM? */
+ if (stream_isempty() == FALSE)
+ {
+ /* STREAM indicates there is some data. Lets read it first. */
+ num_bytes_read = stream_read (((ptr_buf + total_num_bytes_read)), num_bytes);
+
+ /* Keep track of the total amount of data read till now. */
+ total_num_bytes_read = total_num_bytes_read + num_bytes_read;
+
+ /* How much more data do we need to read? */
+ num_bytes = num_bytes - num_bytes_read;
+
+ /* Check if we have read all the data that was requested? */
+ if (num_bytes == 0)
+ break;
+
+ /* Control comes here implies that there was more data to be read into
+ * the buffer. We need it to have it available before we can exit the loop.
+ * So lets fall through! */
+ }
+ else
+ {
+ /* STREAM Module is empty. */
+ }
+
+ /* Initialize the pointer in the received packet is stored.
+ * This is misaligned on the 2 byte boundary as this will ensure that
+ * the layer3 headers i.e. IPv4 and ARP are aligned correctly. */
+ ptr_data_packet = (Uint8 *)&netmcb.rx_packet[2];
+
+ /* Check if a packet has been received? */
+ packet_size = netmcb.net_device.receive(&netmcb.net_device, ptr_data_packet);
+ if (packet_size == 0)
+ continue;
+
+ /* Increment the number of packets received. */
+ net_stats.num_pkt_rxed++;
+
+ /* Extract the destination MAC Address from the received packet. */
+ memcpy ((void *)&dst_mac_address[0], (void *)ptr_data_packet, 6);
+
+ /* Extract the protocol from the received packet. This is at offset 12 from the
+ * start of the packet. We need to skip the destination and source mac address. */
+ protocol = *((Uint16 *)(ptr_data_packet + 12));
+ protocol = ntohs(protocol);
+
+ /* Process the received data.
+ * Check the destination mac address to determine if the packet is
+ * meant for us or not? We accept only directed UNICAST & BROADCAST
+ * packets */
+ if(((dst_mac_address[0] != 0xFF) || (dst_mac_address[1] != 0xFF) ||
+ (dst_mac_address[2] != 0xFF) || (dst_mac_address[3] != 0xFF) ||
+ (dst_mac_address[4] != 0xFF) || (dst_mac_address[5] != 0xFF)) &&
+ ((dst_mac_address[0] != netmcb.net_device.mac_address[0]) ||
+ (dst_mac_address[1] != netmcb.net_device.mac_address[1]) ||
+ (dst_mac_address[2] != netmcb.net_device.mac_address[2]) ||
+ (dst_mac_address[3] != netmcb.net_device.mac_address[3]) ||
+ (dst_mac_address[4] != netmcb.net_device.mac_address[4]) ||
+ (dst_mac_address[5] != netmcb.net_device.mac_address[5])))
+ {
+ /* Packet is not meant for us; ignore this packet. */
+ net_stats.rx_l2_dropped++;
+ continue;
+ }
+
+ /* Move the pointer to the data packet and skip the ethernet header. */
+ ptr_data_packet = ptr_data_packet + sizeof(ETHHDR);
+
+ /* Deduct the Ethernet header size from the total number of bytes received. */
+ packet_size = packet_size - sizeof(ETHHDR);
+
+ /* Sanity Check: We need to ensure that the Layer3 headers are aligned on the
+ * 4 byte boundary at this stage. */
+ if (((Uint32)ptr_data_packet % 4) != 0)
+ mprintf ("ERROR: Misaligned Layer3 packet received 0x%p.\n", ptr_data_packet);
+
+ /* Demux on the protocol basis and pass it to the upper layer. */
+ switch (protocol)
+ {
+ case ETH_IP:
+ {
+ /* IPv4 Packet. */
+ if (ip_receive ((IPHDR *)ptr_data_packet, packet_size) < 0)
+ net_stats.rx_ip_dropped++;
+ break;
+ }
+ case ETH_ARP:
+ {
+ /* ARP Packet. */
+ if (arp_receive ((ARPHDR *)ptr_data_packet, packet_size) < 0)
+ net_stats.rx_arp_dropped++;
+ break;
+ }
+ default:
+ {
+ /* Unexpected packet. Drop the packet! */
+ net_stats.rx_l2_dropped++;
+ break;
+ }
+ }
+ }
+
+ /* Did we come out because of error or not? */
+ if (netmcb.error_flag == 0)
+ return 0;
+
+ /* Return error */
+ return -1;
+}
+
+
diff --git a/src/driver/eth/netif.h b/src/driver/eth/netif.h
--- /dev/null
+++ b/src/driver/eth/netif.h
@@ -0,0 +1,390 @@
+/**
+ * @file netif.h
+ *
+ * @brief
+ * Internal header file used only by the NET Boot Module
+ * This header file is not accessible by the DEVICE layers.
+ *
+ * \par
+ * NOTE:
+ * (C) Copyright 2008, Texas Instruments, Inc.
+ *
+ * \par
+ */
+
+#ifndef __NETIF_H__
+#define __NETIF_H__
+
+/**
+ * @brief This is the protocol identification field in the Ethernet
+ * header which identifies the packet as an IPv4 packet.
+ */
+#define ETH_IP 0x800
+
+/**
+ * @brief This is the protocol identification field in the Ethernet
+ * header which identifies the packet as an IPv4 packet.
+ */
+#define ETH_ARP 0x806
+
+/**
+ * @brief This is the protocol identification field in the IPv4 header
+ * which identifies the packet as an ICMP packet.
+ */
+#define IPPROTO_ICMP 1
+
+/**
+ * @brief This is the protocol identification field in the IPv4 header
+ * which identifies the packet as a UDP packet.
+ */
+#define IPPROTO_UDP 17
+
+/**
+ * @brief This is the ICMP Echo request type field which is present in the
+ * ICMP header. This is the only type handled in the ICMP Network Boot Module.
+ */
+#define ICMP_ECHO_REQUEST_TYPE 8
+
+/**
+ * @brief This is the ICMP Echo reply type field which is present in the
+ * ICMP header. This is the reply packet generated in response to the REQ
+ * packet.
+ */
+#define ICMP_ECHO_REPLY_TYPE 0
+
+/**
+ * @brief This is the BOOTP SERVER port to which BOOTP requests are sent
+ * by the BOOTP client module.
+ */
+#define BOOTP_SERVER_PORT 67
+
+/**
+ * @brief This is the BOOTP Local port using which the BOOTP client will
+ * send requests.
+ */
+#define BOOTP_CLIENT_PORT 68
+
+/**
+ * @brief This is the BOOTP OP definition for a BOOTP request
+ */
+#define BOOTP_OP_REQUEST 1
+
+/**
+ * @brief This is the BOOTP OP definition for a BOOTP reply
+ */
+#define BOOTP_OP_REPLY 2
+
+/**
+ * @brief This is the BOOTP HTYPE definition for Ethernet.
+ */
+#define BOOTP_HTYPE_ETHERNET 1
+
+/**
+ * @brief This is the BOOTP Seed Timeout (in milliseconds) which is being used.
+ */
+#define BOOTP_SEED_TIMEOUT 4000
+
+/**
+ * @brief This is the max. number of retries for which the BOOTP client
+ * will wait.
+ */
+#define BOOTP_MAX_RETRIES 5
+
+/**
+ * @brief This is the default BOOTP subnet mask which is used if there
+ * is none present in the BOOTP options.
+ */
+#define BOOTP_DEFAULT_MASK htonl(0xFFFFFF00)
+
+/**
+ * @brief This is the well defined TFTP Server port.
+ */
+#define TFTP_SERVER_PORT 69
+
+/**
+ * @brief This is the maximum TFTP data size that is sent out.
+ */
+#define TFTP_DATA_SIZE 512
+
+/**
+ * @brief This is the TFTP opcode for READ
+ */
+#define TFTP_OPCODE_RRQ 1
+
+/**
+ * @brief This is the TFTP opcode for DATA
+ */
+#define TFTP_OPCODE_DATA 3
+
+/**
+ * @brief This is the TFTP opcode for ACK
+ */
+#define TFTP_OPCODE_ACK 4
+
+/**
+ * @brief This is the TFTP opcode for ERROR
+ */
+#define TFTP_OPCODE_ERROR 5
+
+/**
+ * @brief This is the TFTP timeout (in milliseconds) used
+ * to send out periodic READ Requests if there is no response
+ * detected.
+ */
+#define TFTP_TIMEOUT 1000
+
+/**
+ * @brief This is the TFTP Server timeout (in milliseconds)
+ * to detect the condition where the TFTP Server goes away in
+ * the middle of the download.
+ */
+#define TFTP_SERVER_TIMEOUT 60000
+
+/**
+ * @brief This is the maximum number of retransmits allowed
+ * in the TFTP Client after which an error is indicated.
+ */
+#define MAX_TFTP_RETRANSMITS 5
+
+/**
+ * @brief This is the the ARP timeout (in milliseconds) used
+ * to resend ARP requests.
+ */
+#define ARP_TIMEOUT 1000
+
+/***********************************************************************
+ ****************** STANDARD NETWORK HEADER DEFINITIONS ****************
+ ***********************************************************************/
+
+#define ETHHDR_SIZE 14
+typedef struct ETHHDR
+{
+ Uint8 DstMac[6];
+ Uint8 SrcMac[6];
+ Uint16 Type;
+} ETHHDR;
+
+#define IPHDR_SIZE 20
+typedef struct IPHDR
+{
+ Uint8 VerLen;
+ Uint8 Tos;
+ Uint16 TotalLen;
+ Uint16 Id;
+ Uint16 FlagOff;
+ Uint8 Ttl;
+ Uint8 Protocol;
+ Uint16 Checksum;
+ Uint32 IPSrc;
+ Uint32 IPDst;
+ Uint8 Options[1];
+} IPHDR;
+
+#define ARPHDR_SIZE 28
+typedef struct ARPHDR
+{
+ Uint16 HardType;
+ Uint16 ProtocolType;
+ Uint8 HardSize;
+ Uint8 ProtocolSize;
+ Uint16 Op;
+ Uint8 SrcAddr[6];
+ Uint8 IPSrc[4];
+ Uint8 DstAddr[6];
+ Uint8 IPDst[4];
+} ARPHDR;
+
+typedef struct PSEUDOHDR
+{
+ IPN IPSrc;
+ IPN IPDst;
+ Uint16 Length;
+ Uint8 Null;
+ Uint8 Protocol;
+} PSEUDOHDR;
+
+#define UDPHDR_SIZE 8
+typedef struct UDPHDR
+{
+ Uint16 SrcPort;
+ Uint16 DstPort;
+ Uint16 Length;
+ Uint16 UDPChecksum;
+}UDPHDR;
+
+#define ICMPHDR_SIZE 4
+typedef struct ICMPHDR
+{
+ Uint8 Type;
+ Uint8 Code;
+ Uint16 Checksum;
+ Uint8 Data[1];
+}ICMPHDR;
+
+typedef struct BOOTPHDR
+{
+ Uint8 op;
+ Uint8 htype;
+ Uint8 hlen;
+ Uint8 hops;
+ Uint32 xid;
+ Uint16 secs;
+ Uint16 unused;
+ Uint32 ciaddr;
+ Uint32 yiaddr;
+ Uint32 siaddr;
+ Uint32 giaddr;
+ Uint8 chaddr[16];
+ Uint8 sname[64];
+ Uint8 file[128];
+ Uint8 options[64];
+} BOOTPHDR;
+
+#define TFTPHEADER_SIZE 4
+typedef struct TFTPHDR
+{
+ Uint16 opcode;
+ Uint16 block;
+ Uint8 data[1];
+}TFTPHDR;
+
+/**
+ * @brief
+ * The structure describes the ROUTE Entry.
+ *
+ * @details
+ * This structures describes the routing entry. This is used by the network
+ * boot module to determine the next hop address. The next hop address might
+ * not be the same as the destination IP address if there exists a default
+ * gateway.
+ */
+typedef struct RT_ENTRY
+{
+ /**
+ * @brief Flags which describe the routing entry.
+ */
+ Uint32 flags;
+
+ /**
+ * @brief IP Address associated with the route
+ */
+ IPN ip_addr;
+
+ /**
+ * @brief Network Mask associated with the route
+ */
+ IPN net_mask;
+
+ /**
+ * @brief Network Address associated with the route
+ */
+ IPN net_addr;
+
+ /**
+ * @brief Next Hop Address associated with the route
+ */
+ IPN next_hop;
+}RT_ENTRY;
+
+/**
+ * @brief
+ * The structure describes the NET Master Control Block.
+ *
+ * @details
+ * This is an *internal* structure used by the NET Core Module for storing
+ * information. This structure should not be used or be accessed by the
+ * platform team.
+ */
+typedef struct NET_MCB
+{
+ /**
+ * @brief This is the network device which is attached to the network
+ * boot module.
+ */
+ NET_DRV_DEVICE net_device;
+
+ /**
+ * @brief This is the receive packet which is passed to the driver
+ * when the Net boot module invokes the receive API. The driver copies
+ * data from its internal buffers to this buffer. The network boot module
+ * only operates on this buffer.
+ */
+ Uint8 rx_packet[NET_MAX_MTU];
+
+ /**
+ * @brief This is the IP ID field which is globally incremented on
+ * every packet transmitted from the Network boot module.
+ */
+ Uint16 ipID;
+
+ /**
+ * @brief This indicates the status of the transmission buffer and whether
+ * it is available to be used or not. This is manipulated by the alloc_tx
+ * and free_tx routines to ensure there is no corruption with respect to the
+ * internal buffers.
+ */
+ Uint32 txuse;
+
+ /**
+ * @brief This flag indicates if there was an Error detected in the
+ * NET Boot Module or not? This is then used to break out of the NET Boot
+ * Module Scheduler. If there is no error detected the flag is set to 0.
+ */
+ Int32 error_flag;
+
+ /**
+ * @brief This is the transmit packet which is used by the network
+ * module to send a packet to the driver.
+ */
+ Uint8 tx_packet[NET_MAX_MTU];
+
+
+ /**
+ * @brief This tracks the current read byte in the file
+ */
+ Uint32 fileOffset;
+
+
+}NET_MCB;
+
+/**********************************************************************
+ **************************** Extern Data *****************************
+ **********************************************************************/
+extern NET_MCB netmcb;
+
+/**********************************************************************
+ **************************** Exported API ****************************
+ **********************************************************************/
+extern void net_init (void);
+extern Uint8* net_alloc_tx_packet(Int32 packet_len);
+extern void net_free_tx_packet (Uint8* ptr);
+extern ETHHDR* net_create_eth_header (Uint8* ptr_l3_hdr, Uint8* dst_mac, Uint16 protocol);
+extern void net_send_packet (ETHHDR* ptr_l2_hdr, Uint16 length);
+
+/* ARP Module exported API. */
+extern void arp_init (void);
+extern Int32 arp_receive (ARPHDR* ptr_arphdr, Int32 num_bytes);
+extern void arp_resolve (IPN dst_ip, IPHDR* ptr_iphdr, Uint16 l3_pkt_size);
+
+/* IPv4 Module exported API. */
+extern void ip_init (void);
+extern Int32 ip_receive (IPHDR* ptr_iphdr, Int32 num_bytes);
+extern void ip_send (IPHDR* ptr_iphdr, Uint16 size);
+extern RT_ENTRY* ip_lookup_route (IPN ip_address);
+
+/* UDP Module exported API. */
+extern void udp_init (void);
+extern Int32 udp_receive (IPHDR* ptr_iphdr);
+
+/* BOOTP Module exported API */
+#ifdef INCLUDE_BLF_NET_BOOTP
+extern void bootp_init (void);
+#endif
+
+#ifdef INCLUDE_BLF_NET_ICMP
+extern void icmp_receive (IPHDR* ptr_iphdr);
+#endif
+
+#endif /* __NETIF_H__ */
+
+
diff --git a/src/driver/eth/tftp.c b/src/driver/eth/tftp.c
--- /dev/null
+++ b/src/driver/eth/tftp.c
@@ -0,0 +1,511 @@
+/**
+ * @file tftp.c
+ *
+ * @brief
+ * The file implements the NET Module TFTP functionality.
+ *
+ * \par
+ * NOTE:
+ * (C) Copyright 2008, Texas Instruments, Inc.
+ *
+ * \par
+ */
+#include "types.h"
+#include "iblloc.h"
+#include "net.h"
+#include "netif.h"
+#include "timer.h"
+#include "stream.h"
+#include <string.h>
+
+
+/**********************************************************************
+ *************************** LOCAL Structures *************************
+ **********************************************************************/
+
+/**
+ * @brief
+ * The structure describes the TFTP State
+ *
+ * @details
+ * The TFTP client can be in one of the following states which are
+ * described in this structure.
+ */
+typedef enum TFTP_STATE
+{
+ /**
+ * @brief This is the initial state of the TFTP client during startup
+ * In this state the TFTP client has sent out the READ Request and has
+ * not yet received a data packet in acknowledgment.
+ */
+ READ_REQUEST = 0x1,
+
+ /**
+ * @brief This is the data receive state of the TFTP client in which
+ * the TFTP client is receiving data packets from the TFTP server.
+ */
+ DATA_RECEIVE
+}TFTP_STATE;
+
+/**
+ * @brief
+ * The structure describes the TFTP Master Control Block.
+ *
+ * @details
+ * The TFTP Master control block stores information used by the
+ * TFTP module.
+ */
+typedef struct TFTP_MCB
+{
+ /**
+ * @brief This describes the state of the TFTP client.
+ */
+ TFTP_STATE state;
+
+ /**
+ * @brief This is the IP Address of the server from where the file
+ * is downloaded.
+ */
+ IPN server_ip;
+
+ /**
+ * @brief This is the TFTP socket which is used to communicate
+ * with the UDP module.
+ */
+ Int32 sock;
+
+ /**
+ * @brief This is the TFTP Timer handle which is used to handle
+ * retransmissions of the READ REQUEST.
+ */
+ Int32 timer;
+
+ /**
+ * @brief This is the name of the file which is being downloaded.
+ * File Names are typically exchanged through the BOOTP protocol
+ * where the max file name length is 64.
+ */
+ Uint8 filename[64];
+
+ /**
+ * @brief This is the block number we expect.
+ */
+ Uint16 block_num;
+
+ /**
+ * @brief This is a generic buffer used by the TFTP module,
+ */
+ Uint8 buffer[TFTP_DATA_SIZE + TFTPHEADER_SIZE];
+
+ /**
+ * @brief Number of retransmission done.
+ */
+ Uint32 num_retransmits;
+}TFTP_MCB;
+
+/**********************************************************************
+ *************************** GLOBAL Variables *************************
+ **********************************************************************/
+
+/**
+ * @brief This is the global master control block for the TFTP
+ * module and keeps track of all the information regarding TFTP.
+ */
+TFTP_MCB tftpmcb;
+
+/**********************************************************************
+ **************************** TFTP Functions **************************
+ **********************************************************************/
+
+/**
+ * @b Description
+ * @n
+ * The function cleans up the TFTP Client. This can be called
+ * on an ERROR or SUCCESSFUL exit.
+ *
+ * @retval
+ * Not Applicable.
+ */
+static void tftp_cleanup (void)
+{
+ /* Close any open timers. */
+ timer_delete (tftpmcb.timer);
+ tftpmcb.timer = -1;
+
+ /* Close the UDP Sockets. */
+ udp_sock_close (tftpmcb.sock);
+
+ /* Close the STREAM module */
+ stream_close ();
+ return;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function creates the TFTP read request and populates it
+ * in the internal TFTP buffer.
+ *
+ * @retval
+ * Size of the TFTP Read Request.
+ */
+static Int32 tftp_create_read_req (Uint8* filename)
+{
+ Uint16* ptr_op;
+ Int32 index = 0;
+
+ /* Create the Read Request: Populate the Request op type */
+ ptr_op = (Uint16 *)&tftpmcb.buffer[0];
+ *ptr_op = htons(TFTP_OPCODE_RRQ);
+
+ /* Copy the file name */
+ index = 0;
+ while (filename[index] != 0)
+ {
+ tftpmcb.buffer[index + 2] = filename[index];
+ index++;
+ }
+
+ /* Null Terminate the file name. */
+ tftpmcb.buffer[index + 2] = 0;
+ index = index + 3;
+
+ /* Copy the transfer mode. */
+ tftpmcb.buffer[index++] = (Uint8)'o';
+ tftpmcb.buffer[index++] = (Uint8)'c';
+ tftpmcb.buffer[index++] = (Uint8)'t';
+ tftpmcb.buffer[index++] = (Uint8)'e';
+ tftpmcb.buffer[index++] = (Uint8)'t';
+ tftpmcb.buffer[index++] = (Uint8)0;
+
+ /* Return the size of the read request */
+ return index;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function is used to send an ACK back to TFTP Server.
+ *
+ * @retval
+ * Not Applicable
+ */
+static void tftp_send_ack(void)
+{
+ TFTPHDR* ptr_tftphdr;
+
+ /* Initialize the data buffer. */
+ memset ((void *)&tftpmcb.buffer[0], 0, TFTP_DATA_SIZE + TFTPHEADER_SIZE);
+
+ /* Create an ACK packet which is to be sent out. Get the pointer to the
+ * TFTP Header. */
+ ptr_tftphdr = (TFTPHDR *)&tftpmcb.buffer[0];
+ ptr_tftphdr->opcode = htons (TFTP_OPCODE_ACK);
+ ptr_tftphdr->block = htons (tftpmcb.block_num);
+
+ /* The packet has been populated; send it to the server; this transfer is now done
+ * over the data socket. */
+ udp_sock_send (tftpmcb.sock, (Uint8 *)ptr_tftphdr, TFTPHEADER_SIZE);
+
+ /* Increment the block number. */
+ tftpmcb.block_num++;
+ return;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function is the timer expiration for TFTP.
+ *
+ * @retval
+ * Not Applicable
+ */
+static void tftp_timer_expiry (void)
+{
+ Int32 len;
+
+ /* Determine the state of the TFTP. */
+ if (tftpmcb.state == READ_REQUEST)
+ {
+ /* We were sending out READ Request and have not received a response
+ * Increment the number of retransmissions which have been done. */
+ tftpmcb.num_retransmits++;
+
+ /* Check if we have exceeded the max allowed? */
+ if (tftpmcb.num_retransmits > MAX_TFTP_RETRANSMITS)
+ {
+ /* FATAL Error: We need to close the TFTP Client and signal Error to the NET Boot Module. */
+ mprintf ("Error: TFTP READ REQ Retransmissions have exceeded\n");
+ tftp_cleanup ();
+ net_set_error();
+ return;
+ }
+
+ /* Create the TFTP Read Request */
+ len = tftp_create_read_req (&tftpmcb.filename[0]);
+
+ /* Send out the READ Request again. */
+ udp_sock_send (tftpmcb.sock, (Uint8 *)&tftpmcb.buffer[0], len);
+ }
+ else
+ {
+ /* We were receiving data from the TFTP Server and there was a timeout. This can
+ * happen only if we have not received any data from the TFTP server. */
+ mprintf ("Error: TFTP server is down; no packet received.\n");
+ tftp_cleanup();
+ net_set_error();
+ return;
+ }
+ return;
+}
+
+/**
+ * @b Description
+ * @n
+ * This is a call back function registered with the UDP module to
+ * be invoked when a TFTP packet is received.
+ *
+ * @param[in] sock
+ * This is the socket handle on which packet was received.
+ * @param[in] ptr_data
+ * This is the pointer to the TFTP data payload.
+ * @param[in] num_bytes
+ * This is the number of bytes of TFTP data received.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+static Int32 tftp_receive (Int32 sock, Uint8* ptr_data, Int32 num_bytes)
+{
+ TFTPHDR* ptr_tftphdr;
+ UDPHDR* ptr_udphdr;
+ Uint16 src_port;
+ SOCKET socket;
+
+ /* Get the pointer to the TFTP Header. */
+ ptr_tftphdr = (TFTPHDR *)ptr_data;
+
+ /* Process the received packet depending on the type of packet received */
+ switch (ntohs(ptr_tftphdr->opcode))
+ {
+ case TFTP_OPCODE_DATA:
+ {
+ /* Is this the first data packet we have received? */
+ if (tftpmcb.state == READ_REQUEST)
+ {
+ /* YES. In this case the socket on which the request was sent has completed
+ * its job. Lets shut it down and open another one for the data transfers. */
+ udp_sock_close (sock);
+
+ /* We need to get the source port from where the data was received.
+ * This information is present in the UDP layer. This is required to
+ * open the data socket. */
+ ptr_udphdr = (UDPHDR *)(ptr_data - sizeof(UDPHDR));
+ src_port = ntohs(ptr_udphdr->SrcPort);
+
+ /* Populate the socket structure and register this with the UDP module. */
+ socket.local_port = 1234;
+ socket.remote_port = src_port;
+ socket.remote_address = tftpmcb.server_ip;
+ socket.app_fn = tftp_receive;
+
+ /* Move to the DATA State. */
+ tftpmcb.state = DATA_RECEIVE;
+ tftpmcb.num_retransmits = 0;
+
+ /* Close the timer. */
+ timer_delete (tftpmcb.timer);
+ tftpmcb.timer = -1;
+
+ /* Open the TFTP data socket. */
+ tftpmcb.sock = udp_sock_open (&socket);
+ if (tftpmcb.sock < 0)
+ {
+ /* Error: Data Socket open failed. */
+ mprintf ("Error: TFTP Data Socket Open Failed\n");
+ tftp_cleanup();
+ net_set_error();
+ return -1;
+ }
+ }
+
+ /* We are in the DATA State: Start the TFTP Server Keep Alive Timer. This timer
+ * keeps track of the TFTP Server and ensures it does not die behind us. This will
+ * help detect that error. */
+ timer_delete (tftpmcb.timer);
+ tftpmcb.timer = timer_add (TFTP_SERVER_TIMEOUT, tftp_timer_expiry);
+ if (tftpmcb.timer < 0)
+ {
+ /* Timer creation failed. */
+ mprintf ("Error: TFTP Timer creation failed\n");
+ tftp_cleanup();
+ net_set_error();
+ return -1;
+ }
+
+ /* Received a data block. Ensure that the block number matches what we expect! */
+ if (ntohs(ptr_tftphdr->block) != tftpmcb.block_num)
+ {
+ /* There is a block number mismatch. This could occur if the ACK we sent was lost.
+ * Increment the number of retransmissions. */
+ tftpmcb.num_retransmits++;
+ if (tftpmcb.num_retransmits > MAX_TFTP_RETRANSMITS)
+ {
+ /* OK; we resent the ACK multiple times & the server still kept sending the
+ * same packet back. We just give up now. */
+ mprintf ("Error: TFTP ACK Retransmits Exceeded\n");
+ tftp_cleanup();
+ net_set_error();
+ return -1;
+ }
+
+ /* We need to send out the ACK for the previous 'block' */
+ tftpmcb.block_num = tftpmcb.block_num - 1;
+
+ /* Send the ACK out again. */
+ tftp_send_ack ();
+
+ /* We dont need to process this packet since we had already picked it up. */
+ return 0;
+ }
+
+ /* The packet looks good. Reset the number of retransmissions. */
+ tftpmcb.num_retransmits = 0;
+
+ /* Pass the received data packet to the STREAM Module.
+ * We need to skip the TFTP Header. */
+ if (stream_write ((ptr_data + TFTPHEADER_SIZE), (num_bytes - TFTPHEADER_SIZE)) == 0)
+ {
+ /* Packet has been copied successfully into the STREAM Buffer. */
+ tftp_send_ack();
+ }
+ else
+ {
+ /* Packet could not be copied; let the server retransmit the packet
+ * because we did not send the ACK. */
+ }
+
+ /* Determine if the TFTP file transfer is complete or not?
+ * If the received number of bytes is less than the TFTP Data Size this
+ * indicates that the transfer is successfully completed. */
+ if (num_bytes < (TFTP_DATA_SIZE + TFTPHEADER_SIZE))
+ {
+ /* Successfully downloaded the file */
+ tftp_cleanup();
+ }
+ break;
+ }
+ default:
+ {
+ /* Control comes here for ERROR, ACK and WRQ which are all indicate
+ * failure. ERROR packet is the only expected failure which is mentioned
+ * in the RFC. All other packets are violation of the RFC. Both these
+ * cases are handled similarly. */
+ mprintf ("Error: TFTP Error Packet Received\n");
+ tftp_cleanup();
+ net_set_error();
+
+ /* Return Error. */
+ return -1;
+ }
+ }
+ return 0;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function gets a file from the TFTP Server. The function
+ * simply initiates the transfer. Successful completion of this
+ * API does not gurantee that the file was downloaded.
+ *
+ * @param[in] server_ip
+ * TFTP Server IP address from where the file is downloaded.
+ * @param[in] filename
+ * Name of the file to be downloaded.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+Int32 tftp_get_file (IPN server_ip, Int8* filename)
+{
+ SOCKET socket;
+ Int32 index = 0;
+
+ /* Basic Validations: Ensure the parameters passed are correct. */
+ if ((server_ip == 0) || (filename == NULL))
+ {
+ /* Error: Invalid parameters passed. Stop the network boot module. */
+ net_set_error();
+ return -1;
+ }
+
+ /* Open the stream module. */
+ if (stream_open (TFTP_DATA_SIZE) < 0)
+ {
+ /* Error: Unable to open the stream device. */
+ net_set_error();
+ return -1;
+ }
+
+ /* Initialize the TFTP MCB at this stage... */
+ memset ((void *)&tftpmcb, 0, sizeof(TFTP_MCB));
+
+ /* Populate the socket structure and register this with the UDP module. */
+ socket.local_port = 1234;
+ socket.remote_port = TFTP_SERVER_PORT;
+ socket.remote_address = server_ip;
+ socket.app_fn = tftp_receive;
+
+ /* Open the TFTP Control socket. */
+ tftpmcb.sock = udp_sock_open (&socket);
+ if (tftpmcb.sock < 0)
+ {
+ /* ERROR: UDP Socket could not be opened. */
+ stream_close();
+ net_set_error();
+ return -1;
+ }
+
+ /* Remember the parameters passed to the TFTP. */
+ tftpmcb.server_ip = server_ip;
+
+ /* Copy the file name over... */
+ while (filename[index] != 0)
+ {
+ tftpmcb.filename[index] = filename[index];
+ index++;
+ }
+
+ /* Initialize the block number expected. */
+ tftpmcb.block_num = 1;
+
+ /* Create the TFTP Read Request. */
+ index = tftp_create_read_req ((Uint8 *)filename);
+
+ /* Initialize the TFTP Client state */
+ tftpmcb.state = READ_REQUEST;
+
+ /* Initialize the TFTP Timer. */
+ tftpmcb.timer = timer_add (TFTP_TIMEOUT, tftp_timer_expiry);
+ if (tftpmcb.timer < 0)
+ {
+ /* Error: TFTP Timer Creation Failed. TFTP is not operational. */
+ mprintf ("Error: TFTP Timer Creation Failed\n");
+ tftp_cleanup ();
+ net_set_error();
+ return -1;
+ }
+
+ /* The packet has been populated; send it to the server. */
+ udp_sock_send (tftpmcb.sock, (Uint8 *)&tftpmcb.buffer[0], index);
+
+ /* Send out the TFTP Read request. */
+ return 0;
+}
+
+
diff --git a/src/driver/eth/udp.c b/src/driver/eth/udp.c
--- /dev/null
+++ b/src/driver/eth/udp.c
@@ -0,0 +1,322 @@
+/**
+ * @file udp.c
+ *
+ * @brief
+ * The file implements the NET Module UDP functionality.
+ *
+ * \par
+ * NOTE:
+ * (C) Copyright 2008, Texas Instruments, Inc.
+ *
+ * \par
+ */
+#include "types.h"
+#include "iblloc.h"
+#include "net.h"
+#include "netif.h"
+#include "iblcfg.h"
+#include <string.h>
+
+
+/**********************************************************************
+ *************************** GLOBAL Variables *************************
+ **********************************************************************/
+
+/**
+ * @brief This is the global master control block for the UDP
+ * Socket Module and contains information about all the UDP sockets
+ * which are open.
+ */
+SOCKET udp_socket[MAX_UDP_SOCKET];
+
+/**********************************************************************
+ **************************** UDP Functions ***************************
+ **********************************************************************/
+
+/**
+ * @b Description
+ * @n
+ * The function computes the UDP checksum and populates the UDP
+ * Checksum field.
+ *
+ * @param[in] ptr_udphdr
+ * This is the pointer to the UDP header.
+ * @param[in] ptr_pseudo
+ * This is the UDP Pseudo header used for checksum calculations.
+ *
+ * @retval
+ * Not Applicable.
+ */
+static void udp_checksum (UDPHDR *ptr_udphdr, PSEUDOHDR* ptr_pseudo)
+{
+ Int32 tmp1;
+ Uint16* pw;
+ Uint32 TSum;
+
+ /* Get header size in bytes */
+ tmp1 = ntohs(ptr_pseudo->Length);
+
+ /* Checksum field is NULL in checksum calculations */
+ ptr_udphdr->UDPChecksum = 0;
+
+ /* Checksum the header */
+ pw = (Uint16 *)ptr_udphdr;
+ TSum = 0;
+ for( ; tmp1 > 1; tmp1 -= 2 )
+ TSum += (Uint32)*pw++;
+#ifdef BIGENDIAN
+ if( tmp1 )
+ TSum += (Uint32)(*pw & 0xFF00);
+#else
+ if( tmp1 )
+ TSum += (Uint32)(*pw & 0x00FF);
+#endif
+
+ /* Checksum the pseudo header */
+ pw = (Uint16 *)ptr_pseudo;
+ for( tmp1=0; tmp1 < 6; tmp1++ )
+ TSum += (Uint32)*pw++;
+
+ TSum = (TSum&0xFFFF) + (TSum>>16);
+ TSum = (TSum&0xFFFF) + (TSum>>16);
+
+ /* Special case the 0xFFFF checksum - don't use a checksum
+ * value of 0x0000 */
+ if( TSum != 0xFFFF )
+ TSum = ~TSum;
+
+ /* Note checksum is Net/Host byte order independent */
+ ptr_udphdr->UDPChecksum = (Uint16)TSum;
+ return;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function handles the processing of UDP packets.
+ *
+ * @param[in] ptr_iphdr
+ * This is the pointer to the IP header.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+Int32 udp_receive (IPHDR* ptr_iphdr)
+{
+ UDPHDR* ptr_udphdr;
+ Uint16 l4_pkt_size;
+ PSEUDOHDR pseudo;
+ Uint16 checksum;
+ Int32 index;
+
+ /* Get the pointer to the ICMP header. */
+ ptr_udphdr = (UDPHDR *) ((Uint8 *)ptr_iphdr + IPHDR_SIZE);
+
+ /* Compute the l4 packet size. */
+ l4_pkt_size = ntohs(ptr_iphdr->TotalLen) - IPHDR_SIZE;
+
+ /* Make sure we have minimum size to proceed. */
+ if (l4_pkt_size < UDPHDR_SIZE)
+ return -1;
+
+ /* Validate the UDP Checksum if one has been provided. */
+ if (ptr_udphdr->UDPChecksum)
+ {
+ /* Create the Pseudo header. */
+ pseudo.IPSrc = ptr_iphdr->IPSrc;
+ pseudo.IPDst = ptr_iphdr->IPDst;
+ pseudo.Null = 0;
+ pseudo.Protocol = 17;
+ pseudo.Length = ptr_udphdr->Length;
+
+ /* Compute the checksum and compare with the one received. */
+ checksum = ptr_udphdr->UDPChecksum;
+ udp_checksum (ptr_udphdr, &pseudo);
+ if (checksum != ptr_udphdr->UDPChecksum)
+ return -1;
+ }
+
+ /* Cycle through the UDP sockets and pass it to the application. */
+ for (index = 0; index < MAX_UDP_SOCKET; index++)
+ {
+ /* Check if there is a match of the destination port of the received
+ * packet with a local port on the socket. */
+ if (udp_socket[index].local_port == ntohs(ptr_udphdr->DstPort))
+ {
+ /* Found the socket! Pass the packet to the application receive handler. */
+ udp_socket[index].app_fn (index, (Uint8 *)((Uint8*)ptr_udphdr + sizeof(UDPHDR)),
+ (ntohs(ptr_udphdr->Length) - sizeof(UDPHDR)));
+
+ /* Packet has been successfully passed to the application. */
+ return 0;
+ }
+ }
+
+ /* Control comes here implies that there was no application waiting for the UDP data. */
+ return -1;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function is available to the application layer to register themselves
+ * with the UDP layer.
+ *
+ * @param[in] ptr_socket
+ * This is the pointer to the socket structure which is populated by the
+ * application layer and registered with the UDP module.
+ *
+ * @retval
+ * Success - Socket handle
+ * @retval
+ * Error - <0
+ */
+Int32 udp_sock_open (SOCKET* ptr_socket)
+{
+ Int32 index = 0;
+
+ /* Basic Validations: The structure should be populated completely. */
+ if ((ptr_socket->remote_address == 0) || (ptr_socket->remote_port == 0) ||
+ (ptr_socket->local_port == 0) || (ptr_socket->app_fn == NULL))
+ return -1;
+
+ /* Cycle through all the UDP socket and create an entry. */
+ for (index= 0; index < MAX_UDP_SOCKET; index++)
+ {
+ /* Check if the socket is free or occupied?
+ * This can simply be done by verifying that the local port is not 0 */
+ if (udp_socket[index].local_port == 0)
+ {
+ /* Got a free slot. Copy the socket data over and return the index as the handle. */
+ memcpy ((void *)&udp_socket[index], (void *)ptr_socket, sizeof(SOCKET));
+ return index;
+ }
+ }
+ /* Control comes here indicates that there were no free sockets available. */
+ return -1;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function is called from the application layer to send out a packet
+ * to the UDP layer.
+ *
+ * @param[in] sock
+ * This is the socket handle which was returned in the call to udp_sock_open.
+ * @param[in] ptr_app_data
+ * This is the pointer to the application data payload.
+ * @param[in] num_bytes
+ * This is the length of the application data payload
+ *
+ * @retval
+ * Success - Number of bytes transmitted
+ * @retval
+ * Error - < 0
+ */
+Int32 udp_sock_send (Int32 sock, Uint8* ptr_app_data, Int32 num_bytes)
+{
+ SOCKET* ptr_socket;
+ IPHDR* ptr_iphdr;
+ UDPHDR* ptr_udphdr;
+ Uint8* ptr_data;
+ PSEUDOHDR pseudo;
+
+ /* Get the pointer to the socket handle. */
+ ptr_socket = &udp_socket[sock];
+
+ /* Sanity Check: Make sure that the UDP socket is valid */
+ if (ptr_socket->local_port == 0)
+ return -1;
+
+ /* Allocate memory for the packet. */
+ ptr_iphdr = (IPHDR *)net_alloc_tx_packet (num_bytes + IPHDR_SIZE + UDPHDR_SIZE);
+ if (ptr_iphdr == NULL)
+ return -1;
+
+ /* Get the pointer to the UDP header. */
+ ptr_udphdr = (UDPHDR *)((Uint8 *)ptr_iphdr + IPHDR_SIZE);
+
+ /* Get the pointer to the data payload in the newly allocated packet. */
+ ptr_data = (Uint8 *)ptr_udphdr + UDPHDR_SIZE;
+
+ /*******************************************************************************
+ ********************************* APP Data ************************************
+ *******************************************************************************/
+ memcpy ((void *)ptr_data, (void *)ptr_app_data, num_bytes);
+
+ /*******************************************************************************
+ ********************************* UDP Header **********************************
+ *******************************************************************************/
+ ptr_udphdr->SrcPort = htons(ptr_socket->local_port);
+ ptr_udphdr->DstPort = htons(ptr_socket->remote_port);
+ ptr_udphdr->Length = htons(UDPHDR_SIZE + num_bytes);
+
+ /* Create the Pseudo header. */
+ pseudo.IPSrc = netmcb.net_device.ip_address;
+ pseudo.IPDst = ptr_socket->remote_address;
+ pseudo.Null = 0;
+ pseudo.Protocol = 17;
+ pseudo.Length = ptr_udphdr->Length;
+ udp_checksum (ptr_udphdr, &pseudo);
+
+ /*******************************************************************************
+ ********************************* IPv4 Header *********************************
+ *******************************************************************************/
+ ptr_iphdr->IPDst = ptr_socket->remote_address;
+ ptr_iphdr->Protocol = IPPROTO_UDP;
+
+ /* Send the IP packet. */
+ ip_send (ptr_iphdr, UDPHDR_SIZE + IPHDR_SIZE + num_bytes);
+
+ /* Packet has been sent out. */
+ return num_bytes;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function is available to the application layer to deregister themselves
+ * with the UDP layer.
+ *
+ * @param[in] sock
+ * This is the socket handle which is to be closed.
+ *
+ * @retval
+ * Not Applicable.
+ */
+void udp_sock_close (Int32 sock)
+{
+ SOCKET* ptr_socket;
+
+ /* Basic Validation: Ensure the sock is in the valid range. */
+ if ((sock < 0) || (sock > MAX_UDP_SOCKET))
+ return;
+
+ /* Get the pointer to the socket handle. */
+ ptr_socket = &udp_socket[sock];
+
+ /* Reset the memory block */
+ memset ((void *)ptr_socket, 0, sizeof(SOCKET));
+ return;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function initializes the UDP Module in the NET Boot module.
+ *
+ * @retval
+ * Not Applicable
+ */
+void udp_init (void)
+{
+ /* Initialize the socket table */
+ memset (&udp_socket, 0, sizeof(udp_socket));
+ return;
+}
+
+
+
diff --git a/src/driver/nand/nand.c b/src/driver/nand/nand.c
--- /dev/null
+++ b/src/driver/nand/nand.c
@@ -0,0 +1,342 @@
+/************************************************************************************************
+ * FILE PURPOSE: The top level NAND driver
+ ************************************************************************************************
+ * FILE NAME: nand.c
+ *
+ * DESCRIPTION: Provides the required driver functions which populate the BOOT_MODULE_FXN_TABLE
+ *
+ * @file nand.c
+ *
+ * @brief
+ * The top level nand driver
+ *
+ *************************************************************************************************/
+#include "types.h"
+#include "ibl.h"
+#include "iblloc.h"
+#include "nand.h"
+#include "nandhwapi.h"
+#include <string.h>
+#include <stdlib.h>
+
+
+/**
+ * @brief The nand master control block which tracks the current nand boot information
+ */
+typedef struct nandmcb_s
+{
+ nandDevInfo_t devInfo; /**< Device information */
+
+ Int32 fpos; /**< The current logical file position */
+ Uint32 currentLogicalBlock; /**< The logical block number of the page currently stored */
+ Uint32 currentPage; /**< The page number currently stored */
+
+ Uint8 *page; /**< The current page */
+ Uint16 *logicalToPhysMap; /**< Maps local block to physical block */
+ Uint16 *physToLogicalMap; /**< Maps a physical block number to a logical block number */
+
+ Uint32 numBadBlocks; /**< Total number of bad blocks */
+ Uint8 *blocks; /**< There is one byte per block. A non-zero value indicates
+ that the block is bad */
+
+} nandmcb_t;
+
+nandmcb_t nandmcb;
+
+
+/**
+ * @b Description
+ * @n
+ *
+ * This function sets the current file position, and loads the page corresponding
+ * to that position into the pre-allocated page memory
+ */
+Int32 nand_seek (Int32 loc, Int32 from)
+{
+ Int32 desiredPos;
+ Uint32 desiredBlock;
+ Uint32 desiredPage;
+
+ /* Can't seek from the end of the file, since the end is not known */
+ if (from == 0)
+ desiredPos = loc;
+ else if (from == 1)
+ desiredPos = nandmcb.fpos + loc;
+ else
+ return (-1);
+
+ if (desiredPos < 0)
+ return (-1);
+
+
+ /* Convert the file position (relative to the file start) into a page number */
+ desiredPage = desiredPos / nandmcb.devInfo.pageSizeBytes;
+
+ /* Convert the logical page to logical block/page */
+ desiredBlock = desiredPage / nandmcb.devInfo.pagesPerBlock;
+ desiredPage = desiredPage % nandmcb.devInfo.pagesPerBlock;
+
+ /* Nothing to do if the current block/page is already loaded */
+ if ((desiredBlock == nandmcb.currentLogicalBlock) && (desiredPage == nandmcb.currentPage))
+ return (0);
+
+ /* Otherwise load the desired page */
+ if (nandHwDriverReadPage((Uint32)(nandmcb.logicalToPhysMap[desiredBlock]), desiredPage, nandmcb.page) < 0)
+ return (-2);
+
+ /* Update the currently loaded block/page info */
+ nandmcb.currentLogicalBlock = desiredBlock;
+ nandmcb.currentPage = desiredPage;
+ nandmcb.fpos = desiredPos;
+
+ return (0);
+
+}
+
+
+/**
+ * @b Description
+ * @n
+ * Free any memory allocated by the driver
+ */
+Int32 nand_free_return (Int32 retcode)
+{
+ if (nandmcb.page != NULL)
+ free (nandmcb.page);
+
+ if (nandmcb.logicalToPhysMap != NULL)
+ free (nandmcb.logicalToPhysMap);
+
+ if (nandmcb.physToLogicalMap != NULL)
+ free (nandmcb.physToLogicalMap);
+
+ if (nandmcb.blocks != NULL)
+ free (nandmcb.blocks);
+
+ return (retcode);
+
+}
+
+
+
+/**
+ * @b Description
+ * @n
+ *
+ * This function initializes the nand control structure and reads the bad block info
+ * from the nand.
+ */
+Int32 nand_open (void *ptr_driver, void (*asyncComplete)(void *))
+{
+ iblNand_t *ibln = (iblNand_t *)ptr_driver;
+
+ Int32 size;
+ Int32 ret;
+ Int32 i, j;
+
+ /* Initialize the control info */
+ memset (&nandmcb, 0, sizeof(nandmcb));
+ memcpy (&nandmcb.devInfo, &ibln->nandInfo, sizeof(iblNand_t));
+
+ nandmcb.page = NULL;
+ nandmcb.logicalToPhysMap = NULL;
+ nandmcb.physToLogicalMap = NULL;
+ nandmcb.blocks = NULL;
+
+ ret = nandHwDriverInit (&nandmcb.devInfo);
+ if (ret < 0)
+ nand_free_return (ret);
+
+ /* allocate memory for the page data and the logical to physical block map */
+ size = nandmcb.devInfo.pageSizeBytes + nandmcb.devInfo.pageEccBytes;
+ nandmcb.page = malloc (size * sizeof(Uint8));
+ if (nandmcb.page == NULL)
+ nand_free_return (NAND_MALLOC_PAGE_FAIL);
+
+
+ /* Logical to physical map data */
+ nandmcb.logicalToPhysMap = malloc (nandmcb.devInfo.totalBlocks * sizeof(Uint16));
+ if (nandmcb.logicalToPhysMap == NULL)
+ nand_free_return (NAND_MALLOC_MAP_LTOP_FAIL);
+
+
+ /* Physical to logical map data */
+ nandmcb.physToLogicalMap = malloc (nandmcb.devInfo.totalBlocks * sizeof(Uint16));
+ if (nandmcb.physToLogicalMap == NULL)
+ nand_free_return (NAND_MALLOC_MAP_PTOL_FAIL);
+
+ /* Block info */
+ size = nandmcb.devInfo.totalBlocks * sizeof(Uint8);
+ nandmcb.blocks = malloc (size);
+ if (nandmcb.blocks == NULL)
+ nand_free_return (NAND_MALLOC_BLOCK_INFO_FAIL);
+
+
+ /* mdebug - read page 0 */
+ nandHwDriverReadPage(0, 0, nandmcb.page);
+
+
+ /* Bad blocks are identified by reading page 0 and page 1. If the first two
+ * bytes in these pages is not 0xffff then the block is bad */
+ nandmcb.numBadBlocks = 0;
+ for (i = 0; i < nandmcb.devInfo.totalBlocks; i++) {
+
+ ret = nandHwDriverReadBytes (i, 0, nandmcb.devInfo.pageSizeBytes, 1, &nandmcb.page[0]);
+ if (ret < 0)
+ nand_free_return (ret);
+
+ ret = nandHwDriverReadBytes (i, 0, nandmcb.devInfo.pageSizeBytes, 1, &nandmcb.page[1]);
+ if (ret < 0)
+ nand_free_return (ret);
+
+ if ((nandmcb.page[0] != 0xff) || (nandmcb.page[1] != 0xff)) {
+ nandmcb.blocks[i] = 0xff;
+ nandmcb.numBadBlocks += 1;
+ } else
+ nandmcb.blocks[i] = 0;
+
+ }
+
+
+ /* Construct the logical to physical block array */
+ for (i = j = 0; i < nandmcb.devInfo.totalBlocks; i++) {
+ if (nandmcb.blocks[i] != 0xff)
+ nandmcb.logicalToPhysMap[j++] = i;
+ }
+
+ /* Construct the physical to logical block array */
+ for (i = j = 0; i < nandmcb.devInfo.totalBlocks; i++) {
+ if (nandmcb.blocks[i] == 0xff)
+ nandmcb.physToLogicalMap[i] = 0xff;
+ else
+ nandmcb.physToLogicalMap[i] = j++;
+ }
+
+
+ /* Seek to the first byte of the file */
+ nandmcb.fpos = -1; /* Force a read on the first seek */
+ nandmcb.currentLogicalBlock = 0xffffffff;
+ nandmcb.currentPage = 0xffffffff;
+ nand_seek (0, 0);
+
+
+ return (0);
+
+}
+
+
+/**
+ * @b Description
+ * @n
+ * This function performs a reads from the current read point
+ *
+ */
+Int32 nand_read (Uint8 *ptr_buf, Uint32 num_bytes)
+{
+ Int32 i;
+ Int32 pIdx;
+
+ /* Convert the global file position to an offset in the currently cached page */
+ pIdx = nandmcb.fpos % nandmcb.devInfo.pageSizeBytes;
+
+
+ for (i = 0; i < num_bytes; i++) {
+
+ ptr_buf[i] = nandmcb.page[pIdx++];
+
+ if (pIdx >= nandmcb.devInfo.pageSizeBytes) {
+
+ pIdx = 0;
+ nandmcb.currentPage += 1;
+
+ if (nandmcb.currentPage >= nandmcb.devInfo.pagesPerBlock) {
+ nandmcb.currentPage = 0;
+ nandmcb.currentLogicalBlock += 1;
+ }
+
+
+ /* Load the new block */
+ if (nandHwDriverReadPage((Uint32)(nandmcb.logicalToPhysMap[nandmcb.currentLogicalBlock]), nandmcb.currentPage, nandmcb.page) < 0)
+ return (-2);
+
+ }
+ }
+
+ return (0);
+
+}
+
+/**
+ * @b Description
+ * @n
+ * This function performs a peek from the current read point.
+ */
+Int32 nand_peek (Uint8 *ptr_buf, Uint32 num_bytes)
+{
+ Int32 ret;
+ Int32 origPos;
+ Uint32 origLogicalBlock;
+ Uint32 origPage;
+
+ origPos = nandmcb.fpos;
+ origLogicalBlock = nandmcb.currentLogicalBlock;
+ origPage = nandmcb.currentPage;
+
+ ret = nand_read (ptr_buf, num_bytes);
+
+ if ( (origLogicalBlock != nandmcb.currentLogicalBlock) ||
+ (origPage != nandmcb.currentPage) ) {
+
+ if (nandHwDriverReadPage((Uint32)(nandmcb.logicalToPhysMap[origLogicalBlock]), origPage, nandmcb.page) < 0)
+ return (-2);
+ }
+
+ nandmcb.fpos = origPos;
+ nandmcb.currentLogicalBlock = origLogicalBlock;
+ nandmcb.currentPage = origPage;
+
+ return (ret);
+
+}
+
+/**
+ * @b Description
+ * @n
+ * This function returns how much data is available for immediate read.
+ * On nand this always returns -1.
+ */
+Int32 nand_query (void)
+{
+ return (-1);
+}
+
+
+/**
+ * @b Description
+ * @n
+ * This function closes the nand driver
+ */
+Int32 nand_close (void)
+{
+ nandHwDriverClose ();
+ return (nand_free_return (0));
+
+}
+
+
+
+/**
+ * @brief The global nand module function table
+ */
+BOOT_MODULE_FXN_TABLE nand_boot_module =
+{
+ nand_open, /* Open API */
+ nand_close, /* Close API */
+ nand_read, /* Read API */
+ NULL, /* Write API */
+ nand_peek, /* Peek API */
+ nand_seek, /* Seek API */
+ nand_query /* Query API */
+
+};
+
diff --git a/src/driver/nand/nand.h b/src/driver/nand/nand.h
--- /dev/null
+++ b/src/driver/nand/nand.h
@@ -0,0 +1,31 @@
+#ifndef _NAND_H
+#define _NAND_H
+/************************************************************************************************
+ * FILE PURPOSE: NAND API definitions
+ ************************************************************************************************
+ * FILE NAME: nand.h
+ *
+ * DESCRIPTION: Defines the nand api
+ *
+ * @file nand.h
+ *
+ * @brief
+ * Defines the nand api.
+ *
+ **************************************************************************************************/
+#include "iblloc.h"
+
+/* All error codes must be negative */
+#define NAND_MALLOC_PAGE_FAIL -400
+#define NAND_MALLOC_MAP_LTOP_FAIL -401
+#define NAND_MALLOC_MAP_PTOL_FAIL -402
+#define NAND_MALLOC_BLOCK_INFO_FAIL -403
+#define NAND_BAD_BAD_BLOCK_MAGIC -404
+#define NAND_BAD_APP_MAGIC -405
+
+extern BOOT_MODULE_FXN_TABLE nand_boot_module;
+
+
+#endif /* _NAND_H */
+
+
diff --git a/src/driver/nand/nflashlay.h.old b/src/driver/nand/nflashlay.h.old
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef _NAND_FLASH_LAYOUT_H
+#define _NAND_FLASH_LAYOUT_H
+/*******************************************************************************************
+ * FILE PURPOSE: Define values associated with the nand flash layout
+ *******************************************************************************************
+ * FILE NAME: nflashlay.h
+ *
+ * DESCRIPTION: The nand flash layout is defined
+ *
+ * @file nflashlay.h
+ *
+ * @brief
+ * The nand flash layout is defined
+ *
+ ********************************************************************************************/
+
+#define APP_MAGIC_NUM 0xa1aced11
+#define BAD_BLOCK_MAGIC_NUM 0xa1aced00
+
+
+
+#endif /* _NAND_FLASH_LAYOUT_H */
+
+
+
+
+
diff --git a/src/driver/stream/stream.c b/src/driver/stream/stream.c
--- /dev/null
@@ -0,0 +1,344 @@
+/**
+ * @file stream.c
+ *
+ * @brief
+ * The file implements the STREAM module.
+ *
+ * \par
+ * NOTE:
+ * (C) Copyright 2008, Texas Instruments, Inc.
+ *
+ * \par
+ */
+
+
+/**********************************************************************
+ ************************** Local Structures **************************
+ **********************************************************************/
+#include "types.h"
+#include "iblcfg.h"
+#include <string.h>
+
+/**
+ * @defgroup stream_op
+ *
+ * @ingroup stream_op
+ * @{
+ *
+ * @brief
+ * Internal defintion to distinguish between read and peek
+ */
+/**
+ * @def STREAM_READ
+ */
+#define STREAM_READ 200 /**< Read from a stream */
+
+/**
+ * @def STREAM_PEEK
+ */
+#define STREAM_PEEK 210 /**< Peek from a stream */
+
+/* @} */
+
+
+
+/**
+ * @brief
+ * The structure describes the Stream Master Control block.
+ *
+ * @details
+ * The structure stores information about the stream module
+ * internal buffers and state information.
+ */
+typedef struct STREAM_MCB
+{
+ /**
+ * @brief Flag which indicates if the stream buffer is open or not?
+ */
+ Bool is_open;
+
+ /**
+ * @brief This is the *internal* stream buffer.
+ */
+ Uint8 buffer[MAX_SIZE_STREAM_BUFFER];
+
+ /**
+ * @brief This is the read index from where data is read.
+ */
+ Int32 read_idx;
+
+ /**
+ * @brief This is the write index to which data is written.
+ */
+ Int32 write_idx;
+
+ /**
+ * @brief This is the free size available in the internal buffer.
+ */
+ Int32 free_size;
+}STREAM_MCB;
+
+/**********************************************************************
+ ************************** Global Variables **************************
+ **********************************************************************/
+
+/**
+ * @brief This is the STREAM Master control block which keeps track
+ * of all the stream module information.
+ */
+STREAM_MCB stream_mcb;
+
+/**********************************************************************
+ ************************** Stream Functions **************************
+ **********************************************************************/
+
+/**
+ * @b Description
+ * @n
+ * The function is called to open the stream module
+ *
+ * @param[in] chunk_size
+ * Maximum amount of data that can be received at any
+ * instant by the boot module.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+Int32 stream_open (Uint32 chunk_size)
+{
+ /* Basic Validations: Ensure that the chunk size is not greater
+ * than the internal buffer size. */
+ if (chunk_size > MAX_SIZE_STREAM_BUFFER)
+ return -1;
+
+ /* Initialize the Master control block. */
+ stream_mcb.is_open = TRUE;
+ stream_mcb.read_idx = 0;
+ stream_mcb.write_idx = 0;
+ stream_mcb.free_size = MAX_SIZE_STREAM_BUFFER;
+
+ /* Module has been initialized. */
+ return 0;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function is called to read/peek data from the stream module.
+ *
+ * @param[in] ptr_data
+ * Pointer to the data buffer where the data will be copied to.
+ * @param[in] num_bytes
+ * Number of bytes to be read.
+ * @param[in] op
+ * Distinguishes a read from a peek @ref stream_op
+ *
+ * @retval
+ * Success - Number of bytes actually read
+ * @retval
+ * Error - <0
+ */
+Int32 stream_read_peek (Uint8* ptr_data, Int32 num_bytes, Int32 op)
+{
+ Int32 index;
+ Int32 num_bytes_to_read;
+
+ /* Determine the number of bytes which can be read. */
+ if (num_bytes > (MAX_SIZE_STREAM_BUFFER - stream_mcb.free_size))
+ {
+ /* User has requested more data than what is available. In this case we
+ * can return only what we have. */
+ num_bytes_to_read = (MAX_SIZE_STREAM_BUFFER - stream_mcb.free_size);
+ }
+ else
+ {
+ /* User has requested less data than what is available. In this case we
+ * return only what the user wants. */
+ num_bytes_to_read = num_bytes;
+ }
+
+ /* There is data available copy it from the internal to the user supplied buffer. */
+ for (index = 0; index < num_bytes_to_read; index++)
+ {
+ /* Copy the data to the "write" index. */
+ if (ptr_data != NULL)
+ *(ptr_data + index) = *(stream_mcb.buffer + stream_mcb.read_idx + index);
+
+ }
+
+ /* Increment the read index.
+ * Once data has been copied; increment the free size accordingly */
+ if (op == STREAM_READ) {
+ stream_mcb.read_idx = (stream_mcb.read_idx + num_bytes_to_read) % MAX_SIZE_STREAM_BUFFER;
+ stream_mcb.free_size = stream_mcb.free_size + num_bytes_to_read;
+ }
+
+
+ /* Return the number of bytes read. */
+ return num_bytes_to_read;
+}
+
+
+/**
+ * @b Description
+ * @n
+ * The function is called to read data from the stream module.
+ *
+ * @param[in] ptr_data
+ * Pointer to the data buffer where the data will be copied to.
+ * @param[in] num_bytes
+ * Number of bytes to be read.
+ *
+ * @retval
+ * Success - Number of bytes actually read
+ * @retval
+ * Error - <0
+ */
+Int32 stream_read (Uint8* ptr_data, Int32 num_bytes)
+{
+ return (stream_read_peek (ptr_data, num_bytes, STREAM_READ));
+}
+
+/**
+ * @b Description
+ * @n
+ * The function is called to peek data from the stream module.
+ *
+ * @param[in] ptr_data
+ * Pointer to the data buffer where the data will be copied to.
+ * @param[in] num_bytes
+ * Number of bytes to be read.
+ *
+ * @retval
+ * Success - Number of bytes actually read
+ * @retval
+ * Error - <0
+ */
+Int32 stream_peek (Uint8* ptr_data, Int32 num_bytes)
+{
+ return (stream_read_peek (ptr_data, num_bytes, STREAM_PEEK));
+}
+
+
+/**
+ * @b Description
+ * @n
+ * The function is called to write data to the stream
+ * module.
+ *
+ * @param[in] ptr_data
+ * Pointer to the data buffer which contains the data to be copied.
+ * @param[in] num_bytes
+ * Number of bytes being written
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+Int32 stream_write (Uint8* ptr_data, Int32 num_bytes)
+{
+ Int32 index;
+
+ /* Basic Validations: Ensure there is sufficient space to copy the data. */
+ if (num_bytes > stream_mcb.free_size)
+ return -1;
+
+ /* Basic Validations: Make sure the pointers are valid. */
+ if (ptr_data == NULL)
+ return -1;
+
+ /* There was sufficient space to copy the data lets do so but we copy byte by byte
+ * since the internal buffer is circular and we can wrap around... */
+ for (index = 0; index < num_bytes; index++)
+ {
+ /* Copy the data to the "write" index. */
+ *(stream_mcb.buffer + stream_mcb.write_idx) = *(ptr_data + index);
+
+ /* Increment the write index. */
+ stream_mcb.write_idx = (stream_mcb.write_idx + 1) % MAX_SIZE_STREAM_BUFFER;
+ }
+
+ /* Once data has been copied; decrement the free size accordingly */
+ stream_mcb.free_size = stream_mcb.free_size - num_bytes;
+ return 0;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function is used to check if the stream buffers are empty or
+ * not?
+ *
+ * @retval
+ * Empty - TRUE
+ * @retval
+ * Not Empty - FALSE
+ */
+Bool stream_isempty (void)
+{
+ /* Check the number of free bytes available? */
+ if (stream_mcb.free_size == MAX_SIZE_STREAM_BUFFER)
+ return TRUE;
+
+ /* There is data in the stream buffer; so its not empty. */
+ return FALSE;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function closes the stream module.
+ *
+ * @retval
+ * Not Applicable.
+ */
+void stream_close (void)
+{
+ /* The stream module is no longer open... */
+ stream_mcb.is_open = FALSE;
+ return;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function initializes the stream module.
+ *
+ * @retval
+ * Not Applicable.
+ */
+void stream_init (void)
+{
+ /* Reset the memory contents. */
+ memset ((void *)&stream_mcb, 0, sizeof(STREAM_MCB));
+
+ /* Make sure we initialize the free size correctly. */
+ stream_mcb.free_size = MAX_SIZE_STREAM_BUFFER;
+ return;
+}
+
+
+/**
+ * @b Description
+ * @n
+ * Returns the number of bytes currently available in the stream
+ *
+ * @retval
+ * The number of bytes in the stream buffer
+ * -1 if the stream is closed AND empty
+ */
+Int32 stream_level (void)
+{
+ Int32 remain;
+
+ remain = MAX_SIZE_STREAM_BUFFER - stream_mcb.free_size;
+
+ if ((stream_mcb.is_open != TRUE) && (remain == 0))
+ return (-1);
+
+ return (remain);
+
+}
diff --git a/src/driver/stream/stream.h b/src/driver/stream/stream.h
--- /dev/null
@@ -0,0 +1,30 @@
+/**
+ * @file stream.h
+ *
+ * @brief
+ * The file has data structures and API definitions for the
+ * STREAM Module
+ *
+ * \par
+ * NOTE:
+ * (C) Copyright 2008, Texas Instruments, Inc.
+ *
+ * \par
+ */
+#ifndef __STREAM_H__
+#define __STREAM_H__
+
+/**********************************************************************
+ **************************** Exported Functions **********************
+ **********************************************************************/
+
+extern void stream_init (void);
+extern Int32 stream_open (Uint32 chunk_size);
+extern void stream_close (void);
+extern Int32 stream_read (Uint8* ptr_data, Int32 num_bytes);
+extern Int32 stream_peek (Uint8* ptr_data, Int32 num_bytes);
+extern Int32 stream_write (Uint8* ptr_data, Int32 num_bytes);
+extern Bool stream_isempty(void);
+extern Int32 stream_level (void);
+
+#endif /* __STREAM_H__ */
diff --git a/src/driver/stream/stream_orig.c b/src/driver/stream/stream_orig.c
--- /dev/null
@@ -0,0 +1,251 @@
+/**
+ * @file stream.c
+ *
+ * @brief
+ * The file implements the STREAM module.
+ *
+ * \par
+ * NOTE:
+ * (C) Copyright 2008, Texas Instruments, Inc.
+ *
+ * \par
+ */
+
+
+/**********************************************************************
+ ************************** Local Structures **************************
+ **********************************************************************/
+#include "types.h"
+#include "iblcfg.h"
+#include <string.h>
+
+/**
+ * @brief
+ * The structure describes the Stream Master Control block.
+ *
+ * @details
+ * The structure stores information about the stream module
+ * internal buffers and state information.
+ */
+typedef struct STREAM_MCB
+{
+ /**
+ * @brief Flag which indicates if the stream buffer is open or not?
+ */
+ Bool is_open;
+
+ /**
+ * @brief This is the *internal* stream buffer.
+ */
+ Uint8 buffer[MAX_SIZE_STREAM_BUFFER];
+
+ /**
+ * @brief This is the read index from where data is read.
+ */
+ Int32 read_idx;
+
+ /**
+ * @brief This is the write index to which data is written.
+ */
+ Int32 write_idx;
+
+ /**
+ * @brief This is the free size available in the internal buffer.
+ */
+ Int32 free_size;
+}STREAM_MCB;
+
+/**********************************************************************
+ ************************** Global Variables **************************
+ **********************************************************************/
+
+/**
+ * @brief This is the STREAM Master control block which keeps track
+ * of all the stream module information.
+ */
+STREAM_MCB stream_mcb;
+
+/**********************************************************************
+ ************************** Stream Functions **************************
+ **********************************************************************/
+
+/**
+ * @b Description
+ * @n
+ * The function is called to open the stream module
+ *
+ * @param[in] chunk_size
+ * Maximum amount of data that can be received at any
+ * instant by the boot module.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+Int32 stream_open (Uint32 chunk_size)
+{
+ /* Basic Validations: Ensure that the chunk size is not greater
+ * than the internal buffer size. */
+ if (chunk_size > MAX_SIZE_STREAM_BUFFER)
+ return -1;
+
+ /* Initialize the Master control block. */
+ stream_mcb.is_open = TRUE;
+ stream_mcb.read_idx = 0;
+ stream_mcb.write_idx = 0;
+ stream_mcb.free_size = MAX_SIZE_STREAM_BUFFER;
+
+ /* Module has been initialized. */
+ return 0;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function is called to read data from the stream module.
+ *
+ * @param[in] ptr_data
+ * Pointer to the data buffer where the data will be copied to.
+ * @param[in] num_bytes
+ * Number of bytes to be read.
+ *
+ * @retval
+ * Success - Number of bytes actually read
+ * @retval
+ * Error - <0
+ */
+Int32 stream_read (Uint8* ptr_data, Int32 num_bytes)
+{
+ Int32 index;
+ Int32 num_bytes_to_read;
+
+ /* Determine the number of bytes which can be read. */
+ if (num_bytes > (MAX_SIZE_STREAM_BUFFER - stream_mcb.free_size))
+ {
+ /* User has requested more data than what is available. In this case we
+ * can return only what we have. */
+ num_bytes_to_read = (MAX_SIZE_STREAM_BUFFER - stream_mcb.free_size);
+ }
+ else
+ {
+ /* User has requested less data than what is available. In this case we
+ * return only what the user wants. */
+ num_bytes_to_read = num_bytes;
+ }
+
+ /* There is data available copy it from the internal to the user supplied buffer. */
+ for (index = 0; index < num_bytes_to_read; index++)
+ {
+ /* Copy the data to the "write" index. */
+ *(ptr_data + index) = *(stream_mcb.buffer + stream_mcb.read_idx);
+
+ /* Increment the read index. */
+ stream_mcb.read_idx = (stream_mcb.read_idx + 1) % MAX_SIZE_STREAM_BUFFER;
+ }
+
+ /* Once data has been copied; increment the free size accordingly */
+ stream_mcb.free_size = stream_mcb.free_size + num_bytes_to_read;
+
+ /* Return the number of bytes read. */
+ return num_bytes_to_read;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function is called to write data to the stream
+ * module.
+ *
+ * @param[in] ptr_data
+ * Pointer to the data buffer which contains the data to be copied.
+ * @param[in] num_bytes
+ * Number of bytes being written
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+Int32 stream_write (Uint8* ptr_data, Int32 num_bytes)
+{
+ Int32 index;
+
+ /* Basic Validations: Ensure there is sufficient space to copy the data. */
+ if (num_bytes > stream_mcb.free_size)
+ return -1;
+
+ /* Basic Validations: Make sure the pointers are valid. */
+ if (ptr_data == NULL)
+ return -1;
+
+ /* There was sufficient space to copy the data lets do so but we copy byte by byte
+ * since the internal buffer is circular and we can wrap around... */
+ for (index = 0; index < num_bytes; index++)
+ {
+ /* Copy the data to the "write" index. */
+ *(stream_mcb.buffer + stream_mcb.write_idx) = *(ptr_data + index);
+
+ /* Increment the write index. */
+ stream_mcb.write_idx = (stream_mcb.write_idx + 1) % MAX_SIZE_STREAM_BUFFER;
+ }
+
+ /* Once data has been copied; decrement the free size accordingly */
+ stream_mcb.free_size = stream_mcb.free_size - num_bytes;
+ return 0;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function is used to check if the stream buffers are empty or
+ * not?
+ *
+ * @retval
+ * Empty - TRUE
+ * @retval
+ * Not Empty - FALSE
+ */
+Bool stream_isempty (void)
+{
+ /* Check the number of free bytes available? */
+ if (stream_mcb.free_size == MAX_SIZE_STREAM_BUFFER)
+ return TRUE;
+
+ /* There is data in the stream buffer; so its not empty. */
+ return FALSE;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function closes the stream module.
+ *
+ * @retval
+ * Not Applicable.
+ */
+void stream_close (void)
+{
+ /* The stream module is no longer open... */
+ stream_mcb.is_open = FALSE;
+ return;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function initializes the stream module.
+ *
+ * @retval
+ * Not Applicable.
+ */
+void stream_init (void)
+{
+ /* Reset the memory contents. */
+ memset ((void *)&stream_mcb, 0, sizeof(STREAM_MCB));
+
+ /* Make sure we initialize the free size correctly. */
+ stream_mcb.free_size = MAX_SIZE_STREAM_BUFFER;
+ return;
+}
+
diff --git a/src/driver/timer/timer.c b/src/driver/timer/timer.c
--- /dev/null
+++ b/src/driver/timer/timer.c
@@ -0,0 +1,252 @@
+/**
+ * @file timer.c
+ *
+ * @brief
+ * The file implements the TIMER module.
+ *
+ * \par
+ * NOTE:
+ * (C) Copyright 2008, Texas Instruments, Inc.
+ *
+ * \par
+ */
+ #include "types.h"
+ #include "iblloc.h"
+ #include "timer.h"
+ #include "devtimer.h"
+ #include "iblcfg.h"
+ #include <string.h>
+
+
+/**********************************************************************
+ *************************** LOCAL Structures *************************
+ **********************************************************************/
+
+/**
+ * @brief
+ * The structure describes the Timer blocks.
+ *
+ * @details
+ * Each timer in the system is associated with a timer
+ * block.
+ */
+typedef struct TIMER_BLOCK
+{
+ /**
+ * @brief Expiration Routine which is called once the timer
+ * expires.
+ */
+ void (*expiry)(void);
+
+ /**
+ * @brief This is the original expiration time in milli-seconds.
+ */
+ Uint32 org_timeout;
+
+ /**
+ * @brief This is the expiration time in milli-seconds. This is
+ * decremented by the timer module.
+ */
+ Uint32 timeout;
+}TIMER_BLOCK;
+
+/**
+ * @brief
+ * The structure describes the Timer Master Control Block.
+ *
+ * @details
+ * The structure contains information about the Timer Master Control
+ * block which stores information about the Timer Module.
+ */
+typedef struct TIMER_MCB
+{
+ /**
+ * @brief This keeps track of all timers which can exist in the
+ * System.
+ */
+ TIMER_BLOCK timer[MAX_TIMER_BLOCKS];
+
+ /**
+ * @brief This is the number of active timers in the system.
+ */
+ Uint32 num_active_timers;
+}TIMER_MCB;
+
+/**********************************************************************
+ *************************** GLOBAL Variables *************************
+ **********************************************************************/
+
+/**
+ * @brief This global variable keeps track of all the timer which are
+ * currently active in the system.
+ */
+TIMER_MCB timermcb;
+
+/**********************************************************************
+ *************************** TIMER Functions **************************
+ **********************************************************************/
+
+/**
+ * @b Description
+ * @n
+ * The function initializes the Timer module.
+ *
+ * @retval
+ * Not Applicable.
+ */
+void timer_init (void)
+{
+ /* Initialize the Timer Master Control Block. */
+ memset (&timermcb, 0, sizeof(TIMER_MCB));
+ return;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function creates a timer.
+ *
+ * @param[in] timeout
+ * This is the timeout specified in milli-seconds after which the timer
+ * will expire.
+ * @param[in] expiry
+ * Expiration routine which is called to indicate that the timer block
+ * has expired.
+ *
+ * @retval
+ * Success - Handle to the timer block
+ * @retval
+ * Error - <0
+ */
+Int32 timer_add (Uint32 timeout, void (*expiry)(void))
+{
+ Uint16 index;
+
+ /* Basic Validations: Ensure parameters passed are valid. */
+ if ((timeout == 0) || (expiry == NULL))
+ return -1;
+
+ /* Cycle through and find a free timer block. */
+ for (index = 0; index < MAX_TIMER_BLOCKS; index++)
+ {
+ /* Free timers can be identified using the expiry routine. NULL indicates
+ * that the timer block is free. */
+ if (timermcb.timer[index].expiry == NULL)
+ {
+ /* Found a free slot. Is this the first timer being created? */
+ if (timermcb.num_active_timers == 0)
+ {
+ /* YES. We need to start the device timer. */
+ if (dev_create_timer() < 0)
+ {
+ /* Device layer timer creation failed. We will not be able
+ * to get the timers operational without this API. So we
+ * might as well fail also. */
+ return -1;
+ }
+ }
+
+ /* Populate the timer block structure. */
+ timermcb.timer[index].expiry = expiry;
+ timermcb.timer[index].timeout = timeout;
+ timermcb.timer[index].org_timeout = timeout;
+
+ /* Increment the number of timers in the system */
+ timermcb.num_active_timers++;
+
+ /* Return the handle to the timer block. */
+ return index;
+ }
+ }
+
+ /* Control comes here indicating that there were no free timer slots. */
+ return -1;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function deletes a timer which was previously created.
+ *
+ * @param[in] handle
+ * This is the handle to the timer block to be deleted.
+ *
+ * @retval
+ * Not Applicable.
+ */
+void timer_delete (Int32 handle)
+{
+ /* Basic Validations: Ensure paramter is valid. */
+ if ((handle < 0) || (handle > MAX_TIMER_BLOCKS))
+ return;
+
+ /* Make sure there is at least one timer which is active; */
+ if (timermcb.num_active_timers > 0)
+ {
+ /* Simply reset the memory contents */
+ memset ((void *)&timermcb.timer[handle], 0, sizeof(TIMER_BLOCK));
+
+ /* Decrement the number of active timers in the system */
+ timermcb.num_active_timers--;
+
+ /* Check if there are any active timers in the system? */
+ if (timermcb.num_active_timers == 0)
+ {
+ /* No more active timers; we can delete the timer in the device layer. */
+ dev_delete_timer ();
+ }
+ }
+ return;
+}
+
+/**
+ * @b Description
+ * @n
+ * The function runs the timer scheduler. This API is required to be
+ * called by the boot modules and this in turn will decrement the various
+ * timer registered in the system and will call the appropriate
+ * expiration routines. If the boot modules fail to call this API then
+ * the timers will never expire.
+ *
+ * @retval
+ * Not Applicable.
+ */
+void timer_run (void)
+{
+ Uint16 index;
+
+ /* Check if there are any active timers in the System or not?
+ * If none are present; then we dont need to run the scheduler. */
+ if (timermcb.num_active_timers == 0)
+ return;
+
+ /* Check if the device timer has expired or not?
+ * If the timer has not expired there is no management to be done. */
+ if (dev_check_timer() == FALSE)
+ return;
+
+ /* Cycle through all the timer blocks and update them. */
+ for (index = 0; index < MAX_TIMER_BLOCKS; index++)
+ {
+ /* Is this an active timer? */
+ if (timermcb.timer[index].expiry != NULL)
+ {
+ /* YES. Decrement the timeout. */
+ timermcb.timer[index].timeout = timermcb.timer[index].timeout - 100;
+
+ /* Has the timer expired? */
+ if (timermcb.timer[index].timeout == 0)
+ {
+ /* Reset the timeouts */
+ timermcb.timer[index].timeout = timermcb.timer[index].org_timeout;
+
+ /* Call the expiration routine. */
+ timermcb.timer[index].expiry();
+ }
+
+ }
+ }
+ return;
+}
+
+
diff --git a/src/driver/timer/timer.h b/src/driver/timer/timer.h
--- /dev/null
+++ b/src/driver/timer/timer.h
@@ -0,0 +1,28 @@
+/**
+ * @file timer.h
+ *
+ * @brief
+ * The file has data structures and API definitions for the
+ * TIMER Module
+ *
+ * \par
+ * NOTE:
+ * (C) Copyright 2008, Texas Instruments, Inc.
+ *
+ * \par
+ */
+#ifndef __TIMER_H__
+#define __TIMER_H__
+
+
+/**********************************************************************
+ **************************** Exported Functions **********************
+ **********************************************************************/
+
+extern void timer_init(void);
+extern Int32 timer_add (Uint32 timeout, void (*expiry)(void));
+extern void timer_delete(Int32 handle);
+extern void timer_run (void);
+
+#endif /* __TIMER_H__ */
+
diff --git a/src/ecc/3byte/3byte_ecc.c b/src/ecc/3byte/3byte_ecc.c
--- /dev/null
@@ -0,0 +1,262 @@
+/******************************************************************************
+ * Copyright (c) 2010 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 Name: ecc.c
+ *
+ * Description: This file implements ECC algorithm used on micron NAND flash
+ *
+ * History:
+ * SEP/4/2009, Amit Solanki, Created the file
+ *
+ *****************************************************************************/
+/****************
+ * Include Files
+ ****************/
+#include "types.h"
+#include "ecc.h"
+
+/*********************************
+ * Defines and Macros and globals
+ *********************************/
+// Pre-calculated 256-way 1 byte column parity
+static const Uint8 nand_ecc_precalc_table[] = {
+ 0x00, 0x55, 0x56, 0x03, 0x59, 0x0c, 0x0f, 0x5a, 0x5a, 0x0f, 0x0c, 0x59, 0x03, 0x56, 0x55, 0x00,
+ 0x65, 0x30, 0x33, 0x66, 0x3c, 0x69, 0x6a, 0x3f, 0x3f, 0x6a, 0x69, 0x3c, 0x66, 0x33, 0x30, 0x65,
+ 0x66, 0x33, 0x30, 0x65, 0x3f, 0x6a, 0x69, 0x3c, 0x3c, 0x69, 0x6a, 0x3f, 0x65, 0x30, 0x33, 0x66,
+ 0x03, 0x56, 0x55, 0x00, 0x5a, 0x0f, 0x0c, 0x59, 0x59, 0x0c, 0x0f, 0x5a, 0x00, 0x55, 0x56, 0x03,
+ 0x69, 0x3c, 0x3f, 0x6a, 0x30, 0x65, 0x66, 0x33, 0x33, 0x66, 0x65, 0x30, 0x6a, 0x3f, 0x3c, 0x69,
+ 0x0c, 0x59, 0x5a, 0x0f, 0x55, 0x00, 0x03, 0x56, 0x56, 0x03, 0x00, 0x55, 0x0f, 0x5a, 0x59, 0x0c,
+ 0x0f, 0x5a, 0x59, 0x0c, 0x56, 0x03, 0x00, 0x55, 0x55, 0x00, 0x03, 0x56, 0x0c, 0x59, 0x5a, 0x0f,
+ 0x6a, 0x3f, 0x3c, 0x69, 0x33, 0x66, 0x65, 0x30, 0x30, 0x65, 0x66, 0x33, 0x69, 0x3c, 0x3f, 0x6a,
+ 0x6a, 0x3f, 0x3c, 0x69, 0x33, 0x66, 0x65, 0x30, 0x30, 0x65, 0x66, 0x33, 0x69, 0x3c, 0x3f, 0x6a,
+ 0x0f, 0x5a, 0x59, 0x0c, 0x56, 0x03, 0x00, 0x55, 0x55, 0x00, 0x03, 0x56, 0x0c, 0x59, 0x5a, 0x0f,
+ 0x0c, 0x59, 0x5a, 0x0f, 0x55, 0x00, 0x03, 0x56, 0x56, 0x03, 0x00, 0x55, 0x0f, 0x5a, 0x59, 0x0c,
+ 0x69, 0x3c, 0x3f, 0x6a, 0x30, 0x65, 0x66, 0x33, 0x33, 0x66, 0x65, 0x30, 0x6a, 0x3f, 0x3c, 0x69,
+ 0x03, 0x56, 0x55, 0x00, 0x5a, 0x0f, 0x0c, 0x59, 0x59, 0x0c, 0x0f, 0x5a, 0x00, 0x55, 0x56, 0x03,
+ 0x66, 0x33, 0x30, 0x65, 0x3f, 0x6a, 0x69, 0x3c, 0x3c, 0x69, 0x6a, 0x3f, 0x65, 0x30, 0x33, 0x66,
+ 0x65, 0x30, 0x33, 0x66, 0x3c, 0x69, 0x6a, 0x3f, 0x3f, 0x6a, 0x69, 0x3c, 0x66, 0x33, 0x30, 0x65,
+ 0x00, 0x55, 0x56, 0x03, 0x59, 0x0c, 0x0f, 0x5a, 0x5a, 0x0f, 0x0c, 0x59, 0x03, 0x56, 0x55, 0x00
+};
+
+/******************************************************************************
+ *
+ * Function: nandTransResult
+ *
+ * Description: Creates non-inverted ECC code from line parity
+ *
+ * Parameters: Uint8 uchReg2 - line parity reg 2
+ * Uint8 uchReg3 - line parity reg 3
+ * Uint8 *puchEccCode - ecc
+ *
+ * Return Value: void
+ ******************************************************************************/
+static void nandTransResult(Uint8 uchReg2, Uint8 uchReg3, Uint8 *puchEccCode)
+{
+ Uint8 a, b, i, tmp1, tmp2;
+
+ /* Initialize variables */
+ a = b = 0x80;
+ tmp1 = tmp2 = 0;
+
+ /* Calculate first ECC byte */
+ for (i = 0; i < 4; i++) {
+ if (uchReg3 & a) /* LP15,13,11,9 --> ecc_code[0] */
+ tmp1 |= b;
+ b >>= 1;
+ if (uchReg2 & a) /* LP14,12,10,8 --> ecc_code[0] */
+ tmp1 |= b;
+ b >>= 1;
+ a >>= 1;
+ }
+
+ /* Calculate second ECC byte */
+ b = 0x80;
+ for (i = 0; i < 4; i++) {
+ if (uchReg3 & a) /* LP7,5,3,1 --> ecc_code[1] */
+ tmp2 |= b;
+ b >>= 1;
+ if (uchReg2 & a) /* LP6,4,2,0 --> ecc_code[1] */
+ tmp2 |= b;
+ b >>= 1;
+ a >>= 1;
+ }
+
+ /* Store two of the ECC bytes */
+ puchEccCode[0] = tmp1;
+ puchEccCode[1] = tmp2;
+}
+/******************************************************************************
+ *
+ * Function: eccComputeECC
+ *
+ * Description: Compute 3 byte ECC code for 256 byte block
+ *
+ * Parameters: Uint8* puchData - pointer to raw data
+ * Uint8 *puchEccCode - pointer to ECC buffer
+ *
+ * Return Value: status
+ ******************************************************************************/
+Int32 eccComputeECC(const Uint8 *puchData, Uint8 *puchEccCode)
+{
+ Uint8 uchIndex, uchReg1, uchReg2, uchReg3;
+ int j;
+ if(puchData == NULL || puchEccCode == NULL)
+ return ECC_FAIL;
+
+ /* Initialize variables */
+ uchReg1 = uchReg2 = uchReg3 = 0;
+ puchEccCode[0] = puchEccCode[1] = puchEccCode[2] = 0;
+
+ /* Build up column parity */
+ for(j = 0; j < 256; j++) {
+
+ /* Get CP0 - CP5 from table */
+ uchIndex = nand_ecc_precalc_table[puchData[j]];
+ uchReg1 ^= (uchIndex & 0x3f);
+
+ /* All bit XOR = 1 ? */
+ if (uchIndex & 0x40) {
+ uchReg3 ^= (Uint8) j;
+ uchReg2 ^= ~((Uint8) j);
+ }
+ }
+
+ /* Create non-inverted ECC code from line parity */
+ nandTransResult(uchReg2, uchReg3, puchEccCode);
+
+ /* Calculate final ECC code */
+ puchEccCode[0] = ~puchEccCode[0];
+ puchEccCode[1] = ~puchEccCode[1];
+ puchEccCode[2] = ((~uchReg1) << 2) | 0x03;
+ return ECC_SUCCESS;
+}
+
+
+/******************************************************************************
+ *
+ * Function: eccCorrectData
+ *
+ * Description: Detect and correct a 1 bit error for 256 byte block
+ *
+ * Parameters: Uint8* puchData - Raw data read from the chip
+ * Uint8 *puchEccRead - ECC from the chip
+ * Uint8 *puchEccCalc - ECC calculated from raw data
+ *
+ * Return Value: status
+ ******************************************************************************/
+Int32 eccCorrectData(Uint8 *puchData, Uint8 *puchEccRead, Uint8 *puchEccCalc)
+{
+ Uint8 a, b, c, d1, d2, d3, add, bit, i;
+
+ if(puchData == NULL || puchEccRead == NULL || puchEccCalc == NULL)
+ return ECC_FAIL;
+
+ /* Do error detection */
+ d1 = puchEccCalc[0] ^ puchEccRead[0];
+ d2 = puchEccCalc[1] ^ puchEccRead[1];
+ d3 = puchEccCalc[2] ^ puchEccRead[2];
+
+ if ((d1 | d2 | d3) == 0) {
+ /* No errors */
+ return ECC_SUCCESS;
+ }
+ else {
+ a = (d1 ^ (d1 >> 1)) & 0x55;
+ b = (d2 ^ (d2 >> 1)) & 0x55;
+ c = (d3 ^ (d3 >> 1)) & 0x54;
+
+ /* Found and will correct single bit error in the data */
+ if ((a == 0x55) && (b == 0x55) && (c == 0x54)) {
+ c = 0x80;
+ add = 0;
+ a = 0x80;
+ for (i=0; i<4; i++) {
+ if (d1 & c)
+ add |= a;
+ c >>= 2;
+ a >>= 1;
+ }
+ c = 0x80;
+ for (i=0; i<4; i++) {
+ if (d2 & c)
+ add |= a;
+ c >>= 2;
+ a >>= 1;
+ }
+ bit = 0;
+ b = 0x04;
+ c = 0x80;
+ for (i=0; i<3; i++) {
+ if (d3 & c)
+ bit |= b;
+ c >>= 2;
+ b >>= 1;
+ }
+ b = 0x01;
+ a = puchData[add];
+ a ^= (b << bit);
+ puchData[add] = a;
+ return ECC_SUCCESS;
+ } else {
+ i = 0;
+ while (d1) {
+ if (d1 & 0x01)
+ ++i;
+ d1 >>= 1;
+ }
+ while (d2) {
+ if (d2 & 0x01)
+ ++i;
+ d2 >>= 1;
+ }
+ while (d3) {
+ if (d3 & 0x01)
+ ++i;
+ d3 >>= 1;
+ }
+ if (i == 1) {
+ /* ECC Code Error Correction */
+ puchEccRead[0] = puchEccCalc[0];
+ puchEccRead[1] = puchEccCalc[1];
+ puchEccRead[2] = puchEccCalc[2];
+ return ECC_SUCCESS;
+ }
+ else {
+ /* Uncorrectable Error */
+ return ECC_FAIL;
+ }
+ }
+ }
+}
diff --git a/src/ecc/c64x/make/makefile b/src/ecc/c64x/make/makefile
--- /dev/null
@@ -0,0 +1,42 @@
+#*************************************************************************************
+#* FILE NAME: makefile
+#*
+#* DESCRIPTION: Makes the ECC module for the IBL
+#*
+#*************************************************************************************/
+
+ifndef IBL_ROOT
+ export IBL_ROOT= ../../..
+endif
+
+ECODIR= $(IBL_ROOT)/ecc
+
+CSRC= 3byte_ecc.c
+
+.PHONY: ecc
+
+
+include $(IBL_ROOT)/make/$(ARCH)/makeeco.mk
+
+
+
+C6X_C_DIR= $(IBL_ROOT)
+C6X_C_DIR+= ;$(IBL_ROOT)/arch/$(ARCH)
+C6X_C_DIR+= ;$(ECODIR)
+C6X_C_DIR+= ;$(STDINC)
+export C6X_C_DIR
+
+vpath % $(ECODIR)/3byte
+
+
+ecc: gen_cdefdep makefile $(OBJS)
+
+
+$(OBJS): cdefdep
+
+gen_cdefdep:
+ @echo Checking command line dependencies
+ @echo $(ENDIAN) $(TARGET) > cdefdep.tmp
+ @sh -c 'if diff -q cdefdep.tmp cdefdep ; then echo same ; else $(CP) cdefdep.tmp cdefdep ; fi '
+
+
diff --git a/src/ecc/ecc.h b/src/ecc/ecc.h
--- /dev/null
+++ b/src/ecc/ecc.h
@@ -0,0 +1,21 @@
+/*******************************************************************************************
+ * FILE PURPOSE: Define the ECC api used by all ECC algorithms
+ *******************************************************************************************
+ * FILE NAME: ecc.h
+ *
+ * DESCRIPTION: The API used by all software CRCs is defined
+ *
+ * @file ecc.h
+ *
+ * @brief
+ * The API used by all software CRCs is defined
+ *
+ *******************************************************************************************/
+#include "types.h"
+
+
+#define ECC_SUCCESS 0
+#define ECC_FAIL -1
+
+Int32 eccCorrectData(Uint8 *puchData, Uint8 *puchEccRead, Uint8 *puchEccCalc);
+Int32 eccComputeECC(const Uint8 *puchData, Uint8 *puchEccCode);
diff --git a/src/ethboot/c64x/make/makefile b/src/ethboot/c64x/make/makefile
--- /dev/null
@@ -0,0 +1,46 @@
+#*************************************************************************************
+#* FILE NAME: makefile
+#*
+#* DESCRIPTION: Makes the ethernet module for the IBL
+#*
+#*************************************************************************************/
+
+ifndef IBL_ROOT
+ export IBL_ROOT= ../../..
+endif
+
+ECODIR= $(IBL_ROOT)/ethboot
+
+CSRC= ethboot.c
+
+.PHONY: ethboot
+
+
+include $(IBL_ROOT)/make/$(ARCH)/makeeco.mk
+
+
+
+C6X_C_DIR+= $(IBL_ROOT)
+C6X_C_DIR+= ;$(IBL_ROOT)/arch/$(ARCH)
+C6X_C_DIR+= ;$(IBL_ROOT)/device
+C6X_C_DIR+= ;$(IBL_ROOT)/device/$(TARGET)
+C6X_C_DIR+= ;$(IBL_ROOT)/ethboot
+C6X_C_DIR+= ;$(IBL_ROOT)/driver/eth
+C6X_C_DIR+= ;$(STDINC)
+C6X_C_DIR+= ;$(IBL_ROOT)/hw/macs
+C6X_C_DIR+= ;$(IBL_ROOT)/hw/mdio
+export C6X_C_DIR
+
+
+
+ethboot: gen_cdefdep makefile $(OBJS)
+
+
+$(OBJS): cdefdep
+
+gen_cdefdep:
+ @echo Checking command line dependencies
+ @echo $(ENDIAN) $(TARGET) > cdefdep.tmp
+ @sh -c 'if diff -q cdefdep.tmp cdefdep ; then echo same ; else $(CP) cdefdep.tmp cdefdep ; fi '
+
+
diff --git a/src/ethboot/ethboot.c b/src/ethboot/ethboot.c
--- /dev/null
+++ b/src/ethboot/ethboot.c
@@ -0,0 +1,233 @@
+/*********************************************************************************
+ * FILE PURPOSE: The Ethernet boot wrapper
+ *********************************************************************************
+ * FILE NAME: ethboot.c
+ *
+ * DESCRIPTION: This file provides the ethernet boot wrapper used by IBL modules
+ *
+ * @file ethboot.c
+ *
+ * @brief
+ * The ethernet boot wrapper
+ *
+ ***********************************************************************************/
+#include "types.h"
+#include "ibl.h"
+#include "iblloc.h"
+#include "ethboot.h"
+#include "net.h"
+#include "cpmacdrv.h"
+#include "device.h"
+#include "mdioapi.h"
+#include <string.h>
+
+
+/* Convert an IP address from unsigned char to IPN (uint32) */
+#define FORM_IPN(x) ( (x[0] << 24) | \
+ (x[1] << 16) | \
+ (x[2] << 8) | \
+ (x[3] << 0) )
+
+#define UNFORM_IPN(x,y) (x)[0] = (y) >> 24; \
+ (x)[1] = (y) >> 16; \
+ (x)[2] = (y) >> 8; \
+ (x)[3] = (y) >> 0
+
+#define MIN(a,b) ((a) < (b)) ? (a) : (b)
+
+static bool have_params;
+
+/* Receive a call back when the boot file name is known */
+void ibl_rec_params (void *params)
+{
+ NET_DRV_DEVICE *netdev = (NET_DRV_DEVICE *)params;
+
+ have_params = TRUE;
+
+ /* Copy the information to the status fields */
+ UNFORM_IPN(iblStatus.ethParams.ipAddr, netdev->ip_address);
+ UNFORM_IPN(iblStatus.ethParams.serverIp, netdev->server_ip);
+
+ memcpy (iblStatus.ethParams.hwAddress, netdev->mac_address, sizeof(iblStatus.ethParams.hwAddress));
+ strncpy (iblStatus.ethParams.fileName, netdev->file_name, sizeof(iblStatus.ethParams.fileName));
+
+}
+
+
+void iblEthBoot (Int32 eIdx)
+{
+ NET_DRV_DEVICE nDevice;
+ Uint32 nl;
+ Uint32 entry;
+ Int32 n;
+ Int32 dataSize;
+ Int32 format;
+ void (*exit)();
+ uint8 buf[16];
+ char *ext;
+
+
+
+ /* Power up the device. No action is taken if the device is already powered up */
+ if (devicePowerPeriph (TARGET_PWR_ETH(ibl.ethConfig[eIdx].port)) < 0)
+ return;
+
+ /* Do any mdio configuration */
+ if (ibl.mdioConfig.nMdioOps > 0)
+ hwMdio (ibl.mdioConfig.nMdioOps, ibl.mdioConfig.mdio,
+ ibl.mdioConfig.mdioClkDiv, ibl.mdioConfig.interDelay);
+
+
+ nDevice.port_num = ibl.ethConfig[eIdx].port;
+
+ /* Simple transation to initialize the driver */
+ memcpy (nDevice.mac_address, ibl.ethConfig[eIdx].ethInfo.hwAddress, sizeof(nDevice.mac_address));
+
+ nl = FORM_IPN(ibl.ethConfig[eIdx].ethInfo.ipAddr);
+ if (ibl.ethConfig[eIdx].doBootp == TRUE)
+ nDevice.ip_address = 0;
+ else
+ nDevice.ip_address = htonl(nl);
+
+ nl = FORM_IPN(ibl.ethConfig[eIdx].ethInfo.netmask);
+ nDevice.net_mask = htonl(nl);
+
+ nl = FORM_IPN(ibl.ethConfig[eIdx].ethInfo.serverIp);
+ nDevice.server_ip = htonl(nl);
+ nDevice.use_bootp_server_ip = ibl.ethConfig[eIdx].useBootpServerIp;
+
+ /* Note - the file name structure in nDevice is only 64 bytes, but 128 in ethInfo */
+ memcpy (nDevice.file_name, ibl.ethConfig[eIdx].ethInfo.fileName, sizeof(nDevice.file_name));
+ nDevice.use_bootp_file_name = ibl.ethConfig[eIdx].useBootpFileName;
+
+
+ nDevice.start = cpmac_drv_start;
+ nDevice.stop = cpmac_drv_stop;
+ nDevice.send = cpmac_drv_send;
+ nDevice.receive = cpmac_drv_receive;
+
+
+ /* have_params will be set to true in the tftp call back. It must be
+ * set to false before opening the module, since the call back will
+ * be from the open call if bootp is not used */
+ have_params = FALSE;
+
+ /* Open the network device */
+ if ((*net_boot_module.open) ((void *)&nDevice, ibl_rec_params) != 0)
+ return;
+
+ /* Wait for the callback with the requested filename */
+ while (have_params == FALSE) {
+
+ if ((*net_boot_module.peek) ((uint8 *)&nl, sizeof(nl)) < 0) {
+
+ (*net_boot_module.close)();
+ return;
+ }
+ }
+
+ format = ibl.ethConfig[eIdx].bootFormat;
+
+ /* If the data format was based on the name extension, determine
+ * the boot data format */
+ if (format == ibl_BOOT_FORMAT_NAME) {
+
+ ext = strrchr (iblStatus.ethParams.fileName, '.');
+
+ if (ext != NULL) {
+
+ if (!strcmp (ext, ".bis"))
+ format = ibl_BOOT_FORMAT_BIS;
+
+ else if (!strcmp (ext, ".ais"))
+ format = ibl_BOOT_FORMAT_BIS;
+
+ else if (!strcmp (ext, ".out"))
+ format = ibl_BOOT_FORMAT_COFF;
+
+ else if (!strcmp (ext, ".coff"))
+ format = ibl_BOOT_FORMAT_COFF;
+
+ else if (!strcmp (ext, ".btbl"))
+ format = ibl_BOOT_FORMAT_BTBL;
+
+ else if (!strcmp (ext, ".bin"))
+ format = ibl_BOOT_FORMAT_BBLOB;
+
+ else if (!strcmp (ext, ".blob"))
+ format = ibl_BOOT_FORMAT_BBLOB;
+
+ }
+
+ /* Name match failed it didn't change */
+ if (format == ibl_BOOT_FORMAT_NAME) {
+
+ iblStatus.nameDetectFailCnt += 1;
+
+ /* Close up the peripheral */
+ (*net_boot_module.close)();
+
+ return;
+ }
+
+ }
+
+ entry = iblBoot (&net_boot_module, format, &ibl.ethConfig[eIdx].blob);
+
+
+ /* Before closing the module read any remaining data. In the coff boot mode the boot may
+ * detect an exit before the entire file has been read. Read the rest of the file
+ * to make the server happy */
+
+ do {
+
+ dataSize = (*net_boot_module.query)(); /* Will return -1 when the data is done */
+
+ if (dataSize > 0) {
+
+ while (dataSize > 0) {
+
+ n = MIN(dataSize, sizeof(buf));
+ (*net_boot_module.read)(buf, n);
+ dataSize = dataSize - n;
+ }
+
+ /* Do not peek if the data size returned in the query was > 0 */
+ } else if (dataSize == 0) {
+
+ (*net_boot_module.peek)(buf, 1);
+ }
+
+ } while (dataSize >= 0);
+
+
+
+ /* Close up the peripheral */
+ (*net_boot_module.close)();
+
+ if (entry != 0) {
+
+ iblStatus.exitAddress = entry;
+ exit = (void (*)())entry;
+ (*exit)();
+
+ }
+
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ethboot/ethboot.h b/src/ethboot/ethboot.h
--- /dev/null
+++ b/src/ethboot/ethboot.h
@@ -0,0 +1,35 @@
+/*****************************************************************************
+ * FILE PURPOSE: Define the Ethernet boot wrapper
+ *****************************************************************************
+ * FILE NAME: ethboot.h
+ *
+ * DESCRIPTION: This file defines the ethernet wrapper used by IBL modules
+ *
+ * @file ethboot.h
+ *
+ * @brief
+ * The ethernet boot wrapper API is defined
+ *
+ *****************************************************************************/
+
+#ifndef ETHBOOT_H
+#define ETHBOOT_H
+
+#include "types.h"
+
+/**
+ * @brief
+ * Attempt an enternet boot
+ *
+ * @details
+ * The IBL will attempt to boot over the ethernet device
+ */
+void iblEthBoot (int32 eIdx);
+
+
+
+#endif /* ETHBOOT_H */
+
+
+
+
diff --git a/src/hw/c64x/make/makefile b/src/hw/c64x/make/makefile
--- /dev/null
@@ -0,0 +1,75 @@
+#**************************************************************************
+#* FILE NAME: makefile
+#*
+#* DESCRIPTION: Makes the low level drivers for the hardware modules
+#*
+#**************************************************************************
+
+ifndef IBL_ROOT
+ export IBL_ROOT=../../..
+endif
+
+ECODIR= $(IBL_ROOT)/hw
+
+ifeq ($(TARGET),c6472)
+ CSRC= t64.c cpmacdrv.c pll.c psc.c emif31.c mdio.c gpio.c nandgpio.c i2c.c
+endif
+
+.PHONY: hw
+
+
+include $(IBL_ROOT)/make/$(ARCH)/makeeco.mk
+
+
+C6X_C_DIR= $(IBL_ROOT)
+C6X_C_DIR+= ;$(IBL_ROOT)/arch/$(ARCH)
+C6X_C_DIR+= ;$(ECODIR)
+C6X_C_DIR+= ;$(STDINC)
+C6X_C_DIR+= ;$(IBL_ROOT)/cfg/$(TARGET)
+C6X_C_DIR+= ;$(IBL_ROOT)/hw/timer
+C6X_C_DIR+= ;$(IBL_ROOT)/hw/macs/cpmac
+C6X_C_DIR+= ;$(IBL_ROOT)/driver/eth
+C6X_C_DIR+= ;$(IBL_ROOT)/device
+C6X_C_DIR+= ;$(IBL_ROOT)/device/$(TARGET)
+C6X_C_DIR+= ;$(IBL_ROOT)/hw/plls
+C6X_C_DIR+= ;$(IBL_ROOT)/hw/pscs
+C6X_C_DIR+= ;$(IBL_ROOT)/hw/mdio
+C6X_C_DIR+= ;$(IBL_ROOT)/hw/gpio
+C6X_C_DIR+= ;$(IBL_ROOT)/hw/nands
+C6X_C_DIR+= ;$(IBL_ROOT)/hw/nands/gpio
+C6X_C_DIR+= ;$(IBL_ROOT)/hw/i2c
+C6X_C_DIR+= ;$(IBL_ROOT)/ecc
+export C6X_C_DIR
+
+
+vpath % $(ECODIR)/timer/timer64
+
+ifeq ($(TARGET),c6472)
+ vpath % $(ECODIR)/macs/cpmac
+ vpath % $(ECODIR)/plls/pllxx1p8
+ vpath % $(ECODIR)/pscs/psc2
+ vpath % $(ECODIR)/ddrs/emif31
+ vpath % $(ECODIR)/mdio
+ vpath % $(ECODIR)/gpio
+ vpath % $(ECODIR)/nands/gpio
+ vpath % $(ECODIR)/i2c
+endif
+
+
+hw: gen_cdefdep makefile $(OBJS)
+
+$(OBJS): cdefdep
+
+
+gen_cdefdep:
+ @echo Checking command line dependencies
+ @echo $(ENDIAN) $(TARGET) $(ARCH) > cdefdep.tmp
+ @sh -c 'if diff -q cdefdep.tmp cdefdep ; then echo same ; else $(CP) cdefdep.tmp cdefdep ; fi '
+
+
+
+
+
+
+
+
diff --git a/src/hw/ddrs/emif31/emif31.c b/src/hw/ddrs/emif31/emif31.c
--- /dev/null
@@ -0,0 +1,44 @@
+/************************************************************************************
+ * FILE PURPOSE: The emif 3.1 driver
+ ************************************************************************************
+ * FILE NAME: emif31.c
+ *
+ * DESCRIPTION: The emif controller is setup
+ *
+ * @file emif31.c
+ *
+ * @brief
+ * The emif controller is setup
+ *
+ **************************************************************************************/
+#include "types.h"
+#include "ibl.h"
+#include "emif31api.h"
+#include "emif31loc.h"
+#include "target.h"
+
+#define DEVICE_REG32_W(x,y) *(volatile unsigned int *)(x)=(y)
+#define DEVICE_REG32_R(x) (*(volatile unsigned int *)(x))
+
+void hwEmif3p1Enable (iblEmif3p1_t *cfg)
+{
+ uint32 v;
+
+ v = cfg->sdcfg | (1 << 15); /* Unlock */
+ DEVICE_REG32_W (DEVICE_DDR_BASE + DDR_REG_SDCFG, v);
+
+ DEVICE_REG32_W (DEVICE_DDR_BASE + DDR_REG_SDRFC, cfg->sdrfc);
+ DEVICE_REG32_W (DEVICE_DDR_BASE + DDR_REG_SDTIM1, cfg->sdtim1);
+ DEVICE_REG32_W (DEVICE_DDR_BASE + DDR_REG_SDTIM2, cfg->sdtim2);
+ DEVICE_REG32_W (DEVICE_DDR_BASE + DDR_REG_DMCCTL, cfg->dmcctl);
+
+ v = cfg->sdcfg & (~(1 << 15)); /* lock */
+ DEVICE_REG32_W (DEVICE_DDR_BASE + DDR_REG_SDCFG, v);
+
+}
+
+
+
+
+
+
diff --git a/src/hw/ddrs/emif31/emif31api.h b/src/hw/ddrs/emif31/emif31api.h
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef EMIF31API_H
+#define EMIF31API_H
+/********************************************************************************
+ * FILE PURPOSE: Define the emif 3.1 API to the applicaiton
+ ********************************************************************************
+ * FILE NAME: emif31api.h
+ *
+ * DESCRIPTION: Defines the user API to the emif 3.1 driver
+ *
+ * @file emif31api.h
+ *
+ * @brief
+ * The Driver API is defined
+ *
+ ********************************************************************************/
+#include "types.h"
+#include "ibl.h"
+
+
+void hwEmif3p1Enable (iblEmif3p1_t *cfg);
+
+
+
+#endif /* EMIF31API_H */
+
diff --git a/src/hw/ddrs/emif31/emif31loc.h b/src/hw/ddrs/emif31/emif31loc.h
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef EMIF31LOC_H
+#define EMIF31LOC_H
+/***********************************************************************************
+ * FILE PURPOSE: Provide EMIF controller definitions
+ ***********************************************************************************
+ * FILE NAME: emif31loc.h
+ *
+ * DESCRIPTION: The EMIF controller is defined
+ *
+ * @file emif31loc.h
+ *
+ * @brief
+ * The EMIF controller is defined
+ *
+ **********************************************************************************/
+
+/* Offsets from the peripheral base */
+#define DDR_REG_SDCFG 0x08
+#define DDR_REG_SDRFC 0x0c
+#define DDR_REG_SDTIM1 0x10
+#define DDR_REG_SDTIM2 0x14
+#define DDR_REG_DMCCTL 0xe4
+
+
+
+
+
+#endif /* EMIF31LOC_H */
diff --git a/src/hw/gpio/gpio.c b/src/hw/gpio/gpio.c
--- /dev/null
+++ b/src/hw/gpio/gpio.c
@@ -0,0 +1,351 @@
+/******************************************************************************
+ * Copyright (c) 2010 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 Name: gpio.c
+ *
+ * Description: This file contains the lower level function to access GPIO
+ *
+ * History:
+ * JUL/22/2009, Amit Solanki, Created the file
+ * SEP/01/2009, Amit Solanki, Updated the documentation
+ *
+ *****************************************************************************/
+/****************
+ * Include Files
+ ****************/
+#include "types.h"
+#include "gpio.h"
+#include "target.h"
+
+/******************************************************************************
+ *
+ * Function: hwGpioSetDirection
+ *
+ * Description: This function configures the specified GPIO's direction
+ *
+ * Parameters: uiNumber - GPIO number to configure
+ * direction - GPIO_OUT or GPIO_IN
+ *
+ * Return Value: void
+ *
+ *****************************************************************************/
+void hwGpioSetDirection( Uint32 uiNumber, GpioDirection direction )
+{
+ Uint32* puiGpioDir = ( Uint32*)GPIO_DIR_REG;
+
+ if ( direction == GPIO_OUT )
+ *puiGpioDir = *puiGpioDir & ~(1 << uiNumber); // Set to OUTPUT
+ else
+ *puiGpioDir = *puiGpioDir | (1 << uiNumber); // Set to INTPUT
+}
+
+/******************************************************************************
+ *
+ * Function: hwGpioSetDataBusDirection
+ *
+ * Description: This function configures the GPIO[7:0]'s direction
+ *
+ * Parameters: direction - GPIO_OUT or GPIO_IN
+ *
+ * Return Value: void
+ *
+ *****************************************************************************/
+void hwGpioSetDataBusDirection( GpioDirection direction )
+{
+ Uint32* puiGpioDir = ( Uint32*)GPIO_DIR_REG;
+
+ if ( direction == GPIO_OUT )
+ *puiGpioDir = *puiGpioDir & 0xffffff00; // Set to OUTPUT
+ else
+ *puiGpioDir = *puiGpioDir | 0x000000ff; // Set to INTPUT
+}
+
+/******************************************************************************
+ *
+ * Function: hwGpioSetOutput
+ *
+ * Description: This function sets the specified GPIO's pin state to 1
+ *
+ * Parameters: uiNumber - GPIO number to configure
+ *
+ * Return Value: void
+ *
+ * Pre-Condition: The specified GPIO should be configured as output
+ *
+ *****************************************************************************/
+void hwGpioSetOutput( Uint32 uiNumber)
+{
+ Uint32* puiGpioSet = (Uint32*) GPIO_SET_DATA_REG;
+ *puiGpioSet = ( 1 << (uiNumber % 32) ); // Set to 1
+}
+
+/******************************************************************************
+ *
+ * Function: hwGpioClearOutput
+ *
+ * Description: This function Clears the specified GPIO's pin state to 0
+ *
+ * Parameters: uiNumber - GPIO number to configure
+ *
+ * Return Value: void
+ *
+ * Pre-Condition: The specified GPIO should be configured as output
+ *
+ *****************************************************************************/
+void hwGpioClearOutput( Uint32 uiNumber)
+{
+ Uint32* puiGpioClear = (Uint32*) GPIO_CLEAR_DATA_REG;
+ *puiGpioClear = ( 1 << (uiNumber % 32) ); // Clear to 0
+}
+
+/******************************************************************************
+ *
+ * Function: hwGpioReadInput
+ *
+ * Description: This function gets the specified GPIO's pin state
+ *
+ * Parameters: uiNumber - GPIO number to configure
+ *
+ * Return Value: Uint32 - Input state of GPIO if success
+ * - else GPIO status
+ *
+ * Pre-Condition: The specified GPIO should be configured as input
+ *
+ *****************************************************************************/
+Uint32 hwGpioReadInput( Uint32 uiNumber )
+{
+ Uint32* puiGpioInput = (Uint32*)GPIO_IN_DATA_REG;
+ if(uiNumber > GPIO_MAX_NUMBER)
+ return INVALID_GPIO_NUMBER;
+
+ if( ( (*puiGpioInput >> uiNumber) & GPIO_HIGH) == GPIO_HIGH)
+ return GPIO_HIGH;
+ else
+ return GPIO_LOW;
+}
+
+/******************************************************************************
+ *
+ * Function: hwGpioWriteDataBus
+ *
+ * Description: This function sets the GPIO[7:0] pins state
+ *
+ * Parameters: uchValue - Value to set as output
+ *
+ * Return Value: void
+ *
+ * Pre-Condition: The GPIO[7:0] should be configured as output
+ *
+ *****************************************************************************/
+void hwGpioWriteDataBus ( Uint8 uchValue )
+{
+ Uint32* puiGpioOutput = (Uint32*) GPIO_OUT_DATA_REG;
+ *puiGpioOutput = ( (*puiGpioOutput & 0xffffff00) | uchValue );
+}
+
+/******************************************************************************
+ *
+ * Function: hwGpioClearDataBus
+ *
+ * Description: This function sets the value to the Clear data register
+ *
+ * Parameters: uchValue - Value to set as output
+ *
+ * Return Value: void
+ *
+ * Pre-Condition: None
+ *
+ *****************************************************************************/
+void hwGpioClearDataBus(Uint8 uchValue)
+{
+ Uint32* puiGpioOutput = (Uint32*) GPIO_CLEAR_DATA_REG;
+ *puiGpioOutput = uchValue;
+}
+
+/******************************************************************************
+ *
+ * Function: hwGpioSetDataBus
+ *
+ * Description: This function sets the value to the Set data register
+ *
+ * Parameters: uchValue - Value to set as output
+ *
+ * Return Value: void
+ *
+ * Pre-Condition: None
+ *
+ *****************************************************************************/
+void hwGpioSetDataBus(Uint8 uchValue)
+{
+ Uint32* puiGpioOutput = (Uint32*) GPIO_SET_DATA_REG;
+ *puiGpioOutput = uchValue;
+}
+
+/******************************************************************************
+ *
+ * Function: hwGpioReadDataBus
+ *
+ * Description: This function gets the GPIO[7:0] pins state
+ *
+ * Parameters: void
+ *
+ * Return Value: Uint8 - Input state of GPIO[7:0]
+ *
+ * Pre-Condition: The GPIO[7:0] should be configured as input
+ *
+ *****************************************************************************/
+Uint8 hwGpioReadDataBus( void )
+{
+ Uint8* puchGpioInput = (Uint8*)GPIO_IN_DATA_REG;
+ return *puchGpioInput;
+}
+
+/******************************************************************************
+ *
+ * Function: hwGpioEnableGlobalInterrupt
+ *
+ * Description: This function Enables GPIO interrupts to CPU
+ *
+ * Parameters: void
+ *
+ * Return Value: void
+ *
+ *****************************************************************************/
+void hwGpioEnableGlobalInterrupt( void )
+{
+ Uint32* puiGpioInterrupt = (Uint32*)GPIO_BINTEN_REG;
+ *puiGpioInterrupt = 0x01;
+}
+
+/******************************************************************************
+ *
+ * Function: hwGpioDisableGlobalInterrupt
+ *
+ * Description: This function Disables GPIO interrupts to CPU
+ *
+ * Parameters: void
+ *
+ * Return Value: void
+ *
+ *****************************************************************************/
+void hwGpioDisableGlobalInterrupt( void )
+{
+ Uint32* puiGpioInterrupt = (Uint32*)GPIO_BINTEN_REG;
+ *puiGpioInterrupt = 0x00;
+}
+
+/******************************************************************************
+ *
+ * Function: hwGpioSetRisingEdgeInterrupt
+ *
+ * Description: This function sets specified GPIO's rising edge interrupt
+ *
+ * Parameters: uiNumber - GPIO number to configure
+ *
+ * Return Value: void
+ *
+ *****************************************************************************/
+void hwGpioSetRisingEdgeInterrupt( Uint32 uiNumber )
+{
+ Uint32* puiGpioSetRisingEdge = (Uint32*)GPIO_SET_RIS_TRIG_REG;
+ *puiGpioSetRisingEdge = (1 << uiNumber);
+}
+
+/******************************************************************************
+ *
+ * Function: hwGpioClearRisingEdgeInterrupt
+ *
+ * Description: This function clears specified GPIO's rising edge interrupt
+ *
+ * Parameters: uiNumber - GPIO number to configure
+ *
+ * Return Value: void
+ *
+ *****************************************************************************/
+void hwGpioClearRisingEdgeInterrupt( Uint32 uiNumber )
+{
+ Uint32* puiGpioClearRisingEdge = (Uint32*)GPIO_CLR_RIS_TRIG_REG;
+ *puiGpioClearRisingEdge = (1 << uiNumber);
+}
+
+/******************************************************************************
+ *
+ * Function: hwGpioSetFallingEdgeInterrupt
+ *
+ * Description: This function sets specified GPIO's falling edge interrupt
+ *
+ * Parameters: uiNumber - GPIO number to configure
+ *
+ * Return Value: void
+ *
+ *****************************************************************************/
+void hwGpioSetFallingEdgeInterrupt( Uint32 uiNumber )
+{
+ Uint32* puiGpioSetFallingEdge = (Uint32*)GPIO_SET_FAL_TRIG_REG;
+ *puiGpioSetFallingEdge = (1 << uiNumber);
+}
+
+/******************************************************************************
+ *
+ * Function: hwGpioClearFallingEdgeInterrupt
+ *
+ * Description: This function clears specified GPIO's falling edge interrupt
+ *
+ * Parameters: uiNumber - GPIO number to configure
+ *
+ * Return Value: void
+ *
+ *****************************************************************************/
+void hwGpioClearFallingEdgeInterrupt( Uint32 uiNumber )
+{
+ Uint32* puiGpioClearFallingEdge = (Uint32*)GPIO_CLR_FAL_TRIG_REG;
+ *puiGpioClearFallingEdge = (1 << uiNumber);
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/hw/gpio/gpio.h b/src/hw/gpio/gpio.h
--- /dev/null
+++ b/src/hw/gpio/gpio.h
@@ -0,0 +1,139 @@
+/******************************************************************************
+ * Copyright (c) 2010 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 Name: gpio.h
+ *
+ * Description: This file is the header file for GPIO module
+ *
+ * History:
+ * JUL/22/2009, Amit Solanki, Created the file
+ *
+ ******************************************************************************/
+#ifndef GPIO_H_
+#define GPIO_H_
+/****************
+ * Include Files
+ ****************/
+#include "types.h"
+
+/*********************************
+ * Defines and Macros and globals
+ *********************************/
+
+#define GPIO_0 0
+#define GPIO_1 1
+#define GPIO_2 2
+#define GPIO_3 3
+#define GPIO_4 4
+#define GPIO_5 5
+#define GPIO_6 6
+#define GPIO_7 7
+#define GPIO_8 8
+#define GPIO_9 9
+#define GPIO_10 10
+#define GPIO_11 11
+#define GPIO_12 12
+#define GPIO_13 13
+#define GPIO_14 14
+#define GPIO_15 15
+
+#define GPIO_DATAMASK 0x000000FF
+
+#define GPIO_MAX_NUMBER 15
+
+#define SUCCESS 0
+#define GPIO_LOW 0
+#define GPIO_HIGH 1
+#define INVALID_GPIO_NUMBER 2
+#define INVALID_GPIO_DIRECTION 3
+#define INVALID_GPIO_STATE 4
+
+// GPIO pins and the Nand flash controller signal mapping
+
+// GPIO[7:0] are used as bi-directional data-bus
+// between DSP and FPGA
+
+// Command pins
+#define DSP_FPGA_CMD0 GPIO_8
+#define DSP_FPGA_CMD1 GPIO_9
+
+// DSP to FPGA strobe for synchronization
+#define DSP_FPGA_STROBE GPIO_10
+
+// FPGA to DSP ready signal
+#define FPGA_DSP_READY GPIO_11
+
+// LED signals
+#define DSP_FPGA_LED_0 GPIO_12
+#define DSP_FPGA_LED_1 GPIO_13
+
+// NAND or non-UART FPGA interrupt
+#define FPGA_DSP_NFC_INTR GPIO_14
+
+// Nand mode selection GPIO
+#define NAND_MODE_GPIO GPIO_14
+
+// UART interrupt
+#define FPGA_DSP_UART_INTR GPIO_15
+
+/*********************
+ * Typedefs and Enums
+ *********************/
+typedef enum _GpioDirection
+{
+ GPIO_OUT = 0,
+ GPIO_IN
+}GpioDirection;
+
+/************************
+ * Function declarations
+ ************************/
+void hwGpioSetDirection( Uint32 uiNumber, GpioDirection direction );
+void hwGpioSetDataBusDirection( GpioDirection direction );
+void hwGpioSetOutput( Uint32 uiNumber);
+void hwGpioClearOutput( Uint32 uiNumber);
+Uint32 hwGpioReadInput( Uint32 uiNumber );
+void hwGpioWriteDataBus ( Uint8 uchValue );
+Uint8 hwGpioReadDataBus( void );
+void hwGpioEnableGlobalInterrupt( void );
+void hwGpioSetDataBus(Uint8 uchValue);
+void hwGpioClearDataBus(Uint8 uchValue);
+void hwGpioDisableGlobalInterrupt( void );
+void hwGpioSetRisingEdgeInterrupt( Uint32 uiNumber );
+void hwGpioClearRisingEdgeInterrupt( Uint32 uiNumber );
+void hwGpioSetFallingEdgeInterrupt( Uint32 uiNumber );
+void hwGpioClearFallingEdgeInterrupt( Uint32 uiNumber );
+
+#endif // GPIO_H_
+
diff --git a/src/hw/i2c/i2c.c b/src/hw/i2c/i2c.c
--- /dev/null
+++ b/src/hw/i2c/i2c.c
@@ -0,0 +1,368 @@
+/****************************************************************************
+ * FILE PURPOSE: An i2c driver for the rom boot loader
+ ****************************************************************************
+ * FILE NAME: i2c.c
+ *
+ * DESCRIPTION: Provides an i2c driver for the rom boot loader. The driver
+ * is adapted from the csl polling driver in the 64x csl.
+ *
+ ****************************************************************************/
+#include "types.h"
+#include "i2c.h"
+#include "i2cloc.h"
+#include "target.h"
+
+#define DEVICE_REG32_W(x,y) *(volatile unsigned int *)(x)=(y)
+#define DEVICE_REG32_R(x) (*(volatile unsigned int *)(x))
+
+ /**************************************************************************
+ * Global variables
+ *************************************************************************/
+ UINT32 i2cCoreFreqMhz;
+ UINT32 i2cBitPeriodCycles;
+
+
+/***********************************************************************************
+ * FUNCTION PURPOSE: Provide an approximate delay
+ ***********************************************************************************
+ * DESCRIPTION: A delay in units of CPU cycles is executed
+ ***********************************************************************************/
+static void chipDelay32 (uint32 del)
+{
+ volatile unsigned int i;
+
+ for (i = 0; i < del/8; i++);
+
+}
+
+
+/***************************************************************************
+ * FUNCTION PURPOSE: Generate a delay
+ ***************************************************************************
+ * DESCRIPTION: Creates a delay specified in usec
+ ***************************************************************************/
+void hw_i2c_delay_usec (UINT32 usec)
+{
+ UINT32 delayCycles;
+
+ delayCycles = usec * i2cCoreFreqMhz;
+
+ chipDelay32 (delayCycles);
+
+} /* hw_i2c_delay_usec */
+
+
+ /***************************************************************************
+ * FUNCTION PURPOSE: Initialize the I2C.
+ ***************************************************************************
+ * DESCRIPTION: Puts the I2C into reset, sets up the device and takes
+ * the device out of reset in slave receiver mode.
+ **************************************************************************/
+void hwI2Cinit (UINT16 coreFreqMhz, UINT16 moduleDivisor, UINT16 clkFreqKhz, UINT16 ownAddr)
+ {
+ UINT32 psc;
+ UINT32 clkx;
+ UINT32 tmp;
+ UINT32 moduleFreqMhzQ1;
+ UINT32 trueModFreqHz;
+ UINT32 trueModFreqkHz;
+
+ /* Put the i2c peripheral into reset */
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_MDR, I2C_VAL_REG_MDR_RESET);
+
+ /* To determine the module prescaler Q31.1 format will be used. This is just
+ * handled simply since the input module frequency is an integer it will just
+ * be multiplied by two. Dividing two Q31.1 result in a Q30.0, or the divider *
+ * Calculate module prescalars to get as close to target frequencies as possible */
+ moduleFreqMhzQ1 = (coreFreqMhz << 1) / moduleDivisor;
+ psc = moduleFreqMhzQ1 / I2C_TARGET_MODULE_FREQ_MHZ_Q1;
+ if (psc > 0)
+ psc = psc - 1;
+ trueModFreqHz = ((UINT32)coreFreqMhz * (UINT32)1000000) / (moduleDivisor * (psc+1));
+
+ tmp = trueModFreqHz / (clkFreqKhz * 1000);
+ if (tmp > 12)
+ clkx = (tmp - 12) >> 1;
+ else
+ clkx = 0;
+
+ /* Store the core frequency for use in generating delay */
+ i2cCoreFreqMhz = coreFreqMhz;
+
+ /* Calculate the number of micro seconds for each bit. */
+ trueModFreqkHz = trueModFreqHz / 1000; /* Prevent 32 bit integer overlflow */
+ i2cBitPeriodCycles = (UINT32)coreFreqMhz * 1000 * (2 * clkx + 12) / trueModFreqkHz;
+
+ /* Initialize the registers */
+ DEVICE_REG32_W(DEVICE_I2C_BASE + I2C_REG_PSC, (UINT32)psc);
+ DEVICE_REG32_W(DEVICE_I2C_BASE + I2C_REG_OAR, (UINT32)ownAddr);
+ DEVICE_REG32_W(DEVICE_I2C_BASE + I2C_REG_IER, (UINT32)0);
+ DEVICE_REG32_W(DEVICE_I2C_BASE + I2C_REG_STR, I2C_VAL_REG_STR_RESET);
+ DEVICE_REG32_W(DEVICE_I2C_BASE + I2C_REG_CLKL, clkx);
+ DEVICE_REG32_W(DEVICE_I2C_BASE + I2C_REG_CLKH, clkx);
+ DEVICE_REG32_W(DEVICE_I2C_BASE + I2C_REG_CNT, (UINT32)0);
+ DEVICE_REG32_W(DEVICE_I2C_BASE + I2C_REG_SAR, (UINT32)0x3ff);
+ DEVICE_REG32_W(DEVICE_I2C_BASE + I2C_REG_DXR, (UINT32)0);
+ DEVICE_REG32_W(DEVICE_I2C_BASE + I2C_REG_PFUNC, (UINT32)0);
+
+ /* Take the I2C out of reset in the slave receiver mode */
+ DEVICE_REG32_W(DEVICE_I2C_BASE + I2C_REG_MDR, I2C_VAL_REG_MDR_SLVRCV);
+
+ /* Read the receive register to clear it */
+ tmp = DEVICE_REG32_R(DEVICE_I2C_BASE + I2C_REG_DRR);
+
+
+} /* hwI2Cinit */
+
+
+/****************************************************************************
+ * FUNCTION PURPOSE: Perform a master write
+ ****************************************************************************
+ * DESCRIPTION: Enters master transmitter mode, writes a specified number
+ * of bytes. The byte stream arrives packed in the 16 bit
+ * data stream, and are sent most significant byte first.
+ ****************************************************************************/
+I2C_RET hwI2cMasterWrite (UINT16 eeprom_i2c_id, UINT8 *eData, UINT16 nbytes, UINT16 endBusState, BOOL busIsMine)
+{
+ UINT32 timeoutCount;
+ UINT32 polling;
+ UINT32 value;
+ UINT32 str;
+ UINT16 i;
+
+ /* If the byte length is 0 there is nothing to do */
+ if (nbytes == 0)
+ return (I2C_RET_OK);
+
+ /* Check for the bus busy signal */
+ if (busIsMine == FALSE) {
+ timeoutCount = 0;
+ do {
+ polling = I2C_REG_STR_FIELD_BB(DEVICE_REG32_R (DEVICE_I2C_BASE + I2C_REG_STR));
+
+ if (polling != 0) {
+ hw_i2c_delay_usec (I2C_MASTER_TRANSMITTER_BUS_ACCESS_DELAY_US);
+
+ timeoutCount += 1;
+ if (timeoutCount >= I2C_MAX_MASTER_TRANSMITTER_BUS_ACCESS_TIMEOUT) {
+
+ /* Return to slave receiver, clear nack and bus busy */
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_MDR, I2C_VAL_REG_MDR_SLVRCV);
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_STR, I2C_VAL_REG_STR_ON_FAIL);
+ return (I2C_RET_IDLE_TIMEOUT);
+ }
+ } else { /* The bus is free */
+ timeoutCount = 0;
+ }
+ }
+ while (timeoutCount != 0);
+
+ }
+
+ /* Enter master transmitter mode, set the slave address register */
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_MDR, I2C_VAL_REG_MDR_MSTXMT);
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_SAR, (UINT32)eeprom_i2c_id);
+
+ /* Put the first byte into the transmit register, set the start bit */
+ value = *eData & 0x00ff;
+ eData = eData + 1;
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_DXR, value);
+
+
+ /* Some delay required */
+ chipDelay32 (i2cBitPeriodCycles);
+
+ /* Set the start bit */
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_MDR, I2C_VAL_REG_MDR_MSTXMTSTRT);
+
+ for (i = 1; i < nbytes; i++) {
+ timeoutCount = 0;
+
+ do {
+ /* Read status */
+ str = DEVICE_REG32_R (DEVICE_I2C_BASE + I2C_REG_STR);
+
+ /* On Nack return failure */
+ if (I2C_REG_STR_FIELD_NACK(str) != 0) {
+
+ /* Return to slave receiver, clear nack and bus busy */
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_MDR, I2C_VAL_REG_MDR_SLVRCV);
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_STR, I2C_VAL_REG_STR_ON_FAIL);
+ return (I2C_RET_NO_ACK);
+ }
+
+ /* Check for transmit ready */
+ if (I2C_REG_STR_FIELD_XRDY(str) != 0) {
+ timeoutCount = 0;
+
+ value = *eData & 0x00ff;
+ eData = eData + 1;
+
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_DXR, value);
+
+
+ } else { /* XRDY bit not set */
+ chipDelay32 (i2cBitPeriodCycles);
+ timeoutCount += 1;
+ if (timeoutCount >= I2C_MAX_MASTER_TRANSMITTER_TIMEOUT) {
+ /* Return to slave receiver, clear nack and bus busy */
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_MDR, I2C_VAL_REG_MDR_SLVRCV);
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_STR, I2C_VAL_REG_STR_ON_FAIL);
+ return (I2C_RET_IDLE_TIMEOUT);
+ }
+ }
+
+ } while (timeoutCount != 0);
+
+ } /* end for loop */
+
+
+ /* If releasing the bus, send a stop bit */
+ if (endBusState == I2C_RELEASE_BUS) {
+
+ /* Wait for the ardy bit to go high */
+ timeoutCount = 0;
+ do {
+ str = DEVICE_REG32_R (DEVICE_I2C_BASE + I2C_REG_STR);
+ if (I2C_REG_STR_FIELD_ARDY(str) != 0) {
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_MDR, I2C_VAL_REG_MDR_MSTXMTSTOP);
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_STR, I2C_VAL_REG_STR_CLR_BUSY);
+ hw_i2c_delay_usec (10000);
+ timeoutCount = 0;
+
+ } else { /* Registers not ready for access */
+ timeoutCount += 1;
+
+ if (timeoutCount >= I2C_MAX_MASTER_TRANSMITTER_ARDY_TIMEOUT) {
+ /* On timeout put the peripheral into reset, wait, then
+ * take it out of reset */
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_MDR, I2C_VAL_REG_MDR_RESET);
+ hw_i2c_delay_usec (10000);
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_MDR, I2C_VAL_REG_MDR_SLVRCV);
+ return (I2C_RET_IDLE_TIMEOUT);
+ }
+ chipDelay32 (i2cBitPeriodCycles);
+ }
+ } while (timeoutCount != 0);
+
+ } /* end bus release */
+
+ return (I2C_RET_OK);
+
+} /* hwI2cMasterWrite */
+
+
+
+/**************************************************************************
+ * FUNCTION PURPOSE: Perform a master read from an I2C prom
+ **************************************************************************
+ * DESCRIPTION: Reads a fixed number of bytes from an I2C prom. The read
+ * consists of a master write of 2 bytes (forming a 16 bit address,
+ * msb transmitted first), followed by a master read of the
+ * input number of bytes. The bytes that are read are placed
+ * in p_packed_bytes in big endian format.
+ **************************************************************************/
+I2C_RET hwI2cMasterRead (
+ UINT32 byte_addr,
+ UINT32 byte_len,
+ UINT8 *p_packed_bytes,
+ UINT16 eeprom_i2c_id,
+ UINT16 address_delay)
+{
+
+ UINT32 str;
+ UINT32 timeoutCount;
+ UINT32 i;
+ UINT8 eAddr[2];
+ I2C_RET ret;
+
+ /* If the byte length is 0, there is nothing to do */
+ if (byte_len == 0)
+ return (I2C_RET_OK);
+
+ /* Write the byte address to the eeprom. Do not send a stop */
+ eAddr[0] = (byte_addr >> 8) & 0xff;
+ eAddr[1] = byte_addr & 0xff;
+
+ ret = hwI2cMasterWrite (eeprom_i2c_id, eAddr, 2, I2C_DO_NOT_RELEASE_BUS, FALSE);
+ if (ret != I2C_RET_OK)
+ return (ret);
+
+ /* Give the I2C prom some time to process the read command */
+ chipDelay32 (((UINT32)address_delay)<<8);
+
+ /* Set the start bit, begin the master read */
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_MDR, I2C_VAL_REG_MDR_MSTRCV);
+
+ /* Read the requested number of bytes */
+ for (i = 0; i < byte_len; i++) {
+ timeoutCount = 0;
+
+ do {
+ /* Read status */
+ str = DEVICE_REG32_R (DEVICE_I2C_BASE + I2C_REG_STR);
+
+ /* On Nack return failure */
+ if (I2C_REG_STR_FIELD_NACK(str) != 0) {
+
+ /* Return to slave receiver, clear nack and bus busy */
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_MDR, I2C_VAL_REG_MDR_SLVRCV);
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_STR, I2C_VAL_REG_STR_ON_FAIL);
+ return (I2C_RET_NO_ACK);
+ }
+
+ /* Check for receive byte ready */
+ if (I2C_REG_STR_FIELD_RRDY(str) != 0) {
+ *p_packed_bytes = (UINT16) (DEVICE_REG32_R (DEVICE_I2C_BASE + I2C_REG_DRR) & 0x00ff);
+ timeoutCount = 0;
+ p_packed_bytes = p_packed_bytes + 1;
+
+
+ } else { /* RRDY bit not set */
+ chipDelay32 (i2cBitPeriodCycles);
+ timeoutCount += 1;
+ if (timeoutCount >= I2C_MAX_MASTER_RECEIVE_TIMEOUT) {
+ /* Return to slave receiver, clear nack and bus busy */
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_MDR, I2C_VAL_REG_MDR_SLVRCV);
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_STR, I2C_VAL_REG_STR_ON_FAIL);
+ return (I2C_RET_IDLE_TIMEOUT);
+ }
+ }
+
+ } while (timeoutCount != 0);
+
+ } /* end for loop */
+
+ /* The data block has been read. Send the stop bit */
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_MDR, I2C_VAL_REG_MDR_MSTRCVSTOP);
+
+
+ /* Wait for the rrdy and read the dummy byte */
+ timeoutCount = 0;
+ do {
+
+ str = DEVICE_REG32_R (DEVICE_I2C_BASE + I2C_REG_STR);
+
+ /* Check for receive byte ready */
+ if (I2C_REG_STR_FIELD_RRDY(str) != 0) {
+ eAddr[0] = (UINT16) (DEVICE_REG32_R (DEVICE_I2C_BASE + I2C_REG_DRR) & 0x00ff);
+ timeoutCount = 0;
+
+ } else { /* rrdy not set */
+
+ chipDelay32 (i2cBitPeriodCycles);
+ timeoutCount += 1;
+ if (timeoutCount >= I2C_MAX_MASTER_RECEIVE_TIMEOUT) {
+ /* Return to slave receiver, clear nack and bus busy */
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_MDR, I2C_VAL_REG_MDR_SLVRCV);
+ DEVICE_REG32_W (DEVICE_I2C_BASE + I2C_REG_STR, I2C_VAL_REG_STR_ON_FAIL);
+ return (I2C_RET_IDLE_TIMEOUT);
+ }
+ }
+
+ } while (timeoutCount != 0);
+
+ return (I2C_RET_OK);
+
+} /* hwI2cMasterRead */
+
diff --git a/src/hw/i2c/i2c.h b/src/hw/i2c/i2c.h
--- /dev/null
+++ b/src/hw/i2c/i2c.h
@@ -0,0 +1,39 @@
+/*********************************************************************
+ * FILE PURPOSE: I2C API definition
+ *********************************************************************
+ * FILE NAME: i2c.h
+ *
+ * DESCRIPTION: Defines the i2c API
+ *
+ * @file i2c.h
+ *
+ * @brief
+ * Defines the i2c API
+ *
+ *********************************************************************/
+#include "types.h"
+
+typedef UINT16 I2C_RET;
+
+
+#define I2C_RET_OK 0
+#define I2C_RET_LOST_ARB 1
+#define I2C_RET_NO_ACK 2
+#define I2C_RET_IDLE_TIMEOUT 3
+#define I2C_RET_BAD_REQUEST 4
+#define I2C_RET_CLOCK_STUCK_LOW 5
+#define I2C_RET_GEN_ERROR 99
+
+
+enum {
+ I2C_RELEASE_BUS,
+ I2C_DO_NOT_RELEASE_BUS
+};
+
+
+void hwI2Cinit (UINT16 coreFreqMhz, UINT16 moduleDivisor, UINT16 clkFreqKhz, UINT16 ownAddr);
+I2C_RET hwI2cMasterWrite (UINT16 eeprom_i2c_id, UINT8 *eData, UINT16 nbytes, UINT16 endBusState, BOOL busIsMine);
+I2C_RET hwI2cMasterRead (UINT32 byte_addr, UINT32 byte_len, UINT8 *p_packed_bytes, UINT16 eeprom_i2c_id, UINT16 address_delay);
+
+
+
diff --git a/src/hw/i2c/i2cloc.h b/src/hw/i2c/i2cloc.h
--- /dev/null
+++ b/src/hw/i2c/i2cloc.h
@@ -0,0 +1,109 @@
+#ifndef _I2CLOC_H
+#define _I2CLOC_H
+/***********************************************************************
+ * FILE PURPOSE: Local definitions used to run the I2C peripheral
+ ***********************************************************************
+ * FILE NAME: i2cloc.h
+ *
+ * DESCRIPTION: Provides defintions and prototypes local to the i2c module
+ *
+ ************************************************************************/
+#include "types.h"
+
+#define BOOTBITMASK(x,y) ( ( ( ((UINT32)1 << (((UINT32)x)-((UINT32)y)+(UINT32)1) ) - (UINT32)1 ) ) << ((UINT32)y) )
+#define BOOT_READ_BITFIELD(z,x,y) (((UINT32)z) & BOOTBITMASK(x,y)) >> (y)
+#define BOOT_SET_BITFIELD(z,f,x,y) (((UINT32)z) & ~BOOTBITMASK(x,y)) | ( (((UINT32)f) << (y)) & BOOTBITMASK(x,y) )
+
+/* Register addresses relative to a base address */
+#define I2C_REG_OAR 0x00
+#define I2C_REG_IER 0x04
+#define I2C_REG_STR 0x08
+#define I2C_REG_CLKL 0x0c
+#define I2C_REG_CLKH 0x10
+#define I2C_REG_CNT 0x14
+#define I2C_REG_DRR 0x18
+#define I2C_REG_SAR 0x1c
+#define I2C_REG_DXR 0x20
+#define I2C_REG_MDR 0x24
+#define I2C_REG_ISR 0x28
+#define I2C_REG_EXMODE 0x2c
+#define I2C_REG_PSC 0x30
+#define I2C_REG_PID1 0x34
+#define I2C_REG_PID2 0x38
+#define I2C_REG_PFUNC 0x48
+
+/* Individual register definitions */
+#define I2C_VAL_REG_MDR_RESET 0x4000
+#define I2C_VAL_REG_MDR_SLVRCV 0x40A0
+#define I2C_VAL_REG_MDR_MSTRCV 0x64A0
+#define I2C_VAL_REG_MDR_MSTRCVSTOP 0x4CA0
+#define I2C_VAL_REG_MDR_MSTXMT 0x46A0
+#define I2C_VAL_REG_MDR_MSTXMTSTRT 0x66A0
+#define I2C_VAL_REG_MDR_MSTXMTSTOP 0x4CA0
+
+#define I2C_VAL_REG_STR_RESET 0x0410
+#define I2C_VAL_REG_STR_ON_FAIL 0x1002 /* Clear bus busy, clear nack */
+#define I2C_VAL_REG_STR_CLR_BUSY 0x1000 /* Clear busy */
+#define I2C_VAL_REG_STR_CLR_RRDY 0x003F
+
+/* Bit field definitions */
+#define I2C_REG_STR_FIELD_BB(x) BOOT_READ_BITFIELD((x), 12, 12)
+#define I2C_REG_STR_FIELD_NACK(x) BOOT_READ_BITFIELD((x), 1, 1)
+#define I2C_REG_STR_FIELD_ARDY(x) BOOT_READ_BITFIELD((x), 2, 2)
+#define I2C_REG_STR_FIELD_XRDY(x) BOOT_READ_BITFIELD((x), 4, 4)
+#define I2C_REG_STR_FIELD_RRDY(x) BOOT_READ_BITFIELD((x), 3, 3)
+
+
+
+/* Byte ordering */
+enum {
+ I2C_BYTE_LSB,
+ I2C_BYTE_MSB
+};
+
+/************************************************************************
+ * Definition: Desired frequency for module operation in Qx.1 format
+ ************************************************************************/
+#define I2C_TARGET_MODULE_FREQ_MHZ_Q1 27 /* 13.5 MHz */
+
+
+/************************************************************************
+ * Definition: Timeout limit for master receiver. The units are
+ * in number of bits, so provide some overhead
+ ************************************************************************/
+#define I2C_MAX_MASTER_RECEIVE_TIMEOUT 240 /* 30 bytes */
+
+/************************************************************************
+ * Definition: Timeout limit for master transmitter. The units are
+ * in number of bits, so provide some overhead
+ ************************************************************************/
+#define I2C_MAX_MASTER_TRANSMITTER_TIMEOUT 240 /* 30 bytes */
+
+/************************************************************************
+ * Definition: Timeout limit for the master transmitter to get access
+ * to the bus. In 10ms units.
+ ************************************************************************/
+#define I2C_MAX_MASTER_TRANSMITTER_BUS_ACCESS_TIMEOUT 100
+#define I2C_MASTER_TRANSMITTER_BUS_ACCESS_DELAY_US 10000
+
+/*************************************************************************
+ * Definition: Timeout limit after a master transmitter operation is
+ * complete, and waiting for access to the MMRs. This should
+ * be on the order of two bytes, for the last two that are
+ * being sent (one in the shift register, one in the dxr. The
+ * units are in bits.
+ *************************************************************************/
+#define I2C_MAX_MASTER_TRANSMITTER_ARDY_TIMEOUT 32 /* 4 bytes */
+
+
+/*************************************************************************
+ * Definition: Timeout limit in slave receiver mode. The unit is in
+ * expected bit periods, but is long since the master
+ * may have a long delay before beginning transmission.
+ *************************************************************************/
+#define I2C_MAX_SLAVE_RECEIVE_TIMEOUT 5000000
+
+
+
+
+#endif /* _I2CLOC_H */
diff --git a/src/hw/macs/cpmac/cpmac_regs.h b/src/hw/macs/cpmac/cpmac_regs.h
--- /dev/null
@@ -0,0 +1,176 @@
+/**
+ * @file cpmac_regs.h
+ *
+ * @brief
+ * This file contains the Register Desciptions for EMAC
+ *
+ * \par
+ * NOTE:
+ * (C) Copyright 2008, Texas Instruments, Inc.
+ *
+ * \par
+ */
+
+#ifndef __CPMAC_REGS_H__
+#define __CPMAC_REGS_H__
+
+/**
+ * @brief
+ * The structure describes the CPMAC Register Overlay.
+ *
+ * @details
+ * This is the CPMAC Register overlay data structure which is used
+ * by the CPMAC Driver.
+ */
+typedef struct CPMAC_REGS
+{
+ volatile Uint32 TXIDVER;
+ volatile Uint32 TXCONTROL;
+ volatile Uint32 TXTEARDOWN;
+ volatile Uint8 RSVD0[4];
+ volatile Uint32 RXIDVER;
+ volatile Uint32 RXCONTROL;
+ volatile Uint32 RXTEARDOWN;
+ volatile Uint8 RSVD1[100];
+ volatile Uint32 TXINTSTATRAW;
+ volatile Uint32 TXINTSTATMASKED;
+ volatile Uint32 TXINTMASKSET;
+ volatile Uint32 TXINTMASKCLEAR;
+ volatile Uint32 MACINVECTOR;
+ volatile Uint8 RSVD2[12];
+ volatile Uint32 RXINTSTATRAW;
+ volatile Uint32 RXINTSTATMASKED;
+ volatile Uint32 RXINTMASKSET;
+ volatile Uint32 RXINTMASKCLEAR;
+ volatile Uint32 MACINTSTATRAW;
+ volatile Uint32 MACINTSTATMASKED;
+ volatile Uint32 MACINTMASKSET;
+ volatile Uint32 MACINTMASKCLEAR;
+ volatile Uint8 RSVD3[64];
+ volatile Uint32 RXMBPENABLE;
+ volatile Uint32 RXUNICASTSET;
+ volatile Uint32 RXUNICASTCLEAR;
+ volatile Uint32 RXMAXLEN;
+ volatile Uint32 RXBUFFEROFFSET;
+ volatile Uint32 RXFILTERLOWTHRESH;
+ volatile Uint8 RSVD4[8];
+ volatile Uint32 RX0FLOWTHRESH;
+ volatile Uint32 RX1FLOWTHRESH;
+ volatile Uint32 RX2FLOWTHRESH;
+ volatile Uint32 RX3FLOWTHRESH;
+ volatile Uint32 RX4FLOWTHRESH;
+ volatile Uint32 RX5FLOWTHRESH;
+ volatile Uint32 RX6FLOWTHRESH;
+ volatile Uint32 RX7FLOWTHRESH;
+ volatile Uint32 RX0FREEBUFFER;
+ volatile Uint32 RX1FREEBUFFER;
+ volatile Uint32 RX2FREEBUFFER;
+ volatile Uint32 RX3FREEBUFFER;
+ volatile Uint32 RX4FREEBUFFER;
+ volatile Uint32 RX5FREEBUFFER;
+ volatile Uint32 RX6FREEBUFFER;
+ volatile Uint32 RX7FREEBUFFER;
+ volatile Uint32 MACCONTROL;
+ volatile Uint32 MACSTATUS;
+ volatile Uint32 EMCONTROL;
+ volatile Uint32 FIFOCONTROL;
+ volatile Uint32 MACCONFIG;
+ volatile Uint32 SOFTRESET;
+ volatile Uint8 RSVD5[88];
+ volatile Uint32 MACSRCADDRLO;
+ volatile Uint32 MACSRCADDRHI;
+ volatile Uint32 MACHASH1;
+ volatile Uint32 MACHASH2;
+ volatile Uint32 BOFFTEST;
+ volatile Uint32 TPACETEST;
+ volatile Uint32 RXPAUSE;
+ volatile Uint32 TXPAUSE;
+ volatile Uint8 RSVD6[16];
+ volatile Uint32 RXGOODFRAMES;
+ volatile Uint32 RXBCASTFRAMES;
+ volatile Uint32 RXMCASTFRAMES;
+ volatile Uint32 RXPAUSEFRAMES;
+ volatile Uint32 RXCRCERRORS;
+ volatile Uint32 RXALIGNCODEERRORS;
+ volatile Uint32 RXOVERSIZED;
+ volatile Uint32 RXJABBER;
+ volatile Uint32 RXUNDERSIZED;
+ volatile Uint32 RXFRAGMENTS;
+ volatile Uint32 RXFILTERED;
+ volatile Uint32 RXQOSFILTERED;
+ volatile Uint32 RXOCTETS;
+ volatile Uint32 TXGOODFRAMES;
+ volatile Uint32 TXBCASTFRAMES;
+ volatile Uint32 TXMCASTFRAMES;
+ volatile Uint32 TXPAUSEFRAMES;
+ volatile Uint32 TXDEFERRED;
+ volatile Uint32 TXCOLLISION;
+ volatile Uint32 TXSINGLECOLL;
+ volatile Uint32 TXMULTICOLL;
+ volatile Uint32 TXEXCESSIVECOLL;
+ volatile Uint32 TXLATECOLL;
+ volatile Uint32 TXUNDERRUN;
+ volatile Uint32 TXCARRIERSENSE;
+ volatile Uint32 TXOCTETS;
+ volatile Uint32 FRAME64;
+ volatile Uint32 FRAME65T127;
+ volatile Uint32 FRAME128T255;
+ volatile Uint32 FRAME256T511;
+ volatile Uint32 FRAME512T1023;
+ volatile Uint32 FRAME1024TUP;
+ volatile Uint32 NETOCTETS;
+ volatile Uint32 RXSOFOVERRUNS;
+ volatile Uint32 RXMOFOVERRUNS;
+ volatile Uint32 RXDMAOVERRUNS;
+ volatile Uint8 RSVD7[624];
+ volatile Uint32 MACADDRLO;
+ volatile Uint32 MACADDRHI;
+ volatile Uint32 MACINDEX;
+ volatile Uint8 RSVD8[244];
+ volatile Uint32 TX0HDP;
+ volatile Uint32 TX1HDP;
+ volatile Uint32 TX2HDP;
+ volatile Uint32 TX3HDP;
+ volatile Uint32 TX4HDP;
+ volatile Uint32 TX5HDP;
+ volatile Uint32 TX6HDP;
+ volatile Uint32 TX7HDP;
+ volatile Uint32 RX0HDP;
+ volatile Uint32 RX1HDP;
+ volatile Uint32 RX2HDP;
+ volatile Uint32 RX3HDP;
+ volatile Uint32 RX4HDP;
+ volatile Uint32 RX5HDP;
+ volatile Uint32 RX6HDP;
+ volatile Uint32 RX7HDP;
+ volatile Uint32 TX0CP;
+ volatile Uint32 TX1CP;
+ volatile Uint32 TX2CP;
+ volatile Uint32 TX3CP;
+ volatile Uint32 TX4CP;
+ volatile Uint32 TX5CP;
+ volatile Uint32 TX6CP;
+ volatile Uint32 TX7CP;
+ volatile Uint32 RX0CP;
+ volatile Uint32 RX1CP;
+ volatile Uint32 RX2CP;
+ volatile Uint32 RX3CP;
+ volatile Uint32 RX4CP;
+ volatile Uint32 RX5CP;
+ volatile Uint32 RX6CP;
+ volatile Uint32 RX7CP;
+}CPMAC_REGS;
+
+/* MACADDRLO: Bit Mask Definitions. */
+#define CPMAC_MACADDRLO_VALID (0x00100000u)
+#define CPMAC_MACADDRLO_MATCHFILT (0x00080000u)
+
+/* MACCONTROL: Bit Mask Definitions. */
+#define CPMAC_MACCONTROL_RXOWNERSHIP (0x00002000u)
+#define CPMAC_MACCONTROL_RXOFFLENBLOCK (0x00004000u)
+#define CPMAC_MACCONTROL_MIIEN (0x00000020u)
+
+/* RXMBP Enable: Bit Mask Definitions. */
+#define CPMAC_RXMBPENABLE_RXBROADEN (0x00002000u)
+
+#endif /* __CPMAC_REGS_H__ */
diff --git a/src/hw/macs/cpmac/cpmacdrv.c b/src/hw/macs/cpmac/cpmacdrv.c
--- /dev/null
@@ -0,0 +1,444 @@
+/**
+ * @file cpmacdrv.c
+ *
+ * @brief
+ * The driver is written for the CPMAC Ethernet controller. It follows
+ * the Network Boot Module Ethernet Driver Specifications.
+ *
+ * If there are modifications to this driver required for it to work
+ * on the specific device then device authors are recommended to
+ * create a copy of this file in the RBL directory and do the
+ * necessary modifications. Please pass on the appropriate information
+ * to the ROM Boot Loader Framework Development Team.
+ *
+ * \par
+ * NOTE:
+ * (C) Copyright 2008, Texas Instruments, Inc.
+ * \par
+ */
+
+#include "types.h"
+#include "iblloc.h"
+#include "device.h"
+#include "net.h"
+#include "cpmac_regs.h"
+#include <string.h>
+
+#ifdef TARGET_DEVICE_CPMAC
+
+/**********************************************************************
+ ************************** Local Definitions *************************
+ **********************************************************************/
+
+// Packet Flags for TX and RX
+#define EMAC_DSC_FLAG_SOP 0x80000000u
+#define EMAC_DSC_FLAG_EOP 0x40000000u
+#define EMAC_DSC_FLAG_OWNER 0x20000000u
+#define EMAC_DSC_FLAG_EOQ 0x10000000u
+#define EMAC_DSC_FLAG_TDOWNCMPLT 0x08000000u
+#define EMAC_DSC_FLAG_PASSCRC 0x04000000u
+
+// The following flags are RX only
+#define EMAC_DSC_FLAG_JABBER 0x02000000u
+#define EMAC_DSC_FLAG_OVERSIZE 0x01000000u
+#define EMAC_DSC_FLAG_FRAGMENT 0x00800000u
+#define EMAC_DSC_FLAG_UNDERSIZED 0x00400000u
+#define EMAC_DSC_FLAG_CONTROL 0x00200000u
+#define EMAC_DSC_FLAG_OVERRUN 0x00100000u
+#define EMAC_DSC_FLAG_CODEERROR 0x00080000u
+#define EMAC_DSC_FLAG_ALIGNERROR 0x00040000u
+#define EMAC_DSC_FLAG_CRCERROR 0x00020000u
+#define EMAC_DSC_FLAG_NOMATCH 0x00010000u
+
+/**********************************************************************
+ ************************** Local Structures **************************
+ **********************************************************************/
+
+/**
+ * @brief
+ * The structure describes the EMAC Descriptor.
+ *
+ * @details
+ * Ethernet drivers receives and transmits data through the descriptor
+ * object described here.
+ */
+typedef struct _EMAC_Desc
+{
+ /**
+ * @brief Pointer to next descriptor in chain
+ */
+ struct _EMAC_Desc* pNext;
+
+ /**
+ * @brief Pointer to the data buffer.
+ */
+ Uint8* pBuffer;
+
+ /**
+ * @brief Buffer Offset(MSW) and Length(LSW)
+ */
+ Uint32 BufOffLen;
+
+ /**
+ * @brief Packet Flags(MSW) and Length(LSW)
+ */
+ volatile Uint32 PktFlgLen;
+
+}EMAC_Desc;
+
+/**
+ * @brief
+ * The structure describes the EMAC Master Control Block.
+ *
+ * @details
+ * The structure stores information required by the EMAC Driver;
+ * which includes the Receive and Transmit Buffer Descriptors.
+ */
+typedef struct EMAC_MCB
+{
+ /**
+ * @brief Pointer to the Receive Buffer Descriptor
+ */
+ EMAC_Desc* rx_bd;
+
+ /**
+ * @brief Pointer to the Transmit Buffer Descriptor
+ */
+ EMAC_Desc* tx_bd;
+
+ /**
+ * @brief Buffer for receiving data linked with the receive
+ * buffer descriptor.
+ */
+ Uint8 rx_buffer[NET_MAX_MTU];
+
+ /**
+ * @brief Tracks the last value placed into the rx hdp
+ */
+ Uint32 lastRxHdp;
+
+}EMAC_MCB;
+
+/**********************************************************************
+ ************************** Global Variables **************************
+ **********************************************************************/
+
+/**
+ * @brief Global Driver structure which keeps track of all the Ethernet
+ * Driver related information.
+ */
+EMAC_MCB emacMCB;
+
+/**
+ * @brief EMAC Registers.
+ */
+Uint32 aptr_EMACRegs[] = TARGET_EMAC_BASE_ADDRESSES;
+Uint32 aptr_EmacDesc[] = TARGET_EMAC_DSC_BASE_ADDR;
+
+
+/**********************************************************************
+ ************************** ETHDRV Functions **************************
+ **********************************************************************/
+
+/**
+ * @b Description
+ * @n
+ * This is the Network Open API which is registered with the
+ * NET Boot module to initialize the Ethernet device.
+ *
+ * @param[in] ptr_device
+ * Pointer to the NET Device structure which is being opened.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+Int32 cpmac_drv_start (NET_DRV_DEVICE* ptr_device)
+{
+ Uint32 tmpval;
+ volatile Uint32* pRegAddr;
+ Int32 index;
+ CPMAC_REGS* ptr_EMACRegs;
+ EMAC_Desc* pDesc;
+
+ if (ptr_device->port_num >= TARGET_EMAC_N_PORTS)
+ return (-1);
+
+ ptr_EMACRegs = (CPMAC_REGS *)(aptr_EMACRegs[ptr_device->port_num]);
+ pDesc = (EMAC_Desc *)(aptr_EmacDesc[ptr_device->port_num]);
+
+
+ /* Reset EMAC */
+ ptr_EMACRegs->SOFTRESET = 0x1;
+ while (ptr_EMACRegs->SOFTRESET != 0x0);
+
+ /* Reset MAC Control */
+ ptr_EMACRegs->MACCONTROL = 0;
+
+ /* Must manually init HDPs to NULL */
+ pRegAddr = &ptr_EMACRegs->TX0HDP;
+ for( index=0; index<8; index++ )
+ *pRegAddr++ = 0;
+
+ pRegAddr = &ptr_EMACRegs->RX0HDP;
+ for( index=0; index<8; index++ )
+ *pRegAddr++ = 0;
+
+ pRegAddr = &ptr_EMACRegs->TX0CP;
+ for( index=0; index<8; index++ ) {
+ tmpval = *pRegAddr;
+ *pRegAddr++ = tmpval;
+ }
+
+ pRegAddr = &ptr_EMACRegs->RX0CP;
+ for( index=0; index<8; index++ ) {
+ tmpval = *pRegAddr;
+ *pRegAddr++ = tmpval;
+ }
+
+
+ /* Initialize the RAM locations */
+ for (index = 0; index < 32; index++)
+ {
+ ptr_EMACRegs->MACINDEX = index;
+ ptr_EMACRegs->MACADDRHI = 0;
+ ptr_EMACRegs->MACADDRLO = 0;
+ }
+
+ /* Setup device MAC address */
+ ptr_EMACRegs->MACINDEX = 0x0;
+
+ /* Configure the MAC Address into the EMAC Controller. */
+ tmpval = 0;
+ for( index=3; index>=0; index-- )
+ tmpval = (tmpval<<8) | *(ptr_device->mac_address+index);
+ ptr_EMACRegs->MACADDRHI = tmpval;
+ tmpval = *(ptr_device->mac_address+5);
+ ptr_EMACRegs->MACADDRLO = CPMAC_MACADDRLO_VALID | CPMAC_MACADDRLO_MATCHFILT |
+ (tmpval<<8) | *(ptr_device->mac_address+4);
+
+ /* For us buffer offset will always be zero */
+ ptr_EMACRegs->RXBUFFEROFFSET = 0;
+
+ /* Reset RX (M)ulticast (B)roadcast (P)romiscuous Enable register */
+ ptr_EMACRegs->RXMBPENABLE = 0;
+ ptr_EMACRegs->MACHASH1 = 0;
+ ptr_EMACRegs->MACHASH2 = 0;
+
+ /* Clear Unicast RX on channel 0-7 */
+ ptr_EMACRegs->RXUNICASTCLEAR = 0xFF;
+
+ /* Make sure there are none of the interrupts are enabled. */
+ ptr_EMACRegs->RXINTMASKCLEAR = 0xFF;
+ ptr_EMACRegs->TXINTMASKCLEAR = 0xFF;
+ ptr_EMACRegs->MACINTMASKCLEAR = 0x0;
+
+ /* Initialize the receive buffer descriptor. */
+ pDesc->pNext = 0;
+ pDesc->pBuffer = (Uint8 *)deviceLocalAddrToGlobal((Uint32)&emacMCB.rx_buffer[0]);
+ pDesc->BufOffLen = NET_MAX_MTU;
+ pDesc->PktFlgLen = EMAC_DSC_FLAG_OWNER;
+
+ /* Store this buffer descriptor in the global EMAC MCB */
+ emacMCB.rx_bd = pDesc;
+
+ /* Get the transmit buffer descriptor; it comes right after the receive BD. */
+ pDesc = pDesc + 1;
+
+ /* Initialize the transmit buffer descriptor. */
+ pDesc->pNext = 0;
+ pDesc->pBuffer = 0;
+ pDesc->BufOffLen = 0;
+ pDesc->PktFlgLen = 0;
+
+ /* Store this buffer descriptor in the global EMAC MCB */
+ emacMCB.tx_bd = pDesc;
+
+#ifdef EMAC_CACHE_SUPPORT
+ /* Writeback the EMAC MCB Information to the PHYSICAL Memory.
+ * This is required because the buffer in the cache will always be
+ * invalidated on the RECEIVE; if the buffer is not aligned on the
+ * CACHE Line then it will result in the RX & TX BD in the structure
+ * to also get invalidated to what resides in the PHYSICAL memory.
+ * But if we have written back the structure here then the PHYSICAL
+ * and CACHE are one and the same as far as the BD's are concerned. */
+ Cache_wbL2((void *)&emacMCB, sizeof(emacMCB));
+#endif
+
+ /* Enable the receive and transmit. */
+ ptr_EMACRegs->TXCONTROL = 0x1;
+ ptr_EMACRegs->RXCONTROL = 0x1;
+
+ /* Initialize the MAC Control: We set the Receive Ownership Bit and the Receive
+ * Offset Length Word and enable the MII. */
+ ptr_EMACRegs->MACCONTROL = CPMAC_MACCONTROL_RXOWNERSHIP |
+ CPMAC_MACCONTROL_RXOFFLENBLOCK |
+ CPMAC_MACCONTROL_MIIEN;
+
+ /* Startup RX */
+ ptr_EMACRegs->RX0HDP = (Uint32)emacMCB.rx_bd;
+ emacMCB.lastRxHdp = (Uint32)emacMCB.rx_bd;
+
+ /* Enable receive filters for channel 1 and all broadcast packets. */
+ ptr_EMACRegs->RXUNICASTSET = 1;
+ ptr_EMACRegs->RXMBPENABLE = CPMAC_RXMBPENABLE_RXBROADEN;
+
+ /* Initialize the Device MDIO layer: The function returns only when
+ * the LINK is UP and RUNNING. */
+ if (dev_mdio_open () < 0)
+ return -1;
+
+ /* Debug Message: */
+ mprintf ("DEBUG: Ethernet Link is UP \n");
+
+ /* Hardware is up and running. */
+ return 0;
+}
+
+/**
+ * @b Description
+ * @n
+ * This is the Network Send API which is registered with the NET boot module
+ * to send out packets.
+ *
+ * @param[in] ptr_device
+ * Pointer to the network interface descriptor object.
+ * @param[in] buffer
+ * Pointer to the packet which is to be transmitted.
+ * @param[in] num_bytes
+ * Length of the packet which is transmitted.
+ *
+ * @retval
+ * Success - Number of bytes transmitted.
+ * @retval
+ * Error - <0
+ */
+Int32 cpmac_drv_send (NET_DRV_DEVICE* ptr_device, Uint8* buffer, int num_bytes)
+{
+ volatile EMAC_Desc* pDesc;
+ CPMAC_REGS* ptr_EMACRegs;
+
+ if (ptr_device->port_num >= TARGET_EMAC_N_PORTS)
+ return (-1);
+
+ ptr_EMACRegs = (CPMAC_REGS *)(aptr_EMACRegs[ptr_device->port_num]);
+
+ /* Ensure the minimum ethernet size is sent out. */
+ if (num_bytes < 64)
+ num_bytes = 64;
+
+#ifdef EMAC_CACHE_SUPPORT
+ /* Clean the cache for external addesses */
+ Cache_wbL2((void *)buffer, num_bytes);
+#endif
+
+ /* Get the pointer to the transmit buffer descriptor. */
+ pDesc = emacMCB.tx_bd;
+
+ /* Fill out the transmit buffer descriptor */
+ pDesc->pNext = 0;
+ pDesc->pBuffer = (Uint8 *)deviceLocalAddrToGlobal((Uint32)buffer);
+ pDesc->BufOffLen = num_bytes;
+ pDesc->PktFlgLen = EMAC_DSC_FLAG_SOP | EMAC_DSC_FLAG_EOP | num_bytes | EMAC_DSC_FLAG_OWNER;
+
+ /* Send the packet out. */
+ ptr_EMACRegs->TX0HDP = (Uint32)pDesc;
+
+ /* Loop around till the transmission is complete. */
+ do {
+ pDesc = (EMAC_Desc *)ptr_EMACRegs->TX0CP;
+ } while (pDesc->PktFlgLen & EMAC_DSC_FLAG_OWNER);
+
+ /* The packet has been successfully transmitted. */
+ return num_bytes;
+}
+
+/**
+ * @b Description
+ * @n
+ * This is the Network Receive API which is registered with the NET boot module
+ * to receive packets.
+ *
+ * @param[in] ptr_device
+ * Pointer to the network interface descriptor object.
+ * @param[out] buffer
+ * Pointer to the packet which is populated with the received data
+ *
+ * @retval
+ * Success - Number of bytes received.
+ * @retval
+ * Error - <0
+ */
+Int32 cpmac_drv_receive (NET_DRV_DEVICE* ptr_device, Uint8* buffer)
+{
+ Int32 bytes_received = 0;
+ Uint32 rxhdp;
+ EMAC_Desc* pDesc;
+ CPMAC_REGS* ptr_EMACRegs;
+
+ if (ptr_device->port_num >= TARGET_EMAC_N_PORTS)
+ return (-1);
+
+ ptr_EMACRegs = (CPMAC_REGS *)(aptr_EMACRegs[ptr_device->port_num]);
+
+ /* Initialize the number of bytes received. */
+ bytes_received = 0;
+
+
+ /* Make sure the header pointer has advanced. */
+ rxhdp = (Uint32)ptr_EMACRegs->RX0HDP;
+ if (rxhdp == emacMCB.lastRxHdp)
+ return (0);
+
+ /* Read the completion register. We know for sure if the SOP flag is set then
+ * a packet has been received and needs to be picked up from the controller. */
+ pDesc = (EMAC_Desc *)ptr_EMACRegs->RX0CP;
+ if (pDesc->PktFlgLen & EMAC_DSC_FLAG_SOP)
+ {
+ /* Acknowledge that the descriptor has been processed. */
+ ptr_EMACRegs->RX0CP = (Uint32)pDesc;
+
+#ifdef EMAC_CACHE_SUPPORT
+ /* External Memory Support: Invalidate the cache. */
+ Cache_invL2((void *)(pDesc->pBuffer), NET_MAX_MTU);
+#endif
+ /* Remember the number of bytes received. */
+ bytes_received = (pDesc->PktFlgLen & 0xFFFF);
+
+ /* The descriptor is now free to receive more data. Set the status accordingly. */
+ pDesc->BufOffLen = NET_MAX_MTU;
+ pDesc->PktFlgLen = EMAC_DSC_FLAG_OWNER;
+
+ /* Copy the data from the descriptor buffer to the supplied buffer. */
+ memcpy((void *)buffer, (void *)pDesc->pBuffer, bytes_received);
+
+ /* Put this descriptor back to the HDP. */
+ ptr_EMACRegs->RX0HDP = (Uint32)pDesc;
+ }
+
+ /* Return the number of bytes received. */
+ return bytes_received;
+}
+
+/**
+ * @b Description
+ * @n
+ * This is the Network Close API which is registered with the NET boot module
+ * to close and shutdown the Ethernet controller.
+ *
+ * @param[in] ptr_device
+ * Pointer to the network interface descriptor object.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+Int32 cpmac_drv_stop (NET_DRV_DEVICE* ptr_device)
+{
+ return 0;
+}
+
+
+#endif /* TARGET_DEVICE_CPMAC */
diff --git a/src/hw/macs/cpmac/cpmacdrv.orig.c b/src/hw/macs/cpmac/cpmacdrv.orig.c
--- /dev/null
@@ -0,0 +1,392 @@
+/**
+ * @file cpmacdrv.c
+ *
+ * @brief
+ * The driver is written for the CPMAC Ethernet controller. It follows
+ * the Network Boot Module Ethernet Driver Specifications.
+ *
+ * If there are modifications to this driver required for it to work
+ * on the specific device then device authors are recommended to
+ * create a copy of this file in the RBL directory and do the
+ * necessary modifications. Please pass on the appropriate information
+ * to the ROM Boot Loader Framework Development Team.
+ *
+ * \par
+ * NOTE:
+ * (C) Copyright 2008, Texas Instruments, Inc.
+ * \par
+ */
+#include "types.h"
+#include "iblloc.h"
+#include "device.h"
+#include "net.h"
+#include "cpmac_regs.h"
+#include <string.h>
+
+
+/**********************************************************************
+ ************************** Local Definitions *************************
+ **********************************************************************/
+
+// Packet Flags for TX and RX
+#define EMAC_DSC_FLAG_SOP 0x80000000u
+#define EMAC_DSC_FLAG_EOP 0x40000000u
+#define EMAC_DSC_FLAG_OWNER 0x20000000u
+#define EMAC_DSC_FLAG_EOQ 0x10000000u
+#define EMAC_DSC_FLAG_TDOWNCMPLT 0x08000000u
+#define EMAC_DSC_FLAG_PASSCRC 0x04000000u
+
+// The following flags are RX only
+#define EMAC_DSC_FLAG_JABBER 0x02000000u
+#define EMAC_DSC_FLAG_OVERSIZE 0x01000000u
+#define EMAC_DSC_FLAG_FRAGMENT 0x00800000u
+#define EMAC_DSC_FLAG_UNDERSIZED 0x00400000u
+#define EMAC_DSC_FLAG_CONTROL 0x00200000u
+#define EMAC_DSC_FLAG_OVERRUN 0x00100000u
+#define EMAC_DSC_FLAG_CODEERROR 0x00080000u
+#define EMAC_DSC_FLAG_ALIGNERROR 0x00040000u
+#define EMAC_DSC_FLAG_CRCERROR 0x00020000u
+#define EMAC_DSC_FLAG_NOMATCH 0x00010000u
+
+/**********************************************************************
+ ************************** Local Structures **************************
+ **********************************************************************/
+
+/**
+ * @brief
+ * The structure describes the EMAC Descriptor.
+ *
+ * @details
+ * Ethernet drivers receives and transmits data through the descriptor
+ * object described here.
+ */
+typedef struct _EMAC_Desc
+{
+ /**
+ * @brief Pointer to next descriptor in chain
+ */
+ struct _EMAC_Desc* pNext;
+
+ /**
+ * @brief Pointer to the data buffer.
+ */
+ Uint8* pBuffer;
+
+ /**
+ * @brief Buffer Offset(MSW) and Length(LSW)
+ */
+ Uint32 BufOffLen;
+
+ /**
+ * @brief Packet Flags(MSW) and Length(LSW)
+ */
+ volatile Uint32 PktFlgLen;
+}EMAC_Desc;
+
+/**
+ * @brief
+ * The structure describes the EMAC Master Control Block.
+ *
+ * @details
+ * The structure stores information required by the EMAC Driver;
+ * which includes the Receive and Transmit Buffer Descriptors.
+ */
+typedef struct EMAC_MCB
+{
+ /**
+ * @brief Pointer to the Receive Buffer Descriptor
+ */
+ EMAC_Desc* rx_bd;
+
+ /**
+ * @brief Pointer to the Transmit Buffer Descriptor
+ */
+ EMAC_Desc* tx_bd;
+
+ /**
+ * @brief Buffer for receiving data linked with the receive
+ * buffer descriptor.
+ */
+ Uint8 rx_buffer[NET_MAX_MTU];
+}EMAC_MCB;
+
+/**********************************************************************
+ ************************** Global Variables **************************
+ **********************************************************************/
+
+/**
+ * @brief Global Driver structure which keeps track of all the Ethernet
+ * Driver related information.
+ */
+EMAC_MCB emacMCB;
+
+/**
+ * @brief EMAC Registers.
+ */
+CPMAC_REGS* ptr_EMACRegs = (CPMAC_REGS *)EMAC_BASE_ADDRESS;
+
+/**********************************************************************
+ ************************** ETHDRV Functions **************************
+ **********************************************************************/
+
+/**
+ * @b Description
+ * @n
+ * This is the Network Open API which is registered with the
+ * NET Boot module to initialize the Ethernet device.
+ *
+ * @param[in] ptr_device
+ * Pointer to the NET Device structure which is being opened.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+Int32 cpmac_drv_start (NET_DRV_DEVICE* ptr_device)
+{
+ Uint32 tmpval;
+ volatile Uint32* pRegAddr;
+ Int32 index;
+ EMAC_Desc* pDesc;
+
+ /* Reset EMAC */
+ ptr_EMACRegs->SOFTRESET = 0x1;
+ while (ptr_EMACRegs->SOFTRESET != 0x0);
+
+ /* Reset MAC Control */
+ ptr_EMACRegs->MACCONTROL = 0;
+
+ /* Must manually init HDPs to NULL */
+ pRegAddr = &ptr_EMACRegs->TX0HDP;
+ for( index=0; index<8; index++ )
+ *pRegAddr++ = 0;
+ pRegAddr = &ptr_EMACRegs->RX0HDP;
+ for( index=0; index<8; index++ )
+ *pRegAddr++ = 0;
+
+ /* Initialize the RAM locations */
+ for (index = 0; index < 32; index++)
+ {
+ ptr_EMACRegs->MACINDEX = index;
+ ptr_EMACRegs->MACADDRHI = 0;
+ ptr_EMACRegs->MACADDRLO = 0;
+ }
+
+ /* Setup device MAC address */
+ ptr_EMACRegs->MACINDEX = 0x0;
+
+ /* Configure the MAC Address into the EMAC Controller. */
+ tmpval = 0;
+ for( index=3; index>=0; index-- )
+ tmpval = (tmpval<<8) | *(ptr_device->mac_address+index);
+ ptr_EMACRegs->MACADDRHI = tmpval;
+ tmpval = *(ptr_device->mac_address+5);
+ ptr_EMACRegs->MACADDRLO = CPMAC_MACADDRLO_VALID | CPMAC_MACADDRLO_MATCHFILT |
+ (tmpval<<8) | *(ptr_device->mac_address+4);
+
+ /* For us buffer offset will always be zero */
+ ptr_EMACRegs->RXBUFFEROFFSET = 0;
+
+ /* Reset RX (M)ulticast (B)roadcast (P)romiscuous Enable register */
+ ptr_EMACRegs->RXMBPENABLE = 0;
+ ptr_EMACRegs->MACHASH1 = 0;
+ ptr_EMACRegs->MACHASH2 = 0;
+
+ /* Clear Unicast RX on channel 0-7 */
+ ptr_EMACRegs->RXUNICASTCLEAR = 0xFF;
+
+ /* Make sure there are none of the interrupts are enabled. */
+ ptr_EMACRegs->RXINTMASKCLEAR = 0xFF;
+ ptr_EMACRegs->TXINTMASKCLEAR = 0xFF;
+ ptr_EMACRegs->MACINTMASKCLEAR = 0x0;
+
+ /* Setup the receive buffer descriptors. */
+ pDesc = (EMAC_Desc *)_EMAC_DSC_BASE_ADDR;
+
+ /* Initialize the receive buffer descriptor. */
+ pDesc->pNext = 0;
+ pDesc->pBuffer = &emacMCB.rx_buffer[0];
+ pDesc->BufOffLen = NET_MAX_MTU;
+ pDesc->PktFlgLen = EMAC_DSC_FLAG_OWNER;
+
+ /* Store this buffer descriptor in the global EMAC MCB */
+ emacMCB.rx_bd = pDesc;
+
+ /* Get the transmit buffer descriptor; it comes right after the receive BD. */
+ pDesc = pDesc + 1;
+
+ /* Initialize the transmit buffer descriptor. */
+ pDesc->pNext = 0;
+ pDesc->pBuffer = 0;
+ pDesc->BufOffLen = 0;
+ pDesc->PktFlgLen = 0;
+
+ /* Store this buffer descriptor in the global EMAC MCB */
+ emacMCB.tx_bd = pDesc;
+
+#ifdef EMAC_CACHE_SUPPORT
+ /* Writeback the EMAC MCB Information to the PHYSICAL Memory.
+ * This is required because the buffer in the cache will always be
+ * invalidated on the RECEIVE; if the buffer is not aligned on the
+ * CACHE Line then it will result in the RX & TX BD in the structure
+ * to also get invalidated to what resides in the PHYSICAL memory.
+ * But if we have written back the structure here then the PHYSICAL
+ * and CACHE are one and the same as far as the BD's are concerned. */
+ Cache_wbL2((void *)&emacMCB, sizeof(emacMCB));
+#endif
+
+ /* Enable the receive and transmit. */
+ ptr_EMACRegs->TXCONTROL = 0x1;
+ ptr_EMACRegs->RXCONTROL = 0x1;
+
+ /* Initialize the MAC Control: We set the Receive Ownership Bit and the Receive
+ * Offset Length Word and enable the MII. */
+ ptr_EMACRegs->MACCONTROL = CPMAC_MACCONTROL_RXOWNERSHIP |
+ CPMAC_MACCONTROL_RXOFFLENBLOCK |
+ CPMAC_MACCONTROL_MIIEN;
+
+ /* Startup RX */
+ ptr_EMACRegs->RX0HDP = (Uint32)emacMCB.rx_bd;
+
+ /* Enable receive filters for channel 1 and all broadcast packets. */
+ ptr_EMACRegs->RXUNICASTSET = 1;
+ ptr_EMACRegs->RXMBPENABLE = CPMAC_RXMBPENABLE_RXBROADEN;
+
+ /* Initialize the Device MDIO layer: The function returns only when
+ * the LINK is UP and RUNNING. */
+ if (dev_mdio_open () < 0)
+ return -1;
+
+ /* Debug Message: */
+ mprintf ("DEBUG: Ethernet Link is UP \n");
+
+ /* Hardware is up and running. */
+ return 0;
+}
+
+/**
+ * @b Description
+ * @n
+ * This is the Network Send API which is registered with the NET boot module
+ * to send out packets.
+ *
+ * @param[in] ptr_device
+ * Pointer to the network interface descriptor object.
+ * @param[in] buffer
+ * Pointer to the packet which is to be transmitted.
+ * @param[in] num_bytes
+ * Length of the packet which is transmitted.
+ *
+ * @retval
+ * Success - Number of bytes transmitted.
+ * @retval
+ * Error - <0
+ */
+Int32 cpmac_drv_send (NET_DRV_DEVICE* ptr_device, Uint8* buffer, int num_bytes)
+{
+ volatile EMAC_Desc* pDesc;
+
+ /* Ensure the minimum ethernet size is sent out. */
+ if (num_bytes < 64)
+ num_bytes = 64;
+
+#ifdef EMAC_CACHE_SUPPORT
+ /* Clean the cache for external addesses */
+ Cache_wbL2((void *)buffer, num_bytes);
+#endif
+
+ /* Get the pointer to the transmit buffer descriptor. */
+ pDesc = emacMCB.tx_bd;
+
+ /* Fill out the transmit buffer descriptor */
+ pDesc->pNext = 0;
+ pDesc->pBuffer = buffer;
+ pDesc->BufOffLen = num_bytes;
+ pDesc->PktFlgLen = EMAC_DSC_FLAG_SOP | EMAC_DSC_FLAG_EOP | num_bytes | EMAC_DSC_FLAG_OWNER;
+
+ /* Send the packet out. */
+ ptr_EMACRegs->TX0HDP = (Uint32)pDesc;
+
+ /* Loop around till the transmission is complete. */
+ pDesc = (EMAC_Desc *)ptr_EMACRegs->TX0CP;
+ while (pDesc->PktFlgLen & EMAC_DSC_FLAG_OWNER);
+
+ /* The packet has been successfully transmitted. */
+ return num_bytes;
+}
+
+/**
+ * @b Description
+ * @n
+ * This is the Network Receive API which is registered with the NET boot module
+ * to receive packets.
+ *
+ * @param[in] ptr_device
+ * Pointer to the network interface descriptor object.
+ * @param[out] buffer
+ * Pointer to the packet which is populated with the received data
+ *
+ * @retval
+ * Success - Number of bytes received.
+ * @retval
+ * Error - <0
+ */
+Int32 cpmac_drv_receive (NET_DRV_DEVICE* ptr_device, Uint8* buffer)
+{
+ Int32 bytes_received = 0;
+ EMAC_Desc* pDesc;
+
+ /* Initialize the number of bytes received. */
+ bytes_received = 0;
+
+ /* Read the completion register. We know for sure if the SOP flag is set then
+ * a packet has been received and needs to be picked up from the controller. */
+ pDesc = (EMAC_Desc *)ptr_EMACRegs->RX0CP;
+ if (pDesc->PktFlgLen & EMAC_DSC_FLAG_SOP)
+ {
+ /* Acknowledge that the descriptor has been processed. */
+ ptr_EMACRegs->RX0CP = (Uint32)pDesc;
+
+#ifdef EMAC_CACHE_SUPPORT
+ /* External Memory Support: Invalidate the cache. */
+ Cache_invL2((void *)(pDesc->pBuffer), NET_MAX_MTU);
+#endif
+ /* Remember the number of bytes received. */
+ bytes_received = (pDesc->PktFlgLen & 0xFFFF);
+
+ /* The descriptor is now free to receive more data. Set the status accordingly. */
+ pDesc->BufOffLen = NET_MAX_MTU;
+ pDesc->PktFlgLen = EMAC_DSC_FLAG_OWNER;
+
+ /* Copy the data from the descriptor buffer to the supplied buffer. */
+ memcpy((void *)buffer, (void *)pDesc->pBuffer, bytes_received);
+
+ /* Put this descriptor back to the HDP. */
+ ptr_EMACRegs->RX0HDP = (Uint32)pDesc;
+ }
+
+ /* Return the number of bytes received. */
+ return bytes_received;
+}
+
+/**
+ * @b Description
+ * @n
+ * This is the Network Close API which is registered with the NET boot module
+ * to close and shutdown the Ethernet controller.
+ *
+ * @param[in] ptr_device
+ * Pointer to the network interface descriptor object.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+Int32 cpmac_drv_stop (NET_DRV_DEVICE* ptr_device)
+{
+ return 0;
+}
+
+
diff --git a/src/hw/macs/cpmacdrv.h b/src/hw/macs/cpmacdrv.h
--- /dev/null
+++ b/src/hw/macs/cpmacdrv.h
@@ -0,0 +1,28 @@
+/**
+ * @file cpmacdrv.h
+ *
+ * @brief
+ * Describes the common API wrapper for all ethernet devices
+ *
+ */
+#ifndef CPMACDRV_H
+#define CPMACDRV_H
+
+#include "types.h"
+#include "net.h"
+
+
+Int32 cpmac_drv_start (NET_DRV_DEVICE* ptr_device);
+Int32 cpmac_drv_send (NET_DRV_DEVICE* ptr_device, Uint8* buffer, int num_bytes);
+Int32 cpmac_drv_receive (NET_DRV_DEVICE* ptr_device, Uint8* buffer);
+Int32 cpmac_drv_stop (NET_DRV_DEVICE* ptr_device);
+
+
+
+#endif /* CPMACDRV_H */
+
+
+
+
+
+
diff --git a/src/hw/mdio/mdio.c b/src/hw/mdio/mdio.c
--- /dev/null
+++ b/src/hw/mdio/mdio.c
@@ -0,0 +1,66 @@
+/**********************************************************************************
+ * FILE PURPOSE: A very simple mdio driver
+ **********************************************************************************
+ * FILE NAME: mdio.c
+ *
+ * DESCRIPTION: Enables mdio and performs blind access
+ *
+ * @file mdio.c
+ *
+ * @brief
+ * Enables mdio and performs blind access
+ *
+ **********************************************************************************/
+#include "types.h"
+#include "mdio.h"
+#include "device.h"
+
+/***********************************************************************************
+ * FUNCTION PURPOSE: Provide an approximate delay
+ ***********************************************************************************
+ * DESCRIPTION: A delay in units of CPU cycles is executed
+ ***********************************************************************************/
+void mdio_delay (uint32 del)
+{
+ volatile unsigned int i;
+
+ for (i = 0; i < del/8; i++);
+
+}
+
+/***********************************************************************************
+ * FUNCTION PURPOSE: Perform blind MDIO access
+ ***********************************************************************************
+ * DESCRIPTION: Pre-configured mdio access is performed.
+ ***********************************************************************************/
+void hwMdio (int16 nAccess, uint32 *access, uint16 clkdiv, uint32 delayCpuCycles)
+{
+ int16 i;
+
+ /* Enable MDIO, set the divider. A divider value of 0 is not allowed */
+ if (clkdiv == 0)
+ clkdiv = 1;
+
+ MDIOR->CONTROL = (0x40000000 | clkdiv);
+
+
+ for (i = 0; i < nAccess; i++) {
+
+ /* Set the Go bit */
+ MDIOR->USERACCESS0 = (((uint32)1 << 31) | access[i]);
+ while (MDIOR->USERACCESS0 & 0x80000000);
+
+ mdio_delay (delayCpuCycles);
+
+ }
+
+ /* A big delay after the last configure */
+ mdio_delay (1000000);
+
+}
+
+
+
+
+
+
diff --git a/src/hw/mdio/mdio.h b/src/hw/mdio/mdio.h
--- /dev/null
+++ b/src/hw/mdio/mdio.h
@@ -0,0 +1,80 @@
+/******************************************************************************
+ * Copyright (c) 2010 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 Name: mdio.h
+ *
+ * Description: This file contains typdedefs and macros for MDIO.
+ *
+ * History:
+ * AUG/14/2009, Amit Solanki, Created the file
+ *
+ ******************************************************************************/
+#ifndef MDIO_H_
+#define MDIO_H_
+
+/****************
+ * Include Files
+****************/
+#include "types.h"
+
+/*********************
+ * Typedefs and Enums
+ *********************/
+/**************************************************************************\
+* Register Overlay Structure
+\**************************************************************************/
+typedef struct _MdioRegs{
+ VUint32 VERSION;
+ VUint32 CONTROL;
+ VUint32 ALIVE;
+ VUint32 LINK;
+ VUint32 LINKINTRAW;
+ VUint32 LINKINTMASKED;
+ VUint8 RSVD0[8];
+ VUint32 USERINTRAW;
+ VUint32 USERINTMASKED;
+ VUint32 USERINTMASKSET;
+ VUint32 USERINTMASKCLEAR;
+ VUint8 RSVD1[80];
+ VUint32 USERACCESS0;
+ VUint32 USERPHYSEL0;
+ VUint32 USERACCESS1;
+ VUint32 USERPHYSEL1;
+}MdioRegs;
+
+#define MDIOR ((MdioRegs *) TARGET_MDIO_BASE)
+
+
+#endif /*MDIO_H_*/
diff --git a/src/hw/mdio/mdioapi.h b/src/hw/mdio/mdioapi.h
--- /dev/null
+++ b/src/hw/mdio/mdioapi.h
@@ -0,0 +1,21 @@
+#ifndef MDIO_API_H
+#define MDIO_API_H
+/*************************************************************************************
+ * FILE PURPOSE: Define the API to the mdio driver
+ *************************************************************************************
+ * FILE NAME: mdioapi.h
+ *
+ * DESCRIPTION: The MDIO api is defined
+ *
+ * @file mdioapi.h
+ *
+ * @brief
+ * The MDIO api is defined
+ **************************************************************************************/
+
+void hwMdio (int16 nAccess, uint32 *access, uint16 clkdiv, uint32 delayCpuCycles);
+
+
+
+
+#endif /* MDIO_API_H */
diff --git a/src/hw/nands/gpio/nandgpio.c b/src/hw/nands/gpio/nandgpio.c
--- /dev/null
@@ -0,0 +1,324 @@
+/********************************************************************************
+ * FILE PURPOSE: Hardware nand driver for 8 bit hwGpio driven nand
+ ********************************************************************************
+ * FILE NAME: nandhwGpio.c
+ *
+ * DESCRIPTION: The low level nand driver which accesses the nand through hwGpio
+ *
+ * @file nandhwGpio.c
+ *
+ * @brief
+ * The low level nand driver which accesses the nand through hwGpio
+ *
+ ********************************************************************************/
+#include "types.h"
+#include "ibl.h"
+#include "nandhwapi.h"
+#include "gpio.h"
+#include "ecc.h"
+#include "target.h"
+
+/* Pointer to the device configuration */
+nandDevInfo_t *hwDevInfo;
+
+
+/**
+ * @brief
+ * Delay for a number of cycles (approximate)
+ */
+
+void ndelay(Uint32 uiDelay)
+{
+ volatile Uint32 i;
+
+ for (i = 0; i < uiDelay>>3; i++);
+}
+
+
+
+/**
+ * @brief
+ * a 100us delay
+ */
+void ptNandWaitRdy(void)
+{
+ ndelay(100 * 1000); // 100 usec
+}
+
+
+/**
+ * @brief
+ * Write to the flash (command for the boot loader)
+ */
+void ptNandWriteDataByte(Uint8 data)
+{
+ // Data is written to the data register on the rising edge of WE# when
+ // \95 CE#, CLE, and ALE are LOW, and
+ // \95 the device is not busy.
+ hwGpioClearOutput(NAND_NWE_GPIO_PIN);
+ ndelay(TARGET_NAND_STD_DELAY);
+ hwGpioClearDataBus(GPIO_DATAMASK);
+ hwGpioWriteDataBus(data);
+ ndelay(TARGET_NAND_STD_DELAY);
+ hwGpioSetOutput(NAND_NWE_GPIO_PIN); // At posedge clock, make WE# = 1.
+ ndelay(TARGET_NAND_STD_DELAY);
+}
+
+
+/**
+ * @brief
+ * Set the address latch
+ */
+void ptNandAleSet(Uint32 addr)
+{
+ // ALE HIGH indicates address cycle occurring
+ hwGpioSetOutput(NAND_ALE_GPIO_PIN);
+ ptNandWriteDataByte(addr);
+ hwGpioClearOutput(NAND_ALE_GPIO_PIN);
+}
+
+/**
+ * @brief
+ * Write a command to the nand flash
+ */
+void ptNandCmdSet(Uint32 cmd)
+{
+ // Commands are written to the command register on the rising edge of WE# when
+ // \95 CE# and ALE are LOW, and
+ // \95 CLE is HIGH, and : CLE HIGH indicates command cycle occurring
+ // \95 the device is not busy
+ hwGpioSetOutput(NAND_CLE_GPIO_PIN);
+ ptNandWriteDataByte(cmd);
+ hwGpioClearOutput(NAND_CLE_GPIO_PIN);
+}
+
+
+/**
+ * @brief
+ * Setup hwGpio to drive the NAND interface
+ */
+void ptNandConfig (void)
+{
+ // Set direction of control signals as OUT
+ hwGpioSetDirection(NAND_CLE_GPIO_PIN, GPIO_OUT);
+ hwGpioSetDirection(NAND_NCE_GPIO_PIN, GPIO_OUT);
+ hwGpioSetDirection(NAND_NWE_GPIO_PIN, GPIO_OUT);
+ hwGpioSetDirection(NAND_ALE_GPIO_PIN, GPIO_OUT);
+ hwGpioSetDirection(NAND_NRE_GPIO_PIN, GPIO_OUT);
+
+ // Set Data Bus direction as OUT
+ hwGpioSetDataBusDirection(GPIO_OUT);
+
+ hwGpioSetOutput(NAND_NCE_GPIO_PIN); // Chip Enable = 1
+ hwGpioClearOutput(NAND_CLE_GPIO_PIN); // Command Latch enable = 0
+ hwGpioClearOutput(NAND_ALE_GPIO_PIN); // Address latch Enable = 0
+ hwGpioSetOutput(NAND_NWE_GPIO_PIN); // Write Enable = 1
+ hwGpioSetOutput(NAND_NRE_GPIO_PIN); // Read Enable = 1
+}
+
+/**
+ * @brief Initialize the driver
+ *
+ */
+Int32 nandHwDriverInit (nandDevInfo_t *devInfo)
+{
+ Uint32 cmd;
+
+ hwDevInfo = devInfo;
+
+ if (devInfo->addressBytes > 4)
+ return (NAND_INVALID_ADDR_SIZE);
+
+ // Initialize NAND interface
+ ptNandConfig();
+ ndelay(TARGET_NAND_STD_DELAY*10);
+
+ cmd = hwDevInfo->resetCommand;
+ // Send reset command to NAND
+ hwGpioClearOutput(NAND_NCE_GPIO_PIN); // Chip EN = 0
+ ptNandCmdSet(cmd);
+ hwGpioSetOutput(NAND_NCE_GPIO_PIN);
+
+ ptNandWaitRdy();
+
+ return (0);
+}
+
+/**
+ * @brief
+ * Read a single data byte
+ */
+void ptNandReadDataByte(Uint8* puchValue)
+{
+ // Set Data Bus direction as IN
+ hwGpioSetDataBusDirection(GPIO_IN);
+
+ hwGpioClearOutput(NAND_NRE_GPIO_PIN);
+ ndelay(TARGET_NAND_STD_DELAY);
+
+ *puchValue = hwGpioReadDataBus();
+ hwGpioSetOutput(NAND_NRE_GPIO_PIN);
+ ndelay(TARGET_NAND_STD_DELAY);
+
+ // Set Data Bus direction as OUT
+ hwGpioSetDataBusDirection(GPIO_OUT);
+ ndelay(TARGET_NAND_STD_DELAY);
+}
+
+/**
+ * @brief
+ * Read multiple bytes
+ */
+Uint32 ptNandReadDataBytes(Uint32 numBytes, Uint8 *destAddr)
+{
+ Uint32 i;
+
+ // 8-bit NAND
+ for (i = 0; i < numBytes; i++)
+ {
+ // NANDRead done directly without checking for nand width
+ ptNandReadDataByte((Uint8 *)destAddr);
+ destAddr++;
+ }
+ return SUCCESS;
+}
+
+/**
+ * @brief
+ * Swap the bytes in a 4 byte field
+ */
+Uint32 swapBytes (Uint32 v)
+{
+ Uint32 w;
+
+ w = (((v >> 24) & 0xff) << 0) |
+ (((v >> 16) & 0xff) << 8) |
+ (((v >> 8) & 0xff) << 16) |
+ (((v >> 0) & 0xff) << 24) ;
+
+ return (w);
+
+}
+
+
+/**
+ * @brief
+ * Read a complete page including the extra page bytes.
+ */
+
+Int32 nandHwDriverReadBytes (Uint32 block, Uint32 page, Uint32 byte, Uint32 nbytes, Uint8 *data)
+{
+
+ Uint32 addr;
+
+ if (data == NULL)
+ return (NAND_NULL_ARG);
+
+ if ( (block >= hwDevInfo->totalBlocks) ||
+ (page >= hwDevInfo->pagesPerBlock) )
+ return (NAND_INVALID_ADDR);
+
+ ndelay(TARGET_NAND_STD_DELAY*10);
+
+ hwGpioClearOutput(NAND_NCE_GPIO_PIN);
+ ndelay(TARGET_NAND_STD_DELAY*5);
+
+ ptNandCmdSet(hwDevInfo->readCommandPre); // First cycle send 0
+
+ // Send address of the block + page to be read
+ // Address cycles = 4, Block shift = 22, Page Shift = 16, Bigblock = 0
+ addr = (block << hwDevInfo->blockOffset) +
+ (page << hwDevInfo->pageOffset) +
+ (byte << hwDevInfo->columnOffset);
+
+ if (hwDevInfo->lsbFirst == FALSE)
+ addr = swapBytes (addr);
+
+ ptNandAleSet(addr & 0xFF); // BIT0-7 1rst Cycle
+ ndelay(TARGET_NAND_STD_DELAY);
+
+ if (hwDevInfo->addressBytes >= 2) {
+ ptNandAleSet((addr >> 8u) & 0x0F); // Bits8-11 2nd Cycle
+ ndelay(TARGET_NAND_STD_DELAY);
+ }
+
+ if (hwDevInfo->addressBytes >= 3) {
+ ptNandAleSet((addr >> 16u) & 0xFF); // Bits16-23
+ ndelay(TARGET_NAND_STD_DELAY);
+ }
+
+ if (hwDevInfo->addressBytes >= 4) {
+ ptNandAleSet((addr >> 24u) & 0xFF); // Bits24-31
+ ndelay(TARGET_NAND_STD_DELAY);
+ }
+
+ if (hwDevInfo->postCommand == TRUE)
+ ptNandCmdSet(hwDevInfo->readCommandPost);
+
+ // Wait for Ready Busy Pin to go HIGH
+ ptNandWaitRdy();
+
+
+ ptNandReadDataBytes(nbytes, data);
+
+
+ // Set Chip enable
+ hwGpioSetOutput(NAND_NCE_GPIO_PIN);
+ ndelay(TARGET_NAND_STD_DELAY*5);
+
+ return (0);
+}
+
+
+
+
+/**
+ * @brief
+ * Read a complete page including the extra page bytes
+ */
+Int32 nandHwDriverReadPage(Uint32 block, Uint32 page, Uint8 *data)
+{
+ Int32 ret;
+ Int32 i;
+ Int32 nblocks;
+ Uint8 *blockp;
+ Uint8 *eccp;
+ Uint8 eccCalc[3];
+
+ /* Read the page, including the extra bytes */
+ ret = nandHwDriverReadBytes (block, page, 0, hwDevInfo->pageSizeBytes + hwDevInfo->pageEccBytes, data);
+ if (ret < 0)
+ return (ret);
+
+ /* Perform ECC on 256 byte blocks. Three bytes of ecc per 512 byte block are used. The last
+ * 3 bytes are used for the last block, the previous three for the block before that, etc */
+ nblocks = hwDevInfo->pageSizeBytes >> 8;
+
+ for (i = 0; i < nblocks; i++) {
+
+ blockp = &data[i * 256];
+ eccp = &data[hwDevInfo->pageSizeBytes + hwDevInfo->pageEccBytes - ((nblocks - i) * 3)];
+
+ eccComputeECC (blockp, eccCalc);
+
+ if (eccCorrectData (blockp, eccp, eccCalc) != ECC_SUCCESS)
+ return (NAND_ECC_FAILURE);
+
+ }
+
+ return (0);
+
+}
+
+
+
+/**
+ * @brief
+ * Close the driver
+ */
+int32 nandHwDriverClose (void)
+{
+ return (0);
+
+}
+
diff --git a/src/hw/nands/nandhwapi.h b/src/hw/nands/nandhwapi.h
--- /dev/null
+++ b/src/hw/nands/nandhwapi.h
@@ -0,0 +1,34 @@
+#ifndef _NAND_HW_API_H
+#define _NAND_HW_API_H
+/****************************************************************************************
+ * FILE PURPOSE: Define the nand api which applies to all nand drivers
+ ****************************************************************************************
+ * FILE NAME: nandhwapi.h
+ *
+ * DESCRIPTION: Defines the API used by all the low level nand drivers
+ *
+ * @file nandhwapi.h
+ *
+ * @brief
+ * Defines the API used by all the low level nand drivers
+ *
+ ****************************************************************************************/
+
+/* Return values */
+#define NAND_INVALID_ADDR_SIZE -810
+#define NAND_NULL_ARG -811
+#define NAND_INVALID_ADDR -812
+#define NAND_ECC_FAILURE -813
+
+
+/* Driver functions */
+Int32 nandHwDriverInit (nandDevInfo_t *devInfo);
+Int32 nandHwDriverReadBytes (Uint32 block, Uint32 page, Uint32 byte, Uint32 nbytes, Uint8 *data);
+Int32 nandHwDriverReadPage(Uint32 block, Uint32 page, Uint8 *data);
+Int32 nandHwDriverClose (void);
+
+
+
+
+
+#endif /* _NAND_HW_API_H */
diff --git a/src/hw/plls/pllapi.h b/src/hw/plls/pllapi.h
--- /dev/null
+++ b/src/hw/plls/pllapi.h
@@ -0,0 +1,39 @@
+#ifndef _PLLAPI_H
+#define _PLLAPI_H
+/*************************************************************************************
+ * FILE PURPOSE: Define the public pll api
+ *************************************************************************************
+ * FILE NAME: pllapi.h
+ *
+ * DESCRIPTION: Defines the public api for the pll driver
+ *
+ * @file pllapi.h
+ *
+ * @brief
+ * This file defines the API used by all PLL drivers
+ *
+ *************************************************************************************/
+#include "types.h"
+
+/* Prototypes */
+uint16 hwPllResetType (uint16 pllNum);
+int16 hwPllSetPll (uint16 pllNum, uint16 prediv, uint16 mult, uint16 postdiv);
+int16 hwPllDisable (uint16 pllNum);
+int16 hwPllEnable (uint16 pllNum);
+
+
+/**
+ * @def pll_POR_RESET
+ */
+#define pll_POR_RESET 500 /**< last reset was a power on reset */
+
+/**
+ * @def pll_WARM_RESET
+ */
+#define pll_WARM_RESET 501 /**< last reset was a warm reset */
+
+
+
+#endif /* _PLLAPI_H */
+
+
diff --git a/src/hw/plls/pllxx1p8/pll.c b/src/hw/plls/pllxx1p8/pll.c
--- /dev/null
@@ -0,0 +1,228 @@
+/*************************************************************************************
+ * FILE PURPOSE: Provide PLL control functions
+ *************************************************************************************
+ * FILE NAME: pll.c
+ *
+ * DESCRIPTION: Provides functions to control the pll
+ *
+ * @file pll.c
+ *
+ * @brief
+ * The pllhi1p8 and pllmd1ph driver
+ *
+ *************************************************************************************/
+#include "types.h"
+#include "pllloc.h"
+#include "pllapi.h"
+#include "target.h"
+
+
+#define DEVICE_REG32_W(x,y) *(volatile unsigned int *)(x)=(y)
+#define DEVICE_REG32_R(x) (*(volatile unsigned int *)(x))
+
+/**************************************************************************************
+ * FUNCTION PURPOSE: Return the last boot type
+ **************************************************************************************
+ * DESCRIPTION: Returns the last boot mode type
+ **************************************************************************************/
+uint16 hwPllResetType (uint16 pllNum)
+{
+ if ( ((DEVICE_REG32_R (DEVICE_PLL_BASE(pllNum) + PLL_REG_RSTYPE)) & PLL_REG_RSTYPE_FIELD_POWER_ON_RESET) != 0 )
+ return (pll_POR_RESET);
+
+ return (pll_WARM_RESET);
+
+} /* hwPllResetType */
+
+
+/*********************************************************************************
+ * FUNCTION PURPOSE: Provide a delay loop
+ *********************************************************************************
+ * DESCRIPTION: Generates a delay, units of cycles
+ *********************************************************************************/
+void hw_pll_delay (uint32 del)
+{
+ uint32 i;
+ volatile uint32 j;
+
+ for (i = j = 0; i < del; i++)
+ j = j + 1;
+
+} /* hw_pll_delay */
+
+
+/**********************************************************************************
+ * FUNCTION PURPOSE: Enables the pll to the specified multiplier
+ **********************************************************************************
+ * DESCRIPTION: Sets up the pll
+ **********************************************************************************/
+int16 hwPllSetPll (uint16 pllNum, uint16 prediv, uint16 mult, uint16 postdiv)
+{
+ uint32 ctl;
+ uint32 status;
+ uint32 pmult;
+ uint32 pdiv;
+ uint32 pllBase;
+ uint32 i;
+
+ /* Mutliplier/divider values of 0 are invalid */
+ if (prediv == 0)
+ prediv = 1;
+
+ if (mult == 0)
+ mult = 1;
+
+ if (postdiv == 0)
+ postdiv = 1;
+
+ /* Get the base address of the pll */
+ pllBase = (uint32) DEVICE_PLL_BASE(pllNum);
+
+ /* Set pllensrc = 0 so that the register bit pllen can control the pllen mux */
+ ctl = DEVICE_REG32_R (pllBase + PLL_REG_CTL);
+ ctl = ctl & ~(PLL_REG_CTL_FIELD_PLLENSRC);
+ DEVICE_REG32_W (pllBase + PLL_REG_CTL, ctl);
+
+
+ /* Program pllen=0 (pll bypass), pllrst=1 (reset pll) */
+ ctl = ctl & ~(PLL_REG_CTL_FIELD_PLLEN);
+ ctl = ctl | PLL_REG_CTL_FIELD_PLLRST;
+ DEVICE_REG32_W (pllBase + PLL_REG_CTL, ctl);
+
+
+ /* Program prediv, pllm, postdiv */
+ pmult = (uint32) ((mult-1) & PLL_REG_PLLM_FIELD_MULTm1);
+ pdiv = (uint32) (((prediv-1) & PLL_REG_PREDIV_FIELD_RATIOm1) | PLL_REG_PREDIV_FIELD_ENABLE);
+
+ DEVICE_REG32_W (pllBase + PLL_REG_PLLM, pmult);
+ DEVICE_REG32_W (pllBase + PLL_REG_PREDIV, pdiv);
+
+ if (postdiv != 1) {
+ postdiv = (uint16) (((postdiv-1) & PLL_REG_POSTDIV_FIELD_RATIO) | PLL_REG_POSTDIV_FIELD_ENABLE);
+ DEVICE_REG32_W (pllBase + PLL_REG_POSTDIV, postdiv);
+ } else {
+ DEVICE_REG32_W (pllBase + PLL_REG_POSTDIV, PLL_REG_POSTDIV_VALUE_DISABLED);
+ }
+
+ /* Wait a while for the pll to reset */
+ hw_pll_delay (2000/7);
+
+ /* set pllrst to 0 to deassert pll reset */
+ ctl = ctl & ~(PLL_REG_CTL_FIELD_PLLRST);
+ DEVICE_REG32_W (pllBase + PLL_REG_CTL, ctl);
+
+
+ /* wait for the pll to lock, but don't trap if lock is never read */
+ for (i = 0; i < 100; i++) {
+ hw_pll_delay (2000/7);
+ status = DEVICE_REG32_R (pllBase + PLL_REG_PLLSTAT);
+ if ( (status & PLL_REG_STATUS_FIELD_LOCK) != 0 )
+ break;
+ }
+
+ /* Do not enable the pll if the lock failed. Return a warning. */
+ if (i == 100)
+ return (-1);
+
+
+ /* Set pllen to 1 to enable pll mode */
+ ctl = ctl | PLL_REG_CTL_FIELD_PLLEN;
+ DEVICE_REG32_W (pllBase + PLL_REG_CTL, ctl);
+
+ return (0);
+
+
+} /* hwPllSetPll */
+
+
+/**********************************************************************************
+ * FUNCTION PURPOSE: Disable the pll
+ **********************************************************************************
+ * DESCRIPTION: The pll is put into bypass. Returns 0 on success.
+ **********************************************************************************/
+int16 hwPllDisable (uint16 pllNum)
+{
+ uint32 ctl;
+ uint32 pllBase;
+
+ /* Get the base address of the pll */
+ pllBase = (uint32)DEVICE_PLL_BASE(pllNum);
+
+ /* Set pllensrc = 0 so that the register bit pllen can control the pllen mux */
+ ctl = DEVICE_REG32_R (pllBase + PLL_REG_CTL);
+ ctl = ctl & ~(PLL_REG_CTL_FIELD_PLLENSRC);
+ DEVICE_REG32_W (pllBase + PLL_REG_CTL, ctl);
+
+
+ /* Program pllen=0 (pll bypass), pllrst=1 (reset pll) */
+ ctl = ctl & ~(PLL_REG_CTL_FIELD_PLLEN);
+ ctl = ctl | PLL_REG_CTL_FIELD_PLLRST;
+ DEVICE_REG32_W (pllBase + PLL_REG_CTL, ctl);
+
+ return (0);
+
+
+} /* hwPllDisable */
+
+/***********************************************************************************
+ * FUNCTION PURPOSE: Enable the PLL
+ ***********************************************************************************
+ * DESCRIPTION: The PLL is enabled with no changes to multipliers or dividers
+ ***********************************************************************************/
+int16 hwPllEnable (uint16 pllNum)
+{
+ uint32 ctl;
+ uint32 pllBase;
+ uint32 status;
+ uint32 i;
+
+ /* Get the base address of the pll */
+ pllBase = (uint32)DEVICE_PLL_BASE(pllNum);
+
+ /* Set pllensrc = 0 so that the register bit pllen can control the pllen mux */
+ ctl = DEVICE_REG32_R (pllBase + PLL_REG_CTL);
+ ctl = ctl & ~(PLL_REG_CTL_FIELD_PLLENSRC);
+ DEVICE_REG32_W (pllBase + PLL_REG_CTL, ctl);
+
+ /* Program pllen=0 (pll bypass), pllrst=1 (reset pll) */
+ ctl = ctl & ~(PLL_REG_CTL_FIELD_PLLEN);
+ ctl = ctl | PLL_REG_CTL_FIELD_PLLRST;
+ DEVICE_REG32_W (pllBase + PLL_REG_CTL, ctl);
+
+ /* Wait a while for the pll to reset */
+ hw_pll_delay (2000/7);
+
+ /* set pllrst to 0 to deassert pll reset */
+ ctl = ctl & ~(PLL_REG_CTL_FIELD_PLLRST);
+ DEVICE_REG32_W (pllBase + PLL_REG_CTL, ctl);
+
+
+ /* wait for the pll to lock, but don't trap if lock is never read */
+ for (i = 0; i < 100; i++) {
+ hw_pll_delay (2000/7);
+ status = DEVICE_REG32_R (pllBase + PLL_REG_PLLSTAT);
+ if ( (status & PLL_REG_STATUS_FIELD_LOCK) != 0 )
+ break;
+ }
+
+ /* Return a warning if the lock failed */
+ if (i == 100)
+ return (-1);
+
+ /* Set pllen to 1 to enable pll mode */
+ ctl = ctl | PLL_REG_CTL_FIELD_PLLEN;
+ DEVICE_REG32_W (pllBase + PLL_REG_CTL, ctl);
+
+ return (0);
+
+} /* hwPllEnable */
+
+
+
+
+
+
+
+
+
+
diff --git a/src/hw/plls/pllxx1p8/pllloc.h b/src/hw/plls/pllxx1p8/pllloc.h
--- /dev/null
@@ -0,0 +1,50 @@
+#ifndef _PLLLOC_H
+#define _PLLLOC_H
+/**************************************************************************************
+ * FILE PURPOSE: Local pll definitions
+ **************************************************************************************
+ * FILE NAME: pllloc.h
+ *
+ * DESCRIPTION: Local definitions for the pll driver
+ **************************************************************************************/
+
+/* Register offsets */
+#define PLL_REG_RSTYPE 0x00e4
+#define PLL_REG_CTL 0x0100
+#define PLL_REG_PLLM 0x0110
+#define PLL_REG_PREDIV 0x0114
+#define PLL_REG_POSTDIV 0x0128
+#define PLL_REG_PLLSTAT 0x013c
+
+
+/* Bit fields */
+/* Reset type register */
+#define PLL_REG_RSTYPE_FIELD_POWER_ON_RESET (1<<0)
+
+/* Ctl register */
+#define PLL_REG_CTL_FIELD_PLLEN (1<<0)
+#define PLL_REG_CTL_FIELD_PLLRST (1<<3)
+#define PLL_REG_CTL_FIELD_PLLENSRC (1<<5)
+
+
+/* Pll multiplier register */
+#define PLL_REG_PLLM_FIELD_MULTm1 (0x3f<<0)
+
+/* Prediv register */
+#define PLL_REG_PREDIV_FIELD_RATIOm1 (0x1f<<0)
+#define PLL_REG_PREDIV_FIELD_ENABLE (1<<15)
+
+/* Postdiv register */
+#define PLL_REG_POSTDIV_FIELD_RATIO (0x3f <<0)
+#define PLL_REG_POSTDIV_FIELD_ENABLE (1<<15)
+#define PLL_REG_POSTDIV_VALUE_DISABLED 0
+
+/* Status register */
+#define PLL_REG_STATUS_FIELD_LOCK (1<<1)
+
+
+
+#endif /* _PLLLOC_H */
+
+
+
diff --git a/src/hw/pscs/psc2/psc.c b/src/hw/pscs/psc2/psc.c
--- /dev/null
+++ b/src/hw/pscs/psc2/psc.c
@@ -0,0 +1,306 @@
+/***********************************************************************************
+ * FILE PURPOSE: Driver for the PSC module
+ ***********************************************************************************
+ * FILE NAME: psc.c
+ *
+ * DESCRIPTION: The boot loader PSC driver
+ *
+ * Copyright (C) 2006, Texas Instruments, Inc.
+ *
+ * @file psc.c
+ *
+ * @brief
+ * The PSC 2.0.x driver
+ *
+ ***********************************************************************************/
+#include "types.h"
+#include "pscapi.h"
+#include "pscloc.h"
+#include "target.h"
+
+
+#define DEVICE_REG32_W(x,y) *(volatile unsigned int *)(x)=(y)
+#define DEVICE_REG32_R(x) (*(volatile unsigned int *)(x))
+
+/***********************************************************************************
+ * FUNCTION PURPOSE: Wait!
+ ***********************************************************************************
+ * DESCRIPTION: This function doesn't do didly. It loops around for a bit
+ * to give transitions some time to occur.
+ * This function always returns 1.
+ ***********************************************************************************/
+int16 pscDelay (void)
+{
+ volatile uint32 i;
+ for (i = 0; i < 100; i++);
+
+ return (0);
+
+} /* pscDelay */
+
+
+/***********************************************************************************
+ * FUNCTION PURPOSE: Wait for end of transitional state
+ ***********************************************************************************
+ * DESCRIPTION: Polls pstat for the selected domain and waits for transitions
+ * to be complete.
+ *
+ * Since this is boot loader code it is *ASSUMED* that interrupts
+ * are disabled and no other core is mucking around with the psc
+ * at the same time.
+ *
+ * Returns 0 when the domain is free. Returns -1 if a timeout
+ * occurred waiting for the completion.
+ ***********************************************************************************/
+int16 pscWait (uint32 domainNum)
+{
+ uint32 retry;
+ uint32 ptstat;
+
+ /* Do nothing if the power domain is in transition. This should never
+ * happen since the boot code is the only software accesses psc.
+ * It's still remotely possible that the hardware state machines initiate transitions.
+ * Don't trap if the domain (or a module in this domain) is
+ * stuck in transition. */
+ retry = 0;
+
+ do {
+
+ ptstat = DEVICE_REG32_R (DEVICE_PSC_BASE + PSC_REG_PSTAT);
+ ptstat = ptstat & (1 << domainNum);
+
+ } while ((ptstat != 0) && ((retry += pscDelay ()) < PSC_PTSTAT_TIMEOUT_LIMIT));
+
+ if (retry >= PSC_PTSTAT_TIMEOUT_LIMIT)
+ return (-1);
+
+ return (0);
+
+} /* pscWait */
+
+
+/***********************************************************************************
+ * FUNCTION PURPOSE: Return the PSC state
+ ***********************************************************************************
+ * DESCRIPTION: Checks the power state of the module
+ ***********************************************************************************/
+BOOL pscModuleIsEnabled (uint32 modNum)
+{
+ uint32 domainNum;
+ uint32 mdstat;
+
+ /* Get the power domain associated with the module number */
+ domainNum = DEVICE_REG32_R (DEVICE_PSC_BASE + PSC_REG_MDCFG(modNum));
+ domainNum = PSC_REG_MDCFG_GET_PD (domainNum);
+
+ /* Wait for the status of the domain/module to be non-transitional,
+ * but don't trap if stuck in a transitional state. */
+ pscWait (domainNum);
+
+ mdstat = DEVICE_REG32_R (DEVICE_PSC_BASE + PSC_REG_MDSTAT(modNum));
+ mdstat = PSC_REG_MDSTAT_GET_STATUS (mdstat);
+
+ if ((mdstat == PSC_REG_VAL_MDSTAT_STATE_ON) ||
+ (mdstat == PSC_REG_VAL_MDSTAT_STATE_ENABLE_IN_PROG))
+ return (TRUE);
+
+ else
+
+ return (FALSE);
+
+} /* pscModuleIsEnabled */
+
+
+
+
+/***********************************************************************************
+ * FUNCTION PURPOSE: Power up/down a module
+ ***********************************************************************************
+ * DESCRIPTION: Powers up/down the requested module and the associated power domain
+ * if required. No action is taken it the module is already
+ * powered up/down.
+ *
+ * This only controls modules. The domain in which the module
+ * resides will be left in the power on state. Multiple modules
+ * can exist in a power domain, so powering down the domain based
+ * on a single module is not done.
+ *
+ * Returns 0 on success, -1 if the module can't be powered up, or
+ * if there is a timeout waiting for the transition.
+ ***********************************************************************************/
+int16 pscSetState (uint32 modNum, uint32 state)
+{
+
+ uint32 domainNum;
+ uint32 pdctl;
+ uint32 mdctl;
+ uint32 ptcmd;
+ uint32 resetIso;
+ uint32 v;
+
+ /* Get the power domain associated with the module number, and reset
+ * isolation functionality */
+ v = DEVICE_REG32_R (DEVICE_PSC_BASE + PSC_REG_MDCFG(modNum));
+ domainNum = PSC_REG_MDCFG_GET_PD (v);
+ resetIso = PSC_REG_MDCFG_GET_RESET_ISO(v);
+
+
+ /* Wait for the status of the domain/module to be non-transitional */
+ if (pscWait (domainNum) != 0)
+ return (-1);
+
+
+ /* Perform configuration even if the current status matches the existing state */
+
+
+ /* Set the next state of the power domain to on. It's OK if the domain
+ * is always on. This code will not ever power down a domain, so no change
+ * is made if the new state is power down. */
+ if (state == PSC_REG_VAL_MDCTL_NEXT_ON) {
+ pdctl = DEVICE_REG32_R (DEVICE_PSC_BASE + PSC_REG_PDCTL(domainNum));
+ pdctl = PSC_REG_PDCTL_SET_NEXT(pdctl, PSC_REG_VAL_PDCTL_NEXT_ON);
+ DEVICE_REG32_W (DEVICE_PSC_BASE + PSC_REG_PDCTL(domainNum), pdctl);
+ }
+
+
+ /* Set the next state for the module to enabled/disabled */
+ mdctl = DEVICE_REG32_R (DEVICE_PSC_BASE + PSC_REG_MDCTL(modNum));
+ mdctl = PSC_REG_MDCTL_SET_NEXT (mdctl, state);
+ mdctl = PSC_REG_MDCTL_SET_RESET_ISO (mdctl, resetIso);
+ DEVICE_REG32_W (DEVICE_PSC_BASE + PSC_REG_MDCTL(modNum), mdctl);
+
+ /* Trigger the enable */
+ ptcmd = DEVICE_REG32_R (DEVICE_PSC_BASE + PSC_REG_PTCMD);
+ ptcmd |= (uint32)(1<<domainNum);
+ DEVICE_REG32_W (DEVICE_PSC_BASE + PSC_REG_PTCMD, ptcmd);
+
+
+ /* Wait on the complete */
+ return (pscWait (domainNum));
+
+} /* pscSetState*/
+
+
+/***********************************************************************************
+ * FUNCTION PURPOSE: Power up a module
+ ***********************************************************************************
+ * DESCRIPTION: Powers up the requested module and the associated power domain
+ * if required. No action is taken it the module is already
+ * powered up.
+ *
+ * Returns 0 on success, -1 if the module can't be powered up, or
+ * if there is a timeout waiting for the transition.
+ ***********************************************************************************/
+int16 pscEnableModule (uint32 modNum)
+{
+
+ return (pscSetState (modNum, PSC_REG_VAL_MDCTL_NEXT_ON));
+
+} /* pscEnableModule */
+
+/************************************************************************************
+ * FUNCTION PURPOSE: Power down a module
+ ************************************************************************************
+ * DESCRIPTION: Powers down the requested module.
+ *
+ * Returns 0 on success, -1 on failure or timeout.
+ ************************************************************************************/
+int16 pscDisableModule (uint32 modNum)
+{
+ uint32 mdctl;
+
+ /* Set the bit to apply reset */
+ mdctl = DEVICE_REG32_R (DEVICE_PSC_BASE + PSC_REG_MDCTL(modNum));
+ mdctl = PSC_REG_MDCTL_SET_LRSTZ(mdctl,0);
+ DEVICE_REG32_W (DEVICE_PSC_BASE + PSC_REG_MDCTL(modNum), mdctl);
+
+ return (pscSetState (modNum, PSC_REG_VAL_MDCTL_NEXT_SWRSTDISABLE));
+
+} /* pscDisableModule */
+
+
+/************************************************************************************
+ * FUNCTION PURPOSE: Set the reset isolation bit in mdctl
+ ************************************************************************************
+ * DESCRIPTION: The reset isolation enable bit is set. The state of the module
+ * is not changed. Returns 0 if the module config showed that
+ * reset isolation is supported. Returns 1 otherwise. This is not
+ * an error, but setting the bit in mdctl has no effect.
+ ************************************************************************************/
+int16 pscSetResetIso (uint32 modNum)
+{
+ uint32 v;
+ uint32 mdctl;
+
+ /* Set the reset isolation bit */
+ mdctl = DEVICE_REG32_R (DEVICE_PSC_BASE + PSC_REG_MDCTL(modNum));
+ mdctl = PSC_REG_MDCTL_SET_RESET_ISO (mdctl, 1);
+ DEVICE_REG32_W (DEVICE_PSC_BASE + PSC_REG_MDCTL(modNum), mdctl);
+
+ v = DEVICE_REG32_R (DEVICE_PSC_BASE + PSC_REG_MDCFG(modNum));
+ if (PSC_REG_MDCFG_GET_RESET_ISO(v) == 1)
+ return (0);
+
+ return (1);
+
+} /* pscSetResetIso */
+
+/*************************************************************************************
+ * FUNCTION PURPOSE: Disable a power domain
+ *************************************************************************************
+ * DESCRIPTION: The power domain is disabled
+ *************************************************************************************/
+int16 pscDisableDomain (uint32 domainNum)
+{
+ uint32 pdctl;
+ uint32 ptcmd;
+
+ pdctl = DEVICE_REG32_R (DEVICE_PSC_BASE + PSC_REG_PDCTL(domainNum));
+ pdctl = PSC_REG_PDCTL_SET_NEXT (pdctl, PSC_REG_VAL_PDCTL_NEXT_OFF);
+ pdctl = PSC_REG_PDCTL_SET_PDMODE (pdctl, PSC_REG_VAL_PDCTL_PDMODE_SLEEP);
+ DEVICE_REG32_W (DEVICE_PSC_BASE + PSC_REG_PDCTL(domainNum), pdctl);
+
+ ptcmd = DEVICE_REG32_R (DEVICE_PSC_BASE + PSC_REG_PTCMD);
+ ptcmd |= (uint32)(1<<domainNum);
+ DEVICE_REG32_W (DEVICE_PSC_BASE + PSC_REG_PTCMD, ptcmd);
+
+ return (0);
+
+} /* pscDisableDomain */
+
+
+/*************************************************************************************
+ * FUNCTION PURPOSE: Power down a domain
+ *************************************************************************************
+ * DESCRIPTION: The specified power domain is set to the disabled state
+ *************************************************************************************/
+void pscDisableModAndDomain (uint32 modNum, uint32 domainNum)
+{
+ uint32 pdctl;
+ uint32 ptcmd;
+ uint32 mdctl;
+
+
+ mdctl = DEVICE_REG32_R (DEVICE_PSC_BASE + PSC_REG_MDCTL(modNum));
+ mdctl = PSC_REG_MDCTL_SET_NEXT(mdctl, PSC_REG_VAL_MDCTL_NEXT_SWRSTDISABLE);
+ mdctl = PSC_REG_MDCTL_SET_LRSTZ(mdctl,0);
+ DEVICE_REG32_W (DEVICE_PSC_BASE + PSC_REG_MDCTL(modNum), mdctl);
+
+
+ pdctl = DEVICE_REG32_R (DEVICE_PSC_BASE + PSC_REG_PDCTL(domainNum));
+ pdctl = PSC_REG_PDCTL_SET_NEXT (pdctl, PSC_REG_VAL_PDCTL_NEXT_OFF);
+ pdctl = PSC_REG_PDCTL_SET_PDMODE (pdctl, PSC_REG_VAL_PDCTL_PDMODE_SLEEP);
+
+ DEVICE_REG32_W (DEVICE_PSC_BASE + PSC_REG_PDCTL(domainNum), pdctl);
+
+ ptcmd = DEVICE_REG32_R (DEVICE_PSC_BASE + PSC_REG_PTCMD);
+ ptcmd |= (uint32)(1<<domainNum);
+ DEVICE_REG32_W (DEVICE_PSC_BASE + PSC_REG_PTCMD, ptcmd);
+
+
+ /* Wait on the complete */
+ pscWait (domainNum);
+
+}
+
+
diff --git a/src/hw/pscs/psc2/pscloc.h b/src/hw/pscs/psc2/pscloc.h
--- /dev/null
@@ -0,0 +1,80 @@
+#ifndef _PSCLOC_H
+#define _PSCLOC_H
+/*************************************************************************************
+ * FILE PURPOSE: Local Power Saver Controller definitions
+ *************************************************************************************
+ * FILE NAME: pscloc.h
+ *
+ * DESCRIPTION: Provides local definitions for the power saver controller
+ *
+ *************************************************************************************/
+
+
+#define BOOTBITMASK(x,y) ( ( ( ((uint32)1 << (((uint32)x)-((uint32)y)+(uint32)1) ) - (uint32)1 ) ) << ((uint32)y) )
+#define BOOT_READ_BITFIELD(z,x,y) (((uint32)z) & BOOTBITMASK(x,y)) >> (y)
+#define BOOT_SET_BITFIELD(z,f,x,y) (((uint32)z) & ~BOOTBITMASK(x,y)) | ( (((uint32)f) << (y)) & BOOTBITMASK(x,y) )
+
+/* Register offsets */
+#define PSC_REG_PTCMD 0x120
+#define PSC_REG_PSTAT 0x128
+#define PSC_REG_PDSTAT(x) (0x200 + (4*(x)))
+#define PSC_REG_PDCTL(x) (0x300 + (4*(x)))
+#define PSC_REG_MDCFG(x) (0x600 + (4*(x)))
+#define PSC_REG_MDSTAT(x) (0x800 + (4*(x)))
+#define PSC_REG_MDCTL(x) (0xa00 + (4*(x)))
+
+
+/* Macros to access register fields */
+/* PDCTL */
+#define PSC_REG_PDCTL_SET_NEXT(x,y) BOOT_SET_BITFIELD((x),(y),0,0)
+#define PSC_REG_PDCTL_SET_PDMODE(x,y) BOOT_SET_BITFIELD((x),(y),15,12)
+
+/* PDSTAT */
+#define PSC_REG_PDSTAT_GET_STATE(x) BOOT_READ_BITFIELD((x),4,0))
+
+/* MDCFG */
+#define PSC_REG_MDCFG_GET_PD(x) BOOT_READ_BITFIELD((x),20,16)
+#define PSC_REG_MDCFG_GET_RESET_ISO(x) BOOT_READ_BITFIELD((x),14,14)
+
+/* MDCTL */
+#define PSC_REG_MDCTL_SET_NEXT(x,y) BOOT_SET_BITFIELD((x),(y),4,0)
+#define PSC_REG_MDCTL_SET_LRSTZ(x,y) BOOT_SET_BITFIELD((x),(y),8,8)
+#define PSC_REG_MDCTL_GET_LRSTZ(x) BOOT_READ_BITFIELD((x),8,8)
+#define PSC_REG_MDCTL_SET_RESET_ISO(x,y) BOOT_SET_BITFIELD((x),(y),12,12)
+
+
+/* MDSTAT */
+#define PSC_REG_MDSTAT_GET_STATUS(x) BOOT_READ_BITFIELD((x),5,0)
+#define PSC_REG_MDSTAT_GET_LRSTZ(x) BOOT_READ_BITFIELD((x),8,8)
+#define PSC_REG_MDSTAT_GET_LRSTDONE(x) BOOT_READ_BITFIELD((x),9,9)
+
+/* PDCTL states */
+#define PSC_REG_VAL_PDCTL_NEXT_ON 1
+#define PSC_REG_VAL_PDCTL_NEXT_OFF 0
+
+#define PSC_REG_VAL_PDCTL_PDMODE_SLEEP 0
+
+/* MDCTL states */
+#define PSC_REG_VAL_MDCTL_NEXT_SWRSTDISABLE 0
+#define PSC_REG_VAL_MDCTL_NEXT_OFF 2
+#define PSC_REG_VAL_MDCTL_NEXT_ON 3 /* Yes, 3 is the on state command */
+
+
+/* MDSTAT states */
+#define PSC_REG_VAL_MDSTAT_STATE_ON 3
+#define PSC_REG_VAL_MDSTAT_STATE_ENABLE_IN_PROG 0x24
+#define PSC_REG_VAL_MDSTAT_STATE_OFF 2
+#define PSC_REG_VAL_MDSTAT_STATE_DISABLE_IN_PROG1 0x20
+#define PSC_REG_VAL_MDSTAT_STATE_DISABLE_IN_PROG2 0x21
+#define PSC_REG_VAL_MDSTAT_STATE_DISABLE_IN_PROG3 0x22
+
+
+/* Timeout limit on checking PTSTAT. This is the number of times the
+ * wait function will be called before giving up. */
+#define PSC_PTSTAT_TIMEOUT_LIMIT 100
+
+
+
+
+
+#endif /* _PSCLOC_H */
diff --git a/src/hw/pscs/pscapi.h b/src/hw/pscs/pscapi.h
--- /dev/null
+++ b/src/hw/pscs/pscapi.h
@@ -0,0 +1,31 @@
+#ifndef _PSCAPI_H
+#define _PSCAPI_H
+/**********************************************************************************
+ * FILE PURPOSE: Define the power save controller api
+ **********************************************************************************
+ * FILE NAME: pscapi.h
+ *
+ * DESCRIPTION: Defines the driver interface for the psc controller driver.
+ *
+ * Copyright (C) 2006, Texas Instruments, Inc.
+ *
+ * @file pscapi.h
+ *
+ * @brief
+ * Defines the API used by all power controllers
+ *
+ **********************************************************************************/
+#include "types.h"
+
+int16 pscEnableModule (uint32 modNum);
+int16 pscDisableModule (uint32 modNum);
+BOOL pscModuleIsEnabled (uint32 modNum);
+int16 pscSetResetIso (uint32 modNum);
+int16 pscDisableDomain (uint32 domainNum);
+void pscDisableModAndDomain (uint32 modNum, uint32 domainNum);
+
+
+
+
+
+#endif /* _PSCAPI_H */
diff --git a/src/hw/timer/devtimer.h b/src/hw/timer/devtimer.h
--- /dev/null
+++ b/src/hw/timer/devtimer.h
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * FILE PURPOSE: Define the device timer API
+ ******************************************************************************
+ * FILE NAME: devtimer.h
+ *
+ * DESCRIPTION: The API for the all device timers
+ *
+ * @file devtimer.h
+ *
+ * @brief
+ * This file defines the API used by all device timers
+ *
+ *******************************************************************************/
+#ifndef DEVTIMER_H
+#define DEVTIMER_H
+
+#include "types.h"
+#include "devtimer.h"
+
+Bool dev_check_timer (void);
+Int32 dev_delete_timer (void);
+Int32 dev_create_timer (void);
+
+
+#endif /* DEVTIMER_H */
+
+
+
+
+
+
+
+
diff --git a/src/hw/timer/timer64/t64.c b/src/hw/timer/timer64/t64.c
--- /dev/null
@@ -0,0 +1,166 @@
+/*************************************************************************
+ * FILE PURPOSE: Timer64 configuration
+ *************************************************************************
+ * FILE NAME: t64.c
+ *
+ * DESCRIPTION: The low level timer 64 driver
+ *
+ * @file t64.c
+ *
+ * @brief
+ * This file is used to control timer64s at the device level. Only timer 0
+ * is supported, and only in single shot mode.
+ *
+ **************************************************************************/
+#include "types.h"
+#include "iblcfg.h"
+#include "ibl.h"
+#include "iblloc.h"
+#include "devtimer.h"
+#include "t64hw.h"
+
+
+/**
+ * @brief
+ * A global variable is used to track the timer enable/disable status
+ */
+Int32 timer_created = 0;
+
+
+/**
+ * @b Description
+ * @n
+ *
+ * A timer is disabled
+ *
+ * @retval
+ * 0 - Timer deleted
+ * -1 - Timer was not active
+ */
+Int32 dev_delete_timer (void)
+{
+ Int32 retval;
+
+ /* Go ahead and disable the timer, even if it is not tracked as active */
+ t64_tcr = TIMER64_TCR_DISABLE;
+ t64_tgcr = TIMER64_TGCR_DISABLE;
+
+ /* Set the counters to 0 */
+ t64_tim12 = 0;
+ t64_tim34 = 0;
+
+ /* Set the timer period to 0 */
+ t64_prd12 = 0;
+ t64_prd34 = 0;
+
+ if (timer_created == 0)
+ retval = -1;
+ else
+ retval = 0;
+
+ timer_created = 0;
+
+ return (retval);
+
+}
+
+/**
+ * @b Description
+ * @n
+ *
+ * Starts the timer in one shot mode
+ */
+void timer_go (void)
+{
+ long long timdiv;
+
+ /* Remove reset, leave timer disabled */
+ t64_tgcr = TIMER64_TGCR_64;
+
+ /* Write the timer period.
+ * The desired period is 100mus. One cycle is 1us per MHz of the device */
+ timdiv = (long long)ibl.pllConfig[ibl_MAIN_PLL].pllOutFreqMhz / TIMER_INPUT_DIVIDER;
+ timdiv = timdiv * 100 * 1000;
+ t64_prd34 = (timdiv >> 32);
+ t64_prd12 = (timdiv & 0xffffffff);
+
+ /* Start the timer in 1 shot mode */
+ t64_tcr = TIMER64_TCR_ONE_SHOT;
+
+}
+
+
+/**
+ * @b Description
+ * @n
+ *
+ * A very simple hardware driver to configure the timer as a one shot 100ms timer.
+ *
+ * @retval
+ * 0 - Timer setup
+ * -1 - Timer setup failed, timer already enabled
+ *
+ */
+Int32 dev_create_timer (void)
+{
+ volatile Int32 i;
+
+ if (timer_created != 0)
+ return (-1);
+
+ /* Close out the timer, just to be safe */
+ dev_delete_timer ();
+
+ /* Need some delay before reprogramming the timer */
+ for (i = 0; i < 500; i++);
+
+
+ timer_go();
+
+ timer_created = 1;
+
+ return (0);
+
+}
+
+
+/**
+ * @b Description
+ * @n
+ *
+ * The status of the timer is returned
+ *
+ * @retval
+ * TRUE - The timer has expired
+ * FALSE - The timer is active
+ *
+ */
+Bool dev_check_timer (void)
+{
+ volatile unsigned int i;
+
+ if (timer_created == 0)
+ return (FALSE);
+
+ if ((t64_tim12 != 0) || (t64_tim34 != 0))
+ return (FALSE);
+
+ /* The timer has expired. Restart the timer */
+ dev_delete_timer ();
+
+ /* Need some delay before reprogramming the timer */
+ for (i = 0; i < 500; i++);
+
+ timer_go ();
+
+ timer_created = 1;
+
+ return (TRUE);
+
+}
+
+
+
+
+
+
diff --git a/src/hw/timer/timer64/t64hw.h b/src/hw/timer/timer64/t64hw.h
--- /dev/null
@@ -0,0 +1,41 @@
+/***********************************************************************
+ * FILE PURPOSE: Timer 64 local definitions
+ ***********************************************************************
+ * FILE NAME: t64hw.h
+ *
+ * @file t64h2.h
+ *
+ * @brief
+ * This file contains local definitions for the timer64 block
+ *
+ ***********************************************************************/
+
+#ifndef T64HW_H
+#define T64HW_H
+
+#include "types.h"
+#include "target.h"
+
+
+/* Local registers */
+#define treg(x) *((volatile unsigned int *)(TIMER0_BASE + (x)))
+
+#define t64_tcr treg(0x20)
+#define t64_tgcr treg(0x24)
+#define t64_tim12 treg(0x10)
+#define t64_tim34 treg(0x14)
+#define t64_prd12 treg(0x18)
+#define t64_prd34 treg(0x1c)
+
+
+#define TIMER64_TCR_ONE_SHOT 0x40
+#define TIMER64_TCR_DISABLE 0x00
+
+#define TIMER64_TGCR_64 0x3
+#define TIMER64_TGCR_DISABLE 0x0
+
+
+
+
+#endif /* T64HW_H */
+
diff --git a/src/ibl.h b/src/ibl.h
--- /dev/null
+++ b/src/ibl.h
@@ -0,0 +1,447 @@
+/********************************************************************************************************
+ * FILE PURPOSE: IBL configuration and control definitions
+ ********************************************************************************************************
+ * FILE NAME: ibl.h
+ *
+ * DESCRIPTION: Defines the data structure used to handle initial configuration and control
+ * of the ibl. This data structure resides at a fixed location in the device memory
+ * map. It is initially populated either during the rom boot. The table can be
+ * over-written during the ibl process to redirect the boot. For example the ibl
+ * can initially load from an i2c which repopulates this table with parameters
+ * for an ethernet boot.
+ *
+ * @file ibl.h
+ *
+ * @brief
+ * This file defines the configuration and control of the IBL
+ *
+ *
+ ********************************************************************************************************/
+#ifndef IBL_H
+#define IBL_H
+
+#include "types.h"
+
+/* Information used to make generate a bootp request */
+/**
+ * @brief
+ * Defines parameters used for making a bootp request
+ *
+ * @details
+ * The bootp request parameters are created from these fields
+ */
+typedef struct iblBootp_s
+{
+ uint8 hwAddress[6]; /**< The hardware (mac) address of this device. If set to 0
+ the ibl will values from e-fuse */
+
+ uint8 ipDest[4]; /**< The IP address of this device. This is typically set
+ to IP broadcast */
+
+} iblBootp_t;
+
+
+/**
+ * @brief
+ * This structure contains information used for tftp boot.
+ *
+ * @details These fields are typically filled in by the bootp packet, but
+ * can be provided if bootp will not be used.
+ */
+typedef struct iblEthBootInfo_s
+{
+ uint8 ipAddr[4]; /**< The IP address of this device */
+ uint8 serverIp[4]; /**< The IP address of the tftp server */
+ uint8 gatewayIp[4]; /**< The IP address of the gateway */
+ uint8 netmask[4]; /**< The IP netmask */
+ uint8 hwAddress[6]; /**< The hardware (mac) address of this device */
+ char8 fileName[128]; /**< The file name to load */
+
+} iblEthBootInfo_t;
+
+
+/**
+ * @def ibl_ETH_PORT_FROM_RBL
+ */
+#define ibl_ETH_PORT_FROM_RBL -1 /**< The ethernet port used is the same one used
+ during the ROM boot load process. */
+
+
+/**
+ * @defgroup iblBootFormats
+ *
+ * @ingroup iblBootFormats
+ * @{
+ */
+#define ibl_BOOT_FORMAT_AUTO 0 /**< Auto determine the boot format from the data */
+#define ibl_BOOT_FORMAT_NAME 1 /**< Determines the boot format based on file name (bootp/tftp only) */
+#define ibl_BOOT_FORMAT_BIS 2 /**< Boot TI AIS format */
+#define ibl_BOOT_FORMAT_COFF 3 /**< Boot a COFF file */
+#define ibl_BOOT_FORMAT_ELF 4 /**< Boot an ELF file */
+#define ibl_BOOT_FORMAT_BBLOB 5 /**< Boot a binary blob */
+#define ibl_BOOT_FORMAT_BTBL 6 /**< Boot a TI boot table file */
+
+/* @} */
+
+/**
+ * @defgroup iblPeriphPriority Defines the boot sequence
+ *
+ * @ingroup iblPeriphPriority
+ * @{
+ * @def ibl_LOWEST_PRIORITY
+ */
+#define ibl_LOWEST_PRIORITY 10 /**< The lowest priority assignable to a peripheral for boot */
+
+/**
+ * @def ibl_HIGHEST_PRIORITY
+ */
+#define ibl_HIGHEST_PRIORITY 1 /**< The highest priority assignable to a peripheral for boot */
+
+/**
+ * @def ibl_DEVICE_NOBOOT
+ */
+#define ibl_DEVICE_NOBOOT 20 /**< Indicates that the device is not to be used for boot */
+
+/* @} */
+
+
+/**
+ * @brief
+ * Emif controller 3.1 configuration
+ *
+ * @details
+ * The paramters are directly placed into the emif controller
+ */
+typedef struct iblEmif3p1_s
+{
+ uint32 sdcfg; /**< SD configuration register */
+ uint32 sdrfc; /**< Refresh timing register */
+ uint32 sdtim1; /**< DDR timing register 1 */
+ uint32 sdtim2; /**< DDR timing register 2 */
+ uint32 dmcctl; /**< CAS match timing */
+
+} iblEmif3p1_t;
+
+
+/**
+ * @brief
+ * Emif controller 4.0 configuration
+ *
+ * @details
+ * The parameters are placed directly into the emif controller
+ */
+typedef struct iblEmif4p0_s
+{
+ uint32 dummy; /**< placeholder */
+
+} iblEmif4p0_t;
+
+/**
+ * @brief
+ * This structure is used to configure the DDR interface
+ *
+ * @details
+ * The DDR configuration parameters are setup
+ *
+ */
+typedef struct idblDdr_s
+{
+ bool configDdr; /**< Set to non-zero to enable EMIF configuration */
+
+ union {
+
+ iblEmif3p1_t emif3p1; /**< Configuration of devices with emif controller version 3.1 */
+ iblEmif4p0_t emif4p0; /**< Configuration of devices with emif controller version 4.0 */
+ } uEmif;
+
+} iblDdr_t;
+
+/**
+ * @brief
+ * This structure is used to identify binary blob load parameters.
+ *
+ * @details
+ * Since binary blob is formatless the start address, size and branch to address
+ * can be specified. In the case of network boot, boot will terminate when no
+ * more data is received (or timed out), even if the size is not reached.
+ */
+typedef struct iblBinBlob_s
+{
+ uint32 startAddress; /**< Where the loaded data is placed */
+ uint32 sizeBytes; /**< How much data to load */
+ uint32 branchAddress; /**< Where to branch to when the load is complete */
+
+} iblBinBlob_t;
+
+/**
+ * @brief
+ * This structure is used to control the operation of the ibl ethernet boot.
+ *
+ * @details
+ * The ethernet port and bootp request are controlled through this structure.
+ */
+typedef struct iblEth_s
+{
+ uint32 ethPriority; /**< The ethernet boot priority. @ref iblPeriphPriority */
+ int32 port; /**< The ethernet port to use, or @ref ibl_ETH_PORT_FROM_RBL */
+ bool doBootp; /**< If true a bootp request is generated. If false the @ref iblEthBootInfo_t
+ table must be populated before the ibl begins execution */
+ bool useBootpServerIp; /**< If TRUE then the server IP received from the bootp server
+ is used, if FALSE the one in the ethInfo field is used */
+ bool useBootpFileName; /**< If TRUE then the file name received from the bootp server
+ is used, if FALSE the one in the ethInfo field is used */
+ int32 bootFormat; /**< The format of the boot data file. @ref iblBootFormats */
+
+ iblBinBlob_t blob; /**< Used only if the format is ibl_BOOT_FORMAT_BBLOB */
+
+ iblEthBootInfo_t ethInfo; /**< Low level ethernet information */
+
+} iblEth_t;
+
+
+/**
+ * @def ibl_N_ETH_PORTS
+ */
+#define ibl_N_ETH_PORTS 2 /**< The number of ethernet port configurations available */
+
+/**
+ * @def ibl_N_MDIO_CFGS
+ */
+#define ibl_N_MDIO_CFGS 16 /**< The maximum number of mdio configurations */
+
+
+/**
+ * @brief
+ * This structure is used to configure phys through the mdio interface
+ *
+ * @details
+ * Defines optional configuration through MDIO.
+ *
+ * The mdio transaction values are mapped as follows:
+ *
+ * /-------------------------------------------------------------\
+ * | 31 | 30 | 29 26 | 25 21 | 20 16 | 15 0|
+ * | rsvd | write | rsvd | register | phy addr | data |
+ * \-------------------------------------------------------------/
+ */
+typedef struct iblMdio_s
+{
+ int16 nMdioOps; /**< The number of mdio writes to perform */
+ uint16 mdioClkDiv; /**< The divide down of the mac clock which drives the mdio */
+
+ uint32 interDelay; /**< The number of cpu cycles to wait between mdio writes */
+
+ uint32 mdio[ibl_N_MDIO_CFGS]; /* The MDIO transactions */
+
+} iblMdio_t;
+
+
+/**
+ * @brief
+ * This structure defines the physical parameters of the NAND device
+ */
+typedef struct nandDevInfo_s
+{
+ uint32 busWidthBits; /**< 8 or 16 bit bus width */
+ uint32 pageSizeBytes; /**< The size of each page */
+ uint32 pageEccBytes; /**< Number of ecc bytes in each page */
+ uint32 pagesPerBlock; /**< The number of pages in each block */
+ uint32 totalBlocks; /**< The total number of blocks in a device */
+
+ uint32 addressBytes; /**< Number of bytes in the address */
+ bool lsbFirst; /**< Set to true if the LSB is output first, otherwise msb is first */
+ uint32 blockOffset; /**< Address bits which specify the block number */
+ uint32 pageOffset; /**< Address bits which specify the page number */
+ uint32 columnOffset; /**< Address bits which specify the column number */
+
+ uint8 resetCommand; /**< The command to reset the flash */
+ uint8 readCommandPre; /**< The read command sent before the address */
+ uint8 readCommandPost; /**< The read command sent after the address */
+ bool postCommand; /**< If TRUE the post command is sent */
+
+} nandDevInfo_t;
+
+
+/**
+ * @brief
+ * This structure is used to control the operation of the NAND boot
+ *
+ */
+typedef struct iblNand_s
+{
+
+ uint32 nandPriority; /**< The nand boot priority. @ref iblPeriphPriority */
+ int32 bootFormat; /**< The format of the boot data file. @ref iblBootFormats */
+ iblBinBlob_t blob; /**< Used only if the format is ibl_BOOT_FORMAT_BBLOB */
+
+
+ nandDevInfo_t nandInfo; /** Low level device info */
+
+} iblNand_t;
+
+
+/**
+ * @brief
+ * This structure is used to control the programming of the device PLL
+ *
+ * @details
+ * The system PLLs are optionally configured
+ */
+typedef struct iblPll_s {
+
+ bool doEnable; /**< If true the PLL is configured */
+
+ Uint32 prediv; /**< The pll pre-divisor */
+ Uint32 mult; /**< The pll multiplier */
+ Uint32 postdiv; /**< The pll post divider */
+
+ Uint32 pllOutFreqMhz; /**< The resulting output frequency, required for timer setup */
+
+} iblPll_t;
+
+
+/**
+ * @defgroup iblPllNum
+ *
+ * @ingroup iblPllNum
+ * @{
+ *
+ * @def ibl_MAIN_PLL
+ */
+#define ibl_MAIN_PLL 0 /**< The main cpu pll */
+
+/**
+ * @def ibl_DDR_PLL
+ */
+#define ibl_DDR_PLL 1 /**< The ddr pll */
+
+/**
+ * @def ibl_NET_PLL
+ */
+#define ibl_NET_PLL 2 /**< The network pll */
+
+/**
+ * @def the number of PLL configuration entries in the table
+ */
+#define ibl_N_PLL_CFGS (ibl_NET_PLL + 1)
+
+/* @} */
+
+
+
+
+/**
+ * @def ibl_MAGIC_VALUE
+ */
+#define ibl_MAGIC_VALUE 0xCEC11EBB /**< Indicates that the configuration table is valid */
+
+/**
+ * @brief
+ * The main configuration/control structure for the ibl
+ *
+ * @details
+ * The operation of the ibl is configured/controlled based on the values in this structure.
+ * This structure resides at a fixed location in the memory map. It can be changed during
+ * the boot operation itself by loading new values into it, but these changes must occur
+ * as part of the boot process itself (not through an asynchronous write through a master
+ * peripheral).
+ *
+ * Each boot mode is assigned a priority, with lower values indicating a higher
+ * priority. The lowest valid priority is @ref ibl_LOWEST_BOOT_PRIORITY, and the value
+ * @ref ibl_DEVICE_NOBOOT indicates no boot will be attempted on that peripheral.
+ */
+typedef struct ibl_s
+{
+ uint32 iblMagic; /**< @ref ibl_MAGIC_VALUE */
+
+ iblPll_t pllConfig[ibl_N_PLL_CFGS]; /**< PLL Configuration. @ref iblPll_t */
+
+ iblDdr_t ddrConfig; /**< DDR configuration @ref iblDdr_t */
+
+ iblEth_t ethConfig[ibl_N_ETH_PORTS]; /**< Ethernet boot configuration. @ref iblEth_t */
+
+ iblMdio_t mdioConfig; /**< MDIO configuration. @ref iblMdio_t */
+
+ iblNand_t nandConfig; /**< NAND configuration @ref iblNand_t */
+
+
+/* iblI2c_t i2cConfig; */
+/* iblSpi_t spiConfig; */
+
+
+} ibl_t;
+
+
+extern ibl_t ibl;
+
+
+
+/**
+ * @defgroup iblActivePeriph
+ *
+ * @ingroup iblActivePeriph
+ * @{
+ * @def ibl_ACTIVE_PERIPH_ETH
+ */
+#define ibl_ACTIVE_PERIPH_ETH 100 /**< An ethernet boot in progress */
+
+/**
+ * @def ibl_ACTIVE_PERIPH_NAND
+ */
+#define ibl_ACTIVE_PERIPH_NAND 101 /**< A nand boot in progress */
+
+/**
+ * @def ibl_ACTIVE_PERIPH_I2C
+ */
+#define ibl_ACTIVE_PERIPH_I2C 102 /**< An i2c boot in progress */
+
+/**
+ * @def ibl_ACTIVE_PERIPH_SPI
+ */
+#define ibl_ACTIVE_PERIPH_SPI 103 /**< An SPI boot in progress */
+
+/* @} */
+
+
+/**
+ * @brief
+ * Provide status on the boot operation
+ *
+ * @details
+ * Run time status of the IBL is provided to aid in debugging
+ *
+ */
+typedef struct iblStatus_s
+{
+ uint32 iblMagic; /**< The @ref ibl_MAGIC_VALUE is placed here to indicate the boot has begun */
+
+ int32 tableLoadFail; /**< If non-zero then the load of the parameter table from i2c failed */
+
+ int32 heartBeat; /**< An increasing value as long as the boot code is running */
+ int32 noMagic; /**< A non-zero value here indicates that @ref ibl_MAGIC_VALUE was not found
+ in the @ref ibl_t magic field, and default values were loaded. */
+ int32 activePeriph; /**< Describes the active boot peripheral @ref iblActivePeriph */
+ int32 activeFormat; /**< Describes the format being decoded */
+
+ int32 autoDetectFailCnt; /**< Counts the number of times an auto detect of the data format failed */
+ int32 nameDetectFailCnt; /**< Counts the number of times an name detect of the data format failed */
+
+ int32 invalidDataFormatSpec; /**< Counts the number of times the main boot found an invalid boot format request */
+
+ uint32 exitAddress; /**< If non-zero the IBL exited and branched to this address */
+
+ iblEthBootInfo_t ethParams; /**< Last ethernet boot attemp parameters */
+
+} iblStatus_t;
+
+extern iblStatus_t iblStatus;
+
+
+
+
+
+
+
+
+
+#endif /* IBL_H */
diff --git a/src/iblloc.h b/src/iblloc.h
--- /dev/null
+++ b/src/iblloc.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+ * FILE PURPOSE: Local inter-module definitions for the IBL
+ ****************************************************************************
+ * FILE NAME: iblloc.h
+ *
+ * DESCRIPTION: Defines global structures used throughout the IBL
+ *
+ * @file iblloc.h
+ *
+ * @brief
+ * Provides global inter-module definitions
+ *
+ *****************************************************************************/
+#ifndef IBLLOC_H
+#define IBLLOC_H
+
+#include "types.h"
+
+typedef struct BOOT_MODULE_FXN_TABLE
+{
+ /**
+ * @brief The API is called by the kernel to open the specific
+ * boot module. This is used by boot module to initialize themselves
+ * and the peripheral drivers.
+ */
+ Int32 (*open)(void* ptr_driver, void (*asyncComplete)(void *));
+
+ /**
+ * @brief The API is called by the kernel to close the boot module
+ * Boot Modules use this API and to close themselves and the peripheral
+ * drivers.
+ */
+ Int32 (*close)(void);
+
+ /**
+ * @brief The API is called by the kernel to read a specific number
+ * of bytes from the boot module and to populate the data buffer.
+ */
+ Int32 (*read)(Uint8* ptr_buf, Uint32 num_bytes);
+
+ /**
+ * @brief The API is called by the kernel to write a specific number
+ * of bytes to the boot module from the data buffer. This is *optional*
+ */
+ Int32 (*write)(Uint8* ptr_buf, Uint32 num_bytes);
+
+ /**
+ * @brief This API is called by the kernal to peek at some bytes
+ * without removing them from the buffer
+ */
+ Int32 (*peek)(Uint8 *ptr_buf, Uint32 num_bytes);
+
+ /**
+ * @brief This API is called by the kernel to move the read/write
+ * pointers in the buffer. The values of parameter from
+ * match those of fseek - 0 = from start of file,
+ * 1 = from current position, 2 = from end of file.
+ * Returns 0 if the seek is successful, -1 if it failed.
+ */
+ Int32 (*seek)(Int32 loc, Int32 from);
+
+ /**
+ * @brief This API is called by the kernel to determine how much data
+ * is currently available for immediate read. Returns -1 if
+ * the stream has been closed.
+ */
+ Int32 (*query)(void);
+
+
+}BOOT_MODULE_FXN_TABLE;
+
+
+/* Prototypes */
+Uint32 iblBoot (BOOT_MODULE_FXN_TABLE *bootFxn, int32 dataFormat, void *formatParams);
+
+
+/* squash printfs */
+void mprintf(char *x, ...);
+
+#endif /* _IBLLOC_H */
diff --git a/src/interp/bis/bis.c b/src/interp/bis/bis.c
--- /dev/null
+++ b/src/interp/bis/bis.c
@@ -0,0 +1,313 @@
+/******************************************************************************
+ * FILE PURPOSE: Boot from a BIS formatted input
+ ******************************************************************************
+ * FILE NAME: bis.c
+ *
+ * DESCRIPTION: A BIS formatted data file is parsed and loaded
+ *
+ * @file bis.c
+ *
+ * @brief
+ * This file is used to load a BIS formatted data file
+ *
+ ******************************************************************************/
+#include "types.h"
+#include "ibl.h"
+#include "iblloc.h"
+#include "bis.h"
+#include "iblcfg.h"
+
+/**********************************************************************
+ ************************** Local Structures **************************
+ **********************************************************************/
+
+/**
+ * @brief
+ * The structure describes the Function Entry.
+ *
+ * @details
+ * The entry stores information about function which can be executed
+ * while executing the BIS Command State machine. These entries are
+ * loaded and executed through the BIS Function Load & Execute commands.
+ */
+typedef struct FN_ENTRY
+{
+ /**
+ * @brief This is the function number which is unique for all
+ * functions.
+ */
+ Uint16 fn_num;
+
+ /**
+ * @brief This is the number of arguments the function takes.
+ */
+ Uint16 arg_cnt;
+
+ /**
+ * @brief This is the address where the function is loaded in
+ * memory via the function load command.
+ */
+ Uint32 fn_address;
+}FN_ENTRY;
+
+/**
+ * @brief Global database all functions which can be loaded and executed
+ * via the BIS Function Load/Execute commands.
+*/
+FN_ENTRY fn_table[MAX_BIS_FUNCTION_SUPPORT];
+
+
+/**
+ * @b Description
+ * @n
+ * The function interfaces with the boot module and reads data as it
+ * is received by the boot module and executes the BIS command state
+ * machine.
+ *
+ * @param[out] entry_point
+ * This is the entry point to which control is to be transferred on
+ * success. This is read from the "payload" of TERMINATE command.
+ *
+ * @retval
+ * Success - 0
+ * @retval
+ * Error - <0
+ */
+Int32 iblBootBis (BOOT_MODULE_FXN_TABLE *bootFxn, Uint32* entry_point)
+{
+ Uint32 dataWord;
+ Uint32 loadAddress;
+ Uint32 sectionSize;
+ Uint32 commandFlags;
+ Uint16 argCnt;
+ Uint16 fn_num;
+ FN_ENTRY* ptr_fn_entry;
+ Bool done = FALSE;
+
+ /* Read the Magic word */
+ if ((*bootFxn->read)((Uint8 *)&dataWord, sizeof(Uint32)) < 0)
+ return -1;
+
+ /* Check if we received the magic number. */
+ if (dataWord != BIS_MAGIC_NUMBER)
+ return -1;
+
+ /* If magic word was good, let's start parsing commands */
+ while (done == FALSE)
+ {
+ /* Read BIS command */
+ if ((*bootFxn->read)((Uint8 *)&dataWord, sizeof(Uint32)) < 0)
+ return -1;
+
+ /* Make sure command at least has right prefix */
+ if ((dataWord & BIS_CMD_MASK) != BIS_CMD_PREFIX )
+ return -1;
+
+ /* Process the command. */
+ switch (dataWord)
+ {
+ case BIS_CMD_SECTION_LOAD:
+ {
+ /* Read the Section Load Header: Load Address */
+ if ((*bootFxn->read)((Uint8 *)&loadAddress, sizeof(Uint32)) < 0)
+ return -1;
+
+ /* Read the Section Load Header: Section Size */
+ if ((*bootFxn->read)((Uint8 *)§ionSize, sizeof(Uint32)) < 0)
+ return -1;
+
+ /* Read the Section Load Header: Flags */
+ if ((*bootFxn->read)((Uint8 *)&commandFlags, sizeof(Uint32)) < 0)
+ return -1;
+
+#if 0
+ /* DEBUG Message: */
+ mprintf ("*****************************\n");
+ mprintf ("Section Load Command\n");
+ mprintf (" Load Address : 0x%x\n", loadAddress);
+ mprintf (" Section Size : %d\n", sectionSize);
+ mprintf (" Command Flags: 0x%x\n", commandFlags);
+ mprintf ("*****************************\n");
+#endif
+ /* Read the data from the Section Load: Payload section. */
+ if ((*bootFxn->read)((Uint8 *)loadAddress, sectionSize) < 0)
+ return -1;
+
+ /* Section Load command has been processed. */
+ break;
+ }
+ case BIS_CMD_FUNCTION_LOAD:
+ {
+ /* Read the Function Load Header: Load Address */
+ if ((*bootFxn->read)((Uint8 *)&loadAddress, sizeof(Uint32)) < 0)
+ return -1;
+
+ /* Read the Function Load Header: Section Size */
+ if ((*bootFxn->read)((Uint8 *)§ionSize, sizeof(Uint32)) < 0)
+ return -1;
+
+ /* Read the Function Load Header: Flags */
+ if ((*bootFxn->read)((Uint8 *)&commandFlags, sizeof(Uint32)) < 0)
+ return -1;
+
+ /* Read the Function Load Header: Argument Count */
+ if ((*bootFxn->read)((Uint8 *)&argCnt, sizeof(Uint16)) < 0)
+ return -1;
+
+ /* Read the Function Load Header: Function Number */
+ if ((*bootFxn->read)((Uint8 *)&fn_num, sizeof(Uint16)) < 0)
+ return -1;
+
+#if 0
+ /* DEBUG Message: */
+ mprintf ("*****************************\n");
+ mprintf ("Function Load Command\n");
+ mprintf (" Load Address : 0x%x\n", loadAddress);
+ mprintf (" Section Size : %d\n", sectionSize);
+ mprintf (" Command Flags: 0x%x\n", commandFlags);
+ mprintf (" Argument Cnt : %d\n", argCnt);
+ mprintf (" Function Num : %d\n", fn_num);
+ mprintf ("*****************************\n");
+#endif
+ /* Read the data from the Function Load: Payload section. */
+ if ((*bootFxn->read)((Uint8 *)loadAddress, sectionSize) < 0)
+ return -1;
+
+ /* Validate the arguments: Ensure that the function number is in range */
+ if (fn_num > MAX_BIS_FUNCTION_SUPPORT)
+ return -1;
+
+ /* Get access to the kernel function entry. */
+ ptr_fn_entry = (FN_ENTRY *)&fn_table[fn_num];
+
+ /* Validate the arguments: Ensure that the argument count is in range */
+ if (argCnt > MAX_BIS_FUNCTION_SUPPORT)
+ return -1;
+
+ /* Validate the arguments: Make sure there is no function entry already loaded.
+ * This is a user error while generating the BIS images. If the function address
+ * is non zero this implies that there is already a function loaded. */
+ if (ptr_fn_entry->fn_address != 0)
+ return -1;
+
+ /* Populate the function entry. */
+ ptr_fn_entry->fn_address = loadAddress;
+ ptr_fn_entry->arg_cnt = argCnt;
+ ptr_fn_entry->fn_num = fn_num;
+ break;
+ }
+ case BIS_CMD_FUNCTION_EXEC:
+ {
+ void (*fnEntryPoint)(void);
+
+ /* Read the Function Execute Header: Load Address */
+ if ((*bootFxn->read)((Uint8 *)&argCnt, sizeof(Uint16)) < 0)
+ return -1;
+
+ /* Read the Function Execute Header: Function Number */
+ if ((*bootFxn->read)((Uint8 *)&fn_num, sizeof(Uint16)) < 0)
+ return -1;
+
+#if 0
+ /* DEBUG Message: */
+ mprintf ("*****************************\n");
+ mprintf ("Function Execute Command\n");
+ mprintf (" Argument Cnt : %d\n", argCnt);
+ mprintf (" Function Num : %d\n", fn_num);
+ mprintf ("*****************************\n");
+#endif
+ /* Validate the arguments: Ensure that the function number is in range */
+ if (fn_num > MAX_BIS_FUNCTION_SUPPORT)
+ return -1;
+
+ /* Get access to the kernel function entry. */
+ ptr_fn_entry = (FN_ENTRY *)&fn_table[fn_num];
+
+ /* Validate the arguments: Make sure that the function entry is already loaded.
+ * If not then we have a FATAL Error. */
+ if (ptr_fn_entry->fn_address == 0)
+ return -1;
+
+ /* Call the kernel function entry. */
+ fnEntryPoint = (void (*)(void))ptr_fn_entry->fn_address;
+ fnEntryPoint();
+ break;
+ }
+ case BIS_CMD_MEMORY_ACCESS:
+ {
+ Uint16 op_type;
+ Uint32 mask;
+ Uint32 sleep_cnt;
+
+ /* Read the Memory Access Header: Address */
+ if ((*bootFxn->read)((Uint8 *)&loadAddress, sizeof(Uint32)) < 0)
+ return -1;
+
+ /* Read the Memory Access Header: Word Count */
+ if ((*bootFxn->read)((Uint8 *)&argCnt, sizeof(Uint16)) < 0)
+ return -1;
+
+ /* Read the Memory Access Header: Op Type */
+ if ((*bootFxn->read)((Uint8 *)&op_type, sizeof(Uint16)) < 0)
+ return -1;
+
+ /* Read the Memory Access Header: Mask */
+ if ((*bootFxn->read)((Uint8 *)&mask, sizeof(Uint32)) < 0)
+ return -1;
+
+ /* Read the Memory Access Header: Sleep Count */
+ if ((*bootFxn->read)((Uint8 *)&sleep_cnt, sizeof(Uint32)) < 0)
+ return -1;
+
+ /* Read the Memory Access Header: Data Payload */
+ if ((*bootFxn->read)((Uint8 *)&dataWord, sizeof(Uint32)) < 0)
+ return -1;
+
+#if 0
+ /* DEBUG Message: */
+ mprintf ("*****************************\n");
+ mprintf ("Memory Access Command\n");
+ mprintf (" Address : 0x%x\n", loadAddress);
+ mprintf (" Word Count : %d\n", argCnt);
+ mprintf (" Op Type : %d\n", op_type);
+ mprintf (" Mask : %d\n", mask);
+ mprintf (" Sleep Count : %d\n", sleep_cnt);
+ mprintf (" Data Payload : %d\n", dataWord);
+ mprintf ("*****************************\n");
+#endif
+ break;
+ }
+ case BIS_CMD_SECTION_TERMINATE:
+ {
+ /* Read the Terminate Command Payload */
+ if ((*bootFxn->read)((Uint8 *)&dataWord, sizeof(Uint32)) < 0)
+ return -1;
+
+ /* DEBUG Message: */
+ mprintf ("*****************************\n");
+ mprintf ("Terminate Command\n");
+ mprintf (" Entry Point : 0x%x\n", dataWord);
+ mprintf ("*****************************\n");
+
+ /* We are done with the BIS Image parsing. */
+ done = TRUE;
+ *entry_point = dataWord;
+ break;
+ }
+ default:
+ {
+ /* BIS Command is not supported. */
+ mprintf ("Error: BIS Command 0x%x not supported\n", dataWord);
+ return -1;
+ }
+ }
+ }
+
+ /* Control comes here indicates that the parsing was successful. */
+ return 0;
+}
+
+
+
+
+
diff --git a/src/interp/bis/bis.h b/src/interp/bis/bis.h
--- /dev/null
+++ b/src/interp/bis/bis.h
@@ -0,0 +1,33 @@
+/**
+ * @file bis.h
+ *
+ * @brief
+ * The file has definitions for the BIS specification.
+ *
+ * \par
+ * NOTE:
+ * (C) Copyright 2008, Texas Instruments, Inc.
+ *
+ * \par
+ */
+#ifndef __BIS_H__
+#define __BIS_H__
+
+/* Boot Image Script (BIS) Magic number definition
+ * Every boot image should begin with TIBI (TI Boot Image) */
+#define BIS_MAGIC_NUMBER (0x54494249u) // 'T','I','B','I'
+
+/* Boot Image Script (BIS) Command Definitions
+ * Every BIS command will read 'B','I','S',XXh, where XXh is the command number */
+#define BIS_CMD_PREFIX (0x42495300u) // 'B','I','S',xxx
+#define BIS_CMD_MASK (0xFFFFFF00u)
+#define BIS_CMD_SECTION_LOAD (0x42495301u)
+#define BIS_CMD_FUNCTION_LOAD (0x42495302u)
+#define BIS_CMD_FUNCTION_EXEC (0x42495303u)
+#define BIS_CMD_MEMORY_ACCESS (0x42495304u)
+#define BIS_CMD_SECTION_TERMINATE (0x424953FFu)
+
+
+Int32 iblBootBis (BOOT_MODULE_FXN_TABLE *bootFxn, Uint32* entry_point);
+
+#endif /* __BIS_H__ */
diff --git a/src/interp/blob/blob.c b/src/interp/blob/blob.c
--- /dev/null
+++ b/src/interp/blob/blob.c
@@ -0,0 +1,91 @@
+/************************************************************************************
+ * FILE PURPOSE: Boot a binary blob
+ ************************************************************************************
+ * FILE NAME: blob.c
+ *
+ * DESCRIPTION: A binary blob is booted.
+ *
+ * @file blob.c
+ *
+ * @brief
+ * This file reads data from the boot device as a binary blob
+ *
+ ************************************************************************************/
+#include "types.h"
+#include "ibl.h"
+#include "iblloc.h"
+#include "iblblob.h"
+
+
+
+/**
+ * @b Description
+ * @n
+ *
+ * A simple read from the boot device is done until one of the following
+ * conditions occurs:
+ * - The complete data block is read
+ * - The read request fails
+ */
+
+void iblBootBlob (BOOT_MODULE_FXN_TABLE *bootFxn, Uint32 *entry, void *formatParams)
+{
+ Int32 dataSize;
+ Uint32 remainSize;
+ Uint32 dummyVal;
+ Uint32 bytesRead = 0;
+ Int32 erVal = 0;
+ Uint8 *datap;
+
+ iblBinBlob_t *blobParams = (iblBinBlob_t *)formatParams;
+
+ datap = (Uint8 *)blobParams->startAddress;
+ *entry = 0;
+
+ for (remainSize = blobParams->sizeBytes; (remainSize > 0) && (erVal == 0); ) {
+
+ /* If there is any data waiting go ahead and process it */
+ dataSize = (*bootFxn->query)();
+
+ /* The query function will return a negative value when the stream has
+ * closed */
+ if (dataSize < 0)
+ break;
+
+ if (dataSize > 0) {
+
+ (*bootFxn->read)(datap, dataSize);
+ datap = datap + dataSize;
+ remainSize = remainSize - dataSize;
+ bytesRead = bytesRead + dataSize;
+
+ } else {
+
+ /* If there is no data waiting peek for more. On error assume
+ * that the device has completed the transfer. This is valid
+ * since the read includes a timeout. */
+ erVal = (*bootFxn->peek)((Uint8 *)&dummyVal, 1);
+
+ }
+
+ }
+
+ /* Assume that if any data was read the boot was successful.
+ * A check could be added to see if the entry address was
+ * actually written, but this assumes there was no data already
+ * at the entry point */
+ if (bytesRead > 0)
+ *entry = blobParams->branchAddress;
+
+}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/interp/blob/iblblob.h b/src/interp/blob/iblblob.h
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef IBLBLOB_H
+#define IBLBLOB_H
+/*****************************************************************************************
+ * FILE PURPOSE: Define the API to the binary blob interpreter
+ *****************************************************************************************
+ * FILE NAME: iblblob.h
+ *
+ * DESCRIPTION: The interface to the binary blob interpreter is defined.
+ *
+ *****************************************************************************************/
+#include "types.h"
+#include "ibl.h"
+#include "iblloc.h"
+
+
+void iblBootBlob (BOOT_MODULE_FXN_TABLE *bootFxn, Uint32 *entry, void *formatParams);
+
+
+#endif /* IBLBLOB_H */
+
+
diff --git a/src/interp/btbl/btbl.h b/src/interp/btbl/btbl.h
--- /dev/null
+++ b/src/interp/btbl/btbl.h
@@ -0,0 +1,122 @@
+#ifndef __BTBL_H__
+#define __BTBL_H__
+/*******************************************************************************
+ * FILE PURPOSE: Defines API and public data definitions for the Boot table (BTBL)
+ *******************************************************************************
+ * FILE NAME: BTBL.h
+ *
+ * DESCRIPTION: Defines API and public data definitions for boot table
+ * processing (BTBL) module
+ *
+ * (C) Copyright 2004, TELOGY Networks, Inc.
+ ******************************************************************************/
+
+/* System level header files */
+#include "types.h"
+
+#if 0
+#include "device.h"
+#endif
+
+/* BTBL error codes */
+enum {
+ BTBL_NOERR = 0,
+ BTBL_ERR_GEN = 1,
+ BTBL_ERR_INVALID_STATE = 2,
+ BTBL_ERR_INVALID_SECTION_ADDR = 3,
+ BTBL_ERR_INVALID_START_VECTOR = 4
+};
+
+/*
+ * We need to reserve some space in the front of the buffer used to store
+ * the partial content of the boot table since the data may be shifted to
+ * achieve the 32-bit data alignment for PDMA transfer during the boot table
+ * processing
+ */
+#define BOOT_TBL_RESERVED_HEADER_SIZE CHIP_BTBL_RSVD_SIZE_UINT16 /* in terms of 16-bit word */
+
+
+/*******************************************************************************
+ * Data Definition : BOOT_TBL_T
+ *******************************************************************************
+ * DESCRIPTION :
+ * This is an instance of a boot table procssing control block.
+ * It defines all the variables used during the boot table processing
+ ******************************************************************************/
+typedef struct boot_tbl_cb_s
+{
+ UINT16 state; /* Boot table prossing state */
+ BOOL f_wait_lsw; /* TRUE: waiting for the least significant
+ 16-bit word of the control
+ word such as I/O register
+ configuration, code section
+ byte count and etc. */
+ UINT32 code_start_addr; /* record the entry point byte addr */
+ UINT32 num_io_regs; /* number of the remaining IO registers
+ needed to be initialized */
+ UINT16 io_addr; /* Record the address of the IO register
+ to be processed */
+ UINT16 core_start_vector; /* Record the core start vector */
+ /*
+ * Record the size and address of the remaining portion of the code section
+ * to be programmed
+ */
+ UINT32 section_size_bytes; /* In bytes */
+ UINT32 section_addr; /* 32-bit byte address */
+ UINT16 last_word; /* Record the last UINT16 word in the
+ previous code section */
+
+
+ UINT16* p_data; /* Point to the UINT16 data to be
+ processed */
+ UINT32 data_size_uint16; /* the size of the remaing 16-bit
+ data needs to be processed */
+} BOOT_TBL_CB_T;
+
+
+/*******************************************************************************
+ * Public function prototypes
+ ******************************************************************************/
+/*******************************************************************************
+ * FUNCTION PURPOSE: Initialize the boot table control instance
+ *******************************************************************************
+ * DESCRIPTION: Allocate and initializea boot table control instance
+ *
+ * void boot_init_boot_tbl_inst (
+ * void **p_inst) - A pointer to Boot Table Control instance
+ *
+ *****************************************************************************/
+void boot_init_boot_tbl_inst(BOOT_TBL_CB_T *inst);
+
+/*******************************************************************************
+ * FUNCTION PURPOSE: Process the boot table
+ *******************************************************************************
+ * DESCRIPTION: Process the whole or partial boot table received by going
+ * through the boot table processing state machine until all
+ * the UINT16 words are processed or the end of table condition
+ * (section size == 0) is satisfied.
+ *
+ * void boot_proc_boot_tbl (
+ * UINT16 *p_data, - 16-bit boot table content to be processed
+ * UINT32 size) - number of 16-bit words
+ *
+ *
+ * Note: It is up to the caller to reserve 4 16-bit word space in front of the
+ * input buffer since the data may be moved to achieve 32-bit alignment
+ * requirement for PDMA transfer
+ *****************************************************************************/
+void boot_proc_boot_tbl(BOOT_TBL_CB_T *inst, UINT16* p_data, UINT32 size);
+
+/* Generic block boot table information for non-secure boot over a master periheral.
+ * The data section of the block contains boot table data */
+typedef struct bootTableBlock_s
+{
+ UINT32 blockLenBytes;
+ UINT32 data;
+
+} bootTableBlock_t;
+
+
+#endif /* __BTBL_H__ */
+
+/* Nothing past this point */
diff --git a/src/interp/btbl/btblloc.h b/src/interp/btbl/btblloc.h
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef __BTBLLOC_H__
+#define __BTBLLOC_H__
+/*******************************************************************************
+ * FILE PURPOSE: Macros and definitions private to BTBL
+ *******************************************************************************
+ * FILE NAME: BTBLLOC.h
+ *
+ * DESCRIPTION: Defines macros and definitions seen only by the BTBL processing
+ * module
+ *
+ * (C) Copyright 2004, TELOGY Networks, Inc.
+ ******************************************************************************/
+/* System level header files */
+#include "types.h"
+
+/* BTBL header files */
+#include "btbl.h"
+
+/*******************************************************************************
+ * Data Definition : Define I/O Register Opcode
+ ******************************************************************************/
+#define BOOT_TBL_IO_CFG_DELAY 0xFFFF
+#define BOOT_TBL_IO_CFG_START_CORE 0xFFFE
+
+/*******************************************************************************
+ * Data Definition : BOOT_TBL_STATE_T
+ *******************************************************************************
+ * DESCRIPTION :
+ * The following definitions describe the boot table processing state.
+ ******************************************************************************/
+typedef UINT16 BOOT_TBL_STATE_T;
+
+#define BOOT_TBL_STATE_INIT 0
+#define BOOT_TBL_STATE_IO_CNT 1
+#define BOOT_TBL_STATE_IO_REGS 2
+#define BOOT_TBL_STATE_SIZE 3
+#define BOOT_TBL_STATE_ADDR 4
+#define BOOT_TBL_STATE_DATA 5
+#define BOOT_TBL_STATE_FLUSH 6
+#define BOOT_TBL_LAST_STATE BOOT_TBL_STATE_FLUSH
+#define BOOT_TBL_NUM_STATES (BOOT_TBL_LAST_STATE + 1)
+
+
+/******************************************************************************
+ * DATA DEFINITION: Boot Table Procssing Function
+ *****************************************************************************/
+typedef void (*BootTblProcFcn_t) (BOOT_TBL_CB_T* p_inst);
+
+#endif /* __BTBLLOC_H__ */
+
+/* Nothing past this point */
diff --git a/src/interp/btbl/btblpr.c b/src/interp/btbl/btblpr.c
--- /dev/null
+++ b/src/interp/btbl/btblpr.c
@@ -0,0 +1,484 @@
+/******************************************************************************
+ * FILE PURPOSE: Boot TaBLe (btbl) processing file
+ ******************************************************************************
+ * FILE NAME: btblpr.c
+ *
+ * DESCRIPTION: This file contains the main boot table processing state machine.
+ *
+ * For reference here is the Boot table format:
+ *
+ * (32-bit) Entry point byte address : Code Execution start address
+ * (32-bit) Number of I/O Registers, delay and etc.
+ * (32-bit) 1st Word for I/O Register configuration(optional)
+ * ...
+ * (32-bit) Nth Word for I/O Register configuration(optional)
+ * (32-bit) Words for added delay in CPU cycles (optional)
+ * (32-bit) Words for Core Start Vector (optional)
+ * (32-bit) 1st code section byte count
+ * (32-bit) 1st code section starting address in bytes
+ * 1st section code byte
+ * ...
+ * (32-bit) Nth code section byte count
+ * (32-bit) Nth code section starting address in bytes
+ * Nth section code byte
+ * ...
+ * Last word of Nth section code type
+ * (32-bit) Zero byte count
+ *
+ * Note1: Core start vector and added delay are special format of I/O Registers
+ * 0xFFFF: NOP execution
+ * 0xFFFE: core start vector
+ *
+ * Note2: There will be a padded byte added if the code section contains odd
+ * number of bytes
+ *
+ * FUNCTION DESCRIPTION
+ * -------- -----------
+ *
+ * btblpr.c:
+ * boot_init_boot_tbl_inst() Initialize the boot table control instance
+ * boot_proc_boot_tbl() Boot Table main processing routine
+ * boot_proc_boot_tbl_xxx() Boot Table procssing routine in xxx state
+ *
+ * (C) Copyright 2004, TELOGY Networks, Inc.
+ *****************************************************************************/
+/* types.h must be included before stdlib.h for splint to work */
+#include "types.h"
+
+/* Ansi header files */
+#include <stdlib.h>
+#include <string.h> /* For memset() */
+
+#include "btblwrap.h"
+
+#if 0
+
+/* System utility files */
+#include "tiboot.h"
+
+/* Main level */
+#include "rmain.h"
+
+/* Device utilities */
+#include "device.h"
+
+#endif
+
+/* Module specific file */
+#include "btbl.h"
+#include "btblloc.h"
+
+/* Build specific Configuration */
+#include "iblcfg.h"
+
+/*******************************************************************************
+ * Private prototypes
+ ******************************************************************************/
+/* boot table processing state machine functions */
+void boot_proc_boot_tbl_init(BOOT_TBL_CB_T* p_inst);
+void boot_proc_boot_tbl_io_cnt(BOOT_TBL_CB_T* p_inst);
+void boot_proc_boot_tbl_io_regs(BOOT_TBL_CB_T* p_inst);
+void boot_proc_boot_tbl_size(BOOT_TBL_CB_T* p_inst);
+void boot_proc_boot_tbl_addr(BOOT_TBL_CB_T* p_inst);
+void boot_proc_boot_tbl_data(BOOT_TBL_CB_T* p_inst);
+void boot_proc_boot_tbl_flush(BOOT_TBL_CB_T* p_inst);
+
+/*******************************************************************************
+ * Local variables
+ ******************************************************************************/
+BOOT_TBL_CB_T btbl_inst; /* Boot table Control Instance */
+
+/*******************************************************************************
+ * DATA DEFINITION: Boot Table Processing State Machine
+ ******************************************************************************/
+BootTblProcFcn_t btbl_st_proc_fcn[BOOT_TBL_NUM_STATES];
+
+/*******************************************************************************
+ * FUNCTION PURPOSE: Process the boot table in Init State
+ *******************************************************************************
+ * DESCRIPTION: Process the boot table in Init State
+ * Record the entry point
+ *
+ * void boot_proc_boot_tbl_init (
+ * BOOT_TBL_CB_T *p_inst) - A pointer to Boot Table Control instance
+ *
+ *****************************************************************************/
+void boot_proc_boot_tbl_init(BOOT_TBL_CB_T* p_inst)
+{
+ if(p_inst->f_wait_lsw)
+ {
+ /* Process the entry point LSW */
+ p_inst->code_start_addr += (*p_inst->p_data & 0xFFFF);
+
+
+ /* C55x boot tables contain an I/O space config. C6x boot tables
+ * do not */
+#ifdef BOOTCONFIG_NO_BTBL_IO
+ p_inst->state = BOOT_TBL_STATE_SIZE;
+#else
+ p_inst->state = BOOT_TBL_STATE_IO_CNT;
+#endif
+
+
+ p_inst->f_wait_lsw = FALSE;
+ }
+ else
+ {
+ /* Process the entry point MSW */
+ p_inst->code_start_addr = ((UINT32)(*p_inst->p_data & 0xFFFF)) << 16;
+ p_inst->f_wait_lsw = (bool)TRUE;
+ }
+
+ /* Update data buffer and counter */
+ p_inst->p_data++;
+ p_inst->data_size_uint16--;
+}
+
+/*******************************************************************************
+ * FUNCTION PURPOSE: Process the boot table in IO_CNT State
+ *******************************************************************************
+ * DESCRIPTION: Process the boot table in IO_CNT State
+ * Record the number of IO Registers
+ *
+ * void boot_proc_boot_tbl_io_cnt (
+ * BOOT_TBL_CB_T *p_inst) - A pointer to Boot Table Control instance
+ *
+ *****************************************************************************/
+#ifndef BOOTCONFIG_NO_BTBL_IO
+void boot_proc_boot_tbl_io_cnt(BOOT_TBL_CB_T* p_inst)
+{
+ if(p_inst->f_wait_lsw)
+ {
+ /* LSW processing */
+ p_inst->num_io_regs += (*p_inst->p_data & 0xFFFF);
+ p_inst->f_wait_lsw = FALSE;
+ if(p_inst->num_io_regs)
+ {
+ p_inst->state = BOOT_TBL_STATE_IO_REGS;
+ }
+ else
+ {
+ p_inst->state = BOOT_TBL_STATE_SIZE;
+ }
+
+ }
+ else
+ {
+ /* MSW processing */
+ p_inst->num_io_regs = ((UINT32)(*p_inst->p_data & 0xFFFF)) << 16;
+ p_inst->f_wait_lsw = TRUE;
+ }
+
+ /* Update data buffer and counter */
+ p_inst->p_data++;
+ p_inst->data_size_uint16--;
+}
+#endif
+
+/*******************************************************************************
+ * FUNCTION PURPOSE: Process the boot table in IO_REGS State
+ *******************************************************************************
+ * DESCRIPTION: Process the boot table in IO_REG State
+ * Process IO Register configuration
+ *
+ * void boot_proc_boot_tbl_io_regs (
+ * BOOT_TBL_CB_T *p_inst) - A pointer to Boot Table Control instance
+ *
+ *****************************************************************************/
+#ifndef BOOTCONFIG_NO_BTBL_IO
+void boot_proc_boot_tbl_io_regs(BOOT_TBL_CB_T* p_inst)
+{
+ UINT16 data;
+
+ if(p_inst->f_wait_lsw)
+ {
+ /* LSW processing */
+ data = *p_inst->p_data;
+
+ /* proess the IO register configuration based on its address (opcode) */
+ switch(p_inst->io_addr)
+ {
+ case BOOT_TBL_IO_CFG_DELAY:
+ /* perform the delay loop requested */
+ chipDelay(data);
+ break;
+
+ case BOOT_TBL_IO_CFG_START_CORE:
+ /* Verify whether the start_vector is valid */
+ if(data >= (BOOT_BIT_TO_MASK(chipReadNumCores())))
+ {
+ BOOT_EXCEPTION(BOOT_ERROR_CODE(BOOT_MODULE_ID_BTBL,
+ BTBL_ERR_INVALID_START_VECTOR));
+ }
+ /* record the core start vector */
+ p_inst->core_start_vector = data;
+ break;
+
+ default:
+ /* IO Configuration */
+ chipIoWrite(p_inst->io_addr, data);
+ break;
+
+ }
+ p_inst->f_wait_lsw = FALSE;
+
+ /* Is it the last IO Register to be configured */
+ if((--p_inst->num_io_regs) == 0)
+ {
+ p_inst->state = BOOT_TBL_STATE_SIZE;
+ }
+ }
+ else
+ {
+ /* MSW processing */
+ p_inst->io_addr = *p_inst->p_data;
+ p_inst->f_wait_lsw = TRUE;
+ }
+
+ /* Update data buffer and counter */
+ p_inst->p_data++;
+ p_inst->data_size_uint16--;
+}
+#endif
+
+/*******************************************************************************
+ * FUNCTION PURPOSE: Process the boot table in SIZE State
+ *******************************************************************************
+ * DESCRIPTION: Process the boot table in SIZE State
+ * Record the size of the new code section
+ * perform end of table processing if size = 0
+ *
+ * void boot_proc_boot_tbl_size (
+ * BOOT_TBL_CB_T *p_inst) - A pointer to Boot Table Control instance
+ *
+ *****************************************************************************/
+void boot_proc_boot_tbl_size(BOOT_TBL_CB_T* p_inst)
+{
+ if(p_inst->f_wait_lsw)
+ {
+ /* LSW processing */
+ p_inst->section_size_bytes += (*p_inst->p_data & 0xFFFF);
+
+ /* Is it the end of the boot table */
+ if(p_inst->section_size_bytes == 0)
+ {
+ chipStartCore(p_inst->code_start_addr,
+ (UINT32)p_boot_entry_addr,
+ p_inst->core_start_vector);
+
+ /* End of Boot table:Clear the instance */
+ p_inst->state = BOOT_TBL_STATE_FLUSH;
+ p_inst->f_wait_lsw = FALSE;
+ return;
+ }
+
+ p_inst->state = BOOT_TBL_STATE_ADDR;
+ p_inst->f_wait_lsw = FALSE;
+
+ /* Update statistics */
+ bootStats.btbl.num_sections++;
+ }
+ else
+ {
+ /* MSW processing */
+ p_inst->section_size_bytes = ((UINT32)(*p_inst->p_data & 0xFFFF)) << 16;
+ p_inst->f_wait_lsw = (bool)TRUE;
+ }
+
+ /* Update data buffer and counter */
+ p_inst->p_data++;
+ p_inst->data_size_uint16--;
+}
+
+/*******************************************************************************
+ * FUNCTION PURPOSE: Process the boot table in ADDR State
+ *******************************************************************************
+ * DESCRIPTION: Process the boot table in ADDR State
+ * Record the start address of the new code section
+ *
+ * void boot_proc_boot_tbl_addr (
+ * BOOT_TBL_CB_T *p_inst) - A pointer to Boot Table Control instance
+ *
+ *****************************************************************************/
+void boot_proc_boot_tbl_addr(BOOT_TBL_CB_T* p_inst)
+{
+ if(p_inst->f_wait_lsw)
+ {
+ /* LSW processing */
+ p_inst->section_addr += (*p_inst->p_data & 0xFFFF);
+ p_inst->state = BOOT_TBL_STATE_DATA;
+ p_inst->f_wait_lsw = FALSE;
+ }
+ else
+ {
+ /* MSW processing */
+ p_inst->section_addr = ((UINT32)(*p_inst->p_data & 0xFFFF)) << 16;
+ p_inst->f_wait_lsw = (bool)TRUE;
+ }
+
+ /* Update data buffer and counter */
+ p_inst->p_data++;
+ p_inst->data_size_uint16--;
+}
+
+/*******************************************************************************
+ * FUNCTION PURPOSE: Process the boot table in DATA State
+ *******************************************************************************
+ * DESCRIPTION: Process the boot table in DATA State
+ * Copy the received section data to the destination memory
+ * locations
+ *
+ * void boot_proc_boot_tbl_data (
+ * BOOT_TBL_CB_T *p_inst) - A pointer to Boot Table Control instance
+ *
+ *****************************************************************************/
+#define MIN(a,b) (a)<(b) ? (a) : (b)
+void boot_proc_boot_tbl_data(BOOT_TBL_CB_T* p_inst)
+{
+ UINT32 num_bytes; /* number of bytes to be copy */
+ UINT32 num_uint16_words; /* number of 16 bit words to copy */
+ UINT16 error;
+
+ num_bytes = MIN (p_inst->section_size_bytes, CHIP_UINT16_TO_BYTES(p_inst->data_size_uint16));
+ num_uint16_words = CHIP_BYTES_TO_UINT16(num_bytes);
+
+ /* Some processors add padding to the memwidth used in the rom (created by tools) */
+ num_uint16_words = chipAddBtblUint16Pad (num_uint16_words);
+
+ /*
+ * Record the last UINT16 word and copy the data to the destination
+ * locations
+ */
+
+ if((error = coreCopyData(p_inst->section_addr, p_inst->p_data, num_bytes,
+ p_inst->core_start_vector))
+ != CORE_NOERR)
+ {
+ /* Error Processing */
+ BOOT_EXCEPTION(BOOT_ERROR_CODE(BOOT_MODULE_ID_CHIP,
+ error));
+ }
+
+ /* Update instance variables for the next code section */
+ p_inst->data_size_uint16 -= num_uint16_words;
+ p_inst->p_data += num_uint16_words;
+
+ p_inst->section_addr += num_bytes;
+ p_inst->section_size_bytes -= num_bytes;
+
+ if(p_inst->section_size_bytes == 0)
+ {
+ p_inst->state = BOOT_TBL_STATE_SIZE;
+
+ /* Chip specific post block handling. Can be defined to an empty statement */
+ chipBtblBlockDone();
+ }
+
+ /* update statistics */
+ bootStats.btbl.num_pdma_copies++;
+}
+
+/*******************************************************************************
+ * FUNCTION PURPOSE: Process the boot table in Flush State
+ *******************************************************************************
+ * DESCRIPTION: Process the boot table in Flush State
+ * We will enter this state when the end of table or error
+ * condition occurs
+ * set data_size to 0, i.e. ignore the reamining data
+ *
+ * void boot_proc_boot_tbl_error (
+ * BOOT_TBL_CB_T *p_inst) - A pointer to Boot Table Control instance
+ *
+ *****************************************************************************/
+void boot_proc_boot_tbl_flush(BOOT_TBL_CB_T* p_inst)
+{
+ p_inst->data_size_uint16 = 0;
+}
+
+/* ------------------- PUBLIC FUNCTIONS START HERE ----------------------- */
+/*******************************************************************************
+ * FUNCTION PURPOSE: Initialize the boot table control instance
+ *******************************************************************************
+ * DESCRIPTION: Initialize and allocate the boot table control instance
+ * Initialize all the variables to zero
+ * Set the state to Init
+ *
+ * void boot_init_boot_tbl_inst ( void )
+ *
+ * Note: only one instance is used at this moment
+ * a free instance function will be needed when multiple instances are
+ * supported
+ *
+ *****************************************************************************/
+void boot_init_boot_tbl_inst(BOOT_TBL_CB_T *p_btbl_inst)
+{
+ memset(p_btbl_inst, 0, sizeof(BOOT_TBL_CB_T));
+ p_btbl_inst->state = BOOT_TBL_STATE_INIT;
+
+ /*
+ * Set the core start vector to start core A only as its default value
+ * in case the boot table does not contain the setting of the core
+ * start vector.
+ */
+ p_btbl_inst->core_start_vector = 1;
+
+
+ /* Initialize the toot table processing function table */
+ btbl_st_proc_fcn[BOOT_TBL_STATE_INIT] = boot_proc_boot_tbl_init;
+
+#ifndef BOOTCONFIG_NO_BTBL_IO
+ btbl_st_proc_fcn[BOOT_TBL_STATE_IO_CNT] = boot_proc_boot_tbl_io_cnt;
+ btbl_st_proc_fcn[BOOT_TBL_STATE_IO_REGS] = boot_proc_boot_tbl_io_regs;
+#endif
+
+ btbl_st_proc_fcn[BOOT_TBL_STATE_SIZE] = boot_proc_boot_tbl_size;
+ btbl_st_proc_fcn[BOOT_TBL_STATE_ADDR] = boot_proc_boot_tbl_addr;
+ btbl_st_proc_fcn[BOOT_TBL_STATE_DATA] = boot_proc_boot_tbl_data;
+ btbl_st_proc_fcn[BOOT_TBL_STATE_FLUSH] = boot_proc_boot_tbl_flush;
+
+} /* end of boot_init_boot_tbl_inst() */
+
+/*******************************************************************************
+ * FUNCTION PURPOSE: Process the boot table
+ *******************************************************************************
+ * DESCRIPTION: Process the whole or partial boot table received by going
+ * through the boot table processing state machine until all
+ * the UINT16 words are processed or the end of table condition
+ * (section size == 0) is satisfied.
+ *
+ * void boot_proc_boot_tbl (
+ * UINT16 *p_data, - 16-bit boot table content to be processed
+ * UINT16 size) - number of 16-bit words
+ *
+ *
+ * Note: It is up to the caller to reserve 4 16-bit word space in front of the
+ * input buffer since the data may be moved to achieve 32-bit alignment
+ * requirement for PDMA transfer
+ *****************************************************************************/
+void boot_proc_boot_tbl(BOOT_TBL_CB_T *p_btbl_inst, UINT16* p_data, UINT32 size)
+{
+
+ /* Record the input data buffer and size */
+ p_btbl_inst->p_data = p_data;
+ p_btbl_inst->data_size_uint16 = size;
+
+ /* Optional: verify the inst state is valid */
+ if(p_btbl_inst->state > BOOT_TBL_LAST_STATE)
+ {
+ /* Error Processing */
+ BOOT_EXCEPTION(BOOT_ERROR_CODE(BOOT_MODULE_ID_BTBL,
+ BTBL_ERR_INVALID_STATE));
+
+ }
+
+ /*
+ * Invoke the Boot table processing state machine until all the input
+ * data are processed or the end of table condition is satified
+ */
+ while (p_btbl_inst->data_size_uint16 != 0)
+ {
+ btbl_st_proc_fcn[p_btbl_inst->state](p_btbl_inst);
+ }
+
+} /* end of boot_proc_boot_tbl() */
+
diff --git a/src/interp/btbl/btblwrap.c b/src/interp/btbl/btblwrap.c
--- /dev/null
@@ -0,0 +1,146 @@
+/************************************************************************************
+ * FILE PURPOSE: Wrapper for the TI boot table processor
+ ************************************************************************************
+ * FILE NAME: btblwrap.c
+ *
+ * DESCRIPTION: The IBL wrapper for the boot table processor.
+ *
+ ************************************************************************************/
+#include "types.h"
+#include "ibl.h"
+#include "iblloc.h"
+#include "btblwrap.h"
+#include "btbl.h"
+#include "btblloc.h"
+#include "iblbtbl.h"
+#include <stdlib.h>
+#include <string.h>
+
+
+/* Globals used by the TI boot table processor */
+
+BOOT_TBL_CB_T tiBootTable;
+bootStats_t bootStats;
+Uint32 btblEcode;
+Int32 btblWrapEcode;
+
+
+#define MIN(a,b) ((a) < (b)) ? (a) : (b)
+
+
+/************************************************************************************
+ * FUNCTION PURPOSE: The main boot wrapper for the TI boot table processor
+ ************************************************************************************
+ * DESCRIPTION: Interfaces the IBL to the TI boot table driver.
+ * The TI boot table driver operates in a push data mode, the
+ * IBL operates in a pull data mode. This function pulls data
+ * from the interface and pushes is to the TI driver. To do this
+ * the internal state of the TI boot table driver is used
+ * to determine how much data to pull.
+ ************************************************************************************/
+void iblBootBtbl (BOOT_MODULE_FXN_TABLE *bootFxn, Uint32 *entry_point)
+{
+ Uint32 readSize;
+ Uint32 blockSize;
+ Uint32 blockSize16;
+ Uint8 *data;
+ Uint16 *data16;
+ Uint16 t16;
+
+ Int32 i, j;
+
+ *entry_point = 0;
+ btblEcode = 0;
+ btblWrapEcode = 0;
+
+ /* Initialize stats and btbl state */
+ memset (&bootStats, 0, sizeof(bootStats_t));
+
+ boot_init_boot_tbl_inst (&tiBootTable);
+
+ data = malloc (TI_BTBL_BLOCK_SIZE);
+ if (data == NULL) {
+ btblWrapEcode = BTBL_WRAP_ECODE_MALLOC_FAIL;
+ return;
+ }
+
+ data16 = (Uint16 *)data;
+
+ while ((tiBootTable.state != BOOT_TBL_STATE_FLUSH) && (btblEcode == 0)) {
+
+ switch (tiBootTable.state) {
+
+ case BOOT_TBL_STATE_INIT:
+ case BOOT_TBL_STATE_SIZE:
+ case BOOT_TBL_STATE_ADDR: readSize = 4;
+ break;
+
+ case BOOT_TBL_STATE_DATA: readSize = tiBootTable.section_size_bytes;
+ break;
+ }
+
+
+ while (readSize > 0) {
+
+ blockSize = MIN(readSize, TI_BTBL_BLOCK_SIZE);
+ blockSize16 = (blockSize + 1) >> 1;
+
+ /* No recovery on block read failure */
+ if ((*bootFxn->read)(data, blockSize) < 0) {
+ btblWrapEcode = BTBL_WRAP_ECODE_READ_FAIL;
+ free (data);
+ return;
+ }
+
+ /* The data has been read as a byte stream. This data must
+ * be re-formatted as a 16 bit word stream */
+ for (j = i = 0; j < blockSize16; j++, i += 2) {
+
+ t16 = (data[i+0] << 8) | data[i+1];
+ data16[j] = t16;
+
+ }
+
+
+ /* Process the block */
+ boot_proc_boot_tbl (&tiBootTable, data16, blockSize16);
+
+ readSize = readSize - blockSize;
+
+ }
+
+ }
+
+ if (btblEcode == 0)
+ *entry_point = tiBootTable.code_start_addr;
+
+ free (data);
+
+}
+
+/***********************************************************************************
+ * FUNCTION PURPOSE: Handle a fatal error from the boot table processor
+ ***********************************************************************************
+ * DESCRIPTION: The error code is stored. Processing is terminated
+ * through the global ecode value.
+ ***********************************************************************************/
+void btblBootException (UINT32 ecode)
+{
+ btblEcode = ecode;
+ btblWrapEcode = BTBL_WRAP_ECODE_BTBL_FAIL;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/interp/btbl/btblwrap.h b/src/interp/btbl/btblwrap.h
--- /dev/null
@@ -0,0 +1,88 @@
+#ifndef BTBLWRAP_H
+#define BTBLWRAP_H
+/********************************************************************************
+ * FILE PURPOSE: Define the IBL wrapper for the TI boot table processor
+ ********************************************************************************
+ * FILE NAM:E btblwrap.h
+ *
+ * DESCRIPTION: Definitions required for the IBL wrapper of the TI boot table
+ * processor
+ *
+ ********************************************************************************/
+
+/* chipStartCore does nothing, since multiple core start is not supported */
+#define chipStartCore(x,y,z)
+
+/* A minimal boot stats structure */
+typedef struct bootTblStats_s {
+
+ UINT32 num_sections;
+ UINT32 num_pdma_copies;
+
+} bootTblStats_t;
+
+
+typedef struct bootStats_s {
+
+ bootTblStats_t btbl;
+
+} bootStats_t;
+
+extern bootStats_t bootStats;
+
+/****************************************************************************
+ * Definition: The c64x boot table tools will always pad boot table
+ * entries to 32 bit elements. The boot table works in 16 bit
+ * element sizes. If the size is not an even number of 16 bit
+ * elements, add one word of padding.
+ ****************************************************************************/
+#define chipAddBtblUint16Pad(x) (((x)+1) & 0xfffffffe)
+
+/* Return values */
+#define CORE_NOERR 0
+
+/* Module number */
+#define BOOT_MODULE_ID_CHIP 0
+#define BOOT_MODULE_ID_BTBL 1
+
+/* Error code creation */
+#define BOOT_ERROR_CODE(modnum,errnum) (((modnum) << 16) | (errnum))
+
+/* Fatal error handling */
+#define BOOT_EXCEPTION btblBootException
+
+/* Macros */
+#define CHIP_UINT16_TO_BYTES(x) ((x) << 1)
+#define CHIP_BYTES_TO_UINT16(x) (((x) + 1) >> 1)
+
+
+/* No interblock processing required */
+#define chipBtblBlockDone()
+
+/* No tracing dummy function */
+#define chipDummy(x)
+
+
+/* gem.c prototypes */
+UINT16 coreCopyData (UINT32 dest_addr, UINT16 *p_data, UINT32 sizeBytes, UINT16 start_vector);
+
+/* btblwrap.c prototypes */
+void btblBootException (UINT32 ecode);
+
+/* The block size allocated through malloc. Chosen to match the value defined
+ * for the coff loader. malloc is used so the same heap section can be used. */
+#define TI_BTBL_BLOCK_SIZE 0x4000
+
+/* Read/Write 32bit values */
+#define chipStoreWord(x,y) *(x) = (y)
+#define chipReadWord(x) *(x)
+
+/* Boot table wrapper error codes */
+#define BTBL_WRAP_ECODE_MALLOC_FAIL 100
+#define BTBL_WRAP_ECODE_READ_FAIL 101
+#define BTBL_WRAP_ECODE_BTBL_FAIL 102
+
+
+#endif /* BTBLWRAP_H */
+
+
diff --git a/src/interp/btbl/gem.c b/src/interp/btbl/gem.c
--- /dev/null
+++ b/src/interp/btbl/gem.c
@@ -0,0 +1,128 @@
+/**********************************************************************************************************
+ * FILE PURPOSE: Support functions specific to gem
+ **********************************************************************************************************
+ * FILE NAME: gem.c
+ *
+ * DESCRIPTION: Contains functions common to all gem devices.
+ *
+ **********************************************************************************************************/
+#include "types.h"
+#include "btblwrap.h"
+
+extern volatile cregister unsigned int CSR;
+#define C64X_REG_CSR_BIT_EN (1 << 8)
+
+/************************************************************************************
+ * FUNCTION PURPOSE: Copy data from the boot table to the destination locations
+ ************************************************************************************
+ * DESCRIPTION: Copy data from the boot table to the destination.
+ *
+ * The input data is interpreted as 32 bit values, made up of two 16
+ * bit values in big endian format. This is done to acheive endian
+ * independence on the c64x.
+ *
+ * If the size is not evenly divisible by 4 then the final write does a
+ * read first, and writes the most significant bytes back.
+ ************************************************************************************/
+UINT16 coreCopyData (UINT32 dest_addr, UINT16 *p_data, UINT32 sizeBytes, UINT16 start_vector)
+{
+ UINT32 value;
+ UINT32 insert;
+ UINT32 i;
+ UINT32 j;
+ UINT32 n32;
+ UINT32 rb;
+
+ UINT32 *restrict rdest;
+ UINT16 *restrict rsrc;
+
+ chipDummy ((void *)start_vector);
+
+ n32 = sizeBytes >> 2;
+
+
+ /* If the destination address is 32 bit aligned an unaligned copy is not requird */
+ if ((dest_addr & 0x3) == 0) {
+
+ rdest = (UINT32 *)dest_addr;
+ rsrc = p_data;
+
+ for (i = j = 0; i < n32; i++, j += 2) {
+
+ value = (((UINT32)rsrc[j]) << 16) | (rsrc[j+1]);
+ rdest[i] = value;
+
+ }
+
+ dest_addr += (n32 << 2);
+
+
+ } else {
+
+ /* Do whole 32 bit writes first */
+ for (i = j = 0; i < n32; i++, j += 2) {
+
+ value = (((UINT32)p_data[j]) << 16) | (p_data[j+1]);
+ chipStoreWord ((UINT32 *)dest_addr, value);
+ dest_addr += 4;
+
+ }
+
+ }
+
+ /* Handle any remaining values based on the endian of the device */
+ rb = sizeBytes - (n32 << 2);
+
+ if (rb != 0) {
+
+ value = chipReadWord ((UINT32 *)dest_addr);
+
+ if ((CSR & C64X_REG_CSR_BIT_EN) != 0) {
+
+ /* Little endian. Put remaining bytes in the least significant value */
+ if (rb >= 1) {
+ insert = (p_data[j] >> 8) & 0x00ff;
+ value = (value & 0xffffff00) | insert;
+
+ }
+
+ if (rb >= 2) {
+ insert = p_data[j] & 0x00ff;
+ value = (value & 0xffff00ff) | (insert << 8);
+
+ }
+
+ if (rb >= 3) {
+ insert = (p_data[j+1] >> 8) & 0x00ff;
+ value = (value & 0xff00ffff) | (insert << 16);
+ }
+
+ } else {
+
+ /* Bit endian. Put remaining bytes in the most significant value */
+ if (rb == 1) {
+ insert = (p_data[j] >> 8) & 0xff;
+ value = (value & 0x00ffffff) | (insert << 24);
+
+ } else if (rb == 2) {
+ insert = p_data[j] & 0xffff;
+ value = (value & 0x0000ffff) | (insert << 16);
+
+ } else if (rb == 3) {
+ insert = ((p_data[j] << 8) | (p_data[j+1] >> 8)) & 0x00ffffff;
+ value = (value & 0x000000ff) | (insert << 8);
+ }
+
+ }
+
+ chipStoreWord ((UINT32 *)dest_addr, value);
+
+ }
+
+
+ return (CORE_NOERR);
+
+} /* coreCopyData */
+
+
+
diff --git a/src/interp/btbl/iblbtbl.h b/src/interp/btbl/iblbtbl.h
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef _IBL_BTBL_H
+#define _IBL_BTBL_H
+
+/*************************************************************************************************
+ * FILE PURPOSE: Define the boot table processor to the IBL
+ *************************************************************************************************
+ * FILE NAME: iblbtbl.h
+ *
+ * DESCRIPTION: Defines the API to the IBL boot table processing wrapper
+ *
+ *************************************************************************************************/
+#include "types.h"
+#include "iblloc.h"
+
+
+/* Prototypes */
+void iblBootBtbl (BOOT_MODULE_FXN_TABLE *bootFxn, Uint32 *entry_point);
+
+
+
+
+
+#endif /* _IBL_BTBL_H */
diff --git a/src/interp/c64x/make/makefile b/src/interp/c64x/make/makefile
--- /dev/null
@@ -0,0 +1,49 @@
+#****************************************************************************
+#* FILE NAME: makefile
+#*
+#* DESCRIPTION: Makes the data parsers for the IBL
+#*
+#****************************************************************************
+
+
+ifndef IBL_ROOT
+ export IBL_ROOT=../../..
+endif
+
+ECODIR= $(IBL_ROOT)/interp
+
+CSRC= bis.c cload.c osal.c btblpr.c btblwrap.c gem.c blob.c
+
+
+.PHONY: interp
+
+
+include $(IBL_ROOT)/make/$(ARCH)/makeeco.mk
+
+
+C6X_C_DIR= $(IBL_ROOT)
+C6X_C_DIR+= ;$(IBL_ROOT)/arch/$(ARCH)
+C6X_C_DIR+= ;$(ECODIR)
+C6X_C_DIR+= ;$(STDINC)
+C6X_C_DIR+= ;$(IBL_ROOT)/cfg/$(TARGET)
+export C6X_C_DIR
+
+
+vpath % $(ECODIR)/bis
+vpath % $(ECODIR)/coff
+vpath % $(ECODIR)/btbl
+vpath % $(ECODIR)/blob
+
+interp: gen_cdefdep makefile $(OBJS)
+
+
+$(OBJS): cdefdep
+
+
+
+gen_cdefdep:
+ @echo Checking command line dependencies
+ @echo $(ENDIAN) $(TARGET) $(ARCH) > cdefdep.tmp
+ @sh -c 'if diff -q cdefdep.tmp cdefdep ; then echo same ; else $(CP) cdefdep.tmp cdefdep ; fi '
+
+
diff --git a/src/interp/coff/cload.c b/src/interp/coff/cload.c
--- /dev/null
+++ b/src/interp/coff/cload.c
@@ -0,0 +1,2176 @@
+/***************************************************************************
+* FILENAME: cload.c
+* VERSION: 2.6 5/2/96 13:11:03
+* SCCS ID: "@(#)cload.c 2.6 5/2/96"
+***************************************************************************/
+/******************************************************************************/
+/* CLOAD.C - Generic COFF Loader Version 6.00 4/96 */
+/******************************************************************************/
+/* */
+/* This module contains functions to read in and load a COFF object file. */
+/* The following routines are defined here: */
+/* */
+/* cload() - Main driver for COFF loader. */
+/* cload_headers() - Read in the various headers of the COFF file. */
+/* cload_data() - Read in the raw data and load it into memory. */
+/* cload_sect_data() - Read, relocate, and write out one section. */
+/* cload_cinit() - Process one buffer of C initialization records. */
+/* cload_symbols() - Read in the symbol table. */
+/* cload_strings() - Read in the string table. */
+/* str_free() - Free a string table. */
+/* sym_read() - Read and relocate a symbol and its aux entry. */
+/* sym_name() - Return a pointer to the name of a symbol. */
+/* sym_add_name() - Add a symbol name to the string table. */
+/* reloc_add() - Add a symbol to the relocation symbol table. */
+/* relocate() - Perform a single relocation. */
+/* reloc_read() - Read in and swap one relocation entry. */
+/* reloc_size() - Return the field size of a relocation type. */
+/* reloc_offset() - Return the field offset of a relocation type. */
+/* reloc_stop() - Return the number of bits to read for a reloc type. */
+/* sym_reloc_amount()- Return relocation amount for a relocation entry. */
+/* unpack() - Extract a relocation field from object bytes. */
+/* repack() - Encode a relocated field into object bytes. */
+/* cload_lineno() - Read in & swap line number entries. */
+/* swap4byte() - Swap the order of bytes in a int. */
+/* swap2byte() - Swap the order of bytes in a short. */
+/* */
+/* The loader calls the following external functions to perform application */
+/* specific tasks: */
+/* */
+/* set_reloc_amount() - Define relocation amounts for each section. */
+/* mem_write() - Load a buffer of data into memory. */
+/* lookup_sym() - Look up a symbol in an external symbol table. */
+/* load_syms() - Build the symbol table for the application. */
+/* load_msg() - Write diagnostic messages during loading. */
+/* */
+/******************************************************************************/
+#include "header.h"
+#include "coff_trg.h"
+#if ((FILE_BASED) && !defined(FILE))
+#include <stdio.h>
+#endif
+/*----------------------------------------------------------------------------*/
+/* CONSTANTS, MACROS, VARIABLES, AND STRUCTURES FOR THE LOADER. */
+/*----------------------------------------------------------------------------*/
+#define TRUE 1
+#define FALSE 0
+#define WORDSZ sizeof(T_DATA) /* SIZE OF DATA UNITS IN OBJ FILE */
+
+#ifdef TMS320C60
+ extern int target_coff (unsigned short flags);
+#endif
+
+/*----------------------------------------------------------------------------*/
+/* APPLICATION VARIABLES */
+/*----------------------------------------------------------------------------*/
+#if (FILE_BASED)
+FILE *fin; /* INPUT FILE */
+#else
+extern unsigned char gRxBuffer[0x400040];
+#endif
+
+int need_data = TRUE; /* APPLICATION NEEDS RAW DATA */
+int need_symbols = FALSE; /* APPLICATION NEEDS SYMBOL TABLE */
+int clear_bss = FALSE; /* CLEAR BSS SECTION */
+
+
+/*----------------------------------------------------------------------------*/
+/* FILL VALUES TO BE USED BY LOADERS */
+/*----------------------------------------------------------------------------*/
+#if defined(OTIS)
+extern int fill_bss;
+extern int fill_bss_value;
+#else
+#define fill_bss 0
+#define fill_bss_value 0
+#endif
+
+/*----------------------------------------------------------------------------*/
+/* LOADER VARIABLES */
+/*----------------------------------------------------------------------------*/
+FILHDR file_hdr; /* FILE HEADER STRUCTURE */
+int coff_version; /* COFF VERSION USED IN FILE */
+AOUTHDR o_filehdr; /* OPTIONAL (A.OUT) FILE HEADER */
+T_ADDR entry_point; /* ENTRY POINT OF MODULE */
+T_ADDR *reloc_amount = NULL; /* AMOUNT OF RELOCATION PER SECTION */
+char *sect_hdrs = NULL; /* ARRAY OF SECTION HEADERS */
+char *o_sect_hdrs = NULL; /* ARRAY OF OLD COFF SECTION HEADERS */
+int n_sections; /* NUMBER OF SECTIONS IN THE FILE */
+int big_e_target; /* TARGET DATA IN BIG-ENDIAN FORMAT */
+int byte_swapped; /* BYTE ORDERING OPPOSITE OF HOST */
+int curr_sect; /* SECTION NUMBER CURRENTLY LOADING */
+int load_err; /* ERROR CODE RETURNED IF LOADER FAILS*/
+struct strtab *str_head = NULL; /* LIST OF STRING TABLE BUFFERS */
+
+static T_SIZE init_size = 0; /* CURRENT SIZE OF C INITIALIZATION */
+static int need_reloc; /* RELOCATION REQUIRED */
+
+#if TMS320C60
+int big_e_config = TRG_DEF_BIG_E; /* ENDIANNESS CONFIGURATION */
+#else
+int big_e_config = DONTCARE; /* ENDIANNESS CONFIGURATION */
+#endif
+
+/*----------------------------------------------------------------------------*/
+/* THIS STRUCTURE IS USED TO STORE THE RELOCATION AMOUNTS FOR SYMBOLS. */
+/* EACH RELOCATABLE SYMBOL HAS A CORRESPONDING ENTRY IN THIS TABLE. */
+/* THE TABLE IS SORTED BY SYMBOL INDEX; LOOKUP USES A BINARY SEARCH. */
+/*----------------------------------------------------------------------------*/
+typedef struct
+{
+ int rt_index; /* INDEX OF SYMBOL IN SYMBOL TABLE */
+ int rt_disp; /* AMOUNT OF RELOCATION */
+} RELOC_TAB;
+
+/*----------------------------------------------------------------------------*/
+/* THE RELOCATION SYMBOL TABLE IS ALLOCATED DYNAMICALLY, AND REALLOCATED */
+/* AS MORE SPACE IS NEEDED. */
+/*----------------------------------------------------------------------------*/
+#define RELOC_TAB_START 128 /* STARTING SIZE OF TABLE */
+#define RELOC_GROW_SIZE 128 /* REALLOC AMOUNT FOR TABLE */
+
+static RELOC_TAB *reloc_tab = NULL; /* RELOCATION SYMBOL TABLE */
+
+static int reloc_tab_size; /* CURRENT ALLOCATED AMOUNT */
+static int reloc_sym_index; /* CURRENT SIZE OF TABLE */
+
+/*----------------------------------------------------------------------------*/
+/* RUN-TIME RELOCATION (AS OPPOSED TO LOAD-TIME) RELOCATION IS DETERMINED */
+/* AS FOLLOWS: IF THE SECTION'S RUNTIME ADDRESS == LOADTIME ADDRESS, USE */
+/* LOADTIME RELOCATION. OTHERWISE, ASSUME LOADTIME RELOC ONLY (RUNTIME RELOC */
+/* == 0). */
+/*----------------------------------------------------------------------------*/
+#define RUN_RELOC_AMOUNT(i) ((SECT_HDR(i)->s_paddr == SECT_HDR(i)->s_vaddr) ? \
+ reloc_amount[i] : 0)
+
+/*----------------------------------------------------------------------------*/
+/* DEFINE A STRUCTURE FOR STRING TABLE BUFFERS. THESE BUFFERS ARE STORED */
+/* AS A LINKED LIST OF MEMORY PACKETS, EACH CONTAINING UP TO 64K OF THE */
+/* STRING TABLE. */
+/*----------------------------------------------------------------------------*/
+typedef struct strtab
+{
+ unsigned int size; /* SIZE OF THIS PACKET */
+ unsigned int offset; /* STARTING OFFSET OF THIS PACKET */
+ unsigned int index; /* AMOUNT CURRENTLY FILLED */
+ struct strtab *next; /* NEXT BUFFER */
+ char buf[1]; /* STRING DATA (EXPAND AS ALLOCATED) */
+} STRTAB;
+
+#define MAX_STRING_ALLOC (unsigned int)(0xffff-sizeof(STRTAB)+1)
+ /* MAX STRING BUFFER: 64K (SMALL HOSTS)*/
+#define MIN_STRING_ALLOC 0x0400 /* MIN STRING BUFFER: 1K */
+
+unsigned int unpack();
+
+/* extern void mem_copy(unsigned char* dst, unsigned char* src, int nbytes); - defined in osal.h */
+/******************************************************************************/
+/* */
+/* CLOAD() - Main driver for COFF loader. */
+/* */
+/******************************************************************************/
+int cload()
+{
+ int result;
+
+ load_err = 0;
+ result = cload_headers() && cload_data();
+
+ if (reloc_tab) free(reloc_tab);
+ reloc_tab = NULL;
+
+ if(result == TRUE)
+ return 0;
+ else
+ return -1;
+}
+
+\f
+/******************************************************************************/
+/* */
+/* CLOAD_HEADERS() - Read in the various headers of the COFF file. */
+/* */
+/******************************************************************************/
+int cload_headers()
+{
+ int i;
+
+ byte_swapped = FALSE;
+ need_reloc = FALSE;
+#if FILE_BASED
+ if (fseek(fin, 0L, 0) != 0 || !fread(&file_hdr, FILHSZ, 1, fin))
+ { load_err = E_FILE; return FALSE; }
+#else
+ mem_copy((void*)&file_hdr, gRxBuffer, FILHSZ);
+#endif
+
+ /*-------------------------------------------------------------------------*/
+ /* MAKE SURE THIS IS REALLY A COFF FILE. CHECK FOR SWAPPED FILES. */
+ /* DETERMINE BYTE ORDERING OF OBJECT DATA. */
+ /*-------------------------------------------------------------------------*/
+ if (!ISCOFF(file_hdr.f_magic))
+ {
+ swap2byte(&file_hdr.f_magic);
+
+ if (!ISCOFF(file_hdr.f_magic)) { load_err = E_MAGIC; return FALSE; }
+
+ byte_swapped = TRUE;
+
+ swap2byte(&file_hdr.f_nscns); swap4byte(&file_hdr.f_timdat);
+ swap4byte(&file_hdr.f_symptr); swap4byte(&file_hdr.f_nsyms);
+ swap2byte(&file_hdr.f_opthdr); swap2byte(&file_hdr.f_flags);
+#if COFF_VERSION_1 || COFF_VERSION_2
+ swap2byte(&file_hdr.f_target_id);
+#endif
+ }
+
+ /*-------------------------------------------------------------------------*/
+ /* DETERMINE THE ENDIANNESS OF THE COFF FILE, AND ENSURE THE ENDIANNESS OF */
+ /* THE FILE IS THE SAME AS THE TARGET, IF THERE IS A TARGET. */
+ /*-------------------------------------------------------------------------*/
+ big_e_target = ((file_hdr.f_flags & F_BIG) != 0);
+ if (big_e_config != DONTCARE && big_e_target != big_e_config)
+ { load_err = E_ENDIAN; return FALSE; }
+
+ /*-------------------------------------------------------------------------*/
+ /* DETERMINE VERSION OF COFF BEING USED, CHECK TARGET ID IF NEEDED. */
+ /*-------------------------------------------------------------------------*/
+ if (ISCOFF_1(file_hdr.f_magic) || ISCOFF_2(file_hdr.f_magic))
+ {
+ if (!ISMAGIC(file_hdr.f_target_id)) { load_err = E_MAGIC; return FALSE; }
+ coff_version = file_hdr.f_magic;
+ }
+ else coff_version = COFF_MAGIC_0;
+
+#ifdef TMS320C60
+ /*-------------------------------------------------------------------------*/
+ /* DETERMINE WHETHER THE RIGHT COFF IS BEING LOADED */
+ /*-------------------------------------------------------------------------*/
+ if ( !target_coff( file_hdr.f_flags) )
+ { load_err = E_FILE; return FALSE; }
+#endif
+
+ /*-------------------------------------------------------------------------*/
+ /* READ IN OPTIONAL HEADER, IF THERE IS ONE, AND SWAP IF NEEDED. */
+ /*-------------------------------------------------------------------------*/
+ if (file_hdr.f_opthdr == AOUTSZ)
+ {
+#if FILE_BASED
+ fseek(fin, (int)FILHSZ_IN(coff_version), 0);
+ if (fread(&o_filehdr, file_hdr.f_opthdr, 1, fin) != 1)
+ { load_err = E_FILE; return FALSE; }
+#else
+ mem_copy((void*)&o_filehdr, &gRxBuffer[(int)FILHSZ_IN(coff_version)], file_hdr.f_opthdr);
+#endif
+
+ if (byte_swapped)
+ {
+ swap2byte(&o_filehdr.magic); swap2byte(&o_filehdr.vstamp);
+ swap4byte(&o_filehdr.tsize); swap4byte(&o_filehdr.dsize);
+ swap4byte(&o_filehdr.bsize); swap4byte(&o_filehdr.entrypt);
+ swap4byte(&o_filehdr.text_start); swap4byte(&o_filehdr.data_start);
+ }
+ entry_point = o_filehdr.entrypt;
+ }
+
+ /*-------------------------------------------------------------------------*/
+ /* Read in string table so that we can see long section names, if needed. */
+ /* This used tobe read right before the symbol table was read, but now the */
+ /* section headers use "flexname" method to specify section names and so */
+ /* might need access to a string table entry. */
+ /*-------------------------------------------------------------------------*/
+ //if (!cload_strings()) return FALSE;
+
+ /*-------------------------------------------------------------------------*/
+ /* READ IN SECTION HEADERS. */
+ /*-------------------------------------------------------------------------*/
+ if (sect_hdrs) { free(sect_hdrs); sect_hdrs = NULL; }
+ if (o_sect_hdrs) { free(o_sect_hdrs); o_sect_hdrs = NULL; }
+
+ if (!(sect_hdrs = (char *)malloc((n_sections = file_hdr.f_nscns) * SCNHSZ)))
+ { load_err = E_ALLOC; return FALSE; }
+
+#if FILE_BASED
+ fseek(fin, (int)FILHSZ_IN(coff_version) + file_hdr.f_opthdr, 0);
+#endif
+ /*-------------------------------------------------------------------------*/
+ /* Depending on which version of COFF we are reading, set up the section */
+ /* headers or s copy that we can translate into the new version. */
+ /*-------------------------------------------------------------------------*/
+ if (ISCOFF_2(coff_version))
+ {
+#if FILE_BASED
+ if (fread(sect_hdrs,SCNHSZ_IN(coff_version),n_sections,fin) != n_sections)
+ { load_err = E_FILE; return FALSE; }
+#else
+ mem_copy((void*)sect_hdrs, &gRxBuffer[(int)FILHSZ_IN(coff_version) + file_hdr.f_opthdr], SCNHSZ_IN(coff_version)*n_sections );
+#endif
+ }
+ else
+ {
+ if (!(o_sect_hdrs = (char *)malloc(n_sections * SCNHSZ_IN(coff_version))))
+ { load_err = E_ALLOC; return FALSE; }
+#if FILE_BASED
+ if (fread(o_sect_hdrs,SCNHSZ_IN(coff_version),n_sections,fin)!=n_sections)
+ { load_err = E_FILE; return FALSE; }
+#else
+ mem_copy((void*)o_sect_hdrs, &gRxBuffer[(int)FILHSZ_IN(coff_version) + file_hdr.f_opthdr], SCNHSZ_IN(coff_version)*n_sections );
+#endif
+ }
+
+ if (reloc_amount) free(reloc_amount);
+
+ if (!(reloc_amount = (T_ADDR*)malloc(n_sections * sizeof(T_ADDR))))
+ {
+ load_err = E_ALLOC;
+ return FALSE;
+ }
+
+ /*-------------------------------------------------------------------------*/
+ /* SWAP SECTION HEADERS IF REQUIRED. */
+ /*-------------------------------------------------------------------------*/
+ for (i = 0; i < n_sections; i++)
+ {
+ SCNHDR *sptr = SECT_HDR(i);
+ O_SCNHDR *tptr = O_SECT_HDR(i);
+
+ if (byte_swapped)
+ {
+ /*-----------------------------------------------------------------*/
+ /* Swap sections according to native COFF version. */
+ /*-----------------------------------------------------------------*/
+ if (ISCOFF_2(coff_version))
+ {
+ if (sptr->s_zeroes == 0L) swap4byte(&sptr->s_offset);
+ swap4byte(&sptr->s_paddr);
+ swap4byte(&sptr->s_vaddr);
+ swap4byte(&sptr->s_size);
+ swap4byte(&sptr->s_scnptr);
+ swap4byte(&sptr->s_relptr);
+ swap4byte(&sptr->s_lnnoptr);
+ swap4byte(&sptr->s_nreloc);
+ swap4byte(&sptr->s_nlnno);
+ swap4byte(&sptr->s_flags);
+ /* s_mwidth - single byte */
+ /* s_reserved - single byte */
+ swap2byte(&sptr->s_page);
+ }
+ else
+ {
+ swap4byte(&tptr->os_paddr);
+ swap4byte(&tptr->os_vaddr);
+ swap4byte(&tptr->os_size);
+ swap4byte(&tptr->os_scnptr);
+ swap4byte(&tptr->os_relptr);
+ swap4byte(&tptr->os_lnnoptr);
+ swap2byte(&tptr->os_nreloc);
+ swap2byte(&tptr->os_nlnno);
+ swap2byte(&tptr->os_flags);
+ /* os_reserved - one byte */
+ /* os_page - one byte */
+ }
+ }
+
+ /*---------------------------------------------------------------------*/
+ /* Old COFF version section headers are now ready to be transferred. */
+ /*---------------------------------------------------------------------*/
+ if (!ISCOFF_2(coff_version))
+ {
+ strn_copy(sptr->s_name, tptr->os_name, SYMNMLEN);
+ sptr->s_paddr = tptr->os_paddr;
+ sptr->s_vaddr = tptr->os_vaddr;
+ sptr->s_size = tptr->os_size;
+ sptr->s_scnptr = tptr->os_scnptr;
+ sptr->s_relptr = tptr->os_relptr;
+ sptr->s_lnnoptr = tptr->os_lnnoptr;
+ sptr->s_nreloc = tptr->os_nreloc;
+ sptr->s_nlnno = tptr->os_nlnno;
+ sptr->s_flags = tptr->os_flags;
+ sptr->s_page = tptr->os_page;
+ }
+
+ reloc_amount[i] = 0;
+
+#if 0 // not to search the string table
+ /*---------------------------------------------------------------------*/
+ /* Fix up section name if it is a pointer into the string table. */
+ /*---------------------------------------------------------------------*/
+ if (sptr->s_zeroes == 0L)
+ {
+ STRTAB *packet = str_head;
+
+ if (packet == NULL)
+ {
+ return -1;
+ }
+
+ if (str_head->offset > sptr->s_offset)
+ {
+ return -1;
+ }
+
+ while (sptr->s_offset < (int)packet->offset) packet = packet->next;
+ sptr->s_nptr = packet->buf + (sptr->s_offset - packet->offset);
+ }
+#endif
+ } // for ends
+
+
+ /*-------------------------------------------------------------------------*/
+ /* CALL AN EXTERNAL ROUTINE TO DETERMINE THE RELOCATION AMOUNTS FOR */
+ /* EACH SECTION. */
+ /*-------------------------------------------------------------------------*/
+ if (!set_reloc_amount()) { load_err = E_SETRELOC; return FALSE; }
+ for (i = 0; i < n_sections; i++) need_reloc |= (reloc_amount[i] != 0);
+ if (!need_data) need_reloc = FALSE;
+
+ if (need_reloc && (file_hdr.f_flags & F_RELFLG))
+ { load_err = E_RELOC; return FALSE; }
+
+ return TRUE;
+}
+
+\f
+/******************************************************************************/
+/* */
+/* CLOAD_DATA() - Read in the raw data and load it into memory. */
+/* */
+/******************************************************************************/
+int cload_data()
+{
+ int ok = TRUE;
+
+ if (!need_data) return TRUE;
+
+ /*-------------------------------------------------------------------------*/
+ /* LOOP THROUGH THE SECTIONS AND LOAD THEM ONE AT A TIME. */
+ /*-------------------------------------------------------------------------*/
+ for (curr_sect = 0; curr_sect < n_sections && ok; curr_sect++)
+ {
+ SCNHDR *sptr = SECT_HDR(curr_sect);
+ char *sname = (sptr->s_zeroes == 0L) ?
+ sptr->s_nptr : SNAMECPY(sptr->s_name);
+
+ /*----------------------------------------------------------------------*/
+ /* IF THIS IS THE TEXT SECTION, RELOCATE THE ENTRY POINT. */
+ /*----------------------------------------------------------------------*/
+ if ((sptr->s_flags & STYP_TEXT) && !str_comp(sname, ".text"))
+ entry_point += RUN_RELOC_AMOUNT(curr_sect);
+
+ /*----------------------------------------------------------------------*/
+ /* IGNORE EMPTY SECTIONS OR SECTIONS WHOSE FLAGS INDICATE THE */
+ /* SECTION IS NOT TO BE LOADED. IF THE CLEAR_BSS FLAG IS SET, BSS */
+ /* IS "LOADED" EVEN THOUGH IT HAS NO DATA, AND DEFER THE CINIT */
+ /* SECTION UNTIL LATER TO ENSURE BSS IS LOADED FIRST. */
+ /*----------------------------------------------------------------------*/
+ if ((sptr->s_scnptr || ((clear_bss || fill_bss) && IS_BSS(sptr))) &&
+ (sptr->s_size) &&
+ !(sptr->s_flags & (STYP_DSECT | STYP_COPY | STYP_NOLOAD)))
+ ok &= cload_sect_data(sptr);
+ }
+
+ /*-------------------------------------------------------------------------*/
+ /* WE DEFERRED CINIT, LOAD IT/THEM NOW. */
+ /*-------------------------------------------------------------------------*/
+ for (curr_sect = 0; curr_sect < n_sections && ok; curr_sect++)
+ {
+ SCNHDR *sptr = SECT_HDR(curr_sect);
+ char *sname = (sptr->s_zeroes == 0L) ?
+ sptr->s_nptr : SNAMECPY(sptr->s_name);
+
+ if (IS_CINIT(sptr))
+ {
+ ok &= cload_sect_data(sptr);
+ }
+ }
+
+ return ok;
+}
+
+\f
+/******************************************************************************/
+/* */
+/* CLOAD_SECT_DATA() - Read, relocate, and write out the data for one section.*/
+/* */
+/******************************************************************************/
+int cload_sect_data(SCNHDR *sptr)
+{
+ T_ADDR addr = sptr->s_vaddr; /* CURRENT ADDRESS IN SECTION */
+ unsigned int nbytes; /* BYTE COUNT WITHIN SECTION */
+ int packet_size = 0; /* SIZE OF CURRENT DATA BUFFER */
+ int excess = 0; /* BYTES LEFT FROM PREVIOUS BUFFER */
+ unsigned int n_reloc = 0; /* COUNTER FOR RELOCATION ENTRIES */
+ RELOC reloc; /* RELOCATION ENTRY */
+ int relsz = RELSZ_IN(coff_version);
+ unsigned char *packet = NULL; /* LOAD BUFFER */
+ unsigned int section_length = (unsigned int)LOCTOBYTE(sptr->s_size);
+ unsigned int buffer_size = LOADBUFSIZE;
+
+#if defined (UNBUFFERED) && UNBUFFERED
+ /*-------------------------------------------------------------------------*/
+ /* IF UNBUFFERED, THEN SET SIZE TO SECTION LENGTH ROUNDED UP TO MULTIPLE */
+ /* 32 BYTES. WE MAINTAIN A MINIMIUM OF LOADBUFSIZE IN THE EVENT SOMEONE */
+ /* CONTINUES TO USE THAT MACRO AS A SIZE LIMIT. */
+ /*-------------------------------------------------------------------------*/
+ buffer_size = MAX(buffer_size, (section_length + 32) & ~31ul);
+#endif
+
+ /*-------------------------------------------------------------------------*/
+ /* ENSURE LOADBUFSIZE IS A MULTIPLE OF 2 */
+ /*-------------------------------------------------------------------------*/
+ if (LOADBUFSIZE % 2)
+ {
+ return -1;
+ }
+
+ /*-------------------------------------------------------------------------*/
+ /* READ THE FIRST RELOCATION ENTRY, IF THERE ARE ANY. */
+ /* IF THIS IS A BSS SECTION, CLEAR THE LOAD BUFFER. */
+ /*-------------------------------------------------------------------------*/
+#if FILE_BASED
+ if (need_reloc && sptr->s_nreloc &&
+ (fseek(fin, sptr->s_relptr, 0) != 0 || !reloc_read(&reloc)))
+ { load_err = E_FILE; return FALSE; }
+#else
+ // need_reloc is not used....
+ if (need_reloc && sptr->s_nreloc && !reloc_read(&reloc, sptr->s_relptr))
+ { load_err = E_FILE; return FALSE; }
+#endif
+ /*-------------------------------------------------------------------------*/
+ /* ALLOCATE THE PACKET BUFFER */
+ /*-------------------------------------------------------------------------*/
+ packet = (unsigned char *) malloc(buffer_size);
+ if (!packet) { load_err = E_ALLOC; return FALSE; }
+
+#ifdef OTIS
+ if (IS_BSS(sptr))
+ {
+ TRG_MVAL filval = fill_bss_value;
+
+ free (packet);
+
+ if (!mem_fill(filval, LOCTOBYTE(sptr->s_size), addr, sptr->s_page))
+ { load_err = E_MEMWRITE; return FALSE; }
+ return TRUE;
+ }
+#else
+ /*-------------------------------------------------------------------------*/
+ /* Always want to clear memory for cases where memsize is not a multiple */
+ /* of the data size being written out. If we do not clear the array, the */
+ /* last byte or so can be corrupted with data from the last buffer read. */
+ /*-------------------------------------------------------------------------*/
+ for (nbytes = 0; nbytes < buffer_size; ++nbytes) packet[nbytes] = 0;
+#endif
+
+ /*-------------------------------------------------------------------------*/
+ /* COPY ALL THE DATA IN THE SECTION. */
+ /*-------------------------------------------------------------------------*/
+
+ for (nbytes = 0; nbytes < section_length; nbytes += packet_size)
+ {
+ int j;
+
+ /*----------------------------------------------------------------------*/
+ /* READ IN A BUFFER OF DATA. IF THE PREVIOUS RELOCATION SPANNED */
+ /* ACROSS THE END OF THE LAST BUFFER, COPY THE LEFTOVER BYTES INTO */
+ /* THE BEGINNING OF THE NEW BUFFER. */
+ /*----------------------------------------------------------------------*/
+ for (j = 0; j < excess; ++j) packet[j] = packet[packet_size + j];
+
+ packet_size = (int)MIN(LOCTOBYTE(sptr->s_size) - nbytes, buffer_size);
+
+ if (sptr->s_scnptr)
+#if FILE_BASED
+ if ((fseek(fin, sptr->s_scnptr + (int)(nbytes + excess), 0) != 0) ||
+ (fread(packet + excess, packet_size - excess, 1, fin) != 1))
+ {
+ load_err = E_FILE;
+ free (packet);
+ return FALSE;
+ }
+#else
+ mem_copy((void*)(packet + excess), (void*)&gRxBuffer[sptr->s_scnptr + (int)(nbytes + excess)], packet_size - excess);
+#endif
+
+
+ excess = 0;
+
+ /*----------------------------------------------------------------------*/
+ /* Clear out end of packet in case we write padding. */
+ /*----------------------------------------------------------------------*/
+ if (excess + packet_size < buffer_size)
+ for(j = excess + packet_size; j < buffer_size; j++)
+ packet[j] = 0;
+
+ /*----------------------------------------------------------------------*/
+ /* READ AND PROCESS ALL THE RELOCATION ENTRIES THAT AFFECT DATA */
+ /* CURRENTLY IN THE BUFFER. */
+ /*----------------------------------------------------------------------*/
+ if (need_reloc)
+ while (n_reloc < sptr->s_nreloc &&
+ (T_ADDR)reloc.r_vaddr < addr + BYTETOLOC(packet_size))
+ {
+ int i = (int)LOCTOBYTE(reloc.r_vaddr - addr); /* BYTE NDX */
+ int fieldsz = reloc_size(reloc.r_type); /* IN BITS */
+ int wordsz = MAX(fieldsz, reloc_stop(reloc.r_type)); /* IN BITS */
+
+ /*----------------------------------------------------------------*/
+ /* IF THIS RELOCATION SPANS PAST THE END OF THE BUFFER, */
+ /* SET 'EXCESS' TO THE NUMBER OF REMAINING BYTES AND FLUSH THE */
+ /* BUFFER. AT THE NEXT FILL, THESE BYTES WILL BE COPIED FROM */
+ /* THE END OF THE BUFFER TO THE BEGINNING AND THEN RELOCATED. */
+ /*----------------------------------------------------------------*/
+ if (i + (wordsz >> 3) > packet_size)
+ {
+ i -= i % LOADWORDSIZE; /* DON'T BREAK WITHIN A WORD */
+ excess = packet_size - i;
+ packet_size = i;
+ break;
+ }
+
+ /*----------------------------------------------------------------*/
+ /* PERFORM THE RELOCATION AND READ IN THE NEXT RELOCATION ENTRY. */
+ /*----------------------------------------------------------------*/
+ if (!relocate(&reloc, packet + i, curr_sect))
+ { free (packet); return FALSE; }
+#if FILE_BASED
+ if (n_reloc++ < sptr->s_nreloc &&
+ (fseek(fin, sptr->s_relptr + ((int)n_reloc * relsz), 0) != 0 ||
+ !reloc_read(&reloc)))
+#else
+ if (n_reloc++ < sptr->s_nreloc && !reloc_read(&reloc, sptr->s_relptr + ((int)n_reloc * relsz)));
+#endif
+ { load_err = E_FILE; free (packet); return FALSE; }
+ }
+
+ /*----------------------------------------------------------------------*/
+ /* WRITE OUT THE RELOCATED DATA TO THE TARGET DEVICE. IF THIS IS A */
+ /* CINIT SECTION, CALL A SPECIAL FUNCTION TO HANDLE IT. */
+ /*----------------------------------------------------------------------*/
+ if (!(IS_CINIT(sptr) ?
+ cload_cinit(packet, &packet_size, &excess) :
+ (int) mem_write(packet, packet_size, addr + reloc_amount[curr_sect],
+ sptr->s_page)))
+ { load_err = E_MEMWRITE; free (packet); return FALSE; }
+
+ /*----------------------------------------------------------------------*/
+ /* KEEP TRACK OF THE ADDRESS WITHIN THE SECTION. */
+ /*----------------------------------------------------------------------*/
+ addr += BYTETOLOC(packet_size);
+
+ }
+
+ free (packet);
+ return TRUE;
+}
+
+\f
+/******************************************************************************/
+/* */
+/* CLOAD_CINIT() - Process one buffer of C initialization records. */
+/* */
+/******************************************************************************/
+int cload_cinit(unsigned char *packet, int *packet_size, int *excess)
+{
+ int i; /* BYTE COUNTER */
+ int init_packet_size; /* SIZE OF CURRENT INITIALIZATION */
+ static T_ADDR init_addr; /* ADDRESS OF CURRENT INITIALIZATION */
+ int bss_page = 0; /* BSS SECTION PAGE NUMBER */
+
+ /*-------------------------------------------------------------------------*/
+ /* FIND THE BSS SECTION ASSOCIATED WITH THE THE CINIT SECTION CURRENTLY */
+ /* BEING LOADED. */
+ /*-------------------------------------------------------------------------*/
+ for (i = 0; i < n_sections; ++i)
+ if (IS_BSS(SECT_HDR(i)))
+ { bss_page = SECT_HDR(i)->s_page; break; }
+
+ /*-------------------------------------------------------------------------*/
+ /* PROCESS ALL THE INITIALIZATION RECORDS IN THE BUFFER. */
+ /*-------------------------------------------------------------------------*/
+ for (i = 0; i < *packet_size; i += init_packet_size)
+ {
+ /*----------------------------------------------------------------------*/
+ /* IF STARTING A NEW INITIALIZATION, READ THE SIZE AND ADDRESS FROM */
+ /* THE TABLE. */
+ /*----------------------------------------------------------------------*/
+ if (init_size == 0)
+ {
+ T_SIZE temp;
+ int align;
+
+ /*-------------------------------------------------------------------*/
+ /* POSITION THE BYTE INDEX ON THE NEXT INIT RECORD. */
+ /*-------------------------------------------------------------------*/
+ if (align = (i % INIT_ALIGN)) i += (INIT_ALIGN - align);
+
+ /*-------------------------------------------------------------------*/
+ /* IF THE SIZE AND ADDRESS ARE NOT FULLY CONTAINED IN THIS BUFFER, */
+ /* STOP HERE. SET THE 'EXCESS' COUNTER TO THE NUMBER OF UNPROCESSED */
+ /* BYTES - THESE WILL BE COPIED TO THE HEAD OF THE NEXT BUFFER. */
+ /*-------------------------------------------------------------------*/
+ if ((int)(i + sizeof(T_SIZE)) > *packet_size)
+ { *excess += *packet_size - i; *packet_size = i; break; }
+
+ /*-------------------------------------------------------------------*/
+ /* IF THE NEXT SIZE FIELD IS ZERO, BREAK. */
+ /*-------------------------------------------------------------------*/
+ temp = unpack(packet + i, sizeof(T_SIZE)*8, sizeof(T_SIZE)*8, 0);
+ if (temp == 0) break;
+
+ /*-------------------------------------------------------------------*/
+ /* READ THE ADDRESS FIELD ,IF IT'S ALL HERE. */
+ /*-------------------------------------------------------------------*/
+ if ((int)(i + sizeof(T_SIZE) + sizeof(T_IADDR)) > *packet_size)
+ { *excess += *packet_size - i; *packet_size = i; break; }
+
+ i += sizeof(T_SIZE);
+ init_size = temp;
+ init_addr = unpack(packet+i,sizeof(T_IADDR)*8,sizeof(T_IADDR)*8,0);
+ i += sizeof(T_IADDR);
+ }
+
+ /*----------------------------------------------------------------------*/
+ /* WRITE OUT THE CURRENT PACKET, UP TO THE END OF THE BUFFER. */
+ /*----------------------------------------------------------------------*/
+ if (init_packet_size = MIN(*packet_size-i, (int)(init_size * INIT_WSIZE)))
+ {
+
+ if (!mem_write(packet + i, init_packet_size, init_addr, bss_page))
+ return FALSE;
+
+ init_addr += BYTETOLOC(init_packet_size);
+ init_size -= init_packet_size / INIT_WSIZE;
+ }
+ }
+ return TRUE;
+}
+
+#if 0
+/******************************************************************************/
+/* */
+/* CLOAD_SYMBOLS() - Read in the symbol table. */
+/* */
+/******************************************************************************/
+int cload_symbols()
+{
+ SYMENT sym;
+ AUXENT aux;
+ int first, next;
+
+ if (file_hdr.f_nsyms == 0 || (!need_symbols && !need_reloc)) return TRUE;
+
+ /*------------------------------------------------------------------------*/
+ /* ALLOCATE THE RELOCATION SYMBOL TABLE. */
+ /*------------------------------------------------------------------------*/
+ if (need_reloc)
+ {
+ reloc_sym_index = 0;
+ reloc_tab_size = MIN(RELOC_TAB_START, (int)file_hdr.f_nsyms);
+
+ if (!(reloc_tab = (RELOC_TAB *)malloc(reloc_tab_size*sizeof(RELOC_TAB))))
+ { load_err = E_ALLOC; return FALSE; }
+ }
+
+ /*------------------------------------------------------------------------*/
+ /* IF THE APPLICATION NEEDS THE SYMBOL TABLE, LET IT READ IT IN. */
+ /* PASS NEED_RELOC TO THE APPLICATION SO THAT IT CAN CALL RELOC_ADD(). */
+ /*------------------------------------------------------------------------*/
+ if (need_symbols)
+ {
+ if (load_syms(need_reloc)) return TRUE;
+ else { load_err = E_SYM; return FALSE; }
+ }
+
+ /*------------------------------------------------------------------------*/
+ /* READ THE SYMBOL TABLE AND BUILD THE RELOCATION SYMBOL TABLE */
+ /* FOR SYMBOLS THAT CAN BE USED IN RELCOATION, STORE THEM IN A */
+ /* SPECIAL SYMBOL TABLE THAT CAN BE SEARCHED QUICKLY DURING */
+ /* RELOCATION. */
+ /*------------------------------------------------------------------------*/
+ for (first = 0; first < file_hdr.f_nsyms; first = next)
+ {
+ if (!(next = sym_read(first, &sym, &aux)))
+ { load_err = E_FILE; return FALSE; }
+
+ if (sym.n_sclass == C_EXT || sym.n_sclass == C_EXTREF ||
+ sym.n_sclass == C_STAT || sym.n_sclass == C_LABEL ||
+ sym.n_sclass == C_SYSTEM || sym.n_sclass == C_BLOCK ||
+ sym.n_sclass == C_FCN || sym.n_sclass == C_STATLAB ||
+ sym.n_sclass == C_EXTLAB)
+ if (!reloc_add(first, &sym)) return FALSE;
+ }
+ return TRUE;
+}
+
+
+/******************************************************************************/
+/* */
+/* CLOAD_STRINGS() - Read in the string table. */
+/* */
+/******************************************************************************/
+int cload_strings()
+{
+ unsigned int str_size; /* SIZE OF STRING TABLE */
+ unsigned int bufsize; /* SIZE OF CURRENT BUFFER */
+ unsigned int ntoread; /* AMOUNT TO READ FROM FILE */
+ int excess; /* AMOUNT LEFT OVER FROM LAST BUFFER */
+ STRTAB *packet; /* STRING TABLE BUFFER PACKET */
+ unsigned int i = 0;
+
+ /*----------------------------------------------------------------------*/
+ /* Do not load if not loading/saving the symbol tables. */
+ /* This is because the string table is an extension of the symbol table */
+ /* and if you free and rebuild it, the symbol table's str_head will be */
+ /* incorrect. */
+ /*----------------------------------------------------------------------*/
+ if (!need_symbols) return TRUE;
+
+ /*------------------------------------------------------------------------*/
+ /* FREE ANY PREVIOUS STRING BUFFERS */
+ /*------------------------------------------------------------------------*/
+ str_free(str_head); str_head = NULL;
+
+ /*------------------------------------------------------------------------*/
+ /* SEEK TO THE END OF THE SYMBOL TABLE AND READ IN THE SIZE OF THE STRING */
+ /* TABLE. */
+ /*------------------------------------------------------------------------*/
+#if FILE_BASED
+ if ((file_hdr.f_nsyms == 0) ||
+ fseek(fin, file_hdr.f_symptr + (file_hdr.f_nsyms * SYMESZ), 0) != 0 ||
+ fread(&str_size, sizeof(int), 1, fin) != 1)
+ return TRUE;
+#else
+ mem_copy(&str_size, &gRxBuffer[file_hdr.f_symptr + (file_hdr.f_nsyms * SYMESZ)], sizeof(int));
+ if ((file_hdr.f_nsyms == 0))
+ return TRUE;
+#endif
+ if (byte_swapped) swap4byte(&str_size);
+
+ /*------------------------------------------------------------------------*/
+ /* THE STRING TABLE IS READ IN AS A LINKED LIST OF BUFFERS. TO */
+ /* PREVENT NAMES FROM BEING SPLIT ACROSS MULTIPLE BUFFERS, ANY PARTIAL */
+ /* NAME AT THE END OF A BUFFER IS COPIED INTO THE BEGINNING OF THE */
+ /* NEXT BUFFER. THE VARIABLE 'EXCESS' KEEPS TRACK OF HOW MUCH NEEDS */
+ /* TO BE COPIED FROM THE PREVIOUS BUFFER. */
+ /*------------------------------------------------------------------------*/
+ str_size -= 4; /* SUBTRACT OFF 4 BYTES ALREADY READ */
+ excess = 0; /* INITIALIZE LAST-BUFFER OVERFLOW */
+
+
+ /*------------------------------------------------------------------------*/
+ /* READ STRING BUFFERS UNTIL THE WHOLE STRING TABLE IS READ. */
+ /*------------------------------------------------------------------------*/
+ while (str_size)
+ {
+ /*---------------------------------------------------------------------*/
+ /* ALLOCATE A NEW BUFFER. ON 16-BIT MACHINES, RESTRICT THE */
+ /* BUFFER SIZE TO THE MAXIMUM THAT CAN BE ALLOCATED AT ONCE. */
+ /*---------------------------------------------------------------------*/
+ bufsize = str_size + excess;
+
+ if (sizeof(int) < 4 && bufsize > MAX_STRING_ALLOC)
+ bufsize = MAX_STRING_ALLOC;
+
+ if (!(packet = (struct strtab *)malloc(sizeof(STRTAB) +
+ (unsigned int)bufsize - 1)))
+ { load_err = E_ALLOC; return FALSE; }
+
+ /*---------------------------------------------------------------------*/
+ /* COPY ANY PARTIAL STRING FROM THE LAST BUFFER INTO THIS ONE. */
+ /* THEN FILL THE REST OF THE BUFFER BY READING FROM THE FILE. */
+ /*---------------------------------------------------------------------*/
+ if (excess)
+ strn_copy(packet->buf, str_head->buf + str_head->size, excess);
+
+ ntoread = (unsigned int)(bufsize - excess);
+#if FILE_BASED
+ if (fread(packet->buf + excess, ntoread, 1, fin) != 1)
+ { load_err = E_FILE; return FALSE; }
+#else
+ mem_copy(packet->buf + excess, &gRxBuffer[file_hdr.f_symptr + (file_hdr.f_nsyms * SYMESZ) +sizeof(int)+ i++*ntoread], ntoread);
+#endif
+ str_size -= ntoread;
+
+ /*---------------------------------------------------------------------*/
+ /* IF THE BUFFER ENDS IN A PARTIAL STRING (DOESN'T END IN NULL), */
+ /* KEEP TRACK OF HOW MANY CHARACTERS ARE IN THE PARTIAL STRING */
+ /* SO THEY CAN BE COPIED INTO THE NEXT BUFFER. */
+ /*---------------------------------------------------------------------*/
+ for (excess = 0; packet->buf[bufsize - 1]; --bufsize, ++excess) ;
+
+ /*---------------------------------------------------------------------*/
+ /* LINK THE NEW BUFFER INTO THE HEAD OF THE LIST. */
+ /*---------------------------------------------------------------------*/
+ packet->size =
+ packet->index = bufsize;
+ packet->next = str_head;
+ packet->offset = str_head ? (str_head->offset + str_head->size) : 4;
+ str_head = packet;
+ }
+ return TRUE;
+}
+
+\f
+/******************************************************************************/
+/* */
+/* STR_FREE() - Free the list of string table buffers. */
+/* */
+/******************************************************************************/
+void str_free(STRTAB *head)
+{
+ STRTAB *this_one, *next;
+ for (this_one = head; this_one; this_one = next)
+ {
+ next = this_one->next;
+ free(this_one);
+ }
+}
+
+
+
+/******************************************************************************/
+/* */
+/* SYM_READ() - Read and relocate a symbol and its aux entry. Return the */
+/* index of the next symbol. */
+/* */
+/******************************************************************************/
+int sym_read(int index, SYMENT *sym, AUXENT *aux)
+{
+ /*------------------------------------------------------------------------*/
+ /* READ IN A SYMBOL AND ITS AUX ENTRY. */
+ /*------------------------------------------------------------------------*/
+#if FILE_BASED
+ if (fseek(fin, file_hdr.f_symptr + (index * SYMESZ), 0) != 0 ||
+ fread(sym, SYMESZ, 1, fin) != 1 ||
+ (sym->n_numaux && fread(aux, SYMESZ, 1, fin) != 1))
+ { load_err = E_FILE; return FALSE; }
+#else
+ mem_copy((void*)sym, (void*)&gRxBuffer[file_hdr.f_symptr + (index * SYMESZ)], SYMESZ);
+ if (sym->n_numaux)
+ {
+ mem_copy((void*)aux, (void*)&gRxBuffer[file_hdr.f_symptr + ( (index+1) * SYMESZ)], SYMESZ);
+ load_err = E_FILE;
+ return FALSE;
+ }
+#endif
+ if (byte_swapped)
+ {
+ /*--------------------------------------------------------------------*/
+ /* SWAP THE SYMBOL TABLE ENTRY. */
+ /*--------------------------------------------------------------------*/
+ if (sym->n_zeroes == 0) swap4byte(&sym->n_offset);
+ swap4byte(&sym->n_value);
+ swap2byte(&sym->n_scnum);
+ swap2byte(&sym->n_type);
+
+ /*--------------------------------------------------------------------*/
+ /* SWAP THE AUX ENTRY, BASED ON THE STORAGE CLASS. */
+ /*--------------------------------------------------------------------*/
+ if (sym->n_numaux) switch(sym->n_sclass)
+ {
+ case C_FILE : break;
+
+ case C_STRTAG :
+ case C_UNTAG :
+ case C_ENTAG : swap4byte(&aux->x_tag.x_fsize);
+ swap4byte(&aux->x_tag.x_endndx);
+ break;
+
+ case C_FCN : if (!str_comp(sym->n_name, ".bf"))
+ {
+ swap2byte(&aux->x_block.x_lcnt);
+ swap4byte(&aux->x_block.x_regmask);
+ swap4byte(&aux->x_block.x_framesize);
+ }
+
+ case C_BLOCK : swap2byte(&aux->x_block.x_lnno);
+ swap4byte(&aux->x_block.x_endndx);
+ break;
+
+ case C_EOS : swap4byte(&aux->x_eos.x_fsize);
+ swap4byte(&aux->x_eos.x_tagndx);
+ break;
+
+ default : /*-------------------------------------------------*/
+ /* HANDLE FUNCTION DEFINITION SYMBOL */
+ /*-------------------------------------------------*/
+ if (((sym->n_type >> 4) & 3) == DCT_FCN)
+ {
+ swap4byte(&aux->x_func.x_tagndx);
+ swap4byte(&aux->x_func.x_fsize);
+ swap4byte(&aux->x_func.x_lnnoptr);
+ swap4byte(&aux->x_func.x_endndx);
+ }
+
+ /*-------------------------------------------------*/
+ /* HANDLE ARRAYS. */
+ /*-------------------------------------------------*/
+ else if (((sym->n_type >> 4) & 3) == DCT_ARY)
+ {
+ swap4byte(&aux->x_array.x_tagndx);
+ swap4byte(&aux->x_array.x_fsize);
+ swap2byte(&aux->x_array.x_dimen[0]);
+ swap2byte(&aux->x_array.x_dimen[1]);
+ swap2byte(&aux->x_array.x_dimen[2]);
+ swap2byte(&aux->x_array.x_dimen[3]);
+ }
+
+ /*-------------------------------------------------*/
+ /* HANDLE SECTION DEFINITIONS */
+ /*-------------------------------------------------*/
+ else if (sym->n_type == 0)
+ {
+ swap4byte(&aux->x_scn.x_scnlen);
+ swap2byte(&aux->x_scn.x_nreloc);
+ swap2byte(&aux->x_scn.x_nlinno);
+ }
+
+ /*-------------------------------------------------*/
+ /* HANDLE MISC SYMBOL RECORD */
+ /*-------------------------------------------------*/
+ else
+ {
+ swap4byte(&aux->x_sym.x_fsize);
+ swap4byte(&aux->x_sym.x_tagndx);
+ }
+ }
+ }
+
+ /*------------------------------------------------------------------------*/
+ /* RELOCATE THE SYMBOL, BASED ON ITS STORAGE CLASS. */
+ /*------------------------------------------------------------------------*/
+ switch(sym->n_sclass)
+ {
+ case C_SYSTEM :
+ case C_EXT :
+ case C_EXTREF :
+ case C_STAT :
+ case C_LABEL :
+ case C_BLOCK :
+ case C_FCN :
+ case C_STATLAB :
+ case C_EXTLAB :
+ /*------------------------------------------------------------------*/
+ /* IF THE SYMBOL IS UNDEFINED, CALL AN APPLICATION ROUTINE TO LOOK */
+ /* IT UP IN AN EXTERNAL SYMBOL TABLE. IF THE SYMBOL IS DEFINED, */
+ /* RELOCATE IT ACCORDING TO THE SECTION IT IS DEFINED IN. */
+ /*------------------------------------------------------------------*/
+ if (sym->n_scnum == 0)
+ lookup_sym((short)index, sym, aux);
+ else if (sym->n_scnum > 0)
+ {
+ if (sym->n_sclass == C_STATLAB || sym->n_sclass == C_EXTLAB)
+ sym->n_value += reloc_amount[sym->n_scnum - 1];
+ else sym->n_value += RUN_RELOC_AMOUNT(sym->n_scnum - 1);
+ }
+ }
+
+ return (index + sym->n_numaux + 1);
+}
+
+\f
+/******************************************************************************/
+/* */
+/* SYM_NAME() - Return a pointer to the name of a symbol in either the symbol */
+/* entry or the string table. */
+/* */
+/******************************************************************************/
+char *sym_name(SYMENT *symptr)
+{
+ static char temp[9];
+
+ if (symptr->n_zeroes == 0)
+ {
+ STRTAB *packet = str_head;
+
+ /*---------------------------------------------------------------------*/
+ /* Return the empty string if this symbol has no name (offset == 0) */
+ /*---------------------------------------------------------------------*/
+ if (symptr->n_offset < 4) /* Anything below 4 isn't valid */
+ {
+ temp[0] = 0;
+ return temp;
+ }
+
+ /*---------------------------------------------------------------------*/
+ /* Otherwise, return the string in the string table. */
+ /*---------------------------------------------------------------------*/
+ while (packet && symptr->n_offset < (int)packet->offset)
+ packet = packet->next;
+
+ /*---------------------------------------------------------------------*/
+ /* Return the empty string if packet NULL (invalid offset) */
+ /*---------------------------------------------------------------------*/
+ if (!packet)
+ {
+ temp[0] = 0;
+ return temp;
+ }
+
+ return packet->buf + (symptr->n_offset - packet->offset);
+ }
+
+ strn_copy(temp, symptr->n_name, 8);
+ temp[8] = 0;
+ return temp;
+}
+
+
+/******************************************************************************/
+/* */
+/* SYM_ADD_NAME() - Given a symbol table entry, return a pointer to the */
+/* symbol's name in the string table. Add the name to the */
+/* table if it's not already there. */
+/* */
+/******************************************************************************/
+char *sym_add_name(SYMENT *symptr)
+{
+ char *dest;
+ char *result;
+ int i;
+
+ /*------------------------------------------------------------------------*/
+ /* IF THE SYMBOL'S NAME WAS IN THE COFF STRING TABLE, LOOK THROUGH THE */
+ /* LIST OF STRING TABLE BUFFERS UNTIL FINDING THE ONE THE NAME IS IN, */
+ /* AND SIMPLY POINT INTO THE BUFFER. */
+ /*------------------------------------------------------------------------*/
+ if (symptr->n_zeroes == 0)
+ return sym_name(symptr);
+
+ /*------------------------------------------------------------------------*/
+ /* OTHERWISE ADD THE STRING TO THE STRING TABLE. */
+ /* ALLOCATE AND LINK IN A NEW PACKET IF NECESSARY. NEW PACKETS ARE */
+ /* LINKED TO THE HEAD OF THE LIST TO EASE ADDING NEW SYMBOLS. */
+ /*------------------------------------------------------------------------*/
+ if (!str_head || str_head->index + SYMNMLEN + 1 > str_head->size)
+ {
+ STRTAB *packet;
+
+ if (!(packet = (STRTAB *)malloc(sizeof(STRTAB) + MIN_STRING_ALLOC - 1)))
+ { load_err = E_ALLOC; return NULL; }
+
+ packet->size = MIN_STRING_ALLOC;
+ packet->index = 0;
+ packet->next = str_head;
+ packet->offset = str_head ? (str_head->offset + str_head->size) : 4;
+ str_head = packet;
+ }
+
+ /*------------------------------------------------------------------------*/
+ /* COPY THE NAME INTO THE STRING TABLE. */
+ /*------------------------------------------------------------------------*/
+ result = dest = str_head->buf + str_head->index;
+ for (i = 0; *dest++ = symptr->n_name[i++]; )
+ if (i == SYMNMLEN) { *dest++ = '\0'; ++i; break; }
+
+ symptr->n_zeroes = 0;
+ symptr->n_offset = str_head->offset + str_head->index;
+ str_head->index += i;
+ return result;
+}
+#endif
+
+/******************************************************************************/
+/* */
+/* RELOC_ADD() - Add an entry to the relocation symbol table. This table */
+/* stores relocation information for each relocatable symbol. */
+/* */
+/******************************************************************************/
+int reloc_add(int index, SYMENT *sym)
+{
+ int disp; /* RELOCATION AMOUNT FOR THIS SYMBOL */
+
+ if (!need_reloc) return TRUE;
+
+ /*-------------------------------------------------------------------------*/
+ /* USE THE SYMBOL VALUE TO CALCULATE THE RELOCATION AMOUNT: */
+ /* 1) IF THE SYMBOL WAS UNDEFINED (DEFINED IN SECTION 0), USE THE */
+ /* SYMBOL'S VALUE. */
+ /* 2) IF THE SYMBOL HAS A POSITIVE SECTION NUMBER, USE THE RELOCATION */
+ /* AMOUNT FOR THE SECTION IN WHICH THE SYMBOL IS DEFINED. */
+ /* 3) OTHERWISE, THE SYMBOL IS ABSOLUTE, SO THE RELOCATION AMOUNT IS 0. */
+ /*-------------------------------------------------------------------------*/
+ if (sym->n_scnum == 0)
+ disp = sym->n_value;
+ else if (sym->n_scnum > 0)
+ {
+ if (sym->n_sclass == C_STATLAB || sym->n_sclass == C_EXTLAB)
+ disp = reloc_amount[sym->n_scnum - 1];
+ else disp = RUN_RELOC_AMOUNT(sym->n_scnum - 1);
+ }
+ else disp = 0;
+
+ /*-------------------------------------------------------------------------*/
+ /* IF THERE IS A NON-ZERO RELOCATION AMOUNT, ADD THE SYMBOL TO THE TABLE. */
+ /*-------------------------------------------------------------------------*/
+ if (disp == 0) return TRUE;
+
+ if (reloc_sym_index >= reloc_tab_size)
+ {
+ reloc_tab_size += RELOC_GROW_SIZE;
+ reloc_tab = (RELOC_TAB *)realloc((char *)reloc_tab,
+ reloc_tab_size*sizeof(RELOC_TAB));
+
+ if (!reloc_tab) { load_err = E_ALLOC; return FALSE; }
+ }
+ reloc_tab[reloc_sym_index ].rt_index = index;
+ reloc_tab[reloc_sym_index++].rt_disp = disp;
+
+ return TRUE;
+}
+
+/******************************************************************************/
+/* */
+/* RELOCATE() - Perform a single relocation by patching the raw data. */
+/* */
+/******************************************************************************/
+int relocate(RELOC *rp, unsigned char *data, int s)
+{
+/* RELOC *rp; RELOCATION ENTRY */
+/* unsigned char *data; DATA BUFFER */
+/* int s; INDEX OF CURRENT SECTION */
+ int fieldsz = reloc_size(rp->r_type); /* SIZE OF ACTUAL PATCH VALUE */
+ int offset = reloc_offset(rp->r_type); /* OFFSET OF ACTUAL PATCH VALUE */
+ int wordsz = MAX(fieldsz, reloc_stop(rp->r_type)); /* SIZE CONTAINING FLD */
+ int objval; /* FIELD TO BE PATCHED */
+ int reloc_amt; /* AMOUNT OF RELOCATION */
+
+ int pp_shift_cnt = 0;
+ int pp_local = FALSE;
+
+ if (rp->r_type == R_ABS) return TRUE; /* NOTHING TO DO */
+
+ /*-------------------------------------------------------------------------*/
+ /* DETERMINE THE RELOCATION AMOUNT FROM THE RELOCATION SYMBOL TABLE. */
+ /*-------------------------------------------------------------------------*/
+ reloc_amt = (rp->r_symndx == -1) ? RUN_RELOC_AMOUNT(s)
+ : sym_reloc_amount(rp);
+
+ /*-------------------------------------------------------------------------*/
+ /* EXTRACT THE RELOCATABLE FIELD FROM THE OBJECT DATA. */
+ /*-------------------------------------------------------------------------*/
+ objval = unpack(data, fieldsz, wordsz, offset + BIT_OFFSET(rp->r_vaddr));
+
+ /*-------------------------------------------------------------------------*/
+ /* MODIFY THE FIELD BASED ON THE RELOCATION TYPE. */
+ /*-------------------------------------------------------------------------*/
+ switch (rp->r_type)
+ {
+ /*----------------------------------------------------------------------*/
+ /* NORMAL RELOCATIONS: ADD IN THE RELOCATION AMOUNT. */
+ /*----------------------------------------------------------------------*/
+ case R_RELBYTE:
+ case R_RELWORD:
+ case R_REL24:
+ case R_RELLONG:
+ case R_DIR32:
+ case R_PARTLS16:
+ objval += reloc_amt;
+ break;
+
+ /*--------------------------------------------------------------------*/
+ /* ADD IN THE RELOCATION AMOUNT, BUT MAKE SURE WE'RE STILL IN THE */
+ /* 370'S REGISTER FILE. */
+ /*--------------------------------------------------------------------*/
+ case R_RRNREG:
+ case R_RRRELREG:
+ if (rp->r_type == R_RRNREG)
+ objval = ((char)objval + reloc_amt);
+ else objval += reloc_amt;
+
+ if (objval & ((-1L >> 8*fieldsz) << 8*fieldsz))
+ {
+ /* ERROR */
+ }
+
+ break;
+
+ /*--------------------------------------------------------------------*/
+ /* PP UNSCALED 15-BIT OFFSET RELOCATION. */
+ /*--------------------------------------------------------------------*/
+ case R_PP15 :
+ case R_PPL15 :
+ case R_PPN15 :
+ case R_PPLN15 :
+ {
+ int bit;
+ char *sname = (SECT_HDR(s)->s_zeroes == 0L) ?
+ SECT_HDR(s)->s_nptr : SNAMECPY(SECT_HDR(s)->s_name);
+
+ pp_local = (rp->r_type == R_PPL15) || (rp->r_type == R_PPLN15);
+
+ /*--------------------------------------------------------------*/
+ /* IF NEGATIVE RELOC TYPE, THEN TREAT CONST OFFSET AS A NEGATIVE*/
+ /*--------------------------------------------------------------*/
+ if (rp->r_type == R_PPN15 || rp->r_type == R_PPLN15)
+ {
+ objval = -objval;
+ rp->r_type -= 010; /* CHANGE TYPE TO NON NEG. */
+ }
+
+ objval += reloc_amt;
+
+ /*--------------------------------------------------------------*/
+ /* IF THE ADDRESS STILL FALLS WITHIN AN APPROPRIATE RANGE */
+ /*--------------------------------------------------------------*/
+ if ((objval >= 0x00000000 && objval <= 0x00007fff) ||
+ (objval >= 0x01000000 && objval <= 0x010007ff) )
+ break;
+
+ /*--------------------------------------------------------------*/
+ /* IF THE ADDRESS FALLS OUTSIDE AN APPROPRIATE RANGE, BUT CAN */
+ /* BE SCALED BY SIZE TO GET BACK INTO RANGE, THEN READ THE UPPER*/
+ /* BIT OF THE SIZE FIELD. IF IT IS A 1, THEN WE CAN SCALE THIS */
+ /* OFFSET BY 4, IF IT IS 0, THEN WE CAN SCALE THIS OFFSET BY 2. */
+ /*--------------------------------------------------------------*/
+ bit = unpack(data, 1, 64, pp_local ? 30 : 8);
+
+ /*--------------------------------------------------------------*/
+ /* DETERMINE IF THE OFFSET IS ALIGNED FOR SCALING. IF SO, */
+ /* THEN PACK THE SCALED OFFSET INTO INSTRUCTION, CHANGE THE */
+ /* RELOC TYPE TO SCALED, AND TURN ON SCALE BIT IN INSTRUCT. */
+ /*--------------------------------------------------------------*/
+ if (!(objval & ((2<<bit)-1)) &&
+ (objval >>= (bit+1)) >= 0 && objval <= 0x7fff)
+ {
+ rp->r_type = pp_local ? (bit ? R_PPL15W : R_PPL15H) :
+ (bit ? R_PP15W : R_PP15H);
+ repack(1, data, 1, 64, pp_local ? 28 : 6);
+ break;
+ }
+
+ /*--------------------------------------------------------------*/
+ /* ERROR, THE OFFSET WILL NOT FIT SCALED OR UNSCALED. */
+ /*--------------------------------------------------------------*/
+
+ load_err = E_RELOCENT;
+ return FALSE;
+ }
+
+ /*--------------------------------------------------------------------*/
+ /* PP SCALED 15-BIT OFFSET RELOCATION. FOR R_PP15W THE RELOC_AMT IS */
+ /* DIVIDED BY 4. FOR R_PP15H THE RELOC_AMT IS DIVIDED BY 2. */
+ /*--------------------------------------------------------------------*/
+ case R_PP15W :
+ case R_PPL15W :
+ case R_PPN15W :
+ case R_PPLN15W : pp_shift_cnt++; /* FALL THROUGH */
+
+ case R_PP15H :
+ case R_PPL15H :
+ case R_PPN15H :
+ case R_PPLN15H : pp_shift_cnt++; /* FALL THROUGH */
+ {
+ int obj_addr_x;
+ char *sname = (SECT_HDR(s)->s_zeroes == 0) ?
+ SECT_HDR(s)->s_nptr : SNAMECPY(SECT_HDR(s)->s_name);
+
+ /*--------------------------------------------------------------*/
+ /* NOTE THAT THIS IS DEPENDENT ON THE NUMBERING OF THESE RELOC */
+ /* VALUES. */
+ /*--------------------------------------------------------------*/
+ pp_local = (rp->r_type & 4);
+
+ /*--------------------------------------------------------------*/
+ /* IF NEGATIVE RELOC TYPE, THEN TREAT CONST OFFSET AS NEGATIVE */
+ /*--------------------------------------------------------------*/
+ if (rp->r_type >= R_PPN15)
+ {
+ objval = -objval;
+ rp->r_type -= 010; /* CHANGE TYPE TO NON NEG. */
+ }
+
+ obj_addr_x = (objval << pp_shift_cnt) + reloc_amt;
+
+ /*--------------------------------------------------------------*/
+ /* LINK TIME ADDRESS VIOLATES THE SCALING FACTOR WE ARE USING */
+ /* FOR THIS OPERAND. UNSCALE THE VALUE IF IT WILL FIT IN 15 BITS*/
+ /* BY CHANGING RELOC TYPE TO UNSCALED, AND CHANGING SCALE BIT */
+ /* IN THE INSTRUCTION. */
+ /*--------------------------------------------------------------*/
+ if (pp_shift_cnt && (reloc_amt & ((1<<pp_shift_cnt)-1)))
+ {
+ objval = obj_addr_x;
+ rp->r_type = (pp_local ? R_PPL15 : R_PP15);
+ repack(0, data, 1, 64, pp_local ? 28 : 6);
+ }
+ else objval = obj_addr_x >> pp_shift_cnt;
+
+ /*--------------------------------------------------------------*/
+ /* IF THE ADDRESS STILL FALLS WITHIN AN APPROPRIATE RANGE */
+ /*--------------------------------------------------------------*/
+ if ((objval >= 0x00000000 && objval <= 0x00007fff) ||
+ (obj_addr_x >= 0x01000000 && obj_addr_x <= 0x010007ff) )
+ break;
+
+ /*--------------------------------------------------------------*/
+ /* ERROR, THE OFFSET WILL NOT FIT SCALED OR UNSCALED. */
+ /*--------------------------------------------------------------*/
+
+ load_err = E_RELOCENT;
+ return FALSE;
+ }
+
+ /*--------------------------------------------------------------------*/
+ /* PP 16-bit byte offset relocation. For R_PP16B the lower 15-bits */
+ /* are handled just like R_PP15, and the upper bit is placed in the */
+ /* scale indicator bit of the field. */
+ /*--------------------------------------------------------------------*/
+ case R_PP16B :
+ case R_PPL16B :
+ case R_PPN16B :
+ case R_PPLN16B :
+ {
+ char *sname = (SECT_HDR(s)->s_zeroes == 0) ?
+ SECT_HDR(s)->s_nptr : SNAMECPY(SECT_HDR(s)->s_name);
+
+ pp_local = (rp->r_type == R_PPL16B) || (rp->r_type == R_PPLN16B);
+
+ /*--------------------------------------------------------------*/
+ /* READ THE SCALE BIT (16th BIT) AND CREATE 16 BIT CONSTANT OFF */
+ /*--------------------------------------------------------------*/
+ objval |= (unpack(data, 1, 64, pp_local ? 28 : 6) << 15);
+
+ /*--------------------------------------------------------------*/
+ /* IF NEGATIVE RELOC TYPE, THEN TREAT CONST OFFSET AS NEGATIVE */
+ /*--------------------------------------------------------------*/
+ if (rp->r_type == R_PPN16B || rp->r_type == R_PPLN16B)
+ {
+ objval = - objval;
+ rp->r_type -= 010; /* CHANGE THE TYPE TO A NON NEG TYPE. */
+ }
+
+ objval += reloc_amt;
+
+ /*--------------------------------------------------------------*/
+ /* IF THE ADDRESS STILL FALLS WITHIN AN APPROPRIATE RANGE */
+ /*--------------------------------------------------------------*/
+ if ((objval >= 0x00000000 && objval <= 0x0000ffff) ||
+ (objval >= 0x01000000 && objval <= 0x010007ff) )
+ {
+ /*-----------------------------------------------------------*/
+ /* RELOCATE THE 16TH BIT OF THE ADDRESS. */
+ /*-----------------------------------------------------------*/
+ repack(((objval&0x8000) >> 15), data, 1, 64, pp_local ? 28 : 6);
+ break;
+ }
+
+ /*--------------------------------------------------------------*/
+ /* ADDRESS IS OUT OF RANGE. */
+ /*--------------------------------------------------------------*/
+
+ load_err = E_RELOCENT;
+ return FALSE;
+ }
+
+ /*--------------------------------------------------------------------*/
+ /* PP BASE ADDRESS RELOCATION. BIT 0 IS 0 IF IN DATA RAM, 1 IF IN */
+ /* PARAMETER RAM. THIS CODE ASSUMES THAT WE DO NOT RELOCATE FROM */
+ /* PRAM TO DRAM OR FROM DRAM TO PRAM AT LOAD TIME. */
+ /*--------------------------------------------------------------------*/
+ case R_PPLBASE: pp_local = TRUE;
+ case R_PPBASE:
+ {
+ /*---------------------------------------------------------------*/
+ /* IF WAS DRAM AND RELOC_AMT IS GREAT ENOUGH TO MOVE INTO PRAM, */
+ /* CHANGE TO PRAM */
+ /*---------------------------------------------------------------*/
+ if (!objval && reloc_amt > (int)(0x01000000 - 0xC000)) objval = 1;
+
+ /*---------------------------------------------------------------*/
+ /* IF WAS PRAM AND RELOC_AMT IS NEGATIVE AND CAN MOVE INTO DRAM, */
+ /* CHANGE TO DRAM */
+ /*---------------------------------------------------------------*/
+ else if (objval && (-reloc_amt) > (int)(0x01000000 - 0xC000))
+ objval = 0;
+
+ break;
+ }
+
+ /*----------------------------------------------------------------------*/
+ /* 34010 ONE'S COMPLEMENT RELOCATION. SUBTRACT INSTEAD OF ADD. */
+ /*----------------------------------------------------------------------*/
+ case R_OCRLONG:
+ objval -= reloc_amt;
+ break;
+
+ /*----------------------------------------------------------------------*/
+ /* 34020 WORD-SWAPPED RELOCATION. SWAP BEFORE RELOCATING. */
+ /*----------------------------------------------------------------------*/
+ case R_GSPOPR32:
+ case R_OCBD32:
+ objval = ((objval >> 16) & 0xFFFF) | (objval << 16);
+ objval += (rp->r_type == R_GSPOPR32) ? reloc_amt : -reloc_amt;
+ objval = ((objval >> 16) & 0xFFFF) | (objval << 16);
+ break;
+
+ /*----------------------------------------------------------------------*/
+ /* PC-RELATIVE RELOCATIONS. IN THIS CASE THE RELOCATION AMOUNT */
+ /* IS ADJUSTED BY THE PC DIFFERENCE. IF THIS IS AN INTERNAL */
+ /* RELOCATION TO THE CURRENT SECTION, NO ADJUSTMENT IS NEEDED. */
+ /*----------------------------------------------------------------------*/
+ case R_PCRBYTE:
+ case R_PCRWORD:
+ case R_GSPPCR16:
+ case R_GSPPCA16:
+ case R_PCRLONG:
+ case R_PCR24:
+ case R_ANKPCR16:
+ case R_ANKPCR8:
+ {
+ int shift = 8 * (4 - fieldsz);
+ unsigned int pcdif = RUN_RELOC_AMOUNT(s);
+
+ /*----------------------------------------------------------------*/
+ /* HANDLE SPECIAL CASES OF JUMPING FROM ABSOLUTE SECTIONS (SPECIAL*/
+ /* RELOC TYPE) OR TO ABSOLUTE DESTINATION (SYMNDX == -1). IN */
+ /* EITHER CASE, SET THE APPROPRIATE RELOCATION AMOUNT TO 0. */
+ /*----------------------------------------------------------------*/
+ if( rp->r_symndx == -1 ) reloc_amt = 0;
+ if( rp->r_type == R_GSPPCA16) pcdif = 0;
+
+ /*----------------------------------------------------------------*/
+ /* Handle ankoor's offset where upper 14 (PCR8) and upper 6(PCR16)*/
+ /* bits of 22 bit address is held in r_disp field of reloc entry */
+ /*----------------------------------------------------------------*/
+ if(rp->r_type == R_ANKPCR8 || rp->r_type == R_ANKPCR16)
+ {
+ shift = 10;
+ objval |= rp->r_disp << ((rp->r_type == R_ANKPCR8) ? 8 : 16);
+ }
+
+ reloc_amt -= pcdif;
+
+ if (rp->r_type == R_GSPPCR16 || rp->r_type == R_GSPPCA16)
+ reloc_amt >>= 4; /* BITS TO WORDS */
+
+ objval = (int)(objval << shift) >> shift; /* SIGN EXTEND */
+ objval += reloc_amt;
+ break;
+ }
+
+ /*--------------------------------------------------------------------*/
+ /* Ankoor page-addressing. Calculate address from the 22-bit */
+ /* value in the relocation field plus the relocation amount. Shift */
+ /* out the lower 16 bits. */
+ /*--------------------------------------------------------------------*/
+ case R_PARTMS6:
+ objval = (objval & 0xC0) |
+ (((rp->r_disp += reloc_amt) >> 16) & 0x3F);
+ break;
+
+ /*----------------------------------------------------------------------*/
+ /* 320C30 PAGE-ADDRESSING RELOCATION. CALCULATE THE ADDRESS FROM */
+ /* THE 8-BIT PAGE VALUE IN THE FIELD, THE 16-BIT OFFSET IN THE RELOC */
+ /* ENTRY, AND THE RELOCATION AMOUNT. THEN, STORE THE 8-BIT PAGE */
+ /* VALUE OF THE RESULT BACK IN THE FIELD. */
+ /*----------------------------------------------------------------------*/
+ case R_PARTMS8:
+ objval = (int)((objval << 16) + rp->r_disp + reloc_amt) >> 16;
+ break;
+
+ /*----------------------------------------------------------------------*/
+ /* DSP(320) PAGE-ADDRESSING. CALCULATE ADDRESS FROM THE 16-BIT */
+ /* VALUE IN THE RELOCATION FIELD PLUS THE RELOCATION AMOUNT. OR THE */
+ /* TOP 9 BITS OF THIS RESULT INTO THE RELOCATION FIELD. */
+ /*----------------------------------------------------------------------*/
+ case R_PARTMS9:
+ objval = (objval & 0xFE00) |
+ (((int)(rp->r_disp + reloc_amt) >> 7) & 0x1FF);
+ break;
+
+ /*----------------------------------------------------------------------*/
+ /* DSP(320) PAGE-ADDRESSING. CALCULATE ADDRESS AS ABOVE, AND OR THE */
+ /* 7-BIT DISPLACEMENT INTO THE FIELD. */
+ /*----------------------------------------------------------------------*/
+ case R_PARTLS7:
+ objval = (objval & 0x80) | ((rp->r_disp + reloc_amt) & 0x7F);
+ break;
+
+ /*--------------------------------------------------------------------*/
+ /* Ankoor page-addressing. Calculate address from the 22-bit */
+ /* value in the relocation field plus the relocation amount. Mask off */
+ /* bits [21:16] and [5:0] to extract a data page within a 64K page */
+ /*--------------------------------------------------------------------*/
+ case R_PARTMID10:
+ objval = (objval & 0xFC00) |
+ (((rp->r_disp += reloc_amt) >> 6) & 0x3FF);
+ break;
+
+ /*--------------------------------------------------------------------*/
+ /* RR(370) MSB RELOCATION. CALCULATE ADDRESS FROM THE 16-BIT VALUE */
+ /* IN THE RELOCATION ENTRY PLUS THE RELOCATION AMOUNT. PATCH THE */
+ /* MSB OF THE RESULT INTO THE RELOCATION FIELD. */
+ /*--------------------------------------------------------------------*/
+ case R_HIWORD:
+ objval += (rp->r_disp += (unsigned short)reloc_amt) >> 8;
+ break;
+
+ /*--------------------------------------------------------------------*/
+ /* C8+ High byte of 24-bit address. Calculate address from 24-bit */
+ /* value in the relocation entry plus the relocation amount. Patch */
+ /* the MSB of the result into the relocation field. */
+ /*--------------------------------------------------------------------*/
+ case R_C8PHIBYTE:
+ objval = (int)((objval << 16) + rp->r_disp + reloc_amt) >> 16;
+ break;
+
+ /*--------------------------------------------------------------------*/
+ /* C8+ Middle byte of 24-bit address. Calculate address from 24-bit */
+ /* value in the relocation entry plus the relocation amount. Patch */
+ /* the middle byte of the result into the relocation field. */
+ /*--------------------------------------------------------------------*/
+ case R_C8PMIDBYTE:
+ objval = (int)((objval << 16) + rp->r_disp + reloc_amt) >> 8;
+ break;
+
+ /*--------------------------------------------------------------------*/
+ /* C8+ Vector Address. Calculate address from 24-bit value in the */
+ /* relocation entry plus the relocation amount. MSB must be 0xFF */
+ /* since interrupt and trap handlers must be programmed in the top- */
+ /* most segment of memory. Patch bottom 16-bits of the result into */
+ /* the relocation field. */
+ /*--------------------------------------------------------------------*/
+ case R_C8PVECADR:
+ objval += reloc_amt;
+ if ((objval & 0xFF0000) != 0xFF0000)
+ {
+ /* ERROR */
+ }
+ objval &= 0xFFFF;
+ break;
+
+ /*----------------------------------------------------------------------*/
+ /* C8+ 24-bit Address. The byte ordering for 24-bit addresses on the */
+ /* C8+ is reversed (low, middle, high). Needs to be unordered, add */
+ /* in reloc_amt, then re-ordered. */
+ /*----------------------------------------------------------------------*/
+ case R_C8PADR24:
+ objval = ((objval>>16) | (objval&0xff00) | ((objval&0xff)<<16));
+ objval += reloc_amt;
+ objval = ((objval>>16) | (objval&0xff00) | ((objval&0xff)<<16));
+ break;
+
+ /*----------------------------------------------------------------------*/
+ /* DSP(320) 13-BIT CONSTANT. RELOCATE ONLY THE LOWER 13 BITS OF THE */
+ /* FIELD. */
+ /*----------------------------------------------------------------------*/
+ case R_REL13:
+ objval = (objval & 0xE000) | ((objval + reloc_amt) & 0x1FFF);
+ break;
+
+ /*--------------------------------------------------------------------*/
+ /* ANKOOR 22-bit extended address. Calculate address by masking */
+ /* off the opcode and OR in the lower 16-bit constant + the */
+ /* amount. */
+ /*--------------------------------------------------------------------*/
+ case R_REL22:
+ {
+ unsigned int obj_hi = unpack(data , 16, 16, 0);
+ unsigned int obj_lo = unpack(data+2, 16, 16, 0);
+
+ /*--------------------------------------------------------------*/
+ /* BUILD THE OFFSET TO BE RELOCATED. */
+ /*--------------------------------------------------------------*/
+ objval = ((obj_hi & 0x003F) << 16) | (obj_lo & 0xFFFF);
+
+ /*--------------------------------------------------------------*/
+ /* Calculate displacement */
+ /*--------------------------------------------------------------*/
+ objval += reloc_amt;
+
+ /*--------------------------------------------------------------*/
+ /* REPACK THE RELOCATED VALUE BACK IN THE OBJECT VALUE. */
+ /*--------------------------------------------------------------*/
+ obj_hi = (obj_hi & 0xFFC0) | ((objval & 0x3F0000) >> 16);
+ obj_lo = objval & 0xFFFF;
+ repack(obj_hi, data , 16, 16, 0);
+ repack(obj_lo, data+2, 16, 16, 0);
+
+ return TRUE;
+ }
+
+ /*--------------------------------------------------------------------*/
+ /* DSP, LEAD 23-bit extended address. Calculate address by masking */
+ /* off the opcode and OR in the lower 16-bit constant + the */
+ /* amount. */
+ /*--------------------------------------------------------------------*/
+ case R_REL23:
+ {
+ unsigned int obj_hi = unpack(data , 16, 16, 0);
+ unsigned int obj_lo = unpack(data+2, 16, 16, 0);
+
+ /*--------------------------------------------------------------*/
+ /* BUILD THE OFFSET TO BE RELOCATED. */
+ /*--------------------------------------------------------------*/
+ objval = ((obj_hi & 0x007F) << 16) | (obj_lo & 0xFFFF);
+
+ /*--------------------------------------------------------------*/
+ /* Calculate displacement */
+ /*--------------------------------------------------------------*/
+ objval += reloc_amt;
+
+ /*--------------------------------------------------------------*/
+ /* REPACK THE RELOCATED VALUE BACK IN THE OBJECT VALUE. */
+ /*--------------------------------------------------------------*/
+ obj_hi = (obj_hi & 0xFF80) | ((objval & 0x7F0000) >> 16);
+ obj_lo = objval & 0xFFFF;
+ repack(obj_hi, data , 16, 16, 0);
+ repack(obj_lo, data+2, 16, 16, 0);
+
+ return TRUE;
+ }
+
+
+ /*----------------------------------------------------------------------*/
+ /* PRISM (370/16) code label relocation. Convert word address to byte */
+ /* address, add in relocation, convert back to word address. */
+ /*----------------------------------------------------------------------*/
+ case R_LABCOD:
+ objval = ((objval << 1) + reloc_amt) >> 1;
+ break;
+ }
+
+ /*-------------------------------------------------------------------------*/
+ /* PACK THE RELOCATED FIELD BACK INTO THE OBJECT DATA. */
+ /*-------------------------------------------------------------------------*/
+ repack(objval, data, fieldsz, wordsz, offset + BIT_OFFSET(rp->r_vaddr));
+ return TRUE;
+}
+
+
+/******************************************************************************/
+/* */
+/* RELOC_READ() - Read a single relocation entry. */
+/* */
+/******************************************************************************/
+#if FILE_BASED
+int reloc_read(RELOC *rptr)
+#else
+int reloc_read(RELOC *rptr, unsigned int offset)
+#endif
+{
+#if COFF_VERSION_1 || COFF_VERSION_2
+ /*------------------------------------------------------------------------*/
+ /* THE FOLLOWING UNION IS USED TO READ IN VERSION 0 OR 1 RELOC ENTRIES */
+ /*------------------------------------------------------------------------*/
+ /* THE FORMAT OF RELOCATION ENTRIES CHANGED BETWEEN COFF VERSIONS 0 AND 1.*/
+ /* VERSION 0 HAS A 16 BIT SYMBOL INDEX, WHILE VERSION 1 HAS A 32 BIT INDX.*/
+ /*------------------------------------------------------------------------*/
+ union { RELOC new_c; RELOC_OLD old; } input_entry;
+#if FILE_BASED
+ if (fread(&input_entry, RELSZ_IN(coff_version), 1, fin) != 1)
+ { load_err = E_FILE; return FALSE; }
+#else
+ mem_copy((void*)&input_entry, (void*)&gRxBuffer[offset], RELSZ_IN(coff_version));
+#endif
+ /*------------------------------------------------------------------------*/
+ /* IF LOADING A VERSION 0 FILE, TRANSLATE ENTRY TO VERSION 1 FORMAT. */
+ /* (THIS COULD BE SIMPLER - ALL THE SWAPS EXCEPT FOR THE SYMBOL INDEX */
+ /* COULD BE DONE AFTER THE TRANSLATION - BUT THIS SEEMS TO BE CLEARER) */
+ /*------------------------------------------------------------------------*/
+ if (ISCOFF_0(coff_version))
+ {
+ if (byte_swapped)
+ {
+ swap4byte(&input_entry.old.r_vaddr);
+ swap2byte(&input_entry.old.r_type);
+
+ /* if a field reloc, fields are chars, so don't swap */
+ if (!isfldrel(input_entry.old.r_type))
+ {
+ swap2byte(&input_entry.old.r_symndx);
+ swap2byte(&input_entry.old.r_disp);
+ }
+ }
+
+ rptr->r_vaddr = input_entry.old.r_vaddr;
+ rptr->r_symndx = input_entry.old.r_symndx;
+ rptr->r_disp = input_entry.old.r_disp;
+ rptr->r_type = input_entry.old.r_type;
+ }
+ else
+ {
+ *rptr = input_entry.new_c;
+
+ if (byte_swapped)
+ {
+ swap4byte(&rptr->r_vaddr);
+ swap2byte(&rptr->r_type);
+
+ /* Again, if a field reloc, fields are chars, so don't swap */
+ if (!isfldrel(rptr->r_type))
+ {
+ swap4byte(&rptr->r_symndx);
+ swap2byte(&rptr->r_disp);
+ }
+ }
+ }
+
+#else
+ /*-------------------------------------------------------------------------*/
+ /* READ IN AND BYTE SWAP AN VERSION 0 RELOC ENTRY */
+ /*-------------------------------------------------------------------------*/
+ if (fread(rptr, RELSZ, 1, fin) != 1) { load_err = E_FILE; return FALSE; }
+
+ if (byte_swapped)
+ {
+ swap4byte(&rptr->r_vaddr);
+ swap2byte(&rptr->r_type);
+
+ /* If a field reloc, fields are chars, so don't swap */
+ if (!isfldrel(rptr->r_type))
+ {
+ swap2byte(&rptr->r_symndx);
+ swap2byte(&rptr->r_disp);
+ }
+ }
+#endif
+
+ return TRUE;
+}
+
+
+/*************************************************************************/
+/* */
+/* RELOC_SIZE()- */
+/* Return the field size of a relocation type. */
+/* */
+/*************************************************************************/
+
+int reloc_size(int type)
+{
+ switch (type)
+ {
+ case R_PPBASE:
+ case R_PPLBASE: return 1;
+
+ case R_HIWORD:
+ case R_C8PHIBYTE:
+ case R_C8PMIDBYTE:
+ case R_RELBYTE:
+ case R_PCRBYTE:
+ case R_RRNREG:
+ case R_RRRELREG:
+ case R_ANKPCR8:
+ case R_PARTLS6:
+ case R_PARTMS6:
+ case R_PARTLS7: return 8;
+
+ case R_PP15:
+ case R_PP15W:
+ case R_PP15H:
+ case R_PP16B:
+ case R_PPN15:
+ case R_PPN15W:
+ case R_PPN15H:
+ case R_PPN16B:
+ case R_PPL15:
+ case R_PPL15W:
+ case R_PPL15H:
+ case R_PPL16B:
+ case R_PPLN15:
+ case R_PPLN15W:
+ case R_PPLN15H:
+ case R_PPLN16B: return 15;
+
+ case R_LABCOD:
+ case R_RELWORD:
+ case R_PCRWORD:
+ case R_ANKPCR16:
+ case R_GSPPCR16:
+ case R_GSPPCA16:
+ case R_PARTLS16:
+ case R_PARTMS8:
+ case R_PARTMS9:
+ case R_PARTMID10:
+ case R_PARTMS16:
+ case R_REL22:
+ case R_REL13:
+ case R_C8PVECADR: return 16;
+
+ case R_REL24:
+ case R_PCR24:
+ case R_PCR24W:
+ case R_C8PADR24: return 24;
+
+ case R_MPPCR:
+ case R_GSPOPR32:
+ case R_RELLONG:
+ case R_PCRLONG:
+ case R_OCBD32:
+ case R_OCRLONG:
+ case R_DIR32: return 32;
+
+ default: return 0;
+ }
+}
+
+
+/*************************************************************************/
+/* */
+/* RELOC_OFFSET()- */
+/* Return the offset of a relocation type field. The value of */
+/* offset should be the bit offset of the LSB of the field in */
+/* little-endian mode. */
+/* */
+/*************************************************************************/
+
+int reloc_offset(int type)
+{
+ switch (type)
+ {
+ case R_PP15 :
+ case R_PP15W :
+ case R_PP15H :
+ case R_PP16B :
+ case R_PPN15 :
+ case R_PPN15W :
+ case R_PPN15H :
+ case R_PPN16B :
+ case R_PPLBASE : return 22;
+
+ case R_PPL15 :
+ case R_PPL15W :
+ case R_PPL15H :
+ case R_PPL16B :
+ case R_PPLN15 :
+ case R_PPLN15W :
+ case R_PPLN15H :
+ case R_PPLN16B :
+ case R_PPBASE : return 0;
+
+ default : return 0;
+ }
+}
+
+
+/*************************************************************************/
+/* */
+/* RELOC_STOP() - */
+/* Return the number of bits to read for a relocation type. */
+/* */
+/*************************************************************************/
+
+int reloc_stop(int type)
+{
+ switch (type)
+ {
+ case R_PPBASE :
+ case R_PPLBASE :
+
+ case R_PP15 :
+ case R_PP15W :
+ case R_PP15H :
+ case R_PP16B :
+
+ case R_PPL15 :
+ case R_PPL15W :
+ case R_PPL15H :
+ case R_PPL16B :
+
+ case R_PPN15 :
+ case R_PPN15W :
+ case R_PPN15H :
+ case R_PPN16B :
+
+ case R_PPLN15 :
+ case R_PPLN15W :
+ case R_PPLN15H :
+ case R_PPLN16B : return 64;
+
+ default : return WORDSZ * 8;
+ }
+}
+
+
+/******************************************************************************/
+/* */
+/* SYM_RELOC_AMOUNT() - Determine the amount of relocation for a particular */
+/* relocation entry. Search the relocation symbol table */
+/* for the referenced symbol, and return the amount from */
+/* the table. */
+/* */
+/******************************************************************************/
+int sym_reloc_amount(RELOC *rp)
+{
+ int index = rp->r_symndx;
+
+ int i = 0,
+ j = reloc_sym_index - 1;
+
+ /*-------------------------------------------------------------------------*/
+ /* THIS IS A SIMPLE BINARY SEARCH (THE RELOC TABLE IS ALWAYS SORTED). */
+ /*-------------------------------------------------------------------------*/
+ while (i <= j)
+ {
+ int m = (i + j) / 2;
+ if (reloc_tab[m].rt_index < index) i = m + 1;
+ else if (reloc_tab[m].rt_index > index) j = m - 1;
+ else return reloc_tab[m].rt_disp; /* FOUND */
+ }
+
+ /*-------------------------------------------------------------------------*/
+ /* IF NOT FOUND, SYMBOL WAS NOT RELOCATED. */
+ /*-------------------------------------------------------------------------*/
+ return 0;
+}
+
+
+/******************************************************************************/
+/* */
+/* UNPACK() - Extract a relocation field from object bytes and convert into */
+/* a int so it can be relocated. */
+/* */
+/******************************************************************************/
+unsigned int unpack(unsigned char *data, int fieldsz, int wordsz, int bit_offset)
+{
+ register int i;
+ unsigned int objval;
+ int start; /* MS byte with reloc data */
+ int stop; /* LS byte with reloc data */
+ int r = bit_offset & 7; /* num unused LS bits in stop */
+ int l = 8 - r; /* num used MS bits in stop */
+ int tr = ((bit_offset+fieldsz-1) & 7)+1; /* # LS bits in strt*/
+ int tl = 8 - tr; /* num unused MS bits in start */
+
+ start = (big_e_target ? (wordsz-fieldsz-bit_offset) :
+ (bit_offset+fieldsz-1)) >>3;
+ stop = (big_e_target ? (wordsz-bit_offset-1) : bit_offset) >>3;
+
+ if (start == stop) return (data[stop] >> r) & ((0x1 << fieldsz) - 0x1);
+
+ objval = (unsigned)((data[start] << tl) & 0xFF) >> tl;
+
+ if (big_e_target)
+ for (i=start+1; i<stop; ++i) objval = (objval << 8) | data[i];
+ else for (i=start-1; i>stop; --i) objval = (objval << 8) | data[i];
+
+ return (objval << l) | (data[stop] >> r);
+}
+
+
+
+/******************************************************************************/
+/* */
+/* REPACK() - Encode a binary relocated field back into the object data. */
+/* */
+/******************************************************************************/
+void repack(unsigned int objval, unsigned char *data, int fieldsz,
+ int wordsz, int bit_offset)
+{
+ register int i;
+ int start; /* MS byte with reloc data */
+ int stop; /* LS byte with reloc data */
+ int r = bit_offset & 7; /* num unused LS bits in stop */
+ int l = 8 - r; /* num used MS bits in stop */
+ int tr = ((bit_offset+fieldsz-1) & 7)+1; /* # LS bits in strt */
+ unsigned int mask = (1ul << fieldsz) - 1ul;
+
+ if (fieldsz < sizeof(objval)) objval &= mask;
+
+ start = (big_e_target ? (wordsz-fieldsz-bit_offset) :
+ (bit_offset+fieldsz-1)) >>3;
+ stop = (big_e_target ? (wordsz-bit_offset-1) : bit_offset) >>3;
+
+ if (start == stop)
+ {
+ data[stop] &= ~(mask << r);
+ data[stop] |= (objval << r);
+ return;
+ }
+
+ data[start] &= ~((1<<tr)-1);
+ data[stop] &= ((1<< r)-1);
+ data[stop] |= (objval << r);
+ objval >>= l;
+
+ if (big_e_target)
+ for (i = stop - 1; i > start; objval >>= 8) data[i--] = objval;
+ else for (i = stop + 1; i < start; objval >>= 8) data[i++] = objval;
+
+ data[start] |= objval;
+}
+
+
+/******************************************************************************/
+/* */
+/* CLOAD_LINENO() - Read in, swap, and relocate line number entries. This */
+/* function is not called directly by the loader, but by the */
+/* application when it needs to read in line number entries. */
+/* */
+/******************************************************************************/
+int cload_lineno(int filptr, int count, LINENO *lptr, int scnum)
+{
+/* int filptr; WHERE TO READ FROM */
+/* int count; HOW MANY TO READ */
+/* LINENO *lptr; WHERE TO PUT THEM */
+/* int scnum; SECTION NUMBER OF THESE ENTRIES */
+
+ int i;
+
+ /*------------------------------------------------------------------------*/
+ /* READ IN THE REQUESTED NUMBER OF LINE NUMBER ENTRIES AS A BLOCK. */
+ /*------------------------------------------------------------------------*/
+#if FILE_BASED
+ if (fseek(fin, filptr, 0) != 0) { load_err = E_FILE; return FALSE; }
+ for (i = 0; i < count; i++)
+ if (fread(lptr + i, 1, LINESZ, fin) != LINESZ)
+ { load_err = E_FILE; return FALSE; }
+#else
+ for (i = 0; i < count; i++)
+ mem_copy((void*)(lptr+i), (void*)&gRxBuffer[filptr + i*LINESZ], LINESZ);
+#endif
+ /*------------------------------------------------------------------------*/
+ /* SWAP AND RELOCATE EACH ENTRY, AS NECESSARY. */
+ /*------------------------------------------------------------------------*/
+ if (byte_swapped || RUN_RELOC_AMOUNT(scnum - 1))
+ for (i = 0; i < count; i++, lptr++)
+ {
+ if (byte_swapped)
+ {
+ swap2byte(&lptr->l_lnno);
+ swap4byte(&lptr->l_addr.l_paddr);
+ }
+
+ if (lptr->l_lnno != 0)
+ lptr->l_addr.l_paddr += RUN_RELOC_AMOUNT(scnum - 1);
+ }
+
+ return TRUE;
+}
+
+
+/******************************************************************************/
+/* */
+/* SWAP4BYTE() - Swap the order of bytes in a int. */
+/* */
+/******************************************************************************/
+void swap4byte(void *addr)
+{
+ unsigned int *value = (unsigned int *)addr;
+ unsigned int temp1, temp2, temp3, temp4;
+
+ temp1 = (*value) & 0xFF;
+ temp2 = (*value >> 8) & 0xFF;
+ temp3 = (*value >> 16) & 0xFF;
+ temp4 = (*value >> 24) & 0xFF;
+
+ *value = (temp1 << 24) | (temp2 << 16) | (temp3 << 8) | temp4;
+}
+
+
+/******************************************************************************/
+/* */
+/* SWAP2BYTE() - Swap the order of bytes in a short. */
+/* */
+/******************************************************************************/
+void swap2byte(void *addr)
+{
+ unsigned short *value = (unsigned short *)addr;
+ unsigned short temp1,temp2;
+
+ temp1 = temp2 = *value;
+ *value = ((temp2 & 0xFF) << 8) | ((temp1 >> 8) & 0xFF);
+}
diff --git a/src/interp/coff/cload.h b/src/interp/coff/cload.h
--- /dev/null
+++ b/src/interp/coff/cload.h
@@ -0,0 +1,134 @@
+/***************************************************************************
+* FILENAME: cload.h
+* VERSION: 2.4 5/2/96 13:12:48
+* SCCS ID: "@(#)cload.h 2.4 5/2/96"
+***************************************************************************/
+/*****************************************************************************/
+/* CLOAD.H - Header file for Generic COFF Loader Version 4.00 9/92 */
+/*****************************************************************************/
+#ifndef _CLOAD_H_
+#define _CLOAD_H_
+
+/*---------------------------------------------------------------------------*/
+/* THIS MACRO IS USED TO FACILIATE ACCESS TO THE SECTION HEADERS */
+/*---------------------------------------------------------------------------*/
+#define SECT_HDR(i) ((SCNHDR *)(sect_hdrs + (i) * SCNHSZ))
+
+/*---------------------------------------------------------------------------*/
+/* THIS MACRO IS USED TO FACILITATE BACKWARDS COMPATIBILITY FOR COFF- */
+/* DEPENDENT TOOLS THAT SUPPORT COFF VERSION 2. */
+/*---------------------------------------------------------------------------*/
+#define O_SECT_HDR(i) ((O_SCNHDR *)(o_sect_hdrs + (i)*SCNHSZ_IN(coff_version)))
+
+/*----------------------------------------------------------------------------*/
+/* STATIC COPY OF 8 CHARACTER SECTION NAME, GUARANTEED NULL TERMINATION WHEN */
+/* USED AS A STRING. */
+/*----------------------------------------------------------------------------*/
+static char stat_nm[SYMNMLEN+1]={'\0','\0','\0','\0','\0','\0','\0','\0','\0'};
+#define SNAMECPY(s) (strn_copy(stat_nm, (s), SYMNMLEN))
+
+/*---------------------------------------------------------------------------*/
+/* THESE MACROS ARE USED TO FIND CINIT AND BSS SECTIONS */
+/*---------------------------------------------------------------------------*/
+#define IS_BSS(sptr) (!str_comp(sptr->s_name, ".bss"))
+#define IS_CINIT(sptr) ((sptr->s_flags & STYP_COPY) && \
+ !str_comp(sptr->s_name, CINIT) )
+
+/*---------------------------------------------------------------------------*/
+/* VARIABLES SET BY THE APPLICATION. */
+/*---------------------------------------------------------------------------*/
+/* #define FILE_BASED 0 - moved to osal.h */
+#define STRIP_RELOC 1
+#define REMOVE_MALLOC 0
+
+#if (FILE_BASED)
+extern FILE *fin; /* INPUT FILE */
+#else
+extern unsigned char gRxBuffer[0x400040];
+#endif
+
+extern int need_data; /* READ IN RAW DATA */
+extern int need_symbols; /* READ IN SYMBOL TABLE */
+extern int clear_bss; /* CLEAR BSS SECTION */
+extern int big_e_config; /* ENDIANNESS CONFIGURATION OF TARGET */
+#if TMS320C60 || RTC
+extern int fill_bss_value; /* NUMBER FOR FILL VALUE */
+#endif
+
+/*---------------------------------------------------------------------------*/
+/* VARIABLES SET BY THE LOADER. */
+/*---------------------------------------------------------------------------*/
+extern FILHDR file_hdr; /* FILE HEADER STRUCTURE */
+extern int coff_version; /* VERSION OF COFF USED BY FILE */
+extern AOUTHDR o_filehdr; /* OPTIONAL (A.OUT) FILE HEADER */
+extern T_ADDR entry_point; /* ENTRY POINT OF MODULE */
+extern T_ADDR *reloc_amount; /* AMOUNT OF RELOCATION PER SECTION */
+extern char *sect_hdrs; /* ARRAY OF SECTION HEADERS */
+extern char *o_sect_hdrs; /* ARRAY OF OLD COFF SECTION HEADERS */
+extern int n_sections; /* NUMBER OF SECTIONS IN THE FILE */
+extern int big_e_target; /* OBJECT DATA IS STORED MSB FIRST */
+extern int byte_swapped; /* BYTE ORDERING OPPOSITE OF HOST */
+extern int curr_sect; /* INDEX OF SECTION CURRENTLY LOADING */
+extern int load_err; /* ERROR CODE RETURNED IF LOADER FAILS */
+extern struct strtab *str_head; /* HEAD OF STRING BUFFER LIST */
+
+/*--------------------------------------------------------------------------*/
+/* CLOAD.C PROTOTYPES */
+/*--------------------------------------------------------------------------*/
+extern int cload (void);
+extern int cload_headers (void);
+extern int cload_data (void);
+extern int cload_sect_data (struct scnhdr *);
+extern int cload_cinit (unsigned char *, int *, int *);
+extern int cload_symbols (void);
+extern int cload_strings (void);
+extern void str_free (struct strtab *);
+extern int sym_read (int, struct syment *, union auxent *);
+extern char *sym_name (struct syment *);
+extern char *sym_add_name (struct syment *);
+extern int reloc_add (int, struct syment *);
+extern int relocate (RELOC *, unsigned char *, int);
+extern int reloc_size (int);
+extern int reloc_offset (int);
+extern int reloc_stop (int);
+extern int sym_reloc_amount (RELOC *);
+extern unsigned int unpack (unsigned char *, int, int, int);
+extern void repack (unsigned int, unsigned char *, int,int,int);
+extern int cload_lineno (int, int, struct lineno *, int);
+extern void swap4byte (void *);
+extern void swap2byte (void *);
+
+#if FILE_BASED
+int reloc_read(RELOC *rptr);
+#else
+int reloc_read(RELOC *rptr, unsigned int offset);
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* PROTOTYPES FOR FUNCTIONS REQUIRED BY CLOAD.C */
+/*--------------------------------------------------------------------------*/
+extern void lookup_sym(int indx, SYMENT *sym, AUXENT *aux);
+/* extern int mem_write(unsigned char *, unsigned int, T_ADDR, unsigned char); - moved to osal.h */
+extern void load_msg(const char *);
+extern int set_reloc_amount(void);
+extern int load_syms(int);
+
+/*---------------------------------------------------------------------------*/
+/* VALUE OF big_e_config IF THERE IS NO TARGET AND SO IT'S A DON'T CARE. */
+/*---------------------------------------------------------------------------*/
+#define DONTCARE -1
+
+/*---------------------------------------------------------------------------*/
+/* ERROR CODES */
+/*---------------------------------------------------------------------------*/
+#define E_FILE 1 /* ERROR READING COFF FILE */
+#define E_MAGIC 2 /* WRONG MAGIC NUMBER */
+#define E_RELOC 3 /* FILE IS NOT RELOCATABLE */
+#define E_SYM 4 /* LOAD_SYM RETURNED FALSE */
+#define E_ALLOC 5 /* MYALLOC OR MRALLOC RETURNED FALSE */
+#define E_SETRELOC 6 /* SET_RELOC_AMOUNT RETURNED FALSE */
+#define E_MEMWRITE 7 /* MEM_WRITE RETURNED FALSE */
+#define E_RELOCENT 8 /* RELOC ENTRY RULES VIOLATED */
+#define E_ENDIAN 9 /* OBJ ENDIANESS CONFLICTS WITH TARGET */
+
+#endif /* _CLOAD_H_ */
diff --git a/src/interp/coff/cload.mike.c b/src/interp/coff/cload.mike.c
--- /dev/null
@@ -0,0 +1,2122 @@
+/***************************************************************************
+* FILENAME: cload.c
+* VERSION: 2.6 5/2/96 13:11:03
+* SCCS ID: "@(#)cload.c 2.6 5/2/96"
+***************************************************************************/
+/******************************************************************************/
+/* CLOAD.C - Generic COFF Loader Version 6.00 4/96 */
+/******************************************************************************/
+/* */
+/* This module contains functions to read in and load a COFF object file. */
+/* The following routines are defined here: */
+/* */
+/* cload() - Main driver for COFF loader. */
+/* cload_headers() - Read in the various headers of the COFF file. */
+/* cload_data() - Read in the raw data and load it into memory. */
+/* cload_sect_data() - Read, relocate, and write out one section. */
+/* cload_cinit() - Process one buffer of C initialization records. */
+/* cload_symbols() - Read in the symbol table. */
+/* cload_strings() - Read in the string table. */
+/* str_free() - Free a string table. */
+/* sym_read() - Read and relocate a symbol and its aux entry. */
+/* sym_name() - Return a pointer to the name of a symbol. */
+/* sym_add_name() - Add a symbol name to the string table. */
+/* reloc_add() - Add a symbol to the relocation symbol table. */
+/* relocate() - Perform a single relocation. */
+/* reloc_read() - Read in and swap one relocation entry. */
+/* reloc_size() - Return the field size of a relocation type. */
+/* reloc_offset() - Return the field offset of a relocation type. */
+/* reloc_stop() - Return the number of bits to read for a reloc type. */
+/* sym_reloc_amount()- Return relocation amount for a relocation entry. */
+/* unpack() - Extract a relocation field from object bytes. */
+/* repack() - Encode a relocated field into object bytes. */
+/* cload_lineno() - Read in & swap line number entries. */
+/* swap4byte() - Swap the order of bytes in a int. */
+/* swap2byte() - Swap the order of bytes in a short. */
+/* */
+/* The loader calls the following external functions to perform application */
+/* specific tasks: */
+/* */
+/* set_reloc_amount() - Define relocation amounts for each section. */
+/* mem_write() - Load a buffer of data into memory. */
+/* lookup_sym() - Look up a symbol in an external symbol table. */
+/* load_syms() - Build the symbol table for the application. */
+/* load_msg() - Write diagnostic messages during loading. */
+/* */
+/******************************************************************************/
+#include "types.h"
+#include "ibl.h"
+#include "iblloc.h"
+#include "iblcfg.h"
+#include "coff.h"
+#include "coff_trg.h"
+#include "cload.h"
+#include <string.h>
+
+#if (FILE_BASED)
+#include <stdio.h>
+#endif
+/*----------------------------------------------------------------------------*/
+/* CONSTANTS, MACROS, VARIABLES, AND STRUCTURES FOR THE LOADER. */
+/*----------------------------------------------------------------------------*/
+#define MIN(a,b) ((a)<(b)?(a):(b))
+#define MAX(a,b) ((a)>(b)?(a):(b))
+
+#define TRUE 1
+#define FALSE 0
+#define WORDSZ sizeof(T_DATA) /* SIZE OF DATA UNITS IN OBJ FILE */
+
+#ifdef TMS320C60
+ extern int target_coff (unsigned short flags);
+#endif
+
+/*----------------------------------------------------------------------------*/
+/* APPLICATION VARIABLES */
+/*----------------------------------------------------------------------------*/
+#if (FILE_BASED)
+FILE *fin; /* INPUT FILE */
+#else
+/* extern unsigned char gRxBuffer[0x400040]; */
+extern unsigned char gRxBuffer[0x10];
+#endif
+
+unsigned char gRxBuffer[0x10];
+
+
+int need_data = TRUE; /* APPLICATION NEEDS RAW DATA */
+int need_symbols = FALSE; /* APPLICATION NEEDS SYMBOL TABLE */
+int clear_bss = FALSE; /* CLEAR BSS SECTION */
+
+
+/*----------------------------------------------------------------------------*/
+/* FILL VALUES TO BE USED BY LOADERS */
+/*----------------------------------------------------------------------------*/
+#if defined(OTIS)
+extern int fill_bss;
+extern int fill_bss_value;
+#else
+#define fill_bss 0
+#define fill_bss_value 0
+#endif
+
+/*----------------------------------------------------------------------------*/
+/* LOADER VARIABLES */
+/*----------------------------------------------------------------------------*/
+FILHDR file_hdr; /* FILE HEADER STRUCTURE */
+int coff_version; /* COFF VERSION USED IN FILE */
+AOUTHDR o_filehdr; /* OPTIONAL (A.OUT) FILE HEADER */
+T_ADDR entry_point; /* ENTRY POINT OF MODULE */
+T_ADDR *reloc_amount = NULL; /* AMOUNT OF RELOCATION PER SECTION */
+int n_sections; /* NUMBER OF SECTIONS IN THE FILE */
+int big_e_target; /* TARGET DATA IN BIG-ENDIAN FORMAT */
+int byte_swapped; /* BYTE ORDERING OPPOSITE OF HOST */
+int curr_sect; /* SECTION NUMBER CURRENTLY LOADING */
+int load_err; /* ERROR CODE RETURNED IF LOADER FAILS*/
+struct strtab *str_head = NULL; /* LIST OF STRING TABLE BUFFERS */
+
+static T_SIZE init_size = 0; /* CURRENT SIZE OF C INITIALIZATION */
+static int need_reloc; /* RELOCATION REQUIRED */
+
+
+int n_array_sections; /* The number of sections in sect_hdrs */
+
+SCNHDR sect_hdrs[MAX_COFF_SECTION_HEADERS]; /* Array of loadable sections */
+O_SCNHDR o_sect_hdrs; /* A single old section header */
+
+unsigned int paBuf[LOADBUFSIZE]; /* Temp buffer for packet load */
+
+int stream_offset; /* The current stream offset */
+
+
+#if TMS320C60
+int big_e_config = TRG_DEF_BIG_E; /* ENDIANNESS CONFIGURATION */
+#else
+int big_e_config = DONTCARE; /* ENDIANNESS CONFIGURATION */
+#endif
+
+/*----------------------------------------------------------------------------*/
+/* THIS STRUCTURE IS USED TO STORE THE RELOCATION AMOUNTS FOR SYMBOLS. */
+/* EACH RELOCATABLE SYMBOL HAS A CORRESPONDING ENTRY IN THIS TABLE. */
+/* THE TABLE IS SORTED BY SYMBOL INDEX; LOOKUP USES A BINARY SEARCH. */
+/*----------------------------------------------------------------------------*/
+typedef struct
+{
+ int rt_index; /* INDEX OF SYMBOL IN SYMBOL TABLE */
+ int rt_disp; /* AMOUNT OF RELOCATION */
+} RELOC_TAB;
+
+/*----------------------------------------------------------------------------*/
+/* THE RELOCATION SYMBOL TABLE IS ALLOCATED DYNAMICALLY, AND REALLOCATED */
+/* AS MORE SPACE IS NEEDED. */
+/*----------------------------------------------------------------------------*/
+#define RELOC_TAB_START 128 /* STARTING SIZE OF TABLE */
+#define RELOC_GROW_SIZE 128 /* REALLOC AMOUNT FOR TABLE */
+
+static RELOC_TAB *reloc_tab = NULL; /* RELOCATION SYMBOL TABLE */
+
+static int reloc_tab_size; /* CURRENT ALLOCATED AMOUNT */
+static int reloc_sym_index; /* CURRENT SIZE OF TABLE */
+
+/*----------------------------------------------------------------------------*/
+/* RUN-TIME RELOCATION (AS OPPOSED TO LOAD-TIME) RELOCATION IS DETERMINED */
+/* AS FOLLOWS: IF THE SECTION'S RUNTIME ADDRESS == LOADTIME ADDRESS, USE */
+/* LOADTIME RELOCATION. OTHERWISE, ASSUME LOADTIME RELOC ONLY (RUNTIME RELOC */
+/* == 0). */
+/*----------------------------------------------------------------------------*/
+#define RUN_RELOC_AMOUNT(i) ((SECT_HDR(i)->s_paddr == SECT_HDR(i)->s_vaddr) ? \
+ reloc_amount[i] : 0)
+
+/*----------------------------------------------------------------------------*/
+/* DEFINE A STRUCTURE FOR STRING TABLE BUFFERS. THESE BUFFERS ARE STORED */
+/* AS A LINKED LIST OF MEMORY PACKETS, EACH CONTAINING UP TO 64K OF THE */
+/* STRING TABLE. */
+/*----------------------------------------------------------------------------*/
+typedef struct strtab
+{
+ unsigned int size; /* SIZE OF THIS PACKET */
+ unsigned int offset; /* STARTING OFFSET OF THIS PACKET */
+ unsigned int index; /* AMOUNT CURRENTLY FILLED */
+ struct strtab *next; /* NEXT BUFFER */
+ char buf[1]; /* STRING DATA (EXPAND AS ALLOCATED) */
+} STRTAB;
+
+#define MAX_STRING_ALLOC (unsigned int)(0xffff-sizeof(STRTAB)+1)
+ /* MAX STRING BUFFER: 64K (SMALL HOSTS)*/
+#define MIN_STRING_ALLOC 0x0400 /* MIN STRING BUFFER: 1K */
+
+unsigned int unpack();
+
+/* extern void mem_copy(unsigned char* dst, unsigned char* src, int nbytes); */
+#define mem_copy(dest,src,nbytes) memcpy((void *)(dest),(void *)(src),nbytes)
+#define mem_write(buf, nbytes, addr, page) memcpy((void *)(addr),(void *)(buf),nbytes)
+#define str_comp strcmp
+/******************************************************************************/
+/* */
+/* CLOAD() - Main driver for COFF loader. */
+/* */
+/******************************************************************************/
+int cload(BOOT_MODULE_FXN_TABLE *bootFxn, Uint32 *ientry_point)
+{
+ int result;
+
+ load_err = 0;
+ stream_offset = 0;
+ result = cload_headers(bootFxn, ientry_point) && cload_data(bootFxn);
+
+ if (reloc_tab) free(reloc_tab);
+ reloc_tab = NULL;
+
+ if(result == TRUE)
+ return 0;
+ else {
+ *ientry_point = 0;
+ return -1;
+ }
+}
+
+\f
+/******************************************************************************/
+/* */
+/* CLOAD_HEADERS() - Read in the various headers of the COFF file. */
+/* */
+/******************************************************************************/
+int cload_headers(BOOT_MODULE_FXN_TABLE *bootFxn, Uint32 *ientry_point)
+{
+ int i;
+
+ byte_swapped = FALSE;
+ need_reloc = FALSE;
+
+ *ientry_point = NULL; /* Error return value */
+
+ if ((*bootFxn->read)((Uint8 *)&file_hdr, FILHSZ) < 0)
+ return (FALSE);
+ stream_offset += FILHSZ;
+
+
+ /*-------------------------------------------------------------------------*/
+ /* MAKE SURE THIS IS REALLY A COFF FILE. CHECK FOR SWAPPED FILES. */
+ /* DETERMINE BYTE ORDERING OF OBJECT DATA. */
+ /*-------------------------------------------------------------------------*/
+ if (!ISCOFF(file_hdr.f_magic))
+ {
+ swap2byte(&file_hdr.f_magic);
+
+ if (!ISCOFF(file_hdr.f_magic)) { load_err = E_MAGIC; return FALSE; }
+
+ byte_swapped = TRUE;
+
+ swap2byte(&file_hdr.f_nscns); swap4byte(&file_hdr.f_timdat);
+ swap4byte(&file_hdr.f_symptr); swap4byte(&file_hdr.f_nsyms);
+ swap2byte(&file_hdr.f_opthdr); swap2byte(&file_hdr.f_flags);
+#if COFF_VERSION_1 || COFF_VERSION_2
+ swap2byte(&file_hdr.f_target_id);
+#endif
+ }
+
+ /*-------------------------------------------------------------------------*/
+ /* DETERMINE THE ENDIANNESS OF THE COFF FILE, AND ENSURE THE ENDIANNESS OF */
+ /* THE FILE IS THE SAME AS THE TARGET, IF THERE IS A TARGET. */
+ /*-------------------------------------------------------------------------*/
+ big_e_target = ((file_hdr.f_flags & F_BIG) != 0);
+ if (big_e_config != DONTCARE && big_e_target != big_e_config)
+ { load_err = E_ENDIAN; return FALSE; }
+
+ /*-------------------------------------------------------------------------*/
+ /* DETERMINE VERSION OF COFF BEING USED, CHECK TARGET ID IF NEEDED. */
+ /*-------------------------------------------------------------------------*/
+ if (ISCOFF_1(file_hdr.f_magic) || ISCOFF_2(file_hdr.f_magic))
+ {
+ if (!ISMAGIC(file_hdr.f_target_id)) { load_err = E_MAGIC; return FALSE; }
+ coff_version = file_hdr.f_magic;
+ }
+ else coff_version = COFF_MAGIC_0;
+
+#ifdef TMS320C60
+ /*-------------------------------------------------------------------------*/
+ /* DETERMINE WHETHER THE RIGHT COFF IS BEING LOADED */
+ /*-------------------------------------------------------------------------*/
+ if ( !target_coff( file_hdr.f_flags) )
+ { load_err = E_FILE; return FALSE; }
+#endif
+
+ /*-------------------------------------------------------------------------*/
+ /* READ IN OPTIONAL HEADER, IF THERE IS ONE, AND SWAP IF NEEDED. */
+ /*-------------------------------------------------------------------------*/
+ if (file_hdr.f_opthdr == AOUTSZ)
+ {
+
+ if ((*bootFxn->read)((Uint8 *)&o_filehdr, file_hdr.f_opthdr) < 0)
+ return (FALSE);
+ stream_offset += file_hdr.f_opthdr;
+
+ if (byte_swapped)
+ {
+ swap2byte(&o_filehdr.magic); swap2byte(&o_filehdr.vstamp);
+ swap4byte(&o_filehdr.tsize); swap4byte(&o_filehdr.dsize);
+ swap4byte(&o_filehdr.bsize); swap4byte(&o_filehdr.entrypt);
+ swap4byte(&o_filehdr.text_start); swap4byte(&o_filehdr.data_start);
+ }
+
+ entry_point = o_filehdr.entrypt;
+ *ientry_point = entry_point;
+ }
+
+ /*-------------------------------------------------------------------------*/
+ /* Read in string table so that we can see long section names, if needed. */
+ /* This used tobe read right before the symbol table was read, but now the */
+ /* section headers use "flexname" method to specify section names and so */
+ /* might need access to a string table entry. */
+ /*-------------------------------------------------------------------------*/
+ //if (!cload_strings()) return FALSE;
+
+ /*-------------------------------------------------------------------------*/
+ /* READ IN SECTION HEADERS. */
+ /*-------------------------------------------------------------------------*/
+
+ n_array_sections = 0;
+ for (i = 0; i < file_hdr.f_nscns; i++) {
+
+ SCNHDR *sptr = (SCNHDR *)§_hdrs[n_array_sections];
+ O_SCNHDR *tptr = (O_SCNHDR *)&o_sect_hdrs;
+
+ if (ISCOFF_2(coff_version)) {
+
+ if ((*bootFxn->read)((Uint8 *)sptr, SCNHSZ_IN(coff_version)) < 0)
+ return (FALSE);
+ stream_offset += SCNHSZ_IN(coff_version);
+
+
+ if (byte_swapped) {
+
+ if (sptr->s_zeroes == 0L) swap4byte(&sptr->s_offset);
+ swap4byte(&sptr->s_paddr);
+ swap4byte(&sptr->s_vaddr);
+ swap4byte(&sptr->s_size);
+ swap4byte(&sptr->s_scnptr);
+ swap4byte(&sptr->s_relptr);
+ swap4byte(&sptr->s_lnnoptr);
+ swap4byte(&sptr->s_nreloc);
+ swap4byte(&sptr->s_nlnno);
+ swap4byte(&sptr->s_flags);
+ /* s_mwidth - single byte */
+ /* s_reserved - single byte */
+ swap2byte(&sptr->s_page);
+ }
+
+
+ } else {
+
+ if ((*bootFxn->read)((Uint8 *)tptr, SCNHSZ_IN(coff_version)) < 0)
+ return (FALSE);
+ stream_offset += SCNHSZ_IN(coff_version);
+
+ if (byte_swapped) {
+ swap4byte(&tptr->os_paddr);
+ swap4byte(&tptr->os_vaddr);
+ swap4byte(&tptr->os_size);
+ swap4byte(&tptr->os_scnptr);
+ swap4byte(&tptr->os_relptr);
+ swap4byte(&tptr->os_lnnoptr);
+ swap2byte(&tptr->os_nreloc);
+ swap2byte(&tptr->os_nlnno);
+ swap2byte(&tptr->os_flags);
+ /* os_reserved - one byte */
+ /* os_page - one byte */
+ }
+
+ strncpy(sptr->s_name, tptr->os_name, SYMNMLEN);
+ sptr->s_paddr = tptr->os_paddr;
+ sptr->s_vaddr = tptr->os_vaddr;
+ sptr->s_size = tptr->os_size;
+ sptr->s_scnptr = tptr->os_scnptr;
+ sptr->s_relptr = tptr->os_relptr;
+ sptr->s_lnnoptr = tptr->os_lnnoptr;
+ sptr->s_nreloc = tptr->os_nreloc;
+ sptr->s_nlnno = tptr->os_nlnno;
+ sptr->s_flags = tptr->os_flags;
+ sptr->s_page = tptr->os_page;
+ }
+
+ /* Dont keep the section if it is not loaded */
+
+ if ((sptr->s_scnptr || ((clear_bss || fill_bss) && IS_BSS(sptr))) &&
+ (sptr->s_size) &&
+ !(sptr->s_flags & (STYP_DSECT | STYP_NOLOAD)))
+
+ n_array_sections += 1;
+
+ }
+
+
+ return TRUE;
+}
+
+\f
+/******************************************************************************/
+/* */
+/* CLOAD_DATA() - Read in the raw data and load it into memory. */
+/* */
+/******************************************************************************/
+int cload_data(BOOT_MODULE_FXN_TABLE *bootFxn)
+{
+ int ok = TRUE;
+
+ if (!need_data) return TRUE;
+
+ /*-------------------------------------------------------------------------*/
+ /* LOOP THROUGH THE SECTIONS AND LOAD THEM ONE AT A TIME. */
+ /*-------------------------------------------------------------------------*/
+ for (curr_sect = 0; curr_sect < n_array_sections && ok; curr_sect++)
+ {
+ SCNHDR *sptr = §_hdrs[curr_sect];
+ char *sname = (sptr->s_zeroes == 0L) ?
+ sptr->s_nptr : SNAMECPY(sptr->s_name);
+
+ /*----------------------------------------------------------------------*/
+ /* IF THIS IS THE TEXT SECTION, RELOCATE THE ENTRY POINT. */
+ /*----------------------------------------------------------------------*/
+ if ((sptr->s_flags & STYP_TEXT) && !strcmp(sname, ".text"))
+ entry_point += RUN_RELOC_AMOUNT(curr_sect);
+
+ /*----------------------------------------------------------------------*/
+ /* IGNORE EMPTY SECTIONS OR SECTIONS WHOSE FLAGS INDICATE THE */
+ /* SECTION IS NOT TO BE LOADED. IF THE CLEAR_BSS FLAG IS SET, BSS */
+ /* IS "LOADED" EVEN THOUGH IT HAS NO DATA */
+ /*----------------------------------------------------------------------*/
+ if ((sptr->s_scnptr || ((clear_bss || fill_bss) && IS_BSS(sptr))) &&
+ (sptr->s_size) &&
+ !(sptr->s_flags & (STYP_DSECT | STYP_NOLOAD))) {
+
+ if (!(sptr->s_flags & STYP_COPY))
+ ok &= cload_sect_data(sptr, bootFxn);
+ else
+ ok &= cload_sect_data(sptr, bootFxn);
+ }
+ }
+
+
+ return ok;
+}
+
+\f
+/******************************************************************************/
+/* */
+/* CLOAD_SECT_DATA() - Read, relocate, and write out the data for one section.*/
+/* */
+/******************************************************************************/
+int cload_sect_data(SCNHDR *sptr, BOOT_MODULE_FXN_TABLE *bootFxn)
+{
+ T_ADDR addr = sptr->s_vaddr; /* CURRENT ADDRESS IN SECTION */
+ unsigned int nbytes; /* BYTE COUNT WITHIN SECTION */
+ int packet_size = 0; /* SIZE OF CURRENT DATA BUFFER */
+ int excess = 0; /* BYTES LEFT FROM PREVIOUS BUFFER */
+ unsigned int n_reloc = 0; /* COUNTER FOR RELOCATION ENTRIES */
+ RELOC reloc; /* RELOCATION ENTRY */
+ int relsz = RELSZ_IN(coff_version);
+ unsigned char *packet = (unsigned char *)paBuf; /* LOAD BUFFER */
+ unsigned int section_length = (unsigned int)LOCTOBYTE(sptr->s_size);
+ unsigned int buffer_size = LOADBUFSIZE;
+
+#if defined (UNBUFFERED) && UNBUFFERED
+ /*-------------------------------------------------------------------------*/
+ /* IF UNBUFFERED, THEN SET SIZE TO SECTION LENGTH ROUNDED UP TO MULTIPLE */
+ /* 32 BYTES. WE MAINTAIN A MINIMIUM OF LOADBUFSIZE IN THE EVENT SOMEONE */
+ /* CONTINUES TO USE THAT MACRO AS A SIZE LIMIT. */
+ /*-------------------------------------------------------------------------*/
+ buffer_size = MAX(buffer_size, (section_length + 32) & ~31ul);
+#endif
+
+ /*-------------------------------------------------------------------------*/
+ /* ENSURE LOADBUFSIZE IS A MULTIPLE OF 2 */
+ /*-------------------------------------------------------------------------*/
+ if (LOADBUFSIZE % 2)
+ {
+ return -1;
+ }
+
+ /*-------------------------------------------------------------------------*/
+ /* ALLOCATE THE PACKET BUFFER */
+ /*-------------------------------------------------------------------------*/
+ if (!packet) { load_err = E_ALLOC; return FALSE; }
+
+#ifdef OTIS
+ if (IS_BSS(sptr))
+ {
+ TRG_MVAL filval = fill_bss_value;
+
+ free (packet);
+
+ if (!mem_fill(filval, LOCTOBYTE(sptr->s_size), addr, sptr->s_page))
+ { load_err = E_MEMWRITE; return FALSE; }
+ return TRUE;
+ }
+#else
+ /*-------------------------------------------------------------------------*/
+ /* Always want to clear memory for cases where memsize is not a multiple */
+ /* of the data size being written out. If we do not clear the array, the */
+ /* last byte or so can be corrupted with data from the last buffer read. */
+ /*-------------------------------------------------------------------------*/
+ for (nbytes = 0; nbytes < buffer_size; ++nbytes) packet[nbytes] = 0;
+#endif
+
+
+ /* Advance the stream to the start of the section */
+ if (sptr->s_scnptr) {
+
+ unsigned int offset;
+
+ offset = sptr->s_scnptr;
+
+ /* Advance the stream to the next section */
+ if (offset > stream_offset) {
+
+ unsigned int delta, rsize;
+ int k;
+
+
+ delta = sptr->s_scnptr - stream_offset;
+
+ for (k = 0; k < delta; k += rsize) {
+
+ rsize = MIN(delta, sizeof(paBuf));
+
+ if ((*bootFxn->read)((Uint8 *)paBuf, rsize) < 0)
+ return (FALSE);
+ stream_offset += rsize;
+
+ }
+
+ }
+
+ }
+
+
+ /*-------------------------------------------------------------------------*/
+ /* COPY ALL THE DATA IN THE SECTION. */
+ /*-------------------------------------------------------------------------*/
+
+ for (nbytes = 0; nbytes < section_length; nbytes += packet_size)
+ {
+ int j;
+
+ /*----------------------------------------------------------------------*/
+ /* READ IN A BUFFER OF DATA. IF THE PREVIOUS RELOCATION SPANNED */
+ /* ACROSS THE END OF THE LAST BUFFER, COPY THE LEFTOVER BYTES INTO */
+ /* THE BEGINNING OF THE NEW BUFFER. */
+ /*----------------------------------------------------------------------*/
+ for (j = 0; j < excess; ++j) packet[j] = packet[packet_size + j];
+
+ packet_size = (int)MIN(LOCTOBYTE(sptr->s_size) - nbytes, buffer_size);
+
+ if (sptr->s_scnptr) {
+
+ if ((*bootFxn->read)((Uint8 *)((Uint8 *)packet+ excess), packet_size - excess) < 0)
+ return (FALSE);
+ stream_offset += (packet_size - excess);
+
+ }
+
+
+ excess = 0;
+
+ /*----------------------------------------------------------------------*/
+ /* Clear out end of packet in case we write padding. */
+ /*----------------------------------------------------------------------*/
+ if (excess + packet_size < buffer_size)
+ for(j = excess + packet_size; j < buffer_size; j++)
+ packet[j] = 0;
+
+
+#if 0 /* For some reason I have a section with STYP_COPY set, but
+ * the name is not .cinit (first section). The address of
+ * this section is 0, so if memcpy is called it returns 0,
+ * which results in the load_err case */
+
+ /*----------------------------------------------------------------------*/
+ /* WRITE OUT THE RELOCATED DATA TO THE TARGET DEVICE. IF THIS IS A */
+ /* CINIT SECTION, CALL A SPECIAL FUNCTION TO HANDLE IT. */
+ /*----------------------------------------------------------------------*/
+ if (!(IS_CINIT(sptr) ?
+ cload_cinit(packet, &packet_size, &excess) :
+ (int)memcpy ((void *)addr, packet, packet_size)))
+ { load_err = E_MEMWRITE; free (packet); return FALSE; }
+#endif
+
+
+
+ if (IS_CINIT(sptr)) {
+ if (cload_cinit(packet, &packet_size, &excess)) {
+ load_err = E_MEMWRITE; return (FALSE);
+
+ }
+
+ } else {
+
+ /* If a copy section, but not cinit, ignore it */
+ if (!(sptr->s_flags & STYP_COPY))
+ memcpy ((void *)addr, packet, packet_size);
+
+ }
+
+
+ /*----------------------------------------------------------------------*/
+ /* KEEP TRACK OF THE ADDRESS WITHIN THE SECTION. */
+ /*----------------------------------------------------------------------*/
+ addr += BYTETOLOC(packet_size);
+
+ }
+
+ return TRUE;
+}
+
+\f
+/******************************************************************************/
+/* */
+/* CLOAD_CINIT() - Process one buffer of C initialization records. */
+/* */
+/******************************************************************************/
+int cload_cinit(unsigned char *packet, int *packet_size, int *excess)
+{
+ int i; /* BYTE COUNTER */
+ int init_packet_size; /* SIZE OF CURRENT INITIALIZATION */
+ static T_ADDR init_addr; /* ADDRESS OF CURRENT INITIALIZATION */
+ int bss_page = 0; /* BSS SECTION PAGE NUMBER */
+
+ /*-------------------------------------------------------------------------*/
+ /* FIND THE BSS SECTION ASSOCIATED WITH THE THE CINIT SECTION CURRENTLY */
+ /* BEING LOADED. */
+ /*-------------------------------------------------------------------------*/
+ for (i = 0; i < n_sections; ++i)
+ if (IS_BSS(SECT_HDR(i)))
+ { bss_page = SECT_HDR(i)->s_page; break; }
+
+ /*-------------------------------------------------------------------------*/
+ /* PROCESS ALL THE INITIALIZATION RECORDS IN THE BUFFER. */
+ /*-------------------------------------------------------------------------*/
+ for (i = 0; i < *packet_size; i += init_packet_size)
+ {
+ /*----------------------------------------------------------------------*/
+ /* IF STARTING A NEW INITIALIZATION, READ THE SIZE AND ADDRESS FROM */
+ /* THE TABLE. */
+ /*----------------------------------------------------------------------*/
+ if (init_size == 0)
+ {
+ T_SIZE temp;
+ int align;
+
+ /*-------------------------------------------------------------------*/
+ /* POSITION THE BYTE INDEX ON THE NEXT INIT RECORD. */
+ /*-------------------------------------------------------------------*/
+ if (align = (i % INIT_ALIGN)) i += (INIT_ALIGN - align);
+
+ /*-------------------------------------------------------------------*/
+ /* IF THE SIZE AND ADDRESS ARE NOT FULLY CONTAINED IN THIS BUFFER, */
+ /* STOP HERE. SET THE 'EXCESS' COUNTER TO THE NUMBER OF UNPROCESSED */
+ /* BYTES - THESE WILL BE COPIED TO THE HEAD OF THE NEXT BUFFER. */
+ /*-------------------------------------------------------------------*/
+ if ((int)(i + sizeof(T_SIZE)) > *packet_size)
+ { *excess += *packet_size - i; *packet_size = i; break; }
+
+ /*-------------------------------------------------------------------*/
+ /* IF THE NEXT SIZE FIELD IS ZERO, BREAK. */
+ /*-------------------------------------------------------------------*/
+ temp = unpack(packet + i, sizeof(T_SIZE)*8, sizeof(T_SIZE)*8, 0);
+ if (temp == 0) break;
+
+ /*-------------------------------------------------------------------*/
+ /* READ THE ADDRESS FIELD ,IF IT'S ALL HERE. */
+ /*-------------------------------------------------------------------*/
+ if ((int)(i + sizeof(T_SIZE) + sizeof(T_IADDR)) > *packet_size)
+ { *excess += *packet_size - i; *packet_size = i; break; }
+
+ i += sizeof(T_SIZE);
+ init_size = temp;
+ init_addr = unpack(packet+i,sizeof(T_IADDR)*8,sizeof(T_IADDR)*8,0);
+ i += sizeof(T_IADDR);
+ }
+
+ /*----------------------------------------------------------------------*/
+ /* WRITE OUT THE CURRENT PACKET, UP TO THE END OF THE BUFFER. */
+ /*----------------------------------------------------------------------*/
+ if (init_packet_size = MIN(*packet_size-i, (int)(init_size * INIT_WSIZE)))
+ {
+
+ if (!mem_write(packet + i, init_packet_size, init_addr, bss_page))
+ return FALSE;
+
+ init_addr += BYTETOLOC(init_packet_size);
+ init_size -= init_packet_size / INIT_WSIZE;
+ }
+ }
+ return TRUE;
+}
+
+#if 0
+/******************************************************************************/
+/* */
+/* CLOAD_SYMBOLS() - Read in the symbol table. */
+/* */
+/******************************************************************************/
+int cload_symbols()
+{
+ SYMENT sym;
+ AUXENT aux;
+ int first, next;
+
+ if (file_hdr.f_nsyms == 0 || (!need_symbols && !need_reloc)) return TRUE;
+
+ /*------------------------------------------------------------------------*/
+ /* ALLOCATE THE RELOCATION SYMBOL TABLE. */
+ /*------------------------------------------------------------------------*/
+ if (need_reloc)
+ {
+ reloc_sym_index = 0;
+ reloc_tab_size = MIN(RELOC_TAB_START, (int)file_hdr.f_nsyms);
+
+ if (!(reloc_tab = (RELOC_TAB *)malloc(reloc_tab_size*sizeof(RELOC_TAB))))
+ { load_err = E_ALLOC; return FALSE; }
+ }
+
+ /*------------------------------------------------------------------------*/
+ /* IF THE APPLICATION NEEDS THE SYMBOL TABLE, LET IT READ IT IN. */
+ /* PASS NEED_RELOC TO THE APPLICATION SO THAT IT CAN CALL RELOC_ADD(). */
+ /*------------------------------------------------------------------------*/
+ if (need_symbols)
+ {
+ if (load_syms(need_reloc)) return TRUE;
+ else { load_err = E_SYM; return FALSE; }
+ }
+
+ /*------------------------------------------------------------------------*/
+ /* READ THE SYMBOL TABLE AND BUILD THE RELOCATION SYMBOL TABLE */
+ /* FOR SYMBOLS THAT CAN BE USED IN RELCOATION, STORE THEM IN A */
+ /* SPECIAL SYMBOL TABLE THAT CAN BE SEARCHED QUICKLY DURING */
+ /* RELOCATION. */
+ /*------------------------------------------------------------------------*/
+ for (first = 0; first < file_hdr.f_nsyms; first = next)
+ {
+ if (!(next = sym_read(first, &sym, &aux)))
+ { load_err = E_FILE; return FALSE; }
+
+ if (sym.n_sclass == C_EXT || sym.n_sclass == C_EXTREF ||
+ sym.n_sclass == C_STAT || sym.n_sclass == C_LABEL ||
+ sym.n_sclass == C_SYSTEM || sym.n_sclass == C_BLOCK ||
+ sym.n_sclass == C_FCN || sym.n_sclass == C_STATLAB ||
+ sym.n_sclass == C_EXTLAB)
+ if (!reloc_add(first, &sym)) return FALSE;
+ }
+ return TRUE;
+}
+
+
+/******************************************************************************/
+/* */
+/* CLOAD_STRINGS() - Read in the string table. */
+/* */
+/******************************************************************************/
+int cload_strings()
+{
+ unsigned int str_size; /* SIZE OF STRING TABLE */
+ unsigned int bufsize; /* SIZE OF CURRENT BUFFER */
+ unsigned int ntoread; /* AMOUNT TO READ FROM FILE */
+ int excess; /* AMOUNT LEFT OVER FROM LAST BUFFER */
+ STRTAB *packet; /* STRING TABLE BUFFER PACKET */
+ unsigned int i = 0;
+
+ /*----------------------------------------------------------------------*/
+ /* Do not load if not loading/saving the symbol tables. */
+ /* This is because the string table is an extension of the symbol table */
+ /* and if you free and rebuild it, the symbol table's str_head will be */
+ /* incorrect. */
+ /*----------------------------------------------------------------------*/
+ if (!need_symbols) return TRUE;
+
+ /*------------------------------------------------------------------------*/
+ /* FREE ANY PREVIOUS STRING BUFFERS */
+ /*------------------------------------------------------------------------*/
+ str_free(str_head); str_head = NULL;
+
+ /*------------------------------------------------------------------------*/
+ /* SEEK TO THE END OF THE SYMBOL TABLE AND READ IN THE SIZE OF THE STRING */
+ /* TABLE. */
+ /*------------------------------------------------------------------------*/
+#if FILE_BASED
+ if ((file_hdr.f_nsyms == 0) ||
+ fseek(fin, file_hdr.f_symptr + (file_hdr.f_nsyms * SYMESZ), 0) != 0 ||
+ fread(&str_size, sizeof(int), 1, fin) != 1)
+ return TRUE;
+#else
+ mem_copy(&str_size, &gRxBuffer[file_hdr.f_symptr + (file_hdr.f_nsyms * SYMESZ)], sizeof(int));
+ if ((file_hdr.f_nsyms == 0))
+ return TRUE;
+#endif
+ if (byte_swapped) swap4byte(&str_size);
+
+ /*------------------------------------------------------------------------*/
+ /* THE STRING TABLE IS READ IN AS A LINKED LIST OF BUFFERS. TO */
+ /* PREVENT NAMES FROM BEING SPLIT ACROSS MULTIPLE BUFFERS, ANY PARTIAL */
+ /* NAME AT THE END OF A BUFFER IS COPIED INTO THE BEGINNING OF THE */
+ /* NEXT BUFFER. THE VARIABLE 'EXCESS' KEEPS TRACK OF HOW MUCH NEEDS */
+ /* TO BE COPIED FROM THE PREVIOUS BUFFER. */
+ /*------------------------------------------------------------------------*/
+ str_size -= 4; /* SUBTRACT OFF 4 BYTES ALREADY READ */
+ excess = 0; /* INITIALIZE LAST-BUFFER OVERFLOW */
+
+
+ /*------------------------------------------------------------------------*/
+ /* READ STRING BUFFERS UNTIL THE WHOLE STRING TABLE IS READ. */
+ /*------------------------------------------------------------------------*/
+ while (str_size)
+ {
+ /*---------------------------------------------------------------------*/
+ /* ALLOCATE A NEW BUFFER. ON 16-BIT MACHINES, RESTRICT THE */
+ /* BUFFER SIZE TO THE MAXIMUM THAT CAN BE ALLOCATED AT ONCE. */
+ /*---------------------------------------------------------------------*/
+ bufsize = str_size + excess;
+
+ if (sizeof(int) < 4 && bufsize > MAX_STRING_ALLOC)
+ bufsize = MAX_STRING_ALLOC;
+
+ if (!(packet = (struct strtab *)malloc(sizeof(STRTAB) +
+ (unsigned int)bufsize - 1)))
+ { load_err = E_ALLOC; return FALSE; }
+
+ /*---------------------------------------------------------------------*/
+ /* COPY ANY PARTIAL STRING FROM THE LAST BUFFER INTO THIS ONE. */
+ /* THEN FILL THE REST OF THE BUFFER BY READING FROM THE FILE. */
+ /*---------------------------------------------------------------------*/
+ if (excess)
+ strn_copy(packet->buf, str_head->buf + str_head->size, excess);
+
+ ntoread = (unsigned int)(bufsize - excess);
+#if FILE_BASED
+ if (fread(packet->buf + excess, ntoread, 1, fin) != 1)
+ { load_err = E_FILE; return FALSE; }
+#else
+ mem_copy(packet->buf + excess, &gRxBuffer[file_hdr.f_symptr + (file_hdr.f_nsyms * SYMESZ) +sizeof(int)+ i++*ntoread], ntoread);
+#endif
+ str_size -= ntoread;
+
+ /*---------------------------------------------------------------------*/
+ /* IF THE BUFFER ENDS IN A PARTIAL STRING (DOESN'T END IN NULL), */
+ /* KEEP TRACK OF HOW MANY CHARACTERS ARE IN THE PARTIAL STRING */
+ /* SO THEY CAN BE COPIED INTO THE NEXT BUFFER. */
+ /*---------------------------------------------------------------------*/
+ for (excess = 0; packet->buf[bufsize - 1]; --bufsize, ++excess) ;
+
+ /*---------------------------------------------------------------------*/
+ /* LINK THE NEW BUFFER INTO THE HEAD OF THE LIST. */
+ /*---------------------------------------------------------------------*/
+ packet->size =
+ packet->index = bufsize;
+ packet->next = str_head;
+ packet->offset = str_head ? (str_head->offset + str_head->size) : 4;
+ str_head = packet;
+ }
+ return TRUE;
+}
+
+\f
+/******************************************************************************/
+/* */
+/* STR_FREE() - Free the list of string table buffers. */
+/* */
+/******************************************************************************/
+void str_free(STRTAB *head)
+{
+ STRTAB *this_one, *next;
+ for (this_one = head; this_one; this_one = next)
+ {
+ next = this_one->next;
+ free(this_one);
+ }
+}
+
+
+
+/******************************************************************************/
+/* */
+/* SYM_READ() - Read and relocate a symbol and its aux entry. Return the */
+/* index of the next symbol. */
+/* */
+/******************************************************************************/
+int sym_read(int index, SYMENT *sym, AUXENT *aux)
+{
+ /*------------------------------------------------------------------------*/
+ /* READ IN A SYMBOL AND ITS AUX ENTRY. */
+ /*------------------------------------------------------------------------*/
+#if FILE_BASED
+ if (fseek(fin, file_hdr.f_symptr + (index * SYMESZ), 0) != 0 ||
+ fread(sym, SYMESZ, 1, fin) != 1 ||
+ (sym->n_numaux && fread(aux, SYMESZ, 1, fin) != 1))
+ { load_err = E_FILE; return FALSE; }
+#else
+ mem_copy((void*)sym, (void*)&gRxBuffer[file_hdr.f_symptr + (index * SYMESZ)], SYMESZ);
+ if (sym->n_numaux)
+ {
+ mem_copy((void*)aux, (void*)&gRxBuffer[file_hdr.f_symptr + ( (index+1) * SYMESZ)], SYMESZ);
+ load_err = E_FILE;
+ return FALSE;
+ }
+#endif
+ if (byte_swapped)
+ {
+ /*--------------------------------------------------------------------*/
+ /* SWAP THE SYMBOL TABLE ENTRY. */
+ /*--------------------------------------------------------------------*/
+ if (sym->n_zeroes == 0) swap4byte(&sym->n_offset);
+ swap4byte(&sym->n_value);
+ swap2byte(&sym->n_scnum);
+ swap2byte(&sym->n_type);
+
+ /*--------------------------------------------------------------------*/
+ /* SWAP THE AUX ENTRY, BASED ON THE STORAGE CLASS. */
+ /*--------------------------------------------------------------------*/
+ if (sym->n_numaux) switch(sym->n_sclass)
+ {
+ case C_FILE : break;
+
+ case C_STRTAG :
+ case C_UNTAG :
+ case C_ENTAG : swap4byte(&aux->x_tag.x_fsize);
+ swap4byte(&aux->x_tag.x_endndx);
+ break;
+
+ case C_FCN : if (!str_comp(sym->n_name, ".bf"))
+ {
+ swap2byte(&aux->x_block.x_lcnt);
+ swap4byte(&aux->x_block.x_regmask);
+ swap4byte(&aux->x_block.x_framesize);
+ }
+
+ case C_BLOCK : swap2byte(&aux->x_block.x_lnno);
+ swap4byte(&aux->x_block.x_endndx);
+ break;
+
+ case C_EOS : swap4byte(&aux->x_eos.x_fsize);
+ swap4byte(&aux->x_eos.x_tagndx);
+ break;
+
+ default : /*-------------------------------------------------*/
+ /* HANDLE FUNCTION DEFINITION SYMBOL */
+ /*-------------------------------------------------*/
+ if (((sym->n_type >> 4) & 3) == DCT_FCN)
+ {
+ swap4byte(&aux->x_func.x_tagndx);
+ swap4byte(&aux->x_func.x_fsize);
+ swap4byte(&aux->x_func.x_lnnoptr);
+ swap4byte(&aux->x_func.x_endndx);
+ }
+
+ /*-------------------------------------------------*/
+ /* HANDLE ARRAYS. */
+ /*-------------------------------------------------*/
+ else if (((sym->n_type >> 4) & 3) == DCT_ARY)
+ {
+ swap4byte(&aux->x_array.x_tagndx);
+ swap4byte(&aux->x_array.x_fsize);
+ swap2byte(&aux->x_array.x_dimen[0]);
+ swap2byte(&aux->x_array.x_dimen[1]);
+ swap2byte(&aux->x_array.x_dimen[2]);
+ swap2byte(&aux->x_array.x_dimen[3]);
+ }
+
+ /*-------------------------------------------------*/
+ /* HANDLE SECTION DEFINITIONS */
+ /*-------------------------------------------------*/
+ else if (sym->n_type == 0)
+ {
+ swap4byte(&aux->x_scn.x_scnlen);
+ swap2byte(&aux->x_scn.x_nreloc);
+ swap2byte(&aux->x_scn.x_nlinno);
+ }
+
+ /*-------------------------------------------------*/
+ /* HANDLE MISC SYMBOL RECORD */
+ /*-------------------------------------------------*/
+ else
+ {
+ swap4byte(&aux->x_sym.x_fsize);
+ swap4byte(&aux->x_sym.x_tagndx);
+ }
+ }
+ }
+
+ /*------------------------------------------------------------------------*/
+ /* RELOCATE THE SYMBOL, BASED ON ITS STORAGE CLASS. */
+ /*------------------------------------------------------------------------*/
+ switch(sym->n_sclass)
+ {
+ case C_SYSTEM :
+ case C_EXT :
+ case C_EXTREF :
+ case C_STAT :
+ case C_LABEL :
+ case C_BLOCK :
+ case C_FCN :
+ case C_STATLAB :
+ case C_EXTLAB :
+ /*------------------------------------------------------------------*/
+ /* IF THE SYMBOL IS UNDEFINED, CALL AN APPLICATION ROUTINE TO LOOK */
+ /* IT UP IN AN EXTERNAL SYMBOL TABLE. IF THE SYMBOL IS DEFINED, */
+ /* RELOCATE IT ACCORDING TO THE SECTION IT IS DEFINED IN. */
+ /*------------------------------------------------------------------*/
+ if (sym->n_scnum == 0)
+ lookup_sym((short)index, sym, aux);
+ else if (sym->n_scnum > 0)
+ {
+ if (sym->n_sclass == C_STATLAB || sym->n_sclass == C_EXTLAB)
+ sym->n_value += reloc_amount[sym->n_scnum - 1];
+ else sym->n_value += RUN_RELOC_AMOUNT(sym->n_scnum - 1);
+ }
+ }
+
+ return (index + sym->n_numaux + 1);
+}
+
+\f
+/******************************************************************************/
+/* */
+/* SYM_NAME() - Return a pointer to the name of a symbol in either the symbol */
+/* entry or the string table. */
+/* */
+/******************************************************************************/
+char *sym_name(SYMENT *symptr)
+{
+ static char temp[9];
+
+ if (symptr->n_zeroes == 0)
+ {
+ STRTAB *packet = str_head;
+
+ /*---------------------------------------------------------------------*/
+ /* Return the empty string if this symbol has no name (offset == 0) */
+ /*---------------------------------------------------------------------*/
+ if (symptr->n_offset < 4) /* Anything below 4 isn't valid */
+ {
+ temp[0] = 0;
+ return temp;
+ }
+
+ /*---------------------------------------------------------------------*/
+ /* Otherwise, return the string in the string table. */
+ /*---------------------------------------------------------------------*/
+ while (packet && symptr->n_offset < (int)packet->offset)
+ packet = packet->next;
+
+ /*---------------------------------------------------------------------*/
+ /* Return the empty string if packet NULL (invalid offset) */
+ /*---------------------------------------------------------------------*/
+ if (!packet)
+ {
+ temp[0] = 0;
+ return temp;
+ }
+
+ return packet->buf + (symptr->n_offset - packet->offset);
+ }
+
+ strn_copy(temp, symptr->n_name, 8);
+ temp[8] = 0;
+ return temp;
+}
+
+
+/******************************************************************************/
+/* */
+/* SYM_ADD_NAME() - Given a symbol table entry, return a pointer to the */
+/* symbol's name in the string table. Add the name to the */
+/* table if it's not already there. */
+/* */
+/******************************************************************************/
+char *sym_add_name(SYMENT *symptr)
+{
+ char *dest;
+ char *result;
+ int i;
+
+ /*------------------------------------------------------------------------*/
+ /* IF THE SYMBOL'S NAME WAS IN THE COFF STRING TABLE, LOOK THROUGH THE */
+ /* LIST OF STRING TABLE BUFFERS UNTIL FINDING THE ONE THE NAME IS IN, */
+ /* AND SIMPLY POINT INTO THE BUFFER. */
+ /*------------------------------------------------------------------------*/
+ if (symptr->n_zeroes == 0)
+ return sym_name(symptr);
+
+ /*------------------------------------------------------------------------*/
+ /* OTHERWISE ADD THE STRING TO THE STRING TABLE. */
+ /* ALLOCATE AND LINK IN A NEW PACKET IF NECESSARY. NEW PACKETS ARE */
+ /* LINKED TO THE HEAD OF THE LIST TO EASE ADDING NEW SYMBOLS. */
+ /*------------------------------------------------------------------------*/
+ if (!str_head || str_head->index + SYMNMLEN + 1 > str_head->size)
+ {
+ STRTAB *packet;
+
+ if (!(packet = (STRTAB *)malloc(sizeof(STRTAB) + MIN_STRING_ALLOC - 1)))
+ { load_err = E_ALLOC; return NULL; }
+
+ packet->size = MIN_STRING_ALLOC;
+ packet->index = 0;
+ packet->next = str_head;
+ packet->offset = str_head ? (str_head->offset + str_head->size) : 4;
+ str_head = packet;
+ }
+
+ /*------------------------------------------------------------------------*/
+ /* COPY THE NAME INTO THE STRING TABLE. */
+ /*------------------------------------------------------------------------*/
+ result = dest = str_head->buf + str_head->index;
+ for (i = 0; *dest++ = symptr->n_name[i++]; )
+ if (i == SYMNMLEN) { *dest++ = '\0'; ++i; break; }
+
+ symptr->n_zeroes = 0;
+ symptr->n_offset = str_head->offset + str_head->index;
+ str_head->index += i;
+ return result;
+}
+#endif
+
+/******************************************************************************/
+/* */
+/* RELOC_ADD() - Add an entry to the relocation symbol table. This table */
+/* stores relocation information for each relocatable symbol. */
+/* */
+/******************************************************************************/
+int reloc_add(int index, SYMENT *sym)
+{
+ int disp; /* RELOCATION AMOUNT FOR THIS SYMBOL */
+
+ if (!need_reloc) return TRUE;
+
+ /*-------------------------------------------------------------------------*/
+ /* USE THE SYMBOL VALUE TO CALCULATE THE RELOCATION AMOUNT: */
+ /* 1) IF THE SYMBOL WAS UNDEFINED (DEFINED IN SECTION 0), USE THE */
+ /* SYMBOL'S VALUE. */
+ /* 2) IF THE SYMBOL HAS A POSITIVE SECTION NUMBER, USE THE RELOCATION */
+ /* AMOUNT FOR THE SECTION IN WHICH THE SYMBOL IS DEFINED. */
+ /* 3) OTHERWISE, THE SYMBOL IS ABSOLUTE, SO THE RELOCATION AMOUNT IS 0. */
+ /*-------------------------------------------------------------------------*/
+ if (sym->n_scnum == 0)
+ disp = sym->n_value;
+ else if (sym->n_scnum > 0)
+ {
+ if (sym->n_sclass == C_STATLAB || sym->n_sclass == C_EXTLAB)
+ disp = reloc_amount[sym->n_scnum - 1];
+ else disp = RUN_RELOC_AMOUNT(sym->n_scnum - 1);
+ }
+ else disp = 0;
+
+ /*-------------------------------------------------------------------------*/
+ /* IF THERE IS A NON-ZERO RELOCATION AMOUNT, ADD THE SYMBOL TO THE TABLE. */
+ /*-------------------------------------------------------------------------*/
+ if (disp == 0) return TRUE;
+
+ if (reloc_sym_index >= reloc_tab_size)
+ {
+ reloc_tab_size += RELOC_GROW_SIZE;
+ reloc_tab = (RELOC_TAB *)realloc((char *)reloc_tab,
+ reloc_tab_size*sizeof(RELOC_TAB));
+
+ if (!reloc_tab) { load_err = E_ALLOC; return FALSE; }
+ }
+ reloc_tab[reloc_sym_index ].rt_index = index;
+ reloc_tab[reloc_sym_index++].rt_disp = disp;
+
+ return TRUE;
+}
+
+/******************************************************************************/
+/* */
+/* RELOCATE() - Perform a single relocation by patching the raw data. */
+/* */
+/******************************************************************************/
+int relocate(RELOC *rp, unsigned char *data, int s)
+{
+/* RELOC *rp; RELOCATION ENTRY */
+/* unsigned char *data; DATA BUFFER */
+/* int s; INDEX OF CURRENT SECTION */
+ int fieldsz = reloc_size(rp->r_type); /* SIZE OF ACTUAL PATCH VALUE */
+ int offset = reloc_offset(rp->r_type); /* OFFSET OF ACTUAL PATCH VALUE */
+ int wordsz = MAX(fieldsz, reloc_stop(rp->r_type)); /* SIZE CONTAINING FLD */
+ int objval; /* FIELD TO BE PATCHED */
+ int reloc_amt; /* AMOUNT OF RELOCATION */
+
+ int pp_shift_cnt = 0;
+ int pp_local = FALSE;
+
+ if (rp->r_type == R_ABS) return TRUE; /* NOTHING TO DO */
+
+ /*-------------------------------------------------------------------------*/
+ /* DETERMINE THE RELOCATION AMOUNT FROM THE RELOCATION SYMBOL TABLE. */
+ /*-------------------------------------------------------------------------*/
+ reloc_amt = (rp->r_symndx == -1) ? RUN_RELOC_AMOUNT(s)
+ : sym_reloc_amount(rp);
+
+ /*-------------------------------------------------------------------------*/
+ /* EXTRACT THE RELOCATABLE FIELD FROM THE OBJECT DATA. */
+ /*-------------------------------------------------------------------------*/
+ objval = unpack(data, fieldsz, wordsz, offset + BIT_OFFSET(rp->r_vaddr));
+
+ /*-------------------------------------------------------------------------*/
+ /* MODIFY THE FIELD BASED ON THE RELOCATION TYPE. */
+ /*-------------------------------------------------------------------------*/
+ switch (rp->r_type)
+ {
+ /*----------------------------------------------------------------------*/
+ /* NORMAL RELOCATIONS: ADD IN THE RELOCATION AMOUNT. */
+ /*----------------------------------------------------------------------*/
+ case R_RELBYTE:
+ case R_RELWORD:
+ case R_REL24:
+ case R_RELLONG:
+ case R_DIR32:
+ case R_PARTLS16:
+ objval += reloc_amt;
+ break;
+
+ /*--------------------------------------------------------------------*/
+ /* ADD IN THE RELOCATION AMOUNT, BUT MAKE SURE WE'RE STILL IN THE */
+ /* 370'S REGISTER FILE. */
+ /*--------------------------------------------------------------------*/
+ case R_RRNREG:
+ case R_RRRELREG:
+ if (rp->r_type == R_RRNREG)
+ objval = ((char)objval + reloc_amt);
+ else objval += reloc_amt;
+
+ if (objval & ((-1L >> 8*fieldsz) << 8*fieldsz))
+ {
+ /* ERROR */
+ }
+
+ break;
+
+ /*--------------------------------------------------------------------*/
+ /* PP UNSCALED 15-BIT OFFSET RELOCATION. */
+ /*--------------------------------------------------------------------*/
+ case R_PP15 :
+ case R_PPL15 :
+ case R_PPN15 :
+ case R_PPLN15 :
+ {
+ int bit;
+ char *sname = (SECT_HDR(s)->s_zeroes == 0L) ?
+ SECT_HDR(s)->s_nptr : SNAMECPY(SECT_HDR(s)->s_name);
+
+ pp_local = (rp->r_type == R_PPL15) || (rp->r_type == R_PPLN15);
+
+ /*--------------------------------------------------------------*/
+ /* IF NEGATIVE RELOC TYPE, THEN TREAT CONST OFFSET AS A NEGATIVE*/
+ /*--------------------------------------------------------------*/
+ if (rp->r_type == R_PPN15 || rp->r_type == R_PPLN15)
+ {
+ objval = -objval;
+ rp->r_type -= 010; /* CHANGE TYPE TO NON NEG. */
+ }
+
+ objval += reloc_amt;
+
+ /*--------------------------------------------------------------*/
+ /* IF THE ADDRESS STILL FALLS WITHIN AN APPROPRIATE RANGE */
+ /*--------------------------------------------------------------*/
+ if ((objval >= 0x00000000 && objval <= 0x00007fff) ||
+ (objval >= 0x01000000 && objval <= 0x010007ff) )
+ break;
+
+ /*--------------------------------------------------------------*/
+ /* IF THE ADDRESS FALLS OUTSIDE AN APPROPRIATE RANGE, BUT CAN */
+ /* BE SCALED BY SIZE TO GET BACK INTO RANGE, THEN READ THE UPPER*/
+ /* BIT OF THE SIZE FIELD. IF IT IS A 1, THEN WE CAN SCALE THIS */
+ /* OFFSET BY 4, IF IT IS 0, THEN WE CAN SCALE THIS OFFSET BY 2. */
+ /*--------------------------------------------------------------*/
+ bit = unpack(data, 1, 64, pp_local ? 30 : 8);
+
+ /*--------------------------------------------------------------*/
+ /* DETERMINE IF THE OFFSET IS ALIGNED FOR SCALING. IF SO, */
+ /* THEN PACK THE SCALED OFFSET INTO INSTRUCTION, CHANGE THE */
+ /* RELOC TYPE TO SCALED, AND TURN ON SCALE BIT IN INSTRUCT. */
+ /*--------------------------------------------------------------*/
+ if (!(objval & ((2<<bit)-1)) &&
+ (objval >>= (bit+1)) >= 0 && objval <= 0x7fff)
+ {
+ rp->r_type = pp_local ? (bit ? R_PPL15W : R_PPL15H) :
+ (bit ? R_PP15W : R_PP15H);
+ repack(1, data, 1, 64, pp_local ? 28 : 6);
+ break;
+ }
+
+ /*--------------------------------------------------------------*/
+ /* ERROR, THE OFFSET WILL NOT FIT SCALED OR UNSCALED. */
+ /*--------------------------------------------------------------*/
+
+ load_err = E_RELOCENT;
+ return FALSE;
+ }
+
+ /*--------------------------------------------------------------------*/
+ /* PP SCALED 15-BIT OFFSET RELOCATION. FOR R_PP15W THE RELOC_AMT IS */
+ /* DIVIDED BY 4. FOR R_PP15H THE RELOC_AMT IS DIVIDED BY 2. */
+ /*--------------------------------------------------------------------*/
+ case R_PP15W :
+ case R_PPL15W :
+ case R_PPN15W :
+ case R_PPLN15W : pp_shift_cnt++; /* FALL THROUGH */
+
+ case R_PP15H :
+ case R_PPL15H :
+ case R_PPN15H :
+ case R_PPLN15H : pp_shift_cnt++; /* FALL THROUGH */
+ {
+ int obj_addr_x;
+ char *sname = (SECT_HDR(s)->s_zeroes == 0) ?
+ SECT_HDR(s)->s_nptr : SNAMECPY(SECT_HDR(s)->s_name);
+
+ /*--------------------------------------------------------------*/
+ /* NOTE THAT THIS IS DEPENDENT ON THE NUMBERING OF THESE RELOC */
+ /* VALUES. */
+ /*--------------------------------------------------------------*/
+ pp_local = (rp->r_type & 4);
+
+ /*--------------------------------------------------------------*/
+ /* IF NEGATIVE RELOC TYPE, THEN TREAT CONST OFFSET AS NEGATIVE */
+ /*--------------------------------------------------------------*/
+ if (rp->r_type >= R_PPN15)
+ {
+ objval = -objval;
+ rp->r_type -= 010; /* CHANGE TYPE TO NON NEG. */
+ }
+
+ obj_addr_x = (objval << pp_shift_cnt) + reloc_amt;
+
+ /*--------------------------------------------------------------*/
+ /* LINK TIME ADDRESS VIOLATES THE SCALING FACTOR WE ARE USING */
+ /* FOR THIS OPERAND. UNSCALE THE VALUE IF IT WILL FIT IN 15 BITS*/
+ /* BY CHANGING RELOC TYPE TO UNSCALED, AND CHANGING SCALE BIT */
+ /* IN THE INSTRUCTION. */
+ /*--------------------------------------------------------------*/
+ if (pp_shift_cnt && (reloc_amt & ((1<<pp_shift_cnt)-1)))
+ {
+ objval = obj_addr_x;
+ rp->r_type = (pp_local ? R_PPL15 : R_PP15);
+ repack(0, data, 1, 64, pp_local ? 28 : 6);
+ }
+ else objval = obj_addr_x >> pp_shift_cnt;
+
+ /*--------------------------------------------------------------*/
+ /* IF THE ADDRESS STILL FALLS WITHIN AN APPROPRIATE RANGE */
+ /*--------------------------------------------------------------*/
+ if ((objval >= 0x00000000 && objval <= 0x00007fff) ||
+ (obj_addr_x >= 0x01000000 && obj_addr_x <= 0x010007ff) )
+ break;
+
+ /*--------------------------------------------------------------*/
+ /* ERROR, THE OFFSET WILL NOT FIT SCALED OR UNSCALED. */
+ /*--------------------------------------------------------------*/
+
+ load_err = E_RELOCENT;
+ return FALSE;
+ }
+
+ /*--------------------------------------------------------------------*/
+ /* PP 16-bit byte offset relocation. For R_PP16B the lower 15-bits */
+ /* are handled just like R_PP15, and the upper bit is placed in the */
+ /* scale indicator bit of the field. */
+ /*--------------------------------------------------------------------*/
+ case R_PP16B :
+ case R_PPL16B :
+ case R_PPN16B :
+ case R_PPLN16B :
+ {
+ char *sname = (SECT_HDR(s)->s_zeroes == 0) ?
+ SECT_HDR(s)->s_nptr : SNAMECPY(SECT_HDR(s)->s_name);
+
+ pp_local = (rp->r_type == R_PPL16B) || (rp->r_type == R_PPLN16B);
+
+ /*--------------------------------------------------------------*/
+ /* READ THE SCALE BIT (16th BIT) AND CREATE 16 BIT CONSTANT OFF */
+ /*--------------------------------------------------------------*/
+ objval |= (unpack(data, 1, 64, pp_local ? 28 : 6) << 15);
+
+ /*--------------------------------------------------------------*/
+ /* IF NEGATIVE RELOC TYPE, THEN TREAT CONST OFFSET AS NEGATIVE */
+ /*--------------------------------------------------------------*/
+ if (rp->r_type == R_PPN16B || rp->r_type == R_PPLN16B)
+ {
+ objval = - objval;
+ rp->r_type -= 010; /* CHANGE THE TYPE TO A NON NEG TYPE. */
+ }
+
+ objval += reloc_amt;
+
+ /*--------------------------------------------------------------*/
+ /* IF THE ADDRESS STILL FALLS WITHIN AN APPROPRIATE RANGE */
+ /*--------------------------------------------------------------*/
+ if ((objval >= 0x00000000 && objval <= 0x0000ffff) ||
+ (objval >= 0x01000000 && objval <= 0x010007ff) )
+ {
+ /*-----------------------------------------------------------*/
+ /* RELOCATE THE 16TH BIT OF THE ADDRESS. */
+ /*-----------------------------------------------------------*/
+ repack(((objval&0x8000) >> 15), data, 1, 64, pp_local ? 28 : 6);
+ break;
+ }
+
+ /*--------------------------------------------------------------*/
+ /* ADDRESS IS OUT OF RANGE. */
+ /*--------------------------------------------------------------*/
+
+ load_err = E_RELOCENT;
+ return FALSE;
+ }
+
+ /*--------------------------------------------------------------------*/
+ /* PP BASE ADDRESS RELOCATION. BIT 0 IS 0 IF IN DATA RAM, 1 IF IN */
+ /* PARAMETER RAM. THIS CODE ASSUMES THAT WE DO NOT RELOCATE FROM */
+ /* PRAM TO DRAM OR FROM DRAM TO PRAM AT LOAD TIME. */
+ /*--------------------------------------------------------------------*/
+ case R_PPLBASE: pp_local = TRUE;
+ case R_PPBASE:
+ {
+ /*---------------------------------------------------------------*/
+ /* IF WAS DRAM AND RELOC_AMT IS GREAT ENOUGH TO MOVE INTO PRAM, */
+ /* CHANGE TO PRAM */
+ /*---------------------------------------------------------------*/
+ if (!objval && reloc_amt > (int)(0x01000000 - 0xC000)) objval = 1;
+
+ /*---------------------------------------------------------------*/
+ /* IF WAS PRAM AND RELOC_AMT IS NEGATIVE AND CAN MOVE INTO DRAM, */
+ /* CHANGE TO DRAM */
+ /*---------------------------------------------------------------*/
+ else if (objval && (-reloc_amt) > (int)(0x01000000 - 0xC000))
+ objval = 0;
+
+ break;
+ }
+
+ /*----------------------------------------------------------------------*/
+ /* 34010 ONE'S COMPLEMENT RELOCATION. SUBTRACT INSTEAD OF ADD. */
+ /*----------------------------------------------------------------------*/
+ case R_OCRLONG:
+ objval -= reloc_amt;
+ break;
+
+ /*----------------------------------------------------------------------*/
+ /* 34020 WORD-SWAPPED RELOCATION. SWAP BEFORE RELOCATING. */
+ /*----------------------------------------------------------------------*/
+ case R_GSPOPR32:
+ case R_OCBD32:
+ objval = ((objval >> 16) & 0xFFFF) | (objval << 16);
+ objval += (rp->r_type == R_GSPOPR32) ? reloc_amt : -reloc_amt;
+ objval = ((objval >> 16) & 0xFFFF) | (objval << 16);
+ break;
+
+ /*----------------------------------------------------------------------*/
+ /* PC-RELATIVE RELOCATIONS. IN THIS CASE THE RELOCATION AMOUNT */
+ /* IS ADJUSTED BY THE PC DIFFERENCE. IF THIS IS AN INTERNAL */
+ /* RELOCATION TO THE CURRENT SECTION, NO ADJUSTMENT IS NEEDED. */
+ /*----------------------------------------------------------------------*/
+ case R_PCRBYTE:
+ case R_PCRWORD:
+ case R_GSPPCR16:
+ case R_GSPPCA16:
+ case R_PCRLONG:
+ case R_PCR24:
+ case R_ANKPCR16:
+ case R_ANKPCR8:
+ {
+ int shift = 8 * (4 - fieldsz);
+ unsigned int pcdif = RUN_RELOC_AMOUNT(s);
+
+ /*----------------------------------------------------------------*/
+ /* HANDLE SPECIAL CASES OF JUMPING FROM ABSOLUTE SECTIONS (SPECIAL*/
+ /* RELOC TYPE) OR TO ABSOLUTE DESTINATION (SYMNDX == -1). IN */
+ /* EITHER CASE, SET THE APPROPRIATE RELOCATION AMOUNT TO 0. */
+ /*----------------------------------------------------------------*/
+ if( rp->r_symndx == -1 ) reloc_amt = 0;
+ if( rp->r_type == R_GSPPCA16) pcdif = 0;
+
+ /*----------------------------------------------------------------*/
+ /* Handle ankoor's offset where upper 14 (PCR8) and upper 6(PCR16)*/
+ /* bits of 22 bit address is held in r_disp field of reloc entry */
+ /*----------------------------------------------------------------*/
+ if(rp->r_type == R_ANKPCR8 || rp->r_type == R_ANKPCR16)
+ {
+ shift = 10;
+ objval |= rp->r_disp << ((rp->r_type == R_ANKPCR8) ? 8 : 16);
+ }
+
+ reloc_amt -= pcdif;
+
+ if (rp->r_type == R_GSPPCR16 || rp->r_type == R_GSPPCA16)
+ reloc_amt >>= 4; /* BITS TO WORDS */
+
+ objval = (int)(objval << shift) >> shift; /* SIGN EXTEND */
+ objval += reloc_amt;
+ break;
+ }
+
+ /*--------------------------------------------------------------------*/
+ /* Ankoor page-addressing. Calculate address from the 22-bit */
+ /* value in the relocation field plus the relocation amount. Shift */
+ /* out the lower 16 bits. */
+ /*--------------------------------------------------------------------*/
+ case R_PARTMS6:
+ objval = (objval & 0xC0) |
+ (((rp->r_disp += reloc_amt) >> 16) & 0x3F);
+ break;
+
+ /*----------------------------------------------------------------------*/
+ /* 320C30 PAGE-ADDRESSING RELOCATION. CALCULATE THE ADDRESS FROM */
+ /* THE 8-BIT PAGE VALUE IN THE FIELD, THE 16-BIT OFFSET IN THE RELOC */
+ /* ENTRY, AND THE RELOCATION AMOUNT. THEN, STORE THE 8-BIT PAGE */
+ /* VALUE OF THE RESULT BACK IN THE FIELD. */
+ /*----------------------------------------------------------------------*/
+ case R_PARTMS8:
+ objval = (int)((objval << 16) + rp->r_disp + reloc_amt) >> 16;
+ break;
+
+ /*----------------------------------------------------------------------*/
+ /* DSP(320) PAGE-ADDRESSING. CALCULATE ADDRESS FROM THE 16-BIT */
+ /* VALUE IN THE RELOCATION FIELD PLUS THE RELOCATION AMOUNT. OR THE */
+ /* TOP 9 BITS OF THIS RESULT INTO THE RELOCATION FIELD. */
+ /*----------------------------------------------------------------------*/
+ case R_PARTMS9:
+ objval = (objval & 0xFE00) |
+ (((int)(rp->r_disp + reloc_amt) >> 7) & 0x1FF);
+ break;
+
+ /*----------------------------------------------------------------------*/
+ /* DSP(320) PAGE-ADDRESSING. CALCULATE ADDRESS AS ABOVE, AND OR THE */
+ /* 7-BIT DISPLACEMENT INTO THE FIELD. */
+ /*----------------------------------------------------------------------*/
+ case R_PARTLS7:
+ objval = (objval & 0x80) | ((rp->r_disp + reloc_amt) & 0x7F);
+ break;
+
+ /*--------------------------------------------------------------------*/
+ /* Ankoor page-addressing. Calculate address from the 22-bit */
+ /* value in the relocation field plus the relocation amount. Mask off */
+ /* bits [21:16] and [5:0] to extract a data page within a 64K page */
+ /*--------------------------------------------------------------------*/
+ case R_PARTMID10:
+ objval = (objval & 0xFC00) |
+ (((rp->r_disp += reloc_amt) >> 6) & 0x3FF);
+ break;
+
+ /*--------------------------------------------------------------------*/
+ /* RR(370) MSB RELOCATION. CALCULATE ADDRESS FROM THE 16-BIT VALUE */
+ /* IN THE RELOCATION ENTRY PLUS THE RELOCATION AMOUNT. PATCH THE */
+ /* MSB OF THE RESULT INTO THE RELOCATION FIELD. */
+ /*--------------------------------------------------------------------*/
+ case R_HIWORD:
+ objval += (rp->r_disp += (unsigned short)reloc_amt) >> 8;
+ break;
+
+ /*--------------------------------------------------------------------*/
+ /* C8+ High byte of 24-bit address. Calculate address from 24-bit */
+ /* value in the relocation entry plus the relocation amount. Patch */
+ /* the MSB of the result into the relocation field. */
+ /*--------------------------------------------------------------------*/
+ case R_C8PHIBYTE:
+ objval = (int)((objval << 16) + rp->r_disp + reloc_amt) >> 16;
+ break;
+
+ /*--------------------------------------------------------------------*/
+ /* C8+ Middle byte of 24-bit address. Calculate address from 24-bit */
+ /* value in the relocation entry plus the relocation amount. Patch */
+ /* the middle byte of the result into the relocation field. */
+ /*--------------------------------------------------------------------*/
+ case R_C8PMIDBYTE:
+ objval = (int)((objval << 16) + rp->r_disp + reloc_amt) >> 8;
+ break;
+
+ /*--------------------------------------------------------------------*/
+ /* C8+ Vector Address. Calculate address from 24-bit value in the */
+ /* relocation entry plus the relocation amount. MSB must be 0xFF */
+ /* since interrupt and trap handlers must be programmed in the top- */
+ /* most segment of memory. Patch bottom 16-bits of the result into */
+ /* the relocation field. */
+ /*--------------------------------------------------------------------*/
+ case R_C8PVECADR:
+ objval += reloc_amt;
+ if ((objval & 0xFF0000) != 0xFF0000)
+ {
+ /* ERROR */
+ }
+ objval &= 0xFFFF;
+ break;
+
+ /*----------------------------------------------------------------------*/
+ /* C8+ 24-bit Address. The byte ordering for 24-bit addresses on the */
+ /* C8+ is reversed (low, middle, high). Needs to be unordered, add */
+ /* in reloc_amt, then re-ordered. */
+ /*----------------------------------------------------------------------*/
+ case R_C8PADR24:
+ objval = ((objval>>16) | (objval&0xff00) | ((objval&0xff)<<16));
+ objval += reloc_amt;
+ objval = ((objval>>16) | (objval&0xff00) | ((objval&0xff)<<16));
+ break;
+
+ /*----------------------------------------------------------------------*/
+ /* DSP(320) 13-BIT CONSTANT. RELOCATE ONLY THE LOWER 13 BITS OF THE */
+ /* FIELD. */
+ /*----------------------------------------------------------------------*/
+ case R_REL13:
+ objval = (objval & 0xE000) | ((objval + reloc_amt) & 0x1FFF);
+ break;
+
+ /*--------------------------------------------------------------------*/
+ /* ANKOOR 22-bit extended address. Calculate address by masking */
+ /* off the opcode and OR in the lower 16-bit constant + the */
+ /* amount. */
+ /*--------------------------------------------------------------------*/
+ case R_REL22:
+ {
+ unsigned int obj_hi = unpack(data , 16, 16, 0);
+ unsigned int obj_lo = unpack(data+2, 16, 16, 0);
+
+ /*--------------------------------------------------------------*/
+ /* BUILD THE OFFSET TO BE RELOCATED. */
+ /*--------------------------------------------------------------*/
+ objval = ((obj_hi & 0x003F) << 16) | (obj_lo & 0xFFFF);
+
+ /*--------------------------------------------------------------*/
+ /* Calculate displacement */
+ /*--------------------------------------------------------------*/
+ objval += reloc_amt;
+
+ /*--------------------------------------------------------------*/
+ /* REPACK THE RELOCATED VALUE BACK IN THE OBJECT VALUE. */
+ /*--------------------------------------------------------------*/
+ obj_hi = (obj_hi & 0xFFC0) | ((objval & 0x3F0000) >> 16);
+ obj_lo = objval & 0xFFFF;
+ repack(obj_hi, data , 16, 16, 0);
+ repack(obj_lo, data+2, 16, 16, 0);
+
+ return TRUE;
+ }
+
+ /*--------------------------------------------------------------------*/
+ /* DSP, LEAD 23-bit extended address. Calculate address by masking */
+ /* off the opcode and OR in the lower 16-bit constant + the */
+ /* amount. */
+ /*--------------------------------------------------------------------*/
+ case R_REL23:
+ {
+ unsigned int obj_hi = unpack(data , 16, 16, 0);
+ unsigned int obj_lo = unpack(data+2, 16, 16, 0);
+
+ /*--------------------------------------------------------------*/
+ /* BUILD THE OFFSET TO BE RELOCATED. */
+ /*--------------------------------------------------------------*/
+ objval = ((obj_hi & 0x007F) << 16) | (obj_lo & 0xFFFF);
+
+ /*--------------------------------------------------------------*/
+ /* Calculate displacement */
+ /*--------------------------------------------------------------*/
+ objval += reloc_amt;
+
+ /*--------------------------------------------------------------*/
+ /* REPACK THE RELOCATED VALUE BACK IN THE OBJECT VALUE. */
+ /*--------------------------------------------------------------*/
+ obj_hi = (obj_hi & 0xFF80) | ((objval & 0x7F0000) >> 16);
+ obj_lo = objval & 0xFFFF;
+ repack(obj_hi, data , 16, 16, 0);
+ repack(obj_lo, data+2, 16, 16, 0);
+
+ return TRUE;
+ }
+
+
+ /*----------------------------------------------------------------------*/
+ /* PRISM (370/16) code label relocation. Convert word address to byte */
+ /* address, add in relocation, convert back to word address. */
+ /*----------------------------------------------------------------------*/
+ case R_LABCOD:
+ objval = ((objval << 1) + reloc_amt) >> 1;
+ break;
+ }
+
+ /*-------------------------------------------------------------------------*/
+ /* PACK THE RELOCATED FIELD BACK INTO THE OBJECT DATA. */
+ /*-------------------------------------------------------------------------*/
+ repack(objval, data, fieldsz, wordsz, offset + BIT_OFFSET(rp->r_vaddr));
+ return TRUE;
+}
+
+
+/******************************************************************************/
+/* */
+/* RELOC_READ() - Read a single relocation entry. */
+/* */
+/******************************************************************************/
+#if FILE_BASED
+int reloc_read(RELOC *rptr)
+#else
+int reloc_read(RELOC *rptr, unsigned int offset)
+#endif
+{
+#if COFF_VERSION_1 || COFF_VERSION_2
+ /*------------------------------------------------------------------------*/
+ /* THE FOLLOWING UNION IS USED TO READ IN VERSION 0 OR 1 RELOC ENTRIES */
+ /*------------------------------------------------------------------------*/
+ /* THE FORMAT OF RELOCATION ENTRIES CHANGED BETWEEN COFF VERSIONS 0 AND 1.*/
+ /* VERSION 0 HAS A 16 BIT SYMBOL INDEX, WHILE VERSION 1 HAS A 32 BIT INDX.*/
+ /*------------------------------------------------------------------------*/
+ union { RELOC new_c; RELOC_OLD old; } input_entry;
+#if FILE_BASED
+ if (fread(&input_entry, RELSZ_IN(coff_version), 1, fin) != 1)
+ { load_err = E_FILE; return FALSE; }
+#else
+ mem_copy((void*)&input_entry, (void*)&gRxBuffer[offset], RELSZ_IN(coff_version));
+#endif
+ /*------------------------------------------------------------------------*/
+ /* IF LOADING A VERSION 0 FILE, TRANSLATE ENTRY TO VERSION 1 FORMAT. */
+ /* (THIS COULD BE SIMPLER - ALL THE SWAPS EXCEPT FOR THE SYMBOL INDEX */
+ /* COULD BE DONE AFTER THE TRANSLATION - BUT THIS SEEMS TO BE CLEARER) */
+ /*------------------------------------------------------------------------*/
+ if (ISCOFF_0(coff_version))
+ {
+ if (byte_swapped)
+ {
+ swap4byte(&input_entry.old.r_vaddr);
+ swap2byte(&input_entry.old.r_type);
+
+ /* if a field reloc, fields are chars, so don't swap */
+ if (!isfldrel(input_entry.old.r_type))
+ {
+ swap2byte(&input_entry.old.r_symndx);
+ swap2byte(&input_entry.old.r_disp);
+ }
+ }
+
+ rptr->r_vaddr = input_entry.old.r_vaddr;
+ rptr->r_symndx = input_entry.old.r_symndx;
+ rptr->r_disp = input_entry.old.r_disp;
+ rptr->r_type = input_entry.old.r_type;
+ }
+ else
+ {
+ *rptr = input_entry.new_c;
+
+ if (byte_swapped)
+ {
+ swap4byte(&rptr->r_vaddr);
+ swap2byte(&rptr->r_type);
+
+ /* Again, if a field reloc, fields are chars, so don't swap */
+ if (!isfldrel(rptr->r_type))
+ {
+ swap4byte(&rptr->r_symndx);
+ swap2byte(&rptr->r_disp);
+ }
+ }
+ }
+
+#else
+ /*-------------------------------------------------------------------------*/
+ /* READ IN AND BYTE SWAP AN VERSION 0 RELOC ENTRY */
+ /*-------------------------------------------------------------------------*/
+ if (fread(rptr, RELSZ, 1, fin) != 1) { load_err = E_FILE; return FALSE; }
+
+ if (byte_swapped)
+ {
+ swap4byte(&rptr->r_vaddr);
+ swap2byte(&rptr->r_type);
+
+ /* If a field reloc, fields are chars, so don't swap */
+ if (!isfldrel(rptr->r_type))
+ {
+ swap2byte(&rptr->r_symndx);
+ swap2byte(&rptr->r_disp);
+ }
+ }
+#endif
+
+ return TRUE;
+}
+
+
+/*************************************************************************/
+/* */
+/* RELOC_SIZE()- */
+/* Return the field size of a relocation type. */
+/* */
+/*************************************************************************/
+
+int reloc_size(int type)
+{
+ switch (type)
+ {
+ case R_PPBASE:
+ case R_PPLBASE: return 1;
+
+ case R_HIWORD:
+ case R_C8PHIBYTE:
+ case R_C8PMIDBYTE:
+ case R_RELBYTE:
+ case R_PCRBYTE:
+ case R_RRNREG:
+ case R_RRRELREG:
+ case R_ANKPCR8:
+ case R_PARTLS6:
+ case R_PARTMS6:
+ case R_PARTLS7: return 8;
+
+ case R_PP15:
+ case R_PP15W:
+ case R_PP15H:
+ case R_PP16B:
+ case R_PPN15:
+ case R_PPN15W:
+ case R_PPN15H:
+ case R_PPN16B:
+ case R_PPL15:
+ case R_PPL15W:
+ case R_PPL15H:
+ case R_PPL16B:
+ case R_PPLN15:
+ case R_PPLN15W:
+ case R_PPLN15H:
+ case R_PPLN16B: return 15;
+
+ case R_LABCOD:
+ case R_RELWORD:
+ case R_PCRWORD:
+ case R_ANKPCR16:
+ case R_GSPPCR16:
+ case R_GSPPCA16:
+ case R_PARTLS16:
+ case R_PARTMS8:
+ case R_PARTMS9:
+ case R_PARTMID10:
+ case R_PARTMS16:
+ case R_REL22:
+ case R_REL13:
+ case R_C8PVECADR: return 16;
+
+ case R_REL24:
+ case R_PCR24:
+ case R_PCR24W:
+ case R_C8PADR24: return 24;
+
+ case R_MPPCR:
+ case R_GSPOPR32:
+ case R_RELLONG:
+ case R_PCRLONG:
+ case R_OCBD32:
+ case R_OCRLONG:
+ case R_DIR32: return 32;
+
+ default: return 0;
+ }
+}
+
+
+/*************************************************************************/
+/* */
+/* RELOC_OFFSET()- */
+/* Return the offset of a relocation type field. The value of */
+/* offset should be the bit offset of the LSB of the field in */
+/* little-endian mode. */
+/* */
+/*************************************************************************/
+
+int reloc_offset(int type)
+{
+ switch (type)
+ {
+ case R_PP15 :
+ case R_PP15W :
+ case R_PP15H :
+ case R_PP16B :
+ case R_PPN15 :
+ case R_PPN15W :
+ case R_PPN15H :
+ case R_PPN16B :
+ case R_PPLBASE : return 22;
+
+ case R_PPL15 :
+ case R_PPL15W :
+ case R_PPL15H :
+ case R_PPL16B :
+ case R_PPLN15 :
+ case R_PPLN15W :
+ case R_PPLN15H :
+ case R_PPLN16B :
+ case R_PPBASE : return 0;
+
+ default : return 0;
+ }
+}
+
+
+/*************************************************************************/
+/* */
+/* RELOC_STOP() - */
+/* Return the number of bits to read for a relocation type. */
+/* */
+/*************************************************************************/
+
+int reloc_stop(int type)
+{
+ switch (type)
+ {
+ case R_PPBASE :
+ case R_PPLBASE :
+
+ case R_PP15 :
+ case R_PP15W :
+ case R_PP15H :
+ case R_PP16B :
+
+ case R_PPL15 :
+ case R_PPL15W :
+ case R_PPL15H :
+ case R_PPL16B :
+
+ case R_PPN15 :
+ case R_PPN15W :
+ case R_PPN15H :
+ case R_PPN16B :
+
+ case R_PPLN15 :
+ case R_PPLN15W :
+ case R_PPLN15H :
+ case R_PPLN16B : return 64;
+
+ default : return WORDSZ * 8;
+ }
+}
+
+
+/******************************************************************************/
+/* */
+/* SYM_RELOC_AMOUNT() - Determine the amount of relocation for a particular */
+/* relocation entry. Search the relocation symbol table */
+/* for the referenced symbol, and return the amount from */
+/* the table. */
+/* */
+/******************************************************************************/
+int sym_reloc_amount(RELOC *rp)
+{
+ int index = rp->r_symndx;
+
+ int i = 0,
+ j = reloc_sym_index - 1;
+
+ /*-------------------------------------------------------------------------*/
+ /* THIS IS A SIMPLE BINARY SEARCH (THE RELOC TABLE IS ALWAYS SORTED). */
+ /*-------------------------------------------------------------------------*/
+ while (i <= j)
+ {
+ int m = (i + j) / 2;
+ if (reloc_tab[m].rt_index < index) i = m + 1;
+ else if (reloc_tab[m].rt_index > index) j = m - 1;
+ else return reloc_tab[m].rt_disp; /* FOUND */
+ }
+
+ /*-------------------------------------------------------------------------*/
+ /* IF NOT FOUND, SYMBOL WAS NOT RELOCATED. */
+ /*-------------------------------------------------------------------------*/
+ return 0;
+}
+
+
+/******************************************************************************/
+/* */
+/* UNPACK() - Extract a relocation field from object bytes and convert into */
+/* a int so it can be relocated. */
+/* */
+/******************************************************************************/
+unsigned int unpack(unsigned char *data, int fieldsz, int wordsz, int bit_offset)
+{
+ register int i;
+ unsigned int objval;
+ int start; /* MS byte with reloc data */
+ int stop; /* LS byte with reloc data */
+ int r = bit_offset & 7; /* num unused LS bits in stop */
+ int l = 8 - r; /* num used MS bits in stop */
+ int tr = ((bit_offset+fieldsz-1) & 7)+1; /* # LS bits in strt*/
+ int tl = 8 - tr; /* num unused MS bits in start */
+
+ start = (big_e_target ? (wordsz-fieldsz-bit_offset) :
+ (bit_offset+fieldsz-1)) >>3;
+ stop = (big_e_target ? (wordsz-bit_offset-1) : bit_offset) >>3;
+
+ if (start == stop) return (data[stop] >> r) & ((0x1 << fieldsz) - 0x1);
+
+ objval = (unsigned)((data[start] << tl) & 0xFF) >> tl;
+
+ if (big_e_target)
+ for (i=start+1; i<stop; ++i) objval = (objval << 8) | data[i];
+ else for (i=start-1; i>stop; --i) objval = (objval << 8) | data[i];
+
+ return (objval << l) | (data[stop] >> r);
+}
+
+
+
+/******************************************************************************/
+/* */
+/* REPACK() - Encode a binary relocated field back into the object data. */
+/* */
+/******************************************************************************/
+void repack(unsigned int objval, unsigned char *data, int fieldsz,
+ int wordsz, int bit_offset)
+{
+ register int i;
+ int start; /* MS byte with reloc data */
+ int stop; /* LS byte with reloc data */
+ int r = bit_offset & 7; /* num unused LS bits in stop */
+ int l = 8 - r; /* num used MS bits in stop */
+ int tr = ((bit_offset+fieldsz-1) & 7)+1; /* # LS bits in strt */
+ unsigned int mask = (1ul << fieldsz) - 1ul;
+
+ if (fieldsz < sizeof(objval)) objval &= mask;
+
+ start = (big_e_target ? (wordsz-fieldsz-bit_offset) :
+ (bit_offset+fieldsz-1)) >>3;
+ stop = (big_e_target ? (wordsz-bit_offset-1) : bit_offset) >>3;
+
+ if (start == stop)
+ {
+ data[stop] &= ~(mask << r);
+ data[stop] |= (objval << r);
+ return;
+ }
+
+ data[start] &= ~((1<<tr)-1);
+ data[stop] &= ((1<< r)-1);
+ data[stop] |= (objval << r);
+ objval >>= l;
+
+ if (big_e_target)
+ for (i = stop - 1; i > start; objval >>= 8) data[i--] = objval;
+ else for (i = stop + 1; i < start; objval >>= 8) data[i++] = objval;
+
+ data[start] |= objval;
+}
+
+
+/******************************************************************************/
+/* */
+/* CLOAD_LINENO() - Read in, swap, and relocate line number entries. This */
+/* function is not called directly by the loader, but by the */
+/* application when it needs to read in line number entries. */
+/* */
+/******************************************************************************/
+int cload_lineno(int filptr, int count, LINENO *lptr, int scnum)
+{
+/* int filptr; WHERE TO READ FROM */
+/* int count; HOW MANY TO READ */
+/* LINENO *lptr; WHERE TO PUT THEM */
+/* int scnum; SECTION NUMBER OF THESE ENTRIES */
+
+ int i;
+
+ /*------------------------------------------------------------------------*/
+ /* READ IN THE REQUESTED NUMBER OF LINE NUMBER ENTRIES AS A BLOCK. */
+ /*------------------------------------------------------------------------*/
+#if FILE_BASED
+ if (fseek(fin, filptr, 0) != 0) { load_err = E_FILE; return FALSE; }
+ for (i = 0; i < count; i++)
+ if (fread(lptr + i, 1, LINESZ, fin) != LINESZ)
+ { load_err = E_FILE; return FALSE; }
+#else
+ for (i = 0; i < count; i++)
+ mem_copy((void*)(lptr+i), (void*)&gRxBuffer[filptr + i*LINESZ], LINESZ);
+#endif
+ /*------------------------------------------------------------------------*/
+ /* SWAP AND RELOCATE EACH ENTRY, AS NECESSARY. */
+ /*------------------------------------------------------------------------*/
+ if (byte_swapped || RUN_RELOC_AMOUNT(scnum - 1))
+ for (i = 0; i < count; i++, lptr++)
+ {
+ if (byte_swapped)
+ {
+ swap2byte(&lptr->l_lnno);
+ swap4byte(&lptr->l_addr.l_paddr);
+ }
+
+ if (lptr->l_lnno != 0)
+ lptr->l_addr.l_paddr += RUN_RELOC_AMOUNT(scnum - 1);
+ }
+
+ return TRUE;
+}
+
+
+/******************************************************************************/
+/* */
+/* SWAP4BYTE() - Swap the order of bytes in a int. */
+/* */
+/******************************************************************************/
+void swap4byte(void *addr)
+{
+ unsigned int *value = (unsigned int *)addr;
+ unsigned int temp1, temp2, temp3, temp4;
+
+ temp1 = (*value) & 0xFF;
+ temp2 = (*value >> 8) & 0xFF;
+ temp3 = (*value >> 16) & 0xFF;
+ temp4 = (*value >> 24) & 0xFF;
+
+ *value = (temp1 << 24) | (temp2 << 16) | (temp3 << 8) | temp4;
+}
+
+
+/******************************************************************************/
+/* */
+/* SWAP2BYTE() - Swap the order of bytes in a short. */
+/* */
+/******************************************************************************/
+void swap2byte(void *addr)
+{
+ unsigned short *value = (unsigned short *)addr;
+ unsigned short temp1,temp2;
+
+ temp1 = temp2 = *value;
+ *value = ((temp2 & 0xFF) << 8) | ((temp1 >> 8) & 0xFF);
+}
diff --git a/src/interp/coff/cload.mike.h b/src/interp/coff/cload.mike.h
--- /dev/null
@@ -0,0 +1,164 @@
+/***************************************************************************
+* FILENAME: cload.h
+* VERSION: 2.4 5/2/96 13:12:48
+* SCCS ID: "@(#)cload.h 2.4 5/2/96"
+***************************************************************************/
+/*****************************************************************************/
+/* CLOAD.H - Header file for Generic COFF Loader Version 4.00 9/92 */
+/*****************************************************************************/
+#ifndef _CLOAD_H_
+#define _CLOAD_H_
+
+typedef unsigned int T_ADDR; /* TYPE FOR TARGET ADDRESS */
+typedef unsigned int T_DATA; /* TYPE FOR TARGET DATA WORD */
+typedef unsigned int T_SIZE; /* TYPE FOR CINIT SIZE FIELD */
+typedef unsigned int T_IADDR; /* TYPE FOR CINIT ADDRESS FIELD */
+typedef unsigned int T_INSTRUCT; /* TYPE FOR INSTRUCTION OPCODE */
+
+#define FT_IEEE_FLT 1
+#define FT_IEEE_DBL 2
+#define FLT_PRECISION 4
+
+typedef struct trg_fval {
+ unsigned int fval1;
+ unsigned int fval2;
+} TRG_FVAL;
+
+#define MAGIC MAGIC_C60 /* C60 Magic Number */
+
+#define LOCTOBYTE(x) (x) /* C60 addresses are same as bytes */
+#define BYTETOLOC(x) (x)
+#define BIT_OFFSET(a) (0) /* BIT OFFSET OF ADDR WITHIN BYTE */
+
+#ifdef OTIS
+#define LOADBUFSIZE (TRG_MAX_MBLK/8) /* USE OTIS BUFFER SIZE */
+#else
+#define LOADBUFSIZE 0x4000 /* 16K BUFFER FOR LOADING DATA */
+//#define UNBUFFERED 1
+#endif
+
+#define LOADWORDSIZE 8 /* MINIMUM DIVISOR OF LOAD SIZE */
+#define CINIT ".cinit" /* NAME OF CINIT SECTION */
+#define INIT_ALIGN 8 /* ALIGNMENT OF CINIT RECORDS */
+#define INIT_WSIZE 4 /* SIZE IN BYTES OF INIT DATA ITEMS */
+
+
+/*---------------------------------------------------------------------------*/
+/* THIS MACRO IS USED TO FACILIATE ACCESS TO THE SECTION HEADERS */
+/*---------------------------------------------------------------------------*/
+#define SECT_HDR(i) ((SCNHDR *)(sect_hdrs + (i) * SCNHSZ))
+
+/*---------------------------------------------------------------------------*/
+/* THIS MACRO IS USED TO FACILITATE BACKWARDS COMPATIBILITY FOR COFF- */
+/* DEPENDENT TOOLS THAT SUPPORT COFF VERSION 2. */
+/*---------------------------------------------------------------------------*/
+#define O_SECT_HDR(i) ((O_SCNHDR *)(o_sect_hdrs + (i)*SCNHSZ_IN(coff_version)))
+
+/*----------------------------------------------------------------------------*/
+/* STATIC COPY OF 8 CHARACTER SECTION NAME, GUARANTEED NULL TERMINATION WHEN */
+/* USED AS A STRING. */
+/*----------------------------------------------------------------------------*/
+static char stat_nm[SYMNMLEN+1]={'\0','\0','\0','\0','\0','\0','\0','\0','\0'};
+#define SNAMECPY(s) (strncpy(stat_nm, (s), SYMNMLEN))
+
+/*---------------------------------------------------------------------------*/
+/* THESE MACROS ARE USED TO FIND CINIT AND BSS SECTIONS */
+/*---------------------------------------------------------------------------*/
+#define IS_BSS(sptr) (!str_comp(sptr->s_name, ".bss"))
+#define IS_CINIT(sptr) ((sptr->s_flags & STYP_COPY) && \
+ !str_comp(sptr->s_name, CINIT) )
+
+/*---------------------------------------------------------------------------*/
+/* VARIABLES SET BY THE APPLICATION. */
+/*---------------------------------------------------------------------------*/
+#define FILE_BASED 0
+#define STRIP_RELOC 1
+#define REMOVE_MALLOC 0
+
+#if (FILE_BASED)
+FILE *fin; /* INPUT FILE */
+#else
+/* extern unsigned char gRxBuffer[0x400040]; */
+extern unsigned char gRxBuffer[0x10];
+#endif
+
+extern int need_data; /* READ IN RAW DATA */
+extern int need_symbols; /* READ IN SYMBOL TABLE */
+extern int clear_bss; /* CLEAR BSS SECTION */
+extern int big_e_config; /* ENDIANNESS CONFIGURATION OF TARGET */
+#if TMS320C60 || RTC
+extern int fill_bss_value; /* NUMBER FOR FILL VALUE */
+#endif
+
+/*---------------------------------------------------------------------------*/
+/* VARIABLES SET BY THE LOADER. */
+/*---------------------------------------------------------------------------*/
+extern FILHDR file_hdr; /* FILE HEADER STRUCTURE */
+extern int coff_version; /* VERSION OF COFF USED BY FILE */
+extern AOUTHDR o_filehdr; /* OPTIONAL (A.OUT) FILE HEADER */
+extern T_ADDR entry_point; /* ENTRY POINT OF MODULE */
+extern T_ADDR *reloc_amount; /* AMOUNT OF RELOCATION PER SECTION */
+extern SCNHDR sect_hdrs[]; /* Array of loadable sections */
+extern O_SCNHDR o_sect_hdr; /* A single old section header */
+extern int n_sections; /* NUMBER OF SECTIONS IN THE FILE */
+extern int big_e_target; /* OBJECT DATA IS STORED MSB FIRST */
+extern int byte_swapped; /* BYTE ORDERING OPPOSITE OF HOST */
+extern int curr_sect; /* INDEX OF SECTION CURRENTLY LOADING */
+extern int load_err; /* ERROR CODE RETURNED IF LOADER FAILS */
+extern struct strtab *str_head; /* HEAD OF STRING BUFFER LIST */
+
+/*--------------------------------------------------------------------------*/
+/* CLOAD.C PROTOTYPES */
+/*--------------------------------------------------------------------------*/
+extern int cload(BOOT_MODULE_FXN_TABLE *bootFxn, Uint32 *ientry_point);
+extern int cload_headers(BOOT_MODULE_FXN_TABLE *bootFxn, Uint32 *ientry_point);
+extern int cload_data(BOOT_MODULE_FXN_TABLE *bootFxn);
+extern int cload_sect_data(SCNHDR *sptr, BOOT_MODULE_FXN_TABLE *bootFxn);
+extern int cload_cinit (unsigned char *, int *, int *);
+extern int cload_symbols (void);
+extern int cload_strings (void);
+extern void str_free (struct strtab *);
+extern int sym_read (int, struct syment *, union auxent *);
+extern char *sym_name (struct syment *);
+extern char *sym_add_name (struct syment *);
+extern int reloc_add (int, struct syment *);
+extern int relocate (RELOC *, unsigned char *, int);
+extern int reloc_read (RELOC *, unsigned int offset);
+extern int reloc_size (int);
+extern int reloc_offset (int);
+extern int reloc_stop (int);
+extern int sym_reloc_amount (RELOC *);
+extern unsigned int unpack (unsigned char *, int, int, int);
+extern void repack (unsigned int, unsigned char *, int,int,int);
+extern int cload_lineno (int, int, struct lineno *, int);
+extern void swap4byte (void *);
+extern void swap2byte (void *);
+
+/*--------------------------------------------------------------------------*/
+/* PROTOTYPES FOR FUNCTIONS REQUIRED BY CLOAD.C */
+/*--------------------------------------------------------------------------*/
+extern void lookup_sym(int indx, SYMENT *sym, AUXENT *aux);
+extern int mem_write(unsigned char *, unsigned int, T_ADDR, unsigned char);
+extern void load_msg(const char *);
+extern int set_reloc_amount(void);
+extern int load_syms(int);
+
+/*---------------------------------------------------------------------------*/
+/* VALUE OF big_e_config IF THERE IS NO TARGET AND SO IT'S A DON'T CARE. */
+/*---------------------------------------------------------------------------*/
+#define DONTCARE -1
+
+/*---------------------------------------------------------------------------*/
+/* ERROR CODES */
+/*---------------------------------------------------------------------------*/
+#define E_FILE 1 /* ERROR READING COFF FILE */
+#define E_MAGIC 2 /* WRONG MAGIC NUMBER */
+#define E_RELOC 3 /* FILE IS NOT RELOCATABLE */
+#define E_SYM 4 /* LOAD_SYM RETURNED FALSE */
+#define E_ALLOC 5 /* MYALLOC OR MRALLOC RETURNED FALSE */
+#define E_SETRELOC 6 /* SET_RELOC_AMOUNT RETURNED FALSE */
+#define E_MEMWRITE 7 /* MEM_WRITE RETURNED FALSE */
+#define E_RELOCENT 8 /* RELOC ENTRY RULES VIOLATED */
+#define E_ENDIAN 9 /* OBJ ENDIANESS CONFLICTS WITH TARGET */
+
+#endif /* _CLOAD_H_ */
diff --git a/src/interp/coff/cload_main.c b/src/interp/coff/cload_main.c
--- /dev/null
@@ -0,0 +1,100 @@
+/****************************************************************************/
+/* MAIN.C - Skeleton Driver for COFF Loader Version 6.00 4/96 */
+/****************************************************************************/
+/* */
+/* General: This module is a skeleton driver for a standalone COFF */
+/* loader. This file is NOT part of the generic loader, but */
+/* provides a sample interface to it that can provide a basis */
+/* for a specific loader. YOU MUST CUSTOMIZE THIS PROGRAM */
+/* FOR YOUR APPLICATION. In particular, you must write the */
+/* function 'mem_write()' which is the low-level function to */
+/* load target memory. */
+/* */
+/* Refer to the documentation provided with the loader for */
+/* details on how to interface with it. */
+/* */
+/* Usage: cload <-options> filename */
+/* Options: -b clear .bss section */
+/* -q quiet mode (no banner) */
+/* -r xxxx relocate by xxxx */
+/* */
+/*--------------------------------------------------------------------------*/
+/* Functions defined in this module: */
+/* */
+/* main() - Main driver for loader. */
+/* mem_write() - Load a buffer of raw data to the target. */
+/* set_reloc_amount() - Determine relocation amount for each section. */
+/* lookup_sym() - Stub for symbol lookup routine. */
+/* myalloc() - Application version of 'malloc()'. */
+/* mralloc() - Application version of 'realloc()'. */
+/* load_msg() - Called by loader to write debug messages. */
+/* */
+/****************************************************************************/
+#include "header.h"
+
+#define READ_BIN "rb" /* HOST-SPECIFIC */
+
+unsigned int reloc = 0; /* RELOCATION AMOUNT */
+
+void mem_copy(unsigned char* dst, unsigned char* src, int nbytes)
+{
+ int i = 0;
+ for(i = 0; i<nbytes; i++)
+ *(dst+i) = *(src+i);
+}
+
+/****************************************************************************/
+/* */
+/* MEM_WRITE() - Load a buffer of raw data to the target. */
+/* */
+/* THIS FUNCTION MUST BE CUSTOMIZED FOR YOUR APPLICATION ! */
+/* */
+/* (As supplied, this function simply dumps the data out to the screen.) */
+/* */
+/****************************************************************************/
+int mem_write(unsigned char *buffer, /* POINTER TO DATA BUFFER */
+ unsigned int nbytes, /* NUMBER OF 8-BIT BYTES */
+ T_ADDR addr, /* TARGET DESTINATION ADDRESS */
+ unsigned char page) /* TARGET DESTINATION PAGE */
+{
+ /*-----------------------------------------------------------------------*/
+ /* INSERT CUSTOM CODE HERE TO LOAD TARGET MEMORY. */
+ /*-----------------------------------------------------------------------*/
+ mem_copy((void*)addr, (void*)buffer, nbytes);
+ return 1;
+}
+
+
+/****************************************************************************/
+/* */
+/* SET_RELOC_AMOUNT() - Determine relocation amount for each section. */
+/* */
+/****************************************************************************/
+int set_reloc_amount()
+{
+ int i;
+
+ for (i = 0; i< n_sections; ++i) reloc_amount[i] = reloc;
+ return 1;
+}
+
+
+/****************************************************************************/
+/* */
+/* LOOKUP_SYM() - Stub for symbol lookup routine. */
+/* */
+/****************************************************************************/
+void lookup_sym(int indx, SYMENT *sym, AUXENT *aux)
+{}
+
+
+/****************************************************************************/
+/* */
+/* LOAD_SYMS() - Stub for symbol load routine. This routine is only called */
+/* if the global flag 'need_symbols' is TRUE. */
+/* */
+/****************************************************************************/
+int load_syms(int need_reloc)
+{
+ return 1;
+}
diff --git a/src/interp/coff/coff.h b/src/interp/coff/coff.h
--- /dev/null
+++ b/src/interp/coff/coff.h
@@ -0,0 +1,884 @@
+/**************************************************************************/
+/* COFF.H - Definition of COFF structures and definitions. */
+/* */
+/* This file defines all standard COFF definitions, used by any program */
+/* which reads or writes COFF files. */
+/* */
+/* HISTORY */
+/* --/--/83 - Original (lost in the mists of time) */
+/* --/--/91 - Tektronics relocation entry kludge */
+/* 01/07/94 RET - Reworked file header and relocation entries, add */
+/* COFF version support. (Removed Tek kludge) */
+/* 12/24/95 TMS - Reworked section header structures for COFF 2 */
+/* */
+/**************************************************************************/
+#ifndef COFF_H
+#define COFF_H
+
+#if defined(TOOL_ASSEMBLER)
+ #error The COFF submodule should no longer be used by the assembler; use TICOFF04
+#endif
+
+/*------------------------------------------------------------------------*/
+/* COFF VERSION FLAGS */
+/*------------------------------------------------------------------------*/
+#if !defined(COFF_VERSION_0) && \
+ !defined(COFF_VERSION_1) && \
+ !defined(COFF_VERSION_2)
+#define COFF_VERSION_0 0
+#define COFF_VERSION_1 0
+#define COFF_VERSION_2 1
+#endif
+
+#ifndef COFF_VERSION_0
+#define COFF_VERSION_0 0
+#endif
+
+#ifndef COFF_VERSION_1
+#define COFF_VERSION_1 0
+#endif
+
+#ifndef COFF_VERSION_2
+#define COFF_VERSION_2 0
+#endif
+
+/*------------------------------------------------------------------------*/
+/* COFF MAGIC NUMBERS */
+/*------------------------------------------------------------------------*/
+#define COFF_MAGIC_0 0xc0 /* ORIGINAL VERSION OF COFF */
+#define COFF_MAGIC_1 0xc1
+#define COFF_MAGIC_2 0xc2
+
+/*------------------------------------------------------------------------*/
+/* COFF TARGET ID's (FORMERLY MAGIC NUMBERS) */
+/* NOTE!!! DEFINE THE MACRO "MAGIC" TO BE ONE OF THESE MACROS. */
+/*------------------------------------------------------------------------*/
+#define MAGIC_340 0x90
+#define MAGIC_370 0x91
+#define MAGIC_DSP 0x92
+#define MAGIC_C30 0x93
+#define MAGIC_380 0x94
+#define MAGIC_MVP 0x95
+#define MAGIC_C16 0x96
+#define MAGIC_ARM 0x97
+#define MAGIC_LEAD 0x98
+#define MAGIC_C60 0x99
+#define MAGIC_C8P 0x9a
+#define MAGIC_unused1 0x9b
+#define MAGIC_LEAD3 0x9c
+#define MAGIC_ANKOOR 0x9d
+#define MAGIC_unused 0x9e
+#define MAGIC_TARANTULA 0x9f
+#define MAGIC_MSP 0xA0
+#define MAGIC_LEAD3_R35 0xA1
+
+#define MAGIC_MIN 0x90 /* MINIMUM VALID MAGIC NUMBER */
+#define MAGIC_MAX 0xA1 /* MAXIMUM VALID MAGIC NUMBER */
+
+/*------------------------------------------------------------------------*/
+/* Macros to recognize magic numbers */
+/* NOTE: ISMAGIC() is now a target-specific macro defined in coff_trg.h */
+/*------------------------------------------------------------------------*/
+#define ISCOFF(x) (ISCOFF_0(x)||ISCOFF_1(x)||ISCOFF_2(x)||ISMAGIC(x))
+#define BADMAGIC(x) (((unsigned short)(x) & 0x8080) && !ISMAGIC(x))
+
+#define ISEXE(x) ((x >> 1) & 0x0001)
+
+#if COFF_VERSION_2
+#define ISCOFF_0(x) ((unsigned short)(x) == COFF_MAGIC_0)
+#define ISCOFF_1(x) ((unsigned short)(x) == COFF_MAGIC_1)
+#define ISCOFF_2(x) ((unsigned short)(x) == COFF_MAGIC_2)
+#elif COFF_VERSION_1
+#define ISCOFF_0(x) ((unsigned short)(x) == COFF_MAGIC_0)
+#define ISCOFF_1(x) ((unsigned short)(x) == COFF_MAGIC_1)
+#define ISCOFF_2(x) FALSE
+#else
+#define ISCOFF_0(x) FALSE
+#define ISCOFF_1(x) FALSE
+#define ISCOFF_2(x) FALSE
+#endif
+
+#define ISMAGIC_ANY(x) (((unsigned short)(x)) >= MAGIC_MIN && \
+ ((unsigned short)(x)) <= MAGIC_MAX)
+#define ISCOFF_ANY(x) (ISCOFF_0(x) || ISCOFF_1(x) || \
+ ISCOFF_2(x) || ISMAGIC_ANY(x))
+
+#include "coffdefs.h"
+
+/*------------------------------------------------------------------------*/
+/* COFF FILE HEADER */
+/*------------------------------------------------------------------------*/
+struct filehdr
+{
+ unsigned short f_magic; /* magic number */
+ unsigned short f_nscns; /* number of sections */
+ unsigned int f_timdat; /* time & date stamp */
+ unsigned int f_symptr; /* file pointer to symtab */
+ unsigned int f_nsyms; /* number of symtab entries */
+ unsigned short f_opthdr; /* sizeof(optional hdr) */
+ unsigned short f_flags; /* flags */
+ unsigned short f_target_id; /* target architecture id */
+};
+
+#define FILHDR struct filehdr
+#define FILHSZ (COFF_VERSION_0 ? 20 : 22)
+#define FILHSZ_IN(version) (version >= COFF_MAGIC_1 ? 22 : 20)
+
+/*------------------------------------------------------------------------*/
+/* File header flags */
+/*------------------------------------------------------------------------*/
+#define F_RELFLG 0x01 /* relocation info stripped from file */
+#define F_EXEC 0x02 /* file is executable (no unresolved refs) */
+#define F_LNNO 0x04 /* line nunbers stripped from file */
+#define F_LSYMS 0x08 /* local symbols stripped from file */
+
+ /*------------------------------------------------------------------------*/
+/* Target device identification flags (bits 4-7 in file header flags) */
+/*------------------------------------------------------------------------*/
+#define F_VERS0 0x0 /* 0th generation CPU */
+#define F_VERS1 0x10 /* 1st generation CPU */
+#define F_VERS2 0x20 /* 2nd generation CPU */
+#define F_VERS3 0x40 /* 3rd generation CPU */
+#define F_VERS4 0x80 /* 4th generation CPU */
+#define F_VERSION (F_VERS1 | F_VERS2 | F_VERS3 | F_VERS4)
+
+/*------------------------------------------------------------------------*/
+/* Target device raw data byte ordering flags (bits 8-9) */
+/*------------------------------------------------------------------------*/
+#define F_LITTLE 0x100 /* object code is LSB first */
+#define F_BIG 0x200 /* object code is MSB first */
+#define F_BYTE_ORDER (F_LITTLE | F_BIG)
+
+#define F_SYMMERGE 0x1000 /* Tags, etc were merged - no duplicates */
+
+#define F_ICODE 0x2000 /* This file contains embedded I-Code */
+
+\f
+/*------------------------------------------------------------------------*/
+/* OPTIONAL FILE HEADER */
+/*------------------------------------------------------------------------*/
+typedef struct aouthdr
+{
+ short magic; /* optional file header magic number */
+ short vstamp; /* version stamp */
+ int tsize; /* text size in bytes, padded to FW bdry*/
+ int dsize; /* initialized data " " */
+ int bsize; /* uninitialized data " " */
+ int entrypt; /* entry pt. */
+ int text_start; /* base of text used for this file */
+ int data_start; /* base of data used for this file */
+} AOUTHDR;
+
+#define AOUTSZ sizeof(AOUTHDR)
+#define AOUT1MAGIC 0x108
+
+\f
+/*------------------------------------------------------------------------*/
+/* COMMON ARCHIVE FILE STRUCTURES */
+/* */
+/* ARCHIVE File Organization: */
+/* +---------------------------------------------+ */
+/* | ARCHIVE_MAGIC_STRING | */
+/* +---------------------------------------------+ */
+/* | ARCHIVE_FILE_MEMBER_1 | */
+/* +- - - - - - - - - - - - - - - - - - - - - - -+ */
+/* | Archive File Header "ar_hdr" | */
+/* | Contents (Ext symbol direct, text file) | */
+/* +---------------------------------------------+ */
+/* | ARCHIVE_FILE_MEMBER_2 | */
+/* +- - - - - - - - - - - - - - - - - - - - - - -+ */
+/* | Archive File Header "ar_hdr" | */
+/* | Contents (long file member name table) | */
+/* +---------------------------------------------+ */
+/* | ARCHIVE_FILE_MEMBER_3 | */
+/* +- - - - - - - - - - - - - - - - - - - - - - -+ */
+/* | Archive File Header "ar_hdr" | */
+/* | Contents (.o or text file) | */
+/* +---------------------------------------------+ */
+/* | . . . | */
+/* | . . . | */
+/* | . . . | */
+/* +---------------------------------------------+ */
+/* | ARCHIVE_FILE_MEMBER_n | */
+/* +- - - - - - - - - - - - - - - - - - - - - - -+ */
+/* | Archive File Header "ar_hdr" | */
+/* | Contents (.o or text file) | */
+/* +---------------------------------------------+ */
+/* */
+/*------------------------------------------------------------------------*/
+
+#define ARMAG "!<arch>\n"
+#define SARMAG 8
+#define ARFMAG "`\n"
+#define ARFMAG_SIZE 2
+
+struct ar_hdr /* archive file member header - printable ascii */
+{
+ char ar_name[16]; /* file member name - `/' terminated */
+ char ar_date[12]; /* file member date - decimal */
+ char ar_offset[6]; /* file member offset - decimal */
+ char ar_gid[6]; /* file member group id - decimal */
+ char ar_mode[8]; /* file member mode - octal */
+ char ar_size[10]; /* file member size - decimal */
+ char ar_fmag[2]; /* ARFMAG - string to end header */
+};
+
+#define ARHDR struct ar_hdr
+#define ARHSZ sizeof(ARHDR)
+#define AR_HDR_SZ sizeof(ARHDR)
+#define AR_FNAME_SIZE 16
+#define MAGIC_LONGFILENAME 1
+#define LONGFILENAME "<filenames>"
+#define SYMDIRNAME "/ "
+
+\f
+/*------------------------------------------------------------------------*/
+/* SECTION HEADER */
+/*------------------------------------------------------------------------*/
+#define SYMNMLEN 8 /* Number of characters in a symbol name */
+
+/*------------------------------------------------------------------------*/
+/* THE OLD COFF VERSION TYPE DEFINITION FOR SECTION HEADERS TO PROVIDE */
+/* BACKWARDS COMPATIBILITY FOR COFF-DEPENDENT TOOLS THAT SUPPORT COFF 2. */
+/*------------------------------------------------------------------------*/
+struct o_scnhdr
+{
+ char os_name[8]; /* section name */
+ int os_paddr; /* physical address */
+ int os_vaddr; /* virtual address */
+ int os_size; /* section size */
+ int os_scnptr; /* file ptr to raw data for scn */
+ int os_relptr; /* file ptr to relocation */
+ int os_lnnoptr; /* file ptr to line numbers */
+ unsigned short os_nreloc; /* number of relocation entries */
+ unsigned short os_nlnno; /* number of line number entries */
+ unsigned short os_flags; /* flags */
+ char os_reserved; /* reserved byte */
+ unsigned char os_page; /* memory page id */
+};
+
+/*------------------------------------------------------------------------*/
+/* THE NEW COFF VERSION TYPE DEFINITION FOR SECTION HEADERS. THIS */
+/* REVISION ALLOWS FOR UNRESTRICTED SECTION NAME LENGTH. */
+/*------------------------------------------------------------------------*/
+struct scnhdr
+{
+ union
+ {
+ char _s_name[SYMNMLEN]; /* old COFF version name fld */
+ struct
+ {
+ int _s_zeroes; /* new == 0 */
+ int _s_offset; /* offset into string table */
+ } _s_s;
+ char *_s_nptr[2]; /* allows for overlaying */
+ } _s;
+
+ int s_paddr; /* physical address */
+ int s_vaddr; /* virtual address */
+ int s_size; /* section size */
+ int s_scnptr; /* file ptr to raw data for section */
+ int s_relptr; /* file ptr to relocation */
+ int s_lnnoptr; /* file ptr to line numbers */
+ unsigned int s_nreloc; /* number of relocation entries */
+ unsigned int s_nlnno; /* number of line number entries */
+ unsigned int s_flags; /* flags */
+ unsigned char s_mwidth; /* memory width in bits */
+ /* (0 == target memory width) */
+ unsigned char s_reserved; /* reserved byte */
+ unsigned short s_page; /* memory page id */
+};
+
+#define s_name _s._s_name
+#define s_nptr _s._s_nptr[1]
+#define s_zeroes _s._s_s._s_zeroes
+#define s_offset _s._s_s._s_offset
+
+#define O_SCNHDR struct o_scnhdr
+#define SCNHDR struct scnhdr
+#define O_SCNHSZ sizeof(O_SCNHDR)
+#define SCNHSZ sizeof(SCNHDR)
+#define SCNHSZ_IN(version) (version == COFF_MAGIC_2 ? SCNHSZ : O_SCNHSZ)
+
+/*------------------------------------------------------------------------*/
+/* Define constants for names of "special" sections */
+/*------------------------------------------------------------------------*/
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+#define _REG ".reg"
+#define _BINIT ".binit"
+#define _CINIT ".cinit"
+#define _PINIT ".pinit"
+#define _ICODE ".icode"
+
+#define _OVLY_PREFIX ".ovly:"
+
+#define IS_DWARF_SECTION(name) (!strncmp(name, ".debug_", 7))
+
+/*------------------------------------------------------------------------*/
+/* Bits 0-8 of s_flags are used as a section "type" */
+/*------------------------------------------------------------------------*/
+#define STYP_REG 0x00 /* "regular" : allocated, relocated, loaded */
+#define STYP_DSECT 0x01 /* "dummy" : !allocated, relocated, !loaded */
+#define STYP_NOLOAD 0x02 /* "noload" : allocated, relocated, !loaded */
+#define STYP_XXX1 0x04 /* not used - was STYP_GROUP */
+#define STYP_XXX2 0x08 /* not used - was STYP_PAD */
+#define STYP_COPY 0x10 /* "copy" : used for C init tables -
+ not allocated, relocated,
+ loaded; reloc & lineno
+ entries processed normally */
+#define STYP_TEXT 0x20 /* section contains text only */
+#define STYP_DATA 0x40 /* section contains data only */
+#define STYP_BSS 0x80 /* section contains bss only */
+
+/*------------------------------------------------------------------------*/
+/* Bits 8-11 specify an alignment. The alignment is (2 ** x), where x is */
+/* is the encoded value */
+/*------------------------------------------------------------------------*/
+#define ALIGN_MASK 0xF00 /* mask for alignment factor */
+#define ALIGN_SIZE(s_flag) (1 << (((unsigned)s_flag & ALIGN_MASK) >> 8))
+#define ALIGN_GET(header) (((header).s_flags & ALIGN_MASK) >> 8)
+#define ALIGN_SET(header,amt) (header).s_flags = \
+ (((header).s_flags & ~ALIGN_MASK) | ((amt << 8) & ALIGN_MASK))
+
+/*------------------------------------------------------------------------*/
+/* bit 12-31 */
+/*------------------------------------------------------------------------*/
+#define STYP_BLOCK 0x01000 /* use alignment as blocking factor */
+#define STYP_PASS 0x02000 /* Pass section through unchanged */
+#define STYP_CLINK 0x04000 /* Conditionally link section */
+
+#define STYP_VECTOR 0x08000 /* section contains vector table */
+ /* (Used in addition to STYP_TEXT) */
+
+#define STYP_PADDED 0x10000 /* section HAS BEEN padded. Do not pad */
+ /* again if partial linking. */
+#define STYP_ICODE 0x20000 /* section has ICODE associated with it */
+
+#define STYP_LGT 0x40000 /* linker generated table section */
+#define STYP_COMMON 0x80000 /* comdat section - remove duplicates */
+
+#define STYP_BASIC_MASK 0xFF /* basic section types */
+#define STYP_TIEXT_MASK 0xFF000 /* TI section type extensions */
+
+/*------------------------------------------------------------------------*/
+/* A mask for all the flags we support - anything else is garbage. */
+/*------------------------------------------------------------------------*/
+#define STYP_KNOWN_MASK (ALIGN_MASK | STYP_BASIC_MASK | STYP_TIEXT_MASK)
+
+\f
+/*------------------------------------------------------------------------*/
+/* RELOCATION ENTRIES */
+/* WE SUPPORT TWO TYPES OF RELOCATION ENTRIES: */
+/* 1) OLD STYLE, WITH 16 BIT SYMBOL TABLE INDEX. */
+/* 2) NEW STYLE, WITH 32 BIT SYMBOL TABLE INDEX. */
+/* FOR ANY GIVEN INPUT FILE, THE FILE HEADER FLAG "F_RELOC_12" INDICATES */
+/* THE TYPE OF RELOCATION ENTRY IN THE FILE. */
+/* THE TARGET-SPECIFIC FLAG RELOC_ENTRY_12 DETERMINES WHETHER THE NEW */
+/* STYLE IS SUPPORTED ON A GIVEN TARGET. */
+/*------------------------------------------------------------------------*/
+typedef struct reloc_old
+{
+ int r_vaddr; /* (virtual) address of reference */
+
+ union {
+ struct {
+ unsigned char _offset; /* bit offset of rel fld */
+ unsigned char _fieldsz; /* size of rel fld */
+ unsigned char _wordsz; /* # bytes containing rel fld */
+ unsigned char _dum1;
+
+ unsigned short _type;
+ } _r_field;
+
+ struct {
+ unsigned int _spc; /* section relative PC */
+ unsigned short _type; /* relocation type */
+ } _r_spc;
+
+ struct {
+ unsigned int _uval; /* constant value */
+ unsigned short _type; /* relocation type */
+ } _r_uval;
+
+ struct {
+ short _symndx; /* 32-bit sym tbl index */
+ unsigned short _disp; /* extra addr encode data */
+ unsigned short _type; /* relocation type */
+ } _r_sym;
+ } _u_reloc;
+} RELOC_OLD;
+
+/*------------------------------------------------------------------------*/
+/* MAKE SURE THE RELOCATION STRUCTURE IS TIGHTLY PACKED TO AVOID HOST */
+/* ALIGNMENT MECHANISMS. */
+/*------------------------------------------------------------------------*/
+typedef struct reloc
+{
+ int r_vaddr; /* (virtual) address of reference */
+
+ union {
+ struct {
+ unsigned char _offset; /* bit offset of rel fld */
+ unsigned char _fieldsz; /* size of rel fld */
+ unsigned char _wordsz; /* # bytes containing rel fld */
+ unsigned char _dum1;
+ unsigned short _dum2;
+
+ unsigned short _type;
+ } _r_field;
+
+ struct {
+ unsigned int _spc; /* section relative PC */
+ unsigned short _dum;
+ unsigned short _type; /* relocation type */
+ } _r_spc;
+
+ struct {
+ unsigned int _uval; /* constant value */
+ unsigned short _dum;
+ unsigned short _type; /* relocation type */
+ } _r_uval;
+
+ struct {
+ int _symndx; /* 32-bit sym tbl index */
+ unsigned short _disp; /* extra addr encode data */
+ unsigned short _type; /* relocation type */
+ } _r_sym;
+ } _u_reloc;
+} RELOC;
+
+#define RELSZ (COFF_VERSION_0 ? 10 : 12)
+#define RELSZ_IN(version) ((version >= COFF_MAGIC_1) ? 12 : 10)
+
+/*------------------------------------------------------------------------*/
+/* Macros for accessing fields in relocation entry data structure. */
+/*------------------------------------------------------------------------*/
+#define r_offset _u_reloc._r_field._offset
+#define r_fieldsz _u_reloc._r_field._fieldsz
+#define r_wordsz _u_reloc._r_field._wordsz
+
+#define r_spc _u_reloc._r_spc._spc
+#define r_uval _u_reloc._r_uval._uval
+
+#define r_symndx _u_reloc._r_sym._symndx
+#define r_disp _u_reloc._r_sym._disp
+#define r_type _u_reloc._r_sym._type
+
+/*------------------------------------------------------------------------*/
+/* define all relocation types */
+/*------------------------------------------------------------------------*/
+#define R_ABS 0x0 /* absolute address - no relocation */
+#define R_DIR16 0x1 /* UNUSED */
+#define R_REL16 0x2 /* UNUSED */
+#define R_DIR24 0x4 /* UNUSED */
+#define R_REL24 0x5 /* 24 bits, direct */
+#define R_DIR32 0x6 /* UNUSED */
+#define R_RRRELREG 0xe /* RR: 8 bit relocatable register */
+
+#define R_RELBYTE 0xf /* 8 bits, direct */
+#define R_RELWORD 0x10 /* 16 bits, direct */
+#define R_RELLONG 0x11 /* 32 bits, direct */
+#define R_PCRBYTE 0x12 /* 8 bits, PC-relative */
+#define R_PCRWORD 0x13 /* 16 bits, PC-relative */
+#define R_PCRLONG 0x14 /* 32 bits, PC-relative */
+ /* (See unsigned (LD3) versions below.) */
+#define R_PCR24 0x15 /* 24 bits, PC-relative */
+#define R_PCR23H 0x16 /* 23 bits, PC-rel in halfwords(x>>1) */
+#define R_PCR24W 0x17 /* 24 bits, PC-rel in words (x >> 2) */
+#define R_OCRLONG 0x18 /* GSP: 32 bits, one's compl direct */
+#define R_GSPPCR16 0x19 /* GSP: 16 bits, PC relative (in words) */
+#define R_GSPOPR32 0x1a /* GSP: 32 bits, direct big-endian */
+#define R_GSPPCA16 0x1b /* GSP: same as GSPPCR16, but PC const */
+#define R_OCBD32 0x1c /* GSP: 32 bits, 1's compl,big-endian */
+#define R_RRNREG 0x1d /* RR: 8 bit reloc. reg. w/ neg off */
+#define R_PARTLS16 0x20 /* Brahma: 16 bit offset of 24 bit addr */
+#define R_PARTMS8 0x21 /* Brahma: 8 bit page of 24 bit addr */
+#define R_PARTLS7 0x28 /* DSP: 7 bit offset of 16 bit addr */
+#define R_PARTMS9 0x29 /* DSP: 9 bit page of 16 bit addr */
+#define R_REL13 0x2a /* DSP: 13 bits, direct */
+#define R_REL23 0x2b /* DSP,C54X: 23 bits, direct (ext addr) */
+#define R_RELXPC 0x2c /* DSP,C54X: 16 bits, relative to XPC */
+#define R_HIEXT 0x2d /* C54X: Hi word of extended prog addr */
+#define R_HIWORD 0x31 /* RR: 8 bit reloc. hi byte of word */
+#define R_LABCOD 0x32 /* C16 16-bit code address relocation */
+
+#define R_PPBASE 0x34 /* PP: Global Base address type */
+#define R_PPLBASE 0x35 /* PP: Local Base address type */
+#define R_PP15 0x38 /* PP: Global 15 bit offset */
+#define R_PP15W 0x39 /* PP: Global 15 bit offset / 4 */
+#define R_PP15H 0x3a /* PP: Global 15 bit offset / 2 */
+#define R_PP16B 0x3b /* PP: Global 16 bit offset for bytes */
+#define R_PPL15 0x3c /* PP: Local 15 bit offset */
+#define R_PPL15W 0x3d /* PP: Local 15 bit offset divided by 4 */
+#define R_PPL15H 0x3e /* PP: Local 15 bit offset divided by 2 */
+#define R_PPL16B 0x3f /* PP: Local 16 bit offset for bytes */
+#define R_PPN15 0x40 /* PP: Global 15 bit neg offset */
+#define R_PPN15W 0x41 /* PP: Global 15 bit neg offset / 4 */
+#define R_PPN15H 0x42 /* PP: Global 15 bit neg offset / 2 */
+#define R_PPN16B 0x43 /* PP: Global 16 bit neg byte offset */
+#define R_PPLN15 0x44 /* PP: Local 15 bit neg offset */
+#define R_PPLN15W 0x45 /* PP: Local 15 bit neg offset / 4 */
+#define R_PPLN15H 0x46 /* PP: Local 15 bit neg offset / 2 */
+#define R_PPLN16B 0x47 /* PP: Local 16 bit neg byte offset */
+
+#define R_MPPCR 0x4f /* MP: 32-bit PC-relative / 4 */
+
+#define R_C60BASE 0x50 /* C60: Data Page Pointer Based Offset */
+#define R_C60DIR15 0x51 /* C60: LD/ST long Displacement */
+#define R_C60PCR21 0x52 /* C60: 21-bit PC Relative */
+#define R_C60PCR10 0x53 /* C60: 10-bit PC Relative */
+#define R_C60LO16 0x54 /* C60: MVK Low Half Register */
+#define R_C60HI16 0x55 /* C60: MVKH/MVKLH High Half Register */
+#define R_C60SECT 0x56 /* C60: Section-Based Offset */
+#define R_C60S16 0x57 /* C60: Signed 16-bit */
+#define R_C60PCR7 0x70 /* C60: 7-bit PC Relative */
+#define R_C60PCR12 0x71 /* C60: 12-bit PC Relative */
+#define R_C60PCR12H 0x72 /* C60: 12-bit PC Relative (Half) */
+#define R_C60PCR7J 0x73 /* C60: 7-bit PC Relative (-BNOP) */
+#define R_C60PCR8J 0x74 /* C60: 8-bit PC Relative (-BNOP) */
+#define R_C60PCR10J 0x75 /* C60: 10-bit PC Relative (-CALLP) */
+#define R_C60ALIGN 0x76 /* C60: Alignment info for compressor */
+#define R_C60FPHEAD 0x77 /* C60: Explicit assembly directive */
+#define R_C60NOCMP 0x100 /* C60: Don't compress this code scn */
+
+#define R_C8PHIBYTE 0x58 /* C8+: High byte of 24-bit address. */
+#define R_C8PMIDBYTE 0x59 /* C8+: Middle byte of 24-bit address. */
+#define R_C8PVECADR 0x5a /* C8+: Vector address (0xFFnnnn) */
+#define R_C8PADR24 0x5b /* C8+: 24-bit address (rev byte order) */
+
+#define R_PARTLS6 0x5d /* ANKOOR: 6 bit offset of 22 bit addr */
+#define R_PARTMID10 0x5e /* ANKOOR: Middle 10 bits of 22 bit addr*/
+#define R_REL22 0x5f /* ANKOOR: 22 bits, direct */
+#define R_PARTMS6 0x60 /* ANKOOR: Upper 6 bits of 22 bit addr */
+#define R_PARTMS16 0x61 /* ANKOOR: Upper 16 bits of 22 bit addr */
+#define R_ANKPCR16 0x62 /* ANKOOR: PC relative 16 bit */
+#define R_ANKPCR8 0x63 /* ANKOOR: PC relatvie 8 bit */
+#define R_ANKPTR 0x64 /* ANKOOR: 22 bit pointer */
+#define R_ANKHI16 0x65 /* ANKOOR: HI 16 bits of address + data */
+#define R_ANKLOPTR 0x66 /* ANKOOR: Pointer to low 64K */
+#define R_ANKNWORD 0x67 /* ANKOOR: 16 bit negated relocation */
+#define R_ANKNBYTE 0x68 /* ANKOOR: 8 bit negated relocation */
+#define R_ANKHIBYTE 0x69 /* ANKOOR: High byte of a word */
+#define R_REL13_SE16 0x6a /* MANTRA: 13 bit sign extend to 16 bit */
+
+#define R_LD3_DMA 0x78 /* LEAD3: 7 most sig bits of a byte, */
+ /* unsigned value; used in DMA address */
+ /* */
+ /* 5432109876543210 */
+ /* xxxxxxxxFFFFFFFx */
+
+#define R_LD3_MDP 0x7a /* LEAD3: 7 bits spanning two bytes, */
+ /* unsigned value; used as MDP reg value*/
+ /* */
+ /* 321098765432109876543210 */
+ /* xxxxxxxxxxxxxFFFFFFFxxxx */
+
+#define R_LD3_PDP 0x7b /* LEAD3: 9 bits spanning two bytes, */
+ /* unsigned value; used as PDP reg value*/
+ /* */
+ /* 321098765432109876543210 */
+ /* xxxxxxxxxxxFFFFFFFFFxxxx */
+
+#define R_LD3_REL23 0x7c /* LEAD3: 23 bit unsigned value in a */
+ /* 24-bit-wide field */
+
+
+#define R_TARBASE 0x80 /* TARANTULA: Data Page Pointer Based Off */
+#define R_TARDIR12 0x81 /* TARANTULA: LD/ST long Displacement */
+#define R_TARLO16 0x82 /* TARANTULA: MVK Low Half Register */
+#define R_TARHI16 0x83 /* TARANTULA: MVKH/MVKLH High Half Reg */
+#define R_TARSECT 0x84 /* TARANTULA: Section-based offset */
+
+#define R_LD3_k8 0x88 /* LD3: Unsigned 8 bit, direct */
+#define R_LD3_k16 0x89 /* LD3: Unsigned 16 bit, direct */
+#define R_LD3_K8 0x8a /* LD3: Signed 8 bit, direct */
+#define R_LD3_K16 0x8b /* LD3: Signed 16 bit, direct */
+
+#define R_LD3_l8 0x8c /* LD3: Unsigned 8 bit, PC-relative */
+#define R_LD3_l16 0x8d /* LD3: Unsigned 16 bit, PC-relative */
+#define R_LD3_L8 0x8e /* LD3: Signed 8 bit, PC-relative */
+#define R_LD3_L16 0x8f /* LD3: Signed 16 bit, PC-relative */
+
+#define R_LD3_k4 0x90 /* LD3: Unsigned 4 bit shift immediate */
+#define R_LD3_k5 0x91 /* LD3: Unsigned 5 bit shift immediate */
+#define R_LD3_K5 0x92 /* LD3: Signed 5 bit shift immediate */
+#define R_LD3_k6 0x93 /* LD3: Unsigned 6 bit immediate */
+#define R_LD3_k12 0x94 /* LD3: Unsigned 12 bit immediate */
+#define R_LD3_ABS16 0x95 /* LD3: abs16(addr) truncated k16 */
+
+#define R_NONE 0x96 /* Encode dependencies between sections */
+
+#define R_MSP_PCR20_SRC 0x97 /* MSP: PC-rel 20-bit src ext encoding */
+#define R_MSP_PCR20_DST 0x98 /* MSP: PC-rel 20-bit dst ext encoding */
+#define R_MSP_PCR20_ODST 0x99 /* MSP: PC-rel 20-bit offset dst ext enc */
+#define R_MSP_EXT20_SRC 0x9A /* MSP: Relative 20-bit src ext encoding */
+#define R_MSP_EXT20_DST 0x9B /* MSP: Relative 20-bit dst ext encoding */
+#define R_MSP_EXT20_ODST 0x9C /* MSP: Rel 20-bit offset dst ext encoding */
+#define R_MSP_REL20_SRC 0x9D /* MSP: Relative 20-bit src opnd */
+#define R_MSP_REL20_DST 0x9E /* MSP: Relative 20-bit dst opnd */
+#define R_MSP_PCR16 0x9F /* MSP: PC-rel 16-bit encoding */
+#define R_MSP_PCR20_CALL 0xA0 /* MSP: PC-rel 20-bit call operand */
+#define R_MSP_REL16 0xA1 /* MSP: Relative 16-bit (20bit MSPx device)*/
+
+#define R_T2_PCR24H 0xA2 /* THUMB2: 24 bits, PC-rel in halfwords(x>>1) */
+#define R_T2_PCR20H 0xA3 /* THUMB2: 20 bits, PC-rel in halfwords(x>>1) */
+
+#define R_LD3_ABS24 0xA4 /* C55x+: LD_R_ABS, ST_R_ABS -- *(#k24) */
+#define R_LD3_SP_K9 0xA5 /* C55x+: SP += K9 w/ K9 encoded as (K9 >> 1) */
+\f
+/*---------------------------------------------------------------------------*/
+/* GENERIC relocation types for complex relocation expressions. */
+/* *** NOTE: This range of relocation types exists above 0x4000 *** */
+/* *** NOTE: Top bit of relocation type field used as SEGVALUE flag *** */
+/*---------------------------------------------------------------------------*/
+#define RE_ADD 0x4000 /* Operator Instructions: + */
+#define RE_SUB 0x4001 /* - */
+#define RE_NEG 0x4002 /* unary - */
+#define RE_MPY 0x4003 /* * */
+#define RE_DIV 0x4004 /* / */
+#define RE_MOD 0x4005 /* % */
+
+#define RE_SR 0x4006 /* >>u */
+#define RE_ASR 0x4007 /* >>s */
+#define RE_SL 0x4008 /* << */
+
+#define RE_AND 0x4009 /* & */
+#define RE_OR 0x400a /* | */
+#define RE_XOR 0x400b /* ^ */
+#define RE_NOTB 0x400c /* ~ */
+
+#define RE_ULDFLD 0x400d /* unsigned relocation field load */
+#define RE_SLDFLD 0x400e /* signed relocation field load */
+#define RE_USTFLD 0x400f /* unsigned relocation field store */
+#define RE_SSTFLD 0x4010 /* signed relocation field store */
+#define RE_XSTFLD 0x4016 /* signedness is irrelevant */
+
+#define RE_PUSH 0x4011 /* push symbol on the stack */
+#define RE_PUSHSV 0xc011 /* push symbol: SEGVALUE flag set */
+#define RE_PUSHSK 0x4012 /* push signed constant on the stack */
+#define RE_PUSHUK 0x4013 /* push unsigned constant on the stack */
+#define RE_PUSHPC 0x4014 /* push current section PC on the stack */
+#define RE_DUP 0x4015 /* duplicate tos and push copy */
+
+/*---------------------------------------------------------------------------*/
+/* Other useful generic relocation types */
+/*---------------------------------------------------------------------------*/
+#define RM_FIRST_MARKER 0x5000 /* First non-relocatable type marker */
+#define RM_RANGE 0x5000 /* Raw data marker - no relocation */
+#define RM_OBJ 0x5001 /* Raw data marker - no relocation */
+#define RM_DWARF_LENGTH 0x5002 /* Raw data marker - no relocation */
+#define RM_LAST_MARKER 0x5002 /* Last non-relocatable type marker */
+
+/*---------------------------------------------------------------------------*/
+/* Macro to determine whether relocation entry has a symbol on the section's */
+/* symbol list. Operator relocation types do not. */
+/*---------------------------------------------------------------------------*/
+#define isunary(x) ((x) == RE_NEG || (x) == RE_NOTB)
+#define isbinary(x) (ismathrel(x) && !isunary(x))
+#define issymrel(x) ((x) == RM_OBJ || (x) == RE_PUSH || \
+ (x) == RE_PUSHSV || (x) < 0x4000)
+#define ismathrel(x) ((x) >= RE_ADD && (x) <= RE_NOTB)
+#define ispushrel(x) (((x) >= RE_PUSH && (x) <= RE_PUSHPC) || ((x) == RE_DUP))
+#define isldfldrel(x) ((x) == RE_ULDFLD || (x) == RE_SLDFLD)
+#define isstfldrel(x) ((x) == RE_USTFLD || (x) == RE_SSTFLD || (x) == RE_XSTFLD )
+#define ismarker(x) ((x) >= RM_FIRST_MARKER && (x) <= RM_LAST_MARKER)
+
+/*---------------------------------------------------------------------------*/
+/* Macro to determine if current relocation entry is a field instruction. */
+/*---------------------------------------------------------------------------*/
+#define isfldrel(x) (((x) >= RE_ULDFLD && (x) <= RE_SSTFLD) || ((x) == RE_XSTFLD))
+
+\f
+/*------------------------------------------------------------------------*/
+/* LINE NUMBER ENTRIES */
+/*------------------------------------------------------------------------*/
+struct lineno
+{
+ union
+ {
+ int l_symndx; /* sym index of fcn name iff l_lnno == 0 */
+ int l_paddr; /* (physical) address of line number */
+ } l_addr;
+ unsigned short l_lnno; /* line number */
+};
+
+#define LINENO struct lineno
+#define LINESZ 6 /* sizeof(LINENO) */
+
+\f
+/*------------------------------------------------------------------------*/
+/* SYMBOL TABLE ENTRIES */
+/*------------------------------------------------------------------------*/
+
+#define FILNMLEN 14 /* Number of characters in a file name */
+#define DIMNUM 4 /* Number of array dimensions in aux entry */
+
+typedef unsigned short DSTYPE;
+
+struct syment
+{
+ union
+ {
+ char _n_name[SYMNMLEN]; /* old COFF version */
+ struct
+ {
+ int _n_zeroes; /* new == 0 */
+ int _n_offset; /* offset into string table */
+ } _n_n;
+ const char *_n_nptr[2]; /* allows for overlaying */
+ } _n;
+
+ int n_value; /* value of symbol */
+ short n_scnum; /* section number */
+ DSTYPE n_type; /* type and derived type */
+ char n_sclass; /* storage class */
+ char n_numaux; /* number of aux. entries */
+};
+
+#define n_name _n._n_name
+#define n_nptr _n._n_nptr[1]
+#define n_zeroes _n._n_n._n_zeroes
+#define n_offset _n._n_n._n_offset
+
+/*------------------------------------------------------------------------*/
+/* Relocatable symbols have a section number of the */
+/* section in which they are defined. Otherwise, section */
+/* numbers have the following meanings: */
+/*------------------------------------------------------------------------*/
+#define N_UNDEF 0 /* undefined symbol */
+#define N_ABS -1 /* value of symbol is absolute */
+#define N_DEBUG -2 /* special debugging symbol */
+
+\f
+/*------------------------------------------------------------------------*/
+/* AUXILIARY SYMBOL ENTRY */
+/*------------------------------------------------------------------------*/
+#define SPACE(len, name) char name[len]
+
+union auxent
+{
+ struct
+ {
+ SPACE(4, _0_3);
+ int x_fsize; /* size of struct in bits. */
+ SPACE(4, _8_11);
+ int x_endndx; /* ptr to next sym beyond .eos */
+ SPACE(2, _16_17);
+ } x_tag;
+
+ struct
+ {
+ int x_tagndx; /* ptr to beginning of struct */
+ int x_fsize; /* size of struct in bits. */
+ SPACE(10, _8_17);
+ } x_eos;
+
+ struct
+ {
+ int x_tagndx; /* ptr to tag for function */
+ int x_fsize; /* size of function in bytes */
+ int x_lnnoptr; /* file ptr to fcn line # */
+ int x_endndx; /* ptr to next sym beyond .ef */
+ SPACE(2, _16_17);
+ } x_func;
+
+ struct
+ {
+ int x_regmask; /* Mask of regs use by func */
+ unsigned short x_lnno; /* line number of block begin */
+ unsigned short x_lcnt; /* # line number entries in func */
+ int x_framesize; /* size of func local vars */
+ int x_endndx; /* ptr to next sym beyond .eb */
+ SPACE(2, _16_17);
+ } x_block;
+
+ struct
+ {
+ int x_tagndx; /* ptr to tag for array type */
+ int x_fsize; /* Size of array in bits. */
+ unsigned short x_dimen[DIMNUM];
+ SPACE(2, _16_17);
+ } x_array;
+
+ struct
+ {
+ int x_tagndx; /* str, un, or enum tag indx */
+ int x_fsize; /* Size of symbol */
+ SPACE(10, _10_17);
+ } x_sym;
+
+ struct
+ {
+ char x_fname[FILNMLEN];
+ } x_file;
+
+ struct
+ {
+ int x_scnlen; /* section length */
+ unsigned short x_nreloc; /* number of reloc entries */
+ unsigned short x_nlinno; /* number of line numbers */
+ SPACE(8, _10_17);
+ } x_scn;
+};
+
+#define SYMENT struct syment
+#define SYMESZ 18 /* sizeof(SYMENT) */
+
+#define AUXENT union auxent
+#define AUXESZ 18 /* sizeof(AUXENT) */
+
+/*------------------------------------------------------------------------*/
+/* NAMES OF "SPECIAL" SYMBOLS */
+/*------------------------------------------------------------------------*/
+#define _BF ".bf"
+#define _EF ".ef"
+#define _STEXT ".text"
+#define _ETEXT "etext"
+#define _SDATA ".data"
+#define _EDATA "edata"
+#define _SBSS ".bss"
+#define _END "end"
+#define _C_ARGS ".args"
+#define _BINITPTR "binit"
+#define _CINITPTR "cinit"
+#define _PINITPTR "pinit"
+#define _ASM_SRC_NAME "$ASM$" /* SPECIAL SYMBOL FOR ASSY SRC DEBUG */
+
+/*------------------------------------------------------------------------*/
+/* HIGH LEVEL LANGUAGE ACCESSIBLE VERSIONS OF THE ABOVE SPECIAL SYMBOLS. */
+/*------------------------------------------------------------------------*/
+#define _STEXT_HLL "___text__"
+#define _ETEXT_HLL "___etext__"
+#define _SDATA_HLL "___data__"
+#define _EDATA_HLL "___edata__"
+#define _SBSS_HLL "___bss__"
+#define _END_HLL "___end__"
+#define _C_ARGSPTR_HLL "___c_args__"
+#define _BINITPTR_HLL "___binit__"
+#define _CINITPTR_HLL "___cinit__"
+#define _PINITPTR_HLL "___pinit__"
+
+/*------------------------------------------------------------------------*/
+/* ENTRY POINT SYMBOLS */
+/*------------------------------------------------------------------------*/
+#define _START "_start"
+#define _MAIN "_main"
+
+/*------------------------------------------------------------------------*/
+/* SYMBOLS USED FOR C++ LOWERING */
+/*------------------------------------------------------------------------*/
+#define _TYPEINFO_ID_PREFIX "__TID_" /* Unique type id for RTTI */
+#define _TEMPLATE_MANGLED_ROOT "__tm__" /* mangled name root for */
+ /* template symbols. */
+#define _TEMPLATE_SIGNATURES "__pt__" /* when distinct_template_ */
+ /* signatures is FALSE, */
+ /* template name is mangled*/
+ /* with this string. */
+#define _PARTIAL_SPEC "__ps__" /* for the first argument */
+ /* list of a partial */
+ /* specialization, this */
+ /* string is used to mangle*/
+ /* the name. */
+#endif
diff --git a/src/interp/coff/coff.mike.h b/src/interp/coff/coff.mike.h
--- /dev/null
@@ -0,0 +1,884 @@
+/**************************************************************************/
+/* COFF.H - Definition of COFF structures and definitions. */
+/* */
+/* This file defines all standard COFF definitions, used by any program */
+/* which reads or writes COFF files. */
+/* */
+/* HISTORY */
+/* --/--/83 - Original (lost in the mists of time) */
+/* --/--/91 - Tektronics relocation entry kludge */
+/* 01/07/94 RET - Reworked file header and relocation entries, add */
+/* COFF version support. (Removed Tek kludge) */
+/* 12/24/95 TMS - Reworked section header structures for COFF 2 */
+/* */
+/**************************************************************************/
+#ifndef COFF_H
+#define COFF_H
+
+#if defined(TOOL_ASSEMBLER)
+ #error The COFF submodule should no longer be used by the assembler; use TICOFF04
+#endif
+
+/*------------------------------------------------------------------------*/
+/* COFF VERSION FLAGS */
+/*------------------------------------------------------------------------*/
+#if !defined(COFF_VERSION_0) && \
+ !defined(COFF_VERSION_1) && \
+ !defined(COFF_VERSION_2)
+#define COFF_VERSION_0 0
+#define COFF_VERSION_1 0
+#define COFF_VERSION_2 1
+#endif
+
+#ifndef COFF_VERSION_0
+#define COFF_VERSION_0 0
+#endif
+
+#ifndef COFF_VERSION_1
+#define COFF_VERSION_1 0
+#endif
+
+#ifndef COFF_VERSION_2
+#define COFF_VERSION_2 0
+#endif
+
+/*------------------------------------------------------------------------*/
+/* COFF MAGIC NUMBERS */
+/*------------------------------------------------------------------------*/
+#define COFF_MAGIC_0 0xc0 /* ORIGINAL VERSION OF COFF */
+#define COFF_MAGIC_1 0xc1
+#define COFF_MAGIC_2 0xc2
+
+/*------------------------------------------------------------------------*/
+/* COFF TARGET ID's (FORMERLY MAGIC NUMBERS) */
+/* NOTE!!! DEFINE THE MACRO "MAGIC" TO BE ONE OF THESE MACROS. */
+/*------------------------------------------------------------------------*/
+#define MAGIC_340 0x90
+#define MAGIC_370 0x91
+#define MAGIC_DSP 0x92
+#define MAGIC_C30 0x93
+#define MAGIC_380 0x94
+#define MAGIC_MVP 0x95
+#define MAGIC_C16 0x96
+#define MAGIC_ARM 0x97
+#define MAGIC_LEAD 0x98
+#define MAGIC_C60 0x99
+#define MAGIC_C8P 0x9a
+#define MAGIC_unused1 0x9b
+#define MAGIC_LEAD3 0x9c
+#define MAGIC_ANKOOR 0x9d
+#define MAGIC_unused 0x9e
+#define MAGIC_TARANTULA 0x9f
+#define MAGIC_MSP 0xA0
+#define MAGIC_LEAD3_R35 0xA1
+
+#define MAGIC_MIN 0x90 /* MINIMUM VALID MAGIC NUMBER */
+#define MAGIC_MAX 0xA1 /* MAXIMUM VALID MAGIC NUMBER */
+
+/*------------------------------------------------------------------------*/
+/* Macros to recognize magic numbers */
+/* NOTE: ISMAGIC() is now a target-specific macro defined in coff_trg.h */
+/*------------------------------------------------------------------------*/
+#define ISCOFF(x) (ISCOFF_0(x)||ISCOFF_1(x)||ISCOFF_2(x)||ISMAGIC(x))
+#define BADMAGIC(x) (((unsigned short)(x) & 0x8080) && !ISMAGIC(x))
+
+#define ISEXE(x) ((x >> 1) & 0x0001)
+
+#if COFF_VERSION_2
+#define ISCOFF_0(x) ((unsigned short)(x) == COFF_MAGIC_0)
+#define ISCOFF_1(x) ((unsigned short)(x) == COFF_MAGIC_1)
+#define ISCOFF_2(x) ((unsigned short)(x) == COFF_MAGIC_2)
+#elif COFF_VERSION_1
+#define ISCOFF_0(x) ((unsigned short)(x) == COFF_MAGIC_0)
+#define ISCOFF_1(x) ((unsigned short)(x) == COFF_MAGIC_1)
+#define ISCOFF_2(x) FALSE
+#else
+#define ISCOFF_0(x) FALSE
+#define ISCOFF_1(x) FALSE
+#define ISCOFF_2(x) FALSE
+#endif
+
+#define ISMAGIC_ANY(x) (((unsigned short)(x)) >= MAGIC_MIN && \
+ ((unsigned short)(x)) <= MAGIC_MAX)
+#define ISCOFF_ANY(x) (ISCOFF_0(x) || ISCOFF_1(x) || \
+ ISCOFF_2(x) || ISMAGIC_ANY(x))
+
+#include "coffdefs.h"
+
+/*------------------------------------------------------------------------*/
+/* COFF FILE HEADER */
+/*------------------------------------------------------------------------*/
+struct filehdr
+{
+ unsigned short f_magic; /* magic number */
+ unsigned short f_nscns; /* number of sections */
+ unsigned int f_timdat; /* time & date stamp */
+ unsigned int f_symptr; /* file pointer to symtab */
+ unsigned int f_nsyms; /* number of symtab entries */
+ unsigned short f_opthdr; /* sizeof(optional hdr) */
+ unsigned short f_flags; /* flags */
+ unsigned short f_target_id; /* target architecture id */
+};
+
+#define FILHDR struct filehdr
+#define FILHSZ (COFF_VERSION_0 ? 20 : 22)
+#define FILHSZ_IN(version) (version >= COFF_MAGIC_1 ? 22 : 20)
+
+/*------------------------------------------------------------------------*/
+/* File header flags */
+/*------------------------------------------------------------------------*/
+#define F_RELFLG 0x01 /* relocation info stripped from file */
+#define F_EXEC 0x02 /* file is executable (no unresolved refs) */
+#define F_LNNO 0x04 /* line nunbers stripped from file */
+#define F_LSYMS 0x08 /* local symbols stripped from file */
+
+ /*------------------------------------------------------------------------*/
+/* Target device identification flags (bits 4-7 in file header flags) */
+/*------------------------------------------------------------------------*/
+#define F_VERS0 0x0 /* 0th generation CPU */
+#define F_VERS1 0x10 /* 1st generation CPU */
+#define F_VERS2 0x20 /* 2nd generation CPU */
+#define F_VERS3 0x40 /* 3rd generation CPU */
+#define F_VERS4 0x80 /* 4th generation CPU */
+#define F_VERSION (F_VERS1 | F_VERS2 | F_VERS3 | F_VERS4)
+
+/*------------------------------------------------------------------------*/
+/* Target device raw data byte ordering flags (bits 8-9) */
+/*------------------------------------------------------------------------*/
+#define F_LITTLE 0x100 /* object code is LSB first */
+#define F_BIG 0x200 /* object code is MSB first */
+#define F_BYTE_ORDER (F_LITTLE | F_BIG)
+
+#define F_SYMMERGE 0x1000 /* Tags, etc were merged - no duplicates */
+
+#define F_ICODE 0x2000 /* This file contains embedded I-Code */
+
+\f
+/*------------------------------------------------------------------------*/
+/* OPTIONAL FILE HEADER */
+/*------------------------------------------------------------------------*/
+typedef struct aouthdr
+{
+ short magic; /* optional file header magic number */
+ short vstamp; /* version stamp */
+ int tsize; /* text size in bytes, padded to FW bdry*/
+ int dsize; /* initialized data " " */
+ int bsize; /* uninitialized data " " */
+ int entrypt; /* entry pt. */
+ int text_start; /* base of text used for this file */
+ int data_start; /* base of data used for this file */
+} AOUTHDR;
+
+#define AOUTSZ sizeof(AOUTHDR)
+#define AOUT1MAGIC 0x108
+
+\f
+/*------------------------------------------------------------------------*/
+/* COMMON ARCHIVE FILE STRUCTURES */
+/* */
+/* ARCHIVE File Organization: */
+/* +---------------------------------------------+ */
+/* | ARCHIVE_MAGIC_STRING | */
+/* +---------------------------------------------+ */
+/* | ARCHIVE_FILE_MEMBER_1 | */
+/* +- - - - - - - - - - - - - - - - - - - - - - -+ */
+/* | Archive File Header "ar_hdr" | */
+/* | Contents (Ext symbol direct, text file) | */
+/* +---------------------------------------------+ */
+/* | ARCHIVE_FILE_MEMBER_2 | */
+/* +- - - - - - - - - - - - - - - - - - - - - - -+ */
+/* | Archive File Header "ar_hdr" | */
+/* | Contents (long file member name table) | */
+/* +---------------------------------------------+ */
+/* | ARCHIVE_FILE_MEMBER_3 | */
+/* +- - - - - - - - - - - - - - - - - - - - - - -+ */
+/* | Archive File Header "ar_hdr" | */
+/* | Contents (.o or text file) | */
+/* +---------------------------------------------+ */
+/* | . . . | */
+/* | . . . | */
+/* | . . . | */
+/* +---------------------------------------------+ */
+/* | ARCHIVE_FILE_MEMBER_n | */
+/* +- - - - - - - - - - - - - - - - - - - - - - -+ */
+/* | Archive File Header "ar_hdr" | */
+/* | Contents (.o or text file) | */
+/* +---------------------------------------------+ */
+/* */
+/*------------------------------------------------------------------------*/
+
+#define ARMAG "!<arch>\n"
+#define SARMAG 8
+#define ARFMAG "`\n"
+#define ARFMAG_SIZE 2
+
+struct ar_hdr /* archive file member header - printable ascii */
+{
+ char ar_name[16]; /* file member name - `/' terminated */
+ char ar_date[12]; /* file member date - decimal */
+ char ar_offset[6]; /* file member offset - decimal */
+ char ar_gid[6]; /* file member group id - decimal */
+ char ar_mode[8]; /* file member mode - octal */
+ char ar_size[10]; /* file member size - decimal */
+ char ar_fmag[2]; /* ARFMAG - string to end header */
+};
+
+#define ARHDR struct ar_hdr
+#define ARHSZ sizeof(ARHDR)
+#define AR_HDR_SZ sizeof(ARHDR)
+#define AR_FNAME_SIZE 16
+#define MAGIC_LONGFILENAME 1
+#define LONGFILENAME "<filenames>"
+#define SYMDIRNAME "/ "
+
+\f
+/*------------------------------------------------------------------------*/
+/* SECTION HEADER */
+/*------------------------------------------------------------------------*/
+#define SYMNMLEN 8 /* Number of characters in a symbol name */
+
+/*------------------------------------------------------------------------*/
+/* THE OLD COFF VERSION TYPE DEFINITION FOR SECTION HEADERS TO PROVIDE */
+/* BACKWARDS COMPATIBILITY FOR COFF-DEPENDENT TOOLS THAT SUPPORT COFF 2. */
+/*------------------------------------------------------------------------*/
+struct o_scnhdr
+{
+ char os_name[8]; /* section name */
+ int os_paddr; /* physical address */
+ int os_vaddr; /* virtual address */
+ int os_size; /* section size */
+ int os_scnptr; /* file ptr to raw data for scn */
+ int os_relptr; /* file ptr to relocation */
+ int os_lnnoptr; /* file ptr to line numbers */
+ unsigned short os_nreloc; /* number of relocation entries */
+ unsigned short os_nlnno; /* number of line number entries */
+ unsigned short os_flags; /* flags */
+ char os_reserved; /* reserved byte */
+ unsigned char os_page; /* memory page id */
+};
+
+/*------------------------------------------------------------------------*/
+/* THE NEW COFF VERSION TYPE DEFINITION FOR SECTION HEADERS. THIS */
+/* REVISION ALLOWS FOR UNRESTRICTED SECTION NAME LENGTH. */
+/*------------------------------------------------------------------------*/
+struct scnhdr
+{
+ union
+ {
+ char _s_name[SYMNMLEN]; /* old COFF version name fld */
+ struct
+ {
+ int _s_zeroes; /* new == 0 */
+ int _s_offset; /* offset into string table */
+ } _s_s;
+ char *_s_nptr[2]; /* allows for overlaying */
+ } _s;
+
+ int s_paddr; /* physical address */
+ int s_vaddr; /* virtual address */
+ int s_size; /* section size */
+ int s_scnptr; /* file ptr to raw data for section */
+ int s_relptr; /* file ptr to relocation */
+ int s_lnnoptr; /* file ptr to line numbers */
+ unsigned int s_nreloc; /* number of relocation entries */
+ unsigned int s_nlnno; /* number of line number entries */
+ unsigned int s_flags; /* flags */
+ unsigned char s_mwidth; /* memory width in bits */
+ /* (0 == target memory width) */
+ unsigned char s_reserved; /* reserved byte */
+ unsigned short s_page; /* memory page id */
+};
+
+#define s_name _s._s_name
+#define s_nptr _s._s_nptr[1]
+#define s_zeroes _s._s_s._s_zeroes
+#define s_offset _s._s_s._s_offset
+
+#define O_SCNHDR struct o_scnhdr
+#define SCNHDR struct scnhdr
+#define O_SCNHSZ sizeof(O_SCNHDR)
+#define SCNHSZ sizeof(SCNHDR)
+#define SCNHSZ_IN(version) (version == COFF_MAGIC_2 ? SCNHSZ : O_SCNHSZ)
+
+/*------------------------------------------------------------------------*/
+/* Define constants for names of "special" sections */
+/*------------------------------------------------------------------------*/
+#define _TEXT ".text"
+#define _DATA ".data"
+#define _BSS ".bss"
+#define _REG ".reg"
+#define _BINIT ".binit"
+#define _CINIT ".cinit"
+#define _PINIT ".pinit"
+#define _ICODE ".icode"
+
+#define _OVLY_PREFIX ".ovly:"
+
+#define IS_DWARF_SECTION(name) (!strncmp(name, ".debug_", 7))
+
+/*------------------------------------------------------------------------*/
+/* Bits 0-8 of s_flags are used as a section "type" */
+/*------------------------------------------------------------------------*/
+#define STYP_REG 0x00 /* "regular" : allocated, relocated, loaded */
+#define STYP_DSECT 0x01 /* "dummy" : !allocated, relocated, !loaded */
+#define STYP_NOLOAD 0x02 /* "noload" : allocated, relocated, !loaded */
+#define STYP_XXX1 0x04 /* not used - was STYP_GROUP */
+#define STYP_XXX2 0x08 /* not used - was STYP_PAD */
+#define STYP_COPY 0x10 /* "copy" : used for C init tables -
+ not allocated, relocated,
+ loaded; reloc & lineno
+ entries processed normally */
+#define STYP_TEXT 0x20 /* section contains text only */
+#define STYP_DATA 0x40 /* section contains data only */
+#define STYP_BSS 0x80 /* section contains bss only */
+
+/*------------------------------------------------------------------------*/
+/* Bits 8-11 specify an alignment. The alignment is (2 ** x), where x is */
+/* is the encoded value */
+/*------------------------------------------------------------------------*/
+#define ALIGN_MASK 0xF00 /* mask for alignment factor */
+#define ALIGN_SIZE(s_flag) (1 << (((unsigned)s_flag & ALIGN_MASK) >> 8))
+#define ALIGN_GET(header) (((header).s_flags & ALIGN_MASK) >> 8)
+#define ALIGN_SET(header,amt) (header).s_flags = \
+ (((header).s_flags & ~ALIGN_MASK) | ((amt << 8) & ALIGN_MASK))
+
+/*------------------------------------------------------------------------*/
+/* bit 12-31 */
+/*------------------------------------------------------------------------*/
+#define STYP_BLOCK 0x01000 /* use alignment as blocking factor */
+#define STYP_PASS 0x02000 /* Pass section through unchanged */
+#define STYP_CLINK 0x04000 /* Conditionally link section */
+
+#define STYP_VECTOR 0x08000 /* section contains vector table */
+ /* (Used in addition to STYP_TEXT) */
+
+#define STYP_PADDED 0x10000 /* section HAS BEEN padded. Do not pad */
+ /* again if partial linking. */
+#define STYP_ICODE 0x20000 /* section has ICODE associated with it */
+
+#define STYP_LGT 0x40000 /* linker generated table section */
+#define STYP_COMMON 0x80000 /* comdat section - remove duplicates */
+
+#define STYP_BASIC_MASK 0xFF /* basic section types */
+#define STYP_TIEXT_MASK 0xFF000 /* TI section type extensions */
+
+/*------------------------------------------------------------------------*/
+/* A mask for all the flags we support - anything else is garbage. */
+/*------------------------------------------------------------------------*/
+#define STYP_KNOWN_MASK (ALIGN_MASK | STYP_BASIC_MASK | STYP_TIEXT_MASK)
+
+\f
+/*------------------------------------------------------------------------*/
+/* RELOCATION ENTRIES */
+/* WE SUPPORT TWO TYPES OF RELOCATION ENTRIES: */
+/* 1) OLD STYLE, WITH 16 BIT SYMBOL TABLE INDEX. */
+/* 2) NEW STYLE, WITH 32 BIT SYMBOL TABLE INDEX. */
+/* FOR ANY GIVEN INPUT FILE, THE FILE HEADER FLAG "F_RELOC_12" INDICATES */
+/* THE TYPE OF RELOCATION ENTRY IN THE FILE. */
+/* THE TARGET-SPECIFIC FLAG RELOC_ENTRY_12 DETERMINES WHETHER THE NEW */
+/* STYLE IS SUPPORTED ON A GIVEN TARGET. */
+/*------------------------------------------------------------------------*/
+typedef struct reloc_old
+{
+ int r_vaddr; /* (virtual) address of reference */
+
+ union {
+ struct {
+ unsigned char _offset; /* bit offset of rel fld */
+ unsigned char _fieldsz; /* size of rel fld */
+ unsigned char _wordsz; /* # bytes containing rel fld */
+ unsigned char _dum1;
+
+ unsigned short _type;
+ } _r_field;
+
+ struct {
+ unsigned int _spc; /* section relative PC */
+ unsigned short _type; /* relocation type */
+ } _r_spc;
+
+ struct {
+ unsigned int _uval; /* constant value */
+ unsigned short _type; /* relocation type */
+ } _r_uval;
+
+ struct {
+ short _symndx; /* 32-bit sym tbl index */
+ unsigned short _disp; /* extra addr encode data */
+ unsigned short _type; /* relocation type */
+ } _r_sym;
+ } _u_reloc;
+} RELOC_OLD;
+
+/*------------------------------------------------------------------------*/
+/* MAKE SURE THE RELOCATION STRUCTURE IS TIGHTLY PACKED TO AVOID HOST */
+/* ALIGNMENT MECHANISMS. */
+/*------------------------------------------------------------------------*/
+typedef struct reloc
+{
+ int r_vaddr; /* (virtual) address of reference */
+
+ union {
+ struct {
+ unsigned char _offset; /* bit offset of rel fld */
+ unsigned char _fieldsz; /* size of rel fld */
+ unsigned char _wordsz; /* # bytes containing rel fld */
+ unsigned char _dum1;
+ unsigned short _dum2;
+
+ unsigned short _type;
+ } _r_field;
+
+ struct {
+ unsigned int _spc; /* section relative PC */
+ unsigned short _dum;
+ unsigned short _type; /* relocation type */
+ } _r_spc;
+
+ struct {
+ unsigned int _uval; /* constant value */
+ unsigned short _dum;
+ unsigned short _type; /* relocation type */
+ } _r_uval;
+
+ struct {
+ int _symndx; /* 32-bit sym tbl index */
+ unsigned short _disp; /* extra addr encode data */
+ unsigned short _type; /* relocation type */
+ } _r_sym;
+ } _u_reloc;
+} RELOC;
+
+#define RELSZ (COFF_VERSION_0 ? 10 : 12)
+#define RELSZ_IN(version) ((version >= COFF_MAGIC_1) ? 12 : 10)
+
+/*------------------------------------------------------------------------*/
+/* Macros for accessing fields in relocation entry data structure. */
+/*------------------------------------------------------------------------*/
+#define r_offset _u_reloc._r_field._offset
+#define r_fieldsz _u_reloc._r_field._fieldsz
+#define r_wordsz _u_reloc._r_field._wordsz
+
+#define r_spc _u_reloc._r_spc._spc
+#define r_uval _u_reloc._r_uval._uval
+
+#define r_symndx _u_reloc._r_sym._symndx
+#define r_disp _u_reloc._r_sym._disp
+#define r_type _u_reloc._r_sym._type
+
+/*------------------------------------------------------------------------*/
+/* define all relocation types */
+/*------------------------------------------------------------------------*/
+#define R_ABS 0x0 /* absolute address - no relocation */
+#define R_DIR16 0x1 /* UNUSED */
+#define R_REL16 0x2 /* UNUSED */
+#define R_DIR24 0x4 /* UNUSED */
+#define R_REL24 0x5 /* 24 bits, direct */
+#define R_DIR32 0x6 /* UNUSED */
+#define R_RRRELREG 0xe /* RR: 8 bit relocatable register */
+
+#define R_RELBYTE 0xf /* 8 bits, direct */
+#define R_RELWORD 0x10 /* 16 bits, direct */
+#define R_RELLONG 0x11 /* 32 bits, direct */
+#define R_PCRBYTE 0x12 /* 8 bits, PC-relative */
+#define R_PCRWORD 0x13 /* 16 bits, PC-relative */
+#define R_PCRLONG 0x14 /* 32 bits, PC-relative */
+ /* (See unsigned (LD3) versions below.) */
+#define R_PCR24 0x15 /* 24 bits, PC-relative */
+#define R_PCR23H 0x16 /* 23 bits, PC-rel in halfwords(x>>1) */
+#define R_PCR24W 0x17 /* 24 bits, PC-rel in words (x >> 2) */
+#define R_OCRLONG 0x18 /* GSP: 32 bits, one's compl direct */
+#define R_GSPPCR16 0x19 /* GSP: 16 bits, PC relative (in words) */
+#define R_GSPOPR32 0x1a /* GSP: 32 bits, direct big-endian */
+#define R_GSPPCA16 0x1b /* GSP: same as GSPPCR16, but PC const */
+#define R_OCBD32 0x1c /* GSP: 32 bits, 1's compl,big-endian */
+#define R_RRNREG 0x1d /* RR: 8 bit reloc. reg. w/ neg off */
+#define R_PARTLS16 0x20 /* Brahma: 16 bit offset of 24 bit addr */
+#define R_PARTMS8 0x21 /* Brahma: 8 bit page of 24 bit addr */
+#define R_PARTLS7 0x28 /* DSP: 7 bit offset of 16 bit addr */
+#define R_PARTMS9 0x29 /* DSP: 9 bit page of 16 bit addr */
+#define R_REL13 0x2a /* DSP: 13 bits, direct */
+#define R_REL23 0x2b /* DSP,C54X: 23 bits, direct (ext addr) */
+#define R_RELXPC 0x2c /* DSP,C54X: 16 bits, relative to XPC */
+#define R_HIEXT 0x2d /* C54X: Hi word of extended prog addr */
+#define R_HIWORD 0x31 /* RR: 8 bit reloc. hi byte of word */
+#define R_LABCOD 0x32 /* C16 16-bit code address relocation */
+
+#define R_PPBASE 0x34 /* PP: Global Base address type */
+#define R_PPLBASE 0x35 /* PP: Local Base address type */
+#define R_PP15 0x38 /* PP: Global 15 bit offset */
+#define R_PP15W 0x39 /* PP: Global 15 bit offset / 4 */
+#define R_PP15H 0x3a /* PP: Global 15 bit offset / 2 */
+#define R_PP16B 0x3b /* PP: Global 16 bit offset for bytes */
+#define R_PPL15 0x3c /* PP: Local 15 bit offset */
+#define R_PPL15W 0x3d /* PP: Local 15 bit offset divided by 4 */
+#define R_PPL15H 0x3e /* PP: Local 15 bit offset divided by 2 */
+#define R_PPL16B 0x3f /* PP: Local 16 bit offset for bytes */
+#define R_PPN15 0x40 /* PP: Global 15 bit neg offset */
+#define R_PPN15W 0x41 /* PP: Global 15 bit neg offset / 4 */
+#define R_PPN15H 0x42 /* PP: Global 15 bit neg offset / 2 */
+#define R_PPN16B 0x43 /* PP: Global 16 bit neg byte offset */
+#define R_PPLN15 0x44 /* PP: Local 15 bit neg offset */
+#define R_PPLN15W 0x45 /* PP: Local 15 bit neg offset / 4 */
+#define R_PPLN15H 0x46 /* PP: Local 15 bit neg offset / 2 */
+#define R_PPLN16B 0x47 /* PP: Local 16 bit neg byte offset */
+
+#define R_MPPCR 0x4f /* MP: 32-bit PC-relative / 4 */
+
+#define R_C60BASE 0x50 /* C60: Data Page Pointer Based Offset */
+#define R_C60DIR15 0x51 /* C60: LD/ST long Displacement */
+#define R_C60PCR21 0x52 /* C60: 21-bit PC Relative */
+#define R_C60PCR10 0x53 /* C60: 10-bit PC Relative */
+#define R_C60LO16 0x54 /* C60: MVK Low Half Register */
+#define R_C60HI16 0x55 /* C60: MVKH/MVKLH High Half Register */
+#define R_C60SECT 0x56 /* C60: Section-Based Offset */
+#define R_C60S16 0x57 /* C60: Signed 16-bit */
+#define R_C60PCR7 0x70 /* C60: 7-bit PC Relative */
+#define R_C60PCR12 0x71 /* C60: 12-bit PC Relative */
+#define R_C60PCR12H 0x72 /* C60: 12-bit PC Relative (Half) */
+#define R_C60PCR7J 0x73 /* C60: 7-bit PC Relative (-BNOP) */
+#define R_C60PCR8J 0x74 /* C60: 8-bit PC Relative (-BNOP) */
+#define R_C60PCR10J 0x75 /* C60: 10-bit PC Relative (-CALLP) */
+#define R_C60ALIGN 0x76 /* C60: Alignment info for compressor */
+#define R_C60FPHEAD 0x77 /* C60: Explicit assembly directive */
+#define R_C60NOCMP 0x100 /* C60: Don't compress this code scn */
+
+#define R_C8PHIBYTE 0x58 /* C8+: High byte of 24-bit address. */
+#define R_C8PMIDBYTE 0x59 /* C8+: Middle byte of 24-bit address. */
+#define R_C8PVECADR 0x5a /* C8+: Vector address (0xFFnnnn) */
+#define R_C8PADR24 0x5b /* C8+: 24-bit address (rev byte order) */
+
+#define R_PARTLS6 0x5d /* ANKOOR: 6 bit offset of 22 bit addr */
+#define R_PARTMID10 0x5e /* ANKOOR: Middle 10 bits of 22 bit addr*/
+#define R_REL22 0x5f /* ANKOOR: 22 bits, direct */
+#define R_PARTMS6 0x60 /* ANKOOR: Upper 6 bits of 22 bit addr */
+#define R_PARTMS16 0x61 /* ANKOOR: Upper 16 bits of 22 bit addr */
+#define R_ANKPCR16 0x62 /* ANKOOR: PC relative 16 bit */
+#define R_ANKPCR8 0x63 /* ANKOOR: PC relatvie 8 bit */
+#define R_ANKPTR 0x64 /* ANKOOR: 22 bit pointer */
+#define R_ANKHI16 0x65 /* ANKOOR: HI 16 bits of address + data */
+#define R_ANKLOPTR 0x66 /* ANKOOR: Pointer to low 64K */
+#define R_ANKNWORD 0x67 /* ANKOOR: 16 bit negated relocation */
+#define R_ANKNBYTE 0x68 /* ANKOOR: 8 bit negated relocation */
+#define R_ANKHIBYTE 0x69 /* ANKOOR: High byte of a word */
+#define R_REL13_SE16 0x6a /* MANTRA: 13 bit sign extend to 16 bit */
+
+#define R_LD3_DMA 0x78 /* LEAD3: 7 most sig bits of a byte, */
+ /* unsigned value; used in DMA address */
+ /* */
+ /* 5432109876543210 */
+ /* xxxxxxxxFFFFFFFx */
+
+#define R_LD3_MDP 0x7a /* LEAD3: 7 bits spanning two bytes, */
+ /* unsigned value; used as MDP reg value*/
+ /* */
+ /* 321098765432109876543210 */
+ /* xxxxxxxxxxxxxFFFFFFFxxxx */
+
+#define R_LD3_PDP 0x7b /* LEAD3: 9 bits spanning two bytes, */
+ /* unsigned value; used as PDP reg value*/
+ /* */
+ /* 321098765432109876543210 */
+ /* xxxxxxxxxxxFFFFFFFFFxxxx */
+
+#define R_LD3_REL23 0x7c /* LEAD3: 23 bit unsigned value in a */
+ /* 24-bit-wide field */
+
+
+#define R_TARBASE 0x80 /* TARANTULA: Data Page Pointer Based Off */
+#define R_TARDIR12 0x81 /* TARANTULA: LD/ST long Displacement */
+#define R_TARLO16 0x82 /* TARANTULA: MVK Low Half Register */
+#define R_TARHI16 0x83 /* TARANTULA: MVKH/MVKLH High Half Reg */
+#define R_TARSECT 0x84 /* TARANTULA: Section-based offset */
+
+#define R_LD3_k8 0x88 /* LD3: Unsigned 8 bit, direct */
+#define R_LD3_k16 0x89 /* LD3: Unsigned 16 bit, direct */
+#define R_LD3_K8 0x8a /* LD3: Signed 8 bit, direct */
+#define R_LD3_K16 0x8b /* LD3: Signed 16 bit, direct */
+
+#define R_LD3_l8 0x8c /* LD3: Unsigned 8 bit, PC-relative */
+#define R_LD3_l16 0x8d /* LD3: Unsigned 16 bit, PC-relative */
+#define R_LD3_L8 0x8e /* LD3: Signed 8 bit, PC-relative */
+#define R_LD3_L16 0x8f /* LD3: Signed 16 bit, PC-relative */
+
+#define R_LD3_k4 0x90 /* LD3: Unsigned 4 bit shift immediate */
+#define R_LD3_k5 0x91 /* LD3: Unsigned 5 bit shift immediate */
+#define R_LD3_K5 0x92 /* LD3: Signed 5 bit shift immediate */
+#define R_LD3_k6 0x93 /* LD3: Unsigned 6 bit immediate */
+#define R_LD3_k12 0x94 /* LD3: Unsigned 12 bit immediate */
+#define R_LD3_ABS16 0x95 /* LD3: abs16(addr) truncated k16 */
+
+#define R_NONE 0x96 /* Encode dependencies between sections */
+
+#define R_MSP_PCR20_SRC 0x97 /* MSP: PC-rel 20-bit src ext encoding */
+#define R_MSP_PCR20_DST 0x98 /* MSP: PC-rel 20-bit dst ext encoding */
+#define R_MSP_PCR20_ODST 0x99 /* MSP: PC-rel 20-bit offset dst ext enc */
+#define R_MSP_EXT20_SRC 0x9A /* MSP: Relative 20-bit src ext encoding */
+#define R_MSP_EXT20_DST 0x9B /* MSP: Relative 20-bit dst ext encoding */
+#define R_MSP_EXT20_ODST 0x9C /* MSP: Rel 20-bit offset dst ext encoding */
+#define R_MSP_REL20_SRC 0x9D /* MSP: Relative 20-bit src opnd */
+#define R_MSP_REL20_DST 0x9E /* MSP: Relative 20-bit dst opnd */
+#define R_MSP_PCR16 0x9F /* MSP: PC-rel 16-bit encoding */
+#define R_MSP_PCR20_CALL 0xA0 /* MSP: PC-rel 20-bit call operand */
+#define R_MSP_REL16 0xA1 /* MSP: Relative 16-bit (20bit MSPx device)*/
+
+#define R_T2_PCR24H 0xA2 /* THUMB2: 24 bits, PC-rel in halfwords(x>>1) */
+#define R_T2_PCR20H 0xA3 /* THUMB2: 20 bits, PC-rel in halfwords(x>>1) */
+
+#define R_LD3_ABS24 0xA4 /* C55x+: LD_R_ABS, ST_R_ABS -- *(#k24) */
+#define R_LD3_SP_K9 0xA5 /* C55x+: SP += K9 w/ K9 encoded as (K9 >> 1) */
+\f
+/*---------------------------------------------------------------------------*/
+/* GENERIC relocation types for complex relocation expressions. */
+/* *** NOTE: This range of relocation types exists above 0x4000 *** */
+/* *** NOTE: Top bit of relocation type field used as SEGVALUE flag *** */
+/*---------------------------------------------------------------------------*/
+#define RE_ADD 0x4000 /* Operator Instructions: + */
+#define RE_SUB 0x4001 /* - */
+#define RE_NEG 0x4002 /* unary - */
+#define RE_MPY 0x4003 /* * */
+#define RE_DIV 0x4004 /* / */
+#define RE_MOD 0x4005 /* % */
+
+#define RE_SR 0x4006 /* >>u */
+#define RE_ASR 0x4007 /* >>s */
+#define RE_SL 0x4008 /* << */
+
+#define RE_AND 0x4009 /* & */
+#define RE_OR 0x400a /* | */
+#define RE_XOR 0x400b /* ^ */
+#define RE_NOTB 0x400c /* ~ */
+
+#define RE_ULDFLD 0x400d /* unsigned relocation field load */
+#define RE_SLDFLD 0x400e /* signed relocation field load */
+#define RE_USTFLD 0x400f /* unsigned relocation field store */
+#define RE_SSTFLD 0x4010 /* signed relocation field store */
+#define RE_XSTFLD 0x4016 /* signedness is irrelevant */
+
+#define RE_PUSH 0x4011 /* push symbol on the stack */
+#define RE_PUSHSV 0xc011 /* push symbol: SEGVALUE flag set */
+#define RE_PUSHSK 0x4012 /* push signed constant on the stack */
+#define RE_PUSHUK 0x4013 /* push unsigned constant on the stack */
+#define RE_PUSHPC 0x4014 /* push current section PC on the stack */
+#define RE_DUP 0x4015 /* duplicate tos and push copy */
+
+/*---------------------------------------------------------------------------*/
+/* Other useful generic relocation types */
+/*---------------------------------------------------------------------------*/
+#define RM_FIRST_MARKER 0x5000 /* First non-relocatable type marker */
+#define RM_RANGE 0x5000 /* Raw data marker - no relocation */
+#define RM_OBJ 0x5001 /* Raw data marker - no relocation */
+#define RM_DWARF_LENGTH 0x5002 /* Raw data marker - no relocation */
+#define RM_LAST_MARKER 0x5002 /* Last non-relocatable type marker */
+
+/*---------------------------------------------------------------------------*/
+/* Macro to determine whether relocation entry has a symbol on the section's */
+/* symbol list. Operator relocation types do not. */
+/*---------------------------------------------------------------------------*/
+#define isunary(x) ((x) == RE_NEG || (x) == RE_NOTB)
+#define isbinary(x) (ismathrel(x) && !isunary(x))
+#define issymrel(x) ((x) == RM_OBJ || (x) == RE_PUSH || \
+ (x) == RE_PUSHSV || (x) < 0x4000)
+#define ismathrel(x) ((x) >= RE_ADD && (x) <= RE_NOTB)
+#define ispushrel(x) (((x) >= RE_PUSH && (x) <= RE_PUSHPC) || ((x) == RE_DUP))
+#define isldfldrel(x) ((x) == RE_ULDFLD || (x) == RE_SLDFLD)
+#define isstfldrel(x) ((x) == RE_USTFLD || (x) == RE_SSTFLD || (x) == RE_XSTFLD )
+#define ismarker(x) ((x) >= RM_FIRST_MARKER && (x) <= RM_LAST_MARKER)
+
+/*---------------------------------------------------------------------------*/
+/* Macro to determine if current relocation entry is a field instruction. */
+/*---------------------------------------------------------------------------*/
+#define isfldrel(x) (((x) >= RE_ULDFLD && (x) <= RE_SSTFLD) || ((x) == RE_XSTFLD))
+
+\f
+/*------------------------------------------------------------------------*/
+/* LINE NUMBER ENTRIES */
+/*------------------------------------------------------------------------*/
+struct lineno
+{
+ union
+ {
+ int l_symndx; /* sym index of fcn name iff l_lnno == 0 */
+ int l_paddr; /* (physical) address of line number */
+ } l_addr;
+ unsigned short l_lnno; /* line number */
+};
+
+#define LINENO struct lineno
+#define LINESZ 6 /* sizeof(LINENO) */
+
+\f
+/*------------------------------------------------------------------------*/
+/* SYMBOL TABLE ENTRIES */
+/*------------------------------------------------------------------------*/
+
+#define FILNMLEN 14 /* Number of characters in a file name */
+#define DIMNUM 4 /* Number of array dimensions in aux entry */
+
+typedef unsigned short DSTYPE;
+
+struct syment
+{
+ union
+ {
+ char _n_name[SYMNMLEN]; /* old COFF version */
+ struct
+ {
+ int _n_zeroes; /* new == 0 */
+ int _n_offset; /* offset into string table */
+ } _n_n;
+ const char *_n_nptr[2]; /* allows for overlaying */
+ } _n;
+
+ int n_value; /* value of symbol */
+ short n_scnum; /* section number */
+ DSTYPE n_type; /* type and derived type */
+ char n_sclass; /* storage class */
+ char n_numaux; /* number of aux. entries */
+};
+
+#define n_name _n._n_name
+#define n_nptr _n._n_nptr[1]
+#define n_zeroes _n._n_n._n_zeroes
+#define n_offset _n._n_n._n_offset
+
+/*------------------------------------------------------------------------*/
+/* Relocatable symbols have a section number of the */
+/* section in which they are defined. Otherwise, section */
+/* numbers have the following meanings: */
+/*------------------------------------------------------------------------*/
+#define N_UNDEF 0 /* undefined symbol */
+#define N_ABS -1 /* value of symbol is absolute */
+#define N_DEBUG -2 /* special debugging symbol */
+
+\f
+/*------------------------------------------------------------------------*/
+/* AUXILIARY SYMBOL ENTRY */
+/*------------------------------------------------------------------------*/
+#define SPACE(len, name) char name[len]
+
+union auxent
+{
+ struct
+ {
+ SPACE(4, _0_3);
+ int x_fsize; /* size of struct in bits. */
+ SPACE(4, _8_11);
+ int x_endndx; /* ptr to next sym beyond .eos */
+ SPACE(2, _16_17);
+ } x_tag;
+
+ struct
+ {
+ int x_tagndx; /* ptr to beginning of struct */
+ int x_fsize; /* size of struct in bits. */
+ SPACE(10, _8_17);
+ } x_eos;
+
+ struct
+ {
+ int x_tagndx; /* ptr to tag for function */
+ int x_fsize; /* size of function in bytes */
+ int x_lnnoptr; /* file ptr to fcn line # */
+ int x_endndx; /* ptr to next sym beyond .ef */
+ SPACE(2, _16_17);
+ } x_func;
+
+ struct
+ {
+ int x_regmask; /* Mask of regs use by func */
+ unsigned short x_lnno; /* line number of block begin */
+ unsigned short x_lcnt; /* # line number entries in func */
+ int x_framesize; /* size of func local vars */
+ int x_endndx; /* ptr to next sym beyond .eb */
+ SPACE(2, _16_17);
+ } x_block;
+
+ struct
+ {
+ int x_tagndx; /* ptr to tag for array type */
+ int x_fsize; /* Size of array in bits. */
+ unsigned short x_dimen[DIMNUM];
+ SPACE(2, _16_17);
+ } x_array;
+
+ struct
+ {
+ int x_tagndx; /* str, un, or enum tag indx */
+ int x_fsize; /* Size of symbol */
+ SPACE(10, _10_17);
+ } x_sym;
+
+ struct
+ {
+ char x_fname[FILNMLEN];
+ } x_file;
+
+ struct
+ {
+ int x_scnlen; /* section length */
+ unsigned short x_nreloc; /* number of reloc entries */
+ unsigned short x_nlinno; /* number of line numbers */
+ SPACE(8, _10_17);
+ } x_scn;
+};
+
+#define SYMENT struct syment
+#define SYMESZ 18 /* sizeof(SYMENT) */
+
+#define AUXENT union auxent
+#define AUXESZ 18 /* sizeof(AUXENT) */
+
+/*------------------------------------------------------------------------*/
+/* NAMES OF "SPECIAL" SYMBOLS */
+/*------------------------------------------------------------------------*/
+#define _BF ".bf"
+#define _EF ".ef"
+#define _STEXT ".text"
+#define _ETEXT "etext"
+#define _SDATA ".data"
+#define _EDATA "edata"
+#define _SBSS ".bss"
+#define _END "end"
+#define _C_ARGS ".args"
+#define _BINITPTR "binit"
+#define _CINITPTR "cinit"
+#define _PINITPTR "pinit"
+#define _ASM_SRC_NAME "$ASM$" /* SPECIAL SYMBOL FOR ASSY SRC DEBUG */
+
+/*------------------------------------------------------------------------*/
+/* HIGH LEVEL LANGUAGE ACCESSIBLE VERSIONS OF THE ABOVE SPECIAL SYMBOLS. */
+/*------------------------------------------------------------------------*/
+#define _STEXT_HLL "___text__"
+#define _ETEXT_HLL "___etext__"
+#define _SDATA_HLL "___data__"
+#define _EDATA_HLL "___edata__"
+#define _SBSS_HLL "___bss__"
+#define _END_HLL "___end__"
+#define _C_ARGSPTR_HLL "___c_args__"
+#define _BINITPTR_HLL "___binit__"
+#define _CINITPTR_HLL "___cinit__"
+#define _PINITPTR_HLL "___pinit__"
+
+/*------------------------------------------------------------------------*/
+/* ENTRY POINT SYMBOLS */
+/*------------------------------------------------------------------------*/
+#define _START "_start"
+#define _MAIN "_main"
+
+/*------------------------------------------------------------------------*/
+/* SYMBOLS USED FOR C++ LOWERING */
+/*------------------------------------------------------------------------*/
+#define _TYPEINFO_ID_PREFIX "__TID_" /* Unique type id for RTTI */
+#define _TEMPLATE_MANGLED_ROOT "__tm__" /* mangled name root for */
+ /* template symbols. */
+#define _TEMPLATE_SIGNATURES "__pt__" /* when distinct_template_ */
+ /* signatures is FALSE, */
+ /* template name is mangled*/
+ /* with this string. */
+#define _PARTIAL_SPEC "__ps__" /* for the first argument */
+ /* list of a partial */
+ /* specialization, this */
+ /* string is used to mangle*/
+ /* the name. */
+#endif
diff --git a/src/interp/coff/coff_trg.h b/src/interp/coff/coff_trg.h
--- /dev/null
@@ -0,0 +1,201 @@
+/****************************************************************************/
+/* COFF_TRG.H */
+/* This file contains target dependent parameters for COFF files. */
+/****************************************************************************/
+#ifndef COFF_TRG_H
+#define COFF_TRG_H
+
+#if defined(TOOL_ASSEMBLER)
+ #error The COFF submodule should no longer be used by the assembler; use TICOFF04
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TMS340 (GSP) Target Specific Parameters (bit-addressable) */
+/*--------------------------------------------------------------------------*/
+#if TMS340
+#define MAGIC MAGIC_340 /* Magic number for GSP */
+#define TRG_MEM_WIDTH 1 /* Bit address */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TMS370/C8 Target Specific Parameters (byte-addressable) */
+/*--------------------------------------------------------------------------*/
+#if TMS370
+#define MAGIC MAGIC_370 /* 370 Magic number */
+#define TRG_MEM_WIDTH 8 /* Byte address */
+#endif
+
+#if TMS370C8
+#define MAGIC MAGIC_370 /* C8 Magic number */
+#define TRG_MEM_WIDTH 8 /* Byte address */
+#endif
+
+#if TMS370C8P
+#define MAGIC MAGIC_C8P /* C8 Magic number */
+#define TRG_MEM_WIDTH 8 /* Byte address */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TMS37016 (C16) Target Specific Parameters (byte-addressable) */
+/*--------------------------------------------------------------------------*/
+#if TMS37016
+#define MAGIC MAGIC_C16 /* 370/16 Magic number */
+#define TRG_MEM_WIDTH 8 /* Byte address */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TMS32030 (C30) Target Specific Parameters (32-bit word-addressable) */
+/*--------------------------------------------------------------------------*/
+#if TMS32030
+#define MAGIC MAGIC_C30 /* Magic number for C30 */
+#define TRG_MEM_WIDTH 32 /* 32-bit address */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TMS32025 (DSP) Target Specific Parameters (16-bit word-addressable) */
+/*--------------------------------------------------------------------------*/
+#if TMS32025
+#define MAGIC MAGIC_DSP /* Magic number for C1x/2x/5x */
+#define TRG_MEM_WIDTH 16 /* 16-bit address */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TMS380 (EGL) Target Specific Parameters (byte-addressable) */
+/*--------------------------------------------------------------------------*/
+#if TMS380
+#define MAGIC MAGIC_380 /* Magic number for TMS380 */
+#define TRG_MEM_WIDTH 8 /* Byte address */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TMS320C8x (MVP MP/PP) Target Specific Parameters (byte-addressable) */
+/*--------------------------------------------------------------------------*/
+#if MVP_PP || MVP_MP
+#define MAGIC MAGIC_MVP /* Magic number for PP */
+#define TRG_MEM_WIDTH 8 /* Byte address */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TMS320C54x (LEAD) Target Specific Parameters (16-bit word-addressable) */
+/*--------------------------------------------------------------------------*/
+#if LEAD
+#define MAGIC MAGIC_LEAD /* Magic number for C5xx */
+#define TRG_MEM_WIDTH 16 /* 16-bit address */
+#define TRG_INST_ALIGN 16 /* Instruction alignment */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TMS470 (ARM) Target Specific Parameters (byte-addressable) */
+/*--------------------------------------------------------------------------*/
+#if ARM
+#define MAGIC MAGIC_ARM /* Magic number for ARM */
+#define TRG_MEM_WIDTH 8 /* Byte address */
+#define TRG_ARM_MODE 0 /* ARM setting for curr_objmode */
+#define TRG_THUMB_MODE 1 /* Thumb setting for curr_objmode */
+#ifndef TRG_INST_ALIGN_THUMB
+#define TRG_INST_ALIGN_THUMB 16
+#endif
+
+#ifndef TRG_INST_ALIGN_ARM
+#define TRG_INST_ALIGN_ARM 32
+#endif
+
+#ifndef TRG_INST_ALIGN
+#define TRG_INST_ALIGN (curr_objmode == TRG_ARM_MODE ? \
+ TRG_INST_ALIGN_ARM \
+ : TRG_INST_ALIGN_THUMB)
+#endif
+extern unsigned char curr_objmode;
+
+/*------------------------------------------------------------------------*/
+/* Target device identification flags (bits 4-7 in file header flags) */
+/*------------------------------------------------------------------------*/
+#define F_ARM9ABI 0x10 /* 0x10 = ARM9ABI, 0x00 = TIABI */
+#define F_ARCH4 0x20 /* ARCH4 = ARM7 */
+#define F_ARCH5E 0x40 /* ARCH5E = ARM9 */
+#define F_ARCH6 0x60 /* ARCH6 = ARM11 */
+#define F_DMODE 0x80 /* DUAL MODE */
+#define ARCH_MASK 0x60
+
+#define ARCH5E_FLAGS(flg) ((flg & ARCH_MASK) == F_ARCH5E)
+#define ARCH6_FLAGS(flg) ((flg & ARCH_MASK) == F_ARCH6)
+#define ARCH4_FLAGS(flg) ((flg & ARCH_MASK) == F_ARCH4)
+
+#undef F_VERSION
+#define F_VERSION ( F_ARM9ABI | F_ARCH4 | \
+ F_ARCH5E | F_DMODE )
+#endif
+
+
+/*--------------------------------------------------------------------------*/
+/* TMS320C6x Target Specific Parameters (byte-addressable) */
+/*--------------------------------------------------------------------------*/
+#if TMS32060
+#define MAGIC MAGIC_C60 /* Magic number for C60 */
+#define TRG_MEM_WIDTH 8 /* Byte address */
+#define TRG_INST_ALIGN 32 /* Instruction alignment */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TARANTULA Target Specific Parameters (byte-addressable) */
+/*--------------------------------------------------------------------------*/
+#if TARANTULA
+#define MAGIC MAGIC_TARANTULA /* Magic number for TARANTULA */
+#define TRG_MEM_WIDTH 8 /* Byte address */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TMS320C2xxx (Ankoor) Target Specific Parameters (16-bit word-addressable)*/
+/*--------------------------------------------------------------------------*/
+#if RTC
+#define MAGIC MAGIC_ANKOOR /* Magic number for Ankoor */
+#define TRG_MEM_WIDTH 16 /* 16-bit address */
+#define TRG_INST_ALIGN 16 /* Instruction alignment */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TMS320C55xx (LEAD3) Target Specific Parameters (byte-addressable code) */
+/* (16-bit word-addressable data) */
+/*--------------------------------------------------------------------------*/
+#if LEAD3
+/*--------------------------------------------------------------------------*/
+/* The C55x object consumers can accept either Laijin or Ryujin object */
+/* files, so ISMAGIC() becomes a target-specific macro, and MAGIC is not */
+/* defined. */
+/*--------------------------------------------------------------------------*/
+#define ISMAGIC(x) (((unsigned short)(x)) == MAGIC_LEAD3 || \
+ ((unsigned short)(x)) == MAGIC_LEAD3_R35)
+
+#define TRG_MEM_WIDTH 8 /* Byte address */
+#define TRG_INST_ALIGN 8 /* Instruction alignment */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* MSP430 Target Specific Parameters (byte-addressable) */
+/*--------------------------------------------------------------------------*/
+#if MSP
+#define MAGIC MAGIC_MSP /* Magic number for MSP */
+#define TRG_MEM_WIDTH 8 /* Byte address */
+#define TRG_INST_ALIGN 16
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* IF WE DIDN'T DEFINE ANY TARGET, DEFINE THEM TO SOMETHING... */
+/*--------------------------------------------------------------------------*/
+#ifndef TRG_MEM_WIDTH
+#define TRG_MEM_WIDTH 8 /* ARBITRARY... */
+#endif
+
+#ifndef TRG_INST_ALIGN
+#define TRG_INST_ALIGN 32 /* Instruction alignment */
+#endif
+
+#ifndef MAGIC
+#define MAGIC 0 /* ARBITRARY... */
+#endif
+
+#ifndef ISMAGIC
+#define ISMAGIC(x) (((unsigned short)(x)) == MAGIC)
+#endif
+
+#endif /* COFF_TRG_H */
diff --git a/src/interp/coff/coff_trg.mike.h b/src/interp/coff/coff_trg.mike.h
--- /dev/null
@@ -0,0 +1,201 @@
+/****************************************************************************/
+/* COFF_TRG.H */
+/* This file contains target dependent parameters for COFF files. */
+/****************************************************************************/
+#ifndef COFF_TRG_H
+#define COFF_TRG_H
+
+#if defined(TOOL_ASSEMBLER)
+ #error The COFF submodule should no longer be used by the assembler; use TICOFF04
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TMS340 (GSP) Target Specific Parameters (bit-addressable) */
+/*--------------------------------------------------------------------------*/
+#if TMS340
+#define MAGIC MAGIC_340 /* Magic number for GSP */
+#define TRG_MEM_WIDTH 1 /* Bit address */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TMS370/C8 Target Specific Parameters (byte-addressable) */
+/*--------------------------------------------------------------------------*/
+#if TMS370
+#define MAGIC MAGIC_370 /* 370 Magic number */
+#define TRG_MEM_WIDTH 8 /* Byte address */
+#endif
+
+#if TMS370C8
+#define MAGIC MAGIC_370 /* C8 Magic number */
+#define TRG_MEM_WIDTH 8 /* Byte address */
+#endif
+
+#if TMS370C8P
+#define MAGIC MAGIC_C8P /* C8 Magic number */
+#define TRG_MEM_WIDTH 8 /* Byte address */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TMS37016 (C16) Target Specific Parameters (byte-addressable) */
+/*--------------------------------------------------------------------------*/
+#if TMS37016
+#define MAGIC MAGIC_C16 /* 370/16 Magic number */
+#define TRG_MEM_WIDTH 8 /* Byte address */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TMS32030 (C30) Target Specific Parameters (32-bit word-addressable) */
+/*--------------------------------------------------------------------------*/
+#if TMS32030
+#define MAGIC MAGIC_C30 /* Magic number for C30 */
+#define TRG_MEM_WIDTH 32 /* 32-bit address */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TMS32025 (DSP) Target Specific Parameters (16-bit word-addressable) */
+/*--------------------------------------------------------------------------*/
+#if TMS32025
+#define MAGIC MAGIC_DSP /* Magic number for C1x/2x/5x */
+#define TRG_MEM_WIDTH 16 /* 16-bit address */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TMS380 (EGL) Target Specific Parameters (byte-addressable) */
+/*--------------------------------------------------------------------------*/
+#if TMS380
+#define MAGIC MAGIC_380 /* Magic number for TMS380 */
+#define TRG_MEM_WIDTH 8 /* Byte address */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TMS320C8x (MVP MP/PP) Target Specific Parameters (byte-addressable) */
+/*--------------------------------------------------------------------------*/
+#if MVP_PP || MVP_MP
+#define MAGIC MAGIC_MVP /* Magic number for PP */
+#define TRG_MEM_WIDTH 8 /* Byte address */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TMS320C54x (LEAD) Target Specific Parameters (16-bit word-addressable) */
+/*--------------------------------------------------------------------------*/
+#if LEAD
+#define MAGIC MAGIC_LEAD /* Magic number for C5xx */
+#define TRG_MEM_WIDTH 16 /* 16-bit address */
+#define TRG_INST_ALIGN 16 /* Instruction alignment */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TMS470 (ARM) Target Specific Parameters (byte-addressable) */
+/*--------------------------------------------------------------------------*/
+#if ARM
+#define MAGIC MAGIC_ARM /* Magic number for ARM */
+#define TRG_MEM_WIDTH 8 /* Byte address */
+#define TRG_ARM_MODE 0 /* ARM setting for curr_objmode */
+#define TRG_THUMB_MODE 1 /* Thumb setting for curr_objmode */
+#ifndef TRG_INST_ALIGN_THUMB
+#define TRG_INST_ALIGN_THUMB 16
+#endif
+
+#ifndef TRG_INST_ALIGN_ARM
+#define TRG_INST_ALIGN_ARM 32
+#endif
+
+#ifndef TRG_INST_ALIGN
+#define TRG_INST_ALIGN (curr_objmode == TRG_ARM_MODE ? \
+ TRG_INST_ALIGN_ARM \
+ : TRG_INST_ALIGN_THUMB)
+#endif
+extern unsigned char curr_objmode;
+
+/*------------------------------------------------------------------------*/
+/* Target device identification flags (bits 4-7 in file header flags) */
+/*------------------------------------------------------------------------*/
+#define F_ARM9ABI 0x10 /* 0x10 = ARM9ABI, 0x00 = TIABI */
+#define F_ARCH4 0x20 /* ARCH4 = ARM7 */
+#define F_ARCH5E 0x40 /* ARCH5E = ARM9 */
+#define F_ARCH6 0x60 /* ARCH6 = ARM11 */
+#define F_DMODE 0x80 /* DUAL MODE */
+#define ARCH_MASK 0x60
+
+#define ARCH5E_FLAGS(flg) ((flg & ARCH_MASK) == F_ARCH5E)
+#define ARCH6_FLAGS(flg) ((flg & ARCH_MASK) == F_ARCH6)
+#define ARCH4_FLAGS(flg) ((flg & ARCH_MASK) == F_ARCH4)
+
+#undef F_VERSION
+#define F_VERSION ( F_ARM9ABI | F_ARCH4 | \
+ F_ARCH5E | F_DMODE )
+#endif
+
+
+/*--------------------------------------------------------------------------*/
+/* TMS320C6x Target Specific Parameters (byte-addressable) */
+/*--------------------------------------------------------------------------*/
+#if TMS32060
+#define MAGIC MAGIC_C60 /* Magic number for C60 */
+#define TRG_MEM_WIDTH 8 /* Byte address */
+#define TRG_INST_ALIGN 32 /* Instruction alignment */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TARANTULA Target Specific Parameters (byte-addressable) */
+/*--------------------------------------------------------------------------*/
+#if TARANTULA
+#define MAGIC MAGIC_TARANTULA /* Magic number for TARANTULA */
+#define TRG_MEM_WIDTH 8 /* Byte address */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TMS320C2xxx (Ankoor) Target Specific Parameters (16-bit word-addressable)*/
+/*--------------------------------------------------------------------------*/
+#if RTC
+#define MAGIC MAGIC_ANKOOR /* Magic number for Ankoor */
+#define TRG_MEM_WIDTH 16 /* 16-bit address */
+#define TRG_INST_ALIGN 16 /* Instruction alignment */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* TMS320C55xx (LEAD3) Target Specific Parameters (byte-addressable code) */
+/* (16-bit word-addressable data) */
+/*--------------------------------------------------------------------------*/
+#if LEAD3
+/*--------------------------------------------------------------------------*/
+/* The C55x object consumers can accept either Laijin or Ryujin object */
+/* files, so ISMAGIC() becomes a target-specific macro, and MAGIC is not */
+/* defined. */
+/*--------------------------------------------------------------------------*/
+#define ISMAGIC(x) (((unsigned short)(x)) == MAGIC_LEAD3 || \
+ ((unsigned short)(x)) == MAGIC_LEAD3_R35)
+
+#define TRG_MEM_WIDTH 8 /* Byte address */
+#define TRG_INST_ALIGN 8 /* Instruction alignment */
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* MSP430 Target Specific Parameters (byte-addressable) */
+/*--------------------------------------------------------------------------*/
+#if MSP
+#define MAGIC MAGIC_MSP /* Magic number for MSP */
+#define TRG_MEM_WIDTH 8 /* Byte address */
+#define TRG_INST_ALIGN 16
+#endif
+
+/*--------------------------------------------------------------------------*/
+/* IF WE DIDN'T DEFINE ANY TARGET, DEFINE THEM TO SOMETHING... */
+/*--------------------------------------------------------------------------*/
+#ifndef TRG_MEM_WIDTH
+#define TRG_MEM_WIDTH 8 /* ARBITRARY... */
+#endif
+
+#ifndef TRG_INST_ALIGN
+#define TRG_INST_ALIGN 32 /* Instruction alignment */
+#endif
+
+#ifndef MAGIC
+#define MAGIC 0 /* ARBITRARY... */
+#endif
+
+#ifndef ISMAGIC
+#define ISMAGIC(x) (((unsigned short)(x)) == MAGIC)
+#endif
+
+#endif /* COFF_TRG_H */
diff --git a/src/interp/coff/coffdefs.h b/src/interp/coff/coffdefs.h
--- /dev/null
@@ -0,0 +1,231 @@
+/**************************************************************************/
+/* COFFDEFS.H */
+/* Definitions of COFF symbol type and storage class fields. */
+/**************************************************************************/
+#ifndef COFFDEFS_H
+#define COFFDEFS_H
+
+#if defined(TOOL_ASSEMBLER)
+ #error The COFF submodule should no longer be used by the assembler; use TICOFF04
+#endif
+
+/*------------------------------------------------------------------------*/
+/* STORAGE CLASSES */
+/*------------------------------------------------------------------------*/
+#define C_NULL 0
+#define C_AUTO 1 /* AUTOMATIC VARIABLE */
+#define C_EXT 2 /* EXTERNAL SYMBOL */
+#define C_STAT 3 /* STATIC */
+#define C_REG 4 /* REGISTER VARIABLE */
+#define C_EXTREF 5 /* EXTERNAL DEFINITION */
+#define C_LABEL 6 /* LABEL */
+#define C_ULABEL 7 /* UNDEFINED LABEL */
+#define C_MOS 8 /* MEMBER OF STRUCTURE */
+#define C_ARG 9 /* FUNCTION ARGUMENT */
+#define C_STRTAG 10 /* STRUCTURE TAG */
+#define C_MOU 11 /* MEMBER OF UNION */
+#define C_UNTAG 12 /* UNION TAG */
+#define C_TPDEF 13 /* TYPE DEFINITION */
+#define C_USTATIC 14 /* UNDEFINED STATIC */
+#define C_ENTAG 15 /* ENUMERATION TAG */
+#define C_MOE 16 /* MEMBER OF ENUMERATION */
+#define C_REGPARM 17 /* REGISTER PARAMETER */
+#define C_FIELD 18 /* BIT FIELD */
+#define C_UEXT 19 /* TENTATIVE EXTERNAL DEFINITION */
+#define C_STATLAB 20 /* STATIC LOAD-TIME LABEL */
+#define C_EXTLAB 21 /* EXTERNAL LOAD-TIME LABEL */
+#define C_VREG 22 /* VIRTUAL REGISTER VARIABLE */
+#define C_SYSTEM 23 /* SYSTEM-WIDE SYMBOL */
+#define C_STATREG 24 /* STATIC REGISTER VARIABLE */
+#define C_EXTREG 25 /* EXTERNAL REGISTER VARIABLE */
+#define C_EXTREFREG 26 /* EXTERNAL REGISTER VARIABLE REFERENCE */
+#define C_VARARG 27 /* LAST DECLARED PARAMETER OF VARARG FN */
+#define C_EXTDEF 28 /* C_EXT DEFINED IN DIFFERENT FILE */
+#define C_USTATREG 29 /* UNDEFINED STATIC REGISTER VARIABLE */
+
+#define C_BLOCK 100 /* ".BB" OR ".EB" */
+#define C_FCN 101 /* ".BF" OR ".EF" */
+#define C_EOS 102 /* END OF STRUCTURE */
+#define C_FILE 103 /* FILE NAME */
+#define C_LINE 104 /* DUMMY SCLASS FOR LINE NUMBER ENTRY */
+#define C_ALIAS 105 /* DUPLICATE TAG */
+#define C_PREF 106 /* DUMMY SCLASS FOR REF PRAGMA TABLE ENTRY */
+
+#define C_GRPTAG 107 /* TAG FOR GROUPED GLOBAL VARIABLES */
+#define C_SMOG 108 /* STATIC MEMBER OF GROUP */
+#define C_EMOG 109 /* EXTERN MEMBER OF GROUP */
+#define C_EOG 110 /* END OF GROUP */
+
+/*------------------------------------------------------------------------*/
+/* STORAGE CLASS QUALIFIERS */
+/*------------------------------------------------------------------------*/
+#define CQ_NEAR 0x0001
+#define CQ_FAR 0x0002
+#define CQ_INLINE 0x0004 /* INLINE THIS FUNCTION DEFINITION */
+#define CQ_SUPPRESS 0x0008 /* INLINE AND EMIT NO ICODE OUTPUT */
+#define CQ_CONTROL 0x0010 /* SYMBOL IS A "CONTROL REGISTER" */
+#define CQ_INTERRUPT 0x0020 /* INTERRUPT FUNCTION */
+#define CQ_TRAP 0x0040 /* (MVP CODE GENERATOR) */
+#define CQ_GREGISTER 0x0080 /* GLOBAL REGISTER SYMBOL */
+#define CQ_PORT 0x0100 /* 370 PORT VARIABLE */
+#define CQ_SYSTEM 0x0200 /* MVP SHARED SYMBOL (MP AND PPs) */
+#define CQ_SYSTEMPP 0x0400 /* MVP SHARED SYMBOL (PPs only) */
+#define CQ_REENTRANT 0x0800 /* FUNCTION IS REENTRANT/NEEDS STACK */
+#define CQ_NMI_INTERRUPT 0x1000 /* NMI INTERRUPT FUNCTION */
+
+#define CQ_ALIASED 0x2000 /* ADDRESS OF SYMBOL TAKEN SOMEWHERE */
+#define CQ_WRITTEN 0x4000 /* VARIABLE IS MODIFIED BY CODE */
+#define CQ_TOUCHED 0x8000 /* VARIABLE IS REFERENCED BY CODE */
+
+#define CQ_ICODE ( CQ_NEAR | CQ_INLINE | CQ_CONTROL | CQ_TRAP \
+ | CQ_FAR | CQ_SUPPRESS | CQ_INTERRUPT | CQ_GREGISTER \
+ | CQ_PORT | CQ_SYSTEM | CQ_SYSTEMPP | CQ_REENTRANT \
+ | CQ_NMI_INTERRUPT)
+
+/*------------------------------------------------------------------------*/
+/* STORAGE CLASS MACROS */
+/*------------------------------------------------------------------------*/
+#define ISLOCAL(c) ((c) == C_AUTO || (c) == C_REG || (c) == C_VREG)
+#define ISPARM(c) ((c) == C_ARG || (c) == C_REGPARM || (c) == C_VARARG)
+#define ISAUTO(c) ((c) == C_AUTO || (c) == C_ARG || (c) == C_VARARG)
+#define ISREG(c) ((c) == C_REG || (c) == C_REGPARM || (c) == C_VREG || \
+ (c) == C_EXTREG || (c) == C_STATREG || (c) == C_EXTREFREG)
+#define ISTAG(c) ((c) == C_STRTAG || (c) == C_UNTAG || (c) == C_ENTAG)
+#define ISGROUP(c) ((c) == C_GRPTAG)
+
+#define ISMOS(c) ((c) == C_MOS || (c) == C_MOU || \
+ (c) == C_MOE || (c) == C_FIELD)
+
+#define ISXDEF(c) ((c) == C_STAT || (c) == C_STATREG || \
+ (c) == C_EXT || (c) == C_EXTDEF || (c) == C_EXTREG)
+
+#define ISEXT(c) ((c) == C_USTATIC || (c) == C_STAT || (c) == C_STATREG ||\
+ (c) == C_EXTREF || (c) == C_UEXT || (c) == C_EXTREFREG||\
+ (c) == C_EXT || (c) == C_EXTDEF || (c) == C_EXTREG ||\
+ (c) == C_EXTLAB || (c) == C_SYSTEM)
+
+#define ISGLOB(c) ((c) == C_EXTREF || (c) == C_UEXT || (c) == C_EXTREFREG||\
+ (c) == C_EXT || (c) == C_EXTDEF || (c) == C_EXTREG ||\
+ (c) == C_EXTLAB || (c) == C_SYSTEM)
+
+#define ISNEAR(cq) (((cq) & CQ_NEAR) != 0)
+#define ISFAR(cq) (((cq) & CQ_FAR) != 0)
+#define ISCONTROL(cq) (((cq) & CQ_CONTROL) != 0)
+#define ISGREGISTER(cq) (((cq) & CQ_GREGISTER) != 0)
+#define ISPORT(cq) (((cq) & CQ_PORT) != 0)
+#define ISINTERRUPT(cq) (((cq) & CQ_INTERRUPT) != 0)
+#define ISNMIINTERRUPT(cq) (((cq) & CQ_NMI_INTERRUPT) != 0)
+#define ISREENTRANT(cq) (((cq) & CQ_REENTRANT) != 0)
+#define ISTRAP(cq) (((cq) & CQ_TRAP) != 0)
+#define ISINT_OR_TRAP(cq) (((cq) & (CQ_TRAP | CQ_INTERRUPT)) != 0)
+
+/*-------------------------------------------------------------------------*/
+/* COFF BASIC TYPES - PACKED INTO THE LOWER 4 BITS OF THE TYPE FIELD */
+/*-------------------------------------------------------------------------*/
+#define CT_NULL 0x80 /* UNDEFINED OR ERROR TYPE (NO TYPE INFO) */
+#define CT_VOID 0 /* VOID TYPE */
+#define CT_SCHAR 1 /* CHARACTER (EXPLICITLY "signed") */
+#define CT_CHAR 2 /* CHARACTER (IMPLICITLY SIGNED) */
+#define CT_SHORT 3 /* SHORT INTEGER */
+#define CT_INT 4 /* INTEGER */
+#define CT_LONG 5 /* LONG INTEGER */
+#define CT_FLOAT 6 /* SINGLE PRECISION FLOATING POINT */
+#define CT_DOUBLE 7 /* DOUBLE PRECISION FLOATING POINT */
+#define CT_STRUCT 8 /* STRUCTURE */
+#define CT_UNION 9 /* UNION */
+#define CT_ENUM 10 /* ENUMERATION */
+#define CT_LDOUBLE 11 /* LONG DOUBLE FLOATING POINT */
+#define CT_UCHAR 12 /* UNSIGNED CHARACTER */
+#define CT_USHORT 13 /* UNSIGNED SHORT */
+#define CT_UINT 14 /* UNSIGNED INTEGER */
+#define CT_ULONG 15 /* UNSIGNED LONG */
+
+/*-------------------------------------------------------------------------*/
+/* COFF DERIVED TYPES: 2 BITS EACH */
+/*-------------------------------------------------------------------------*/
+#define DCT_NON 0x0 /* NO DERIVED TYPE */
+#define DCT_PTR 0x1 /* POINTER */
+#define DCT_FCN 0x2 /* FUNCTION */
+#define DCT_ARY 0x3 /* ARRAY */
+
+/*-------------------------------------------------------------------------*/
+/* COFF TYPE FIELD MASKS AND SIZES */
+/*-------------------------------------------------------------------------*/
+#define N_BCTMASK 0xF /* MASK FOR BASIC TYPE */
+#define N_CTMASK 0x30 /* MASK FOR FIRST DERIVED TYPE */
+#define N_DCTMAX 12 /* MAXIMUM DERIVED TYPES */
+#define N_BCTSHFT 4 /* SHIFT AMOUNT (WIDTH) FOR BASIC TYPE */
+#define N_CTSHIFT 2 /* SHIFT AMOUNT (WIDTH) FOR DERIVED TYPES */
+
+/*-------------------------------------------------------------------------*/
+/* COFF TYPE MANIPULATION MACROS */
+/* */
+/* BCTYPE(t) - Return basic type from t */
+/* DCTYPE(t) - Return all derived types from t */
+/* DCTYPE1(t) - Return 1st derived type from t */
+/* CTQUAL(t,q) - Return qualification of type */
+/* CTUNQUAL(t,q)- Return unqualified version of type */
+/* */
+/* MKCTYPE() - Build a type from basic and several derived types */
+/* CDERIVE(d,t) - Build a type from basic and one derived type */
+/* CINCREF(t) - Convert 't' into pointer to 't' */
+/* CDECREF(t) - Remove first derviation from t */
+/* */
+/* ISCINT(t) - TRUE if t is an integral type */
+/* ISCSGN(t) - TRUE if t is a signed type */
+/* ISCUNS(t) - TRUE if t is an unsigned type */
+/* ISCFLT(t) - TRUE if t is a floating point type */
+/* ISCDBL(t) - TRUE if t is a double or long double type */
+/* ISCPTR(t) - TRUE if t is a pointer */
+/* ISCFCN(t) - TRUE if t is a function */
+/* ISCARY(t) - TRUE if t is an array */
+/* ISCSTR(t) - TRUE if t is a struct, union, or enum type */
+/* ISCAGG(t) - TRUE if t is an array, struct, or union */
+/* */
+/* CITOU(t) - convert signed type to unsigned equivalent */
+/* CUTOI(t) - convert unsigned type to signed equivalent */
+/* CNOSIGN(t) - convert signed or unsigned type to "plain" equivalent */
+/*-------------------------------------------------------------------------*/
+#define BCTYPE(t) ((int)((t) & N_BCTMASK))
+#define DCTYPE(t) ((t) & ~N_BCTMASK)
+#define DCTYPE1(t) (((t) & N_CTMASK) >> N_BCTSHFT)
+
+#define CTQUAL(t,q) ((int)(DCTYPE(t) ? DCTYPE1(q) : BCTYPE(q)))
+#define CTUNQUAL(t,q) (ISCPTR(t) ? ((q) & ~N_CTMASK) : ((q) & ~N_BCTMASK))
+
+#define MKCTYPE(basic, d1,d2,d3,d4,d5,d6) \
+ ((basic) | ((d1) << 4) | ((d2) << 6) | ((d3) << 8) |\
+ ((d4) << 10) | ((d5) << 12) | ((d6) << 14))
+#define CDERIVE(d,t) ((DCTYPE(t) << N_CTSHIFT) | ((d) << N_BCTSHFT) | BCTYPE(t))
+#define CINCREF(t) ((DCTYPE(t) << N_CTSHIFT) | (DCT_PTR<<N_BCTSHFT)|BCTYPE(t))
+#define CDECREF(t) (DCTYPE((t) >> N_CTSHIFT) | BCTYPE(t))
+
+#define ISCSGN(t) (((t) >= CT_SCHAR && (t) <= CT_LONG) || (t) == CT_ENUM)
+#define ISCUNS(t) ((t) >= CT_UCHAR && (t) <= CT_ULONG)
+#define ISCINT(t) (((t) >= CT_SCHAR && (t) <= CT_LONG) || (t) == CT_ENUM ||\
+ ((t) >= CT_UCHAR && (t) <= CT_ULONG))
+#define ISCFLT(t) ((t) == CT_FLOAT || (t) == CT_DOUBLE || (t) == CT_LDOUBLE)
+#define ISCDBL(t) ((t) == CT_DOUBLE || (t) == CT_LDOUBLE)
+#define ISCPTR(t) (((t) & N_CTMASK) == (DCT_PTR << N_BCTSHFT))
+#define ISCFCN(t) (((t) & N_CTMASK) == (DCT_FCN << N_BCTSHFT))
+#define ISCARY(t) (((t) & N_CTMASK) == (DCT_ARY << N_BCTSHFT))
+#define ISCSTR(t) ((t) == CT_STRUCT || (t) == CT_UNION || (t) == CT_ENUM)
+#define ISCAGG(t) (ISCARY(t) || (t) == CT_STRUCT || (t) == CT_UNION)
+#define ISCCHAR(t) ((t) == CT_CHAR || (t) == CT_SCHAR || (t) == CT_UCHAR)
+#define ISCSHORT(t) ((t) == CT_SHORT || (t) == CT_USHORT)
+#define ISCLONG(t) ((t) == CT_LONG || (t) == CT_ULONG)
+
+#define CITOU(t) ((t) + (CT_UCHAR - ((t) == CT_SCHAR ? CT_SCHAR : CT_CHAR)))
+#define CUTOI(t) ((t) - (CT_UCHAR - CT_CHAR))
+#define CNOSIGN(t) (ISCUNS(t) ? CUTOI(t) : (t) == CT_SCHAR ? CT_CHAR : (t))
+
+/*------------------------------------------------------------------------*/
+/* ILLEGAL COFF TYPES USED TO MARK SPECIAL OBJECTS. */
+/* */
+/* CT_VENEER - DENOTES A VENEER OF A FUNCTION. */
+/*------------------------------------------------------------------------*/
+#define CT_VENEER (MKCTYPE(CT_VOID, DCT_FCN, DCT_FCN, 0, 0, 0, 0))
+#define ISCVENEER(t) ((t) == CT_VENEER)
+
+#endif /* COFFDEFS_H */
+
diff --git a/src/interp/coff/coffdefs.mike.h b/src/interp/coff/coffdefs.mike.h
--- /dev/null
@@ -0,0 +1,231 @@
+/**************************************************************************/
+/* COFFDEFS.H */
+/* Definitions of COFF symbol type and storage class fields. */
+/**************************************************************************/
+#ifndef COFFDEFS_H
+#define COFFDEFS_H
+
+#if defined(TOOL_ASSEMBLER)
+ #error The COFF submodule should no longer be used by the assembler; use TICOFF04
+#endif
+
+/*------------------------------------------------------------------------*/
+/* STORAGE CLASSES */
+/*------------------------------------------------------------------------*/
+#define C_NULL 0
+#define C_AUTO 1 /* AUTOMATIC VARIABLE */
+#define C_EXT 2 /* EXTERNAL SYMBOL */
+#define C_STAT 3 /* STATIC */
+#define C_REG 4 /* REGISTER VARIABLE */
+#define C_EXTREF 5 /* EXTERNAL DEFINITION */
+#define C_LABEL 6 /* LABEL */
+#define C_ULABEL 7 /* UNDEFINED LABEL */
+#define C_MOS 8 /* MEMBER OF STRUCTURE */
+#define C_ARG 9 /* FUNCTION ARGUMENT */
+#define C_STRTAG 10 /* STRUCTURE TAG */
+#define C_MOU 11 /* MEMBER OF UNION */
+#define C_UNTAG 12 /* UNION TAG */
+#define C_TPDEF 13 /* TYPE DEFINITION */
+#define C_USTATIC 14 /* UNDEFINED STATIC */
+#define C_ENTAG 15 /* ENUMERATION TAG */
+#define C_MOE 16 /* MEMBER OF ENUMERATION */
+#define C_REGPARM 17 /* REGISTER PARAMETER */
+#define C_FIELD 18 /* BIT FIELD */
+#define C_UEXT 19 /* TENTATIVE EXTERNAL DEFINITION */
+#define C_STATLAB 20 /* STATIC LOAD-TIME LABEL */
+#define C_EXTLAB 21 /* EXTERNAL LOAD-TIME LABEL */
+#define C_VREG 22 /* VIRTUAL REGISTER VARIABLE */
+#define C_SYSTEM 23 /* SYSTEM-WIDE SYMBOL */
+#define C_STATREG 24 /* STATIC REGISTER VARIABLE */
+#define C_EXTREG 25 /* EXTERNAL REGISTER VARIABLE */
+#define C_EXTREFREG 26 /* EXTERNAL REGISTER VARIABLE REFERENCE */
+#define C_VARARG 27 /* LAST DECLARED PARAMETER OF VARARG FN */
+#define C_EXTDEF 28 /* C_EXT DEFINED IN DIFFERENT FILE */
+#define C_USTATREG 29 /* UNDEFINED STATIC REGISTER VARIABLE */
+
+#define C_BLOCK 100 /* ".BB" OR ".EB" */
+#define C_FCN 101 /* ".BF" OR ".EF" */
+#define C_EOS 102 /* END OF STRUCTURE */
+#define C_FILE 103 /* FILE NAME */
+#define C_LINE 104 /* DUMMY SCLASS FOR LINE NUMBER ENTRY */
+#define C_ALIAS 105 /* DUPLICATE TAG */
+#define C_PREF 106 /* DUMMY SCLASS FOR REF PRAGMA TABLE ENTRY */
+
+#define C_GRPTAG 107 /* TAG FOR GROUPED GLOBAL VARIABLES */
+#define C_SMOG 108 /* STATIC MEMBER OF GROUP */
+#define C_EMOG 109 /* EXTERN MEMBER OF GROUP */
+#define C_EOG 110 /* END OF GROUP */
+
+/*------------------------------------------------------------------------*/
+/* STORAGE CLASS QUALIFIERS */
+/*------------------------------------------------------------------------*/
+#define CQ_NEAR 0x0001
+#define CQ_FAR 0x0002
+#define CQ_INLINE 0x0004 /* INLINE THIS FUNCTION DEFINITION */
+#define CQ_SUPPRESS 0x0008 /* INLINE AND EMIT NO ICODE OUTPUT */
+#define CQ_CONTROL 0x0010 /* SYMBOL IS A "CONTROL REGISTER" */
+#define CQ_INTERRUPT 0x0020 /* INTERRUPT FUNCTION */
+#define CQ_TRAP 0x0040 /* (MVP CODE GENERATOR) */
+#define CQ_GREGISTER 0x0080 /* GLOBAL REGISTER SYMBOL */
+#define CQ_PORT 0x0100 /* 370 PORT VARIABLE */
+#define CQ_SYSTEM 0x0200 /* MVP SHARED SYMBOL (MP AND PPs) */
+#define CQ_SYSTEMPP 0x0400 /* MVP SHARED SYMBOL (PPs only) */
+#define CQ_REENTRANT 0x0800 /* FUNCTION IS REENTRANT/NEEDS STACK */
+#define CQ_NMI_INTERRUPT 0x1000 /* NMI INTERRUPT FUNCTION */
+
+#define CQ_ALIASED 0x2000 /* ADDRESS OF SYMBOL TAKEN SOMEWHERE */
+#define CQ_WRITTEN 0x4000 /* VARIABLE IS MODIFIED BY CODE */
+#define CQ_TOUCHED 0x8000 /* VARIABLE IS REFERENCED BY CODE */
+
+#define CQ_ICODE ( CQ_NEAR | CQ_INLINE | CQ_CONTROL | CQ_TRAP \
+ | CQ_FAR | CQ_SUPPRESS | CQ_INTERRUPT | CQ_GREGISTER \
+ | CQ_PORT | CQ_SYSTEM | CQ_SYSTEMPP | CQ_REENTRANT \
+ | CQ_NMI_INTERRUPT)
+
+/*------------------------------------------------------------------------*/
+/* STORAGE CLASS MACROS */
+/*------------------------------------------------------------------------*/
+#define ISLOCAL(c) ((c) == C_AUTO || (c) == C_REG || (c) == C_VREG)
+#define ISPARM(c) ((c) == C_ARG || (c) == C_REGPARM || (c) == C_VARARG)
+#define ISAUTO(c) ((c) == C_AUTO || (c) == C_ARG || (c) == C_VARARG)
+#define ISREG(c) ((c) == C_REG || (c) == C_REGPARM || (c) == C_VREG || \
+ (c) == C_EXTREG || (c) == C_STATREG || (c) == C_EXTREFREG)
+#define ISTAG(c) ((c) == C_STRTAG || (c) == C_UNTAG || (c) == C_ENTAG)
+#define ISGROUP(c) ((c) == C_GRPTAG)
+
+#define ISMOS(c) ((c) == C_MOS || (c) == C_MOU || \
+ (c) == C_MOE || (c) == C_FIELD)
+
+#define ISXDEF(c) ((c) == C_STAT || (c) == C_STATREG || \
+ (c) == C_EXT || (c) == C_EXTDEF || (c) == C_EXTREG)
+
+#define ISEXT(c) ((c) == C_USTATIC || (c) == C_STAT || (c) == C_STATREG ||\
+ (c) == C_EXTREF || (c) == C_UEXT || (c) == C_EXTREFREG||\
+ (c) == C_EXT || (c) == C_EXTDEF || (c) == C_EXTREG ||\
+ (c) == C_EXTLAB || (c) == C_SYSTEM)
+
+#define ISGLOB(c) ((c) == C_EXTREF || (c) == C_UEXT || (c) == C_EXTREFREG||\
+ (c) == C_EXT || (c) == C_EXTDEF || (c) == C_EXTREG ||\
+ (c) == C_EXTLAB || (c) == C_SYSTEM)
+
+#define ISNEAR(cq) (((cq) & CQ_NEAR) != 0)
+#define ISFAR(cq) (((cq) & CQ_FAR) != 0)
+#define ISCONTROL(cq) (((cq) & CQ_CONTROL) != 0)
+#define ISGREGISTER(cq) (((cq) & CQ_GREGISTER) != 0)
+#define ISPORT(cq) (((cq) & CQ_PORT) != 0)
+#define ISINTERRUPT(cq) (((cq) & CQ_INTERRUPT) != 0)
+#define ISNMIINTERRUPT(cq) (((cq) & CQ_NMI_INTERRUPT) != 0)
+#define ISREENTRANT(cq) (((cq) & CQ_REENTRANT) != 0)
+#define ISTRAP(cq) (((cq) & CQ_TRAP) != 0)
+#define ISINT_OR_TRAP(cq) (((cq) & (CQ_TRAP | CQ_INTERRUPT)) != 0)
+
+/*-------------------------------------------------------------------------*/
+/* COFF BASIC TYPES - PACKED INTO THE LOWER 4 BITS OF THE TYPE FIELD */
+/*-------------------------------------------------------------------------*/
+#define CT_NULL 0x80 /* UNDEFINED OR ERROR TYPE (NO TYPE INFO) */
+#define CT_VOID 0 /* VOID TYPE */
+#define CT_SCHAR 1 /* CHARACTER (EXPLICITLY "signed") */
+#define CT_CHAR 2 /* CHARACTER (IMPLICITLY SIGNED) */
+#define CT_SHORT 3 /* SHORT INTEGER */
+#define CT_INT 4 /* INTEGER */
+#define CT_LONG 5 /* LONG INTEGER */
+#define CT_FLOAT 6 /* SINGLE PRECISION FLOATING POINT */
+#define CT_DOUBLE 7 /* DOUBLE PRECISION FLOATING POINT */
+#define CT_STRUCT 8 /* STRUCTURE */
+#define CT_UNION 9 /* UNION */
+#define CT_ENUM 10 /* ENUMERATION */
+#define CT_LDOUBLE 11 /* LONG DOUBLE FLOATING POINT */
+#define CT_UCHAR 12 /* UNSIGNED CHARACTER */
+#define CT_USHORT 13 /* UNSIGNED SHORT */
+#define CT_UINT 14 /* UNSIGNED INTEGER */
+#define CT_ULONG 15 /* UNSIGNED LONG */
+
+/*-------------------------------------------------------------------------*/
+/* COFF DERIVED TYPES: 2 BITS EACH */
+/*-------------------------------------------------------------------------*/
+#define DCT_NON 0x0 /* NO DERIVED TYPE */
+#define DCT_PTR 0x1 /* POINTER */
+#define DCT_FCN 0x2 /* FUNCTION */
+#define DCT_ARY 0x3 /* ARRAY */
+
+/*-------------------------------------------------------------------------*/
+/* COFF TYPE FIELD MASKS AND SIZES */
+/*-------------------------------------------------------------------------*/
+#define N_BCTMASK 0xF /* MASK FOR BASIC TYPE */
+#define N_CTMASK 0x30 /* MASK FOR FIRST DERIVED TYPE */
+#define N_DCTMAX 12 /* MAXIMUM DERIVED TYPES */
+#define N_BCTSHFT 4 /* SHIFT AMOUNT (WIDTH) FOR BASIC TYPE */
+#define N_CTSHIFT 2 /* SHIFT AMOUNT (WIDTH) FOR DERIVED TYPES */
+
+/*-------------------------------------------------------------------------*/
+/* COFF TYPE MANIPULATION MACROS */
+/* */
+/* BCTYPE(t) - Return basic type from t */
+/* DCTYPE(t) - Return all derived types from t */
+/* DCTYPE1(t) - Return 1st derived type from t */
+/* CTQUAL(t,q) - Return qualification of type */
+/* CTUNQUAL(t,q)- Return unqualified version of type */
+/* */
+/* MKCTYPE() - Build a type from basic and several derived types */
+/* CDERIVE(d,t) - Build a type from basic and one derived type */
+/* CINCREF(t) - Convert 't' into pointer to 't' */
+/* CDECREF(t) - Remove first derviation from t */
+/* */
+/* ISCINT(t) - TRUE if t is an integral type */
+/* ISCSGN(t) - TRUE if t is a signed type */
+/* ISCUNS(t) - TRUE if t is an unsigned type */
+/* ISCFLT(t) - TRUE if t is a floating point type */
+/* ISCDBL(t) - TRUE if t is a double or long double type */
+/* ISCPTR(t) - TRUE if t is a pointer */
+/* ISCFCN(t) - TRUE if t is a function */
+/* ISCARY(t) - TRUE if t is an array */
+/* ISCSTR(t) - TRUE if t is a struct, union, or enum type */
+/* ISCAGG(t) - TRUE if t is an array, struct, or union */
+/* */
+/* CITOU(t) - convert signed type to unsigned equivalent */
+/* CUTOI(t) - convert unsigned type to signed equivalent */
+/* CNOSIGN(t) - convert signed or unsigned type to "plain" equivalent */
+/*-------------------------------------------------------------------------*/
+#define BCTYPE(t) ((int)((t) & N_BCTMASK))
+#define DCTYPE(t) ((t) & ~N_BCTMASK)
+#define DCTYPE1(t) (((t) & N_CTMASK) >> N_BCTSHFT)
+
+#define CTQUAL(t,q) ((int)(DCTYPE(t) ? DCTYPE1(q) : BCTYPE(q)))
+#define CTUNQUAL(t,q) (ISCPTR(t) ? ((q) & ~N_CTMASK) : ((q) & ~N_BCTMASK))
+
+#define MKCTYPE(basic, d1,d2,d3,d4,d5,d6) \
+ ((basic) | ((d1) << 4) | ((d2) << 6) | ((d3) << 8) |\
+ ((d4) << 10) | ((d5) << 12) | ((d6) << 14))
+#define CDERIVE(d,t) ((DCTYPE(t) << N_CTSHIFT) | ((d) << N_BCTSHFT) | BCTYPE(t))
+#define CINCREF(t) ((DCTYPE(t) << N_CTSHIFT) | (DCT_PTR<<N_BCTSHFT)|BCTYPE(t))
+#define CDECREF(t) (DCTYPE((t) >> N_CTSHIFT) | BCTYPE(t))
+
+#define ISCSGN(t) (((t) >= CT_SCHAR && (t) <= CT_LONG) || (t) == CT_ENUM)
+#define ISCUNS(t) ((t) >= CT_UCHAR && (t) <= CT_ULONG)
+#define ISCINT(t) (((t) >= CT_SCHAR && (t) <= CT_LONG) || (t) == CT_ENUM ||\
+ ((t) >= CT_UCHAR && (t) <= CT_ULONG))
+#define ISCFLT(t) ((t) == CT_FLOAT || (t) == CT_DOUBLE || (t) == CT_LDOUBLE)
+#define ISCDBL(t) ((t) == CT_DOUBLE || (t) == CT_LDOUBLE)
+#define ISCPTR(t) (((t) & N_CTMASK) == (DCT_PTR << N_BCTSHFT))
+#define ISCFCN(t) (((t) & N_CTMASK) == (DCT_FCN << N_BCTSHFT))
+#define ISCARY(t) (((t) & N_CTMASK) == (DCT_ARY << N_BCTSHFT))
+#define ISCSTR(t) ((t) == CT_STRUCT || (t) == CT_UNION || (t) == CT_ENUM)
+#define ISCAGG(t) (ISCARY(t) || (t) == CT_STRUCT || (t) == CT_UNION)
+#define ISCCHAR(t) ((t) == CT_CHAR || (t) == CT_SCHAR || (t) == CT_UCHAR)
+#define ISCSHORT(t) ((t) == CT_SHORT || (t) == CT_USHORT)
+#define ISCLONG(t) ((t) == CT_LONG || (t) == CT_ULONG)
+
+#define CITOU(t) ((t) + (CT_UCHAR - ((t) == CT_SCHAR ? CT_SCHAR : CT_CHAR)))
+#define CUTOI(t) ((t) - (CT_UCHAR - CT_CHAR))
+#define CNOSIGN(t) (ISCUNS(t) ? CUTOI(t) : (t) == CT_SCHAR ? CT_CHAR : (t))
+
+/*------------------------------------------------------------------------*/
+/* ILLEGAL COFF TYPES USED TO MARK SPECIAL OBJECTS. */
+/* */
+/* CT_VENEER - DENOTES A VENEER OF A FUNCTION. */
+/*------------------------------------------------------------------------*/
+#define CT_VENEER (MKCTYPE(CT_VOID, DCT_FCN, DCT_FCN, 0, 0, 0, 0))
+#define ISCVENEER(t) ((t) == CT_VENEER)
+
+#endif /* COFFDEFS_H */
+
diff --git a/src/interp/coff/coffwrap.h b/src/interp/coff/coffwrap.h
--- /dev/null
@@ -0,0 +1,27 @@
+#ifndef COFFWRAP_H
+#define COFFWRAP_H
+/*****************************************************************************************
+ * FILE PURPOSE: Define the coff loader wrapper to the IBL
+ *****************************************************************************************
+ * FILE NAME: coffwrap.h
+ *
+ * DESCRIPTION: Defines the application interface to the coff wrapper
+ *
+ *****************************************************************************************/
+#include "types.h"
+#include "iblloc.h"
+
+
+/* The wrapper functions */
+void iblBootCoff (BOOT_MODULE_FXN_TABLE *bootFxn, Uint32 *ientry_point);
+bool iblIsCoff (Uint16 cv);
+
+
+
+
+
+#endif /* COFFWRAP_H */
+
+
+
+
diff --git a/src/interp/coff/header.h b/src/interp/coff/header.h
--- /dev/null
+++ b/src/interp/coff/header.h
@@ -0,0 +1,25 @@
+/************************************************************************/
+/* HEADER.H - STANDARD HEADER FILE FOR COFF LOADERS */
+/************************************************************************/
+
+/*-----------------------------------------------------------------------*/
+/* INCLUDE STANDARD HEADER FILES */
+/*-----------------------------------------------------------------------*/
+//#include <string.h>
+//#include <stdlib.h>
+#include <stdarg.h>
+#include "version.h"
+#include "params.h"
+#include "coff.h"
+#include "osal.h" /* must preceed cload.h. */
+#include "cload.h"
+#include "proto.h"
+#include "types.h"
+#include "coff_trg.h"
+
+/*-----------------------------------------------------------------------*/
+/* CONSTANTS, MACROS, VARIABLES, AND STRUCTURES FOR THE LOADER. */
+/*-----------------------------------------------------------------------*/
+#define MIN(a,b) ((a)<(b)?(a):(b))
+#define MAX(a,b) ((a)>(b)?(a):(b))
+
diff --git a/src/interp/coff/osal.c b/src/interp/coff/osal.c
--- /dev/null
+++ b/src/interp/coff/osal.c
@@ -0,0 +1,74 @@
+/*****************************************************************************
+ * FILE PURPOSE: IBL wrapper for the coff loader
+ *****************************************************************************
+ * FILE NAME: osal.c
+ *
+ * DESCRIPTION: Provides a boot wrapper to attach the coff loader
+ * to the IBL.
+ *
+ *****************************************************************************/
+#include "types.h"
+#include "ibl.h"
+#include "iblloc.h"
+#include "header.h"
+
+
+/*****************************************************************************
+ * FUNCTION PURPOSE: The main wrapper
+ *****************************************************************************
+ * DESCRIPTION: Attaches the coff loader to the IBL. The input parameters
+ * are associated with globals defined in cload.c.
+ *****************************************************************************/
+void iblBootCoff (BOOT_MODULE_FXN_TABLE *bootFxn, Uint32 *ientry_point)
+{
+
+ /* Fin is declared as a FILE * in cload.c In osal.h FILE is
+ * defined to be BOOT_MODULE_FXN_TABLE, and reads/seeks
+ * are defined (in osal.h) to call through the BOOT_MODULE_FXN_TABLE
+ * calls. */
+ fin = bootFxn;
+
+ /* cload is the main coff loader function. It returns 0 on success.
+ * The entry point will be in the global entry_point declared in
+ * cload.c */
+ if (cload () == 0)
+ *ientry_point = entry_point;
+ else
+ *ientry_point = 0;
+
+}
+
+
+/******************************************************************************
+ * FUNCTION PURPOSE: Determine if a file could be a coff file
+ ******************************************************************************
+ * DESCRIPTION: Examines the magic number and returns TRUE if it is one of
+ * the coff numbers (different numbers for different versions
+ ******************************************************************************/
+bool iblIsCoff (Uint16 cv)
+{
+ if (ISCOFF(cv))
+ return (TRUE);
+
+ /* Try an endian swap an recheck */
+ cv = ((cv >> 8) & 0x00ff) | ((cv << 8) & 0xff00);
+ if (ISCOFF(cv))
+ return (TRUE);
+
+ return (FALSE);
+
+}
+
+/******************************************************************************
+ * This is copied directly from cload_main.c from the original source
+ ******************************************************************************/
+unsigned int reloc = 0; /* RELOCATION AMOUNT */
+int set_reloc_amount()
+{
+ int i;
+
+ for (i = 0; i< n_sections; ++i) reloc_amount[i] = reloc;
+ return 1;
+}
+
+
diff --git a/src/interp/coff/osal.h b/src/interp/coff/osal.h
--- /dev/null
+++ b/src/interp/coff/osal.h
@@ -0,0 +1,35 @@
+#ifndef OSAL_H_
+#define OSAL_H_
+
+
+/********************************************************************
+ * IBL Adaptions
+ *
+ * The ibl will use the file based definition, but define it to be
+ * directed into the BOOT_MODULE_FXN_TABLE calls.
+ *
+ ********************************************************************/
+#include "iblloc.h"
+
+#define FILE_BASED 1
+#define FILE BOOT_MODULE_FXN_TABLE /* use the already existing global */
+
+
+/* Redirect seek and reads */
+#define fseek(x,y,z) (*x->seek)((Int32)(y),(Int32)(z))
+#define fread(w,x,y,z) (((*z->read)((Uint8 *)(w),(Uint32)((x)*(y)))) == 0 ? (y) : 0)
+
+/* Use stdlib functions where possible */
+#define mem_copy(dest,src,nbytes) memcpy((void *)(dest),(void *)(src),nbytes)
+#define mem_write(buf, nbytes, addr, page) memcpy((void *)(addr),(void *)(buf),nbytes)
+#define str_comp strcmp
+#define strn_copy strncpy
+
+
+/***********************
+ * Function Prototypes
+ **********************/
+char* strn_copy(char* dst, const char* src, unsigned int n);
+int str_comp(const char *s1, const char *s2);
+
+#endif /*OSAL_H_*/
diff --git a/src/interp/coff/params.h b/src/interp/coff/params.h
--- /dev/null
+++ b/src/interp/coff/params.h
@@ -0,0 +1,338 @@
+/****************************************************************************/
+/* PARAMS.H - Target dependent parameters. */
+/****************************************************************************/
+
+#if TMS340
+typedef unsigned int T_ADDR; /* TYPE FOR TARGET ADDRESS */
+typedef unsigned short T_DATA; /* TYPE FOR TARGET DATA WORD */
+typedef unsigned short T_SIZE; /* TYPE FOR CINIT SIZE FIELD */
+typedef unsigned int T_IADDR; /* TYPE FOR CINIT ADDRESS FIELD */
+typedef unsigned short T_INSTRUCT; /* TYPE FOR INSTRUCTION OPCODE */
+
+#define MAGIC MAGIC_340
+/* #define NEW_SYM_NDX 1 USE 32-bit SYMBOL INDEX, NO DISP */
+#define BYTETOLOC(x) ((T_ADDR)(x)<<3) /* CONVERT ADDRESSES TO BYTES */
+#define LOCTOBYTE(x) ((x)>>3) /* CONVERT BYTES TO ADDRESSES */
+#define BIT_OFFSET(a) ((a)&7) /* BIT OFFSET OF ADDR WITHIN BYTE */
+
+#ifdef OTIS
+#define LOADBUFSIZE (TRG_MAX_MBLK/8) /* USE OTIS BUFFER SIZE */
+#else
+#define LOADBUFSIZE 0x1000 /* 16K BUFFER FOR LOADING DATA */
+#endif
+
+#define LOADWORDSIZE 2 /* MINIMUM DIVISOR OF LOAD SIZE */
+#define CINIT ".cinit" /* NAME OF CINIT SECTION */
+#define INIT_ALIGN 1 /* ALIGNMENT OF CINIT RECORDS */
+#define INIT_WSIZE 2 /* SIZE IN BYTES OF INIT DATA ITEMS */
+#endif
+
+#if TMS32030 || TMS32040
+typedef unsigned int T_ADDR; /* TYPE FOR TARGET ADDRESS */
+typedef unsigned int T_DATA; /* TYPE FOR TARGET DATA WORD */
+typedef unsigned int T_SIZE; /* TYPE FOR CINIT SIZE FIELD */
+typedef unsigned int T_IADDR; /* TYPE FOR CINIT ADDRESS FIELD */
+typedef unsigned int T_INSTRUCT; /* TYPE FOR INSTRUCTION OPCODE */
+
+#define MAGIC MAGIC_C30 /* Magic number for C30 */
+
+#define LOCTOBYTE(x) ((x)<<2) /* C30 word addrs to byte addrs */
+#define BYTETOLOC(x) ((x)>>2) /* byte addrs to word addrs */
+#define BIT_OFFSET(a) (0) /* BIT OFFSET OF ADDR WITHIN BYTE */
+
+#ifdef OTIS
+#define LOADBUFSIZE (TRG_MAX_MBLK/8) /* USE OTIS BUFFER SIZE */
+#else
+#define LOADBUFSIZE 0x0FF8 /* 4K-8 BUFFER FOR LOADING DATA */
+#endif
+
+#define LOADWORDSIZE 2 /* MINIMUM DIVISOR OF LOAD SIZE */
+#define CINIT ".cinit" /* NAME OF CINIT SECTION */
+#define INIT_ALIGN 1 /* ALIGNMENT OF CINIT RECORDS */
+#define INIT_WSIZE 4 /* SIZE IN BYTES OF INIT DATA ITEMS */
+#endif
+
+#if TMS32025 || TMS32050
+typedef unsigned short T_ADDR; /* TYPE FOR TARGET ADDRESS */
+typedef unsigned short T_DATA; /* TYPE FOR TARGET DATA WORD */
+typedef unsigned short T_SIZE; /* TYPE FOR CINIT SIZE FIELD */
+typedef unsigned short T_IADDR; /* TYPE FOR CINIT ADDRESS FIELD */
+typedef unsigned short T_INSTRUCT; /* TYPE FOR INSTRUCTION OPCODE */
+
+#define MAGIC MAGIC_DSP /* Magic number for C25 */
+
+#define LOCTOBYTE(x) ((x)<<1) /* 16-bit word addrs to byte addrs */
+#define BYTETOLOC(x) ((x)>>1) /* byte addrs to word addrs */
+#define BIT_OFFSET(a) (0) /* BIT OFFSET OF ADDR WITHIN BYTE */
+
+#ifdef OTIS
+#define LOADBUFSIZE (TRG_MAX_MBLK/8) /* USE OTIS BUFFER SIZE */
+#else
+#define LOADBUFSIZE 0x4000 /* 16K BUFFER FOR LOADING DATA */
+#endif /* ifdef OTIS */
+
+#define LOADWORDSIZE 2 /* MINIMUM DIVISOR OF LOAD SIZE */
+#define CINIT ".cinit" /* NAME OF CINIT SECTION */
+#define INIT_ALIGN 1 /* ALIGNMENT OF CINIT RECORDS */
+#define INIT_WSIZE 2 /* SIZE IN BYTES OF INIT DATA ITEMS */
+
+#endif /* TMS32025 || TMS32050 */
+
+#if TMS380
+typedef unsigned short T_ADDR; /* TYPE FOR TARGET ADDRESS */
+typedef unsigned short T_DATA; /* TYPE FOR TARGET DATA WORD */
+typedef unsigned short T_SIZE; /* TYPE FOR CINIT SIZE FIELD */
+typedef unsigned short T_IADDR; /* TYPE FOR CINIT ADDRESS FIELD */
+typedef unsigned short T_INSTRUCT; /* TYPE FOR INSTRUCTION OPCODE */
+
+#define MAGIC MAGIC_380 /* Magic number for TMS380 */
+
+#define LOCTOBYTE(x) x /* 16-bit byte addrs to byte addrs */
+#define BYTETOLOC(x) x /* byte addrs to byte addrs */
+#define BIT_OFFSET(a) (0) /* BIT OFFSET OF ADDR WITHIN BYTE */
+
+#ifdef OTIS
+#define LOADBUFSIZE (TRG_MAX_MBLK/8) /* USE OTIS BUFFER SIZE */
+#else
+#define LOADBUFSIZE 0x4000 /* 16K BUFFER FOR LOADING DATA */
+#endif
+
+#define LOADWORDSIZE 2 /* MINIMUM DIVISOR OF LOAD SIZE */
+#define CINIT ".cinit" /* NAME OF CINIT SECTION */
+#define INIT_ALIGN 2 /* ALIGNMENT OF CINIT RECORDS */
+#define INIT_WSIZE 1 /* SIZE IN BYTES OF INIT DATA ITEMS */
+#endif
+
+#if TMS370 || TMS370C8
+typedef unsigned short T_ADDR; /* TYPE FOR TARGET ADDRESS */
+typedef unsigned char T_DATA; /* TYPE FOR TARGET DATA WORD */
+typedef unsigned short T_SIZE; /* TYPE FOR CINIT SIZE FIELD */
+typedef unsigned short T_IADDR; /* TYPE FOR CINIT ADDRESS FIELD */
+typedef unsigned char T_INSTRUCT; /* TYPE FOR INSTRUCTION OPCODE */
+
+#define MAGIC MAGIC_370 /* 370 Magic Number */
+
+#define LOCTOBYTE(x) x /* 370 addresses are same as bytes */
+#define BYTETOLOC(x) x
+#define BIT_OFFSET(a) (0) /* BIT OFFSET OF ADDR WITHIN BYTE */
+
+#ifdef OTIS
+#define LOADBUFSIZE (TRG_MAX_MBLK/8) /* USE OTIS BUFFER SIZE */
+#else
+#define LOADBUFSIZE 0x4000 /* 16K BUFFER FOR LOADING DATA */
+#endif
+
+#define LOADWORDSIZE 2 /* MINIMUM DIVISOR OF LOAD SIZE */
+#define CINIT ".cinit" /* NAME OF CINIT SECTION */
+#define INIT_ALIGN 1 /* ALIGNMENT OF CINIT RECORDS */
+#define INIT_WSIZE 1 /* SIZE IN BYTES OF INIT DATA ITEMS */
+#endif
+
+#if MVP_PP
+typedef unsigned int T_ADDR; /* TYPE FOR TARGET ADDRESS */
+typedef unsigned int T_DATA; /* TYPE FOR TARGET DATA WORD */
+typedef unsigned int T_SIZE; /* TYPE FOR CINIT SIZE FIELD */
+typedef unsigned int T_IADDR; /* TYPE FOR CINIT ADDRESS FIELD */
+
+typedef struct {unsigned int ins_h; unsigned int ins_l; } T_INSTRUCT;
+ /* TYPE FOR INSTRUCTION OPCODE */
+
+#define MAGIC MAGIC_MVP /* PP Magic Number */
+
+#define LOCTOBYTE(x) (x) /* PP addresses are same as bytes */
+#define BYTETOLOC(x) (x)
+#define BIT_OFFSET(a) (0) /* BIT OFFSET OF ADDR WITHIN BYTE */
+
+#ifdef OTIS
+#define LOADBUFSIZE (TRG_MAX_MBLK/8) /* USE OTIS BUFFER SIZE */
+#else
+#define LOADBUFSIZE 0x4000 /* 16K BUFFER FOR LOADING DATA */
+#endif
+
+#define LOADWORDSIZE 8 /* MINIMUM DIVISOR OF LOAD SIZE */
+#define CINIT ".cinit" /* NAME OF CINIT SECTION */
+#define INIT_ALIGN 8 /* ALIGNMENT OF CINIT RECORDS */
+#define INIT_WSIZE 4 /* SIZE IN BYTES OF INIT DATA ITEMS */
+#endif
+
+#if MVP_MP
+typedef unsigned int T_ADDR; /* TYPE FOR TARGET ADDRESS */
+typedef unsigned int T_DATA; /* TYPE FOR TARGET DATA WORD */
+typedef unsigned int T_SIZE; /* TYPE FOR CINIT SIZE FIELD */
+typedef unsigned int T_IADDR; /* TYPE FOR CINIT ADDRESS FIELD */
+typedef unsigned int T_INSTRUCT; /* TYPE FOR INSTRUCTION OPCODE */
+
+#define FT_IEEE_FLT 1
+#define FT_IEEE_DBL 2
+#define FLT_PRECISION 4
+
+typedef struct trg_fval {
+ unsigned int fval1;
+ unsigned int fval2;
+} TRG_FVAL;
+
+#define MAGIC MAGIC_MVP /* MP Magic Number */
+
+#define LOCTOBYTE(x) (x) /* MP addresses are same as bytes */
+#define BYTETOLOC(x) (x)
+#define BIT_OFFSET(a) (0) /* BIT OFFSET OF ADDR WITHIN BYTE */
+
+#ifdef OTIS
+#define LOADBUFSIZE (TRG_MAX_MBLK/8) /* USE OTIS BUFFER SIZE */
+#else
+#define LOADBUFSIZE 0x4000 /* 16K BUFFER FOR LOADING DATA */
+#endif
+
+#define LOADWORDSIZE 8 /* MINIMUM DIVISOR OF LOAD SIZE */
+#define CINIT ".cinit" /* NAME OF CINIT SECTION */
+#define INIT_ALIGN 8 /* ALIGNMENT OF CINIT RECORDS */
+#define INIT_WSIZE 4 /* SIZE IN BYTES OF INIT DATA ITEMS */
+#endif
+
+#if LEAD
+typedef unsigned short T_ADDR; /* TYPE FOR TARGET ADDRESS */
+typedef unsigned short T_DATA; /* TYPE FOR TARGET DATA WORD */
+typedef unsigned short T_SIZE; /* TYPE FOR CINIT SIZE FIELD */
+typedef unsigned short T_IADDR; /* TYPE FOR CINIT ADDRESS FIELD */
+typedef unsigned short T_INSTRUCT; /* TYPE FOR INSTRUCTION OPCODE */
+
+#define MAGIC MAGIC_LEAD /* Magic number for C25 */
+
+#define LOCTOBYTE(x) ((x)<<1) /* 16-bit word addrs to byte addrs */
+#define BYTETOLOC(x) ((x)>>1) /* byte addrs to word addrs */
+#define BIT_OFFSET(a) (0) /* BIT OFFSET OF ADDR WITHIN BYTE */
+
+#ifdef OTIS
+#define LOADBUFSIZE (TRG_MAX_MBLK/8) /* USE OTIS BUFFER SIZE */
+#else
+#define LOADBUFSIZE 0x4000 /* 16K BUFFER FOR LOADING DATA */
+#endif /* ifdef OTIS */
+
+#define LOADWORDSIZE 2 /* MINIMUM DIVISOR OF LOAD SIZE */
+#define CINIT ".cinit" /* NAME OF CINIT SECTION */
+#define INIT_ALIGN 1 /* ALIGNMENT OF CINIT RECORDS */
+#define INIT_WSIZE 2 /* SIZE IN BYTES OF INIT DATA ITEMS */
+
+#endif /* LEAD */
+
+#if LEAD3
+typedef unsigned int T_ADDR; /* TYPE FOR TARGET ADDRESS */
+typedef unsigned short T_DATA; /* TYPE FOR TARGET DATA WORD */
+typedef unsigned short T_SIZE; /* TYPE FOR CINIT SIZE FIELD */
+typedef unsigned int T_IADDR; /* TYPE FOR CINIT ADDRESS FIELD */
+typedef unsigned int T_INSTRUCT; /* TYPE FOR INSTRUCTION OPCODE */
+
+#define MAGIC MAGIC_LEAD3 /* Magic number for C55 */
+
+#define LOCTOBYTE(x) (x) /* LEAD3 is byte addressable */
+#define BYTETOLOC(x) (x) /* LEAD3 is byte addressable */
+#define BIT_OFFSET(a) (0) /* BIT OFFSET OF ADDR WITHIN BYTE */
+
+#ifdef OTIS
+#define LOADBUFSIZE (TRG_MAX_MBLK/8) /* USE OTIS BUFFER SIZE */
+#else
+#define LOADBUFSIZE 0x4000 /* 16K BUFFER FOR LOADING DATA */
+#endif /* ifdef OTIS */
+
+#define LOADWORDSIZE 2 /* MINIMUM DIVISOR OF LOAD SIZE */
+#define CINIT ".cinit" /* NAME OF CINIT SECTION */
+#define INIT_ALIGN 1 /* ALIGNMENT OF CINIT RECORDS */
+#define INIT_WSIZE 2 /* SIZE IN BYTES OF INIT DATA ITEMS */
+
+#endif /* LEAD3 */
+
+#if ARM
+typedef unsigned int T_ADDR; /* TYPE FOR TARGET ADDRESS */
+typedef unsigned int T_DATA; /* TYPE FOR TARGET DATA WORD */
+typedef unsigned int T_SIZE; /* TYPE FOR CINIT SIZE FIELD */
+typedef unsigned int T_IADDR; /* TYPE FOR CINIT ADDRESS FIELD */
+typedef unsigned int T_INSTRUCT; /* TYPE FOR INSTRUCTION OPCODE */
+
+#define MAGIC MAGIC_ARM /* Magic number for ARM */
+
+#define LOCTOBYTE(x) (x) /* ARM addresses are same as bytes */
+#define BYTETOLOC(x) (x)
+#define BIT_OFFSET(a) (0) /* BIT OFFSET OF ADDR WITHIN BYTE */
+
+#ifdef OTIS
+#define LOADBUFSIZE (TRG_MAX_MBLK/8) /* USE OTIS BUFFER SIZE */
+#else
+#define LOADBUFSIZE 0x4000 /* 16K BUFFER FOR LOADING DATA */
+#endif
+
+#define LOADWORDSIZE 4 /* MINIMUM DIVISOR OF LOAD SIZE */
+#define CINIT ".cinit" /* NAME OF CINIT SECTION */
+#define INIT_ALIGN 4 /* ALIGNMENT OF CINIT RECORDS */
+#define INIT_WSIZE 4 /* SIZE IN BYTES OF INIT DATA ITEMS */
+
+#endif /* ARM */
+
+#if TMS32060
+typedef unsigned int T_ADDR; /* TYPE FOR TARGET ADDRESS */
+typedef unsigned int T_DATA; /* TYPE FOR TARGET DATA WORD */
+typedef unsigned int T_SIZE; /* TYPE FOR CINIT SIZE FIELD */
+typedef unsigned int T_IADDR; /* TYPE FOR CINIT ADDRESS FIELD */
+typedef unsigned int T_INSTRUCT; /* TYPE FOR INSTRUCTION OPCODE */
+
+#define FT_IEEE_FLT 1
+#define FT_IEEE_DBL 2
+#define FLT_PRECISION 4
+
+typedef struct trg_fval {
+ unsigned int fval1;
+ unsigned int fval2;
+} TRG_FVAL;
+
+#define MAGIC MAGIC_C60 /* C60 Magic Number */
+
+#define LOCTOBYTE(x) (x) /* C60 addresses are same as bytes */
+#define BYTETOLOC(x) (x)
+#define BIT_OFFSET(a) (0) /* BIT OFFSET OF ADDR WITHIN BYTE */
+
+#ifdef OTIS
+#define LOADBUFSIZE (TRG_MAX_MBLK/8) /* USE OTIS BUFFER SIZE */
+#else
+#define LOADBUFSIZE 0x4000 /* 16K BUFFER FOR LOADING DATA */
+//#define UNBUFFERED 1
+#endif
+
+#define LOADWORDSIZE 8 /* MINIMUM DIVISOR OF LOAD SIZE */
+#define CINIT ".cinit" /* NAME OF CINIT SECTION */
+#define INIT_ALIGN 8 /* ALIGNMENT OF CINIT RECORDS */
+#define INIT_WSIZE 4 /* SIZE IN BYTES OF INIT DATA ITEMS */
+#endif
+
+#if VIVID
+typedef unsigned int T_ADDR; /* TYPE FOR TARGET ADDRESS */
+typedef unsigned int T_DATA; /* TYPE FOR TARGET DATA WORD */
+typedef unsigned int T_SIZE; /* TYPE FOR CINIT SIZE FIELD */
+typedef unsigned int T_IADDR; /* TYPE FOR CINIT ADDRESS FIELD */
+typedef unsigned int T_INSTRUCT; /* TYPE FOR INSTRUCTION OPCODE */
+
+#define FT_IEEE_FLT 1
+#define FT_IEEE_DBL 2
+#define FLT_PRECISION 4
+
+typedef struct trg_fval {
+ unsigned int fval1;
+ unsigned int fval2;
+} TRG_FVAL;
+
+#define MAGIC MAGIC_VIVID /* Vivid Magic Number */
+
+#define LOCTOBYTE(x) (x) /* Vivid addresses are same as bytes*/
+#define BYTETOLOC(x) (x)
+#define BIT_OFFSET(a) (0) /* BIT OFFSET OF ADDR WITHIN BYTE */
+
+#ifdef OTIS
+#define LOADBUFSIZE (TRG_MAX_MBLK/8) /* USE OTIS BUFFER SIZE */
+#else
+#define LOADBUFSIZE 0x4000 /* 16K BUFFER FOR LOADING DATA */
+#endif
+
+#define LOADWORDSIZE 8 /* MINIMUM DIVISOR OF LOAD SIZE */
+#define CINIT ".cinit" /* NAME OF CINIT SECTION */
+#define INIT_ALIGN 8 /* ALIGNMENT OF CINIT RECORDS */
+#define INIT_WSIZE 4 /* SIZE IN BYTES OF INIT DATA ITEMS */
+#endif
+
diff --git a/src/interp/coff/proto.h b/src/interp/coff/proto.h
--- /dev/null
+++ b/src/interp/coff/proto.h
@@ -0,0 +1,15 @@
+/*****************************************************************************/
+/* PROTO.H - Prototypes for loader required functions. */
+/*****************************************************************************/
+
+/*--------------------------------------------------------------------------*/
+/* LOADER REQUIRED FUNCTIONS */
+/*--------------------------------------------------------------------------*/
+/* extern int mem_write (unsigned char *, unsigned int, T_ADDR,
+ unsigned char); - moved to osal.h */
+extern int set_reloc_amount (void);
+extern void lookup_sym (int indx, SYMENT *sym, AUXENT *aux);
+extern int load_syms (int need_reloc);
+extern void *myalloc (unsigned int size);
+extern void *mralloc (void *p, unsigned int size);
+extern void load_msg (const char *format);
diff --git a/src/interp/coff/version.h b/src/interp/coff/version.h
--- /dev/null
@@ -0,0 +1,106 @@
+/****************************************************************************/
+/* */
+/* File: version.h Last change: 25-June-90 RET */
+/* */
+/* All portability flags and version information is to appear HERE ONLY. */
+/* Host specific flags are defined automatically by this file. */
+/* */
+/****************************************************************************/
+
+/****************************************************************************/
+/* TARGET SPECIFIC FLAGS */
+/****************************************************************************/
+#define TMS340 0 /* TMS340 */
+#define TMS34020 0 /* TMS340 340XX, 0 for 10 only */
+#define TMS370 0 /* Roadrunner */
+#define TMS32030 0 /* Brahma */
+#define TMS32025 0 /* Shiva, Himiko */
+#define TMS32050 0 /* Mosaic */
+#define TMS380 0 /* Eagle */
+#define TMS37016 0 /* Prism */
+#define MVP 0 /* MVP */
+#define MVP_MP 0 /* MVP MP */
+#define MVP_PP 0 /* MVP PP */
+#define TMS32060 1 /* TMS320C60 */
+#define VIVID 0 /* VIVID */
+#define LEAD 0 /* LEAD Fixed-Point DSP */
+#define LEAD3 0 /* LEAD Fixed-Point DSP */
+#define ARM 0 /* ARM */
+#define TMS370C8 0 /* C8 */
+#define TMS370C8P 0 /* C8+ */
+#define RTC 0 /* ANKOOR */
+
+#define VERSION "Version 0.01"
+#define COPYRITE "Copyright (c) 1997 Texas Instruments Incorporated"
+#define BANNER_PAD 30
+#define VSTAMP 001 /* version stamp for output file*/
+
+\f
+/****************************************************************************/
+/* OPERATING SYSTEM SPECIFIC FLAGS: MSDOS, UNIX, VAX_VMS, MPW. */
+/* THESE FLAGS ARE SET AUTOMATICALLY BY THE HOST COMPILER DEPENDING ON */
+/* PREDEFINED HOST COMPILER SYMBOLS. WHEN THE TOOLS ARE PORTED TO A NEW */
+/* HOST OR A NEW COMPILER, THIS FILE MAY NEED MODIFICATION. */
+/****************************************************************************/
+
+/****************************************************************************/
+/* MSDOS : If system is DOS based. (MS-DOS, PC-DOS, etc) */
+/****************************************************************************/
+#ifdef MSDOS /* ALWAYS defed IN MSC 5.00+ */
+#undef MSDOS
+#define MSDOS 1
+#else
+#define MSDOS 0
+#endif
+
+/****************************************************************************/
+/* UNIX : Any unix environment */
+/****************************************************************************/
+#if unix || __unix /* ALWAYS defined by UNIX compilers */
+#define UNIX 1
+#else
+#define UNIX 0
+#endif
+
+/****************************************************************************/
+/* NT : If target is Windows NT */
+/****************************************************************************/
+#ifdef __NT__ /* DEFINED WITH /bt=NT on WATCOM COMPILER */
+#define WIN_NT 1
+#else
+#define WIN_NT 0
+#endif
+
+/****************************************************************************/
+/* VAX_VMS : If system is a VAX, running VMS */
+/****************************************************************************/
+#if VAX && VMS /* BOTH DEFINED BY VAX C COMPILER */
+#define VAX_VMS 1
+#else
+#define VAX_VMS 0
+#endif
+
+/****************************************************************************/
+/* MPW : Macintosh, particularly the MPW environment */
+/****************************************************************************/
+#if macintosh || mcu68000 /* DEFINED BY MPW COMPILER */
+#define MPW 1
+#else
+#define MPW 0
+#endif
+
+\f
+/****************************************************************************/
+/* HOST_ENFORCES_ALIGNMENT is used by the tools to determine if the */
+/* host allows memory accesses on unaligned boundaries. This flag is */
+/* used in the compilers for reading I-CODE, and in the assemblers for */
+/* building memory images of object files. */
+/*--------------------------------------------------------------------------*/
+/* This implementation is PARANOID - that is, if I don't specifically know */
+/* that a host can handle non-aligned memory accesses, I assume it can't. */
+/****************************************************************************/
+#if MSDOS || VAX_VMS || MPW || WIN_NT
+#define HOST_ENFORCES_ALIGNMENT 0 /* NON-ALIGNED ACCESSES LEGAL */
+#else
+#define HOST_ENFORCES_ALIGNMENT 1 /* SPARC, MIPS, HP... */
+#endif
diff --git a/src/main/c64x/make/makefile b/src/main/c64x/make/makefile
--- /dev/null
@@ -0,0 +1,56 @@
+#***********************************************************************
+#* FILE PURPOSE: Build the IBL main module
+#***********************************************************************
+#* FILE NAME: makefile
+#*
+#* DESCRIPTION: Makes the main module for the IBL
+#*
+#***********************************************************************
+
+ifndef IBL_ROOT
+ export IBL_ROOT= ../../..
+endif
+
+ECODIR= $(IBL_ROOT)/main
+
+
+CSRC= iblmain.c
+
+
+.PHONY: main
+
+
+
+include $(IBL_ROOT)/make/$(ARCH)/makeeco.mk
+
+
+C6X_C_DIR= $(IBL_ROOT)/main
+C6X_C_DIR+= ;$(IBL_ROOT)
+C6X_C_DIR+= ;$(IBL_ROOT)/interp/bis
+C6X_C_DIR+= ;$(IBL_ROOT)/interp/coff
+C6X_C_DIR+= ;$(IBL_ROOT)/interp/btbl
+C6X_C_DIR+= ;$(IBL_ROOT)/interp/blob
+C6X_C_DIR+= ;$(IBL_ROOT)/arch/$(ARCH)
+C6X_C_DIR+= ;$(IBL_ROOT)/device
+C6X_C_DIR+= ;$(IBL_ROOT)/device/$(TARGET)
+C6X_C_DIR+= ;$(IBL_ROOT)/ethboot
+C6X_C_DIR+= ;$(IBL_ROOT)/driver/timer
+C6X_C_DIR+= ;$(IBL_ROOT)/hw/i2c
+C6X_C_DIR+= ;$(IBL_ROOT)/cfg/$(TARGET)
+C6X_C_DIR+= ;$(STDINC)
+export C6X_C_DIR
+
+
+
+
+main: gen_cdefdep makefile $(OBJS)
+
+
+
+$(OBJS): cdefdep
+
+gen_cdefdep:
+ @echo Checking command line dependencies
+ @echo $(ENDIAN) $(TARGET) > cdefdep.tmp
+ @sh -c 'if diff -q cdefdep.tmp cdefdep ; then echo same ; else $(CP) cdefdep.tmp cdefdep ; fi '
+
diff --git a/src/main/iblmain.c b/src/main/iblmain.c
--- /dev/null
+++ b/src/main/iblmain.c
@@ -0,0 +1,267 @@
+/*****************************************************************************************
+ * FILE PURPOSE: Perform the top level boot
+ *****************************************************************************************
+ * FILE NAME: iblmain.c
+ *
+ * DESCRIPTION: The top level boot examines the boot configuration and performs boot
+ * based on this configuration
+ *
+ * @file iblmain.c
+ *
+ * @brief
+ * This file is used to launch a boot based on the boot configuration structure
+ *
+ *****************************************************************************************/
+#include "ibl.h"
+#include "iblloc.h"
+#include "iblcfg.h"
+#include "device.h"
+#include "ethboot.h"
+#include "bis.h"
+#include "coffwrap.h"
+#include "iblbtbl.h"
+#include "iblblob.h"
+#include "timer.h"
+#include "i2c.h"
+#include <string.h>
+
+
+/**
+ * @brief The ibl table is declared.
+ *
+ * @details
+ * The ibl table is declared uninitialized by this ibl program. An external
+ * initialization can be performed if the default operation of the ibl is
+ * not desired.
+ */
+#pragma DATA_SECTION(ibl, ".ibl_config_table")
+ibl_t ibl;
+
+
+/**
+ * @brief The ibl status table is declared.
+ *
+ * @details
+ * The ibl status table is declared. It is initialized at run time
+ * in function main.
+ */
+#pragma DATA_SECTION(iblStatus, ".ibl_status_table")
+iblStatus_t iblStatus;
+
+
+/* Eat printfs */
+void mprintf(char *x, ...) { }
+
+/**
+ * @b Description
+ * @n
+ *
+ * Returns TRUE if the input priority is valid and enabled
+ */
+BOOL iblPriorityIsValid (uint32 priority)
+{
+ if ( (priority >= ibl_HIGHEST_PRIORITY) &&
+ (priority <= ibl_LOWEST_PRIORITY) )
+
+ return (TRUE);
+
+
+ return (FALSE);
+
+}
+
+/**
+ * @b Description
+ * @n
+ *
+ * Returns TRUE if the mac address is 0
+ */
+BOOL iblMacAddrIsZero (uint8 *maddr)
+{
+ int32 i;
+
+ for (i = 0; i < 6; i++)
+ if (maddr[i] != 0)
+ return (FALSE);
+
+ return (TRUE);
+
+}
+
+
+/**
+ * @b Description
+ * @n
+ *
+ * The main function kicks off the boot. If it does not find the magic value in the
+ * configuration array then default values are loaded. This default load
+ * is done only once at the start of boot.
+ *
+ * @retval
+ * None
+ */
+void main (void)
+{
+ int32 i, j;
+
+ /* Initialize the status structure */
+ memset (&iblStatus, 0, sizeof(iblStatus_t));
+ iblStatus.iblMagic = ibl_MAGIC_VALUE;
+
+ /* Initialize the system timer (software tracking of the hardware timer state */
+ timer_init ();
+
+#if 0
+ /* If there is no magic value in the ibl configuration structure then a default
+ * table is used. */
+ if (ibl.iblMagic != ibl_MAGIC_VALUE) {
+ deviceLoadDefaultIblTable();
+ iblStatus.noMagic = 1;
+ ibl.iblMagic = ibl_MAGIC_VALUE;
+ }
+#endif
+
+ /* Load the default configuration table from the i2c. The actual speed of the device
+ * isn't really known here, since it is part of the table, so a compile time
+ * value is used (the pll may have been configured during the initial load) */
+ hwI2Cinit (IBL_I2C_DEV_FREQ_MHZ, /* The CPU frequency during I2C data load */
+ DEVICE_I2C_MODULE_DIVISOR, /* The divide down of CPU that drives the i2c */
+ IBL_I2C_CLK_FREQ_KHZ, /* The I2C data rate used during table load */
+ IBL_I2C_OWN_ADDR); /* The address used by this device on the i2c bus */
+
+ if (hwI2cMasterRead (IBL_I2C_CFG_TABLE_DATA_ADDR, /* The address on the eeprom of the table */
+ sizeof(ibl_t), /* The number of bytes to read */
+ (UINT8 *)&ibl, /* Where to store the bytes */
+ IBL_I2C_CFG_EEPROM_BUS_ADDR, /* The bus address of the eeprom */
+ IBL_I2C_CFG_ADDR_DELAY) /* The delay between sending the address and reading data */
+
+ != I2C_RET_OK) {
+
+ /* There is no recovery if the load of the configuration table failed */
+ iblStatus.tableLoadFail = 0x11111111;
+ for (;;);
+ }
+
+ /* Load default mac addresses for ethernet boot if requested */
+ for (i = 0; i < ibl_N_ETH_PORTS; i++) {
+
+ if ( (iblPriorityIsValid (ibl.ethConfig[i].ethPriority) ) &&
+ (iblMacAddrIsZero (ibl.ethConfig[i].ethInfo.hwAddress) ) )
+
+ deviceLoadDefaultEthAddress (ibl.ethConfig[i].ethInfo.hwAddress);
+
+ }
+
+
+ /* Pll configuration is device specific */
+ devicePllConfig ();
+
+ /* DDR configuration is device specific */
+ deviceDdrConfig ();
+
+ /* Try booting forever */
+ for (;;) {
+
+ /* Start looping through the boot modes to find the one with the lowest priority
+ * value, and try to boot it */
+ for (i = ibl_HIGHEST_PRIORITY; i < ibl_LOWEST_PRIORITY; i++) {
+
+ for (j = 0; j < ibl_N_ETH_PORTS; j++) {
+ if (ibl.ethConfig[j].ethPriority == i)
+ iblEthBoot (j);
+ }
+
+ if (ibl.nandConfig.nandPriority == i)
+ iblNandBoot ();
+
+ iblStatus.heartBeat += 1;
+ }
+
+ }
+
+
+} /* main */
+
+
+
+/**
+ * @b Description
+ * @n
+ *
+ * The ibl boot function links a device to a data format. The data format
+ * parser pulls data from the boot device
+ *
+ * @param[in] bootFxn The structure containing the boot device functions
+ *
+ * @retval
+ * None
+ */
+Uint32 iblBoot (BOOT_MODULE_FXN_TABLE *bootFxn, Int32 dataFormat, void *formatParams)
+{
+ Uint32 entry = 0;
+
+ union {
+
+ Uint8 dataBuf[4]; /* Place holder */
+ Uint32 bisValue;
+ Uint16 coffVer;
+
+ } fid;
+
+
+ /* Determine the data format if required */
+ if (dataFormat == ibl_BOOT_FORMAT_AUTO) {
+
+ (*bootFxn->peek)((Uint8 *)&fid, sizeof(fid));
+
+ /* BIS */
+ if (fid.bisValue == BIS_MAGIC_NUMBER)
+ dataFormat = ibl_BOOT_FORMAT_BIS;
+
+ if (iblIsCoff (fid.coffVer))
+ dataFormat = ibl_BOOT_FORMAT_COFF;
+
+ else {
+ iblStatus.autoDetectFailCnt += 1;
+ return (0);
+ }
+ }
+
+
+ /* Invoke the parser */
+ switch (dataFormat) {
+
+ case ibl_BOOT_FORMAT_BIS:
+ iblBootBis (bootFxn, &entry);
+ break;
+
+ case ibl_BOOT_FORMAT_COFF:
+ iblBootCoff (bootFxn, &entry);
+ break;
+
+ case ibl_BOOT_FORMAT_BTBL:
+ iblBootBtbl (bootFxn, &entry);
+ break;
+
+ case ibl_BOOT_FORMAT_BBLOB:
+ iblBootBlob (bootFxn, &entry, formatParams);
+ break;
+
+ default:
+ iblStatus.invalidDataFormatSpec += 1;
+ break;
+
+ }
+
+
+ return (entry);
+
+}
+
+
+
+
+
+
+
+
diff --git a/src/make/Makefile b/src/make/Makefile
--- /dev/null
+++ b/src/make/Makefile
@@ -0,0 +1,40 @@
+#*******************************************************************************************
+#* FILE PURPOSE: Top level make for the IBL
+#*******************************************************************************************
+#* FILE NAME: Makefile
+#*
+#* DESCRIPTION: Builds the Intermediate Boot Loader (IBL)
+#*
+#*******************************************************************************************
+
+IBLS_C6X= c6455 c6472
+
+
+all:
+ @echo must specify a target [ $(IBLS_C6X) ]
+
+
+# Default options that can be overridden on the command line
+ifndef ENDIAN
+ ENDIAN=little
+endif
+export ENDIAN
+
+
+$(IBLS_C6X):
+ make -f makestg2 ARCH=c64x TARGET=$@ $@
+
+
+# will need to add a line for each additional ARCH type added
+clean:
+ make -f makestg2 clean ARCH=c64x
+
+
+
+
+
+
+
+
+
+
diff --git a/src/make/c64x/bootinc.mk b/src/make/c64x/bootinc.mk
--- /dev/null
+++ b/src/make/c64x/bootinc.mk
@@ -0,0 +1,65 @@
+#************************************************************************************
+#* FILE PURPOSE: Boot loader specific make options
+#************************************************************************************
+#* FILE NAME: bootinc.mk
+#*
+#* DESCRIPTION: Definitions common accross boot loader make files
+#*
+#************************************************************************************
+
+# Adjust the cflags based on desired endianness
+
+ifeq ($(ENDIANNES),big)
+CFLAGS+= -me
+AFLAGS+= -me
+endif
+
+ifneq ($(MV6400PLUS),no)
+CFLAGS:=$(subst mv6400,mv6400+,$(CFLAGS))
+AFLAGS:=$(subst mv6400,mv6400+,$(AFLAGS))
+#CFLAGS:=$(subst o3,,$(CFLAGS)) # for debug builds
+endif
+
+# mdebug - remove this
+# CFLAGS:=$(subst -o3,-o2,$(CFLAGS))
+# end mdebug
+
+CFLAGS+= -ms2
+
+ifdef RTLIBS
+RTLIBS = $(TOOLSC6X)/cgtools/lib/rts6400.lib
+endif
+
+# Rule to run splint. Form the splint
+SPLINTCHECK= -splint $(CDEFS) $(SPLINT_OPTS) $(SPLINT_IPATH) $(SPLINT_DEFS) $<
+SPLINT_OBJ_EXT= sobj
+
+ALLDIR= $(C6X_C_DIR) $(SPLINT_PATH)
+
+SPLINT_I0= $(subst \\\\\,!,$(ALLDIR))
+SPLINT_I1= $(subst \\\\,!,$(SPLINT_I0))
+SPLINT_I2= $(subst \\\,!,$(SPLINT_I1))
+SPLINT_I3= $(subst \\,!,$(SPLINT_I2))
+SPLINT_I4= $(subst \,!,$(SPLINT_I3))
+SPLINT_I5= $(subst !,\,$(SPLINT_I4))
+SPLINT_I6= $(subst ;, ,$(SPLINT_I5))
+SPLINT_I7= $(addprefix -I,$(SPLINT_I6))
+SPLINT_I8= $(subst /,\,$(SPLINT_I7))
+SPLINT_I9= $(SPLINT_I8) -I..\..
+
+SPLINT_IPATH= $(SPLINT_I9)
+
+SPLINT_OPTS= -booltype BOOL +boolint -nullret -incondefs -exportlocal -Dcregister=
+
+
+
+#MIKE_DASH= \\hello\\\\mike
+#MIKE_RM= $(subst \\\\,;,$(MIKE_DASH))
+#MIKE_R2= $(subst \\,;,$(MIKE_RM))
+
+
+SPLINT_OBJS= $(patsubst %.c, %.$(SPLINT_OBJ_EXT), $(CFILES))
+
+%.$(SPLINT_OBJ_EXT): %.c
+ -$(SPLINTCHECK)
+
diff --git a/src/make/c64x/makedefs.mk b/src/make/c64x/makedefs.mk
--- /dev/null
@@ -0,0 +1,101 @@
+#*******************************************************************************
+#* FILE PURPOSE: Define makefile variables for C64X
+#*******************************************************************************
+#* FILE NAME: makedefs.mk
+#*
+#* DESCRIPTION: Make include file which defines variables used by all DSP
+#* Makefiles.
+#*
+#* (C) Copyright 1999 TELOGY Networks, Inc.
+#*******************************************************************************
+
+CC = $(TOOLSC6X)/cgtools/bin/cl6x
+AS = $(TOOLSC6X)/cgtools/bin/cl6x
+LD = $(TOOLSC6X)/cgtools/bin/cl6x -z
+ARIN = $(TOOLSC6X)/cgtools/bin/ar6x -rq
+AROUT = $(TOOLSC6X)/cgtools/bin/ar6x -xq
+HEX6X = $(TOOLSC6X)/cgtools/bin/hex6x
+CDBTOOL = $(COMSPEC) /c $(TOOLSBIOSCDBC6X)\gconfgen
+MAKEDEP = $(MAKEDEPPATH)
+MAKEDEP_OPT = -q
+COBJEXT = oc
+LOBJEXT = ol
+AOBJEXT = oa
+CDEPEXT = dc
+LDEPEXT = dl
+ADEPEXT = da
+ASMEXT = s
+LASMEXT = sa
+LIBEXT = lib
+RM = rm -f
+CP = cp -f
+MV = mv -f
+CPUDIR = c64x
+
+
+# CPU Class flags
+CPUFLAGS = -mv6400+
+
+ifeq ($(ENDIAN),big)
+ ALLFARLIB = $(TOOLSC6XDOS)/cgtools/lib/rts64pluse.lib
+else
+ ALLFARLIB = $(TOOLSC6XDOS)/cgtools/lib/rts64plus.lib
+endif
+
+RTLIBS = $(subst /,\,$(ALLFARLIB))
+
+# Common compilation flags
+# -c : disable linker
+# -k : keep .asm file
+# -mi200 : set imterrupt threshold to max of 200 cycles.
+# -ml3 : far memory model
+# -pm : program level optimization
+# -mv6400: Target processor is 64x
+# -pden : display diagnostic number along with messages
+# -pdr : display remarks
+# -pds1111: shut off #pragma symbol warnings
+# -pds827: shut off #pragma symbol warnings (symbol undefined)
+# -pds824: shut off #pragma symbol warnings (can be applied to file level symbol only)
+# -pds837: shut off #pragma symbol warnings (can be applied to file level symbol only)
+# -pds97: shut off no source in file warning
+#CFLAGS = -c -k -mi200 -ml3 -o2 -pm -pds1111 -pds827 -pds824 -pds837 -pds1037 -pds195 -pds97 -pden -pdr $(CPUFLAGS)
+CFLAGS = -c -k -mi200 -ml3 -ms3 -o2 -pm -pds1111 -pds827 -pds824 -pds837 -pds1037 -pds195 -pds97 -pden -pdr $(CPUFLAGS)
+
+ifeq ($(ENDIAN),big)
+ CFLAGS+= -me
+endif
+
+# Debug flags
+# -as : keep local symbols
+# -g : enable debugging
+# -ss : interlist C source and optimizer with .asm source
+DCFLAGS = -g -as -ss
+#DCFLAGS = -gp
+
+
+# ASM options
+# -s : place all symbols in object file
+# -l : produce listing
+# -pw : warn pipelne conflicts
+# AFLAGS = -s -l -g -mk -ms $(CPUFLAGS)
+AFLAGS = -g -ea.s -c -k -mi200 -ml3 -pm -al $(CPUFLAGS)
+
+ifeq ($(ENDIAN),big)
+ AFLAGS+= -me
+endif
+
+# Include files for standard (non siu) modules. Also used by linker to find
+# library files.
+FSTDINC =$(TOOLSC6XDOS)/cgtools/include;$(TOOLSC6XDOS)/cgtools/lib
+FSTDINC +=;$(TOOLSC6XDOS)/rtdx/include;$(TOOLSC6XDOS)/rtdx/lib
+FSTDINC +=;$(TOOLSBIOSC6XDOS)/bios/include;$(TOOLSBIOSC6XDOS)/bios/lib
+FSTDINC +=;$(TOOLSBIOSC6XDOS)/xdais/include;;$(TOOLSBIOSC6XDOS)/xdais/src/api
+STDINC =$(subst /,\,$(FSTDINC))
+
+# Include files for ASM in standard (non siu) modules
+STDAINC =$(subst /,\,$(TOOLSBIOSC6XDOS)/bios/include;$(GGROOT)/misc/$(CPUDIR))
+
+# Include files for this platform. Change this for test code.
+PLATINC =$(subst /,\,$(GGROOT)/hw/$(CPUDIR);$(ECODIR)/gg/$(CPUDIR);$(ECODIR)/$(CPUDIR))
+
+# Nothing past this point
diff --git a/src/make/c64x/makeeco.mk b/src/make/c64x/makeeco.mk
--- /dev/null
+++ b/src/make/c64x/makeeco.mk
@@ -0,0 +1,223 @@
+#*******************************************************************************
+#* FILE PURPOSE: Perform standard variable computation and targets for ECOs
+#*******************************************************************************
+#* FILE NAME: makeeco.mk
+#*
+#* DESCRIPTION: Make include file which computes some variables and defines
+#* standard targets for DSP ECOs.
+#*
+#* Input variables:
+#* CSRC : List of C Source files
+#* ASMSRC : List of assembly source files
+#* Output variables:
+#* OBJS : List of all object files
+#*
+#*
+#* (C) Copyright 1999-2001 TELOGY Networks, Inc.
+#*******************************************************************************
+
+# get definitions
+include $(IBL_ROOT)/make/$(ARCH)/makedefs.mk
+
+# If ECODIR is not defined, derive it from ECONAME
+ifndef ECODIR
+ ECODIR = $(IBL_ROOT)/$(ECONAME)
+endif
+
+# VPATH tells make how to find sources in other directories
+vpath %.$(ASMEXT) $(ECODIR)/$(CPUDIR)
+#The vpath below is needed to compile the dsp/memory folder properly
+vpath %.c $(ECODIR)/$(CPUDIR)/$(CPUTYPEDIR)
+vpath %.c $(ECODIR)/$(CPUDIR)
+vpath %.sa $(ECODIR)/$(CPUDIR)
+vpath %.s62 $(ECODIR)/$(CPUDIR)
+vpath % $(ECODIR)
+
+# Get filenames w/o paths
+
+CFILES = $(foreach file, $(CSRC), $(notdir $(file)))
+AFILES = $(foreach file, $(ASMSRC), $(notdir $(file)))
+LINAFILES = $(foreach file, $(LINASMSRC), $(notdir $(file)))
+BIOSSFILES = $(foreach file, $(BIOSASMSRC), $(notdir $(file)))
+EXCFILES = $(foreach file, $(EXCSRC), $(notdir $(file)))
+EXAFILES = $(foreach file, $(EXASMSRC), $(notdir $(file)))
+TESTCFILES = $(foreach file, $(TESTCSRC), $(notdir $(file)))
+TESTAFILES = $(foreach file, $(TESTASMSRC), $(notdir $(file)))
+TESTLINASMFILES = $(foreach file, $(TESTLINASMSRC), $(notdir $(file)))
+
+
+DFULLPATH = $(patsubst %.s62, %.$(ADEPEXT),$(BIOSSFILES) \
+ $(patsubst %.c, %.$(CDEPEXT), $(CFILES) $(EXCFILES) $(TESTCFILES)) \
+ $(patsubst %.$(ASMEXT), %.$(ADEPEXT), $(AFILES) $(EXAFILES) $(TESTAFILES) $(BIOSSFILES)) \
+ $(patsubst %.sa, %.$(LDEPEXT), $(LINAFILES) $(TESTLINASMFILES)))
+
+
+OBJS = $(COBJS) $(AOBJS)
+COBJS = $(patsubst %.c, %.$(COBJEXT), $(CFILES))
+AOBJS = $(patsubst %.s62, %.$(AOBJEXT), $(BIOSSFILES) \
+ $(patsubst %.$(ASMEXT), %.$(AOBJEXT), $(AFILES)) \
+ $(patsubst %.sa, %.$(LOBJEXT), $(LINAFILES)))
+REFTGT =
+
+DCS = $(CDCS) $(ADCS)
+CDCS = $(patsubst %.c, %.$(CDEPEXT), $(CFILES))
+ADCS = $(patsubst %.s62, %.$(CDEPEXT), $(BIOSSFILES) \
+ $(patsubst %.$(ASMEXT), %.$(CDEPEXT), $(AFILES)) \
+ $(patsubst %.sa, %.$(CDEPEXT), $(LINAFILES)))
+
+
+# extra objects (not built by builtin rules)
+EXOBJS = $(patsubst %.s62, %.$(AOBJEXT), $(BIOSSFILES) \
+ $(patsubst %.c, %.$(COBJEXT), $(EXCFILES)) \
+ $(patsubst %.$(ASMEXT), %.$(AOBJEXT), $(EXAFILES)))
+
+# extra objects (used for test code)
+TESTOBJS = $(patsubst %.s62, %.$(AOBJEXT), $(BIOSSFILES) \
+ $(patsubst %.c, %.$(COBJEXT), $(TESTCFILES)) \
+ $(patsubst %.$(ASMEXT), %.$(AOBJEXT), $(TESTAFILES)) \
+ $(patsubst %.$(LASMEXT), %.$(LOBJEXT), $(TESTLINASMFILES)))
+
+# intermediate files
+CLEAN_INTERMEDIATES = $(patsubst %.s62, %.lst, $(BIOSSFILES) \
+ $(patsubst %.c, %.asm, $(CFILES) $(EXCFILES) $(TESTCFILES)) \
+ $(patsubst %.c, %.lst, $(CFILES) $(EXCFILES) $(TESTCFILES)) \
+ $(patsubst %.$(ASMEXT), %.lst, $(AFILES) $(EXAFILES) $(TESTAFILES)) \
+ $(patsubst %.sa, %.asm, $(LINAFILES) $(TESTLINASMFILES)) \
+ $(patsubst %.sa, %.lst, $(LINAFILES) $(TESTLINASMFILES)) \
+ $(DFULLPATH))
+
+# Compute FLATFILES, if necessary
+ifndef FLATFILES
+ FLATFILES =$(patsubst %,$(ECODIR)/%,$(CSRC) $(ASMSRC) $(HDR) $(LINASMSRC) $(BIOSASMSRC) )
+endif
+
+# If FLATGGDIR isnt set, and we make flat, then we are making flat for test prg
+ifndef FLATGGDIR
+ # This has two magical effects: 1) causes FLATGGDIR to be set now, and
+ # causes recursive makefiles to set the correct FLAT directory even during
+ # recursion.
+ FLATFILES +=$(patsubst %,$(ECODIR)/%,$(TESTCSRC) $(TESTASMSRC) $(TESTHDR))
+ ifdef ECONAME
+ export FLATGGDIR = $(ECONAME)/c64x/make/flat
+ else
+ export FLATGGDIR = $(notdir $(ECODIR))/c64x/make/flat
+ endif
+endif
+
+FLATDIR =$(ROMROOT)/$(FLATGGDIR)
+
+ifneq ($(findstring $(FLAT),yes YES),)
+ FLAT_TARGET =$(REFTGT) flat
+else
+ FLAT_TARGET =$(REFTGT)
+endif
+
+.PHONY: clean flat gen_flatdir
+
+# standard targets
+clean:
+ -$(RM) $(OBJS) $(EXOBJS) $(TESTOBJS) $(CLEAN_TARGETS) $(CLEAN_INTERMEDIATES) $(REFTGT)
+ -$(RM) -r flat
+
+ifneq ($(findstring $(FLAT),yes YES),)
+flat:
+ -mkdir $(subst /,\,$(FLATDIR))
+ -$(CP) -u $(FLATFILES) $(FLATDIR)
+
+# Define command to copy targets to flat
+CPFLATCMD = $(CP) $@ $(FLATDIR)
+
+else
+
+CPFLATCMD =
+
+endif
+
+# Copy targets to delivery directory
+# The variables STDDLV and BOOTLD should be set by calling makefile
+ifneq ($(BOOTLD),none)
+ CPBOOTLD=$(CP) $(BOOTPATH)/$(BOOTLD) $(DELIVERY)/boot_$(OUTFILE).out
+ CPBOOTLD2=
+else
+ ifeq ($(GGDSP_CPU),12)
+ CPBOOTLD=$(CP) $(BOOTPATH)/boot5560_pg10_20.out $(DELIVERY)/bootpg10_20_$(OUTFILE).out
+ CPBOOTLD2=
+ else
+ CPBOOTLD=
+ CPBOOTLD2=
+ endif
+endif
+
+# how to build .c and .s files on c64x
+FNAMEDEF = -dTNFNAME=$(notdir $<)
+GGCCOMPILE = $(CC) $(CFLAGS) $(DCFLAGS) $(CDEFS) $(FNAMEDEF) $< -eo.$(COBJEXT)
+GGLCOMPILE = $(CC) $(CFLAGS) $(DCFLAGS) $(CDEFS) $(FNAMEDEF) $< -eo.$(LOBJEXT)
+GGACOMPILE = $(AS) $(AFLAGS) $(ADEFS) $< $@ -eo.$(AOBJEXT)
+GGCMAKEDEP = $(MAKEDEP) $(MAKEDEP_OPT) $(CDEPINC) -e$(COBJEXT) -o$$.$(CDEPEXT) $<
+GGLMAKEDEP = $(MAKEDEP) $(MAKEDEP_OPT) $(ADEPINC) -a -e$(AOBJEXT) -o$$.$(LDEPEXT) $<
+GGAMAKEDEP = $(MAKEDEP) $(MAKEDEP_OPT) $(ADEPINC) -a -e$(AOBJEXT) -o$$.$(ADEPEXT) $<
+GGALMAKEDEP = $(MAKEDEP) $(MAKEDEP_OPT) $(ALDEPINC) -a -e$(ALOBJEXT) -o$$.$(ALDEPEXT) $<
+
+#Two options of invoking blockexpn:
+# 1)Passing NUMCH for implicit expansion
+# 2)Explicitly giving the number of expansions in the .bex file
+GGBLOCKEXPN = $(BLOCKEXPN) $< $@
+GGBLOCKEXPNNUMCH = $(BLOCKEXPN) $< $@ $(NUMCH)
+
+%.$(COBJEXT): %.c
+ $(GGCCOMPILE)
+
+# Compilation of Linear Assembly files
+%.$(LOBJEXT): %.$(LASMEXT)
+ $(GGLCOMPILE)
+
+%.$(AOBJEXT): %.$(ASMEXT)
+ $(GGACOMPILE)
+
+# Special compilation for BIOS
+%.$(AOBJEXT): %.s62
+ $(GGACOMPILE)
+
+CDEPINC = $(subst \,/,-I$(subst ;, -I,$(C6X_C_DIR)))
+ADEPINC = $(subst \,/,-I$(subst ;, -I,$(C6X_A_DIR)))
+
+
+%.$(CDEPEXT): %.c
+ $(GGCMAKEDEP)
+
+# dependency for .sa files
+%.$(LDEPEXT): %.sa
+ $(GGLMAKEDEP)
+
+%.$(ADEPEXT): %.s
+ $(GGAMAKEDEP)
+
+%.$(ADEPEXT): %.s62
+ $(GGAMAKEDEP)
+
+# Preprocessing via blockexpn.pl
+# ggmbuf.bec and ggmheap.bec are not build specific but common.They need to use the
+# NUMCH parameter
+%.c: %.bec
+ $(GGBLOCKEXPNNUMCH)
+
+#Numch parameter not passed to linker command file / memmap as the number of expansion
+#required may be different from num channels in the build
+%.h: %.beh
+ $(GGBLOCKEXPN)
+
+%.cmd: %.becmd
+ $(GGBLOCKEXPN)
+
+# Reflection page symbol tables
+# %.oc is included so we inherit the dependancies from the .dc file
+# Set GGREFDBG=-v# on command line to debug
+%.ref: %.c %.oc $(REFPAGEDEP)
+ $(REFPAGE) $(GGREFDBG) -iC6X_C_DIR $< -s$@ $(CDEFS) -dGG_REF_PAGE -d6416 -t$(REFSYM)
+
+ifneq ($(DOMAKEDEP),no)
+# include generated dependancies.
+sinclude $(DFULLPATH)
+endif
+
+# Nothing past this point
diff --git a/src/make/cpytools/cpytools.pl b/src/make/cpytools/cpytools.pl
--- /dev/null
@@ -0,0 +1,204 @@
+#!/usr/bin/perl
+
+# Syntax
+# ccperl cpytools.pl srcbase dstbase [enable_write]
+#
+# Copy tree specified from srcbase to dstbase. If the enable_write parameter
+# is provided, then files are copied to and deleted from dstbase, to maintain
+# an exact mirror of srcbase. If the enable_write parameter is not provided,
+# an exit status of 0 is returned if all of the files in srcbase are present
+# in dstbase with same sizes and dates; If any of the files are missing or do
+# not match, then a nonzero exit value is returned.
+#
+
+# For DOS, change this to "command /c copy"
+
+$copy="cmd /c copy";
+$write_enabled = 0;
+$error = 1;
+$files_to_copy = 0;
+$files_to_delete = 0;
+
+$error = 0 if ($#ARGV == 1);
+if ($#ARGV == 2) {
+ if ($ARGV[2] eq "enable_write") {
+ $write_enabled = 1;
+ $error = 0;
+ }
+}
+
+errexit ("Syntax: ccperl $0 srcbase dstbase [enable_write]\n") if ($error);
+
+# Now verify that srcbase exists
+$srcbase = $ARGV[0];
+errexit ("Source base directory invalid ($srcbase)\n") if ( !-d $srcbase);
+
+# Set dstbase, error will "fall out" while trying to copy files
+$dstbase = $ARGV[1];
+
+# Get a list of files in $dstbase
+@subdirs = ("$dstbase");
+
+while (@subdirs) {
+ $dir = pop (@subdirs);
+ opendir (DIR, $dir) || next;
+ @files = readdir(DIR);
+ closedir DIR;
+
+ foreach $file (@files) {
+ next if (($file eq ".") || ($file eq ".."));
+ if (-f "$dir/$file") {
+ # Add files to checklist hash
+ $dstfiles{normalize("$dir/$file")} = 1;
+ } elsif (-d "$dir/$file") {
+ # Add directories to @subdirs
+ push @subdirs, "$dir/$file";
+ }
+ }
+}
+
+# Get a list of files in $srcbase
+@subdirs = ("");
+@cpylist = ();
+
+while (@subdirs) {
+ $reldir = pop (@subdirs);
+ opendir DIR, "$srcbase$reldir" || errexit ("Can\'t read $srcbase$reldir\n");
+ @files = readdir(DIR);
+ closedir DIR;
+
+ foreach $file (@files) {
+ next if (($file eq ".") || ($file eq ".."));
+ if (-f "$srcbase$reldir/$file") {
+ # Process the file.
+ $dstpath = normalize("$dstbase$reldir/$file");
+
+ # Mark file as present
+ $dstfiles{"$dstpath"} = 0;
+
+ push @cpylist, "$reldir/$file";
+ } elsif (-d "$srcbase$reldir/$file") {
+ # Add directories to @subdirs
+ push @subdirs, "$reldir/$file";
+ }
+ }
+}
+
+# Find any files that were in srcbase, but were not in dstfiles, and delete them
+foreach $file (keys %dstfiles) {
+ if ($dstfiles{"$file"}) {
+ if ($write_enabled) {
+ print "rm -f $file\n";
+ chmod 0777, $file;
+ unlink $file;
+ } else {
+ $files_to_delete ++;
+ }
+ }
+}
+
+# Now copy source files to dest files; this is done after deletions so that
+# files with incorrect case on case preserving but case insensitive filesystems
+# are recopied with correct case.
+for ($i=0; $i<=$#cpylist; $i++) {
+ $srcpath = normalize("$srcbase$cpylist[$i]");
+ $dstpath = normalize("$dstbase$cpylist[$i]");
+
+ if ((-e $srcpath) && (-e $dstpath)) {
+ @stats = stat($srcpath);
+ $srcmtime = $stats[9];
+ $srcsize = $stats[7];
+ @stats = stat($dstpath);
+ $dstmtime = $stats[9];
+ $dstsize = $stats[7];
+ next if (($srcmtime == $dstmtime) && ($srcsize == $dstsize));
+ }
+
+ if ($write_enabled) {
+ makepath ($dstpath);
+
+ if ((-e $dstpath) && (! -w $dstpath)) {
+ print "rm -f $dstpath\n";
+ chmod 0777, $dstpath;
+ unlink $dstpath;
+ }
+ $cmd = dosnormalize("\"$srcpath\" \"$dstpath\"");
+ print "copy $cmd\n";
+ $ret = system "$copy $cmd >nul";
+ errexit ("Command ($cmd) failed\nCheck for cmd vs command\n") if ($ret != 0);
+ } else {
+ $files_to_copy ++;
+ }
+}
+
+# Check and return error status
+if (! $write_enabled) {
+ if ($files_to_delete || $files_to_copy) {
+ print "********************** UNSYNCHRONIZED TOOLS ***************************\n";
+ print "In order to synchronize $dstbase,\n";
+ print "need to delete $files_to_delete files, and copy $files_to_copy files.\n";
+ print "Rerun command with 'enable_write' parameter to perform synchronization\n";
+ print "********************** UNSYNCHRONIZED TOOLS ***************************\n";
+ exit (1);
+ }
+}
+exit (0);
+
+# Convert \ to /, and then // to /
+sub normalize {
+ my ($str) = @_;
+
+ $str =~ s|\\|/|g;
+
+ $str =~ s|/+|/|g;
+
+ return "$str";
+}
+
+# Convert / to \, and then \\ to \
+sub dosnormalize {
+ my ($str) = @_;
+
+ $str =~ s|/|\\|g;
+
+ $str =~ s|\\+|\\|g;
+
+ return "$str";
+}
+
+sub makepath {
+ my ($path) = @_;
+
+ @components = split /\//, $path;
+ # Dispose of file name part
+ pop(@components);
+
+ $first = 1;
+ $path = "";
+ foreach $component (@components) {
+ $path = $path . "$component";
+
+ if ($first) {
+ # Skip through the drive letter
+ $first = 0;
+ if ($component =~ /^[A-Za-z]:$/) {
+ $path = $path . "/";
+ next;
+ }
+ }
+ if (! -e $path) {
+ print "mkdir $path\n";
+ mkdir "$path",0777;
+ }
+ errexit ("Destination must be directory: ($path)") if (! -d $path);
+
+ $path = $path . "/";
+ }
+}
+
+sub errexit {
+ my ($msg) = @_;
+
+ print $msg;
+ exit(5);
+}
diff --git a/src/make/ibl_c6455/ibl.cmd b/src/make/ibl_c6455/ibl.cmd
--- /dev/null
@@ -0,0 +1,52 @@
+/************************************************************************************
+ * FILE PURPOSE: Define the memory usage of the ibl module for the c6455
+ ************************************************************************************
+ * FILE NAME: ibl.cmd
+ *
+ * DESCRIPTION: The memory placement for the IBL is defined
+ *
+ ************************************************************************************/
+
+
+../main/c64x/make/iblmain.oc
+../device/c64x/make/c6455.oc
+../ethboot/c64x/make/ethboot.oc
+../driver/c64x/make/net.oc
+../driver/c64x/make/arp.oc
+../driver/c64x/make/ip.oc
+../driver/c64x/make/udp.oc
+../driver/c64x/make/stream.oc
+../driver/c64x/make/timer.oc
+../driver/c64x/make/bootp.oc
+../driver/c64x/make/tftp.oc
+../hw/c64x/make/t64.oc
+../hw/c64x/make/cpmacdrv.oc
+../interp/c64x/make/bis.oc
+
+-c
+-stack 0x400
+
+
+
+MEMORY
+{
+ L2 : origin = 0x800000, length = 0x10000
+ CFG : origin = 0x810000, length = 0x0200
+ STAT : origin = 0x810200, length = 0x0200
+}
+
+SECTIONS
+{
+ .stack > L2
+ .cinit > L2
+ .const > L2
+ .text > L2
+ .far > L2
+ .switch > L2
+ .bss > L2
+
+ .ibl_config_table > CFG
+ .ibl_status_table > STAT
+
+}
+
diff --git a/src/make/ibl_c6455/ibl_c6455.out.ept b/src/make/ibl_c6455/ibl_c6455.out.ept
--- /dev/null
@@ -0,0 +1 @@
+\ 3
\ No newline at end of file
diff --git a/src/make/ibl_c6472/i2crom.dat b/src/make/ibl_c6472/i2crom.dat
--- /dev/null
@@ -0,0 +1,12033 @@
+1651 1 10000 1 2f00
+0x001e0000
+0x01010000
+0x00190001
+0x04200050
+0x00000001
+0x02710032
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x0080ff3d
+0x0080b7c0
+0x000001cc
+0x0080bec0
+0x00000009
+0x00818048
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000004
+0x00818058
+0x00000001
+0x00000000
+0x00000004
+0x0081805c
+0x00000000
+0x00000000
+0x00000004
+0x00818060
+0x00000000
+0x00000000
+0x00000004
+0x008180a0
+0x00000000
+0x00000000
+0x00000004
+0x008180a4
+0x00000000
+0x00000000
+0x00000004
+0x008180a8
+0x00807158
+0x00000000
+0x00000000
+0x00000004
+0x008180c0
+0x00000000
+0x00000000
+0x00000004
+0x008180c4
+0x00000000
+0x00000000
+0x00000004
+0x008180cc
+0xffffffff
+0x00000000
+0x00000004
+0x008180d0
+0x00000000
+0x00000000
+0x00000004
+0x00818270
+0x00000000
+0x00000000
+0x00000004
+0x00818274
+0x00000000
+0x00000000
+0x00000004
+0x00818278
+0x00000001
+0x00000000
+0x00000004
+0x00806941
+0x0081828c
+0x00004800
+0x00000000
+0x00000008
+0x00811800
+0x000047f8
+0x00000000
+0x00000004
+0x00818290
+0x00811800
+0x00000000
+0x0000001c
+0x00818130
+0x00805ba0
+0x00805f50
+0x00805928
+0x00000000
+0x00805a14
+0x00805800
+0x00805a10
+0x00000000
+0x0000001c
+0x00816c70
+0x00804968
+0x00804964
+0x00804946
+0x00000000
+0x00804926
+0x00804cd8
+0x008047ee
+0x00000000
+0x008011de
+0x00000008
+0x00817290
+0x02c80000
+0x02cc0000
+0x00000008
+0x00817298
+0x02c82000
+0x02cc2000
+0x00000004
+0x00818284
+0x0080b960
+0x00000000
+0x00000004
+0x00818288
+0x0080b960
+0x00000000
+0x00000004
+0x00818044
+0x00000000
+0x00000000
+0x00000004
+0x0081814c
+0x00000000
+0x00000000
+0x00000000
+0x0000051e
+0x0080b9a0
+0x544f4f42
+0x61462050
+0x72756c69
+0x42203a65
+0x008008f1
+0x6f6b6361
+0x74206666
+0x72656d69
+0x69616620
+0x0a64656c
+0x4f4f4200
+0x46205054
+0x756c6961
+0x203a6572
+0x2078614d
+0x72746552
+0x6d736e61
+0x69737369
+0x20736e6f
+0x65637865
+0x64656465
+0x2a2a000a
+0x2a2a2a2a
+0x2a2a2a2a
+0x2a2a2a2a
+0x2a2a2a2a
+0x2a2a2a2a
+0x2a2a2a2a
+0x0a2a2a2a
+0x4f4f4200
+0x43205054
+0x6c706d6f
+0x0a657465
+0x20202000
+0x20504920
+0x72646441
+0x00801375
+0x20737365
+0x3a202020
+0x25783020
+0x20000a78
+0x4e202020
+0x4d207465
+0x206b7361
+0x20202020
+0x30203a20
+0x0a782578
+0x20202000
+0x66654420
+0x746c7561
+0x756f5220
+0x3a726574
+0x25783020
+0x20000a78
+0x53202020
+0x65767265
+0x50492072
+0x20202020
+0x30203a20
+0x0a782578
+0x20202000
+0x6c694620
+0x614e2065
+0x2020656d
+0x3a202020
+0x0a732520
+0x52524500
+0x203a524f
+0x00807011
+0x544f4f42
+0x44412050
+0x69542044
+0x2072656d
+0x6c696146
+0x000a6465
+0x4f525245
+0x42203a52
+0x50544f4f
+0x434f5320
+0x704f204b
+0x46206e65
+0x656c6961
+0x00000a64
+0x6f727245
+0x54203a72
+0x20505446
+0x44414552
+0x51455220
+0x74655220
+0x736e6172
+0x7373696d
+0x736e6f69
+0x76616820
+0x78652065
+0x64656563
+0x000a6465
+0x6f727245
+0x54203a72
+0x20505446
+0x76726573
+0x00804932
+0x69207265
+0x6f642073
+0x203b6e77
+0x70206f6e
+0x656b6361
+0x65722074
+0x76696563
+0x0a2e6465
+0x72724500
+0x203a726f
+0x50544654
+0x72724520
+0x5020726f
+0x656b6361
+0x65522074
+0x76696563
+0x000a6465
+0x6f727245
+0x54203a72
+0x20505446
+0x61746144
+0x636f5320
+0x2074656b
+0x6e65704f
+0x69614620
+0x0a64656c
+0x72724500
+0x203a726f
+0x50544654
+0x6d695420
+0x63207265
+0x008029d9
+0x74616572
+0x206e6f69
+0x6c696166
+0x000a6465
+0x6f727245
+0x54203a72
+0x20505446
+0x204b4341
+0x72746552
+0x6d736e61
+0x20737469
+0x65637845
+0x64656465
+0x7245000a
+0x3a726f72
+0x54465420
+0x69542050
+0x2072656d
+0x61657243
+0x6e6f6974
+0x69614620
+0x0a64656c
+0x00000000
+0x00000000
+0x03565500
+0x5a0f0c59
+0x590c0f5a
+0x00555603
+0x66333065
+0x3f6a693c
+0x3c696a3f
+0x008035b8
+0x65303366
+0x65303366
+0x3c696a3f
+0x3f6a693c
+0x66333065
+0x00555603
+0x590c0f5a
+0x5a0f0c59
+0x03565500
+0x6a3f3c69
+0x33666530
+0x30656633
+0x693c3f6a
+0x0f5a590c
+0x56030055
+0x55000356
+0x0c595a0f
+0x0c595a0f
+0x55000356
+0x56030055
+0x0f5a590c
+0x693c3f6a
+0x30656633
+0x33666530
+0x6a3f3c69
+0x693c3f6a
+0x30656633
+0x33666530
+0x6a3f3c69
+0x0c595a0f
+0x55000356
+0x0080f56f
+0x56030055
+0x0f5a590c
+0x0f5a590c
+0x56030055
+0x55000356
+0x0c595a0f
+0x6a3f3c69
+0x33666530
+0x30656633
+0x693c3f6a
+0x00555603
+0x590c0f5a
+0x5a0f0c59
+0x03565500
+0x65303366
+0x3c696a3f
+0x3f6a693c
+0x66333065
+0x66333065
+0x3f6a693c
+0x3c696a3f
+0x65303366
+0x03565500
+0x5a0f0c59
+0x590c0f5a
+0x00555603
+0x4f525245
+0x4d203a52
+0x6c617369
+0x656e6769
+0x614c2064
+0x00807fe2
+0x33726579
+0x63617020
+0x2074656b
+0x65636572
+0x64657669
+0x25783020
+0x000a2e70
+0x4f525245
+0x4d203a52
+0x6c617369
+0x656e6769
+0x614c2064
+0x33726579
+0x63617020
+0x2074656b
+0x6e617274
+0x74696d73
+0x20646574
+0x70257830
+0x45000a2e
+0x524f5252
+0x454e203a
+0x72462054
+0x54206565
+0x736e6172
+0x2074696d
+0x6b636170
+0x64207465
+0x63657465
+0x20646574
+0x72726f63
+0x0080a94e
+0x69747075
+0x000a6e6f
+0x4f525245
+0x4e203a52
+0x46205445
+0x20656572
+0x6e617254
+0x74696d73
+0x63617020
+0x2074656b
+0x65746564
+0x64657463
+0x756f6420
+0x20656c62
+0x65657266
+0x0000000a
+0x6f727245
+0x42203a72
+0x43205349
+0x616d6d6f
+0x3020646e
+0x20782578
+0x20746f6e
+0x70707573
+0x6574726f
+0x2a000a64
+0x2a2a2a2a
+0x2a2a2a2a
+0x2a2a2a2a
+0x2a2a2a2a
+0x2a2a2a2a
+0x0080ef34
+0x2a2a2a2a
+0x2a2a2a2a
+0x6554000a
+0x6e696d72
+0x20657461
+0x6d6d6f43
+0x0a646e61
+0x20202000
+0x746e4520
+0x50207972
+0x746e696f
+0x30203a20
+0x0a782578
+0x00000000
+0x7369622e
+0x69612e00
+0x6f2e0073
+0x2e007475
+0x66666f63
+0x74622e00
+0x2e006c62
+0x006e6962
+0x6f6c622e
+0x00000062
+0x55424544
+0x45203a47
+0x72656874
+0x2074656e
+0x6b6e694c
+0x20736920
+0x0a205055
+0x00801020
+0x00000000
+0x74736574
+0x696c5f32
+0x656c7474
+0x74756f2e
+0x00000000
+0x7373622e
+0x69632e00
+0x0074696e
+0x7865742e
+0x00000074
+0x00000000
+0xffffffff
+0x0000ffff
+0x0000a9a0
+0x00801000
+0x624731f7
+0xc24e2346
+0xe427434f
+0x00004f7a
+0x028100da
+0xe6116141
+0x0084ef5a
+0xe4e0000e
+0x0084e0da
+0x02405828
+0x020040e8
+0x6c6e002c
+0xa00ca120
+0xfe00840a
+0x19003980
+0x0080a9ab
+0xed008000
+0x02006da0
+0xb007a120
+0x3900620a
+0x1146ec00
+0x02806da0
+0x86ba86e8
+0xc78ce2c6
+0xed808000
+0x0084a35a
+0x004d2120
+0x00846ce2
+0x000019e2
+0x1408fc80
+0x6c6ec60c
+0x01003ce2
+0xe6000000
+0x010b180a
+0x008829e2
+0xa01ba120
+0x0ea8ee00
+0x8310ad3a
+0x80c68b80
+0xdbeffc71
+0xef008000
+0x2c6e10c6
+0x4e0c0ce6
+0xe41a4c6e
+0x04a89c66
+0x00248120
+0x26003047
+0x0080ed14
+0x00140af8
+0xe5e00040
+0xd014a120
+0x24108300
+0x80c6ea00
+0xdbeffc71
+0x2c6e10c6
+0x0e0c0ce6
+0xe41a4c6e
+0xefc00000
+0x04a89c66
+0x30470c6e
+0xa4e3c68c
+0x00004000
+0x000019e2
+0x0c6e04a9
+0x71f71046
+0xece00001
+0x4c6e8046
+0x008ca362
+0x03102264
+0x03c06c28
+0x038040e8
+0x6c6e018c
+0x1026ec30
+0xec200000
+0xd022a120
+0x03c06828
+0x038040e8
+0x052601fc
+0x00086078
+0x0080e32c
+0x0083e9a0
+0x2c1a2000
+0xe9000000
+0x021c3e40
+0x6c6e005c
+0xa32aaf08
+0xa2aaaf28
+0x204c84ca
+0xecb0834a
+0x4da824a0
+0xefc08000
+0xdfe8a120
+0xa1ef0626
+0x6c6e002c
+0x000a1808
+0x008b1008
+0x01891809
+0x0c0204a8
+0xe8c00000
+0x0c026428
+0x000b19a2
+0x10041429
+0x008ca362
+0x6c6e020c
+0x00831008
+0x000119a2
+0xe2a20000
+0x120414a9
+0x008ca362
+0x634731f7
+0x8406324f
+0x00804653
+0x4257434e
+0x8498e4a6
+0x00000000
+0xe7a201e0
+0x028510da
+0xe6804250
+0x0000ef58
+0x24262460
+0x040044e0
+0x0423e418
+0x01a00fd8
+0xe1400000
+0x000899da
+0x3599a13b
+0x03c05828
+0x038040e8
+0xa32a018c
+0xeea0844a
+0x010872f8
+0xe6508000
+0x65224a20
+0xd009a120
+0x000a6120
+0x001072f8
+0x0246ec00
+0x46e86c5a
+0xc0588120
+0xe6200000
+0x714682c6
+0x123d5141
+0x0c6e2427
+0x00801f9a
+0x0000dce0
+0x0c6eec00
+0x00007f9a
+0x660c1205
+0xeae00008
+0x27622726
+0x031be058
+0x00843ce0
+0x2428c408
+0xb4e36604
+0xa86a018c
+0x0d082600
+0xef308000
+0x9100a8fa
+0x4a002410
+0xfc0180c6
+0x10c6d86f
+0x0c662c6e
+0x0c420e04
+0x88ca1c67
+0xefe08400
+0xee803047
+0xa4fa0d28
+0x8900b110
+0xfc0180c6
+0x10c6d86f
+0x0c662c6e
+0x0c424e04
+0xefe09000
+0x0c6e1c67
+0x120d3047
+0x008044f5
+0x24296c6e
+0xa58a1205
+0x86fc9146
+0x000c2ce0
+0x00004000
+0xe3e08000
+0x0080ef99
+0x00043ce0
+0x868404a8
+0xa1ef71f7
+0x0010aa58
+0xc0728120
+0xc0a62246
+0xe9900000
+0xcc26d82a
+0xb0262800
+0xd066a120
+0x000609c0
+0x0001abd8
+0x0032d33a
+0xb0262800
+0xec608000
+0x0832d53a
+0xd5aa2468
+0x28002832
+0xd53ab026
+0x24683032
+0x5032d5aa
+0xd52a2468
+0xefe08000
+0x28009032
+0x00805cc1
+0xaebab026
+0x28001832
+0x0001ebd8
+0xe852af3a
+0xd02a2468
+0x28001852
+0xeee08000
+0xadbab026
+0x24685852
+0x7852ad2a
+0xacaa2468
+0x2468b852
+0xd852adaa
+0xb0262800
+0xefe08000
+0x0072a93a
+0xa9aa2468
+0x28002072
+0xa93ab026
+0x24686072
+0xaa0aa9aa
+0x0060462a
+0xe7e08000
+0x0000406b
+0x00044ca0
+0x007fe050
+0x000c1040
+0x0080b362
+0x2626864a
+0xee26864a
+0xed108000
+0x00804581
+0x0232824a
+0x1a12824a
+0x1212824a
+0x0e26824a
+0xa1ef0626
+0x8468b032
+0x224686ea
+0xefe08000
+0x28001832
+0x00006bd8
+0x0052a2fa
+0x000020f8
+0x00006bd8
+0x840aa36a
+0x0626d212
+0xeca08000
+0x008ca362
+0x20460246
+0x28009032
+0xa37ab026
+0x28001832
+0x0001ebd8
+0x848aa46a
+0xebc08008
+0x02320252
+0x008ca362
+0x957727f7
+0x277731f7
+0x85778677
+0x86464647
+0x049806a0
+0x008072c3
+0xe7a00c00
+0x01896828
+0x01804069
+0x0c6ea22c
+0x000c1362
+0x01882162
+0x10620146
+0x804e0446
+0xec821000
+0x05901fda
+0x0189da28
+0x01804068
+0x02080fd8
+0x000c1362
+0x01868162
+0x07900fd8
+0x0209f22a
+0x0200406a
+0x00100362
+0x01846162
+0x02080fd8
+0x0e281586
+0x844aa43a
+0x072c1fd8
+0xe6008000
+0x0146c646
+0xc008a120
+0x04938120
+0x0204a358
+0x0240522a
+0x020040eb
+0x0080619c
+0x100d8606
+0xe8202000
+0x6c6e200c
+0x24002447
+0x040031a2
+0x0680a358
+0xc028a120
+0x248e0486
+0x948ba402
+0xec60040c
+0x248f1001
+0x701d2041
+0x001042e6
+0x02405028
+0x020040e8
+0x0c6e004c
+0xa52b04e9
+0xec608001
+0x00148120
+0x05b40fd8
+0x850aa486
+0x6446a40c
+0x0208842a
+0x0200406a
+0x00100362
+0xe1808020
+0x01818162
+0x05900fd8
+0x0288002a
+0x0280406a
+0x00140362
+0x0080234c
+0x01896162
+0x85879506
+0xe8003000
+0xd78fc70e
+0x04064646
+0xb0266c00
+0xd4188120
+0x240e4406
+0x0005ca58
+0xc2d2a120
+0xe2e00101
+0x2800ec26
+0x00004bd8
+0xd408a120
+0x000649c0
+0x00006bd8
+0x5992fdfa
+0x000709c0
+0xe4208800
+0xa5ba0de8
+0x28009032
+0x00002bd8
+0xd292a120
+0x28001832
+0x1c490833
+0x4072a93b
+0xee608000
+0xb0262800
+0xd0d7a120
+0x0400a120
+0x0060622a
+0x0080154f
+0x0000406b
+0x00044ca0
+0x007fd050
+0xe0200000
+0x000c1040
+0x0080b362
+0x0060982a
+0x0000406b
+0x00044ca0
+0x007f9050
+0x000c1040
+0xe8300000
+0x0080b362
+0x0288002a
+0x0280406a
+0x121302ef
+0x02281fd8
+0x01882162
+0xd687d246
+0xe9001000
+0x01900fd8
+0x02880028
+0x02804068
+0x00280fda
+0x00141362
+0x54401213
+0x01892162
+0xe4000000
+0x03101fd8
+0x000f3908
+0x00100019
+0x00805d25
+0x2000258e
+0xf0470c6e
+0x000e1708
+0xe40233c6
+0xeb001000
+0x00853908
+0x00002ff8
+0x0288d42a
+0x0280406a
+0x131302ef
+0x018a4162
+0x8507d346
+0xea003000
+0x043408f1
+0x020006a0
+0x0288d42a
+0x0280406a
+0x050702ef
+0x001c1fd8
+0x018b2162
+0xe2000000
+0x90624441
+0x043408f1
+0x03181fd8
+0x03a38120
+0x0204a358
+0x0288002a
+0x0280406a
+0xe0200003
+0x121302ef
+0x02281fd8
+0x00802c0d
+0x01842162
+0xd687d246
+0x01900fd8
+0x02880028
+0x02804068
+0xe1200040
+0x00280fda
+0x00141362
+0x54401213
+0x01852162
+0x03101fd8
+0x000f5a08
+0x00100019
+0xe0800000
+0x2000258e
+0xf0470c6e
+0x00802028
+0x000e1608
+0x00840f81
+0x001c1fd8
+0x00015a08
+0xe0600000
+0x00040ff8
+0x0288d42a
+0x0280406a
+0x131302ef
+0x01894162
+0x8507d346
+0x043408f1
+0xe5000c00
+0x020006a0
+0x0080e409
+0x0288d42a
+0x0280406a
+0x050702ef
+0x001c1fd8
+0x018a2162
+0x90624441
+0xe9003000
+0x043408f1
+0x03181fd8
+0x03438120
+0x15862626
+0x740b0c6e
+0x18500032
+0x248e0486
+0xef001000
+0x948ba402
+0x248f1001
+0x701d2041
+0x001042e6
+0x03c05028
+0x038040e8
+0x0c6e01cc
+0xe8e00004
+0xa12b04e9
+0x6686818a
+0xe43ce486
+0xa2ab0407
+0x05b40fd8
+0x44687812
+0x6686a43a
+0xede08000
+0x00809ae5
+0x44786072
+0x8008a120
+0x44684072
+0xd018a120
+0x900ca120
+0x0c26834a
+0xe6061012
+0xeca08000
+0x6c6e839c
+0x00040ce1
+0x04a82506
+0x4ea64446
+0x058d60f8
+0x44683812
+0x7812a4aa
+0xeda28000
+0xa17a4468
+0x84220586
+0x05066446
+0xac62a462
+0x05016078
+0x02e0a120
+0x248e0486
+0xe9e09000
+0x948ba402
+0x048f1011
+0x100d2041
+0x3020a120
+0x02daf02a
+0x0280406a
+0x00140362
+0x0080815b
+0xe0f00004
+0x02402428
+0x00240fda
+0x01852162
+0x020040e9
+0x0f2600c1
+0xa20c8606
+0x044e4046
+0xee121100
+0x4468f832
+0x2427822a
+0x4468e052
+0x1687a22a
+0x34460c6e
+0x847a0486
+0x848a01d2
+0xefe08000
+0xc4279813
+0x0288002a
+0x0280406a
+0x00140362
+0x01886162
+0x26279506
+0xc04fc1ce
+0xec201c00
+0x00a80fd9
+0x0011eca0
+0x444604a8
+0x60522406
+0xa42a2468
+0x4406e052
+0x00801e0d
+0xa5ba4468
+0xef808440
+0x58660506
+0x0c804446
+0xa204860e
+0x258e0506
+0x50262000
+0xc0158120
+0x05296078
+0xe3e20048
+0x10220012
+0x2c082506
+0x0012a6ea
+0x25061822
+0xa4aa2c08
+0x00040028
+0x00008068
+0xe3e08042
+0xa2ea2c08
+0x02405e28
+0x020040e9
+0x00040c26
+0x02738120
+0x14878686
+0x0506657b
+0xed208000
+0x02021f08
+0x00068120
+0xc4269812
+0x0288d42a
+0x0280406a
+0x0080fc1f
+0x00140362
+0x018a6162
+0xe0800000
+0x27268507
+0x044ed1cf
+0x0240a120
+0x248e0486
+0x948ba402
+0x048f1011
+0x100d2041
+0xef700447
+0x300ba120
+0x02daf02a
+0x0280406a
+0x00140362
+0x02402428
+0x00240fda
+0x01892162
+0x020040e9
+0x0f2600c1
+0xa22c8606
+0x00004000
+0x44689832
+0x24a6842a
+0x44688052
+0x2686a42a
+0xef628001
+0x005204c6
+0xa1ea4468
+0x44688052
+0x0506a43a
+0x008089b0
+0x44465866
+0x860e0d00
+0x0c6ea204
+0xefe29400
+0x258e0506
+0x50262000
+0xc0108120
+0x05296078
+0xe8220012
+0x2c082506
+0xc200a120
+0xe6600201
+0x18220012
+0x2c082506
+0xc010a120
+0x00040028
+0x00008068
+0x00002af8
+0xc1f0a120
+0xe0600002
+0xa13a0406
+0xd813818a
+0x0020a35a
+0x0288002a
+0x0280406a
+0x00140362
+0x018a6162
+0xe0608000
+0x26279506
+0xc04f0352
+0x44262246
+0x0080a487
+0xec002462
+0x6408650e
+0x2480a62a
+0x000c0de0
+0xe7e08087
+0x5026444e
+0x0012a22a
+0x6506e822
+0xa4ea6c08
+0x02405e28
+0x020040e9
+0x00040c26
+0xe9e08011
+0x01c38120
+0x14078686
+0x3010a120
+0x900aa120
+0xb83282ca
+0x858ad832
+0x00021008
+0xe6408000
+0x9004a120
+0x3832814a
+0x10625832
+0xa2048606
+0xa33a0406
+0x9812840a
+0x0018a358
+0xe7c28000
+0x0288d42a
+0x0280406a
+0x0080e06f
+0x272602ef
+0x0300202a
+0x01882162
+0x85078346
+0x040006a0
+0xe4800c00
+0x0180a120
+0xa2ea0506
+0x00200028
+0x00007fe9
+0x2c282586
+0x0506a72a
+0xd180a120
+0xe6408000
+0x00600028
+0x007f8069
+0x2c082586
+0xd170a120
+0x01708120
+0x05340fd8
+0x01706120
+0xe0800000
+0x44462426
+0x4468b812
+0xd148a120
+0x01604120
+0x08620506
+0x05016078
+0x820c8606
+0xea620000
+0x45062586
+0x00801ecd
+0x20002c6e
+0x820404d2
+0x44462508
+0x0150a120
+0x820c8606
+0x45862506
+0xede20028
+0x00861a08
+0x40000c6e
+0x01054ca0
+0x00821608
+0x00108255
+0x44462528
+0x0140a120
+0xe4400008
+0x25060506
+0x00021809
+0x0c021c0b
+0x01070809
+0x44281428
+0x4000458e
+0x1c0b0c6e
+0xeea02200
+0x00821808
+0x34280c82
+0x01030808
+0x44464428
+0x0120a120
+0x258e0506
+0x10622000
+0xed400408
+0x00800f74
+0x05000fd8
+0x0110a120
+0x820c8606
+0x14822506
+0x00802c6e
+0x2000258e
+0x44460c22
+0xef820200
+0x0100a120
+0x820c8606
+0x14822506
+0x00802c6e
+0x2000258e
+0x44461422
+0x0100a120
+0xe7c20080
+0xa4462426
+0x248e0486
+0x948ba402
+0x048f1011
+0x100d2041
+0x3023a120
+0x02daf02a
+0xe3f00044
+0x0280406a
+0x00140362
+0x02402428
+0x00240fda
+0x01882162
+0x020040e9
+0x0f2600c1
+0x00803f05
+0xe8001000
+0xa22c8606
+0x84a64c6e
+0x00524498
+0xa42a4c08
+0x58660506
+0x0d004446
+0xa204860e
+0xefe28800
+0x01a80fd9
+0x003421a0
+0x000c0ce1
+0x60006586
+0x06b42058
+0x6686f047
+0x64622012
+0xed000800
+0x658eec00
+0xa2ea6408
+0x06864a8a
+0x009c16a0
+0x00040de0
+0x57c64446
+0x9012a120
+0xe4e08021
+0x983280ca
+0x86061832
+0x0010a254
+0x900b8120
+0x830a0353
+0xc4269812
+0x0080b3df
+0x0288d42a
+0xe6608000
+0x0280406a
+0x00140362
+0x01856162
+0x85070626
+0x04562312
+0x50260506
+0x0012a52a
+0xef0081c0
+0x2506e822
+0xe02a2c08
+0x18220012
+0xa42a1fa8
+0x00040028
+0x00008068
+0xe02a1fa8
+0xe9e08001
+0x02405e28
+0x020040e9
+0x00040c26
+0x00838120
+0x05060626
+0x258e0000
+0x24222000
+0xee800400
+0xd80a4446
+0x820c8606
+0x4c6e2586
+0x00002078
+0x00821808
+0x0080896c
+0x05282079
+0xd80a8204
+0xe8e28000
+0xe1122586
+0x20000516
+0xad022516
+0x01027309
+0x44284488
+0xd40a4446
+0x820c8606
+0xeee2801b
+0x45862506
+0x00861908
+0x40002c82
+0x00021708
+0x444604a8
+0x8606d00a
+0x2586820c
+0xeea28000
+0x2c6e4506
+0x04922000
+0x01033909
+0x44282508
+0xac0a4446
+0x820c8606
+0x14822506
+0xef628004
+0x00802c6e
+0x2000258e
+0x44461422
+0x0020a120
+0x00802616
+0x05296078
+0x0020a120
+0x05294378
+0xe0e00002
+0xa13a45e8
+0x0586818a
+0x58660586
+0x00802506
+0x05000378
+0x0010a120
+0x052d40f8
+0xe1e08000
+0x0188d428
+0x01804068
+0x02280fd8
+0x000c1362
+0xd5868507
+0x03381fda
+0x043c0fd8
+0xe2000000
+0x01810162
+0xc5772626
+0x6777c677
+0x2c6e71f7
+0x67f7d577
+0x008ca362
+0x857731f7
+0xebc00000
+0x66468cf7
+0x01c03e28
+0x018040e8
+0x0080b866
+0x000c81c6
+0x02402a2a
+0x0000602a
+0x020040ea
+0xe1200000
+0x1c09104d
+0x502d81fb
+0x824a45c6
+0x4c278c27
+0x016f4c6e
+0x01896162
+0x023c9059
+0xe3e08008
+0x02000fda
+0xa37a0246
+0x02405e28
+0x020040e9
+0x00042426
+0x00c28120
+0x85060626
+0xea408000
+0x04d2020c
+0x02405a2a
+0x020040ea
+0x04e8100d
+0xc05ba120
+0x023c805a
+0x009042e6
+0xe1220000
+0x8586103d
+0x52142c6e
+0x00806c55
+0xe83b1034
+0x0188b428
+0x01804068
+0x00000000
+0x000c1362
+0xe0e48000
+0x01818162
+0x0208c82a
+0x0200406a
+0x4e26026f
+0x002c0fd8
+0x01882162
+0x02008078
+0xe1000000
+0xa21c8586
+0xc822a812
+0x2c082c6e
+0x1012a2ea
+0x2c28c822
+0xd012e03a
+0x2468c822
+0xefe28000
+0xc070a120
+0x0208b42a
+0x0200406a
+0x0586026f
+0x01864162
+0x02008058
+0x0188c828
+0xe1000000
+0x01804068
+0x00803efc
+0x002c0fd8
+0x000c1362
+0x01856162
+0x02010058
+0xd3bbd80a
+0x0188b428
+0xe4008000
+0x01804068
+0x023c9058
+0x000c1362
+0x01848162
+0x0208c82a
+0x0200406a
+0x00100362
+0x01896162
+0x023d9058
+0x00bcc284
+0xc822a812
+0x2c082c6e
+0x1012a36a
+0x2c28c822
+0xd012ac3a
+0xef808000
+0x2468c822
+0xc020a120
+0x0188c828
+0x01804068
+0x023d1058
+0x000c1362
+0x01888162
+0xe0200000
+0x00808af7
+0x0208c82a
+0x0200406a
+0x00100362
+0x01856162
+0x023d5058
+0x00088120
+0x00bcc284
+0x00bcc284
+0x8586bc0d
+0x10044c6e
+0x003c82c6
+0x30046c6e
+0x003ca286
+0x92046c6e
+0x0090a254
+0xe5620000
+0x0204a358
+0x07800852
+0x71f7c577
+0xa1ef6c6e
+0x867731f7
+0xa6468577
+0x02406428
+0xe7800000
+0x020040e8
+0x6c6e000c
+0xd21dd8ba
+0x00006000
+0x5050a120
+0xd2bb10a7
+0x019202a6
+0x00800026
+0xe4c38000
+0x4c6e9013
+0xaaab6469
+0x6469b013
+0x202aa120
+0x02405228
+0x020040e8
+0x00c7000c
+0xe8e09000
+0x8403a43b
+0x000c007a
+0x0240502a
+0x02001078
+0x0090a124
+0x020040ea
+0x2c6e100d
+0xe8200000
+0xa6ba04e8
+0x02044ca2
+0x090a0241
+0x051020e4
+0x00006000
+0x0240502a
+0x020040ea
+0xe0a08010
+0x44cb100d
+0x02414c6e
+0x00000510
+0x051020e4
+0x00006000
+0x00148120
+0x0080b1a9
+0x0500a358
+0xe0600008
+0x6c6e400d
+0x05000fd8
+0x15070c6e
+0x20162120
+0x01c06c28
+0x018040e8
+0x001c81c6
+0xe8a02000
+0x060c0fd8
+0x00238120
+0x0204a358
+0x02406a28
+0x020040e8
+0x01100264
+0x0240682a
+0x020040ea
+0x7646100d
+0xa9aa2d08
+0x40000412
+0x00100274
+0x02c8102a
+0x0280406a
+0x640202ef
+0xe8e08000
+0x01824162
+0x90469047
+0x02469587
+0xa4aa0005
+0x02405e28
+0x00802cc7
+0x020040e9
+0x0004a426
+0xe9c08014
+0x0626858a
+0x020a8606
+0x6c6e001c
+0x4c6e000d
+0x02046ca0
+0x802e0686
+0x05060004
+0xede08404
+0x20048606
+0x000421a0
+0x26260004
+0xc677c577
+0x6c6e71f7
+0x008ca362
+0x367727f7
+0xeba00003
+0x31f79577
+0x86772777
+0xc6468577
+0x6756964e
+0x02405628
+0x020040e8
+0x10a6001c
+0xe9f00060
+0xd028a120
+0x02405228
+0x020040e8
+0xa4c6000c
+0x0080aa47
+0x44464c6e
+0x01dc8028
+0x01804068
+0xe3000000
+0x025f502a
+0x000c1362
+0x0200406a
+0x01854162
+0x02280fd8
+0xa63a0246
+0x00a80fd8
+0xe4008000
+0x0004dec0
+0x0037e1a1
+0x9aaa4446
+0x06b7e058
+0x000c8606
+0xa44e6c6e
+0xf83a1026
+0xee808800
+0x07c06228
+0x078040e8
+0x000c8786
+0x74470446
+0x0500a358
+0xe0aa0406
+0x00280fd8
+0xe5908040
+0x0000ef58
+0xd014a120
+0x4c1a0506
+0x00801b20
+0xe4a6bcc2
+0x010021e0
+0x00844f98
+0x000400f8
+0xe1800080
+0x000140f8
+0x05010058
+0x00288058
+0x003408f8
+0xc02aa120
+0x0288002a
+0x0280406a
+0x00140362
+0x0200102a
+0x01844162
+0x0727d246
+0x023941e0
+0x00900fd8
+0x90a08120
+0x01b94078
+0xe0800030
+0x00290058
+0x003408f8
+0x0246a9aa
+0x00059787
+0x04c67647
+0x0288002a
+0x0280406a
+0xe38081a0
+0x023302ef
+0x01844162
+0x00800fa3
+0x020c81a1
+0x03101fd8
+0x96474246
+0x02406e28
+0x020040e9
+0xe2200300
+0x00243586
+0x05290059
+0xaa8a4482
+0x100d9587
+0x26860506
+0x0c6e2800
+0x10051001
+0xefa08002
+0x860e0506
+0xd80a0004
+0x100d9587
+0x26860506
+0x0c6e2800
+0x10051001
+0x860e0506
+0xefe09001
+0xd40a0004
+0x02406e28
+0x020040e9
+0x44822406
+0x06100266
+0x0129a0f8
+0xa53a4c88
+0xe9208080
+0x8dfa0146
+0x0080b0dc
+0xa20a5547
+0x8dfa00c6
+0x05041fda
+0x02da002a
+0x0280406a
+0x00140362
+0xe0e08000
+0x00394078
+0x02301fd8
+0x01842162
+0xd5069047
+0xa42a0246
+0x06268c4a
+0x0c6e0c6e
+0xef009840
+0x02406e2b
+0x00a81fd8
+0x020040eb
+0x00303078
+0x87860005
+0x5506000c
+0xdcc22d1a
+0xee000400
+0x44a22110
+0x00040880
+0x040572f9
+0x0c6e7447
+0x05295078
+0x00354af8
+0xcf4aa120
+0xe1600000
+0x00803a26
+0xc5772626
+0x6777c677
+0x0c6e71f7
+0x7677d577
+0xa1ef67f7
+0x967727f7
+0x31f79577
+0xefe00000
+0x86772777
+0xccf78577
+0x0c6e6646
+0x700d9587
+0x0427d446
+0xbc05dc05
+0x02403e28
+0xe7f00000
+0x020040e8
+0x0453000c
+0x1c094c6e
+0x630aa2bb
+0x64478c27
+0x64474c27
+0x6c6e900d
+0xefc08000
+0x06000fda
+0x0500a358
+0x06406428
+0x060040e8
+0x000c8606
+0x180daeba
+0x303aa120
+0x00806843
+0xe6108000
+0x02402a28
+0x020040e8
+0x6c6e004c
+0xc04da00c
+0x2c6e9507
+0x00001362
+0x01888162
+0xe3800000
+0xa42a0246
+0x020edc2a
+0x0200406a
+0x00100362
+0x01866162
+0x023d9058
+0xa6aa0246
+0xe8208000
+0x02405e28
+0x020040e9
+0x00042426
+0x01fc8120
+0x02280fd8
+0x0252e02a
+0x0200406a
+0xe0800000
+0x0212026f
+0x01834162
+0x0211ce88
+0x0686a646
+0xc016a120
+0x02405e28
+0x0080ad4d
+0x020040e9
+0xe1200000
+0x0004a426
+0x01dc8120
+0x02280fd8
+0x07a80fd8
+0xc8230013
+0xd86f8c01
+0x0c670786
+0xee200800
+0x1c670e04
+0x1606e446
+0xd1c0a120
+0x0500a35a
+0x6c6ebc1d
+0xa73b10a7
+0x0686dc0d
+0xee608000
+0x2c6e8686
+0xec811050
+0x0ee7d86f
+0xbc0d0e8c
+0x0e044c6e
+0x20471ce6
+0x900d9587
+0xefe00000
+0x4c6e4507
+0x00130921
+0x4c49c823
+0x0012a2eb
+0x0c6ec822
+0x00801f4a
+0xdc255047
+0xd43bb00d
+0xeff08004
+0x01c02a28
+0x018040e8
+0x004c81c6
+0x01014507
+0xb5c72001
+0x0627a00c
+0x2c6e9046
+0xef800000
+0x00001362
+0x01828162
+0xa62a0246
+0x004c9686
+0xbc2dbc1d
+0x0686dc0d
+0x6c6e401c
+0xef808000
+0x00041362
+0x01836162
+0x08c11140
+0xa77a0246
+0x02405e2a
+0x020040eb
+0x10052427
+0xe9808010
+0x01cc3028
+0x01804068
+0x02340fd8
+0x000c1362
+0x00808a2a
+0x01858162
+0x016c8120
+0xdc2d0626
+0xe8000000
+0xbc050427
+0xc8230013
+0xa53b4c49
+0x11400686
+0xc8230013
+0xd86f0901
+0x2c6e0786
+0xefe08000
+0x0e040c66
+0xe4461c67
+0x000c8606
+0xf03a6c6e
+0x181d9587
+0x0c6e6c6e
+0x002839fa
+0xe7e08000
+0x30b02120
+0x4c6edc1d
+0x01bc62e6
+0x0038307a
+0x6c494c6e
+0x30b0a120
+0x013872f8
+0xe2400000
+0x01896828
+0x01804068
+0x013d6286
+0x0080b490
+0x000c1362
+0x01866162
+0x02081fd8
+0x01900fd8
+0x0209f22a
+0x0200406a
+0x00100362
+0x01846162
+0x02081fd8
+0xa33a6e28
+0x01c6834a
+0x64220246
+0xee008000
+0x0c6e4000
+0xdc6b3c09
+0x028a042a
+0x0280406b
+0x02405c28
+0x020040e9
+0x006c02ef
+0xe8608000
+0x00344078
+0x01842162
+0x023d9059
+0x02001fda
+0xa66a0246
+0x01cc3028
+0x01804068
+0xe2008000
+0x02340fd8
+0x000c1362
+0x00804950
+0x01838162
+0x00ec8120
+0x95870626
+0x6c6e181d
+0x002839fa
+0xe6000000
+0x3f9b8120
+0x05282058
+0x02402a28
+0x020040e8
+0xd00d004c
+0x02281fda
+0x00ac8802
+0xe2000000
+0xa00c0627
+0x00001362
+0x0000207a
+0x01854162
+0x02001fd8
+0xa72a0246
+0x020edc2a
+0xe4308000
+0x0200406a
+0x00100362
+0x01846162
+0x023d9058
+0x00100fd8
+0xcfbca120
+0x02405e2a
+0x020040eb
+0x10052427
+0x0080cd35
+0x01cc3028
+0x01804068
+0x02340fd8
+0x000c1362
+0x01868162
+0x00ac8120
+0xe0200000
+0x01460626
+0xbcc24c1a
+0xe0922030
+0x00846f98
+0x48000880
+0x38010c6e
+0xcc05bc05
+0xeee00010
+0x580d9587
+0xaebb7803
+0x01dc8028
+0x01804068
+0x025f52aa
+0x000c1362
+0x0200406a
+0xe0708000
+0x01824162
+0x022c0fd8
+0xa6aa0246
+0x01907c28
+0x01804068
+0x02340fd8
+0x000c1362
+0xe0808000
+0x00807493
+0x023d005a
+0x033c9058
+0x01834162
+0xaeba0246
+0x0050a120
+0x02405c29
+0x0240502a
+0xe1008000
+0x00000613
+0x020040e8
+0x020040eb
+0x104d105c
+0x2c6ecc6d
+0x02405c28
+0x0240502b
+0xe3000000
+0x020040e8
+0x020040eb
+0x104d105c
+0x2c6ecc6d
+0x01da0028
+0x01804069
+0x3707b40d
+0xe9800000
+0x000c1362
+0x01842162
+0x96872001
+0x02001fd8
+0xa82a0246
+0x02405e2a
+0x020040eb
+0x0080c955
+0xe2808000
+0x1005e427
+0x01cc3028
+0x01804068
+0x02340fd8
+0x000c1362
+0x01868162
+0x06268b0a
+0xe8208000
+0x3707dc0d
+0x00914c6e
+0xd4c60c6e
+0x0528007a
+0x250f0607
+0x00002bfa
+0x2e58a120
+0xe2e00100
+0x01cc3028
+0x01804068
+0x02340fd8
+0x000c1362
+0x01858162
+0x0204a358
+0x07800c52
+0x053c33e4
+0x6777c677
+0x0c6e71f7
+0xd677d577
+0xa1ef67f7
+0x31f727f7
+0x86772777
+0x0080dd0a
+0xd6468577
+0xefe00000
+0x774e4746
+0x019008f0
+0x07c02a28
+0x078040e8
+0x004c8786
+0x4c6e0627
+0x81c6a00c
+0xee200003
+0x00004000
+0x00001362
+0x01838162
+0xa4fa0246
+0x02405e28
+0x020040e9
+0x00042426
+0xe9008000
+0x00b88120
+0x17070626
+0xaf3b1027
+0x00280fd8
+0x06380fd8
+0x06830058
+0x004c8786
+0xe8c08000
+0x4c6ec627
+0x00904264
+0x02350058
+0x06b50058
+0x00002000
+0x0080df20
+0x00041362
+0x01888162
+0xe0200000
+0xa12a0246
+0x0426814a
+0x00265c26
+0xec10f866
+0x0033e058
+0x9b2a2408
+0x0633e058
+0xe5e08000
+0x800ca120
+0x02405e28
+0x020040e9
+0x00042426
+0x00888120
+0x0200a358
+0x03405a28
+0xe1000000
+0x030040e8
+0x00180264
+0x02c05228
+0x028040e8
+0x0c6e009c
+0xc02aa120
+0x0c6e0586
+0xea000000
+0xa402940b
+0x20001000
+0x0180a124
+0x45e86c6e
+0x00808155
+0xd067a120
+0x03c05028
+0x038040e8
+0xe1600000
+0xe586018c
+0x00004000
+0x0000fc40
+0x00002064
+0xd5fa6c6e
+0x10271707
+0x3707d5fb
+0xee208000
+0xa6ba010c
+0x0208c82a
+0x0200406a
+0x00100362
+0x01866162
+0x02288058
+0x0188b428
+0xe0308000
+0x01804068
+0x02280fd8
+0x000c1362
+0x01848162
+0x001c82c6
+0x438ce506
+0xacba6c6e
+0xee028000
+0x002c0fd8
+0x0240502a
+0xa402940b
+0x0080d11d
+0x20001000
+0x0180a124
+0x020040ea
+0x2c6e100d
+0xe9800000
+0xa12a45e8
+0x0426828a
+0xf04e0586
+0x001c1c40
+0x00002064
+0x01ace506
+0x01006c6e
+0xece08010
+0x001c0274
+0x05290058
+0x902bec81
+0x2626ec91
+0xc677c577
+0x71f76777
+0x67f74c6e
+0xef808000
+0x008ca362
+0x967727f7
+0x31f79577
+0x86772777
+0xccf78577
+0x02405a2a
+0x020040ea
+0xe3c00000
+0xbc450426
+0x001002f4
+0x008029be
+0x0240642a
+0x020040eb
+0x10051047
+0x023c42f6
+0x05c02a28
+0xe2200001
+0x058040e8
+0x004c8586
+0x4c6e8047
+0x9046a00c
+0x00004000
+0x00001362
+0x01888162
+0xe1c00000
+0xa62a0246
+0x004c8586
+0x06c03228
+0x068040e8
+0x02000b2a
+0x052c0fd8
+0x8686400c
+0xe8608000
+0x00004000
+0x00001362
+0x01838162
+0xa4fa0246
+0x02405e28
+0x020040e9
+0x00042426
+0xe9008000
+0x04b68120
+0x0080d0f5
+0xa6860626
+0x0452029c
+0x24684c6e
+0x2452e3aa
+0xe3aa2468
+0x24684452
+0xefc28000
+0x3c12dfaa
+0xdfaa2468
+0x0208c82a
+0x0200406a
+0x00100362
+0x01886162
+0x02140fd8
+0xe0608000
+0x0452021c
+0x24684c6e
+0x2452a66a
+0xa66a2468
+0x24684452
+0x3c12a66a
+0xa66a2468
+0xefe28000
+0x02405e28
+0x020040e9
+0x00044426
+0x04868120
+0xbc4d0626
+0x4c6e2427
+0x001002f6
+0xe6800000
+0x008040bd
+0x0188c828
+0x01804068
+0x02144058
+0x000c1362
+0x01858162
+0x0188b428
+0x01804068
+0x02148058
+0x000c1362
+0x01828162
+0x0208b42a
+0x0200406a
+0x00100362
+0x01876162
+0x02150058
+0x0188b428
+0x01804068
+0x0230a358
+0x000c1362
+0x01856162
+0x02148078
+0x0188c828
+0x01804068
+0x02000828
+0x000c1362
+0x01836162
+0x0210a078
+0x0208c82a
+0x0200406a
+0x5212026f
+0x01894162
+0x0080887b
+0xe4000000
+0x0210a078
+0x0188c828
+0x01804068
+0x02000a28
+0x000c1362
+0x01876162
+0x0210a078
+0x00000928
+0xa00aa040
+0x020cec05
+0x0240582a
+0x020040ea
+0xd0022c6e
+0x001002f4
+0x0240662a
+0xe2620001
+0x020040ea
+0x6c6e101d
+0x0007ea5a
+0x3469a6ab
+0x2015a120
+0x02405e28
+0x020040e9
+0xe1408000
+0x00042c26
+0x04068120
+0x82c60626
+0x121c040a
+0x4c6e2453
+0x121c82c6
+0x0080f2c4
+0x4c6e2453
+0xefa28020
+0xa16b2469
+0x24694453
+0xec0da93b
+0x4c6e3c92
+0x020c4440
+0x04e86c6e
+0xc01aa120
+0xe7e28000
+0x02405e28
+0x020040e9
+0x00044426
+0x03e68120
+0x0200a358
+0x02403e2a
+0x020040eb
+0xe0800000
+0x100500c7
+0x000ba120
+0x02403e2a
+0x0000602a
+0x020040ea
+0xec0d1005
+0x4c6e9892
+0xec200000
+0x020ccc40
+0x0703c058
+0x04e86c6e
+0x04d3e8ba
+0x85060ca9
+0x00808c82
+0x30138121
+0xb01c004c
+0xeba28102
+0x00058120
+0x9212d212
+0x00ef4c6e
+0x01856162
+0x0200a35a
+0x004c8586
+0x124d9707
+0xecc20000
+0x06404028
+0x060040e8
+0x8606400c
+0x00004000
+0x00001362
+0x01868162
+0xa67a0246
+0xe8808000
+0x02405e28
+0x020040e9
+0x00042426
+0x03968120
+0xbc4d0626
+0xd9bb100d
+0x0188c828
+0xe6908000
+0x01804068
+0x02300fd8
+0x000c1362
+0x01848162
+0x0080e27c
+0x02b00fd8
+0x0188c828
+0x01804068
+0x02144058
+0x000c1362
+0x01828162
+0x0188b428
+0x01804068
+0x02148058
+0x000c1362
+0x01878162
+0x0208b42a
+0x0200406a
+0x00100362
+0x01846162
+0x02150058
+0x0188b428
+0x01804068
+0x0230a358
+0x000c1362
+0x01826162
+0x02148078
+0x0188b428
+0x01804068
+0x02000828
+0x000c1362
+0x01886162
+0x0210a078
+0x0188b428
+0x01804068
+0x02000a28
+0x008038fb
+0x000c1362
+0x01866162
+0x0210a078
+0x0208b42a
+0x0200406a
+0x1a12026f
+0x01834162
+0x0210a078
+0x06061212
+0x000c0240
+0x02404e2a
+0x020040ea
+0xe3200040
+0x00052c6e
+0x06405228
+0x060040e8
+0x000c8606
+0xa6ba6c6e
+0x024c302a
+0x0200406a
+0xe3208000
+0x004c026f
+0x01834162
+0x07b00fd8
+0x00128786
+0x00100274
+0x01c05428
+0x018040e8
+0xe1200040
+0x000c81c6
+0x4c6eb5c7
+0x0080b886
+0xd015a120
+0x024c302a
+0x0200406a
+0x004c026f
+0x01894162
+0xe4600000
+0x078c0fd8
+0x00128786
+0x06860004
+0x020c4440
+0x0252e02a
+0x0200406a
+0x00100362
+0xe1c20084
+0x06c05628
+0x068040e8
+0xa41a940b
+0x00048686
+0x01860163
+0x02003078
+0x00100fd8
+0xe18000a0
+0xc0000690
+0x01c03e28
+0x018040e8
+0x001c81c6
+0x95878606
+0x75c70004
+0x021002e6
+0xe7000d80
+0x02405e28
+0x00801bd1
+0x020040e9
+0x0004a426
+0x02c68120
+0x0200a358
+0x04532c6e
+0xa4fb1c89
+0xec808000
+0x00048120
+0x9012d012
+0x8706b00d
+0x0627021c
+0x006f0c6e
+0x01886162
+0x02002078
+0xe3c20000
+0x95867586
+0x001c8cb5
+0xbcc59607
+0x9687103d
+0x07b40fd9
+0x4552102d
+0x056810e2
+0xede0004a
+0x2568d6ea
+0x818aa17a
+0x08321032
+0x0252e02a
+0x0200406a
+0x00100362
+0x02081800
+0xe0e08000
+0x008083d7
+0x01816162
+0x64ea0246
+0x96869587
+0x0004104d
+0x02405e28
+0x020040e9
+0x0004a426
+0xe9c08050
+0x02768120
+0x95860626
+0x44d2000c
+0x04e84c6e
+0x08b2843a
+0x1032448a
+0x10470c6e
+0xefc08000
+0x10c70c6e
+0x109db787
+0x96861063
+0x02100264
+0x053c0fd8
+0x02002803
+0x6c6e500d
+0xe8e00000
+0x00000362
+0x01828162
+0xa2aa0246
+0x840a9507
+0x00c6001d
+0x001d9507
+0x4c6e0426
+0x0080f5e1
+0xef808080
+0xaf2a04e8
+0x02405e28
+0x020040e9
+0x00042426
+0x02468120
+0x44520626
+0x850e2468
+0xed209000
+0x004c81fa
+0x424a501c
+0x0c6e1032
+0x08331047
+0x00ef4c6e
+0x0002100a
+0x02004802
+0xe3e08001
+0x020c1fd8
+0x01822162
+0xa2aa0246
+0x840a8686
+0x00c6001c
+0x001c8686
+0x4c6e0426
+0xef808080
+0xa32a04e8
+0x02405e28
+0x020040e9
+0x00042426
+0x02168120
+0x0200a358
+0x0080fe65
+0x01c05028
+0xe1208000
+0x018040e8
+0x000c81c6
+0x4c6eccb5
+0xd014a120
+0x024c302a
+0x0200406a
+0x004c026f
+0xe8c00000
+0x01816162
+0x001c8686
+0x0252e02a
+0x0200406a
+0x00100362
+0x01886162
+0x02044ca0
+0xe0400000
+0xccbd0246
+0x81c6646a
+0x55c70004
+0x02405e28
+0x020040e9
+0x0004a426
+0x01e68120
+0xe4e08011
+0x87860626
+0x1026000c
+0xd17aa120
+0x0700a359
+0x06000028
+0x0080a17d
+0x05b80fd8
+0x100dbccd
+0xe8700000
+0x0501d078
+0x019cf586
+0x4c6e4452
+0xa2fa2468
+0x1032634a
+0x08324046
+0x96864046
+0xefc08000
+0x00100264
+0x01096800
+0x01004c6e
+0x94470c6e
+0x6c6ebc4d
+0x6c6e100d
+0x10e2fe7b
+0xef808000
+0x04e844d2
+0x9507df3a
+0xa4ab100d
+0x0188b428
+0x01804068
+0x02288058
+0x000c1362
+0xe0f08000
+0x01818162
+0x02a80fd8
+0x0188b428
+0x01804068
+0x0080b6cf
+0x02150058
+0x000c1362
+0x01878162
+0x0208b42a
+0x0200406a
+0x00100362
+0x01846162
+0x02158058
+0x0188b428
+0x01804068
+0x02160940
+0x000c1362
+0x01818162
+0x0188b428
+0x01804068
+0x02168940
+0x000c1362
+0x01868162
+0x0188b428
+0x01804068
+0x02170940
+0x000c1362
+0x01838162
+0x0208b42a
+0x0200406a
+0x00100362
+0x01886162
+0x02178940
+0x0188b428
+0x01804068
+0x02149ec0
+0x00808db7
+0x000c1362
+0x01858162
+0x0188b428
+0x01804068
+0x02153d40
+0x000c1362
+0x01828162
+0x0208b42a
+0x0200406a
+0x00100362
+0x01876162
+0x0214bec0
+0x0188c828
+0x01804068
+0x0216fb40
+0x000c1362
+0x01848162
+0x001c83c6
+0x0079a120
+0x0208b42a
+0xe2000000
+0x0200406a
+0x00100362
+0x01846162
+0x02311058
+0x0188b428
+0x01804068
+0x02319058
+0x000c1362
+0x01818162
+0x0188b428
+0x00802fe9
+0x01804068
+0x00301fd8
+0x000c1362
+0x01876162
+0x02020940
+0x0188b428
+0x01804068
+0x00301fd8
+0x000c1362
+0x01856162
+0x02028940
+0x0208b42a
+0x0200406a
+0x00100362
+0x00301fd8
+0x01834162
+0x02030940
+0x0188b428
+0x01804068
+0x00301fd8
+0x000c1362
+0x01896162
+0x02038940
+0x0188c828
+0x01804068
+0x00301fd8
+0x000c1362
+0x01876162
+0x02009ec0
+0x0208c82a
+0x0200406a
+0x008085a2
+0x1606026f
+0x01844162
+0x02023b40
+0x0188c828
+0x01804068
+0x00301fd8
+0xe0400000
+0x000c1362
+0x01836162
+0x02013d40
+0x001c9586
+0x10e26c6e
+0x04e844d2
+0x9506a6ba
+0xef008000
+0x00100264
+0x00464120
+0x260e8786
+0x000c2040
+0x00000000
+0x02daf02a
+0x0280406a
+0xe1800050
+0x00140362
+0x01846162
+0x86078506
+0x03000428
+0x500c9606
+0x4c6e9507
+0x700c5005
+0xee800030
+0x00802bf4
+0x70056c6e
+0x9005900c
+0xb005b00c
+0xc005c00c
+0xf005f00c
+0x00120204
+0x001102f4
+0xe3f00000
+0x00122204
+0x28056c6e
+0x00124204
+0x48056c6e
+0x002c9506
+0xb606e232
+0x8786869c
+0xef400600
+0x2c6e000c
+0x0092e2d5
+0x02098078
+0x001404a6
+0x00ac2058
+0x57070ca8
+0xcfffab10
+0xe5200800
+0x10333607
+0x000481a3
+0x0088007a
+0x05ac2058
+0x9446d4c6
+0x01d63028
+0x01804068
+0x00807c6d
+0xe2200001
+0x00000000
+0x000c1362
+0x01838162
+0xa4ea0246
+0x02405e28
+0x020040e9
+0x0004c426
+0xe9008000
+0x00468120
+0x86860626
+0x6c6e001c
+0xa77a10a6
+0x9506cc5d
+0x068413a3
+0x2c6e004c
+0xebc08000
+0x0ce6008c
+0x6c6e1c1c
+0x0c6e00a7
+0x00803dd8
+0x24289ce7
+0x2046648a
+0xdc4d0094
+0xeee08100
+0x001d6c6e
+0x03c02c28
+0x038040e8
+0x6c6e018c
+0xdc4da42a
+0x04a60427
+0x0080b6eb
+0x10052c6e
+0xef208000
+0x08a6ec7d
+0x00042dd8
+0x03ac2c6e
+0x44086c6e
+0xd015a120
+0x02405e28
+0x020040e9
+0xe1a20000
+0x00046426
+0x00068120
+0x26260626
+0x07800c52
+0xc677c577
+0x71f76777
+0xd5770c6e
+0xeea00000
+0x67f7d677
+0x008ca362
+0x357727f7
+0x277731f7
+0x85778677
+0x02402c28
+0x020040e8
+0xe3a00000
+0x6c6e000c
+0xc008a120
+0x01498120
+0x0204a358
+0x0240562a
+0x00807a34
+0x020040ea
+0x9646102d
+0xe8200000
+0x24260c6e
+0x1127a446
+0x30caa120
+0x07c05c28
+0x078040e8
+0x00128786
+0x05260004
+0xec601400
+0x01c05228
+0x018040e8
+0x001c81c6
+0x950bb51b
+0x65c60081
+0x07003078
+0xb70710c1
+0xeb800000
+0x6c6e108d
+0x490aa32b
+0x02c03028
+0x028040e8
+0x05140267
+0x021022e4
+0x02daf02a
+0xe0608000
+0x0280406a
+0x00140362
+0x02402428
+0x01864162
+0x0080dfb0
+0x020040e9
+0x0f269707
+0x0240302a
+0xe4000400
+0x020040ea
+0x051002e6
+0x02381fda
+0x051142e4
+0x4c6e0033
+0x04893507
+0x3047a120
+0xe6000000
+0x01dc8028
+0x01804068
+0x02ac0fd8
+0x000c1362
+0x05940264
+0x025f562a
+0x0200406a
+0x01882162
+0xa9ea0246
+0x001c8786
+0x0240502a
+0x02c04e28
+0x020040ea
+0x028040e8
+0x00049ca2
+0xe0608000
+0x0004aca0
+0x00001078
+0x02016078
+0x008025d8
+0x400c602c
+0x4c6e100d
+0x846a0568
+0x84ca00ac
+0xef008000
+0x90460426
+0x82c6240c
+0x40004c6e
+0x97070004
+0x6c6eb00d
+0x1506a86b
+0xd037a120
+0xe7e08000
+0x01dc8028
+0x01804068
+0x025f502a
+0x000c1362
+0x0200406a
+0x01874162
+0x02380fd8
+0x00100fd8
+0x9707a5ea
+0xa5fb900d
+0x70133507
+0xa5eb0489
+0x02119a2a
+0x0200406a
+0x00100362
+0xe1f08010
+0x01826162
+0x02380fd8
+0x00807039
+0x06080686
+0x8786a446
+0x6c6e000c
+0x00242420
+0x102d9607
+0xef800000
+0x00b40a58
+0x00042dd8
+0x5d292c6e
+0x00001f7a
+0x2f50a120
+0x07405c28
+0x070040e8
+0xe0800000
+0x00128706
+0x06860004
+0x11270026
+0x02003dda
+0x44094247
+0x30688120
+0x04265646
+0xeae00001
+0x02405228
+0x020040e8
+0xb41b001c
+0x0081940b
+0x00000000
+0x05803078
+0x000c8586
+0xe9800000
+0xa4ba6c6e
+0x00809c2b
+0x02daf02a
+0x0280406a
+0x00140362
+0x02402428
+0x01894162
+0x020040e9
+0xe0208000
+0x0f269587
+0x480c8586
+0xaaba7802
+0x01dc8028
+0x01804068
+0x025f52aa
+0x000c1362
+0xe0f08001
+0x0200406a
+0x01826162
+0xa6aa0246
+0x02119a2a
+0x0200406a
+0x00100362
+0x01896162
+0xe0808000
+0x022c0fd8
+0x06080686
+0xa4460826
+0x02043dda
+0x56460c6e
+0x000c8706
+0x00042400
+0xeed00000
+0x008093f6
+0x100d9607
+0x4c6e5507
+0x44091c29
+0x2fb0a120
+0xc5778686
+0x6777c677
+0x2c6e71f7
+0xeee00000
+0x67f77577
+0x008ca362
+0x857731f7
+0x02405e2a
+0x020040eb
+0x10050427
+0x0194e228
+0xe4a00000
+0x01804068
+0x00000000
+0x000c1362
+0x01848162
+0xa6ba0246
+0x0199f428
+0x01804068
+0xe2008000
+0x00000000
+0x000c1362
+0x01838162
+0xa2ba0246
+0x242782ca
+0x0c6e0427
+0x05801fd8
+0x008053eb
+0xe7008000
+0x05406828
+0x050040e8
+0x000c8506
+0xa4ba6c6e
+0x024c302a
+0x0200406a
+0x004c026f
+0xe9808000
+0x01816162
+0x00128506
+0x15870004
+0xa26b2027
+0xc577fc26
+0x71f78046
+0xa1ef6c6e
+0xefc08204
+0x00111808
+0x00010ca0
+0x001319a2
+0x00121809
+0x14021429
+0x01131ca2
+0x15281428
+0xea000200
+0xa1ef8046
+0x042731f7
+0xbc0dbc05
+0x001069a0
+0x1c494c6e
+0x3024a120
+0x00807794
+0x904f2527
+0xeae01000
+0x6683e000
+0x00010000
+0x00000000
+0x603c22e4
+0xac152410
+0x6e59bc3d
+0x2c6e40c7
+0xee100000
+0x00000000
+0x00034000
+0xa1ef71f7
+0x01bc54f6
+0x053c22f4
+0x05100fd8
+0x01d58a28
+0xe0900000
+0x01804068
+0x0228a358
+0x000c1362
+0x01848162
+0x019bb228
+0x01804068
+0x02000ca8
+0x000c1362
+0x01818162
+0x0255a02a
+0x0200406a
+0x00100362
+0x01866162
+0x008085eb
+0x02007fa8
+0x01d50028
+0x01804068
+0x02280fd8
+0x000c1362
+0x01838162
+0x019bb228
+0x01804068
+0x02000ca8
+0x000c1362
+0x01888162
+0x0255142a
+0x0200406a
+0x00100362
+0x01856162
+0x0228a358
+0x019bb228
+0x01804068
+0x02000ca8
+0x000c1362
+0x01828162
+0x053c22e4
+0x6c6e71f7
+0x008ca362
+0x01bc54f6
+0x021bb22a
+0xe1000000
+0x0200406a
+0x00100362
+0x02435028
+0x01854162
+0x00806488
+0x020000e8
+0xa1ef71f7
+0x01bc54f6
+0xe4100000
+0x053c22f4
+0x05100fd8
+0x01d54228
+0x01804068
+0x0204a358
+0x000c1362
+0x01878162
+0x01d58a28
+0x01804068
+0x0230a358
+0x000c1362
+0x01848162
+0x019bb228
+0x01804068
+0x02000ca8
+0x000c1362
+0x01818162
+0x02556c2a
+0x0200406a
+0x00100362
+0x01858162
+0x850e0246
+0x00100234
+0xe4000400
+0x01d51428
+0x01804068
+0x0230a358
+0x00804960
+0x000c1362
+0x01858162
+0x019bb228
+0x01804068
+0x02000ca8
+0x000c1362
+0x01828162
+0x0255422a
+0x0200406a
+0x00100362
+0x01876162
+0x0200a358
+0x019bb228
+0x01804068
+0x02000ca8
+0x000c1362
+0x01848162
+0x053c22e4
+0x6c6e71f7
+0x008ca362
+0xe4000000
+0x857731f7
+0x024e5646
+0x6446a6ba
+0x019c3c28
+0x01804068
+0x02280fd8
+0x000c1362
+0xe0e08004
+0x01818162
+0x05282058
+0x008029b1
+0x002fe058
+0xcff68120
+0x05afe058
+0xc5770626
+0x6c6e71f7
+0xec000000
+0x008ca362
+0x01bc54f6
+0x01d52828
+0x01804068
+0x0220a358
+0x000c1362
+0x0200a35a
+0x01886162
+0x01d52828
+0x01804068
+0x0234a358
+0x000c1362
+0x0200a35a
+0x01866162
+0x02d5282a
+0x0280406a
+0x00140362
+0x01836162
+0x06274e26
+0x01d52828
+0x01804068
+0x0224a358
+0x000c1362
+0xe0800010
+0x0200a35a
+0x00807666
+0x01826162
+0x01d52828
+0x01804068
+0x0230a358
+0x000c1362
+0x0200a35a
+0x01886162
+0x01d54228
+0x01804068
+0x0200a358
+0x000c1362
+0x01858162
+0x0255142a
+0x0200406a
+0x00100362
+0x01826162
+0x0234a358
+0x01d58a28
+0x01804068
+0x0220a358
+0x000c1362
+0x01878162
+0x01d58a28
+0x01804068
+0x0224a358
+0x000c1362
+0x01848162
+0x0255142a
+0x0200406a
+0x00100362
+0x01896162
+0x00803850
+0x0228a358
+0x01d51428
+0x01804068
+0x0230a358
+0x000c1362
+0x01868162
+0xa1ef71f7
+0xe8100000
+0x01bc54f6
+0x053c22f4
+0x05100fd8
+0x01d51428
+0x01804068
+0x0220a358
+0x000c1362
+0x01888162
+0x021bd62a
+0x0200406a
+0x0506026f
+0x01854162
+0x02031808
+0x01d58a28
+0x01804068
+0xe0800000
+0x0220a358
+0x000c1362
+0x01838162
+0x053c22e4
+0x6c6e71f7
+0x008ca362
+0x01bc54f6
+0x008003a8
+0xe2000000
+0x053c22f4
+0x05100fd8
+0x01d51428
+0x01804068
+0x0224a358
+0x000c1362
+0x01878162
+0x021bd62a
+0x0200406a
+0x0506026f
+0x01844162
+0x02031808
+0x01d58a28
+0x01804068
+0x0224a358
+0xe0400000
+0x000c1362
+0x01828162
+0x053c22e4
+0x6c6e71f7
+0x008ca362
+0x357727f7
+0x277731f7
+0xed000000
+0x85778677
+0x4747e746
+0x564ec646
+0x05a008f0
+0xa42a0586
+0x01338120
+0x0080f386
+0x027e6aa8
+0xe2e08038
+0x01b64628
+0x018040e8
+0x004c81c6
+0xa5c62706
+0x800c2c6e
+0x2c486c6e
+0x600ca53a
+0xef808000
+0x4c6e1507
+0xa22b1c49
+0x01138120
+0x027e6a28
+0x019bb228
+0x01804068
+0x02007d28
+0xe0608000
+0x000c1362
+0x01828162
+0x02558a2a
+0x0200406a
+0x00100362
+0x01876162
+0x0234a358
+0x019bb228
+0x01804068
+0x02003ea8
+0x000c1362
+0x01848162
+0x004c8686
+0x00807474
+0x021d402a
+0x0200406a
+0xe2000000
+0x026f2ab2
+0x0210aa14
+0x01844162
+0x06340fd8
+0x004c8606
+0x47865507
+0x0c6e2706
+0xee200000
+0xe00c180c
+0x4c6e381c
+0x00080ce2
+0x00040ce1
+0x00883ce2
+0x00001078
+0x05041078
+0xe0600000
+0xa42a8a0c
+0x021ba02a
+0x0200406a
+0x00100362
+0x01866162
+0x02280fd8
+0x05100fd8
+0xe0338000
+0x019d6c28
+0x01804068
+0x00280fd8
+0x000c1362
+0x00804093
+0x01866162
+0x02031808
+0x021bb22a
+0x0200406a
+0x00100362
+0x01836162
+0x02000ca8
+0x004c8686
+0xb0a7b01c
+0x3028a120
+0x019d6c28
+0xe3100000
+0x01804068
+0x00280fd8
+0x000c1362
+0x01856162
+0x02029c08
+0x021bb22a
+0x0200406a
+0x00100362
+0x01826162
+0x02000ca8
+0x004c8686
+0x0090a266
+0x00044bda
+0x3028a120
+0x019d6c28
+0xe0900000
+0x01804068
+0x00280fd8
+0x000c1362
+0x00805eb7
+0x01856162
+0x02011808
+0x021bb22a
+0x0200406a
+0x00100362
+0x01826162
+0x02000ca8
+0x004c8606
+0x0090a266
+0x00046bda
+0x3026a120
+0x021d6c2a
+0xe0900000
+0x0200406a
+0x0506026f
+0x01844162
+0x020309a0
+0x019bb228
+0x01804068
+0x02000ca8
+0xe0400000
+0x000c1362
+0x01828162
+0x004c8686
+0x0012c244
+0xa5ba2026
+0x021d402a
+0x0200406a
+0xe2908000
+0x4ab2026f
+0x0210aa14
+0x0080dc0d
+0x01836162
+0x019c2a28
+0x01804068
+0x00000000
+0x000c1362
+0xe0200001
+0x01818162
+0x019ca028
+0x01804068
+0x02281fd8
+0x000c1362
+0x022c1fda
+0x01876162
+0x0255142a
+0x0200406a
+0x00100362
+0x01846162
+0x0234a358
+0x019bb228
+0x01804068
+0x02003ea8
+0x000c1362
+0x01818162
+0xc5770626
+0x6777c677
+0x2c6e71f7
+0x67f77577
+0x008ca362
+0x31f727f7
+0xebc00000
+0x86772777
+0x00806a89
+0x053c35c4
+0x07bf005a
+0xa24e8746
+0x01b64628
+0x018040e8
+0x004c81c6
+0xe9200040
+0x029d9a2a
+0x0280406a
+0x45c60726
+0x400c201c
+0x04300fd8
+0x82c602ef
+0x018a0162
+0xe5800000
+0x0c6e0080
+0x03001fda
+0xda2a5226
+0x005c8506
+0x0c42208c
+0xd064a120
+0x06b00fd8
+0xe3b08000
+0x6426c446
+0x01b806a0
+0x030c0570
+0x01b40fd8
+0x01ff8050
+0x068c0fd8
+0x05986058
+0xe0200002
+0x0080a6d7
+0x004c8506
+0x400c6c6e
+0x4c6e201c
+0x002c00f8
+0x00002078
+0x00018078
+0x07806058
+0xe0e00000
+0x01c49028
+0x01804068
+0x00008028
+0x000c1362
+0x01876162
+0x02340079
+0x023d005a
+0x02c3502a
+0x0280406a
+0x00140362
+0x00008028
+0x01874162
+0x02340079
+0x033d11a1
+0x023c1fda
+0x00100a58
+0xec10f866
+0x003be058
+0x542a2408
+0x01b40fd8
+0x01808050
+0x073be1a1
+0x05afa059
+0x0080aff6
+0xe0a08000
+0x068c08f0
+0x9006a120
+0x0626820a
+0x027e69a8
+0x07bd005a
+0xc677c577
+0x71f76777
+0xec808000
+0x67f74c6e
+0x008ca362
+0x01bc54f6
+0x053c22f4
+0x05364628
+0x050040e8
+0x00c4a506
+0xe8200000
+0x6c6ea00c
+0x00008bd8
+0xd00aa120
+0x00528120
+0x027e6b28
+0x019cc228
+0x01804068
+0xe0200000
+0x00000000
+0x000c1362
+0x01838162
+0x019bb228
+0x01804068
+0x02007d28
+0x0080ced0
+0x000c1362
+0x01888162
+0x004c8506
+0x4c6e0ab2
+0x6c6ea60c
+0x05000fd8
+0x02558a2a
+0x0200406a
+0x00100362
+0xe0e00000
+0x01826162
+0x0234a358
+0x019d4028
+0x01804068
+0x02280fd8
+0x000c1362
+0x01878162
+0x01d51428
+0x01804068
+0x0234a358
+0x000c1362
+0x01848162
+0x021c2a2a
+0x0200406a
+0x00100362
+0x01888162
+0x0200a358
+0x053c22e4
+0x01bc52e6
+0x00006000
+0x008ca362
+0x008092dd
+0x0200a358
+0x008ca362
+0x00000000
+0x01bc94f6
+0x053c62f4
+0x023f842a
+0x020040eb
+0x02052426
+0xc4272205
+0x00135205
+0xee000000
+0x30051823
+0x02b0022a
+0x028040ea
+0x011403b6
+0xb28d929d
+0x82d19a93
+0x011403d6
+0xe6210000
+0xb2859295
+0x01bfd028
+0x05401a28
+0x01804068
+0x050040e8
+0x000c1363
+0x004c8506
+0xe8200000
+0x03001628
+0x01832162
+0x03190888
+0x200c8506
+0x0080fbc6
+0x20042400
+0x01d24c28
+0x01804068
+0xe3100000
+0x02104264
+0x000c1362
+0x01838162
+0x201c8506
+0x00006000
+0x0004c8d8
+0xd058a120
+0xe1000000
+0x01d29028
+0x01804068
+0x00003ea8
+0x000c1362
+0x0000aca0
+0x02040570
+0x021fe02a
+0x0200406a
+0x01810162
+0x84400506
+0x2004024e
+0xd73a5026
+0x01c17028
+0x01804068
+0x005cd02a
+0xe1c08008
+0x000c1362
+0x0000406a
+0x01844162
+0x00804bcb
+0x003c22f6
+0x01a3f028
+0x01804068
+0x00000000
+0x000c1362
+0x01818162
+0x01cfb228
+0x01804068
+0x00000000
+0x000c1362
+0x01868162
+0x0240b42a
+0x0200406a
+0x8506026f
+0x02100264
+0x01836162
+0x002ca120
+0x01c17028
+0x01804068
+0x005ce2a8
+0xe0200001
+0x000c1362
+0x00004068
+0x01844162
+0x003c22f4
+0x01a3f028
+0x01804068
+0x00000000
+0x000c1362
+0x01818162
+0x0240b42a
+0x0080adf4
+0x0200406a
+0x8506026f
+0x02100264
+0x01866162
+0x053c62e4
+0xe1000040
+0x01bc92e6
+0x27f7a1ef
+0x95779677
+0x277731f7
+0x85778677
+0xe6468cf7
+0x64470247
+0xefd00800
+0x95860c6e
+0x6c6e020c
+0xae3a4026
+0x023f8629
+0x208cb586
+0x020040e8
+0x6c6e001c
+0xeae08200
+0xaa3a04e8
+0x01b00228
+0x018040e9
+0x81c69a13
+0x020c0241
+0x55c7120d
+0x2c6ec5c6
+0xef208280
+0xa63b1469
+0x00800776
+0x320d220c
+0xa63a1468
+0x520d420c
+0xa63a1468
+0x720d620c
+0xa63a1468
+0xeff08444
+0x920d820c
+0xa23a1468
+0xb20da20c
+0xa2ea1468
+0x02088120
+0x1586fe26
+0x10518c73
+0xedf08011
+0x0200a35a
+0x0580a358
+0x05ac1788
+0x06101fd8
+0x05300fd8
+0x6c6eb61d
+0x5085a120
+0xe4000000
+0xd6ab20a7
+0xd06b60a7
+0x2469d413
+0xfc73a5eb
+0xa4eb2469
+0x12401586
+0xa60caef2
+0xeff08800
+0x00801942
+0x44419001
+0x0052d98a
+0x90470c6e
+0x1586d98a
+0xcc721240
+0xec72061c
+0x16f2060c
+0xefe08500
+0x36f2a62c
+0xa63c0c82
+0x0c0204a8
+0x0c024428
+0x00006ff8
+0x02811808
+0x01021808
+0xe1e00004
+0x018309a0
+0x00031ca3
+0x1181050a
+0xe69a1001
+0x05003078
+0x060cac72
+0x44419001
+0xed900000
+0x1586ad8a
+0xcef21240
+0xec72a61c
+0x16f2060c
+0x36f2a62c
+0xa63c0c82
+0x0c0204a8
+0x0080e01d
+0xefe08414
+0x0c024428
+0x84466428
+0x060cac72
+0x90016c6e
+0xa98a4441
+0x12401586
+0xa61ccef2
+0xefe0a800
+0x060cec72
+0xa62c16f2
+0x0c8236f2
+0x04a8a63c
+0x44280c02
+0x64280c02
+0xac726446
+0xefe00020
+0x6c6e060c
+0x44419001
+0x2641a18a
+0x8c090053
+0x2f8aa120
+0x01d24c28
+0x01804069
+0xe1e08000
+0x02401e2a
+0x020040ea
+0x000c1362
+0x021002e4
+0x01864162
+0x06901fd8
+0x00808c95
+0xa52a0506
+0xe8008000
+0xb00c9586
+0x54466c6e
+0x800c9586
+0x27060a12
+0x0c6e2240
+0x88120004
+0x028c8050
+0xefe30000
+0x07107d40
+0x20264c6e
+0x0706a27a
+0x15078c50
+0x05861084
+0x45962586
+0x00021808
+0xe7c08c40
+0x14021c82
+0x000b19a2
+0x25861081
+0x00051809
+0x0c021001
+0x10003506
+0x028781a0
+0xe6a00a12
+0x052b805b
+0x00148274
+0x02c7d22a
+0x0280406a
+0x104c02ef
+0x008090c8
+0x01894162
+0xb647c046
+0xea003000
+0x03132212
+0x58523506
+0x020c00c0
+0xa6ba2026
+0x02da002a
+0x0280406a
+0x158602ef
+0xe9f38005
+0x00037d40
+0x002b4942
+0x90469047
+0x01850163
+0x03002028
+0x002c1fd8
+0x00037d40
+0xe0800020
+0x05ab4942
+0xfc459047
+0xa8ba0606
+0x00031ca2
+0x02c7d22b
+0x00821808
+0x0280406b
+0xe0c08000
+0x1c424606
+0x01091809
+0x101002ef
+0x0090048a
+0x00806c16
+0x0080e50a
+0x01890162
+0x06274626
+0xeba030a1
+0xd04f0312
+0x02417028
+0x02004068
+0x01dcf928
+0x00101362
+0x01804068
+0x000c0fd8
+0xe0200001
+0x01822162
+0xac0595c7
+0x01c17028
+0x01804068
+0x005d08aa
+0x000c1362
+0x0000406a
+0xe0400004
+0x01824162
+0x003c22f6
+0x000c9686
+0x025d10a8
+0x0241702a
+0x0200406a
+0x02004068
+0xe0800000
+0x01811808
+0x010309a0
+0x00821809
+0x0080d40b
+0x048a026f
+0x00031ca2
+0xe59a1101
+0x10811001
+0xed002480
+0xdc05ac45
+0x01820162
+0x01c17028
+0x01804068
+0x005d1da8
+0x000c1362
+0x00ac0fd8
+0xe0200002
+0x00004068
+0x00bc42f4
+0x01840162
+0x003c22f4
+0x01c17028
+0x01804068
+0x005d2aaa
+0x000c1362
+0x00300fd8
+0x0000406a
+0x003c42f4
+0x01850162
+0x003c22f6
+0x00281fdb
+0x03dd37aa
+0x01c17029
+0x0082180a
+0x01804069
+0x0080cec5
+0x0380406b
+0xd5075507
+0x00860ca2
+0x000c1363
+0x000b1ca0
+0xe1000080
+0x001b09a2
+0x0109180b
+0x20111001
+0x0081e50b
+0xdc05bc75
+0x01860162
+0x0241702a
+0xe38002a0
+0x0200406a
+0xfc0d026f
+0x005d44a8
+0x00004068
+0x003c22f4
+0x01880162
+0x003c42f6
+0xe0400004
+0x01c17028
+0x01804068
+0x00301fd8
+0x000c1362
+0x01866162
+0x003c22f4
+0x024fb22a
+0x0200406a
+0x00100362
+0x0080d43b
+0x01828162
+0x01c0b428
+0x01804068
+0x023c0fd8
+0x000c1362
+0x01878162
+0x00341fda
+0x100d8441
+0x006fa23b
+0x01846162
+0x02281fd8
+0x02aaf22a
+0x0280406b
+0x02ef0706
+0xe870a000
+0x004c8c40
+0x01834162
+0x022c0fda
+0x0200a358
+0x07800852
+0xc677c577
+0x71f76777
+0xec200000
+0xd5770c6e
+0x67f7d677
+0x008ca362
+0x31f73577
+0xccf78577
+0x05900fd8
+0x02d8002a
+0xe3600000
+0x0080630b
+0x0280406a
+0x00140362
+0x053f8428
+0x03001e28
+0x050040e8
+0x01890162
+0x0b228506
+0xe8003000
+0x0200a35a
+0x05281fda
+0x0240202a
+0x020040ea
+0x56460586
+0x80520005
+0x003cc2d4
+0xe6000200
+0x000021a8
+0x003ce2d4
+0x8c85fc26
+0x0020a328
+0x00004068
+0x003ca2f4
+0x0240782a
+0xe0800000
+0x0200406a
+0x00100362
+0x01846162
+0x023d9058
+0x88122506
+0x05287dc1
+0x00c42850
+0x0080877a
+0xea000100
+0xe12a5226
+0x024f4c2a
+0x0200406a
+0x0212026f
+0x01864162
+0x02112988
+0x20138507
+0xe9209000
+0x32051205
+0x5205c427
+0x18230013
+0x001022f6
+0x02300228
+0x020040e8
+0x01100334
+0xe0e00000
+0xa20c821c
+0x82d19a93
+0x011403d4
+0xa2858295
+0x01bfd028
+0x01804068
+0x02280fd8
+0xe1610000
+0x000c1362
+0x8b32004c
+0x01842162
+0x03190888
+0x200c8506
+0x24006c6e
+0x0080cb3f
+0x00102274
+0xe6400000
+0x02d2902a
+0x0280406a
+0x00140362
+0x021fe02a
+0x02003ea8
+0x0200406a
+0x01880162
+0x0210aca0
+0x40c4a506
+0xd33a5226
+0x01c17028
+0x01804068
+0x005d50aa
+0x000c1362
+0x0000406a
+0xe0608000
+0x01824162
+0x003c22f6
+0x01cfb228
+0x01804068
+0x00000000
+0x000c1362
+0x01878162
+0x01c0b428
+0x01804068
+0x02280fd8
+0x000c1362
+0x02100264
+0x01856162
+0x0080eeec
+0x0223f02a
+0x0200406a
+0x00100362
+0x01818162
+0x000ea120
+0x0241702a
+0x0200406a
+0x00100362
+0x005d6028
+0x00004068
+0x01892162
+0x003c22f4
+0x01a3f028
+0x01804068
+0x00000000
+0x000c1362
+0x01868162
+0x07800c52
+0x053c33e4
+0x01bc52e6
+0x00004000
+0x053c52e6
+0x008ca362
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x02333028
+0x020040e9
+0x00042426
+0x31f7a1ef
+0x008070c5
+0x01cf6828
+0x01804068
+0x00000000
+0xe1800000
+0x000c1362
+0x01828162
+0xa1ef71f7
+0x277731f7
+0x85778677
+0xa74e8646
+0x06067656
+0xef900c00
+0x052780fa
+0x15872527
+0x00800a5a
+0x00042dda
+0xde3b0509
+0x0233302a
+0x020040ea
+0xe2608000
+0xd646100d
+0xd92b4c6e
+0x0500a358
+0x0251f02a
+0x0200406a
+0x00100362
+0x01888162
+0xe0608000
+0x01cf8428
+0x01804068
+0x00000000
+0x0080190a
+0x000c1362
+0x01858162
+0xd12a0246
+0x0000c82a
+0xe4008000
+0x00341a7a
+0x2009a120
+0x02cf3c2a
+0x0280406a
+0x00140362
+0x01886162
+0x02314079
+0x022c1fda
+0x1247868a
+0x02cf2c2a
+0x0280406a
+0x00140362
+0x01886162
+0x02314079
+0x022c1fda
+0xe0208000
+0x02b62a28
+0x028040e8
+0x1247008c
+0x80004c6e
+0x00140274
+0x05288078
+0x000170f8
+0xe1800000
+0xd00a8120
+0x058170f8
+0x00807ed3
+0x01a57128
+0x01804068
+0x00000000
+0x000c1362
+0x01878162
+0x02381fda
+0x6c6e100d
+0x3fa6a120
+0x100d9707
+0xa2bb6c6e
+0xfe2682ca
+0xc5770626
+0x6777c677
+0xefa08000
+0x6c6e71f7
+0x31f7a1ef
+0x02a4062a
+0x0280406a
+0x873202ef
+0x01884162
+0x03190888
+0xe2600000
+0x6c6e71f7
+0x31f7a1ef
+0x02a4062a
+0x0280406a
+0x171202ef
+0x01884162
+0x03190888
+0xe2600000
+0xa1ef71f7
+0x00806a85
+0xa1ef0626
+0x31f73577
+0x85772677
+0x464e9646
+0xddba0506
+0x0012e264
+0xe7f08100
+0xd066a120
+0x00132264
+0xd9ba6c6e
+0x00134264
+0xd9ba6c6e
+0x00130264
+0xd9ba6c6e
+0xea808000
+0x02d8002a
+0x0280406a
+0x00140362
+0x05b00028
+0x058040e8
+0x01892162
+0x06278586
+0xe8003000
+0x03062c28
+0x01d80028
+0x01804068
+0x02362c2a
+0x000c1362
+0x020040ea
+0x01894162
+0x02101fd9
+0x0080d2c1
+0x1b120627
+0x01da0028
+0x01804068
+0x022c0fd8
+0x000c1362
+0x8b729507
+0x01884162
+0xe4200001
+0x01b8d628
+0x01804068
+0x00000000
+0x000c1362
+0x01858162
+0x0247a22a
+0x0200406a
+0x00100362
+0x01818162
+0x0241522a
+0x0200406a
+0x00100362
+0x01858162
+0x022c0fd8
+0x0012e264
+0xe0100000
+0x00001362
+0x01828162
+0xa27a5226
+0x00498120
+0x8a12fe26
+0x02400586
+0xaf3a000c
+0x008019b1
+0xee908200
+0x02c7d22a
+0x0280406a
+0x862e02ef
+0x05108058
+0x03100264
+0x01894162
+0x07272626
+0xe8803030
+0x020016a2
+0x052c1fda
+0xa33a0606
+0x026f9607
+0x01866162
+0x02281fd8
+0x02aaf22a
+0xe1808000
+0x0280406b
+0x02ef0506
+0x004c8440
+0x01854162
+0x022b4942
+0x0018a120
+0x01a2f628
+0xe0c00008
+0x01804068
+0x02300fd8
+0x000c1362
+0x01848162
+0xc5770626
+0x71f76677
+0x008061b6
+0x75774c6e
+0xee000000
+0x31f7a1ef
+0x86772777
+0xccf78577
+0x06b00028
+0x068040e8
+0x08730686
+0x101d1041
+0xece00000
+0x8686c873
+0x0601b078
+0x0234107a
+0x00040362
+0x05340fd8
+0x05b5bec0
+0x01884162
+0xe0200000
+0x00100fd8
+0xd0d48120
+0x864ea606
+0x07362c28
+0x070040e8
+0x018ce706
+0x4c6e8706
+0xec800010
+0x00042400
+0x01140334
+0xa28c829c
+0x0c6e8637
+0x011003d4
+0x0080859c
+0xa2058215
+0x022c1fda
+0xe5a10000
+0x6c6e3a0d
+0x008109a2
+0x0003100a
+0x10630081
+0x74460c6e
+0x00be0296
+0x4c6efc73
+0xeb220000
+0xa73b2469
+0x003e2296
+0x4c6efd73
+0xa73b0569
+0x003e4296
+0x05696c6e
+0x301ca120
+0xe5a08000
+0x003e6296
+0xa33b0569
+0x003e8296
+0xa33b0569
+0x003ea296
+0xac2b0569
+0x838ce686
+0xed508000
+0xdf3b3469
+0x003e2297
+0x1469a38c
+0xc38cdf3b
+0x0080600e
+0x003e4296
+0xdf3a1468
+0x003e6297
+0xe5b08080
+0x1468e38c
+0x0b8cdb3a
+0x003e8296
+0xdb3a1468
+0x003ea297
+0x14682b8c
+0xd06ca120
+0xe5708008
+0x06324058
+0x98f20506
+0x60120090
+0xa6ba2408
+0x01c17028
+0x01804068
+0x005e802a
+0xe1c08014
+0x000c1362
+0x0000406a
+0x00bc42f4
+0x01852162
+0x003c22f6
+0x68230013
+0x24693587
+0xec000800
+0x070648ab
+0x000c8440
+0x06b88058
+0x00802921
+0x6823c013
+0xae7b2469
+0x02b7922a
+0x0280406a
+0xe3608008
+0x050602ef
+0x02003e28
+0x01842162
+0x96070240
+0xad3a5226
+0x84400686
+0x6d0a000c
+0xef208040
+0x00042400
+0x02c73a2a
+0x0280406a
+0x9a7202ef
+0x02400506
+0x01880162
+0x02301fda
+0xe3200000
+0xa53a5226
+0x06860a12
+0x000c0240
+0x2400650a
+0x24000004
+0xa50a0004
+0x000c8640
+0xefe08004
+0x24006c6e
+0x00100274
+0x0080eac5
+0x07800c52
+0xc677c577
+0x71f76777
+0xa1ef6c6e
+0x857731f7
+0xef200000
+0x02470246
+0x2027a43b
+0x306ca120
+0x02362a2a
+0x020040ea
+0x101d85ca
+0x0100307a
+0xe4608401
+0x02362a2a
+0x020040ea
+0x5047101d
+0x44e94c6e
+0x4cc9d82b
+0x4881d72b
+0x54460c6e
+0xef808000
+0x0233302a
+0x020040ea
+0x7646100d
+0xd26b4c6e
+0x0251f02a
+0x0200406a
+0x00100362
+0xe1808000
+0x01818162
+0x00804148
+0x01cf8428
+0x01804068
+0x00000000
+0x000c1362
+0x01868162
+0xaaaa0246
+0xe8008000
+0x02cf2c2a
+0x0280406a
+0x00140362
+0x01856162
+0x95070626
+0x02b62a28
+0x028040e8
+0xe2000100
+0x6c6e008c
+0x00848000
+0x001140f8
+0xd0198120
+0x051140f8
+0x01a57128
+0x01804068
+0xe0600000
+0x00000000
+0x000c1362
+0x01838162
+0x100d9587
+0x9587b23b
+0xa43b100d
+0xfe26844a
+0xef108000
+0x0080942e
+0xc5770626
+0x6c6e71f7
+0x008ca362
+0x857731f7
+0x07bf005a
+0x76464646
+0xcc011507
+0xed600000
+0x00006f5a
+0x300ba120
+0x01c17028
+0x01804068
+0x005e982a
+0x000c1362
+0x00a81fda
+0x0000406a
+0x00bc42f6
+0x01830162
+0x003c22f6
+0x02363628
+0x020040e8
+0x6c6e000c
+0x00042400
+0xec000000
+0x0230322a
+0x020040ea
+0x8073101d
+0x95078801
+0x00efc586
+0x01886162
+0x02001fd8
+0x0080df37
+0xe3800000
+0x07bd005a
+0x71f7c577
+0xa1ef6c6e
+0x857731f7
+0x07bf005a
+0x05b33a28
+0x058040e8
+0xe1c00000
+0x84680586
+0xc014a120
+0x01c17028
+0x01804068
+0x005eb1aa
+0x000c1362
+0x0000406a
+0xe0200000
+0x01824162
+0x003c22f6
+0x25861812
+0x000c2840
+0x052cddc0
+0xa72a4c6e
+0x01c17028
+0xe5808010
+0x01804068
+0x005ecc2a
+0x000c1362
+0x0000406a
+0x01864162
+0x003c22f6
+0x0080889d
+0x00128506
+0xe8001000
+0x00100274
+0x07bd005a
+0x71f7c577
+0xa1ef6c6e
+0x07bf005a
+0x234e0246
+0x204e00c6
+0xed801400
+0x01300028
+0x010040e8
+0x0003322a
+0x0008107a
+0x008032fa
+0xa56b50a7
+0x0002f72a
+0xe4008000
+0xa16b2c29
+0x0005c8da
+0x8d0aa23b
+0x0200a358
+0x000119a2
+0x00031008
+0x00001078
+0xe0a08000
+0x003c42d4
+0x02bc805a
+0x328d129d
+0x2c6eccc0
+0x32041214
+0x0080ce41
+0x02888058
+0x01140334
+0xe3810000
+0xa28c829c
+0x0c6e4e40
+0x01100354
+0xa2048214
+0x011003b6
+0xb20d921d
+0x0c6e4e40
+0xed610000
+0x01100356
+0xb2049214
+0x07bd005a
+0x008ca362
+0x01bc54f6
+0x053c22f4
+0x0002f728
+0xe0400000
+0xa46a8c28
+0x00300028
+0x000040e8
+0x00032e2a
+0x100d1041
+0x0a22f612
+0x20272c6e
+0xee208000
+0x880aa0fb
+0x44460626
+0xa50e2426
+0x00148a74
+0x0080c841
+0x02d8002a
+0x0280406a
+0x250602ef
+0xe8e08010
+0x00033228
+0x01842162
+0x062700c0
+0x0302f728
+0x00a80fd9
+0x00033a28
+0x02040078
+0xe0800030
+0x053c22e4
+0x01bc52e6
+0x00006000
+0x008ca362
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x003e5628
+0x000040e9
+0x0c6e5053
+0x10501041
+0x08230013
+0x001002d6
+0x504704a6
+0xeb8000c0
+0x6c6e020c
+0x10c7a6fa
+0x42419253
+0x0080d7c0
+0x2526304f
+0xa303e000
+0x00004000
+0xa09036b6
+0xe1e08068
+0xa1903214
+0x41c631c7
+0x0c6e2c6e
+0x00034001
+0x0c6e2401
+0x0c6e3046
+0x50d10526
+0xeed03004
+0xa6259253
+0x64c0e873
+0x2640b604
+0xa6046072
+0x26409072
+0xa073a604
+0xb6042640
+0xefe00924
+0xa6042640
+0xa6242640
+0xa1ef2640
+0x01bc54f6
+0x053c22f4
+0x053e5c29
+0x02524c2a
+0xe0e00000
+0x0200406b
+0x050040e8
+0x008013b6
+0x026f8506
+0x02100264
+0x01856162
+0x02280fd9
+0x007fffa8
+0xe0800010
+0x00100274
+0x01c0b428
+0x01804068
+0x02138058
+0x000c1362
+0x02100264
+0x01876162
+0x024fb22a
+0x0200406a
+0x00100362
+0x01838162
+0x053c22e4
+0x6c6e71f7
+0x008ca362
+0x01bc94f6
+0xe2000000
+0x023e5628
+0x020040e8
+0x6c6e000c
+0xd83a2026
+0x28221852
+0x008c0250
+0x023f822a
+0xe7808000
+0x020040ea
+0x00803f46
+0x24002c6e
+0x001002f4
+0x0000abd8
+0xc02ca120
+0x01a80028
+0x01804068
+0xe0400000
+0x03100fd8
+0x000c1362
+0x02000828
+0x01854162
+0x0210c078
+0x01900fd8
+0x02bfd02a
+0x0280406b
+0x02ef0a12
+0x004cc240
+0x0000292a
+0x01852162
+0xc1c61341
+0x0050a120
+0x01c17028
+0xe2600102
+0x01804068
+0x005d7028
+0x000c1362
+0x00004068
+0x01864162
+0x003c22f4
+0x0228462a
+0x0200406a
+0x00802d51
+0x00100362
+0x01828162
+0x01a3f028
+0x01804068
+0x00000000
+0x000c1362
+0x01878162
+0x0018a120
+0x01c17028
+0x01804068
+0x005d8a28
+0x000c1362
+0x00004068
+0x01874162
+0x003c22f4
+0x0228462a
+0x0200406a
+0x00100362
+0x01838162
+0x01a3f028
+0x01804068
+0x00000000
+0x000c1362
+0x01888162
+0x01bc92e6
+0xa1ef6c6e
+0x857731f7
+0x01d80028
+0x01804068
+0x053e5628
+0x000c1362
+0x008054c9
+0xe0c00000
+0x0000292a
+0x050040e8
+0x83120506
+0x05815078
+0x01880163
+0x2b221040
+0x0200a35a
+0xe4800c20
+0x00130506
+0x95874823
+0x10531205
+0x120d1041
+0x022c1fda
+0x05015ec0
+0x00002000
+0xe1e20004
+0x008109a2
+0x0003100a
+0x32050081
+0x02bfd02a
+0x10415053
+0x0a520506
+0x0280406a
+0xe6820e00
+0x0a4002ef
+0x02100264
+0x01844162
+0x0310a358
+0x120d9507
+0x24016c6e
+0x00800c15
+0xc5771205
+0xee220001
+0xa1ef71f7
+0x277731f7
+0x85778677
+0x8746ccf7
+0xa256b64e
+0x07340fd8
+0x00100286
+0xe3f00180
+0x008109a2
+0x0003100a
+0x60270081
+0x202ea120
+0x01c17028
+0x01804068
+0x005da2a8
+0xe0800000
+0x000c1362
+0x00004068
+0x01844162
+0x003c22f4
+0x0228462a
+0x0200406a
+0x00100362
+0x01888162
+0x01a3f028
+0x01804068
+0x00000000
+0x000c1362
+0x01858162
+0x0080dc1c
+0x00b48120
+0x027ca358
+0x05be5628
+0x058040e8
+0x000c8586
+0xe13a2026
+0x0240b42a
+0x0200406a
+0x00100362
+0x01896162
+0xe0d08000
+0x02140fd8
+0x48225452
+0x003cc2d4
+0x02341fda
+0x00108086
+0x008109a2
+0x0003100a
+0xe0500000
+0x0004007a
+0x003ce2d6
+0x84400586
+0x8c85000c
+0x0029522a
+0x0000406a
+0x9587bc85
+0xe9902000
+0x10054013
+0x023f822a
+0x020040eb
+0x00050426
+0x0080cec1
+0x01d24c28
+0x01804068
+0x80400812
+0xe9202000
+0x05103ec1
+0x000c1362
+0x02100264
+0x01846162
+0x8506fc27
+0x00100276
+0x0240782a
+0xe2000100
+0x0200406a
+0x00100362
+0x01846162
+0x023d9058
+0x8c400506
+0x0004024e
+0xad3a5026
+0xee008200
+0x01c17028
+0x01804068
+0x005db428
+0x000c1362
+0x00004068
+0x01874162
+0x003c22f4
+0x0228462a
+0x0200406a
+0x00100362
+0x01838162
+0x00804668
+0x01a3f028
+0x01804068
+0x00000000
+0x000c1362
+0x01888162
+0x00d88120
+0x027ca358
+0x01d24c28
+0x01804068
+0x88122586
+0x000c1363
+0x004c2040
+0xea000100
+0x01824162
+0x05047d40
+0x02d2902a
+0x0280406a
+0x00140362
+0x02287c2a
+0x02753028
+0x0200406a
+0x01820162
+0x02000068
+0x00c4a506
+0xab7a5226
+0x01c17028
+0x01804068
+0x005dc6a8
+0xe1808000
+0x000c1362
+0x00004068
+0x00800ac7
+0x01844162
+0x003c22f4
+0x0228462a
+0x0200406a
+0x00100362
+0x01888162
+0x01a3f028
+0x01804068
+0x00000000
+0x000c1362
+0x01858162
+0x00988120
+0x9707fe26
+0xe8000000
+0x8252320d
+0x020ca240
+0x00000000
+0x008109a2
+0x0003100a
+0x0c6e0081
+0xd23a1468
+0xec628000
+0x023f8228
+0x020040e9
+0x00040426
+0x02cea02a
+0x0280406a
+0x060602ef
+0x00341fda
+0xe4800000
+0x01822162
+0x0080817e
+0x9c419440
+0xa4aa0246
+0x01a90428
+0x01804068
+0x00000000
+0x000c1362
+0xe0c08004
+0x01818162
+0x28228012
+0x2c082606
+0xd014a120
+0x01a84628
+0x01804068
+0x00000000
+0xe0c00008
+0x000c1362
+0x01828162
+0x00488120
+0x0200a358
+0x02bf8228
+0x028040e8
+0x2400008c
+0xe8100000
+0x00140274
+0x0000abd8
+0xd014a120
+0x01c17028
+0x01804068
+0x005dd828
+0x000c1362
+0x00004068
+0x008020ae
+0x01824162
+0x003c22f4
+0x0228462a
+0x0200406a
+0x00100362
+0x01868162
+0x01a3f028
+0x01804068
+0x00000000
+0x000c1362
+0x01838162
+0xfe26860a
+0x6c6e020c
+0x0204ec00
+0x0229042a
+0xe7028000
+0x0200406a
+0x00100362
+0x01838162
+0x0200a358
+0x07800c52
+0xc677c577
+0x71f76777
+0xec000000
+0xa1ef6c6e
+0x867731f7
+0xccf78577
+0x664e5646
+0xa6ba0586
+0xa6ba0506
+0x024f4c2a
+0x008011a0
+0xe7e08040
+0x0200406a
+0x0212026f
+0x01844162
+0x02112988
+0xa6ba5226
+0x01a3f028
+0x01804068
+0xe2408000
+0x00000000
+0x000c1362
+0x01838162
+0x00738120
+0x027ca358
+0x01d80028
+0x01804068
+0x023e562a
+0x000c1362
+0x020040ea
+0x92469b52
+0x01860162
+0x0627b646
+0x03192988
+0x48225452
+0xea800300
+0x003cc2d4
+0x000022aa
+0x003ce2d6
+0x8c850586
+0x00295228
+0x00004068
+0x00809a70
+0x003ca2f4
+0xe1000000
+0x0240782a
+0x0200406a
+0x00100362
+0x01856162
+0x023d9058
+0x08122686
+0x06343ec1
+0xe4000400
+0x00c42050
+0xa6fa5226
+0x024fb22a
+0x0200406a
+0x00100362
+0x01868162
+0x01a3f028
+0xe0608000
+0x01804068
+0x00000000
+0x000c1362
+0x01848162
+0x00968120
+0xd687fe26
+0x21050586
+0xec000800
+0x120d9507
+0xa6bb6c6e
+0xa0478506
+0x02c71213
+0x2526832f
+0x0080585b
+0xa303e000
+0x00004000
+0xe3e18190
+0xa01036b6
+0xa1903224
+0x41c611c7
+0x0c6e2c6e
+0x00034000
+0x0a520606
+0x24270240
+0xed901410
+0x00100256
+0x0228002a
+0x0200406a
+0x00100362
+0x01866162
+0x02280fd8
+0x24274646
+0xe8002000
+0x1005834f
+0x05981fd8
+0x01d29028
+0x01804068
+0x02287c2a
+0x000c1362
+0x02003ea8
+0xe0200002
+0x0200406a
+0x01832162
+0x02106ca0
+0x84400606
+0x008040ed
+0x0004024e
+0xacba5026
+0x01c17028
+0xe7008080
+0x01804068
+0x005deb28
+0x000c1362
+0x00004068
+0x01864162
+0x003c22f4
+0x0228462a
+0x0200406a
+0x00100362
+0x01828162
+0x01a3f028
+0x01804068
+0x00000000
+0x000c1362
+0x01878162
+0x00138120
+0x027ca358
+0x01bfd028
+0x01804068
+0x02300fd8
+0x000c1362
+0x5053004c
+0x00ac1fda
+0xe4000000
+0x01820162
+0xc50600c1
+0x0200a358
+0x0080b591
+0x07800c52
+0xc677c577
+0x6c6e71f7
+0x008ca362
+0xe6400004
+0x277731f7
+0x85778677
+0x02470246
+0x2027a53b
+0x301aa120
+0x0240882a
+0x020040ea
+0xe1e08010
+0x100d814a
+0x05801078
+0x0c6e6446
+0x50271587
+0x3010a120
+0x007c8120
+0x027ca358
+0xe1a08001
+0x01c07628
+0x02d95028
+0x018040e8
+0x02804069
+0x0280042a
+0x029472fa
+0x00141362
+0x021402e6
+0x01834162
+0x022c0fd9
+0x0080840e
+0x038c0264
+0x02d95028
+0x02804068
+0x04100fd8
+0x00141362
+0x01896162
+0x021c1fda
+0x06100fd8
+0x0359b02a
+0x0300406a
+0x00180362
+0x01886162
+0x840693c7
+0xe8001000
+0x1033a646
+0x02afa041
+0x54460606
+0x6c6e100d
+0xa57a1468
+0x84411507
+0x0686100d
+0xefe08024
+0x14684c6e
+0x8b0aa17a
+0x92320626
+0x005c6240
+0x029edc2a
+0x0280406a
+0x03300fd8
+0xe1e08000
+0x07138058
+0x0080d859
+0x02ef8e40
+0x006cc69c
+0x01854162
+0x80c69687
+0xa43a5226
+0xde26870a
+0xeec2810c
+0x95070606
+0x07060005
+0x020381a1
+0x00040686
+0x158f8e41
+0x06261005
+0xc677c577
+0xef600101
+0x71f76777
+0xa1ef6c6e
+0x267731f7
+0x46468577
+0x02900fda
+0x02408828
+0x00001628
+0xe1e00080
+0x0359b02b
+0x020040e8
+0x0300406b
+0x06117dc1
+0x036f8850
+0x004c10cc
+0x01886162
+0xe6000200
+0x00802e51
+0x02c7a246
+0x76c6d4bb
+0x0230fec0
+0x6c6e006c
+0xc506a70c
+0x03044c6e
+0x010cc606
+0xef608000
+0x4c6e26d0
+0xae2aac48
+0x010c8e60
+0x0200305a
+0x02997dc0
+0x9c49008c
+0x684aa53b
+0xecf08000
+0x8f50b347
+0x00dc10c5
+0x0012a346
+0x8ee00084
+0x029781a0
+0x6c6e008c
+0x01542450
+0xede00095
+0x86600627
+0x03180264
+0x029edc2a
+0x0280406a
+0xa70c2c6e
+0x006c02ef
+0x01894162
+0x00806bb8
+0xe6220200
+0x02000fd8
+0xa1ba5226
+0xde2684ca
+0x0280a358
+0x05282058
+0x002ff05a
+0x2fc48120
+0xe0c08000
+0x05afe058
+0xc5770626
+0x71f76677
+0xa1ef6c6e
+0xa1effe26
+0x357727f7
+0x277731f7
+0xefc00000
+0x85778677
+0xc2476246
+0x05408828
+0x050040e8
+0x000c8506
+0x54476c6e
+0x84400506
+0xee600004
+0x00100264
+0x06288058
+0xc4464c6e
+0x00300fd8
+0x06b08058
+0x100d9441
+0x0080c0b3
+0xf4466c6e
+0xec800000
+0x02ac942a
+0x0280406a
+0x00140362
+0x01856162
+0x834781c6
+0x86066646
+0x2706000c
+0xee000100
+0x24684c6e
+0x9687a27a
+0x3787100d
+0x24694c6e
+0x1212a92b
+0x02400506
+0x02900264
+0xe7e08200
+0x029edc2a
+0x0280406a
+0x8e40c706
+0x0014ca05
+0x006c02ef
+0x01884162
+0x80469787
+0xea801000
+0xa13a5226
+0xde26840a
+0x850e1506
+0x07060004
+0x0004860e
+0x00808fc5
+0x17879687
+0x85861005
+0xefe08090
+0xc677c577
+0x71f76777
+0x75772c6e
+0xa1ef67f7
+0x857731f7
+0x05100fd8
+0x05c08e28
+0xe3e00000
+0x058040e8
+0x000c8586
+0xa4ba6c6e
+0x01cc3028
+0x01804068
+0x02000fd8
+0x000c1362
+0xe0c08000
+0x01818162
+0x84400586
+0x00100264
+0x05ac8058
+0xa5ba4c6e
+0x01cc3028
+0x01804068
+0xe2408000
+0x02000fd8
+0x000c1362
+0x01838162
+0x84400586
+0x0080d2fa
+0xa5ba000c
+0x01cc3028
+0x01804068
+0xe3108000
+0x02000fd8
+0x000c1362
+0x01838162
+0x05868a12
+0x000c0240
+0xa63a6c6e
+0x01cc3028
+0xe7008040
+0x01804068
+0x02000fd8
+0x000c1362
+0x01848162
+0xc5778506
+0x6c6e71f7
+0x008ca362
+0xe6000000
+0x967727f7
+0x31f79577
+0x86772777
+0x053c35c4
+0x07bf005a
+0x05900fd8
+0x02d8002a
+0xe0e00000
+0x0280406a
+0x00140362
+0x06407028
+0x0080e7dd
+0x060040e8
+0x01882162
+0x06278606
+0x03002828
+0xe4000c00
+0x05300fd8
+0x02da002a
+0x0280406a
+0x00140362
+0x002e8940
+0x01894162
+0x83529047
+0xe8003000
+0x02280fd8
+0x0012e506
+0x001de274
+0x05a91ec0
+0x07291ec1
+0x0184e586
+0x2184e706
+0xec400004
+0x001c6274
+0x021f742a
+0x0200406a
+0x00100362
+0x01866162
+0x02280fd8
+0xa6ba5226
+0xe8008000
+0x01ad7828
+0x01804068
+0x00800182
+0x00000000
+0x000c1362
+0x01858162
+0x84400606
+0x100d1441
+0xec002000
+0x0252e02a
+0x0200406a
+0x000c026f
+0x01866162
+0x06308059
+0x020011e0
+0x8c100586
+0xe8800010
+0x80ce0246
+0x06af8059
+0xa4aa0004
+0x01ad7828
+0x01804068
+0x027f3828
+0x000c1362
+0xe0a08001
+0x01818162
+0x10322706
+0x0252e02a
+0x0200406b
+0x000c2840
+0x00100362
+0x018a6162
+0xe240020c
+0x05399dc1
+0x0080952b
+0x02000078
+0x870e0246
+0xa52a0004
+0x01ad7828
+0x01804068
+0x027f37a8
+0xe1808010
+0x000c1362
+0x01828162
+0x0252e02a
+0x0200406b
+0x026f8506
+0x00100264
+0x018a6162
+0xe2000200
+0x05281fdb
+0x02000078
+0x84100586
+0x80ce0246
+0x0004ac15
+0xc018a120
+0x01ad7828
+0xe38000c0
+0x01804068
+0x027f3728
+0x000c1362
+0x01848162
+0x0252e02a
+0x0200406a
+0x8506026f
+0xe8001000
+0x008015c9
+0x02100264
+0x01826162
+0x98322506
+0x0705fd41
+0x02462010
+0x000480ce
+0xc01aa120
+0xe6800210
+0x01ad7828
+0x01804068
+0x027f36a8
+0x000c1362
+0x01858162
+0x029edc2a
+0x0280406a
+0x00140363
+0x006c8686
+0x01844162
+0x06270626
+0x06b416a2
+0x0427ac0d
+0x84404c6e
+0x0580905b
+0xe6a00030
+0x95061004
+0x6c6e001c
+0x9080a120
+0x07801fd8
+0x053c0fd9
+0x06340fda
+0x029d9a2a
+0x0080a3bc
+0xe0600000
+0x0280406b
+0x02ef9686
+0x04100265
+0x006c8606
+0x01884162
+0x06278786
+0x030000aa
+0xe5400c08
+0xa33a5226
+0x01ad7828
+0x01804068
+0x00000000
+0x000c1362
+0x01868162
+0x029d9a2a
+0xe0208000
+0x0280406b
+0x02ef8686
+0x8606000c
+0x03100264
+0x01894162
+0x06278786
+0x040021a1
+0xe4c00c18
+0x030000aa
+0xa43a5226
+0x01ad7828
+0x01804068
+0x00000000
+0x000c1362
+0x0080a3dc
+0x01888162
+0xe0408000
+0x004c9606
+0x4c6efcf2
+0x6c6e020c
+0xa53a04e8
+0x6c6e220c
+0xa53a04e8
+0x684a8706
+0xefe0a000
+0xa506004c
+0xa6040012
+0x004c8706
+0x00c6a506
+0xa6042c6e
+0x000c9586
+0x24006c6e
+0xefe00002
+0x95060004
+0x4c6e001c
+0x00282058
+0x00040bf8
+0xcf9c8120
+0x07a82059
+0x052821a0
+0xe0600000
+0x9018a120
+0x006c8706
+0x10c7fdf2
+0x05260c6e
+0x1af6e58e
+0x0080e6d9
+0x6c6e0f0c
+0xa52a05e8
+0xefc08180
+0x6c6e01cc
+0x26d0a624
+0xec012520
+0x2ffaa120
+0x9022a120
+0x8706ac5d
+0xfdf2004c
+0xece20004
+0x21c610c7
+0x04a700dc
+0x00103614
+0x05e86c6e
+0x834aa32a
+0x24911294
+0x46d00294
+0xef628402
+0xbd2bec01
+0x1a121586
+0xfc270a40
+0xfc261004
+0x0004862e
+0x00048640
+0x02ac002a
+0xe7e08094
+0x0280406a
+0x00140362
+0x01846162
+0x06270626
+0x00808d0b
+0x0200a358
+0x07bd005a
+0xc677c577
+0xe9000040
+0x71f76777
+0xd5770c6e
+0x67f7d677
+0x008ca362
+0x01bc54f6
+0x019fda28
+0x01804068
+0xe0e00000
+0x00000000
+0x000c1362
+0x01838162
+0x022d782a
+0x0200406a
+0x00100362
+0x01886162
+0x0200a358
+0x01bc52e6
+0x00006000
+0x008ca362
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x02412a2a
+0x020040eb
+0x12052427
+0x00804abe
+0x00106264
+0x0201942a
+0x0200416a
+0x00002000
+0xe0820000
+0x000319a2
+0x600c1205
+0x000219a2
+0x600c3205
+0x000119a2
+0x9a0c5205
+0xa00c7205
+0xed500000
+0x000319a2
+0xa00c9205
+0x000219a2
+0xa00cb205
+0x000119a2
+0x0010c2b6
+0x00128216
+0xe1500000
+0x8650f205
+0x01940334
+0xa29c82ac
+0x12501012
+0x01940354
+0xa29482a4
+0x5e2ec6d0
+0xeda10000
+0x0c6e0413
+0x020c3046
+0x0080d336
+0x82fa6c6e
+0xec010e84
+0xec9080eb
+0x0c6e262e
+0x00043bda
+0xe7e18200
+0x300b8120
+0x82c6ec90
+0x068413a2
+0x2c6e0426
+0x0e040c66
+0xa1ef1c67
+0x277731f7
+0xef400000
+0x85778677
+0x07ffbc52
+0x00005c28
+0x01100571
+0x0000002a
+0x0000416a
+0x10009852
+0xe8200000
+0x000c0140
+0x20471111
+0x0006fd42
+0x74468546
+0x54c6832a
+0xe626840a
+0x0220a358
+0xe7608008
+0x0238f02a
+0x0080e1a4
+0x0200406a
+0x00100362
+0x01848162
+0x001008d8
+0xc2fca120
+0x08230c53
+0xe8002000
+0x00c13507
+0x6c6e120d
+0xa73b1027
+0x0200e529
+0x02d5d42a
+0x02004169
+0x0280406a
+0xe0e38000
+0x4640026c
+0x106c02ef
+0x021002c4
+0x05061453
+0x10410823
+0x01860162
+0x95873507
+0xeb62020b
+0x6c6e100d
+0x0606dc05
+0x30010e13
+0x0210007a
+0x019003b6
+0xb21d922d
+0x07059078
+0xe4e10800
+0x0080b49f
+0x023d805a
+0x00000000
+0x019003d6
+0xb2159225
+0x050e2606
+0x02f22040
+0x02948078
+0xe7000500
+0x00140244
+0x20266c6e
+0x1872aa2a
+0x061c3872
+0x5af2060c
+0x7af2a62c
+0x0c82a63c
+0xefc09040
+0x0c0204a8
+0x0c024428
+0x00006ff8
+0x02011808
+0x018309a0
+0x00000693
+0x01021808
+0xe0600000
+0x00031ca3
+0x1181050a
+0x1001e61a
+0xbc851081
+0xbc850427
+0x050e2606
+0x84122040
+0x00802983
+0xefc01408
+0xa492060c
+0xc512261c
+0x0c6e462c
+0x14a9f40b
+0x0c03e412
+0x0c6e161c
+0x0c025428
+0xefe00281
+0x34290c6e
+0x010309a2
+0x00031ca1
+0x0182180a
+0x0081180b
+0x058b1100
+0xe48b1011
+0xec201000
+0xdc850081
+0x061c9872
+0x060cb872
+0x462cd972
+0x0c82faf2
+0x04a8a63c
+0x44280c02
+0xefe00208
+0x64280c02
+0xa046ac05
+0x01021809
+0x30476056
+0x001709a0
+0x000f1ca3
+0x008051bf
+0x1001051a
+0xe9602088
+0x0085180a
+0xe48b1091
+0xfc850081
+0x12414073
+0x05809079
+0x6c6e120d
+0x003e02d6
+0xe5c30004
+0x02da002a
+0x0280406a
+0x370702ef
+0x0000472a
+0x01882162
+0x035200c1
+0x120011dc
+0xe4800c00
+0x320d9587
+0x120031de
+0x12054c6e
+0x003b4228
+0x00004069
+0x00854651
+0x003b4028
+0xe4a30000
+0x00004069
+0x0085c651
+0x003ca02b
+0xa2514ea7
+0x0000406a
+0x00805903
+0x001402f6
+0x003d062a
+0xe1400080
+0x0000406b
+0x0211c05a
+0x001002f6
+0x02412a2a
+0x020040ea
+0x76460427
+0x001002d6
+0xe4000800
+0x06b63828
+0x068040e8
+0x000c8686
+0x022fd02a
+0x0200406a
+0x023d1058
+0x00000000
+0xe0800000
+0x00001362
+0x01828162
+0x00100fd8
+0xc1dca120
+0x020c8586
+0xa8ea6c6e
+0x02345ec0
+0xe6038000
+0x00100264
+0x023c9058
+0x2c6e8627
+0x00001362
+0x00809594
+0x01858162
+0x001008d8
+0xc1c4a120
+0xe0800000
+0x020c8586
+0x0606bb3a
+0x2040250e
+0x02934264
+0x00142a58
+0xd134a120
+0x03819f28
+0xe0f38008
+0x03804168
+0xc9b283c6
+0x021c0726
+0x25e86c6e
+0xc246a2ba
+0x81a1a120
+0x01181fda
+0xe3c18004
+0x710aa120
+0x025f2229
+0x01462526
+0x02004069
+0x02080fda
+0xa483e000
+0x0000a000
+0xe0800020
+0xa1903615
+0xa19036a6
+0x19e36c6e
+0x0080ef5b
+0x39e30027
+0x24393991
+0xc28406a2
+0x4100a358
+0xe3800240
+0x01462c6e
+0x12c61c66
+0x2526aa3a
+0x025f24a8
+0x02004069
+0x81470146
+0xa483e000
+0xe4e08420
+0x0000a000
+0xa1903615
+0xa19036a6
+0x19e36c6e
+0x39e30027
+0x24393991
+0xc28406a2
+0xe7000900
+0x4100a358
+0x01462c6e
+0x12c61c66
+0xc010a120
+0x00ca8120
+0x0c6e46a6
+0x00000000
+0xe4c00c00
+0x025f2729
+0x01462526
+0x00800cee
+0x02004069
+0x02080fda
+0xa483e000
+0x0000a000
+0xa1903615
+0xe0400008
+0xa19036a6
+0x19e36c6e
+0x39e30027
+0x24393991
+0xc28406a2
+0x4100a358
+0x01462c6e
+0xe9c00090
+0x12c61c66
+0x2526a9ba
+0x025f29a8
+0x02004069
+0x81470146
+0xa483e000
+0x0000a000
+0xe2608108
+0xa1903615
+0xa19036a6
+0x19e36c6e
+0x39e30027
+0x24393991
+0xc28406a2
+0x4100a358
+0xe3800240
+0x01462c6e
+0x00806f45
+0x12c61c66
+0xc00aa120
+0x007a8120
+0x028ca358
+0x025f2ca9
+0x01462526
+0xe8602000
+0x02004069
+0x02080fda
+0xa483e000
+0x0000a000
+0xa1903615
+0xa19036a6
+0x002719e3
+0xe8102000
+0x399139e3
+0xc28406a3
+0x00802ffa
+0x4100a358
+0x01462c6e
+0x12c61c66
+0xc014a120
+0xe6200000
+0x004a8120
+0x0298a358
+0x025f2fa9
+0x01462526
+0x02004069
+0x02080fda
+0xa483e000
+0xe1000080
+0x00804eb4
+0x0000a000
+0xa1903615
+0xa19036a6
+0x19e36c6e
+0x39e30027
+0x24393991
+0xc28406a2
+0xe7000900
+0x4100a358
+0x01462c6e
+0x12c61c66
+0x2526aa7a
+0x025f3228
+0x02004069
+0x81470146
+0xe9c09080
+0xa483e000
+0x0000a000
+0xa1903615
+0xa19036a6
+0x19e36c6e
+0x39e30027
+0x24393991
+0xee002400
+0xc28406a2
+0x4100a358
+0x01462c6e
+0x12c61c66
+0xa6a6a2aa
+0x22a60686
+0x020081a0
+0x00805969
+0xe7808800
+0xc0758120
+0x00900264
+0x02c2b82a
+0x0280406a
+0x170702ef
+0x00037d42
+0x018a2162
+0xe2000000
+0x92c78686
+0x030016a0
+0x18128646
+0x20402686
+0x00100264
+0x05347ec0
+0x00004000
+0xe1a00023
+0x00001362
+0x01828162
+0x85ea1226
+0x05866646
+0x0a12ae2a
+0x0a400506
+0xde36000c
+0xef808200
+0x2c6e2627
+0x00001362
+0x01838162
+0x1013aa0a
+0x002c19fa
+0x850aa43b
+0x0080ed6b
+0x052c0fd8
+0xe5208000
+0x0c6e1013
+0x05001fd8
+0x02343ec0
+0x9507000c
+0x2c6ede36
+0x00001362
+0x01888162
+0xe3200000
+0x00ac1fda
+0x002830fa
+0x99eb1027
+0x05a960f8
+0x15870c6e
+0xb17b5027
+0x84400686
+0xee808000
+0x6c6e000c
+0x00001362
+0x01838162
+0xab3a0606
+0x02019228
+0x02004168
+0x00100274
+0xe1208000
+0x00301362
+0x01828162
+0x4232a70a
+0x000cea40
+0x00042400
+0x0080a15c
+0x00041362
+0x01888162
+0xe3908000
+0x2640a30a
+0x0e65a120
+0x84400686
+0x6c6e000c
+0x00001362
+0x01868162
+0x07804452
+0xe1a08000
+0x053c33e4
+0x063c33e4
+0x073c52e4
+0x01bc52e6
+0x00006000
+0x008ca362
+0x00000000
+0x00000000
+0x042731f7
+0xbc0dbc05
+0x001069a0
+0x1c494c6e
+0x3022a120
+0x904f2527
+0x6683e000
+0xe5600400
+0x00010000
+0x00000000
+0x603c22e4
+0xac152410
+0x00804506
+0x6e59bc3d
+0x2c6e40c7
+0x00000000
+0xe7100000
+0x00034000
+0x6c6e71f7
+0x008ca362
+0x624631f7
+0x02413e28
+0x020040e8
+0x00100264
+0xe1400000
+0x0233602a
+0x0200406a
+0x00100362
+0x01860162
+0x02006800
+0x00004000
+0xa1ef71f7
+0xe8100000
+0x140731f7
+0x1746f347
+0xd24e4246
+0x001c1fd8
+0xd112a120
+0x2040a120
+0x03938828
+0xe0e00014
+0x0280a35a
+0x02a00428
+0x02815868
+0x00808954
+0x6c6e008c
+0xaa7a7002
+0x01b38628
+0x01804068
+0xe3008000
+0x021c0fd8
+0x000c1362
+0x01838162
+0x26916073
+0x86bb2c69
+0x9a1226d1
+0xa2400433
+0xef00a840
+0x1004c823
+0x88224012
+0x000482c6
+0x00e38120
+0x06a76626
+0x12c60c6e
+0xcfe2a120
+0xe6e00008
+0x03a01228
+0x03815869
+0x0023502a
+0x0a121184
+0x0024ea40
+0x8650030c
+0x2c6e8620
+0xef000000
+0x00140274
+0x0233602a
+0x00802ff0
+0x0341402a
+0x0200406a
+0x030040ea
+0x014d026f
+0x01886162
+0xe4000000
+0x029c1fdb
+0x0033502a
+0x001402f6
+0x001c59d8
+0xc059a120
+0xeff12760
+0x0480a358
+0xe4000000
+0x029cfdc0
+0x6c6e009c
+0x00044f58
+0x0433a57a
+0x93c7c823
+0x40121005
+0x82c68822
+0xef409100
+0x00100274
+0x00938120
+0x78824626
+0xc029a120
+0x08336028
+0x08004068
+0x00000000
+0xe0800000
+0x00401362
+0x00801d74
+0x01828162
+0x000077ab
+0x0224305a
+0x88bb8c69
+0x04a42058
+0xc8230433
+0xea00a000
+0x100582c7
+0x88224012
+0x000482c6
+0x00738120
+0x0f0c6626
+0xa1464c6e
+0x00140274
+0xe6e00008
+0x0480a358
+0xb02a0486
+0x001ff058
+0xcfbc8120
+0x0406eff1
+0xc062a120
+0x03938828
+0xe2408000
+0x8aa20292
+0x03a6502a
+0x0180a358
+0x0208ddc0
+0x6c6e000c
+0x00008f58
+0x0c6eaf6a
+0xea209002
+0x0080690c
+0x2590f812
+0x683a2c68
+0x100d8347
+0x6c6e25b0
+0xc8230013
+0x001402f6
+0x01b38628
+0xe3e08021
+0x01804068
+0x021c0fd8
+0x000c1362
+0x01848162
+0xc8230433
+0x100582c7
+0x66268cca
+0xee008200
+0x03336028
+0x03004068
+0x00000000
+0x00181362
+0x02001fd8
+0x01866162
+0x82c7a74a
+0xe8008000
+0x00541075
+0x01b38628
+0x01804068
+0x021c0fd8
+0x000c1362
+0x01868162
+0x01c605a6
+0x00801950
+0xe8200000
+0xcfb6a120
+0x71f70626
+0xa1ef6c6e
+0x01bc94f6
+0x06472b46
+0x04a016a3
+0x0407224e
+0xeac00300
+0x3059a120
+0x000509a0
+0x003d02b4
+0x00bd22b4
+0x02b3a02a
+0x0280406a
+0x00140362
+0x023d005a
+0x01844162
+0x27279346
+0x04000041
+0x03000128
+0xe92a0246
+0x0233602a
+0x0200406a
+0xe240800c
+0x1486026f
+0x01834162
+0x02010ca0
+0x03201228
+0x03015869
+0x0032502a
+0x008096df
+0xa4071104
+0xe8202000
+0x0298fdc0
+0x009c0526
+0x00044f58
+0x0433a5ba
+0x9347c823
+0x40121005
+0x82c68822
+0xef509100
+0x00100274
+0x003a8120
+0x0008a358
+0x00050f58
+0xc015a120
+0x0233602a
+0x0200406b
+0x02414028
+0x020040e9
+0x004c026f
+0x01836162
+0x2510ec72
+0x893a2c68
+0x04332520
+0x9347c823
+0xef409040
+0x40121005
+0x82c68822
+0x00100274
+0x00548120
+0x000ca358
+0x0080cf99
+0x02145ec0
+0x8886000c
+0xe8600004
+0x0e044c6e
+0x05262a46
+0xb0ea0146
+0x90aafe80
+0x0297e05a
+0x00265028
+0x05260104
+0xe9e08000
+0x6c6e008c
+0x00010f58
+0xc026a120
+0x0233602a
+0x0200406b
+0x02414028
+0x020040e9
+0xe0200000
+0x004c026f
+0x01826162
+0x2510ec72
+0x877a2c68
+0x04332520
+0x9347c823
+0x40121005
+0xefa08410
+0x82c68822
+0x850a0004
+0x000ca358
+0x02145ec0
+0x0080196e
+0x6c6e000c
+0x003d02b4
+0x01460526
+0xea608001
+0xcfd0a120
+0x0000a358
+0x01bc92e6
+0x4c6e8046
+0x008ca362
+0xb24631f7
+0xe347274e
+0xed003800
+0x00126256
+0x0320122a
+0x0301586b
+0x0105c822
+0x02d7202a
+0x0280406a
+0x00140362
+0xe1200002
+0x01826162
+0x020c6078
+0x03595028
+0x03004068
+0x02000daa
+0x00181362
+0x01878162
+0x03900fd8
+0xa13a03c6
+0x0383e058
+0x02d9502a
+0x0080a6c2
+0x001e84aa
+0x0280406b
+0x02ef2780
+0x0200a800
+0xe4208800
+0x000c1f82
+0x01840162
+0x0c6ec403
+0x90469247
+0x04100fd8
+0x02d9502a
+0x0280406a
+0xe1800040
+0xb87202ef
+0x00006ca0
+0x02012e80
+0x01852162
+0x84069247
+0x00118bd8
+0x858aa46a
+0xea208101
+0x8c2606a6
+0x000080f8
+0x028029a0
+0x03413e28
+0x030040e8
+0x01980274
+0x02d9502a
+0xe0200000
+0x0280406a
+0xba7302ef
+0x00800523
+0x02106ca2
+0x01852162
+0x02200fd8
+0x0000c680
+0x03595028
+0xe4400800
+0x01806801
+0x03004068
+0x00003ea8
+0x00181362
+0x62466402
+0x020c0800
+0x01892162
+0xe2000200
+0x020c1fda
+0x00100fd9
+0x02414028
+0x020040e8
+0x8a930004
+0x00f5c2d1
+0xaa411233
+0xee000000
+0x04a71075
+0x1015862f
+0x48221012
+0x00058641
+0x00558641
+0x00558641
+0x10958651
+0xefe00022
+0xa2410a13
+0x00807920
+0x0001ffaa
+0x86511005
+0x0a321095
+0x101492c0
+0xc8230433
+0x8e411105
+0xefa00002
+0x001002e6
+0x01bc52e6
+0x00006000
+0x008ca362
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x267731f7
+0x8cf78577
+0xbc051247
+0x764e8746
+0x025f5c28
+0x02004068
+0x420c001c
+0xe9e30060
+0x023d005a
+0x00152c6e
+0x001042d4
+0xfca7bc0d
+0x04e94c6e
+0x2110a120
+0x02395428
+0xe3400000
+0x0080c19e
+0x020040e8
+0xbc0d000c
+0x14696c6e
+0x301ca120
+0x88500812
+0x0c6e880a
+0x320d9047
+0xeec02204
+0x522d028c
+0x925d723d
+0x1429b24d
+0x64294429
+0x8429a429
+0x20c4a120
+0x01d80028
+0xe3e00000
+0x01804068
+0x00000428
+0x000c1362
+0x01886162
+0x05105dc1
+0x06278840
+0x0302fe28
+0xe4000c00
+0x8506bc0d
+0x50044c6e
+0x023c4d2a
+0x020040eb
+0x02050606
+0x02da002a
+0x0280406a
+0x0080b801
+0xe2620000
+0x050602ef
+0x0230a358
+0x01852162
+0xc60e8040
+0x022c1fda
+0x01a72628
+0x01804068
+0xe12000c0
+0x022c0fd8
+0x000c1362
+0x01838162
+0x0227b82a
+0x0200406a
+0x00100362
+0x01886162
+0x02000e28
+0x05866646
+0xd0c8a120
+0x08220012
+0x0c270204
+0xc4273204
+0x00108236
+0x0010a35a
+0xe3a20000
+0x0010a236
+0x00106254
+0x02b00028
+0x028040e8
+0x02148058
+0x01100334
+0x00803f55
+0xa20c821c
+0xe8012000
+0x0c6e6586
+0x022515c1
+0x009082b4
+0x0010a2b5
+0x8e2602c6
+0x020c8040
+0x022dc058
+0xe6660000
+0x00004000
+0x00100354
+0x921c8506
+0x0010a226
+0x00100334
+0x25865212
+0x92142240
+0xec810400
+0x0010a236
+0x00100354
+0x023c805a
+0x0586120d
+0x02401a12
+0x12040c6e
+0x02a7682a
+0xe7060000
+0x0280406a
+0xc31202ef
+0x01854162
+0x85866b22
+0x023d005a
+0x00801337
+0xde3a0246
+0x02a6e62a
+0xe54080c0
+0x0280406a
+0x4a3302ef
+0x01836162
+0x01a72628
+0x01804068
+0x022c0fd8
+0x000c1362
+0xe0400000
+0x01818162
+0x0058a120
+0x02a7682a
+0x0280406a
+0x031202ef
+0x01894162
+0x85866b22
+0xea003000
+0x02141fda
+0xd23a0246
+0x01a6e628
+0x01804068
+0x00b1c058
+0x000c1362
+0x00861008
+0xe0408000
+0x01824162
+0x02041fda
+0x0227262a
+0x0200406a
+0x00806dec
+0x00100362
+0x01876162
+0x022c0fd8
+0x001ca120
+0x02a7682a
+0x0280406a
+0x031202ef
+0x01864162
+0x85866b22
+0x023d005a
+0xaa3a0246
+0xea808300
+0x01a6e628
+0x01804068
+0x00b1c058
+0x000c1362
+0x00861008
+0x01874162
+0x02041fda
+0x0227262a
+0x0200406a
+0x00100362
+0x01846162
+0x022c0fd8
+0x07800852
+0x6677c577
+0x6c6e71f7
+0xec000000
+0x008ca362
+0x31f73577
+0x85778677
+0x00806506
+0xaa0c8a1c
+0x00006000
+0x03840018
+0x00b00028
+0xe1c20000
+0x008040e8
+0x0a0c84d0
+0x90c702ac
+0x06048058
+0x0c6e44c6
+0xa9ba0568
+0x2a0cb20d
+0xeec09004
+0x14686c6e
+0xd20da5ba
+0x14684a0c
+0xf20da5ba
+0x14686a0c
+0x1a0da5ba
+0x14688a0c
+0xeff08888
+0x3a0da1ba
+0x6c6eaa0c
+0xf92a1468
+0x22d08a92
+0x6c6e008c
+0xf93ae468
+0x0010e204
+0xe7e08002
+0x00910204
+0x0239502a
+0x00806bb6
+0x020040ea
+0x76464647
+0x00002018
+0x06504005
+0x01140334
+0xe5000000
+0x829ca28c
+0x00002000
+0x011003d4
+0x8215a205
+0x00106204
+0x08a20092
+0x04e82c6e
+0xed210000
+0xd078a120
+0x0227b82a
+0x0200406a
+0x00100362
+0x01866162
+0x02000e28
+0x0686a646
+0xe8000000
+0xd0a4a120
+0x08220012
+0x00100254
+0x0020a35a
+0x00102256
+0x9204c427
+0xa2048426
+0xec400000
+0x28230013
+0x0080d322
+0x00106256
+0x022c8606
+0x00908224
+0x0010a225
+0x0c6e6686
+0x022515c1
+0xeca60000
+0x009082b4
+0x0010a2b4
+0x0229905a
+0x001003b6
+0x0235c058
+0x12044c6e
+0x122d9587
+0xec060000
+0xb20d921d
+0x52120686
+0x02100078
+0x01100356
+0xb2049214
+0x0291005a
+0x001403b6
+0xe2610004
+0x02401a12
+0x12042c6e
+0x01a76828
+0x01804068
+0x03000328
+0x000c1362
+0x01896162
+0xe0660000
+0x0080c202
+0x86866b22
+0xd53a0246
+0x02a6e62a
+0x0280406a
+0x4a3302ef
+0x01866162
+0x01a72628
+0xe2608001
+0x01804068
+0x02340fd8
+0x000c1362
+0x01848162
+0x00a80fdb
+0x0002fd2a
+0x120d00c1
+0xe8120000
+0x305ca120
+0x0227b82a
+0x0200406a
+0x00100362
+0x01866162
+0x02001fd8
+0x05064646
+0xe8000000
+0xd024a120
+0x02da002a
+0x0280406b
+0x023c4d28
+0x020040e9
+0x026c02ef
+0x018a4162
+0x0080b957
+0xe4020000
+0x0229805b
+0x02280fd8
+0x02a7682a
+0x0280406a
+0x031202ef
+0x01894162
+0x85066b22
+0xea003000
+0x02280fda
+0xa1aa0246
+0xfe268b4a
+0x2a22be72
+0x869cb506
+0x01a6e628
+0x01804068
+0xe3c28280
+0x02000fd8
+0x000c1362
+0x01850162
+0x30e2ccae
+0x90c70c6e
+0x2a22be72
+0x0427b506
+0xef001800
+0x00148a56
+0x0227262a
+0x0200406a
+0x00100362
+0x01866162
+0x02280fd8
+0x0080c4f3
+0xc5770626
+0xe8000000
+0x71f7c677
+0x75774c6e
+0x008ca362
+0x01bc54f6
+0x02d8002a
+0x0280406a
+0x00140362
+0xe0600000
+0x02395028
+0x0302fe28
+0x01852162
+0x020040e9
+0x0200a35a
+0x6c6e71f7
+0x008ca362
+0xe4000000
+0x522631f7
+0x858aa1ba
+0x0200a358
+0x00118ad8
+0x858aa33a
+0x027ca358
+0x0246002a
+0xe2608000
+0x0200406a
+0x00100362
+0x01838162
+0xa1ef71f7
+0x857731f7
+0x0080acc0
+0x05800028
+0x05804168
+0xe3100000
+0x420c8586
+0x052c0fd8
+0x20264c6e
+0xd018a120
+0x02caf42a
+0x0280406b
+0x03110206
+0xe0a30000
+0xc26c02ef
+0x02108206
+0x01844162
+0x0200a358
+0x05861a12
+0x02100078
+0x00100244
+0xe2220101
+0x20266c6e
+0xd010a120
+0x01cbac28
+0x01804068
+0x0208a358
+0x000c1362
+0x01888162
+0xe0200000
+0x05068a32
+0x020c0240
+0xa4ba2026
+0x01cbac28
+0x00800aae
+0x01804068
+0x0204a358
+0x000c1362
+0xe0f38001
+0x01818162
+0x71f7c577
+0xa1ef6c6e
+0x0000a358
+0x00001688
+0x85ba8c68
+0x0084a358
+0xe4c08000
+0x00400028
+0x000044e8
+0xa8ea8c48
+0x007fffa8
+0x00006fe8
+0xa53a8c68
+0x00400028
+0xe4808000
+0x00007068
+0xa4ea8c48
+0x007fffa8
+0x000077e8
+0xa4ba8c68
+0x00400028
+0x00007868
+0xe2408000
+0xa0ea8c48
+0x00c604a6
+0xa1ef8046
+0x008074a8
+0x424631f7
+0x0239562a
+0x0200406a
+0x00100362
+0xe1e08000
+0x01818162
+0xa33a0246
+0x004403e2
+0x0c6e1c03
+0x00005ff8
+0x01039c88
+0x814671f7
+0xe9408000
+0xa1ef4c6e
+0x01bc54f6
+0x053c22f4
+0x0200002a
+0x0200416a
+0x92401a52
+0x10044c27
+0xec202800
+0x04265646
+0x90472004
+0x0010801a
+0xc2045004
+0x80042426
+0x02d8002a
+0x0280406a
+0xe3620000
+0x1a7202ef
+0x00280fd8
+0x0080421e
+0x01842162
+0xd7120240
+0x18722506
+0x4c272040
+0x58631204
+0xef201540
+0x32045c53
+0x5214a8f3
+0x6204b012
+0xb2049224
+0x8452d214
+0x1a24e204
+0x5a143a04
+0xefe00000
+0x6a042426
+0x02df4628
+0x02804068
+0xf013028c
+0x901036d1
+0x88baece0
+0x25260304
+0xef218000
+0x90c70146
+0xa283e000
+0x00002000
+0xa01436a6
+0xc01036b7
+0x0c6ec966
+0x0c6e0146
+0xec300001
+0x00034000
+0x00800aec
+0x60920012
+0x85068af2
+0x5482b022
+0x009482d0
+0x00144274
+0x03838028
+0xe3c400a0
+0x03815468
+0x4f50018c
+0x00004000
+0x000319a2
+0x00140236
+0x000219a2
+0x00142236
+0xe0400000
+0x000119a2
+0x62845284
+0x010c87e0
+0x008309a0
+0x14428294
+0x0f12a284
+0x9012a360
+0xeed01000
+0x0c530104
+0x12410823
+0x12050813
+0x13515c33
+0x02850032
+0x6402ec32
+0x008456d0
+0xefe20888
+0x00806346
+0x0086702a
+0x004245aa
+0x00a14c6a
+0x0021bc6b
+0x1015c6c1
+0x032080a8
+0x03c8a028
+0xe2040000
+0x03218c69
+0x82d10a93
+0x03a00c68
+0x039403f4
+0x004245aa
+0x0086702a
+0x0021bceb
+0xe0400008
+0xb2d00a92
+0x00a14cea
+0x00940376
+0x012080a8
+0x01c8a028
+0x00800428
+0x01218ce8
+0xe0200002
+0x01a00ce9
+0x0134a0e0
+0x42042426
+0x24269892
+0x94f30814
+0x104708a3
+0x00904376
+0x0080e50d
+0xe7c70440
+0x82d01a92
+0x02842012
+0x00154254
+0x0044192a
+0x000029ea
+0x00122276
+0x00039daa
+0xe0620002
+0x00158276
+0x002de928
+0x00239268
+0x0015a274
+0x006e222a
+0x000092ea
+0x0015c276
+0x000c8328
+0x00280068
+0x1013e884
+0x12412823
+0x00052426
+0x79046427
+0x28238033
+0x08131241
+0xefc01020
+0x00531005
+0x00131341
+0x10056823
+0x20050052
+0x00134005
+0x70054823
+0x0080ce6e
+0x90058427
+0xefe00004
+0x0004a35a
+0x001142d6
+0xd015d093
+0xf0151093
+0x08050426
+0x80c180b3
+0x1215fcf3
+0xef800800
+0x32153047
+0x42051032
+0x001042d6
+0x053c22e4
+0x6c6e71f7
+0x008ca362
+0x02838028
+0xe2600000
+0x02815468
+0x2c6e008c
+0x009c86d0
+0x010309a0
+0x01100234
+0x000219a2
+0x00102236
+0xe0c00000
+0x010109a0
+0x62044224
+0x000719a2
+0x00108236
+0x000609a0
+0x0080ed2e
+0xa1efa204
+0x01bc54f6
+0xe4400000
+0x00000028
+0x02002028
+0x00004168
+0x20460240
+0xa5ba020c
+0x025c102a
+0x0200406a
+0xe3138080
+0x8252026f
+0x01834162
+0x02102078
+0xa1ef71f7
+0x01bc54f6
+0x02d5282a
+0x0280406a
+0xe1300000
+0x00140362
+0x01836162
+0x0627ce26
+0x01d51428
+0x01804068
+0x0238a358
+0x000c1362
+0xe0800010
+0x01818162
+0x0200a358
+0x01bc52e6
+0x00006000
+0x0080d496
+0x008ca362
+0x00000000
+0x00000000
+0x00000000
+0xa1ef0626
+0x267731f7
+0x053c35c4
+0x07bf005a
+0x014cc246
+0xa4bab226
+0x01568120
+0xe6708000
+0x027ca358
+0x02b94828
+0x028040e8
+0x8446848c
+0x02b94c28
+0x028040e8
+0x4446848c
+0xe9100000
+0x08239073
+0x10400606
+0x00042012
+0x0c6e0606
+0x100d1041
+0xa77b6c6e
+0x46062427
+0xefe09008
+0x2283e000
+0x0000ba28
+0x02080078
+0x00802df0
+0x20900264
+0x2c6e10c7
+0x1c660c6e
+0x00728546
+0xee100000
+0x26060822
+0x00ca04a6
+0x60130014
+0x06062c03
+0x40ce1040
+0xd86f8427
+0x0c670146
+0xefe00905
+0x1c670c04
+0x30324046
+0x2606a402
+0x842700c0
+0xd86f0146
+0x0c040c67
+0x0c6e1c67
+0xefe01110
+0x38130606
+0x1041c403
+0xd86fe427
+0x0ee7a247
+0x1c051c8d
+0x06061ce6
+0xa4037033
+0xeff00821
+0xe4271041
+0xa247d86f
+0x00809035
+0x1c8d0ee7
+0x1ce61c05
+0xa1920033
+0xcc210d82
+0x26b20606
+0xeff01804
+0x18779591
+0x6682d96f
+0x18f60526
+0xa04a0ce7
+0x60403041
+0x10050014
+0x24901ce6
+0xefe0369f
+0x84460024
+0x64022432
+0x04262606
+0x074000ca
+0x84270004
+0xd86fcc01
+0x4e0c0ce7
+0xefe000a8
+0xe41a4c6e
+0x04a89c66
+0x30470c6e
+0x00300fd8
+0x0002822a
+0x10151041
+0x0b1c2b0c
+0xece00004
+0x66069c20
+0x0080f1b9
+0x0c0241c0
+0x00002ff8
+0x00027488
+0x10130004
+0x08230606
+0x00131041
+0xee601200
+0x06a71005
+0x08230013
+0x02cf1041
+0x1c531005
+0x10410823
+0x100502cf
+0x08239c53
+0xefe00211
+0x02cf1041
+0x08121005
+0x26060822
+0xfc7200c0
+0x46060004
+0x21408cb2
+0x26060004
+0xefe00251
+0x10c18c13
+0x06060005
+0x10419c33
+0x100502cf
+0x850e12c6
+0x00100274
+0x0239862a
+0xe3e00120
+0x0080100f
+0x0200406a
+0x00100362
+0x05b64c28
+0x058040e8
+0x01862162
+0x022c0fd8
+0x850e0246
+0xe8001000
+0x00102274
+0x0002f728
+0x00124004
+0x6004b822
+0x0b930586
+0x039c12fb
+0x01850506
+0xeb800000
+0x0000a358
+0x00109274
+0x20044646
+0x50041047
+0x97c07004
+0x0004050e
+0x860624a7
+0xef801200
+0xb0143014
+0x06060073
+0x10410823
+0x00301028
+0x118d0005
+0xa4023032
+0x00c02606
+0x0080a4ce
+0xeee00024
+0x00100276
+0x03b9442a
+0x038040ea
+0x80131185
+0x08230606
+0x10151041
+0x10418c01
+0xef002080
+0xa8220012
+0x001002f4
+0x0241702a
+0x0200406a
+0x00100362
+0x005f362a
+0x0000406a
+0xe0200000
+0x01822162
+0x003c22f6
+0x0200a358
+0x07bd005a
+0x6677c577
+0x6c6e71f7
+0x008ca362
+0xe6000000
+0x267731f7
+0x67468577
+0x6c6e004c
+0xa33ab226
+0x00618120
+0x027ca358
+0x0080a6ed
+0x02b94828
+0xe1e08000
+0x028040e8
+0x9446948c
+0x00530586
+0xa2bb1c29
+0x64460052
+0x02364a28
+0x020040e8
+0xe3d08000
+0x6c6e000c
+0x85064446
+0x00040012
+0x02b9862a
+0x0280406a
+0x00140362
+0x01896162
+0xe0e00008
+0x02101fd8
+0x85061247
+0x05863004
+0x00104274
+0x0003bf88
+0x60136004
+0x39130313
+0xecc00004
+0x36072c03
+0x050600c1
+0xbb232112
+0x01460005
+0xf607c503
+0x00805de8
+0xa583e000
+0x43c1cc6e
+0xebe001dd
+0xa29002e6
+0x00006000
+0xc19462e6
+0xc5996c6e
+0x5100a358
+0x01460c6e
+0x1c660c6e
+0xed000000
+0xc5778586
+0x71f76677
+0xa1ef6c6e
+0x267731f7
+0xc2478577
+0x6c6e004c
+0xa53ab226
+0xefe08000
+0x00538120
+0x027ca358
+0x02b94828
+0x028040e8
+0x84c6849c
+0x30330606
+0x1041a403
+0xee100400
+0x001002e6
+0x0239442a
+0x020040ea
+0x6c6e101d
+0x00800197
+0xa37b04e9
+0x00438120
+0x70320626
+0xeb008000
+0x4606a402
+0x000c0140
+0x85866446
+0xfc42600c
+0x8c8aa32a
+0x0500a358
+0xa4037033
+0xebf08001
+0x30400586
+0x85860004
+0x6c6e600c
+0x44461062
+0x0002f728
+0x00124004
+0x6004b822
+0xede00000
+0x02da002a
+0x0280406a
+0x304c02ef
+0x01854162
+0xc50e9346
+0xa4023032
+0x00c02606
+0xee802900
+0x0004058e
+0xc5778506
+0x71f76677
+0x00807fcd
+0xa1ef6c6e
+0x00000000
+0x00000000
+0x00000000
+0xe1e00000
+0x867731f7
+0x053c35c4
+0x07ffec52
+0x96464646
+0x501d9507
+0x0210a35a
+0x023d9058
+0xe3200000
+0x00ef2c6e
+0x01828162
+0x001008d8
+0xc1eca120
+0x003c62e6
+0x00a124aa
+0x00aa24ea
+0xe0200000
+0x04e92c6e
+0x31dca120
+0x0229802a
+0x022124ea
+0xb6460c6e
+0x0580a358
+0x501d9507
+0xea200000
+0x0210a35a
+0x023d9058
+0x0080809d
+0x00ef2c6e
+0x01848162
+0x001008d8
+0xc1cca120
+0x00bc62e6
+0xe0800000
+0x007f802a
+0x04894c6e
+0x00341a7a
+0x31bca120
+0x00bc62e6
+0x0134305a
+0x29014c6e
+0xe8400000
+0x00006bda
+0xdc73a23b
+0x24694001
+0xa68aac6b
+0x00260228
+0x000492e9
+0x00044ca2
+0xe1c08000
+0x00e0f42a
+0x0080406b
+0x20411801
+0x6c6e100d
+0x0080a362
+0x01c17028
+0x01804068
+0xe1800000
+0x003c62e6
+0x0080dfca
+0x000c1362
+0x00dee82a
+0x0080406a
+0xdc05bc15
+0x01860162
+0x01968120
+0xe2000000
+0x9507fe26
+0x8627501d
+0x023d9058
+0x00ef2c6e
+0x01858162
+0x001008d8
+0xc17ca120
+0xe1600000
+0x025efbaa
+0x0241702b
+0x02900fda
+0x0200406a
+0x00100362
+0x0280406a
+0x76c602c7
+0xe8000000
+0x003c22f6
+0x01820162
+0x01c17028
+0x01804068
+0x005f0b28
+0x000c1362
+0x00004068
+0x01894162
+0x0080ae94
+0x003c22f4
+0x01c17028
+0x01804068
+0x003c62e6
+0x000c1362
+0x00df14aa
+0x0080406a
+0x00bc22f6
+0x003c42f6
+0x01820162
+0x01c17028
+0x01804068
+0x002c1fda
+0x000c1362
+0x01886162
+0x003c22f6
+0x9607fc0d
+0x10054c6e
+0x64462426
+0x0130a120
+0x500d9507
+0x86368627
+0x006f2c6e
+0xeee00000
+0x01818162
+0x001008d8
+0xc11ca120
+0x500d9507
+0xe6364627
+0x006f2c6e
+0x01888162
+0x008006d5
+0xe7000000
+0x001008d8
+0xc10ca120
+0x500d9507
+0x0e364627
+0x006f2c6e
+0x01868162
+0x001008d8
+0xe3800000
+0xc0fca120
+0x500d9507
+0x2e368627
+0x006f2c6e
+0x01858162
+0xff2a5226
+0x500d9507
+0xedc08000
+0x4e368627
+0x006f2c6e
+0x01838162
+0xfb2a5226
+0x501d9507
+0x0210a35a
+0x023d9058
+0xe3608000
+0x00ef2c6e
+0x01828162
+0xf72a5226
+0x9507f80a
+0x4627500d
+0x2c6ee636
+0x00801887
+0x00000362
+0xe7a08000
+0x01818162
+0xf32a5226
+0x500d9507
+0x0208a35a
+0x12000fdc
+0x006f2c6e
+0x01888162
+0xe4c08000
+0xef2a5226
+0x003de286
+0x00006000
+0x000089da
+0x30bca120
+0x003de286
+0x00c12e2a
+0xe0208000
+0x008040ea
+0x00002000
+0x02041e42
+0x6c6e100d
+0x006feb3b
+0x01868162
+0x9507ec0a
+0xeb008000
+0x8627500d
+0x2c6e8636
+0x00000362
+0x01848162
+0xe72a5226
+0x0080dd8f
+0x500d9507
+0xa6368627
+0xee608000
+0x006f2c6e
+0x01828162
+0xe32a5226
+0x500d9507
+0xc6368627
+0x006f2c6e
+0x01888162
+0xe7a08000
+0xdf2a5226
+0x500d9507
+0xe6364627
+0x006f2c6e
+0x01858162
+0xdf2a5226
+0x500d9507
+0xede08000
+0x0208a35a
+0x12000fdc
+0x006f2c6e
+0x01848162
+0xdb2a5226
+0x500d9507
+0xbccd8ccd
+0xee808000
+0x006f2c6e
+0x01828162
+0xd72a5226
+0x003de286
+0x0080badd
+0x000089da
+0x305ca120
+0x003dc286
+0xe0b08000
+0x000089da
+0x3026a120
+0x003de286
+0x00c12c2a
+0x008040ea
+0x00002000
+0x02041e42
+0x001022e6
+0xaf2b6c6e
+0x30059c8d
+0x003dc286
+0x001022d6
+0x003de286
+0x001002d6
+0x9507d00a
+0xe8708000
+0x8627500d
+0x2c6e8636
+0x00000362
+0x01848162
+0xab2a5226
+0x500d9507
+0xa6368627
+0xee608000
+0x006f2c6e
+0x01828162
+0xa72a5226
+0x00806b24
+0x500d9507
+0xc6368627
+0x006f2c6e
+0x01888162
+0xe7a08000
+0xa32a5226
+0x500d9507
+0xbccd8ccd
+0x006f2c6e
+0x01858162
+0xa43a5226
+0xfe26858a
+0xede08000
+0x002c0fd8
+0xde2ca120
+0x0200a358
+0x07801452
+0xc677c577
+0x6c6e71f7
+0x008ca362
+0xe6000000
+0xf24ea246
+0xedaa83bc
+0x000f1008
+0x04260120
+0x20466284
+0x000848d8
+0xc026a120
+0xe3720001
+0x000d0da0
+0x018f1008
+0x0080ded8
+0x0c6e6000
+0x0c6e3c0b
+0xd86f1046
+0x01081ac0
+0x0c662c6e
+0xeb800000
+0x4c6e0e0c
+0x5c670c6e
+0x00840078
+0xb00ca120
+0x6c6e020c
+0x00901862
+0x442783c6
+0xee620008
+0x0c67d86f
+0x4c6e0e0c
+0x5c670c6e
+0x0c6e0090
+0x000619a2
+0x100010e2
+0x00000000
+0xe5e20020
+0x000219a2
+0x05261062
+0x01080f89
+0x25681010
+0xc00ca120
+0x0087edd8
+0xa1ef6294
+0xe9420004
+0x31f73577
+0x00803818
+0x85778677
+0x46478cf7
+0x224e8746
+0x01411828
+0x00046ca0
+0x00003c41
+0xe1e00060
+0x010040e8
+0x020c4040
+0x05804078
+0xe37a6c6e
+0x0227b82a
+0x0200406a
+0x0606026f
+0xe9428008
+0x00038940
+0x01832162
+0xa44e8046
+0x05064646
+0xd07da120
+0x01da0028
+0x01804068
+0xe1800010
+0x02000e28
+0x000c1362
+0x01856162
+0x85070240
+0x033006a0
+0x020c8586
+0x4c6e8506
+0xed0200c0
+0x0080f3e5
+0x00831008
+0x000119a2
+0x5a041081
+0x220c8586
+0x4c6e8506
+0x008109a0
+0x00031008
+0xe3820000
+0x6a040080
+0x0c6e0606
+0x0400f40b
+0x00040052
+0x0002180b
+0x00021808
+0x10010c03
+0xe8e20020
+0x10639a04
+0x02300628
+0x020040e8
+0xac05000c
+0x200c8586
+0x04a7cc05
+0x00bdc2b6
+0xe7320001
+0x008008aa
+0x00bde2b6
+0x003cc2d6
+0x01bf8028
+0x01804068
+0x02000a28
+0x000c1362
+0x0080c5e0
+0x00280fd8
+0x01834162
+0x023c805b
+0x02100078
+0x200c8586
+0x4c6e8506
+0x3a148004
+0x02c6d22a
+0xe7000000
+0x0280406a
+0x068602ef
+0x00021008
+0x01852162
+0x02001fda
+0x00108120
+0xfe268606
+0xe8400000
+0x07800852
+0xc677c577
+0x4c6e71f7
+0xa1ef7577
+0x218ce246
+0xae3a6c6e
+0x6c6e238c
+0xefc28000
+0x038caa3a
+0x418caa3a
+0xd028a120
+0x02411228
+0x020040e9
+0x8e2665a6
+0x0080c8d9
+0x82c0a24e
+0xec72a800
+0x21129d81
+0xa403e000
+0x00008000
+0xa290d604
+0x03140a58
+0x7b6eedb0
+0x40c6c598
+0xec300401
+0x0c6e2c6e
+0x24011c66
+0x62ba0346
+0x8ad08ea6
+0xfe2684ca
+0x01bc439c
+0x42944c6e
+0xefe48004
+0x01940374
+0xa1ef9046
+0x522631f7
+0xc022a120
+0x001088d8
+0xd022a120
+0x01d80028
+0xe0c00000
+0x01804068
+0x0041182a
+0x000c1362
+0x000040ea
+0x00106ca0
+0x008088b6
+0x00009c40
+0x01890162
+0x02001079
+0x8b120627
+0xa1ef71f7
+0x01bc94f6
+0x9012c246
+0x0400c078
+0x00182204
+0x008109a0
+0xe1700001
+0x00031008
+0x00040078
+0x000289c0
+0x00021008
+0x000109d8
+0xab0cdaea
+0x611cad3a
+0xec128000
+0x811cac15
+0x0427cc15
+0x003dc2b6
+0x000008aa
+0x003de2b6
+0x00998204
+0x00bcc2d4
+0xe0700000
+0x04800fd8
+0x02bf802a
+0x0280406a
+0x00140362
+0x00809318
+0x01876162
+0x02200fd9
+0x023c805a
+0x0019a204
+0x4c6e2486
+0xaefa2468
+0x220c8406
+0x02411828
+0x020040e8
+0x0c6ea246
+0x00831008
+0xe4e28000
+0x20100c42
+0x06260c6e
+0x6c6e028c
+0xa97a04e8
+0x438ce406
+0x039240dc
+0x2c6e0ba2
+0xefe28000
+0x039c0e81
+0x00141362
+0x008109a0
+0x001e1808
+0xe4060c02
+0x0c600080
+0x01890163
+0xe6000900
+0x021d105a
+0x000c8120
+0x26400626
+0x0080cbb8
+0x001068d8
+0xcfe48120
+0xfe268eae
+0x01bc92e6
+0xe4900000
+0x008ca362
+0x01bc54f6
+0x02d8002a
+0x0280406a
+0x00140362
+0x02411828
+0x03001228
+0x018a2162
+0x020040e9
+0x0200a35a
+0x01bc52e6
+0x00006000
+0x008ca362
+0x00000000
+0x00000000
+0x00000000
+0x07bc1fd9
+0x0c6e27f7
+0x07bc1fdb
+0x07bc0264
+0x008ca362
+0x857a0246
+0x0080a358
+0xe4408000
+0x000169d8
+0xd005a120
+0x0080f1d6
+0x00c624a6
+0xa1ef8046
+0x252631f7
+0xc5a70146
+0x0213f1a2
+0xe7800c00
+0xa483e000
+0x26418c6e
+0xa2900296
+0x02a76c6e
+0xedb1f867
+0x0599786f
+0xc30006a2
+0xe7400a00
+0x5100a358
+0x01460c6e
+0x00000000
+0x00034000
+0x0c6e0327
+0x02003dd8
+0xa1ef71f7
+0xea500000
+0x357727f7
+0x277731f7
+0x85778677
+0x01d80028
+0x01804068
+0x0501802a
+0x000c1362
+0xe0e00000
+0x0500416a
+0x00803338
+0x01844162
+0x06279506
+0x03006028
+0x000f5daa
+0x006760eb
+0x10049506
+0xe8802030
+0x07a81fd8
+0x01d23628
+0x01804068
+0x00000000
+0x000c1362
+0x01868162
+0x01b57a28
+0x01804068
+0x020038a8
+0x000c1362
+0x4f272a22
+0x01852162
+0x8372c627
+0x02b4b62a
+0x0280406a
+0xe2800100
+0xbe7202ef
+0x05000029
+0x13539253
+0x04008028
+0x05004169
+0xc5062a23
+0x01890163
+0xe4a00820
+0x00809242
+0x02110ca0
+0xec2a0246
+0x00280fd8
+0x00017ec0
+0x44278446
+0x0580a358
+0x06801fd8
+0xe2408000
+0x02417a2a
+0x0200406a
+0x8606026f
+0x02100264
+0x01856162
+0xaaba0246
+0x0241882a
+0xe4808010
+0x0200406a
+0x00100362
+0x00296078
+0x00823ec0
+0x01862162
+0x02040fd8
+0xa6ba0246
+0xe8008000
+0x01badc28
+0x01804068
+0x02040fd8
+0x000c1362
+0x01858162
+0x36875587
+0x01111c33
+0x0080f859
+0xec002800
+0x0007e1a2
+0x10462606
+0xcfd06120
+0xb44674c6
+0x0606fec0
+0x0239082a
+0x0200406a
+0xe1400080
+0x00100362
+0x01828162
+0x01bafc28
+0x01804068
+0x00000000
+0x000c1362
+0x01878162
+0x0004a358
+0x25068446
+0x06857ec1
+0x07300fd8
+0x0580a358
+0x000c8686
+0x00380a78
+0xd01aa120
+0xe2300000
+0x01b02c28
+0x01804068
+0x022c0fd8
+0x000c1362
+0x01858162
+0x1c324696
+0x00803176
+0x00ac2058
+0xe4000c00
+0x008801e1
+0x000448d8
+0xa4c69a2a
+0x05ac21a0
+0x02010828
+0x02004168
+0x2706000c
+0xe8808020
+0x04e84c6e
+0xd010a120
+0x01d8e028
+0x01804068
+0x00000000
+0x000c1362
+0x01888162
+0xe0200000
+0x07860a12
+0x000c0240
+0x00042400
+0x06302058
+0x003148d8
+0xdfbea120
+0x0fc1a120
+0xe0f00001
+0x000888a9
+0x84c02786
+0x000888e8
+0xa1ca0004
+0x857731f7
+0x008057a8
+0x07bf005a
+0x674e4646
+0xeb40b008
+0x04a70247
+0xaa2bbc15
+0x8627901c
+0x023d1058
+0x00ef2c6e
+0x01868162
+0x01d64c28
+0xe2e08000
+0x01804068
+0x023c8284
+0x000c1362
+0x01848162
+0xa5ea0246
+0x02018c28
+0x02004168
+0xe2008000
+0x6c6e000c
+0x00042400
+0x00608120
+0x64270626
+0x204fcc11
+0x00048bda
+0x201aa120
+0xe3600200
+0x0c01448b
+0x0060ea28
+0x00004068
+0x000c1040
+0x008025fc
+0x0080b362
+0x02019028
+0x02004168
+0xe1300002
+0x2400000c
+0xaf8a0004
+0x01d0e028
+0x01804068
+0x02280fd8
+0x000c1362
+0x023c805a
+0xe0708000
+0x01816162
+0x0017a120
+0x01d87028
+0x01804068
+0x02280fd8
+0x000c1362
+0x023c805a
+0x032c0fd8
+0x01814162
+0x000fa120
+0x01d67428
+0x01804068
+0x02280fd8
+0x000c1362
+0x023c805a
+0x01886162
+0x0007a120
+0x01bd7028
+0x01804068
+0x0080020b
+0x02280fd8
+0x000c1362
+0x023c805a
+0x01876162
+0x023c22e4
+0x07bd005a
+0x053c33e4
+0x01bc52e6
+0x00006000
+0x008ca362
+0x00000000
+0x00000000
+0x00000000
+0x024631f7
+0x0247834e
+0xa356a24f
+0xea3bea3a
+0xea3b12c7
+0x122d021c
+0x186354c9
+0xeff0841e
+0x320dc047
+0x15c9223c
+0x423c1863
+0x35d9521d
+0xe24798e3
+0x0c6e80c6
+0x78e35659
+0xeff00022
+0x424f05b9
+0x00844ffa
+0x0080e588
+0x400aa120
+0x00d88120
+0x0200a358
+0x008c29a2
+0xb0d264d9
+0xe8200001
+0xb1d23498
+0x008c2a78
+0x901aa120
+0x008029a2
+0x21c604d9
+0x25f83498
+0x901aa120
+0xe6200001
+0x008829a2
+0x90d244d9
+0x91d23498
+0x008c2a78
+0x806ba120
+0xa42a1346
+0x05a78a4a
+0xecc08010
+0x00b32347
+0x01042d5a
+0x04262911
+0x01180fda
+0x01082f5a
+0x700da120
+0x43472400
+0xe8a00012
+0x030af80a
+0x0080de80
+0x0087e05a
+0x4ff6a120
+0x0c6e1862
+0xa8bb7047
+0x01002d5b
+0x291100b3
+0xeb00a000
+0x000c1fd8
+0x01002f5a
+0x7004a120
+0x00002058
+0x0002f80a
+0x0087e05a
+0x4001a120
+0x00031808
+0x70470c6e
+0xa67b03c7
+0x00802d5b
+0x08810033
+0x23c711c6
+0x00842f5a
+0x5011a120
+0xe3608080
+0x23c72400
+0x0386f80a
+0xbe6bec01
+0x0c6e1862
+0x21a77047
+0x82c7a63b
+0x82c60245
+0xefa08000
+0x0080b7d0
+0x2205220c
+0x4205420c
+0x00588120
+0x0200a358
+0x00588120
+0x0592fe26
+0x31c70c6e
+0xec700000
+0x84a778e3
+0x062721c6
+0x01180fda
+0x01045f7a
+0x700ca120
+0x02106ffa
+0x0086d808
+0xe0600000
+0x018ef80a
+0x0087e05a
+0x4ff4a120
+0x39e29a63
+0x0090a35a
+0x01041f7a
+0x7012a120
+0xe1000000
+0x02106ffa
+0x0086d808
+0x018ef80a
+0x0087e05a
+0x4ffaa120
+0x98e23246
+0x642739e2
+0x00800c76
+0xec000000
+0x062785a7
+0x349923c7
+0x5008a120
+0x02106ffa
+0x0086d808
+0x018ef80a
+0xa0abec01
+0xe8608000
+0x3a63061c
+0x24632427
+0x34580c6e
+0x06260614
+0x6c6e71f7
+0x31f7a1ef
+0x8346b247
+0xefe01000
+0x0c6e0592
+0x786311c7
+0x41c684a7
+0x001204a6
+0xa33b6609
+0x00004ff8
+0x010af808
+0xe3e08040
+0xa13b6689
+0x00844ff8
+0x010af808
+0x018ef80a
+0x0087e05a
+0x4ff8a120
+0x00808502
+0xb8622428
+0xe8208000
+0x042659e2
+0x84a70092
+0xa23b6609
+0x00004ff8
+0x010af808
+0xa43b6689
+0x00844ff8
+0xe4e08006
+0x010af808
+0x018ef80a
+0x0087e05a
+0x4ff4a120
+0x24280254
+0x71f72204
+0xa1ef6c6e
+0xee000000
+0xc24731f7
+0x00900fd8
+0x9008a120
+0xa2ea1346
+0x00668120
+0x0427fe26
+0x32055205
+0xed208002
+0xe0c61205
+0x04802028
+0x025e0028
+0x02004069
+0x08230013
+0x0080a9ea
+0x07a7c246
+0x0400a359
+0xe6200a03
+0x01930192
+0x0fcc1af6
+0x4c6e53c6
+0x6c6ec61c
+0x00075a08
+0x0c6e0548
+0x03801fda
+0xe5e00003
+0x00052f78
+0xd00aa120
+0x018c7dfa
+0x04206df9
+0x0297e2a0
+0x9cebec01
+0x018c2058
+0xe4008000
+0x02c44b2a
+0x0280406a
+0x00140362
+0x00150df8
+0x020f180a
+0x01882162
+0xd3469862
+0xe8001000
+0x120d8347
+0x0003edda
+0x320d1205
+0x0003edda
+0x00807d27
+0x13c63205
+0x00004ca0
+0x0003edd8
+0xe2b00000
+0x00006fd8
+0x001042b4
+0x0200a358
+0x01bc52e6
+0x00006000
+0x008ca362
+0x00000000
+0x00000000
+0x042731f7
+0xbc0dbc05
+0x4c6e80f3
+0xa83b0cc9
+0x82732527
+0x6683e000
+0x00010000
+0xe3e08100
+0x00000000
+0x603c22e4
+0xac152410
+0x6e59bc3d
+0x2c6e40c7
+0x00000000
+0x00034000
+0xe3900000
+0x71f70626
+0xa1ef6c6e
+0x242631f7
+0x0080a97a
+0x010031a8
+0x01808ce0
+0x0280a358
+0x02009428
+0xe0e00020
+0x02015768
+0x6c6e000c
+0xa53a0588
+0x0245002a
+0x0200406a
+0x00100362
+0x01888162
+0xe0c08000
+0x0d68a200
+0xa2509b3a
+0xa23aad68
+0xfc26824a
+0x71f70426
+0x4c6e8046
+0x008ca362
+0xe7e08000
+0xa24731f7
+0x00900fd8
+0x00030028
+0x03844ca0
+0x00015768
+0x000c03c0
+0x03017b08
+0xe4300002
+0x0301d9a2
+0x039bff0a
+0x00805db8
+0x0245242a
+0x0200406a
+0x00100362
+0x01876162
+0x02180fd8
+0x00100fd8
+0xd005a120
+0x00448120
+0x62a7fe26
+0x3016a120
+0x07099873
+0x00018028
+0x00015768
+0xe2800200
+0x000c1040
+0x00226c6e
+0x00100274
+0x00050028
+0x00015768
+0x000c03c0
+0x00004000
+0xe4600000
+0x0077f02a
+0x63d71409
+0x01177b0a
+0x010ff30b
+0x44294429
+0x00100276
+0x02009028
+0xe240000c
+0x02015768
+0x0080bb51
+0x2c6e001c
+0xc4622426
+0x000404a8
+0x0245242a
+0x0200406a
+0x00100362
+0xe1c00000
+0x01826162
+0x02180fd8
+0xa1ef71f7
+0x0005002b
+0x00104ca0
+0x0001576a
+0x100d1041
+0xe8900000
+0x10058823
+0x0003002a
+0x0001576a
+0x10400c6e
+0x2426000c
+0x0081c9a0
+0x00040f98
+0xe3300200
+0xa1ef8062
+0x01bc54f6
+0x0003002a
+0x0001576a
+0xd040466a
+0x6c6e000c
+0x02017b08
+0xe6200000
+0x0080072e
+0x0245242a
+0x0200406a
+0x00100362
+0x01848162
+0x0004002a
+0x0001576a
+0x100d1341
+0xe8100000
+0x00835a0a
+0x826b60a7
+0x80332426
+0xa26b2469
+0x71f70426
+0x4c6e8046
+0x008ca362
+0xe7c08000
+0x01bc54f6
+0x02c5502a
+0x0280406a
+0x00140362
+0x01866162
+0x020ca35a
+0xa1ef71f7
+0xe8100000
+0x224631f7
+0x00050028
+0x00015768
+0x024044ca
+0x6c6e000c
+0x00040842
+0x02c5502a
+0x0080fa10
+0xe7200000
+0x0280406a
+0x00140362
+0x01846162
+0x062780c6
+0xa1ef71f7
+0x024631f7
+0x01100fda
+0xe7100840
+0x00850028
+0x00815768
+0x2240444a
+0x4c6e000c
+0x007f702a
+0x10041409
+0x0001802a
+0xe5800000
+0x02084ca2
+0x0001576a
+0x100d0241
+0x00002000
+0x0007ff28
+0x007fffe8
+0x00051408
+0xe8800000
+0x02009028
+0x02015768
+0x2c6e000c
+0x44632427
+0x10041429
+0x0245242a
+0x0080eec2
+0x0200406a
+0xe3800000
+0x00100362
+0x01836162
+0x02081fd8
+0xa1ef71f7
+0x00900fd8
+0x00018028
+0x00015768
+0xe1100000
+0x024044ca
+0x2c6e000c
+0x0007ff2a
+0x007fffea
+0x10041409
+0x0200902a
+0x0201576a
+0xe2600000
+0x0c6e100d
+0x24622426
+0x14290c6e
+0x06261005
+0x008ca362
+0x00000000
+0x00000000
+0xe1e00000
+0x01900fd8
+0x02410428
+0x020040e9
+0x000c4427
+0x00006000
+0x0080b03f
+0x00006f58
+0x400ca57a
+0xe9008000
+0x4c6e602c
+0x05686408
+0xec01a26a
+0x962e9deb
+0xa1ef0626
+0x128db247
+0x4c6eeca7
+0xefe08000
+0x05270499
+0xd8efb2a5
+0x214746c1
+0x0c663146
+0x2e0c3e0d
+0x0c6e4c6e
+0x00915c67
+0xefe23100
+0x0c6e0090
+0x30623080
+0x000219a2
+0x0004107a
+0x008209a2
+0x0004007a
+0x0003edda
+0xe0600000
+0xa1efb285
+0xa24631f7
+0x809cc247
+0x4c6efc26
+0x0080cc1f
+0xaaea2468
+0x0246902a
+0x0200406a
+0xe3e28008
+0x00100362
+0x01836162
+0x02040fd8
+0xa43a0246
+0x6c6e000c
+0xa6ea2026
+0x802c870a
+0xef008000
+0x01a72628
+0x01804068
+0x02140fd8
+0x000c1362
+0x01858162
+0x40c6d18a
+0x0284a052
+0xec008000
+0x0000a35a
+0x00142236
+0x02332d28
+0x020040e8
+0x2410020c
+0x42840214
+0x00527284
+0xee120000
+0x00150234
+0x001b100a
+0x001919a0
+0x0080ec36
+0x22841000
+0x0230062a
+0x020040ea
+0x7084100d
+0xe9120000
+0x01c6aa28
+0x01804068
+0x02140fd8
+0x000c1362
+0x01858162
+0x02b6402a
+0x0280406a
+0x00140362
+0x01836162
+0x92c78146
+0x031816a0
+0x6c6e71f7
+0x008ca362
+0xa24631f7
+0x028c0247
+0xed40080c
+0x4c6e00d2
+0x00020f58
+0xd17a04e8
+0x6c6e228c
+0x008109a0
+0x00031008
+0x0c6e0080
+0xe9a28000
+0xad6b1c09
+0x6c6ea28c
+0x0080d631
+0x04a64046
+0x00840f88
+0xa33a04e8
+0x0100a358
+0x0246aa2a
+0xe2e28000
+0x0200406a
+0x00100362
+0x01838162
+0x4468a28c
+0xd025a120
+0x00140214
+0x00039c08
+0xe1120000
+0xa57aa026
+0x02300628
+0x020040e9
+0x000c809c
+0x24686c6e
+0xfc26a42a
+0xa57a2468
+0xef208000
+0x30922a8c
+0x04e84c6e
+0x880aa22a
+0x027ca358
+0x0240d42a
+0x0200406a
+0x00100362
+0xe0e08000
+0x01826162
+0x00809c34
+0x02140fd8
+0xa37a5226
+0x02363428
+0x020040e8
+0x2400000c
+0x06260004
+0xec908000
+0xa1ef71f7
+0x01bc54f6
+0x02d8002a
+0x0280406a
+0x00140362
+0x02410428
+0x03001428
+0xe0300000
+0x01832162
+0x020040e9
+0x0200a35a
+0xa1ef71f7
+0x222631f7
+0x4226a42a
+0xd020a120
+0xe7108000
+0x02d8002a
+0x0280406a
+0x00140362
+0x02410428
+0x03000a28
+0x01882162
+0x020040e9
+0x0200a35a
+0x0080cf34
+0xa1ef71f7
+0x02474346
+0xe34f224e
+0xa32a20a6
+0xa32a40a6
+0xfe268e0a
+0xa8aa20a6
+0xeff0801c
+0x02410428
+0x020040e8
+0x4427a246
+0x0080002a
+0x00168376
+0xd0c6f0c6
+0x03178374
+0xe4800030
+0x38f4858a
+0x02410428
+0x020040e9
+0x101424a7
+0x10048640
+0x00248640
+0x5408862e
+0xef209000
+0x00100274
+0x02108058
+0x00100276
+0x0200a358
+0x008ca362
+0x00000000
+0x00000000
+0x0080dcbd
+0x00000000
+0x36f70246
+0x092aa5c7
+0x87779577
+0x07130058
+0xb6468677
+0xc6000028
+0x46468577
+0xeae0b32b
+0xe641924e
+0xc22806a1
+0x00340fd8
+0x05130f5a
+0x1002b012
+0xc677c577
+0x6687c777
+0xec201001
+0x01efd577
+0x6c6e76f7
+0xc0000711
+0xc1b80264
+0xd0010010
+0x00004000
+0xc58fe058
+0xe0600001
+0x01810162
+0x8606c577
+0xc777c677
+0xd5776687
+0x76f701ef
+0x00006000
+0x008032f9
+0x000c2f58
+0xe3c000a8
+0x00ad5a7b
+0xd0003e90
+0xd080002b
+0xc02d5afa
+0x40856120
+0x4000a35b
+0x5241422b
+0x57c14629
+0x522970f9
+0x51adc840
+0x20003d91
+0x558bfc2a
+0x02800829
+0x020040eb
+0x060d0059
+0x21a9dab1
+0x22a82fda
+0x058040eb
+0x321002e7
+0x222972fb
+0x218d0941
+0x078040e9
+0xe8e68ed8
+0xe8002000
+0x2213005b
+0x220d01a1
+0x262808f0
+0x90e42121
+0x22102fda
+0x0080f5a4
+0x026f0c6e
+0x01888162
+0xe4000000
+0x01bc0264
+0x00006000
+0x01ac7078
+0x000d8bf8
+0x01000fd9
+0xd0002011
+0xc1b00264
+0xb0029410
+0x00004000
+0x000c2f58
+0xc0684121
+0x022c6079
+0x03a80fda
+0x022892fa
+0x53270661
+0xe8000000
+0x07478606
+0x20001610
+0x30047c10
+0x0200082a
+0x0110cbfa
+0x03c14428
+0x038040e8
+0xe0200003
+0x01810162
+0x0228c07b
+0x06280fd9
+0x019ddab1
+0x00809ca8
+0x70000c13
+0x05c02bce
+0x70046413
+0xe4000800
+0x028d01a1
+0x019c0264
+0x029c2fda
+0x03102fda
+0x0223005a
+0x72b80276
+0x000c1362
+0x01896162
+0x03380276
+0x8606c577
+0xc777c677
+0xd5776687
+0x76f701ef
+0x0c6e6c6e
+0x00000000
+0xe7c00ca8
+0x02140277
+0x01820162
+0x01c40264
+0x00006000
+0x000c1362
+0x01868162
+0x8606c577
+0xe8002000
+0xc777c677
+0xd5776687
+0x76f701ef
+0x0080c0f1
+0x00006000
+0x00027810
+0x0c6e6c6e
+0x00000000
+0xe4e00c0a
+0x02340fd9
+0x01820162
+0x95070246
+0x06c14429
+0xc5868656
+0xd0001113
+0xd53c33e5
+0xe2800230
+0x068040e9
+0xd1b40fda
+0xc0043811
+0xd63c33e4
+0xd73c33e4
+0xd00c0363
+0xd53c33e6
+0xd6bc52e6
+0xd200a358
+0x01820162
+0x1000c013
+0x02280fd8
+0x01b40264
+0x000c1362
+0x01888162
+0xe0100000
+0x8606c577
+0xc777c677
+0x00806def
+0xd5776687
+0x76f701ef
+0x00006000
+0xc677c577
+0x6687c777
+0xede0102a
+0xd57701ef
+0x062676f7
+0x00004000
+0x9000b810
+0x00004000
+0xc5778506
+0xc777c677
+0xec600401
+0x01efd577
+0x6c6e76f7
+0x02b80276
+0x020c0277
+0x01850162
+0x8606c577
+0xc777c677
+0xec602801
+0x01b40fda
+0x053c33e7
+0x000c0362
+0x06bc52e6
+0x00006000
+0x00000000
+0x00000000
+0x00000000
+0x00102244
+0x00803979
+0xa8ba6c6e
+0x801ce05c
+0x028c4c6e
+0x00806c6e
+0x462a8004
+0x0240fc2a
+0xe7c28000
+0x020040ea
+0xc426100d
+0x04260204
+0xa74a2204
+0x02048426
+0x22040426
+0x10052401
+0xefc28000
+0x0008a120
+0x028ce05c
+0x80041402
+0x22042426
+0xe0044680
+0xec00080c
+0xa1ef0804
+0xefd20000
+0x00102244
+0xa36a6c6e
+0x6c6ee05c
+0x6c6e028c
+0x20041402
+0x2426668a
+0xe05c2204
+0xefc28000
+0x00809745
+0x4c6e201c
+0x6c6e028c
+0x20040080
+0x02046426
+0x22040426
+0xe0044680
+0x6c6e080c
+0xefe20000
+0x0804ec00
+0x008ca362
+0x08040426
+0x008ca362
+0x267731f7
+0x46468577
+0x801c080c
+0xeea00000
+0x00204c6e
+0xa1ba2d48
+0x64c681ca
+0x05866546
+0x24422400
+0x00422400
+0x06000fd8
+0xe7e08000
+0x02d4502a
+0x0280406b
+0x02eff26c
+0xa04cf04c
+0x01864162
+0x032c0fd8
+0xa6ba0246
+0x00809771
+0xe9828020
+0x01d1d428
+0x01804068
+0x00000000
+0x000c1362
+0x01858162
+0x080c8506
+0x4c6e2606
+0xec000000
+0x08040880
+0x6c6ee00c
+0x00003a40
+0xa00ce004
+0x4c6e2586
+0xa0042000
+0x6c6e800c
+0xef600000
+0x80040880
+0xc006a120
+0x02046426
+0x0240fe28
+0x020040e8
+0x6c6e000c
+0x00042400
+0xeca20000
+0x6677c577
+0x6c6e71f7
+0x008ca362
+0x00102244
+0xa56a6c6e
+0x6c6ee05c
+0x0080f09c
+0x6c6e028c
+0xee628000
+0xa0041402
+0x2426648a
+0xe05c2204
+0x4c6ea01c
+0x6c6e028c
+0xa0040080
+0x0204a426
+0xefe28000
+0x22040426
+0xe0044680
+0xec00080c
+0xa1ef0804
+0x01bc54f6
+0x053c22f4
+0x234e4646
+0xe9f23000
+0xf0040247
+0x020c0814
+0x0000cbd8
+0xd018a120
+0x0251d42a
+0x0200406a
+0x4212026f
+0xe8720000
+0x01824162
+0x02121088
+0x081c8506
+0x00006000
+0x9020a120
+0x00800aa1
+0x02100204
+0x02c0bc28
+0xe0800000
+0x028040e8
+0x848c2c6e
+0x4c6e8506
+0x00001362
+0x01858162
+0x080c8506
+0xbeaa6c6e
+0xecc08000
+0x053c22e4
+0x6c6e71f7
+0x008ca362
+0x01bc54f6
+0x053c22f4
+0x05100fd8
+0x02d8002a
+0xe0400000
+0x0280406a
+0x00140362
+0x01846162
+0x83320627
+0x04278506
+0x24261204
+0x0010e254
+0xe7020140
+0x0240bc29
+0x0049b02a
+0x0000406b
+0x020040e8
+0x008094b4
+0x00100276
+0x00498028
+0x00004068
+0x00106274
+0x004a362a
+0x0000406a
+0x00108276
+0x0049d828
+0x00004068
+0x0010a274
+0x0049d42a
+0x0000406a
+0x0010c276
+0x053c22e4
+0x01bc52e6
+0x00006000
+0x008ca362
+0x00000000
+0x00000000
+0x00000000
+0x07bf005a
+0x04270246
+0xa43abc05
+0xd86ffc01
+0xbc0d0f67
+0x34006c6e
+0x1ce6ac05
+0xefc08000
+0x07bd005a
+0x008ca362
+0x724731f7
+0x0080ead1
+0x0357224f
+0x00180fd8
+0x400da120
+0xa46a24a7
+0xe98080e0
+0xa12b2426
+0x0004a35a
+0x010c2a5a
+0x700ca120
+0xe633648a
+0x02124ca2
+0x0202002a
+0xe2208000
+0x02014e6a
+0x010c0fda
+0x600a8120
+0x05a67246
+0x01814d68
+0x0a220212
+0x005c81c0
+0xed100000
+0x0054a2c2
+0x0297cf58
+0x005462a2
+0x0003e058
+0x00035a08
+0xec918004
+0x00877b0a
+0xe4a00000
+0xb014e8a3
+0x00802a5a
+0x0080f23a
+0x500aa120
+0x00186120
+0x48040426
+0x2001f8b3
+0x00035a0a
+0xe6200000
+0x0001ff8a
+0x08321063
+0x01c00822
+0x00100276
+0x024ae02a
+0x0200406a
+0xbb12026f
+0xe8c00000
+0x03190888
+0x01832162
+0x02180fd8
+0x08220012
+0x817201c0
+0x0296e9f0
+0x31470054
+0xeb000300
+0x0080a358
+0x024ae02a
+0x0200406a
+0x00100362
+0x01866162
+0x02180fd8
+0x00009e28
+0x020c0078
+0x6c6e000c
+0x0080b72a
+0x00004f58
+0xfc80a26a
+0x24909caa
+0x2568ec91
+0x858aa37a
+0x0012fe26
+0xefa08080
+0x01c00822
+0x00140088
+0x06260004
+0xa1ef71f7
+0x21264246
+0x650aa43a
+0x5603e633
+0xefb08002
+0x0202002a
+0x02014e6a
+0xa00c8120
+0x634a1246
+0x0080a358
+0x00814d68
+0x84722046
+0xe9008000
+0x000c00c0
+0xf8026c6e
+0x628aa23a
+0x08229472
+0x0822b472
+0xa1ef8046
+0x424631f7
+0xefe08000
+0x0080ad1b
+0xa1ba2126
+0xe633628a
+0x02124ca2
+0x0202002a
+0x02014e6a
+0xa0128120
+0x05a67246
+0xe8608000
+0x01814d68
+0x08220012
+0x008c01d0
+0xa0426c6e
+0x00420084
+0x00806388
+0x00940274
+0xe3c00000
+0x024ae02a
+0x0200406a
+0xbb92026f
+0x039d0888
+0x01862162
+0x021c0fd8
+0x009460c2
+0xe8802000
+0x0c6e82f2
+0x052632c7
+0x024ae02a
+0x0200406a
+0x00100362
+0x01886162
+0x021c0fd8
+0x0080e7ea
+0xe0600000
+0x00009e28
+0x000c01c0
+0x00004f58
+0xfc80a2ea
+0x25209d2a
+0x46e8ec91
+0x860aa47a
+0xef508200
+0x0012fe26
+0x01c00822
+0x00040088
+0x06260004
+0xa1ef71f7
+0x21264246
+0x658aa4ba
+0xef708008
+0x5603e633
+0x0202002a
+0x02014e6a
+0xa0108120
+0x644a1246
+0x0080a358
+0x00814d68
+0xe2208000
+0x00122046
+0x00c00822
+0x6c6e000c
+0x0004a042
+0x60220042
+0x06260004
+0x00802c19
+0x008ca362
+0xe7e00000
+0x024625f7
+0x0241422b
+0xb5c6664e
+0xd0004c11
+0x25778677
+0x020040ea
+0xc21002e6
+0xe2a00223
+0x060c0028
+0x060040e8
+0x05300fd8
+0x026f0c6e
+0x01888163
+0x0c6e0c6e
+0x0c6e0c6e
+0xed001c00
+0x01af0059
+0x0527a50e
+0x05ad09c0
+0x000d4bf8
+0xd030a121
+0xc1940264
+0xe50ec586
+0xe840300c
+0x048fc9f1
+0x10004000
+0x041740f1
+0x0224e078
+0x8f480640
+0x0080ce27
+0x029006a0
+0xc0046123
+0xe2000200
+0xc1940264
+0x03940fd8
+0x048fc7a0
+0x54074646
+0x10006001
+0x0c6e674e
+0x00000000
+0xe5000cc0
+0x0241462b
+0x002d4a78
+0x020040eb
+0xd0003491
+0xc1a80264
+0xc21002e6
+0x00006000
+0x020fcf59
+0x000c27a1
+0x0230907a
+0xd0003093
+0xc2280275
+0x02a881e1
+0x06a009e6
+0x9d490e41
+0xec002000
+0x89660a6f
+0x6204a35a
+0xa184a359
+0xc0900fda
+0x0080a117
+0x428802e6
+0x000c1fda
+0x22080264
+0xe0200002
+0x5000a358
+0x3080a358
+0x43142f5a
+0x00000000
+0x20902f59
+0x401816a1
+0x0341442a
+0x8180a358
+0x95890a67
+0x20001b10
+0x20037810
+0xc100a35a
+0x030040ea
+0x8100a358
+0x02081fd8
+0xe0200000
+0x60001091
+0x6100a358
+0xa0000890
+0x60037410
+0x72280fd8
+0x72980fda
+0x00000000
+0xa0037410
+0x00035c10
+0x01828162
+0x6c6e10cd
+0x00802a47
+0x00100362
+0x01858162
+0x76876577
+0x01efc677
+0xec801400
+0x6c6e65f7
+0x01836162
+0x02080fd8
+0x01a80264
+0x02080264
+0x81b06c6e
+0x850605b0
+0xec202000
+0x01a80275
+0x10035412
+0x6c6e114d
+0x00100362
+0x01858162
+0x76876577
+0x01efc677
+0xec801400
+0x05bc52e4
+0x01822162
+0x020802e7
+0x01a80264
+0x05b07230
+0x10035013
+0x018802f4
+0xe2100000
+0x6c6e114d
+0x00100362
+0x00802d13
+0x01838162
+0x76876577
+0x01efc677
+0x6c6e65f7
+0x01880162
+0xe7200140
+0x10035c13
+0x02080fd8
+0x020802e7
+0x01880264
+0x02280264
+0x72304c6e
+0x15ae81b0
+0xec000000
+0x10034413
+0x018802f5
+0x114d9146
+0x026f6c6e
+0x01858162
+0x76876577
+0x01efc677
+0xed801400
+0x6c6e65f7
+0x01c14428
+0x018040e8
+0x018c0264
+0x00006000
+0x000c1362
+0x01888162
+0xe0200000
+0x053c52e5
+0x008066e1
+0x01b41fda
+0x063c33e5
+0x000c0362
+0x05bc52e4
+0x00006000
+0x00000000
+0x00000000
+0x019225f7
+0x0800a35b
+0xe24fb6f8
+0x46c62577
+0x0480102b
+0x9677c2c7
+0x000d4a79
+0xe5a008d3
+0x04182d5b
+0x0880002a
+0x021c2d5b
+0x81909bf9
+0x0500102b
+0x87779577
+0x9194bbf9
+0xe4000800
+0x029141e3
+0x00250a7a
+0xa64e8677
+0x06282d59
+0x32a006a3
+0x0044ca7a
+0xc041ba79
+0xe0800030
+0x00803310
+0x01bcd4f7
+0x0900a35a
+0x000c06e1
+0x03342d59
+0x2048ea7b
+0x08677816
+0x01299a79
+0xe4000800
+0xc0003891
+0xd5b408f0
+0x0219507b
+0x03000029
+0x20003893
+0xd7299a78
+0xb2301fdb
+0xd37ca359
+0xd29816a0
+0xd21c16a1
+0xd1980fd9
+0xbc45aa41
+0xd23c22e6
+0x30036010
+0x01888162
+0xe1000000
+0x01b42d58
+0x00380fd8
+0x020d507a
+0xd2301fda
+0x02100a5a
+0x0593eda2
+0x924ea646
+0x0080477d
+0xe8001000
+0xbc4dd646
+0x10035813
+0xb58e86c6
+0x00a98a79
+0x083416a3
+0x0200a35a
+0x00116a7b
+0xe0a00012
+0x902989f9
+0x04b016a2
+0x20389a7b
+0x802da9f8
+0x354177fb
+0x200000a9
+0x01298a79
+0x22bc22e7
+0x31a988c1
+0x36a7eca2
+0x322f184b
+0xb0a989f9
+0x31bc62f5
+0x37a7fca1
+0x404e8656
+0xe8002000
+0x324029a3
+0xa0ada9f9
+0x323c42f7
+0x8966a6d6
+0x323c82f7
+0x0fb029a1
+0x0080fdcc
+0xd4a429a3
+0xe1000080
+0xd5a818f0
+0xd23c82e7
+0x0337fca3
+0x86b429a0
+0xd1bc62e5
+0x364029a2
+0xb0154121
+0xd23c42e5
+0xa4a429a3
+0x861bfff8
+0xd811affb
+0x221421a2
+0x223c22f7
+0xa83d9ffa
+0xb23c22e7
+0xd5106078
+0x024175f8
+0x022552fb
+0x6ae26646
+0x05107079
+0x023c22e6
+0x12276c6e
+0xaa3b3246
+0xec808800
+0x00035810
+0x8807a487
+0x00002000
+0x01850163
+0xa50e8586
+0x0080c41f
+0x0087e058
+0x80000190
+0xe2400100
+0x80035410
+0x82400fda
+0x82a40fda
+0x46c66646
+0xbc5da506
+0xc6060253
+0x85866686
+0xef000100
+0x8acb12c6
+0x051480fa
+0xd1bcd2e7
+0xd0000a90
+0xc0033411
+0xd63c33e4
+0xd73c33e4
+0xe0200003
+0xd53c33e6
+0xd63c33e6
+0xd00c0363
+0xd53c52e4
+0x01850162
+0x10034013
+0x02280fda
+0x03118ff9
+0x0195a6e0
+0x01bcd2e6
+0xc777c677
+0xd677d577
+0x00804dbf
+0x657701ef
+0x834665f7
+0x2c6ea1c6
+0xef800100
+0x024631f7
+0x01100fda
+0x023c4e28
+0x020040e8
+0x6212e246
+0x859c0a22
+0xa46b5ca9
+0xee308102
+0x8d0aa0ea
+0x1127fe26
+0xf047aa3b
+0x00081fd8
+0x023e5228
+0x4193d3c7
+0x0301ffa8
+0xe4e08c00
+0xb3c709a3
+0x020040e8
+0x1f8d751d
+0xa0c14c6e
+0x001c5205
+0x24906c6e
+0x01052da0
+0xe7a00003
+0x40f0d542
+0x0398ef98
+0x00142b90
+0x00801e4b
+0xbd2aec00
+0x023e5428
+0x020040e8
+0x6c6e000c
+0xe9a08000
+0x000812fa
+0x06261004
+0xa1ef71f7
+0x22464247
+0x039806a0
+0x033e5428
+0x030040e8
+0xe1d000c0
+0x0013010c
+0x2c6e4823
+0x4ca91811
+0x828aa27b
+0x514650c6
+0xa8ba1126
+0x06261147
+0xefe08000
+0x003c4e28
+0x000040e8
+0x900da120
+0x02985dc0
+0x81b000bc
+0x42bc01d0
+0x26402634
+0xee100000
+0xbd2bec01
+0xe4680c52
+0x00804cde
+0x0812a67a
+0x000cc840
+0x0001ffaa
+0x40004c6e
+0x00812da0
+0xe5e08000
+0x2010d4c2
+0x00803f98
+0x00040880
+0x4000400c
+0x01464004
+0xa1ef8046
+0x01bc54f6
+0xe7b00000
+0x02cee62a
+0x0280406a
+0x00140362
+0x01856162
+0x03006428
+0xa1ef71f7
+0x01bc54f6
+0xe4100000
+0x02cee62a
+0x0280406a
+0x00140362
+0x01856162
+0x03006928
+0xa1ef71f7
+0x48220012
+0xec100000
+0xa13a8c68
+0x008007b9
+0xfe2685ca
+0x023c4e2a
+0x020040eb
+0x02052426
+0x023e5028
+0x020040e9
+0xe2628000
+0x00040426
+0x00132004
+0x50044823
+0xa1ef8046
+0x023e542a
+0x020040ea
+0x0093100d
+0xe9e00000
+0x2c6e48a3
+0x010020fa
+0x023c4e28
+0x020040e8
+0x2026020c
+0x04e9a36a
+0x848aa46b
+0xee338000
+0xfe269146
+0x008ca362
+0x023e5428
+0x020040e8
+0x0013000c
+0x2c6e4823
+0x80461468
+0xee200000
+0x00807617
+0x008ca362
+0x01bc54f6
+0x01d80028
+0x01804068
+0x023c4e28
+0x000c1362
+0x03000828
+0x020040e8
+0x01822162
+0x06274b22
+0x0000002a
+0x023e542a
+0x00014a8a
+0x020040ea
+0x71f71005
+0xe8500004
+0x008ca362
+0x023c4e28
+0x020040e9
+0x0000a358
+0x00100254
+0x008ca362
+0x00000000
+0x00000000
+0x01bc54f6
+0x053c22f4
+0x05001228
+0x05012f68
+0x60128506
+0x00100274
+0x0353a02a
+0x0080cebd
+0xe2000100
+0x0300406b
+0x02000a28
+0x02004169
+0x004c036f
+0x01884162
+0xc62706a6
+0x0280002a
+0xe5000c00
+0x0180a359
+0x0243502a
+0x020000eb
+0x03106b00
+0x00149672
+0x01109632
+0x13112c6e
+0xe8000000
+0x014f6091
+0x0a130506
+0x021012fa
+0x8e511015
+0x00531085
+0x10058641
+0x053c22e4
+0xe7600201
+0xa1ef71f7
+0x04270232
+0x02012f68
+0x86401004
+0x92131004
+0x021092fa
+0x0080296f
+0x86411005
+0xeb700008
+0x86411005
+0x86411005
+0x001002f6
+0x0240a628
+0x020040e8
+0xa42a000c
+0xfca6844a
+0xec708000
+0x10463046
+0x00c60004
+0xa1ef8046
+0x01bc94f6
+0x053c62f4
+0x01c0a628
+0x018040e8
+0xe0e00000
+0x000c81c6
+0x4c6e45c6
+0xd00aa120
+0x00488120
+0x027ca358
+0x01d00228
+0x01804068
+0xe0600000
+0x00000000
+0x000c1362
+0x01838162
+0xbc050427
+0x94f3bc0d
+0x0080820c
+0x2c6e08a3
+0xaa3b0c89
+0xef008000
+0x0a239673
+0x0104a35a
+0x6683e000
+0x00010000
+0x00000000
+0x603c22e4
+0xac152410
+0xe8300002
+0x6c6ebc3d
+0x40c76e19
+0x0c6e2c6e
+0x00034000
+0x01cfc028
+0x01804068
+0x00000000
+0xe0e00000
+0x000c1362
+0x01828162
+0x20128506
+0x06260004
+0x053c62e4
+0x01bc92e6
+0xa1ef6c6e
+0xe9800010
+0x01bc94f6
+0x053c62f4
+0x0540a628
+0x050040e8
+0x0080eaae
+0x000c8506
+0x1212a5ba
+0x02012f68
+0xe6108000
+0xa1aa000c
+0x000c8640
+0xd00aa120
+0x00488120
+0x0200a358
+0x01d00228
+0x01804068
+0xe0708000
+0x00000000
+0x000c1362
+0x01838162
+0xbc050427
+0x94f3bc0d
+0x2c6e08a3
+0xaa3b0cc9
+0xef008000
+0x0a239673
+0x0104a35a
+0x6683e000
+0x00010000
+0x00000000
+0x603c22e4
+0xac152410
+0xe8300002
+0x6c6ebc3d
+0x40c76e59
+0x0c6e2c6e
+0x008061f5
+0x00034000
+0x01cfc028
+0x01804068
+0x00000000
+0xe0e00000
+0x000c1362
+0x01828162
+0x20128506
+0x26260004
+0x053c62e4
+0x01bc92e6
+0xa1ef6c6e
+0xe9800010
+0x967727f7
+0x31f79577
+0x86772777
+0xe6468577
+0x0427a647
+0x001002f6
+0x0641002a
+0xe3e00080
+0x060040ea
+0x10468607
+0x001002f4
+0x05c1022a
+0x058040ea
+0x10058587
+0x01d80028
+0xe4400004
+0x01804068
+0x0240fc28
+0x0080fd37
+0x000c1362
+0x01866162
+0x020040e9
+0x0f268047
+0x024a962a
+0xe4000400
+0x0200406a
+0x00100362
+0x06c0ea28
+0x068040e8
+0x01862162
+0x02340fd8
+0x0252e02a
+0x0200406a
+0x0212026f
+0x01834162
+0x0211ce88
+0x06068646
+0x8587a42a
+0x10058073
+0x00a8a120
+0xe7208200
+0x05301fda
+0x12aca686
+0x103d8607
+0x02145ec0
+0xc1272c6e
+0x00806ffa
+0x40858120
+0xe2c20008
+0x000c1fd8
+0x0080874d
+0x700da120
+0xb027ad01
+0xa127a37b
+0x3012a120
+0x05100264
+0x8427a48a
+0xe9808000
+0x54460c6e
+0xbb3a0506
+0xc8230013
+0x2c493507
+0x844aa33b
+0x07280fd8
+0xc8220012
+0xebe08020
+0x0c6ec446
+0x24011707
+0x0c6e2443
+0x97877446
+0x006f500d
+0x97076c6e
+0x01890163
+0xe7f00800
+0x02300fd8
+0xad2a5226
+0xa63a0586
+0x8606a507
+0x06ac13a2
+0x2c6e3641
+0x2e0c0ce6
+0xedc08040
+0x00809467
+0x4c6e3e1d
+0x0c6ee41a
+0x9ce734a9
+0x001436d6
+0x01ca5828
+0x01804068
+0x02340fd8
+0xe0e00020
+0x000c1362
+0xc5868507
+0x01834162
+0x35071707
+0x0c6e2801
+0x00001fd8
+0xdfa28120
+0xe3400000
+0x05001fd8
+0x0fb4a120
+0xa0738587
+0x001002f6
+0x01cc3028
+0x01804068
+0x02300fd8
+0xe0800010
+0x000c1362
+0x01828162
+0xa32aa60a
+0x000c86c0
+0x4c6e8687
+0x001002f4
+0x01cc3028
+0x0080e580
+0xe3808000
+0x01804068
+0x02300fd8
+0x000c1362
+0x01848162
+0xc677c577
+0x71f76777
+0xd5770c6e
+0xee000000
+0x67f7d677
+0x008ca362
+0x0241002a
+0x020040ea
+0x021002f4
+0x02410228
+0x020040e9
+0xe0200000
+0x0000332a
+0x00100276
+0x008ca362
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x857731f7
+0x01c0e828
+0x018040e8
+0x000c81c6
+0x4c6e45c6
+0xd042a120
+0x0080d8c0
+0x01d08028
+0xe3200000
+0x01804068
+0x00000000
+0x000c1362
+0x01848162
+0xacba0246
+0x2506a427
+0x0585fdc1
+0xe6008000
+0x85865446
+0x6c6e002c
+0xb018a120
+0x01904264
+0x007fce28
+0x01804c6e
+0x400c4004
+0xec600000
+0xa22a6c6e
+0x4004200c
+0x00081362
+0x01848162
+0x002be058
+0xcff18120
+0x05ad8059
+0xe0708000
+0x052be1a0
+0x71f7c577
+0xa1ef6c6e
+0x01bc54f6
+0x02d8002a
+0x0080f1d3
+0x0280406a
+0x00140362
+0xe0c00000
+0x0240ca28
+0x03002028
+0x01852162
+0x020040e9
+0x0200a35a
+0xa1ef71f7
+0x01bc54f6
+0xe4100000
+0x053c22f4
+0xae2a5226
+0x0010c8d8
+0xd038a120
+0x0540e828
+0x050040e8
+0x008ca506
+0xe8508000
+0xd028a120
+0x02d8002a
+0x0280406a
+0x050602ef
+0x660a9833
+0x000012fa
+0x00009c40
+0xe3000200
+0x06271040
+0x01830163
+0x03000628
+0x000c8506
+0x00802d20
+0xec006c6e
+0xa62a0004
+0x01d00228
+0xe7208003
+0x01804068
+0x00000000
+0x000c1362
+0x01848162
+0x053c22e4
+0x6c6e71f7
+0x008ca362
+0xe4000000
+0x277731f7
+0x85778677
+0x664e9646
+0xd0fa0586
+0xd0fa0606
+0x00c0ca2a
+0x008040ea
+0xe3e08010
+0x04a680c7
+0x100dd4ce
+0x10e2aaeb
+0x9833a446
+0x00af2041
+0x54460c6e
+0xa6ab100d
+0xeff08902
+0x0250262a
+0x0200406a
+0x00100362
+0x0080543e
+0x01848162
+0xa8ea5226
+0x00358f00
+0x20402706
+0xea00a000
+0x10041607
+0x40040586
+0x95072004
+0x2401100d
+0x850a1005
+0x24908686
+0x0004a8d8
+0xe7f08000
+0xcfd38120
+0xfe268e2f
+0xc677c577
+0x71f76777
+0xa1ef6c6e
+0x00000000
+0x00000000
+0xe3c00000
+0x02463577
+0x0241422b
+0x0190e1a1
+0x0560a35a
+0xb5c68677
+0x06414829
+0xd0002c92
+0xe2200303
+0x020040eb
+0x053c35c4
+0x00804f48
+0xc21002e6
+0x060040e8
+0x050f0f58
+0x0580a358
+0x026f0c6e
+0xe8000000
+0x01818162
+0x00300264
+0xd0476c6e
+0xd0001311
+0xd3c1442b
+0x01000fd8
+0xd38040ea
+0xe0800020
+0x01981fd8
+0xc18c0265
+0xd0181fd8
+0xa000a359
+0xb21816a0
+0xc0001410
+0x00002000
+0x00286bf8
+0x28e7a93a
+0x4583e000
+0x2c67cc6e
+0x00981fd8
+0x40842264
+0x2ce72c6e
+0x00c7a506
+0xeca09821
+0x5080a358
+0x00805bc1
+0x21840fd9
+0x82040264
+0x90000029
+0x80148bf8
+0x0c6e48e7
+0x0c6e00c7
+0xec100000
+0x00034000
+0x46c6d1c7
+0x00181fd9
+0x03c1442a
+0x9346082a
+0x038040ea
+0xd21c02e6
+0xe2408304
+0xc001d410
+0x026f4c6e
+0x01838162
+0xc5778586
+0xc6777687
+0x757701ef
+0x00006000
+0xe74002c0
+0x03981fd8
+0x01830163
+0x041c0264
+0x08a80fd8
+0x019d4078
+0x028d0058
+0x022900f8
+0x0011ebd8
+0x00803564
+0x0211507b
+0xd21c02e7
+0xd0000590
+0xc001b810
+0x02140fd8
+0xd1981fd8
+0xd88c0264
+0xd0100362
+0x01820163
+0x02140276
+0x026f11cd
+0x05181fd8
+0x01882162
+0x01c42fd8
+0x01a80274
+0xe0900000
+0x05a90058
+0x85867687
+0xc677c577
+0x757701ef
+0x00006000
+0x00000000
+0x00000000
+0xe1c0002c
+0x05a62777
+0x9247924e
+0x96c79677
+0x01c00069
+0xd5c6a64f
+0x66c79577
+0x9246564f
+0x00809bd2
+0xeee01d37
+0x0600a359
+0x000d9a7b
+0x033162e3
+0x85778677
+0x019265c6
+0x069bfda0
+0x200c9a7b
+0xe3000180
+0x051bfda0
+0x00800fdb
+0x20000710
+0x30022810
+0x2280a35a
+0x4200a35a
+0x22c0006a
+0x20156a7a
+0x01810162
+0x0280a35a
+0x02c0006a
+0x00156a7b
+0x864e66c6
+0x0200002a
+0x20114a7a
+0xe2000300
+0x20000510
+0x30022010
+0x2ffe6410
+0xb5869506
+0x00000000
+0x01860162
+0x00809e9f
+0x0ffe6410
+0xe1000000
+0x9247b2c7
+0x00000000
+0x8606a586
+0x01840162
+0x05a60627
+0x03000028
+0x00116a7b
+0xe2a00320
+0x008d4a78
+0x8019aa79
+0x900406a1
+0x200d5a7a
+0x20000c91
+0x2000a359
+0x00918a7b
+0x2183e040
+0x510406a3
+0x1a770a2a
+0x4111aa7a
+0x0240006a
+0x0213e05a
+0x22346df8
+0x22915df8
+0xe040800c
+0xd0022011
+0xc53c33e4
+0x01838162
+0xc577088a
+0xc6777707
+0x0080f831
+0x01efd577
+0x6777d677
+0xef0088c0
+0x00000000
+0x053c33e5
+0x62180fd9
+0x629806a0
+0xd577c677
+0xd6777707
+0x677701ef
+0xee000a00
+0x00000000
+0x00004000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0xc247a246
+0x019806a0
+0x008c49a0
+0xa4086426
+0x0347ab2a
+0x8010a120
+0x05278a0a
+0xeb208003
+0x544092c7
+0x008006a2
+0x000c59a2
+0x068003a2
+0x00800db6
+0x000c29a0
+0x02840fda
+0x0103df5a
+0xe0200003
+0x3e9d0ce6
+0x6c6e2e0c
+0x0000301a
+0x1c059c67
+0x02943c40
+0x002aa120
+0x8013a120
+0xe1620040
+0x001a8120
+0x93460527
+0x000c59a2
+0x000c29a1
+0xb24792c7
+0x4640786f
+0x0103df5b
+0xe6400a00
+0x0f67d86f
+0x3e8d2e0c
+0x0000101a
+0x1ce61c05
+0xb2460c6e
+0x6820448a
+0x00006a78
+0xe7720004
+0x009cd6ea
+0x000403e2
+0xac2bf003
+0x008058df
+0xa8ea2126
+0xa72a4126
+0xd6ba6126
+0x570d2541
+0xefa29000
+0x18e2971d
+0xe42b2c6e
+0x00001290
+0x000509a2
+0x0c030529
+0x14380c6e
+0x6c6e470d
+0xee620008
+0x00840018
+0x570dae8a
+0x0c83fcf3
+0x00050808
+0x24090c6e
+0x0c6e1403
+0xae8a1438
+0xeec28000
+0xb00aa120
+0x00184a86
+0x000407c8
+0x0c434c6e
+0x14380c6e
+0xa63ab126
+0x00184a86
+0xe7008000
+0x00050fc8
+0x00004000
+0x00800b2b
+0x0003100a
+0x14380c6e
+0x00084bd8
+0x2541a6ba
+0xfcf3970d
+0xed028000
+0x00850ca2
+0x000617c8
+0x24090c6e
+0x0c6e0c03
+0x00801ff8
+0x06260094
+0x008ca362
+0xe5800000
+0x92122246
+0x02015868
+0x0c42000c
+0x24280c02
+0xa1ef0004
+0x82323247
+0x24632427
+0xefb02800
+0x02015868
+0xa1ef1004
+0x1a132426
+0x00937b08
+0x0201586b
+0x00052462
+0x008ca362
+0xe4c00030
+0x8a323247
+0x00802863
+0x24632427
+0x02015868
+0xa1ef1004
+0x02472246
+0x0200082a
+0x0201586a
+0xe360010a
+0x100da26b
+0x2426044a
+0x0c6e2462
+0x00001f9a
+0x100d1005
+0x24622426
+0x14292c6e
+0xeee08000
+0xa1ef1005
+0x12130246
+0x0201586a
+0x100da36a
+0x454a0c6e
+0x0c030c43
+0x100d1005
+0xef608000
+0x00006000
+0x0000078a
+0xa1ef1005
+0x1a120246
+0x02015868
+0xa1ef0004
+0x0011ebd8
+0xe5800000
+0x00800808
+0x828aa0fa
+0x02b24426
+0x02815868
+0x6c6e008c
+0xf8029462
+0xa1ef8046
+0x02001028
+0xe7608000
+0x02015868
+0xa1ef024c
+0x24260a12
+0x02015868
+0xa1ef0004
+0x04260a12
+0x02015868
+0xe6c00820
+0xa1ef0004
+0x0a323247
+0x24632427
+0x02015868
+0xa1ef1004
+0x9a132426
+0x00937b08
+0xe6e00c28
+0x0201586b
+0x00052462
+0x008ca362
+0x12323247
+0x24632427
+0x02015868
+0xa1ef1004
+0x00805ab9
+0xeb400280
+0x00100fd8
+0x02000e28
+0x02015868
+0x00100274
+0x008ca362
+0x00000000
+0x00000000
+0x00000000
+0x042731f7
+0xbc0dbc05
+0x001069a0
+0x1c494c6e
+0x3022a120
+0x904f2527
+0x6683e000
+0xe5600400
+0x00010000
+0x00000000
+0x603c22e4
+0xac152410
+0x6e59bc3d
+0x2c6e40c7
+0x00000000
+0xe7100000
+0x00034000
+0xa1ef71f7
+0x134731f7
+0x324782ab
+0x24271746
+0x010c0228
+0x00804540
+0x01016468
+0xe3d08080
+0xd8238146
+0x10a71004
+0x0292ae3b
+0xf246faa2
+0x018ca0c7
+0x43609b72
+0xa4282c6e
+0xefe08041
+0x010c0104
+0xa4086c6e
+0x2427a5ba
+0x2303e000
+0x83462c6e
+0x21900264
+0xa5986c6e
+0xeae08000
+0x9000a35a
+0x0c6e2c6e
+0x00034000
+0x00000000
+0x01d5b028
+0x01804068
+0x02200fd8
+0xe0400000
+0x000c1362
+0x01828162
+0x966afe80
+0xeed187f0
+0x0255b02a
+0x0080f0f6
+0x0200406a
+0x00100362
+0xe1808040
+0x02212028
+0x01834162
+0x020007e8
+0x01bc52e6
+0x00006000
+0x008ca362
+0x00000000
+0x00000000
+0x02405628
+0x020040e8
+0x6c6e001c
+0xa6ba10a6
+0x02405028
+0x0240222b
+0x020040e8
+0xe1808000
+0x020040eb
+0x000d004c
+0x068413a2
+0x0c664c6e
+0x1c670c04
+0xa1ef2626
+0x84680452
+0xef400008
+0x2452a82a
+0xa82a8468
+0x84684452
+0x3c12a82a
+0x0080c403
+0xa82a8468
+0x009109a0
+0x00131008
+0xe3e08000
+0x306204a8
+0x14e90453
+0x2452a42b
+0xa42a2468
+0x24684452
+0x3c12a42a
+0xa4ba2468
+0xefe08000
+0x262680ca
+0xa1ef0626
+0x01bc54f6
+0x053c22f4
+0x024e5646
+0x02402a2a
+0x020040ea
+0xe2608100
+0x001002f4
+0x019b5428
+0x01804068
+0x00000000
+0x000c1362
+0x01868162
+0xa66a0246
+0xe8008000
+0x02404e28
+0x020040e8
+0x000c6121
+0x00803c96
+0x9507000c
+0x04270005
+0x1005950f
+0x053c22e4
+0xe7000200
+0x01bc52e6
+0x00006000
+0x008ca362
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x0013ea59
+0x86773577
+0xc0001111
+0xb5d62046
+0x46468577
+0xd0283664
+0x81ffffa8
+0xe3400148
+0x81ffffe8
+0x800fea58
+0x0660a358
+0x6046abba
+0x0000d010
+0x02280264
+0x0228905a
+0xe1008040
+0xc1c665c6
+0x01820162
+0x00801c7b
+0x01ad4078
+0x018d6058
+0x018d8f78
+0x050c8058
+0x00282064
+0xe0300000
+0xcffffc91
+0xc2280264
+0xc000c810
+0xc228905a
+0x01800fd8
+0xc58c0fd8
+0xc30c0fd8
+0x01ffffa8
+0x01ffffe8
+0x000fea58
+0x2046482a
+0xd00c0264
+0x950c1fda
+0x8004a358
+0x90001fdb
+0xe0808030
+0x8c6e043a
+0x6c6e006f
+0x01830162
+0x002832e6
+0x012b6c6e
+0x20000362
+0x0c6e6c6e
+0xea609000
+0x053c33e5
+0x00808ff9
+0x01b41fda
+0x000c0363
+0x063c33e4
+0x053c52e6
+0x00006000
+0x00000000
+0x00000000
+0x029005a3
+0x053c54f5
+0x0500a359
+0x00902d5a
+0x01148f7b
+0x05bc22f5
+0x05900fd9
+0x50902ca2
+0xa0d7a569
+0x0093e9a1
+0x0093e9a2
+0x25282941
+0x001408f3
+0x01088a7b
+0x821000d9
+0xe0200003
+0x421005a3
+0x00000990
+0x657fffa9
+0x01100c79
+0x01100c7b
+0xa0d7c0d6
+0x9e58098b
+0xec00ac00
+0x0080009d
+0xf8125901
+0x00000593
+0x35000040
+0x02100ce3
+0x0100c8db
+0x0080c9c3
+0x058a1800
+0xe8209003
+0x60800043
+0x02109979
+0x00000192
+0x22109979
+0x2003e05b
+0x408429c3
+0x40000190
+0x000c0363
+0x05bc22e5
+0x0100a35a
+0x92100ce1
+0x82000041
+0x0114ddf9
+0x053c52e5
+0x0140006a
+0x921009e1
+0x002c5a7a
+0xa21005a1
+0x3500a358
+0x01280fd8
+0xa2088078
+0x00000000
+0x00000000
+0x00801d77
+0x00000000
+0x01c13c29
+0x05bc54f4
+0x018040e8
+0x018c0264
+0x02fca35a
+0x027fffaa
+0x027fffea
+0x02948a7a
+0x018c0a58
+0x053c22f4
+0x06ebb5a9
+0x21c14228
+0x30100363
+0x218040e8
+0x218c0264
+0xe0808020
+0x2c6e4646
+0x01820162
+0x01c14228
+0x018040e8
+0x018c0264
+0x0c6e4c6e
+0x000c1362
+0xe4200000
+0x01818162
+0x02413a2a
+0x020040ea
+0x8506100d
+0x04bb4c6e
+0x20000362
+0x008018cf
+0x00006000
+0xe3008000
+0x01810162
+0x01c13828
+0x018040e8
+0x000c0264
+0x04ba6c6e
+0xc0001362
+0x00006000
+0xe2008000
+0x01810162
+0x01c14428
+0x018040e8
+0x018c0264
+0x000c1362
+0x01868162
+0x10013812
+0xe0100000
+0x0000a120
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x3a4e0a46
+0x26562356
+0x02c62ff1
+0x01c000d8
+0x018ce7a1
+0x0080174b
+0x0414ad18
+0xe40ecde8
+0xe860100b
+0x4aee91c7
+0xc28c4f59
+0xc09868c0
+0x00102f5b
+0xc10c8f59
+0x940f4976
+0x090489a0
+0xe4200c03
+0x02c64867
+0xa40ef0cf
+0x032008f0
+0x24902059
+0x28c00235
+0x02488ca1
+0x9380a35a
+0xe060000f
+0xc4243655
+0x0005ebd8
+0xd00d4121
+0xc6c813a3
+0xa4243674
+0xc29c1fda
+0x01a50058
+0xc3241fda
+0xfa710c66
+0x3d459246
+0x020c5744
+0xd2461c67
+0x0080fa7f
+0xf2c63746
+0x000c0363
+0x001d0f5a
+0xe364000b
+0x001c8f5b
+0x24a50059
+0x23a40374
+0x001c4f5b
+0x24a48059
+0x24240354
+0x24240234
+0x001c2f5b
+0x24a44059
+0x24242234
+0x28a40235
+0x02400fd8
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x957727f7
+0x277731f7
+0x85778677
+0x07bf005a
+0xc64ef646
+0x0c6e5747
+0x000c9506
+0xeef00100
+0x04277447
+0x300c1005
+0x06801fd8
+0x00805e12
+0x0580a358
+0xd13a0686
+0x062c0fd8
+0xd00d9707
+0xea708000
+0x00000362
+0x01828162
+0x8d2a5226
+0x05100fd8
+0x00280ad8
+0x9707a6aa
+0x2627901d
+0xec808000
+0x023c9058
+0x00ef2c6e
+0x01838162
+0x8646880a
+0x00341a5a
+0x500d9707
+0x95869507
+0xed408080
+0x006f2c6e
+0x01828162
+0x05a9707a
+0x06a9a0f8
+0x00000000
+0x00341a5b
+0x05ad4078
+0xe0200000
+0x56070c6e
+0xb33b4429
+0x0080abe2
+0xa33a0586
+0x400c9506
+0x4c6e9787
+0x001002f4
+0x07bd005a
+0xe3e08000
+0xc677c577
+0x71f76777
+0xd5772c6e
+0xa1ef67f7
+0x00000000
+0x00000000
+0x00000000
+0xe1e00000
+0x267731f7
+0x053c35c4
+0x0238f02a
+0x0200406a
+0x00100362
+0x01886162
+0x027ca358
+0xe0200000
+0xd5aa5226
+0x023b182a
+0x0200406a
+0x00100362
+0x01858162
+0xd5aa5226
+0x05c09828
+0xe4208000
+0x058040e8
+0x0080633b
+0x000c8586
+0x0200002a
+0x0000082a
+0x0200416a
+0x0001298a
+0x00001362
+0xe0400000
+0x96460201
+0x05001fd8
+0x01840162
+0x06279046
+0x8daa0246
+0x00b01fda
+0x01c2b828
+0xe3208040
+0x01804068
+0x02281fda
+0x000c1362
+0x1813304d
+0x00812823
+0x01880162
+0xd04e8586
+0xeb001040
+0x464e0586
+0x000c8440
+0x00001362
+0x01848162
+0xa5ba0506
+0x02019228
+0x02004168
+0xe2708001
+0x00803ecd
+0x00100274
+0x00281362
+0x01838162
+0x6677c577
+0x6c6e71f7
+0x008ca362
+0x00000000
+0xe3000000
+0x00903d5b
+0x00903d59
+0x19760032
+0x00909bf9
+0x00043d73
+0x51002040
+0x02100ce3
+0xe0800010
+0x40002943
+0x030018f0
+0x011099fb
+0xc5621836
+0x00000c12
+0x4100a35b
+0x608808f3
+0xe10000c0
+0x610829a1
+0x00000812
+0x621029a3
+0x52109b31
+0x00000810
+0x521029a3
+0x62109b31
+0x0080ee05
+0x0100e8db
+0x0080e9c3
+0x00000410
+0x6080a35b
+0x22109979
+0x200029c3
+0x00000413
+0x00000001
+0x00000000
+0x22109979
+0x200029c3
+0x4087e05b
+0x40000012
+0x000c0362
+0x92100ce1
+0x8200a358
+0x921009e0
+0x92104840
+0x00002000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00903d5b
+0x00903d58
+0x00909bf9
+0x00043d73
+0x0663a256
+0x40002942
+0x008001d8
+0x011099fb
+0xe2000200
+0x00000892
+0x4100a35b
+0x608808f3
+0x088bf056
+0x621029a3
+0x52109b31
+0x00000890
+0xe1008040
+0x521029a3
+0x62109b31
+0x0100e8db
+0x0080e9c3
+0x00000490
+0x6080a35b
+0x22109979
+0x200029c3
+0x00000092
+0x22109979
+0x200029c3
+0x4087e05b
+0x40000092
+0x9210e9e1
+0x821408f1
+0x000c0362
+0x00008000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00805fac
+0x00000000
+0x00000000
+0x00000000
+0x001829f1
+0x009847a1
+0x0404a358
+0xc19036a5
+0xc4000129
+0x04901fd8
+0x829056a7
+0x84a50a25
+0x001879a3
+0x011887a0
+0xa81037b5
+0x144ea256
+0x0084a35a
+0x239037a5
+0x2003e1a3
+0xe10000c0
+0x010068da
+0x600c0363
+0x289037a7
+0x2003e05a
+0xc1943635
+0xc0804043
+0xd86f52c7
+0xe8001000
+0x82945637
+0x84882ab4
+0xa8143755
+0x00200fd8
+0x008043f1
+0xc3943775
+0xc003e1a0
+0x00838001
+0xc8943776
+0x039037a4
+0x00004000
+0x00000000
+0x00034001
+0x03943774
+0x008ca362
+0x00000000
+0x00000000
+0x04c14828
+0x048040e8
+0x04240264
+0x06270a46
+0x0c6e05a6
+0xa0460406
+0xd0001211
+0xe7000800
+0xc3c00264
+0xc2140264
+0xd1c02274
+0xd8240274
+0xd24e2c6e
+0x8fc86056
+0x10004000
+0xe6000e00
+0xc30c0fd8
+0xc2982264
+0x22ce6c6e
+0x0080b616
+0xd080a358
+0x80006123
+0x82140264
+0x8fc862c6
+0xe8800000
+0x134702c6
+0x33476867
+0x34402274
+0x38240275
+0x934748e7
+0x40402274
+0xd81022f4
+0xe2600209
+0x481022f5
+0x0180a358
+0xd1c02275
+0x10006000
+0x008ca362
+0x00000000
+0x00000000
+0x00000000
+0x03414828
+0x030040e8
+0x0627011c
+0x2c6e06a7
+0xa0ce2668
+0x8284a35a
+0x86896a67
+0xeb802300
+0x20470213
+0x20942265
+0x0080e203
+0x30268121
+0x200000aa
+0x42900fda
+0x82800fdb
+0x10004001
+0xe0200002
+0x00102a78
+0x019740f1
+0x86896a67
+0x02840fd8
+0x20026121
+0x20942264
+0x062706a7
+0xe8802020
+0x828000ab
+0x91c72668
+0x10006000
+0x00100fda
+0x9004a35a
+0x31902264
+0x224706a7
+0xe8400008
+0x90940fda
+0x02980fd8
+0x31980274
+0x008c8363
+0x41902264
+0x419022f5
+0x92940276
+0x00000000
+0xee41e246
+0x0080c314
+0x634e334f
+0x50001010
+0x43101fd8
+0x40983224
+0x02900fd8
+0x420c1fda
+0xe0600007
+0x42041fd8
+0x10004000
+0x820ff05b
+0x8207f059
+0x0e9400ce
+0x019340f1
+0x48670247
+0xea000100
+0x20983225
+0x00ce9eab
+0x20943635
+0x8213e059
+0x8213e05a
+0x000c3bdb
+0x10006000
+0xe0408008
+0x30102121
+0x020ff05a
+0x269003a2
+0x2c6e06a7
+0x82c60c66
+0x0e3472ce
+0x08034000
+0xe7000300
+0x0080091c
+0x008c8362
+0x021c0fd8
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0xd25705a6
+0x0400102b
+0x03900a5a
+0xa5e8b247
+0xc0187a78
+0x00208bfa
+0x0080fffa
+0xe1200043
+0x4000a35b
+0x40000911
+0x532088c3
+0x53949ce2
+0x20000991
+0x5314c9e2
+0x531ccffb
+0x54148ce3
+0x51802028
+0x501079f8
+0x52981fd8
+0x52201fd8
+0x32111dc3
+0x200c0362
+0x02148ce2
+0x0080d39c
+0xd200a35a
+0x0200a358
+0x02901fd8
+0x000c0362
+0x00008000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x0400102b
+0x02900fda
+0x00a08bfb
+0x0310b9e2
+0x40000a91
+0x0394b9e3
+0x7a307406
+0xe8002000
+0xae490253
+0x52151dc3
+0x01946ce1
+0x400c0362
+0x521499e3
+0x02187ff8
+0x73c6ca67
+0xe8201002
+0x428c0fd8
+0x008c4363
+0x0180a359
+0x021016a0
+0x028c0fd8
+0x00002000
+0x0080f78e
+0x00000000
+0x00000000
+0xc247c246
+0x277b273a
+0x06c7e2c6
+0x04202ca3
+0xb6e82782
+0x041bf9a1
+0x031c77fb
+0xe2e0011d
+0xa34f01ef
+0xd014b9fb
+0xcbe3ff42
+0x021428f3
+0x02a11ff9
+0x031cc6e1
+0xc01099fa
+0xe0a00022
+0x220c1fdb
+0x0214c0f8
+0x02989078
+0x02101fd9
+0x229806a0
+0x00000000
+0x00000000
+0x00000000
+0x078bfe2a
+0x078040ea
+0x07bf09f2
+0x0730002a
+0x070040ea
+0x0080cda1
+0x0256b02a
+0x0200406a
+0x00100362
+0x025f6028
+0x01834162
+0x02004068
+0x01dc4028
+0x01804068
+0x00000000
+0x000c1362
+0x01888162
+0x0257902a
+0x0200406a
+0x00100362
+0x01856162
+0x0204a358
+0x0005a120
+0x00000000
+0x00000000
+0x0a13100c
+0x023c006a
+0xe8232c6e
+0x200c1005
+0x4c6e8651
+0x400c0085
+0x4c6e86d1
+0xefa00000
+0x600c0085
+0x4c6e86d1
+0x800c0085
+0xb2d016d2
+0x008026a1
+0x00842c6e
+0x6c6e000c
+0x0005e842
+0xefe00000
+0x008ca362
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x02ffffa8
+0x02ffffe9
+0x02c1b02a
+0x0280406b
+0x96e9fe27
+0x02ef62c6
+0x320c0265
+0xe6000600
+0x0200a358
+0x0180a358
+0x31948058
+0x00000000
+0x020c1fda
+0x00000000
+0x00000000
+0x00000000
+0x31f70627
+0x00149a7a
+0x20109bf8
+0x00803db5
+0x3010baf8
+0xd1bc52e7
+0xd0000710
+0xc0001010
+0xe0200001
+0x00004000
+0xd00c0362
+0x01830162
+0x01bc52e6
+0x00006000
+0x000c0362
+0x00008000
+0x00000000
+0x0f5cc246
+0x0426a247
+0xd2143696
+0x10004000
+0x9ae20c6e
+0x02100a59
+0x7a307ae2
+0xea610004
+0x00106ff8
+0xdffa2123
+0xd2983624
+0xd2143696
+0x9ae22c6e
+0x81c681ef
+0x10006000
+0xe6000800
+0x05a621ef
+0x0200a35a
+0x008072c2
+0x031065f8
+0x019492f9
+0x81d08be2
+0x021806a0
+0x00000000
+0xe2200202
+0x008ca362
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x0001a120
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x0000016c
+0x0080c08c
+0x008013a8
+0x008013a0
+0x008013ac
+0x008013a8
+0x008013a0
+0x008013a4
+0x008013b0
+0x0080bbfe
+0x008013a4
+0x008013a0
+0x008013a8
+0x008013a0
+0x008013a8
+0x008013a0
+0x008013ac
+0x00801d78
+0x0080172e
+0x00801d58
+0x0080172e
+0x00801d58
+0x00801ac4
+0x00801d80
+0x00801d80
+0x00801d50
+0x00801d34
+0x00801d80
+0x00801d80
+0x00801d80
+0x00801d80
+0x00801d80
+0x00801d80
+0x00801d16
+0x00801cf8
+0x00801ce0
+0x008015c4
+0x00801d80
+0x00801d80
+0x00801d80
+0x00801d80
+0x00809666
+0x00801d80
+0x00801cc4
+0x00801cb2
+0x0080190c
+0x00801ba0
+0x00801ba4
+0x008017d8
+0x0080190c
+0x00801ba0
+0x00801ba4
+0x008017d8
+0x0080190c
+0x00801ba0
+0x00801ba4
+0x008017d8
+0x0080190c
+0x00801ba0
+0x00801ba4
+0x008017d8
+0x00801d80
+0x00801d80
+0x00801d80
+0x00801d80
+0x00801d80
+0x00801d80
+0x00801d80
+0x00801d80
+0x00801d80
+0x00801d80
+0x00801d80
+0x00801d80
+0x0060f557
+0x00801d80
+0x00801d80
+0x00801d80
+0x00801d80
+0x00801b84
+0x00801b68
+0x00801b54
+0x00801b20
+0x00801d80
+0x00801d80
+0x00801af4
+0x00801674
+0x00801ad8
+0x00808664
+0x00808648
+0x008085f4
+0x00808628
+0x00808608
+0x00807e7a
+0x00807d9a
+0x00807d2e
+0x00807c90
+0x00000000
diff --git a/src/make/ibl_c6472/ibl.cmd b/src/make/ibl_c6472/ibl.cmd
--- /dev/null
@@ -0,0 +1,73 @@
+/************************************************************************************
+ * FILE PURPOSE: Define the memory usage of the ibl module for the c6455
+ ************************************************************************************
+ * FILE NAME: ibl.cmd
+ *
+ * DESCRIPTION: The memory placement for the IBL is defined
+ *
+ ************************************************************************************/
+
+
+../main/c64x/make/iblmain.oc
+../device/c64x/make/c6472.oc
+../ethboot/c64x/make/ethboot.oc
+../nandboot/c64x/make/nandboot.oc
+../driver/c64x/make/net.oc
+../driver/c64x/make/arp.oc
+../driver/c64x/make/ip.oc
+../driver/c64x/make/udp.oc
+../driver/c64x/make/stream.oc
+../driver/c64x/make/timer.oc
+../driver/c64x/make/bootp.oc
+../driver/c64x/make/tftp.oc
+../driver/c64x/make/nand.oc
+../hw/c64x/make/t64.oc
+../hw/c64x/make/cpmacdrv.oc
+../hw/c64x/make/pll.oc
+../hw/c64x/make/psc.oc
+../hw/c64x/make/emif31.oc
+../hw/c64x/make/mdio.oc
+../hw/c64x/make/gpio.oc
+../hw/c64x/make/nandgpio.oc
+../hw/c64x/make/i2c.oc
+../interp/c64x/make/bis.oc
+../interp/c64x/make/cload.oc
+../interp/c64x/make/osal.oc
+../interp/c64x/make/btblwrap.oc
+../interp/c64x/make/btblpr.oc
+../interp/c64x/make/gem.oc
+../interp/c64x/make/blob.oc
+../ecc/c64x/make/3byte_ecc.oc
+
+-c
+-stack 0x800
+-heap 0x4800
+
+
+
+MEMORY
+{
+ TEXT : origin = 0x801000, length = 0x10000
+ STACK : origin = 0x811000, length = 0x0800
+ HEAP : origin = 0x811800, length = 0x4800
+ DATA : origin = 0x816000, length = 0x3000
+ CFG : origin = 0x820000, length = 0x0300
+ STAT : origin = 0x820300, length = 0x0200
+}
+
+SECTIONS
+{
+ .stack > STACK
+ .sysmem > HEAP
+ .cinit > TEXT
+ .const > TEXT
+ .text > TEXT
+ .switch > TEXT
+ .far > DATA
+ .bss > DATA
+
+ .ibl_config_table > CFG
+ .ibl_status_table > STAT
+
+}
+
diff --git a/src/make/ibl_c6472/ibl.rmd b/src/make/ibl_c6472/ibl.rmd
--- /dev/null
@@ -0,0 +1,12 @@
+-a
+-boot
+-e _c_int00
+-order L
+
+ROMS
+{
+ ROM1: org = 0x0400, length = 0x10000, memwidth = 32, romwidth = 32
+ files = { ibl.b }
+}
+
+
diff --git a/src/make/makedep/makedep.awk b/src/make/makedep/makedep.awk
--- /dev/null
@@ -0,0 +1,735 @@
+#*****************************************************************************
+#* FILE PURPOSE:Scan C files for include references
+#*
+#******************************************************************************
+#* FILE NAME: makedep.awk
+#*
+#* DESCRIPTION:
+#*
+#* NOTE: Written for Thompson Automation TAWK compiler
+#*
+#* NOTE: Processes #includes even in false conditional compilation
+#*
+#* (C) Copyright 1999, Telogy Networks, Inc.
+#******************************************************************************
+
+local progname = "makedep"
+local version_string = "V1.01"
+local version_date = "Aug 17, 2001"
+
+#*******************************************************************************
+# Types & Constants
+#*******************************************************************************
+local true = 1
+local false = 0
+
+local c_re_include = /^[ \t]*#[ \t]*include[ \t]+/
+local s_re_include = /^[ \t]*\.(include|copy)[ \t]+/
+local re_include = c_re_include
+
+#*******************************************************************************
+# Command Line Options
+#*******************************************************************************
+local quiet = false
+local no_warn = false
+local bracket_includes = true
+local quote_includes = true
+local abs_paths = true
+local recurse = true
+local depend_not_found = false
+local stdout_format = false
+local indent_string = " "
+local objext = "obj"
+local outfile_spec = ""
+
+local outfile = ""
+local infile = ""
+local infile_basename
+
+local err_file
+
+local orig_argc
+
+
+local paths[]
+local depends[] # actually [][]
+local processed_files[]
+
+#*******************************************************************************
+# Syntax
+#*******************************************************************************
+local comment_start = "# "
+local comment_stop = ""
+local eol_continue = "\\"
+
+#*******************************************************************************
+# File Processing
+#*******************************************************************************
+local file_error = false
+
+#*******************************************************************************
+# Program Debug & Control
+#*******************************************************************************
+local trace_file = "trace.out"
+local trace_classes[]
+local exit_code = -1
+local banner_done = false
+
+#*******************************************************************************
+# Top Level Functions
+#*******************************************************************************
+BEGIN \
+{
+ local i
+ local j
+ local option
+ local arg
+ local sub_option
+ local input_found = false
+ local any_gen = false
+
+ trace_classes[ "includes" ] = 0
+ trace_classes[ "flow" ] = 0
+ trace_classes[ "file" ] = 0
+ trace_classes[ "fileops" ] = 0 # 1 = inhibit file delete rename, etc
+
+
+ paths[0] = 1
+ paths[1] = "" # place holder for "current place" directory
+
+ trace( "flow", "BEGIN" )
+
+ err_file = stdout
+
+ for ( i=1; i < ARGC; i++)
+ {
+ if (ARGV[i] ~ /^-/)
+ {
+ option = substr(ARGV[i], 2, 1)
+ arg = substr(ARGV[i], 3)
+
+ if (option == "I")
+ {
+ if (arg == "")
+ {
+ # don't process this argument as a file
+ ARGV[i] = ""
+
+ i++
+ arg = ARGV[i]
+ }
+ paths[0]++
+ paths[paths[0]] = arg
+ }
+ else if (option == "a")
+ {
+ re_include = s_re_include
+ }
+ else if (option == "e")
+ {
+ if (arg == "")
+ {
+ # don't process this argument as a file
+ ARGV[i] = ""
+
+ i++
+ arg = ARGV[i]
+ }
+ objext = arg
+ }
+ else if (option == "f")
+ {
+ depend_not_found = true
+ }
+ else if (option == "p")
+ {
+ stdout_format = true
+ }
+ else if (option == "o")
+ {
+ if (arg == "")
+ {
+ # don't process this argument as a file
+ ARGV[i] = ""
+
+ i++
+ arg = ARGV[i]
+ }
+ outfile_spec = arg
+ }
+ else if (option == "r")
+ {
+ recurse = false
+ }
+ else if (option == "s")
+ {
+ bracket_includes = false
+ }
+ else if (option == "q")
+ {
+ quiet = true
+ }
+ else if (option == "w")
+ {
+ no_warn = true
+ }
+ else if (option == "d")
+ {
+ process_trace_option(arg)
+ }
+ else if (option == "h" || option == "?")
+ {
+ help()
+ }
+ else
+ {
+ fatal_error("bad option:" ARGV[i])
+ }
+
+ # don't process this argument as a file
+ ARGV[i] = ""
+ }
+ else
+ {
+ input_found = true
+ ARGV[i] = to_abs_path(ARGV[i])
+ }
+ }
+
+ if (!quiet)
+ {
+ banner()
+ }
+
+ if (stdout_format)
+ {
+ if (outfile_spec != "")
+ {
+ fatal_error("can't specify both -p and -o")
+ }
+
+ err_file = stderr
+ outfile = stdout
+ }
+
+ if (outfile_spec == "")
+ {
+ outfile_spec = "./$.d"
+ }
+
+ if (!input_found)
+ {
+ fatal_error("nothing to do, use " progname "-h for help");
+ }
+
+ # we add more arguments as we go so remember the number of original args
+ orig_argc = ARGC
+}
+
+match( $0, re_include ) != 0 \
+{
+ local num_depends
+ local filename
+ local abs_filename
+ local this_dir
+
+ trace("includes", "#include line:" $0)
+
+ # find directory of current file
+ this_dir = file_path(FILENAME)
+ if (this_dir == "")
+ {
+ this_dir = "./"
+ }
+
+ # assume that the file name is the second arg
+ filename = $2
+
+ # is this a bracket include?
+ if (filename ~ /^</)
+ {
+ # yes, should we process it?
+ if (!bracket_includes)
+ {
+ # no
+ next
+ }
+ paths[1] = ""
+ }
+ else
+ {
+ # no, must be a quote include, should we process it?
+ if (!quote_includes)
+ {
+ # no
+ next
+ }
+ paths[1] = this_dir
+ }
+
+ # strip off the quotes or brackets
+ if (filename ~ /^[<"]/)
+ {
+ filename = substr(filename, 2, length(filename)-2)
+ }
+
+ abs_filename = find_file(filename, paths);
+ if (abs_filename == "")
+ {
+ warn("include file not found", filename)
+ abs_filename = filename
+ }
+ else
+ {
+ if (recurse && !(abs_filename in processed_files))
+ {
+ trace("flow", "queueing file " abs_filename)
+ ARGV[ARGC] = abs_filename
+ processed_files[abs_filename] = 1
+ ARGC++
+ depends[abs_filename][0] = 0
+ }
+ }
+
+ num_depends = depends[FILENAME][0]+1
+ depends[FILENAME][num_depends] = abs_filename
+ depends[FILENAME][0] = num_depends
+
+ next
+}
+
+# all other lines do nothing
+{
+ next
+}
+
+END \
+{
+ local arg
+
+ trace( "flow", "END" )
+
+ if (exit_code >= 0)
+ {
+ exit(exit_code)
+ }
+
+ for (arg=1; arg < orig_argc; arg++)
+ {
+ delete processed_files
+ infile = ARGV[arg]
+
+ if (infile != "" && !stdout_format)
+ {
+ file_done()
+
+ infile_basename = basename(infile)
+ infile_basename = strip_ext(infile_basename)
+ outfile = outfile_spec
+ gsubs("$", infile_basename, outfile, 0)
+
+ gen_header()
+ file_error = false
+ }
+
+ process_depends(infile, 1)
+ }
+}
+
+#*******************************************************************************
+# Command Line Functions
+#*******************************************************************************
+function process_trace_option(arg)
+{
+ local i
+ local setting
+
+ if ( arg ~ /^\+/ )
+ {
+ setting = 1
+ }
+ else if ( arg ~ /^-/ )
+ {
+ setting = 0
+ }
+ else
+ {
+ fatal_error("bad debug option:" ARGV[i])
+ }
+
+ arg = substr(arg,2)
+ if (arg == "")
+ {
+ for (i in trace_classes)
+ {
+ trace_classes[i] = setting
+ }
+ }
+ else if (arg in trace_classes)
+ {
+ trace_classes[arg] = setting
+ }
+ else
+ {
+ banner()
+ print "Valid Trace Classes are:"
+ for (i in trace_classes)
+ {
+ print "\t" i
+ }
+ fatal_error("unknown trace class " arg)
+ }
+}
+
+function banner()
+{
+ if (banner_done)
+ {
+ return
+ }
+
+ banner_done = true
+ print toupper(progname) " " version_string ": C include dependency generator/lister" >err_file
+ print "Last updated " version_date >err_file
+}
+
+function help()
+{
+ banner()
+ print "usage " progname " <options> <file>"
+ print "where options is 0 or more of the following:"
+ print "(default values are listed in paren's)"
+ print " -Idir add an include path"
+ print " -a use asm format includes"
+ print " -eext set obj extension to ext"
+ print " -s don't process standard include files ie. <>"
+ print " -r don't recurse to find dependencies of found include file"
+ print " -o specify output file (./$.d)"
+ print " -p pipe output to stdout w/o extra formating"
+ print " -q quiet mode (no banner)"
+ print " -w suppress warnings"
+ print " -d(+|-)[trace class] this program's diagnostics (see source)"
+ print " -h or -? this help"
+ exit_code = 10
+ exit
+}
+
+#*******************************************************************************
+# File Functions
+#*******************************************************************************
+function file_done()
+{
+ close( outfile )
+ if ( file_error )
+ {
+ delete_file( outfile )
+ }
+}
+
+function file_time( name )
+{
+ return ctime(filetime(name))
+}
+
+function file_exists( name )
+{
+ return ( filemode(name) != "" )
+}
+
+function rename_file( old_name, new_name )
+{
+ trace( "file", "rename " old_name " to " new_name )
+ if ( !traceif( "fileops" ) )
+ {
+ delete_file( new_name )
+ if ( !file_exists( old_name ) )
+ {
+ print "File does not exist: " old_name
+ }
+ else
+ {
+ rename(old_name,new_name)
+ }
+ }
+}
+
+function delete_file( name )
+{
+ trace( "file", "delete " name )
+ if ( !traceif( "fileops" ) && file_exists( name ) )
+ {
+ rmfile(name)
+ }
+}
+
+# return filename without extension
+function strip_ext( filename )
+{
+ local new_name
+
+ # match the extension ( last dot and file component after it )
+ if ( match( filename, /\.[^ \t/\\.]*$/ ) != 0 )
+ {
+ # has an extension, return everything up to but not including it
+ new_name = substr( filename, 1, RSTART-1 )
+ }
+ else
+ {
+ # does not have an extension, return it all
+ new_name = filename
+ }
+
+ trace( "file", "strip_ext of " filename " gives " new_name )
+ return new_name
+}
+
+# return extension
+function file_ext( filename )
+{
+ local new_name
+
+ # match the extension ( last dot and file component after it )
+ if ( match( filename, /\.[^ \t/\\.]*$/ ) != 0 )
+ {
+ # has an extension, return it
+ new_name = substr( filename, RSTART )
+ }
+ else
+ {
+ # does not have an extension, return it all
+ new_name = ""
+ }
+
+ trace( "file", "filename_ext of " filename " gives " new_name )
+ return new_name
+}
+
+# return filename.ext w/o leading paths
+function basename( filename )
+{
+ local new_name
+
+ new_name = filename
+
+ # turn all backslashes to forward slashes
+ gsubs("\\", "/", new_name)
+
+ # match the basename (everything after the last slash)
+ if ( match( new_name, /\/[^/]*$/ ) != 0 )
+ {
+ # match found, return it
+ new_name = substr(new_name, RSTART+1)
+ }
+ else
+ {
+ # no slashes found, strip off any drive spec
+ # for this purpose a drive spec is everything before the first colon
+ if ( match( new_name, /:[^:]*$/ ) != 0 )
+ {
+ # match found, return it
+ new_name = substr(new_name, RSTART+1)
+ }
+ }
+
+ trace( "file", "basename of " filename " gives " new_name )
+ return new_name
+}
+
+# return drive & directories of filename
+function file_path( filename )
+{
+ local new_name
+
+ new_name = filename
+
+ # turn all backslashes to forward slashes
+ gsubs("\\", "/", new_name)
+
+ # match the basename (everything after the last slash)
+ if ( match( new_name, /\/[^/]*$/ ) != 0 )
+ {
+ # match found, return it
+ new_name = substr(new_name, 1, RSTART-1)
+ }
+ else
+ {
+ # no slashes found, strip off any drive spec
+ # for this purpose a drive spec is everything before the first colon
+ if ( match( new_name, /:[^:]*$/ ) != 0 )
+ {
+ # match found, return it
+ new_name = substr(new_name, 1, RSTART-1)
+ }
+ else
+ {
+ # no drive & no directories
+ new_name = ""
+ }
+ }
+
+ trace( "file", "basename of " filename " gives " new_name )
+ return new_name
+}
+
+function to_abs_path(filename)
+{
+ # not implemented yet
+ return filename
+}
+
+function find_file(filename, path_array)
+{
+ local i
+ local test_file
+ local num_paths
+
+ num_paths = path_array[0]
+
+ for (i=1; i <= num_paths; i++)
+ {
+ test_file = path_array[i]
+
+ if (test_file != "")
+ {
+ if (!(test_file ~ /\/$/))
+ {
+ test_file = test_file "/"
+ }
+ test_file = test_file filename
+ test_file = to_abs_path(test_file)
+
+ if (file_exists(test_file))
+ {
+ return test_file
+ }
+ }
+ }
+
+ return ""
+}
+
+#*******************************************************************************
+# Output Processing
+#*******************************************************************************
+function process_depends(filename, level)
+{
+ local i
+ local j
+ local abs_file
+ local num_depends
+
+ num_depends = depends[filename][0]
+
+ for (i=1; i <= num_depends; i++)
+ {
+ abs_file = depends[filename][i]
+
+ for (j=0; j < level; j++)
+ {
+ printf("%s", indent_string) >outfile
+ }
+
+ if (abs_file in processed_files)
+ {
+# printf("%s %-40s already included %s %s\n", \
+# comment_start, abs_file, comment_stop, eol_continue) >outfile
+ }
+ else
+ {
+ processed_files[abs_file] = 1
+
+ if (abs_file in depends)
+ {
+ printf("%-40s %s\n", abs_file, eol_continue) >outfile
+# printf("%-40s %s %s %s %s\n", \
+# abs_file, comment_start, file_time(abs_file), \
+# comment_stop, eol_continue) >outfile
+ process_depends(abs_file, level+1)
+ }
+ else
+ {
+ if (depend_not_found)
+ {
+ printf("%-40s %s\n", abs_file, eol_continue) >outfile
+# printf("%-40s %s not found %s %s\n", \
+# abs_file, comment_start, comment_stop, eol_continue) >outfile
+ }
+ else
+ {
+# printf("%s %-40s not found %s %s\n", \
+# comment_start, abs_file, comment_stop, eol_continue) >outfile
+ }
+ }
+ }
+ }
+}
+
+function gen_header()
+{
+ # print header
+
+ local infile_ext
+ local outfile_ext
+
+ infile_ext = file_ext(infile)
+ outfile_ext = file_ext(outfile)
+
+ print comment_start "Dependency file for " infile comment_stop >outfile
+ print comment_start "Generated on " ctime() comment_stop >outfile
+ print comment_start "From " infile " dated " ctime(filetime(infile)) comment_stop >outfile
+ print comment_start "This file was generated by " progname ", do not edit!!" comment_stop >outfile
+ print "" >outfile
+ print infile_basename "." objext, ":", infile, infile_basename outfile_ext, eol_continue >outfile
+}
+
+#*******************************************************************************
+# Support Functions
+#*******************************************************************************
+function error( desc )
+{
+ print "Error: " desc " in " FILENAME " line " FNR >err_file
+ file_error = true
+}
+
+function warn( desc, arg )
+{
+ local err
+
+ if (no_warn)
+ {
+ return
+ }
+
+ if (arg != "")
+ {
+ arg = sprintf("for item %s ", arg)
+ }
+
+ printf("Warning: %s%s in %s line %d\n", arg, desc, FILENAME, FNR) >err_file
+}
+
+function fatal_error( desc )
+{
+ print "Error: " desc >err_file
+
+ exit_code = 3
+ exit
+}
+
+function trace( class, msg )
+{
+ if ( traceif( class ) )
+ {
+ print msg >trace_file
+ }
+}
+
+function traceif( class )
+{
+ if ( !(class in trace_classes) )
+ {
+ print "trace class", class, "missing" >trace_file
+ return true
+ }
+ return ( trace_classes[class] != 0 )
+}
diff --git a/src/make/makestg2 b/src/make/makestg2
--- /dev/null
+++ b/src/make/makestg2
@@ -0,0 +1,60 @@
+#*****************************************************************************
+#* FILE PURPOSE: 2nd stage makefile for the intermediate boot loader
+#*****************************************************************************
+#* FILE NAME: makestg2
+#*
+#* DESCRIPTION: This makefile is invoked with build specific options
+#*
+#******************************************************************************
+
+ifndef IBL_ROOT
+ IBL_ROOT=..
+endif
+
+MODULES= main device ethboot nandboot driver hw interp ecc
+CLEAN_MODULES=$(addprefix clean_,$(MODULES))
+
+
+include $(IBL_ROOT)/make/$(ARCH)/makedefs.mk
+
+export ARCH
+export TARGET
+
+
+c6455: $(MODULES)
+ $(LD) -o ibl_$@/ibl_$@.out -m ibl_$@/ibl_$@.map ibl_$@/ibl.cmd $(RTLIBS)
+
+
+c6472: $(MODULES) utils
+ $(LD) -o ibl_$@/ibl_$@.out -m ibl_$@/ibl_$@.map ibl_$@/ibl.cmd $(RTLIBS)
+ hex6x ibl_$@/ibl.rmd ibl_$@/ibl_$@.out
+ $(CP) ibl.b ibl_$@
+ ../util/btoccs/b2i2c ibl_$@/ibl.b ibl_$@/ibl.i2c.b
+ ../util/btoccs/b2ccs ibl_$@/ibl.i2c.b ibl_$@/ibl.i2c.ccs
+ ../util/romparse_$@/romparse ibl_$@/i2crom.map
+ $(CP) i2crom.ccs ibl_$@
+ $(RM) -f i2crom.ccs ibl.b
+
+
+$(MODULES):
+ @echo making $@
+ make -C $(IBL_ROOT)/$@/$(ARCH)/make $@
+
+utils:
+ make -C $(IBL_ROOT)/util/btoccs
+ make -C $(IBL_ROOT)/util/romparse_$(TARGET)
+
+clean: $(CLEAN_MODULES)
+
+
+$(CLEAN_MODULES):
+ @echo cleaning $(subst clean_, ,$@)
+ make -C $(IBL_ROOT)/$(subst clean_,,$@)/$(ARCH)/make clean
+
+
+
+
+
+
+
+
diff --git a/src/mkdeppath.bat b/src/mkdeppath.bat
--- /dev/null
+++ b/src/mkdeppath.bat
@@ -0,0 +1 @@
+set MAKEDEPPATH=/data/projects/ibl/ibl_0.3/src/make/makedep/makedep.exe
diff --git a/src/nandboot/c64x/make/makefile b/src/nandboot/c64x/make/makefile
--- /dev/null
@@ -0,0 +1,44 @@
+#*************************************************************************************
+#* FILE NAME: makefile
+#*
+#* DESCRIPTION: Makes the nand module for the IBL
+#*
+#*************************************************************************************/
+
+ifndef IBL_ROOT
+ export IBL_ROOT= ../../..
+endif
+
+ECODIR= $(IBL_ROOT)/nandboot
+
+CSRC= nandboot.c
+
+.PHONY: nandboot
+
+
+include $(IBL_ROOT)/make/$(ARCH)/makeeco.mk
+
+
+
+C6X_C_DIR+= $(IBL_ROOT)
+C6X_C_DIR+= ;$(IBL_ROOT)/arch/$(ARCH)
+C6X_C_DIR+= ;$(IBL_ROOT)/device
+C6X_C_DIR+= ;$(IBL_ROOT)/device/$(TARGET)
+C6X_C_DIR+= ;$(IBL_ROOT)/nandboot
+C6X_C_DIR+= ;$(IBL_ROOT)/driver/nand
+C6X_C_DIR+= ;$(STDINC)
+export C6X_C_DIR
+
+
+
+nandboot: gen_cdefdep makefile $(OBJS)
+
+
+$(OBJS): cdefdep
+
+gen_cdefdep:
+ @echo Checking command line dependencies
+ @echo $(ENDIAN) $(TARGET) > cdefdep.tmp
+ @sh -c 'if diff -q cdefdep.tmp cdefdep ; then echo same ; else $(CP) cdefdep.tmp cdefdep ; fi '
+
+
diff --git a/src/nandboot/nandboot.c b/src/nandboot/nandboot.c
--- /dev/null
+++ b/src/nandboot/nandboot.c
@@ -0,0 +1,55 @@
+/***********************************************************************************
+ * FILE PURPOSE: The NAND boot wrapper
+ ***********************************************************************************
+ * FILE NAME: nandboot.c
+ *
+ * DESCRIPTION: This file provides the nand boot wrapper used by IBL modules
+ *
+ * @file nandboot.c
+ *
+ * @brief
+ * The nand boot wrapper
+ *
+ ************************************************************************************/
+#include "types.h"
+#include "ibl.h"
+#include "iblloc.h"
+#include "nand.h"
+#include "device.h"
+
+
+void iblNandBoot (void)
+{
+ Uint32 entry;
+ void (*exit)();
+
+ /* Power up the device */
+ if (devicePowerPeriph (TARGET_PWR_NAND) < 0)
+ return;
+
+
+ /* Perform any device specific configurations */
+ if (deviceConfigureForNand() < 0)
+ return;
+
+
+ /* Open the nand driver */
+ if ((*nand_boot_module.open) ((void *)&ibl.nandConfig, NULL))
+ return;
+
+
+ entry = iblBoot (&nand_boot_module, ibl.nandConfig.bootFormat, &ibl.nandConfig.blob);
+
+ (*nand_boot_module.close)();
+
+ if (entry != 0) {
+
+ iblStatus.exitAddress = entry;
+ exit = (void (*)())entry;
+ (*exit)();
+
+ }
+
+ }
+
+
diff --git a/src/setupenv.bat b/src/setupenv.bat
--- /dev/null
+++ b/src/setupenv.bat
@@ -0,0 +1,91 @@
+@echo off
+
+rem Setup the ibl build environment
+
+
+set PATH=t:\gen\gnu\99-11-01\cygwin-b20\H-i586-cygwin32\bin;c:\tools\c6xx\cgen6_1_12\c6000\cgtools\bin
+set PATH=%PATH%;%SystemRoot%\system32;%SystemRoot%;t:\ti_pdsp_cgen\20091120
+
+set PERL=//t/gen/perl/activestate/5_6_1_635/bin/perl
+set PERLDOS=t:\gen\perl\activestate\5_6_1_635\bin\perl
+
+set CYGWINPATH=//t/gen/gnu/99-11-01/cygwin-b20/H-i586-cygwin32/bin
+set TOOLSC6X=c:/tools/c6xx/cgen6_1_12/c6000
+set TOOLSC6XDOS=c:\tools\c6xx\cgen6_1_12\c6000\
+
+set TOOLC6XSRC=t:\c6xx\cgen6_1_12\c6000
+set TOOLC6XDST=c:\tools\c6xx\cgen6_1_12\c6000
+
+rem splint libraries
+set LARCH_PATH=e:\splint-3.1.1\lib
+
+rem Generate path to makedep, then set it
+rm -f mkdeppath.bat
+rem sh -c "makedepdir=`pwd`;echo set MAKEDEPPATH=`dirname $makedepdir`/make/makedep/makedep.exe" >mkdeppath.bat
+sh -c "makedepdir=`pwd`;echo set MAKEDEPPATH=`pwd`/make/makedep/makedep.exe" >mkdeppath.bat
+call mkdeppath.bat
+
+
+rem ************************* Tools Copy/Validation **************************
+rem If the "bypass" option is not provided, validate/copy the tools
+rem *********************************************************************
+if "%1" == "bypass" goto environment
+
+rem check, but don't copy tools
+if "%1" == "" goto toolcheck
+
+rem copy tools if check fails
+if "%1" == "enable_write" goto toolcopy
+
+rem error: invalid argument
+echo =========================== INVALID ARGUMENT ============================
+echo Option "%1" is invalid. Valid options are:
+echo "bypass": configure environment without checking tools
+echo "enable_write": *****ERASE***** all files in %TOOLDST%,
+echo and replace with correct tools
+echo =========================== INVALID ARGUMENT ============================
+goto end
+
+:toolcheck
+echo Verifying local tools
+goto toolperl
+
+:toolcopy
+echo UPDATING local tools
+:toolperl
+%PERLDOS% make\cpytools\cpytools.pl %TOOLC6XSRC% %TOOLC6XDST% %1
+rem note: windows is stupid; "errorlevel 1" means "retval >= 1"
+if errorlevel 1 goto error
+
+echo Local tools are good
+goto environment
+
+
+rem ************************** Bad Tools *************************************
+rem Tools are bad; deconfigure environment and print error
+rem **************************************************************************
+:error
+set TOOLS=
+set TOOLSDOS=
+set MAKEDEPPATH=
+
+echo ============================== BAD TOOLS =================================
+echo * Build environment is NOT configured. You may rerun script with:
+echo *
+echo * %0 bypass
+echo * configure environment without checking tools. This option is
+echo * is used when the user will manually configure the tools.
+echo *
+echo * %0 enable_write
+echo * [*** DANGEROUS OPTION ***]
+echo * This option
+echo * 1) *** DANGER *** Recursively deletes all files in subdirectories
+echo * %DST365% and %TOOLDST%
+echo * 2) Copies correct tools from the subdirectories
+echo * %SRC365% and %TOOLSRC%
+echo *
+echo ============================== BAD TOOLS =================================
+
+:environment
+:end
+
diff --git a/src/test/test1/makefile b/src/test/test1/makefile
--- /dev/null
+++ b/src/test/test1/makefile
@@ -0,0 +1,19 @@
+# makefile for test1
+
+test1.btbl.bin: test1.btbl.ccs
+ ..\util\ccs2bin $< $@
+
+test1.btbl.ccs: test1.btbl
+ ..\util\b2ccs $< $@
+
+test1.btbl: test1.out
+ hex6x -a -order L -boot -e=_c_int00 -bootorg=0x0400 -memwidth32 -romwidth32 -o=test1.btbl test1.out
+
+test1.out: test1.obj test1.cmd
+ cl6x -z -o test1.out -m test1.map test1.cmd $(TOOLSC6X)/cgtools/lib/rts64plus.lib
+
+
+test1.obj: test1.c
+ cl6x -g -c -mv 6400+ test1.c
+
+
diff --git a/src/test/test1/test1.btbl b/src/test/test1/test1.btbl
--- /dev/null
@@ -0,0 +1,51 @@
+\ 2
+$A0400,
+00 84 02 E0 00 00 03 C0 00 84 00 00 00 13 EA 59 86 77 35 77 C0 00 11 11
+B5 D6 20 46 46 46 85 77 D0 28 36 64 81 FF FF A8 E3 40 01 48 81 FF FF E8
+80 0F EA 58 06 60 A3 58 60 46 AB BA 00 00 34 10 02 28 02 64 02 28 90 5A
+E1 00 80 40 C1 C6 65 C6 01 82 01 62 01 AD 40 78 01 8D 60 58 01 8D 8F 78
+05 0C 80 58 00 28 20 64 E0 30 00 00 CF FF FC 91 C2 28 02 64 C0 00 2C 10
+C2 28 90 5A 01 80 0F D8 C5 8C 0F D8 C3 0C 0F D8 01 FF FF A8 01 FF FF E8
+00 0F EA 58 20 46 48 2A D0 0C 02 64 95 0C 1F DA 80 04 A3 58 90 00 1F DB
+E0 80 80 30 8C 6E 04 3A 6C 6E 00 6F 01 83 01 62 00 28 32 E6 01 2B 6C 6E
+20 00 03 62 0C 6E 6C 6E EA 60 90 00 05 3C 33 E5 01 B4 1F DA 00 0C 03 63
+06 3C 33 E4 05 3C 52 E6 00 00 60 00 00 00 00 00 00 00 00 00 01 8A 4C 29
+05 BC 54 F4 01 80 42 68 01 8C 02 64 02 FC A3 5A 02 7F FF AA 02 7F FF EA
+02 94 8A 7A 01 8C 0A 58 05 3C 22 F4 06 EB B5 A9 21 8A 4E 28 30 10 03 63
+21 80 42 68 21 8C 02 64 E0 80 80 20 2C 6E 46 46 01 82 01 62 01 8A 4E 28
+01 80 42 68 01 8C 02 64 0C 6E 4C 6E 00 0C 13 62 E4 20 00 00 01 81 81 62
+02 0A 4A 2A 02 00 42 6A 85 06 10 0D 04 BB 4C 6E 20 00 03 62 00 00 60 00
+E3 00 80 00 01 81 01 62 01 8A 48 28 01 80 42 68 00 0C 02 64 04 BA 6C 6E
+C0 00 13 62 00 00 60 00 E2 00 80 00 01 81 01 62 01 8A 50 28 01 80 42 68
+01 8C 02 64 00 0C 13 62 01 86 81 62 10 00 44 12 E0 10 00 00 00 00 A1 20
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 18 29 F1 00 98 47 A1 04 04 A3 58 C1 90 36 A5 C4 00 01 29
+04 90 1F D8 82 90 56 A7 84 A5 0A 25 00 18 79 A3 01 18 87 A0 A8 10 37 B5
+14 4E A2 56 00 84 A3 5A 23 90 37 A5 20 03 E1 A3 E1 00 00 C0 01 00 68 DA
+60 0C 03 63 28 90 37 A7 20 03 E0 5A C1 94 36 35 C0 80 40 43 D8 6F 52 C7
+E8 00 10 00 82 94 56 37 84 88 2A B4 A8 14 37 55 00 20 0F D8 C3 94 37 75
+C0 03 E1 A0 00 83 80 01 C8 94 37 76 03 90 37 A4 00 00 40 00 00 00 00 00
+00 03 40 01 03 94 37 74 00 8C A3 62 00 00 00 00 00 00 00 00 07 BF 00 5A
+02 04 A3 5A 05 10 03 A2 00 00 00 00 02 28 03 E2 2C 6E BC 45 02 89 80 2A
+E4 00 00 00 02 80 42 6A 2C 6E 10 C5 00 22 A1 20 01 89 00 28 01 80 42 68
+01 8C 02 64 4C 6E 86 C1 E8 40 00 00 2C 6E 00 35 00 1A A1 20 01 89 02 28
+01 80 42 68 01 8C 02 64 02 14 3E C2 00 35 4C 6E E8 20 00 00 A2 8A 2C 6E
+6C 6E BC 4D 00 10 2F 5A 28 27 99 BB 4F F4 A1 20 00 0A A1 20 00 00 00 00
+E1 60 80 00 07 88 FE 2A 07 80 42 6A 07 BF 09 F2 07 0A 52 2A 07 00 42 6A
+02 00 00 2A 02 00 42 6A 00 10 03 62 02 10 00 28 01 83 41 62 02 00 42 68
+01 81 A0 28 01 80 42 68 00 00 00 00 00 0C 13 62 01 88 81 62 02 00 70 2A
+02 00 42 6A 00 10 03 62 01 85 61 62 02 04 A3 58 00 05 A1 20 00 00 00 00
+00 00 00 00 02 FF FF A8 02 FF FF E9 02 81 30 2A 02 80 42 6B 96 E9 FE 27
+02 EF 62 C6 32 0C 02 65 E6 00 06 00 02 00 A3 58 01 80 A3 58 31 94 80 58
+00 00 00 00 02 0C 1F DA 00 00 00 00 00 00 00 00 00 00 00 00 00 8C A3 62
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 01 A1 20 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 08 00 84 12 00 11 11 11 11 22 22 22 22
+00 00 00 74 00 84 20 00 00 00 00 04 00 84 14 90 00 00 00 00 00 00 00 00
+00 00 00 04 00 84 14 94 00 00 00 00 00 00 00 00 00 00 00 04 00 84 14 98
+00 00 00 01 00 00 00 00 00 00 00 04 00 84 14 9C 00 84 03 80 00 00 00 00
+00 00 00 04 00 84 14 A0 00 84 03 80 00 00 00 00 00 00 00 04 00 84 14 A4
+12 34 56 78 00 00 00 00 00 00 00 04 00 84 14 A8 AB CD 12 34 00 00 00 00
+00 00 00 00 00 00 00 00
+\ 3
\ No newline at end of file
diff --git a/src/test/test1/test1.btbl.bin b/src/test/test1/test1.btbl.bin
new file mode 100644 (file)
index 0000000..3a58770
Binary files /dev/null and b/src/test/test1/test1.btbl.bin differ
index 0000000..3a58770
Binary files /dev/null and b/src/test/test1/test1.btbl.bin differ
diff --git a/src/test/test1/test1.c b/src/test/test1/test1.c
--- /dev/null
+++ b/src/test/test1/test1.c
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * FILE PURPOSE: A very simple test program used to verify IBL loading
+ *******************************************************************************
+ * FILE NAME: test1.c
+ *
+ * DESCRIPTION: A simple program that simply verifies the loading of
+ * several sections.
+ *
+ * @file test1.c
+ *
+ * @brief
+ * Verify the IBL
+ *
+ ********************************************************************************/
+
+/**
+ * @brief Test loading some const sections
+ */
+const unsigned int c1 = 0x12345678;
+const unsigned int c2[] = { 0x11111111, 0x22222222 };
+
+
+/**
+ * @brief Test load the cinit section
+ */
+unsigned int cini1 = 0xabcd1234;
+
+
+/**
+ * @brief The bss/far sections should not actually load
+ */
+unsigned int cbss[100];
+
+
+extern cregister volatile unsigned int TSCL;
+/**
+ * @brief The text section which will include a switch
+ */
+void main (void)
+{
+ unsigned int v;
+
+ /* Start the system timer */
+ TSCL = 1;
+
+
+ /* Read the timer and put the value in the bss */
+ v = TSCL;
+
+ cbss[0] = v;
+
+ switch (v & 1) {
+
+ case 0: cbss[1] = c2[0];
+ break;
+
+ case 1: cbss[2] = c2[1];
+ break;
+
+ }
+
+ for (;;);
+
+}
+
+
+
+
+
+
+
+
+
diff --git a/src/test/test1/test1.cmd b/src/test/test1/test1.cmd
--- /dev/null
+++ b/src/test/test1/test1.cmd
@@ -0,0 +1,32 @@
+/* Linker command file for test1 */
+
+test1.obj
+
+-c
+-stack 0x200
+
+/* Memory must not conflict with the IBL */
+MEMORY
+{
+ TEXT : origin = 0x840000, length = 0x1000
+ STACK : origin = 0x841000, length = 0x200
+ CONST : origin = 0x841200, length = 0x100
+ FAR : origin = 0x841300, length = 0xd00
+ CINIT : origin = 0x842000, length = 0x400
+ SWITCH : origin = 0x842400, length = 0x400
+
+}
+
+SECTIONS
+{
+ .text > TEXT
+ .stack > STACK
+ .const > CONST
+ .far > FAR
+ .bss > FAR
+ .cinit > CINIT
+ .switch > SWITCH
+
+}
+
+
diff --git a/src/test/test2/c0.c b/src/test/test2/c0.c
--- /dev/null
+++ b/src/test/test2/c0.c
@@ -0,0 +1,134 @@
+//#pragma DATA_SECTION(nint_c0, ".data0")
+//int nint_c0 = 1024;
+
+
+#pragma DATA_SECTION(c0, ".dconst")
+const unsigned int c0[] = {
+ 0x7efeb0e7,0xe4ff9b3d,0xdffb7483,0xbefbae39,0xbffed5df,0x33fff4f5,0x2f9ef0fb,0x459feb71,
+ 0xdfffa1d7,0xfbdecdad,0x7bf28473,0xbf7797a9,0x756ef4cf,0x7f5d0565,0x66ba0eeb,0x6f5992e1,
+ 0x5e56aec7,0x7eff7c1d,0xff977063,0x7df8bd19,0x7bdeafbf,0x36af11d5,0xffee88db,0x3f7bf651,
+ 0xffb6d7b7,0xcbbca68d,0x70e33853,0x7ff61e89,0xfedf06af,0x5fbd1a45,0x759f5ecb,0x6fbe15c1,
+ 0x61671ca7,0x5f5d4cfd,0x3ffadc43,0x76e6bbf9,0x37fef99f,0xfeee1eb5,0x796b90bb,0xfbdef131,
+ 0xdf567d97,0xbff46f6d,0xf7fb5c33,0xfff19569,0xfbef888f,0xffdd1f25,0xbdfe1eab,0x7bcd88a1,
+ 0x7ffffa87,0xffbd0ddd,0x6fd3b823,0x6fbdaad9,0x1e9fb37f,0x6ffd1b95,0x5cae089b,0x5fb8dc11,
+ 0x7ff69377,0x3ffe284d,0xef32f013,0x7f71fc49,0xff5e7a6f,0x3bfd1405,0x7e7e4e8b,0xff7feb81,
+ 0xfe3f4867,0x6e16bebd,0xffba0403,0xfff589b9,0x7ffedd5f,0x67fc0875,0x70bbf07b,0x4ff9b6f1,
+ 0xcedf1957,0x7e5dd12d,0xff63f3f3,0x5abf5329,0x7fbfdc4f,0x5fdcf8e5,0xffbfee6b,0x5dcd3e61,
+ 0x6db70647,0x7f7e5f9d,0xbd9fbfe3,0x3de65899,0xbf7e773f,0x3d3ee555,0xbbeb485b,0xfdf981d1,
+ 0x34760f37,0x6cff6a0d,0x6de267d3,0xbff19a09,0xcebfae2f,0xef3ccdc5,0xffbafe4b,0x7c2d8141,
+ 0x4ee73427,0x57d7f07d,0xfb72ebc3,0xfde81779,0x1cfe811f,0xbd6db235,0x37de103b,0x17f83cb1,
+ 0xf5bf7517,0x4d5ef2ed,0xd7664bb3,0xf7f0d0e9,0x7deff00f,0xfc9c92a5,0xefff7e2b,0x57d8b421,
+ 0xf4ffd207,0xffff715d,0xeefb87a3,0xdaf2c659,0xe69efaff,0xe4cc6f15,0xe6ae481b,0x1fbde791,
+ 0xfff74af7,0x5ff46bcd,0x9fab9f93,0xefd4f7c9,0xfeeea1ef,0xf6fc4785,0x7dff6e0b,0x7dfed701,
+ 0x7dbedfe7,0xeff4e23d,0x7e7b9383,0xff7e6539,0xffffe4df,0xbf7f1bf5,0xbffbeffb,0xdeda8271,
+ 0x6cf790d7,0x7df7d4ad,0x73ea6373,0x97760ea9,0xee7fc3cf,0xfb7fec65,0x9fbacdeb,0x77efe9e1,
+ 0x53565dc7,0xfff4431d,0xfbd30f63,0xe762f419,0xbeff3ebf,0x19cdb8d5,0xcbef07db,0x77fe0d51,
+ 0xeffe46b7,0x1ffd2d8d,0xdb569753,0xed9c1589,0x1d8f55af,0xffbf8145,0x7aff9dcb,0x7bebecc1,
+ 0xfee64ba7,0x4a7593fd,0x69f3fb43,0x95f872f9,0x72bf089f,0x7dec45b5,0x1e5f8fbb,0x5dd88831,
+ 0x5b976c97,0x7ea4766d,0xffaa3b33,0xfeff0c69,0x77ef578f,0x4a9f0625,0x13ffddab,0xbd1adfa1,
+ 0x75c6a987,0xadfcd4dd,0x7cd65723,0xfe76e1d9,0x77bf427f,0x7b4ec295,0x7fff879b,0x3779f311,
+ 0xff770277,0x7ee5af4d,0x6a9b4f13,0xf576f349,0x556fc96f,0xde7e7b05,0x3f7b8d8b,0xfe7cc281,
+ 0x5f277767,0x7f5e05bd,0x3ff62303,0x1b9640b9,0x3effec5f,0xf7fd2f75,0x4b3eef7b,0xb59a4df1,
+ 0xdfd70857,0x7f6cd82d,0xfb67d2f3,0x2ffbca29,0xc1aeab4f,0x37dddfe5,0x5efead6b,0xeac99561,
+ 0x7bc6b547,0x37f5269d,0x7fdb5ee3,0xdcee8f99,0xf67f063f,0x6b4f8c55,0xd6fbc75b,0xeff998d1,
+ 0xff3f7e37,0xaffdf10d,0xefffc6d3,0x2a359109,0xbf3ffd2f,0x6f3d34c5,0xffbf3d4b,0x73395841,
+ 0x9ff66327,0x5bde377d,0xeffa0ac3,0x3f57ce79,0xf7be901f,0xff7dd935,0xddee0f3b,0xe7ffd3b1,
+ 0x4cf66417,0xd64cf9ed,0xf9e32ab3,0xeb7c47e9,0xeeffbf0f,0x5fdc79a5,0x5dff3d2b,0x7ffc0b21,
+ 0xfb568107,0x47fd385d,0xedfa26a3,0x5de9fd59,0x2dfe89ff,0xf3dc1615,0xffabc71b,0x7bbcfe91,
+ 0xf5f7b9f7,0xec75f2cd,0x7783fe93,0x7fd7eec9,0x19cff0ef,0xbfffae85,0x7fdaad0b,0x7ff9ae01,
+ 0xdcb70ee7,0xead6293d,0x5777b283,0x7e3d1c39,0xfbfef3df,0xf8ee42f5,0x5caaeefb,0x6bd91971,
+ 0x7f777fd7,0x30c4dbad,0x6ffa4273,0xeff085a9,0xff2e92cf,0xc47ed365,0xfe3b8ceb,0xef4a40e1,
+ 0x7f760cc7,0x4bf50a1d,0x75faae63,0xde692b19,0x27ffcdbf,0xfedc5fd5,0xf7eb86db,0x7ffc2451,
+ 0x74b7b5b7,0x5ffdb48d,0x1fe3f653,0x5bfe0c89,0x7dcfa4af,0xa9bde845,0x3bbfdccb,0x7dadc3c1,
+ 0x57677aa7,0x7ff5dafd,0x97f71a43,0xeec629f9,0xef3f179f,0xbdfe6cb5,0xbf5f8ebb,0xeffe1f31,
+ 0x77de5b97,0x35d47d6d,0xcff31a33,0xe1f88369,0x69ff268f,0x2d5ced25,0x7efb9cab,0xff1c36a1,
+ 0xfbe75887,0x6fbc9bdd,0xeff6f623,0xaf6c18d9,0xe3ded17f,0x5ddc6995,0xbebb069b,0x7aff0a11,
+ 0xa77f7177,0xe7e5364d,0xeddfae13,0x7c57ea49,0x2f4f186f,0x697fe205,0xfffecc8b,0xa9ed9981,
+ 0xfaefa667,0x7efd4cbd,0x7bf24203,0x75f2f7b9,0x17fefb5f,0x6fee5675,0xf61fee7b,0x77fee4f1,
+ 0x58d6f757,0x03ffdf2d,0xeee7b1f3,0xfef44129,0x7cbf7a4f,0x55dec6e5,0xafbb6c6b,0xf7f9ec61,
+ 0x63ee6447,0xa6ffed9d,0x72defde3,0x73f2c699,0x7f7f953f,0xef6c3355,0xf3fe465b,0xdffdafd1,
+ 0xba3eed37,0xfebc780d,0x43fb25d3,0xd7b58809,0xff4e4c2f,0xf23d9bc5,0xa91f7c4b,0xfeb92f41,
+ 0x5fff9227,0x5efc7e7d,0x217b29c3,0x7b438579,0xebfe9f1f,0x63ee0035,0x6cee0e3b,0x7bdb6ab1,
+ 0xdbbf5317,0xbbbf00ed,0xeb3a09b3,0xfff3bee9,0x7fff8e0f,0x3fbc60a5,0xfd7afc2b,0xeddb6221,
+ 0x56c73007,0xd77eff5d,0x52f6c5a3,0x56fd3459,0xfbfe18ff,0xc7efbd15,0x5f2f461b,0x47b81591,
+ 0xeef628f7,0xe36f79cd,0xe2b65d93,0xf7f6e5c9,0x4fff3fef,0x3eff1585,0xffdfec0b,0x5af88501,
+ 0x3fa73de7,0xedbf703d,0xdd7fd183,0x6f37d339,0x7ffe02df,0x7b3d69f5,0xffafedfb,0xfe9bb071,
+ 0xffd76ed7,0xf7d5e2ad,0x7fea2173,0x7d76fca9,0x5f7f61cf,0xf77dba65,0x7ffe4beb,0x1d5897e1,
+ 0x6fafbbc7,0xedfdd11d,0x4ffe4d63,0x7d6b6219,0xf7de5cbf,0xffef06d5,0xfeee05db,0x6ffe3b51,
+ 0x1fb724b7,0xd53e3b8d,0xb5cb5553,0xde9c0389,0x7faff3af,0x6bbc4f45,0xf7de1bcb,0xffbb9ac1,
+ 0xef66a9a7,0x6ffe21fd,0xfff63943,0xfbcfe0f9,0xd87f269f,0x3fec93b5,0x7b4b8dbb,0x83dfb631,
+ 0xf9374a97,0xf584846d,0xc8b7f933,0xd6fdfa69,0xedeef58f,0x573ed425,0xffff5bab,0x77d98da1,
+ 0xdfe60787,0x9efc62dd,0xff7f9523,0x7a7d4fd9,0x6d9e607f,0xf86e1095,0xf5aa859b,0x6d382111,
+ 0x73f7e077,0x4efcbd4d,0x77020d13,0xdfd4e149,0x7e5e676f,0x6efd4905,0xddfa0b8b,0x7fea7081,
+ 0x65efd567,0x7f3493bd,0xbdf66103,0x7b8baeb9,0xf2fe0a5f,0x8caf7d75,0x5f5aed7b,0xef9f7bf1,
+ 0x73fee657,0xef46e62d,0xe7e390f3,0xfdb8b829,0x3fbe494f,0x7fdfade5,0x03fe2b6b,0x7ede4361,
+ 0x7eb61347,0x577eb49d,0xffd29ce3,0x7ff2fd99,0xfb7e243f,0xd96cda55,0x5feac55b,0xf9fdc6d1,
+ 0xa73e5c37,0x7fb6ff0d,0xffd284d3,0x5e717f09,0x1dfe9b2f,0xdd3e02c5,0x7fdbbb4b,0xcf3d0641,
+ 0xf7eec127,0x5ff6c57d,0x5d7648c3,0xbd6b3c79,0xfdfeae1f,0xc77e2735,0x27fe0d3b,0xed5b01b1,
+ 0xf7be4217,0x5ea507ed,0xe66ae8b3,0xfff735e9,0x2b6f5d0f,0x79fc47a5,0xff7abb2b,0xfbfeb921,
+ 0x3d4fdf07,0x4974c65d,0xffdf64a3,0xfbac6b59,0x3b7fa7ff,0x7def6415,0x37eac51b,0x7fbf2c91,
+ 0x7ff697f7,0x37ed00cd,0xffc2bc93,0x56f1dcc9,0x6fde8eef,0xdffe7c85,0xfafb2b0b,0xddeb5c01,
+ 0xbeb76ce7,0xfbbcb73d,0xef73f083,0x9a6e8a39,0x6a7f11df,0xbfac90f5,0xde9aecfb,0xb7fa4771,
+ 0x1fff5dd7,0xe6dee9ad,0x7ef20073,0x6f3973a9,0xff6e30cf,0x0b7ca165,0xbefb0aeb,0x725aeee1,
+ 0x74ff6ac7,0x4df6981d,0xebdbec63,0x1fe99919,0xfddeebbf,0xeefdadd5,0x5bfa84db,0x7b7c5251,
+ 0xfaf693b7,0xdf36c28d,0xfdd2b453,0x45f5fa89,0xbeae42af,0xf7beb645,0xf3da5acb,0xb7fd71c1,
+ 0x6df7d8a7,0x55d668fd,0xfdff5843,0x6ed597f9,0xcfff359f,0x7eeebab5,0xdf4b8cbb,0x7ffd4d31,
+ 0xfcb63997,0xf7ac8b6d,0xdbf6d833,0xc7ff7169,0x77fec48f,0x77fcbb25,0x77fb1aab,0xed4ae4a1,
+ 0xd6feb687,0x29b429dd,0x59563423,0x0fea86d9,0xfeffef7f,0xdbffb795,0xf5ae049b,0x653d3811,
+ 0x3dfe4f77,0x67f4444d,0xfbfe6c13,0xfe7dd849,0xed7fb66f,0xbffeb005,0xbb7b4a8b,0x77fb4781,
+ 0xf82e0467,0x7fdfdabd,0xfbba8003,0xdbe065b9,0xdfff195f,0xefbca475,0xdcefec7b,0x5adc12f1,
+ 0xffd6d557,0xbbcded2d,0xf27b6ff3,0xfcb92f29,0xd6ff184f,0xbfdc94e5,0x5bfaea6b,0xddce9a61,
+ 0x7997c247,0xcbf57b9d,0xff9e3be3,0xdfef3499,0x3bfeb33f,0xf57d8155,0x2fef445b,0x1cf9ddd1,
+ 0x707fcb37,0x7aed860d,0x7fc7e3d3,0x7f597609,0x3a4eea2f,0x7d3e69c5,0x7ffbfa4b,0xdc3cdd41,
+ 0x77eff027,0x73fd0c7d,0xff7f67c3,0xf9cef379,0xbcfebd1f,0x2aee4e35,0xa2ee0c3b,0x5f5e98b1,
+ 0x7fbf3117,0x590f0eed,0xfd7bc7b3,0xdd76ace9,0xffff2c0f,0xdfbc2ea5,0x7e7e7a2b,0x5ece1021,
+ 0x3cf68e07,0xcffe8d5d,0xfff603a3,0x7fb7a259,0x6fbf36ff,0x4eff0b15,0x4eee441b,0x6bba4391,
+ 0x77ff06f7,0x6d7e87cd,0x7caf1b93,0xb7f8d3c9,0xffcfddef,0xa1fde385,0xfdda6a0b,0xfefa3301,
+ 0x35e79be7,0xff9dfe3d,0x0e360f83,0xf7e14139,0x7bfe20df,0x3d2fb7f5,0x3ddfebfb,0x3d3cde71,
+ 0x7ed74cd7,0x69dff0ad,0x7ff7df73,0x7e37eaa9,0x9eeeffcf,0x7d7f8865,0x5d7fc9eb,0xefe945e1,
+ 0x7f6f19c7,0xebff5f1d,0xbf978b63,0xbf63d019,0x6eff7abf,0xa5fc54d5,0x3eeb03db,0x8e7e6951,
+ 0xbfbe02b7,0x7a67498d,0x7ff21353,0xf49bf189,0xc7ce91af,0xffbd1d45,0xad9e99cb,0xf5fb48c1,
+ 0xffef07a7,0x57deaffd,0x7df67743,0x75d74ef9,0xbe3f449f,0xd9fce1b5,0x755f8bbb,0xefdee431,
+ 0x5f5f2897,0x7acc926d,0xbef3b733,0xbefce869,0x6bee938f,0xbfbea225,0x7ffed9ab,0xf9883ba1,
+ 0xb3f76587,0x8df7f0dd,0x1d7ad323,0xfbb3bdd9,0x3bff7e7f,0xff7d5e95,0xfbfb839b,0x7bfe4f11,
+ 0x1d7ebe77,0xdee7cb4d,0x76d6cb13,0x7952cf49,0xb5ff056f,0x537c1705,0xd7da898b,0x3e681e81,
+ 0x7b663367,0x7dff21bd,0x3ff69f03,0xeef11cb9,0xf8fe285f,0x5bfdcb75,0x7feaeb7b,0xeffca9f1,
+ 0xfdfec457,0x5bd4f42d,0xfdef4ef3,0xd7b5a629,0x7defe74f,0xbfdd7be5,0xf7bba96b,0xedeaf161,
+ 0xed8f7147,0x5f74429d,0x6757dae3,0xffe76b99,0x9f5f423f,0xd77e2855,0x7a6bc35b,0x37f9f4d1,
+ 0x1bb73a37,0xfbe40d0d,0xb7d742d3,0xef9d6d09,0x5b2f392f,0xff3ed0c5,0x5b7a394b,0x6f38b441,
+ 0xfdef1f27,0x7dff537d,0xf27686c3,0xfb6eaa79,0xaffecc1f,0xeb6e7535,0x7dee0b3b,0xfb5e2fb1,
+ 0x6efe2017,0xfced15ed,0xfe66a6b3,0xb5f223e9,0x7dfefb0f,0xe7fc15a5,0xfffe392b,0xb5e96721,
+ 0x37ff3d07,0x4efc545d,0x7bd6a2a3,0x3dfed959,0xdd7ec5ff,0x3ffeb215,0x6f7bc31b,0x7fb95a91,
+ 0xfff775f7,0xecf40ecd,0xfbf37a93,0x3afbcac9,0xf7df2cef,0x77fd4a85,0x7cffa90b,0xdbfd0a01,
+ 0xfcafcae7,0xf7ff453d,0x79f22e83,0xeb8ff839,0x7f7f2fdf,0xb66edef5,0xdefeeafb,0xf71b7571,
+ 0xff573bd7,0x7ee4f7ad,0x5ffbbe73,0x71b261a9,0x732fcecf,0x767e6f65,0x757e88eb,0x77eb9ce1,
+ 0xbefec8c7,0x5efc261d,0x7dbf2a63,0x667a0719,0xd7fe09bf,0x9afefbd5,0x6fff82db,0xa17c8051,
+ 0x81ff71b7,0x7f37d08d,0xf36f7253,0x37dde889,0xf2fee0af,0x3dbf8445,0xb7bad8cb,0x79ad1fc1,
+ 0xa7fe36a7,0x575ef6fd,0x6ffb9643,0xd7d505f9,0xdf3f539f,0x3fff08b5,0x7f5f8abb,0x7ffc7b31,
+ 0xd61e1797,0x7fec996d,0xb9ae9633,0xeff65f69,0xeffe628f,0xb95c8925,0xdafa98ab,0x6b7992a1,
+ 0xbece1487,0x1ff7b7dd,0xdfd77223,0x7378f4d9,0x9e9f0d7f,0xebff0595,0xfeff029b,0x867b6611,
+ 0xdb7f2d77,0xedf7524d,0xb58b2a13,0xfd73c649,0xffde546f,0xff7d7e05,0x7fdbc88b,0xefe8f581,
+ 0x5fbe6267,0x7e9e68bd,0x7ef2be03,0x57bdd3b9,0xb3ff375f,0xb5fef275,0x173bea7b,0xa4b940f1,
+ 0x5efeb357,0x3f4ffb2d,0xfcff2df3,0xcfbe1d29,0x3abeb64f,0xedde62e5,0x15be686b,0x3fcb4861,
+ 0xbfaf2047,0x9377099d,0x1fdf79e3,0x3ffba299,0x69dfd13f,0x7f7ecf55,0x7ffe425b,0x2efe0bd1,
+ 0xe736a937,0xffee940d,0x6fc2a1d3,0x75fd6409,0xffaf882f,0x7e3f37c5,0xfd5a784b,0x5eb88b41,
+ 0x7fee4e27,0x7efd9a7d,0x1f77a5c3,0x3f4a6179,0x8ebedb1f,0xefee9c35,0xd9de0a3b,0xcf59c6b1,
+ 0xf7bf0f17,0x9f4f1ced,0xff2b85b3,0xa7799ae9,0x73eeca0f,0xfe9ffca5,0x58fff82b,0xf6b8be21,
+ 0x77dfec07,0xd93e1b5d,0x3cd341a3,0xeda21059,0x65de54ff,0x3ffe5915,0xfc2b421b,0xeffc7191,
+ 0xfdf7e4f7,0xeffd95cd,0x7f97d993,0xdffac1c9,0xf9fe7bef,0xcffcb185,0x5bdee80b,0x57ebe101,
+ 0x7feff9e7,0xffdc8c3d,0x7e3a4d83,0x7b7aaf39,0x29fe3edf,0xe7ee05f5,0x5ffbe9fb,0x4ade0c71,
+ 0xfa572ad7,0xefddfead,0x7df79d73,0x5438d8a9,0xeeee9dcf,0x7f7d5665,0xbfbf47eb,0x6be9f3e1,
+ 0xbfa677c7,0xd5fced1d,0xfbb2c963,0x19ec3e19,0x7ffe98bf,0x6bfda2d5,0x6bfe01db,0xb47e9751,
+ 0x5ff6e0b7,0xe1a4578d,0x7d4ad153,0x9afbdf89,0x1bcf2faf,0xffbdeb45,0x7fbf17cb,0x7faaf6c1,
+ 0x7f6765a7,0x5b573dfd,0xfbfab543,0xe7cebcf9,0x8ebf629f,0xfffd2fb5,0xff6b89bb,0xffde1231,
+ 0xffdf0697,0x298ca06d,0xf7e37533,0xf0fbd669,0x7efe318f,0xfc1e7025,0x35fe57ab,0x9e1ee9a1,
+ 0xf7f6c387,0xd6bf7edd,0xdaf21123,0x3fba2bd9,0xffde9c7f,0x8e7cac95,0x7bfe819b,0xbbbc7d11,
+ 0xff779c77,0x50e6d94d,0x2e1b8913,0x5fd0bd49,0x2fcfa36f,0xdffee505,0x3b7f078b,0xc3edcc81,
+ 0xf92e9167,0x7bbdafbd,0xbff6dd03,0x3ec68ab9,0x9ffe465f,0x1ebc1975,0xefdee97b,0x7fd9d7f1,
+ 0x8fd6a257,0xdb4f022d,0xdf6b0cf3,0xfff29429,0xfbbf854f,0x77df49e5,0x6fff276b,0xffef9f61,
+ 0xdedecf47,0x3b7dd09d,0xdf3f18e3,0xfaebd999,0x757e603f,0x5d7f7655,0x79fec15b,0x3ffe22d1,
+ 0xf3b61837,0x63fd1b0d,0xfeca00d3,0xf5b95b09,0xf5cfd72f,0x2b3f9ec5,0xf89eb74b,0x5d2c6241,
+ 0xf3e77d27,0x5bf7e17d,0x4af2c4c3,0x7d621879,0x79feea1f,0x73eec335,0x77de093b,0x38d95db1,
+ 0x3a97fe17,0x672523ed,0xffae64b3,0xba7d11e9,0xff6e990f,0xffdfe3a5,0x77ffb72b,0x4fbc1521,
+ 0x3fde9b07,0x7e37e25d,0xefdbe0a3,0x7fe14759,0xbfdfe3ff,0xfffe0015,0xff7ac11b,0xf7bb8891,
+ 0xf7fe53f7,0x76671ccd,0xeb963893,0x3bf5b8c9,0x1fffcaef,0x6ffc1885,0x26fa270b,0x3c060800 };
diff --git a/src/test/test2/makefile b/src/test/test2/makefile
--- /dev/null
+++ b/src/test/test2/makefile
@@ -0,0 +1,16 @@
+# simple makefile for test2
+
+
+all: test2be test2le
+
+
+test2be:
+ make -f makestage2 test2 ENDIAN=big
+
+
+test2le:
+ make -f makestage2 test2 ENDIAN=little
+
+
+
+
diff --git a/src/test/test2/makestage2 b/src/test/test2/makestage2
--- /dev/null
@@ -0,0 +1,51 @@
+# simple make file for test2
+
+
+CC= cl6x
+CFLAGS= -g -c -mv 6400+ $(OPT)
+
+.PHONY: test2
+
+test2: gen_cdefdep test2_$(ENDIAN).blob
+
+ifeq ($(ENDIAN),little)
+ LIB= $(TOOLSC6X)/cgtools/lib/rts64plus.lib
+ OPT=
+else
+ LIB= $(TOOLSC6X)/cgtools/lib/rts64pluse.lib
+ OPT= -me
+endif
+
+
+
+test2_$(ENDIAN).blob: test2_$(ENDIAN).bccs
+ ..\util\ccs2bin $< $@
+
+test2_$(ENDIAN).bccs: test2_$(ENDIAN).b
+ ..\util\b2ccs $< $@
+
+test2_$(ENDIAN).b: test2_$(ENDIAN).out test2.rmd
+ hex6x $< test2.rmd
+ copy test2im.hex $@
+
+test2_$(ENDIAN).out: cdefdep c0.obj test2.obj test2ini.obj test2.cmd
+ cl6x -z -o $@ -m test2.map -e _enter test2.cmd $(LIB)
+
+
+c0.obj: c0.c cdefdep
+ $(CC) $(CFLAGS) $<
+
+
+test2.obj: test2.c cdefdep
+ $(CC) $(CFLAGS) $<
+
+test2ini.obj: test2ini.s
+ $(CC) $(CFLAGS) $<
+
+gen_cdefdep:
+ @echo checking endian dependency
+ @echo $(ENDIAN) > cdefdep.tmp
+ @sh -c 'if diff -q cdefdep.tmp cdefdep ; then echo same ; else cp cdefdep.tmp cdefdep ; fi '
+
+
+
diff --git a/src/test/test2/test.blob b/src/test/test2/test.blob
new file mode 100644 (file)
index 0000000..bd1d1d1
Binary files /dev/null and b/src/test/test2/test.blob differ
index 0000000..bd1d1d1
Binary files /dev/null and b/src/test/test2/test.blob differ
diff --git a/src/test/test2/test2.c b/src/test/test2/test2.c
--- /dev/null
+++ b/src/test/test2/test2.c
@@ -0,0 +1,33 @@
+/********************************************************************************
+ * Simple test program that supports a binary blob load
+ ********************************************************************************/
+
+
+#pragma DATA_SECTION(nint_c0, ".data0")
+int nint_c0 = 1024;
+
+extern const unsigned int c0[];
+
+unsigned int sum;
+
+void main (void)
+{
+
+ int i;
+
+ sum = 0;
+
+ for (i = 0; i < nint_c0; i++)
+ sum = sum + c0[i];
+
+
+ for (;;);
+
+}
+
+
+
+
+
+
+
diff --git a/src/test/test2/test2.cmd b/src/test/test2/test2.cmd
--- /dev/null
+++ b/src/test/test2/test2.cmd
@@ -0,0 +1,43 @@
+/* Linker command file for test2. Placement is for Tomahawk */
+
+c0.obj
+test2.obj
+test2ini.obj
+
+
+-c
+-stack 0x400
+
+
+MEMORY
+{
+
+ BLOB_ENTER : origin = 0xe0000000, length = 0x0040
+ TEXT : origin = 0xe0000040, length = 0x04c0
+ CONST : origin = 0xe0000500, length = 0x1100
+ CINIT : origin = 0xe0001600, length = 0x0080
+
+ STACK : origin = 0x210000, length = 0x400
+ DATA : origin = 0x210400, length = 0x400
+
+}
+
+SECTIONS
+{
+ .enter > BLOB_ENTER
+ .text > TEXT
+ .dconst > CONST
+ .const > CONST
+ .cinit > CINIT
+
+ .stack > STACK
+ .data > DATA
+ .bss > DATA
+ .far > DATA
+ .data0 > DATA
+
+}
+
+
+
+
diff --git a/src/test/test2/test2.rmd b/src/test/test2/test2.rmd
--- /dev/null
+++ b/src/test/test2/test2.rmd
@@ -0,0 +1,10 @@
+-a
+-image
+
+ROMS
+{
+ ROM1: org = 0xe0000000, length = 0x1680, memwidth=32 romwidth=32
+ files= { test2im.hex }
+
+}
+
diff --git a/src/test/test2/test2_little.bccs b/src/test/test2/test2_little.bccs
--- /dev/null
@@ -0,0 +1,1441 @@
+1651 1 10000 1 5a0
+0x00c8a120
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x0013ea59
+0x86773577
+0xc0001111
+0xb5d62046
+0x46468577
+0xd0283664
+0x81ffffa8
+0xe3400148
+0x81ffffe8
+0x800fea58
+0x0660a358
+0x6046abba
+0x00003410
+0x02280264
+0x0228905a
+0xe1008040
+0xc1c665c6
+0x01820162
+0x01ad4078
+0x018d6058
+0x018d8f78
+0x050c8058
+0x00282064
+0xe0300000
+0xcffffc91
+0xc2280264
+0xc0002c10
+0xc228905a
+0x01800fd8
+0xc58c0fd8
+0xc30c0fd8
+0x01ffffa8
+0x01ffffe8
+0x000fea58
+0x2046482a
+0xd00c0264
+0x950c1fda
+0x8004a358
+0x90001fdb
+0xe0808030
+0x8c6e043a
+0x6c6e006f
+0x01830162
+0x002832e6
+0x012b6c6e
+0x20000362
+0x0c6e6c6e
+0xea609000
+0x053c33e5
+0x01b41fda
+0x000c0363
+0x063c33e4
+0x053c52e6
+0x00006000
+0x00000000
+0x00000000
+0x01820429
+0x05bc54f4
+0x018010e8
+0x018c0264
+0x02fca35a
+0x027fffaa
+0x027fffea
+0x02948a7a
+0x018c0a58
+0x053c22f4
+0x06ebb5a9
+0x21820628
+0x30100363
+0x218010e8
+0x218c0264
+0xe0808020
+0x2c6e4646
+0x01820162
+0x01820628
+0x018010e8
+0x018c0264
+0x0c6e4c6e
+0x000c1362
+0xe4200000
+0x01818162
+0x0202022a
+0x020010ea
+0x8506100d
+0x04bb4c6e
+0x20000362
+0x00006000
+0xe3008000
+0x01810162
+0x01820028
+0x018010e8
+0x000c0264
+0x04ba6c6e
+0xc0001362
+0x00006000
+0xe2008000
+0x01810162
+0x01820828
+0x018010e8
+0x018c0264
+0x000c1362
+0x01868162
+0x10004412
+0xe0100000
+0x0000a120
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x001829f1
+0x009847a1
+0x0404a358
+0xc19036a5
+0xc4000129
+0x04901fd8
+0x829056a7
+0x84a50a25
+0x001879a3
+0x011887a0
+0xa81037b5
+0x144ea256
+0x0084a35a
+0x239037a5
+0x2003e1a3
+0xe10000c0
+0x010068da
+0x600c0363
+0x289037a7
+0x2003e05a
+0xc1943635
+0xc0804043
+0xd86f52c7
+0xe8001000
+0x82945637
+0x84882ab4
+0xa8143755
+0x00200fd8
+0xc3943775
+0xc003e1a0
+0x00838001
+0xc8943776
+0x039037a4
+0x00004000
+0x00000000
+0x00034001
+0x03943774
+0x008ca362
+0x00000000
+0x00000000
+0x07bf005a
+0x0200a35a
+0x0200007e
+0xbc452c6e
+0x00002000
+0x01820c28
+0x018010e8
+0xe1000000
+0x018c0264
+0x9d896c6e
+0x3028a120
+0x0302802a
+0x0370006b
+0x0200006f
+0xb55da247
+0xe8400000
+0xa2416c6e
+0x0200007e
+0xbc4d2c6e
+0x26416c6e
+0x2c6ebc45
+0x01820c28
+0x018010e8
+0xe3a00000
+0x018c0264
+0x00006000
+0x001078f8
+0xcff3a120
+0x0004a120
+0x00000000
+0x00000000
+0x00000000
+0x0781fe2a
+0x078010ea
+0x07bf09f2
+0x07020a2a
+0x070010ea
+0x0200202a
+0x0270006a
+0x00100362
+0x020b0028
+0x01834162
+0x02700068
+0x0181c028
+0x01f00068
+0x00000000
+0x000c1362
+0x01888162
+0x0200902a
+0x0270006a
+0x00100362
+0x01856162
+0x0204a358
+0x0005a120
+0x00000000
+0x00000000
+0x02ffffa8
+0x02ffffe9
+0x0281502a
+0x02f0006b
+0x96e9fe27
+0x02ef62c6
+0x320c0265
+0xe6000600
+0x0200a358
+0x0180a358
+0x31948058
+0x00000000
+0x020c1fda
+0x00000000
+0x00000000
+0x00000000
+0x008ca362
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x0001a120
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x7efeb0e7
+0xe4ff9b3d
+0xdffb7483
+0xbefbae39
+0xbffed5df
+0x33fff4f5
+0x2f9ef0fb
+0x459feb71
+0xdfffa1d7
+0xfbdecdad
+0x7bf28473
+0xbf7797a9
+0x756ef4cf
+0x7f5d0565
+0x66ba0eeb
+0x6f5992e1
+0x5e56aec7
+0x7eff7c1d
+0xff977063
+0x7df8bd19
+0x7bdeafbf
+0x36af11d5
+0xffee88db
+0x3f7bf651
+0xffb6d7b7
+0xcbbca68d
+0x70e33853
+0x7ff61e89
+0xfedf06af
+0x5fbd1a45
+0x759f5ecb
+0x6fbe15c1
+0x61671ca7
+0x5f5d4cfd
+0x3ffadc43
+0x76e6bbf9
+0x37fef99f
+0xfeee1eb5
+0x796b90bb
+0xfbdef131
+0xdf567d97
+0xbff46f6d
+0xf7fb5c33
+0xfff19569
+0xfbef888f
+0xffdd1f25
+0xbdfe1eab
+0x7bcd88a1
+0x7ffffa87
+0xffbd0ddd
+0x6fd3b823
+0x6fbdaad9
+0x1e9fb37f
+0x6ffd1b95
+0x5cae089b
+0x5fb8dc11
+0x7ff69377
+0x3ffe284d
+0xef32f013
+0x7f71fc49
+0xff5e7a6f
+0x3bfd1405
+0x7e7e4e8b
+0xff7feb81
+0xfe3f4867
+0x6e16bebd
+0xffba0403
+0xfff589b9
+0x7ffedd5f
+0x67fc0875
+0x70bbf07b
+0x4ff9b6f1
+0xcedf1957
+0x7e5dd12d
+0xff63f3f3
+0x5abf5329
+0x7fbfdc4f
+0x5fdcf8e5
+0xffbfee6b
+0x5dcd3e61
+0x6db70647
+0x7f7e5f9d
+0xbd9fbfe3
+0x3de65899
+0xbf7e773f
+0x3d3ee555
+0xbbeb485b
+0xfdf981d1
+0x34760f37
+0x6cff6a0d
+0x6de267d3
+0xbff19a09
+0xcebfae2f
+0xef3ccdc5
+0xffbafe4b
+0x7c2d8141
+0x4ee73427
+0x57d7f07d
+0xfb72ebc3
+0xfde81779
+0x1cfe811f
+0xbd6db235
+0x37de103b
+0x17f83cb1
+0xf5bf7517
+0x4d5ef2ed
+0xd7664bb3
+0xf7f0d0e9
+0x7deff00f
+0xfc9c92a5
+0xefff7e2b
+0x57d8b421
+0xf4ffd207
+0xffff715d
+0xeefb87a3
+0xdaf2c659
+0xe69efaff
+0xe4cc6f15
+0xe6ae481b
+0x1fbde791
+0xfff74af7
+0x5ff46bcd
+0x9fab9f93
+0xefd4f7c9
+0xfeeea1ef
+0xf6fc4785
+0x7dff6e0b
+0x7dfed701
+0x7dbedfe7
+0xeff4e23d
+0x7e7b9383
+0xff7e6539
+0xffffe4df
+0xbf7f1bf5
+0xbffbeffb
+0xdeda8271
+0x6cf790d7
+0x7df7d4ad
+0x73ea6373
+0x97760ea9
+0xee7fc3cf
+0xfb7fec65
+0x9fbacdeb
+0x77efe9e1
+0x53565dc7
+0xfff4431d
+0xfbd30f63
+0xe762f419
+0xbeff3ebf
+0x19cdb8d5
+0xcbef07db
+0x77fe0d51
+0xeffe46b7
+0x1ffd2d8d
+0xdb569753
+0xed9c1589
+0x1d8f55af
+0xffbf8145
+0x7aff9dcb
+0x7bebecc1
+0xfee64ba7
+0x4a7593fd
+0x69f3fb43
+0x95f872f9
+0x72bf089f
+0x7dec45b5
+0x1e5f8fbb
+0x5dd88831
+0x5b976c97
+0x7ea4766d
+0xffaa3b33
+0xfeff0c69
+0x77ef578f
+0x4a9f0625
+0x13ffddab
+0xbd1adfa1
+0x75c6a987
+0xadfcd4dd
+0x7cd65723
+0xfe76e1d9
+0x77bf427f
+0x7b4ec295
+0x7fff879b
+0x3779f311
+0xff770277
+0x7ee5af4d
+0x6a9b4f13
+0xf576f349
+0x556fc96f
+0xde7e7b05
+0x3f7b8d8b
+0xfe7cc281
+0x5f277767
+0x7f5e05bd
+0x3ff62303
+0x1b9640b9
+0x3effec5f
+0xf7fd2f75
+0x4b3eef7b
+0xb59a4df1
+0xdfd70857
+0x7f6cd82d
+0xfb67d2f3
+0x2ffbca29
+0xc1aeab4f
+0x37dddfe5
+0x5efead6b
+0xeac99561
+0x7bc6b547
+0x37f5269d
+0x7fdb5ee3
+0xdcee8f99
+0xf67f063f
+0x6b4f8c55
+0xd6fbc75b
+0xeff998d1
+0xff3f7e37
+0xaffdf10d
+0xefffc6d3
+0x2a359109
+0xbf3ffd2f
+0x6f3d34c5
+0xffbf3d4b
+0x73395841
+0x9ff66327
+0x5bde377d
+0xeffa0ac3
+0x3f57ce79
+0xf7be901f
+0xff7dd935
+0xddee0f3b
+0xe7ffd3b1
+0x4cf66417
+0xd64cf9ed
+0xf9e32ab3
+0xeb7c47e9
+0xeeffbf0f
+0x5fdc79a5
+0x5dff3d2b
+0x7ffc0b21
+0xfb568107
+0x47fd385d
+0xedfa26a3
+0x5de9fd59
+0x2dfe89ff
+0xf3dc1615
+0xffabc71b
+0x7bbcfe91
+0xf5f7b9f7
+0xec75f2cd
+0x7783fe93
+0x7fd7eec9
+0x19cff0ef
+0xbfffae85
+0x7fdaad0b
+0x7ff9ae01
+0xdcb70ee7
+0xead6293d
+0x5777b283
+0x7e3d1c39
+0xfbfef3df
+0xf8ee42f5
+0x5caaeefb
+0x6bd91971
+0x7f777fd7
+0x30c4dbad
+0x6ffa4273
+0xeff085a9
+0xff2e92cf
+0xc47ed365
+0xfe3b8ceb
+0xef4a40e1
+0x7f760cc7
+0x4bf50a1d
+0x75faae63
+0xde692b19
+0x27ffcdbf
+0xfedc5fd5
+0xf7eb86db
+0x7ffc2451
+0x74b7b5b7
+0x5ffdb48d
+0x1fe3f653
+0x5bfe0c89
+0x7dcfa4af
+0xa9bde845
+0x3bbfdccb
+0x7dadc3c1
+0x57677aa7
+0x7ff5dafd
+0x97f71a43
+0xeec629f9
+0xef3f179f
+0xbdfe6cb5
+0xbf5f8ebb
+0xeffe1f31
+0x77de5b97
+0x35d47d6d
+0xcff31a33
+0xe1f88369
+0x69ff268f
+0x2d5ced25
+0x7efb9cab
+0xff1c36a1
+0xfbe75887
+0x6fbc9bdd
+0xeff6f623
+0xaf6c18d9
+0xe3ded17f
+0x5ddc6995
+0xbebb069b
+0x7aff0a11
+0xa77f7177
+0xe7e5364d
+0xeddfae13
+0x7c57ea49
+0x2f4f186f
+0x697fe205
+0xfffecc8b
+0xa9ed9981
+0xfaefa667
+0x7efd4cbd
+0x7bf24203
+0x75f2f7b9
+0x17fefb5f
+0x6fee5675
+0xf61fee7b
+0x77fee4f1
+0x58d6f757
+0x03ffdf2d
+0xeee7b1f3
+0xfef44129
+0x7cbf7a4f
+0x55dec6e5
+0xafbb6c6b
+0xf7f9ec61
+0x63ee6447
+0xa6ffed9d
+0x72defde3
+0x73f2c699
+0x7f7f953f
+0xef6c3355
+0xf3fe465b
+0xdffdafd1
+0xba3eed37
+0xfebc780d
+0x43fb25d3
+0xd7b58809
+0xff4e4c2f
+0xf23d9bc5
+0xa91f7c4b
+0xfeb92f41
+0x5fff9227
+0x5efc7e7d
+0x217b29c3
+0x7b438579
+0xebfe9f1f
+0x63ee0035
+0x6cee0e3b
+0x7bdb6ab1
+0xdbbf5317
+0xbbbf00ed
+0xeb3a09b3
+0xfff3bee9
+0x7fff8e0f
+0x3fbc60a5
+0xfd7afc2b
+0xeddb6221
+0x56c73007
+0xd77eff5d
+0x52f6c5a3
+0x56fd3459
+0xfbfe18ff
+0xc7efbd15
+0x5f2f461b
+0x47b81591
+0xeef628f7
+0xe36f79cd
+0xe2b65d93
+0xf7f6e5c9
+0x4fff3fef
+0x3eff1585
+0xffdfec0b
+0x5af88501
+0x3fa73de7
+0xedbf703d
+0xdd7fd183
+0x6f37d339
+0x7ffe02df
+0x7b3d69f5
+0xffafedfb
+0xfe9bb071
+0xffd76ed7
+0xf7d5e2ad
+0x7fea2173
+0x7d76fca9
+0x5f7f61cf
+0xf77dba65
+0x7ffe4beb
+0x1d5897e1
+0x6fafbbc7
+0xedfdd11d
+0x4ffe4d63
+0x7d6b6219
+0xf7de5cbf
+0xffef06d5
+0xfeee05db
+0x6ffe3b51
+0x1fb724b7
+0xd53e3b8d
+0xb5cb5553
+0xde9c0389
+0x7faff3af
+0x6bbc4f45
+0xf7de1bcb
+0xffbb9ac1
+0xef66a9a7
+0x6ffe21fd
+0xfff63943
+0xfbcfe0f9
+0xd87f269f
+0x3fec93b5
+0x7b4b8dbb
+0x83dfb631
+0xf9374a97
+0xf584846d
+0xc8b7f933
+0xd6fdfa69
+0xedeef58f
+0x573ed425
+0xffff5bab
+0x77d98da1
+0xdfe60787
+0x9efc62dd
+0xff7f9523
+0x7a7d4fd9
+0x6d9e607f
+0xf86e1095
+0xf5aa859b
+0x6d382111
+0x73f7e077
+0x4efcbd4d
+0x77020d13
+0xdfd4e149
+0x7e5e676f
+0x6efd4905
+0xddfa0b8b
+0x7fea7081
+0x65efd567
+0x7f3493bd
+0xbdf66103
+0x7b8baeb9
+0xf2fe0a5f
+0x8caf7d75
+0x5f5aed7b
+0xef9f7bf1
+0x73fee657
+0xef46e62d
+0xe7e390f3
+0xfdb8b829
+0x3fbe494f
+0x7fdfade5
+0x03fe2b6b
+0x7ede4361
+0x7eb61347
+0x577eb49d
+0xffd29ce3
+0x7ff2fd99
+0xfb7e243f
+0xd96cda55
+0x5feac55b
+0xf9fdc6d1
+0xa73e5c37
+0x7fb6ff0d
+0xffd284d3
+0x5e717f09
+0x1dfe9b2f
+0xdd3e02c5
+0x7fdbbb4b
+0xcf3d0641
+0xf7eec127
+0x5ff6c57d
+0x5d7648c3
+0xbd6b3c79
+0xfdfeae1f
+0xc77e2735
+0x27fe0d3b
+0xed5b01b1
+0xf7be4217
+0x5ea507ed
+0xe66ae8b3
+0xfff735e9
+0x2b6f5d0f
+0x79fc47a5
+0xff7abb2b
+0xfbfeb921
+0x3d4fdf07
+0x4974c65d
+0xffdf64a3
+0xfbac6b59
+0x3b7fa7ff
+0x7def6415
+0x37eac51b
+0x7fbf2c91
+0x7ff697f7
+0x37ed00cd
+0xffc2bc93
+0x56f1dcc9
+0x6fde8eef
+0xdffe7c85
+0xfafb2b0b
+0xddeb5c01
+0xbeb76ce7
+0xfbbcb73d
+0xef73f083
+0x9a6e8a39
+0x6a7f11df
+0xbfac90f5
+0xde9aecfb
+0xb7fa4771
+0x1fff5dd7
+0xe6dee9ad
+0x7ef20073
+0x6f3973a9
+0xff6e30cf
+0x0b7ca165
+0xbefb0aeb
+0x725aeee1
+0x74ff6ac7
+0x4df6981d
+0xebdbec63
+0x1fe99919
+0xfddeebbf
+0xeefdadd5
+0x5bfa84db
+0x7b7c5251
+0xfaf693b7
+0xdf36c28d
+0xfdd2b453
+0x45f5fa89
+0xbeae42af
+0xf7beb645
+0xf3da5acb
+0xb7fd71c1
+0x6df7d8a7
+0x55d668fd
+0xfdff5843
+0x6ed597f9
+0xcfff359f
+0x7eeebab5
+0xdf4b8cbb
+0x7ffd4d31
+0xfcb63997
+0xf7ac8b6d
+0xdbf6d833
+0xc7ff7169
+0x77fec48f
+0x77fcbb25
+0x77fb1aab
+0xed4ae4a1
+0xd6feb687
+0x29b429dd
+0x59563423
+0x0fea86d9
+0xfeffef7f
+0xdbffb795
+0xf5ae049b
+0x653d3811
+0x3dfe4f77
+0x67f4444d
+0xfbfe6c13
+0xfe7dd849
+0xed7fb66f
+0xbffeb005
+0xbb7b4a8b
+0x77fb4781
+0xf82e0467
+0x7fdfdabd
+0xfbba8003
+0xdbe065b9
+0xdfff195f
+0xefbca475
+0xdcefec7b
+0x5adc12f1
+0xffd6d557
+0xbbcded2d
+0xf27b6ff3
+0xfcb92f29
+0xd6ff184f
+0xbfdc94e5
+0x5bfaea6b
+0xddce9a61
+0x7997c247
+0xcbf57b9d
+0xff9e3be3
+0xdfef3499
+0x3bfeb33f
+0xf57d8155
+0x2fef445b
+0x1cf9ddd1
+0x707fcb37
+0x7aed860d
+0x7fc7e3d3
+0x7f597609
+0x3a4eea2f
+0x7d3e69c5
+0x7ffbfa4b
+0xdc3cdd41
+0x77eff027
+0x73fd0c7d
+0xff7f67c3
+0xf9cef379
+0xbcfebd1f
+0x2aee4e35
+0xa2ee0c3b
+0x5f5e98b1
+0x7fbf3117
+0x590f0eed
+0xfd7bc7b3
+0xdd76ace9
+0xffff2c0f
+0xdfbc2ea5
+0x7e7e7a2b
+0x5ece1021
+0x3cf68e07
+0xcffe8d5d
+0xfff603a3
+0x7fb7a259
+0x6fbf36ff
+0x4eff0b15
+0x4eee441b
+0x6bba4391
+0x77ff06f7
+0x6d7e87cd
+0x7caf1b93
+0xb7f8d3c9
+0xffcfddef
+0xa1fde385
+0xfdda6a0b
+0xfefa3301
+0x35e79be7
+0xff9dfe3d
+0x0e360f83
+0xf7e14139
+0x7bfe20df
+0x3d2fb7f5
+0x3ddfebfb
+0x3d3cde71
+0x7ed74cd7
+0x69dff0ad
+0x7ff7df73
+0x7e37eaa9
+0x9eeeffcf
+0x7d7f8865
+0x5d7fc9eb
+0xefe945e1
+0x7f6f19c7
+0xebff5f1d
+0xbf978b63
+0xbf63d019
+0x6eff7abf
+0xa5fc54d5
+0x3eeb03db
+0x8e7e6951
+0xbfbe02b7
+0x7a67498d
+0x7ff21353
+0xf49bf189
+0xc7ce91af
+0xffbd1d45
+0xad9e99cb
+0xf5fb48c1
+0xffef07a7
+0x57deaffd
+0x7df67743
+0x75d74ef9
+0xbe3f449f
+0xd9fce1b5
+0x755f8bbb
+0xefdee431
+0x5f5f2897
+0x7acc926d
+0xbef3b733
+0xbefce869
+0x6bee938f
+0xbfbea225
+0x7ffed9ab
+0xf9883ba1
+0xb3f76587
+0x8df7f0dd
+0x1d7ad323
+0xfbb3bdd9
+0x3bff7e7f
+0xff7d5e95
+0xfbfb839b
+0x7bfe4f11
+0x1d7ebe77
+0xdee7cb4d
+0x76d6cb13
+0x7952cf49
+0xb5ff056f
+0x537c1705
+0xd7da898b
+0x3e681e81
+0x7b663367
+0x7dff21bd
+0x3ff69f03
+0xeef11cb9
+0xf8fe285f
+0x5bfdcb75
+0x7feaeb7b
+0xeffca9f1
+0xfdfec457
+0x5bd4f42d
+0xfdef4ef3
+0xd7b5a629
+0x7defe74f
+0xbfdd7be5
+0xf7bba96b
+0xedeaf161
+0xed8f7147
+0x5f74429d
+0x6757dae3
+0xffe76b99
+0x9f5f423f
+0xd77e2855
+0x7a6bc35b
+0x37f9f4d1
+0x1bb73a37
+0xfbe40d0d
+0xb7d742d3
+0xef9d6d09
+0x5b2f392f
+0xff3ed0c5
+0x5b7a394b
+0x6f38b441
+0xfdef1f27
+0x7dff537d
+0xf27686c3
+0xfb6eaa79
+0xaffecc1f
+0xeb6e7535
+0x7dee0b3b
+0xfb5e2fb1
+0x6efe2017
+0xfced15ed
+0xfe66a6b3
+0xb5f223e9
+0x7dfefb0f
+0xe7fc15a5
+0xfffe392b
+0xb5e96721
+0x37ff3d07
+0x4efc545d
+0x7bd6a2a3
+0x3dfed959
+0xdd7ec5ff
+0x3ffeb215
+0x6f7bc31b
+0x7fb95a91
+0xfff775f7
+0xecf40ecd
+0xfbf37a93
+0x3afbcac9
+0xf7df2cef
+0x77fd4a85
+0x7cffa90b
+0xdbfd0a01
+0xfcafcae7
+0xf7ff453d
+0x79f22e83
+0xeb8ff839
+0x7f7f2fdf
+0xb66edef5
+0xdefeeafb
+0xf71b7571
+0xff573bd7
+0x7ee4f7ad
+0x5ffbbe73
+0x71b261a9
+0x732fcecf
+0x767e6f65
+0x757e88eb
+0x77eb9ce1
+0xbefec8c7
+0x5efc261d
+0x7dbf2a63
+0x667a0719
+0xd7fe09bf
+0x9afefbd5
+0x6fff82db
+0xa17c8051
+0x81ff71b7
+0x7f37d08d
+0xf36f7253
+0x37dde889
+0xf2fee0af
+0x3dbf8445
+0xb7bad8cb
+0x79ad1fc1
+0xa7fe36a7
+0x575ef6fd
+0x6ffb9643
+0xd7d505f9
+0xdf3f539f
+0x3fff08b5
+0x7f5f8abb
+0x7ffc7b31
+0xd61e1797
+0x7fec996d
+0xb9ae9633
+0xeff65f69
+0xeffe628f
+0xb95c8925
+0xdafa98ab
+0x6b7992a1
+0xbece1487
+0x1ff7b7dd
+0xdfd77223
+0x7378f4d9
+0x9e9f0d7f
+0xebff0595
+0xfeff029b
+0x867b6611
+0xdb7f2d77
+0xedf7524d
+0xb58b2a13
+0xfd73c649
+0xffde546f
+0xff7d7e05
+0x7fdbc88b
+0xefe8f581
+0x5fbe6267
+0x7e9e68bd
+0x7ef2be03
+0x57bdd3b9
+0xb3ff375f
+0xb5fef275
+0x173bea7b
+0xa4b940f1
+0x5efeb357
+0x3f4ffb2d
+0xfcff2df3
+0xcfbe1d29
+0x3abeb64f
+0xedde62e5
+0x15be686b
+0x3fcb4861
+0xbfaf2047
+0x9377099d
+0x1fdf79e3
+0x3ffba299
+0x69dfd13f
+0x7f7ecf55
+0x7ffe425b
+0x2efe0bd1
+0xe736a937
+0xffee940d
+0x6fc2a1d3
+0x75fd6409
+0xffaf882f
+0x7e3f37c5
+0xfd5a784b
+0x5eb88b41
+0x7fee4e27
+0x7efd9a7d
+0x1f77a5c3
+0x3f4a6179
+0x8ebedb1f
+0xefee9c35
+0xd9de0a3b
+0xcf59c6b1
+0xf7bf0f17
+0x9f4f1ced
+0xff2b85b3
+0xa7799ae9
+0x73eeca0f
+0xfe9ffca5
+0x58fff82b
+0xf6b8be21
+0x77dfec07
+0xd93e1b5d
+0x3cd341a3
+0xeda21059
+0x65de54ff
+0x3ffe5915
+0xfc2b421b
+0xeffc7191
+0xfdf7e4f7
+0xeffd95cd
+0x7f97d993
+0xdffac1c9
+0xf9fe7bef
+0xcffcb185
+0x5bdee80b
+0x57ebe101
+0x7feff9e7
+0xffdc8c3d
+0x7e3a4d83
+0x7b7aaf39
+0x29fe3edf
+0xe7ee05f5
+0x5ffbe9fb
+0x4ade0c71
+0xfa572ad7
+0xefddfead
+0x7df79d73
+0x5438d8a9
+0xeeee9dcf
+0x7f7d5665
+0xbfbf47eb
+0x6be9f3e1
+0xbfa677c7
+0xd5fced1d
+0xfbb2c963
+0x19ec3e19
+0x7ffe98bf
+0x6bfda2d5
+0x6bfe01db
+0xb47e9751
+0x5ff6e0b7
+0xe1a4578d
+0x7d4ad153
+0x9afbdf89
+0x1bcf2faf
+0xffbdeb45
+0x7fbf17cb
+0x7faaf6c1
+0x7f6765a7
+0x5b573dfd
+0xfbfab543
+0xe7cebcf9
+0x8ebf629f
+0xfffd2fb5
+0xff6b89bb
+0xffde1231
+0xffdf0697
+0x298ca06d
+0xf7e37533
+0xf0fbd669
+0x7efe318f
+0xfc1e7025
+0x35fe57ab
+0x9e1ee9a1
+0xf7f6c387
+0xd6bf7edd
+0xdaf21123
+0x3fba2bd9
+0xffde9c7f
+0x8e7cac95
+0x7bfe819b
+0xbbbc7d11
+0xff779c77
+0x50e6d94d
+0x2e1b8913
+0x5fd0bd49
+0x2fcfa36f
+0xdffee505
+0x3b7f078b
+0xc3edcc81
+0xf92e9167
+0x7bbdafbd
+0xbff6dd03
+0x3ec68ab9
+0x9ffe465f
+0x1ebc1975
+0xefdee97b
+0x7fd9d7f1
+0x8fd6a257
+0xdb4f022d
+0xdf6b0cf3
+0xfff29429
+0xfbbf854f
+0x77df49e5
+0x6fff276b
+0xffef9f61
+0xdedecf47
+0x3b7dd09d
+0xdf3f18e3
+0xfaebd999
+0x757e603f
+0x5d7f7655
+0x79fec15b
+0x3ffe22d1
+0xf3b61837
+0x63fd1b0d
+0xfeca00d3
+0xf5b95b09
+0xf5cfd72f
+0x2b3f9ec5
+0xf89eb74b
+0x5d2c6241
+0xf3e77d27
+0x5bf7e17d
+0x4af2c4c3
+0x7d621879
+0x79feea1f
+0x73eec335
+0x77de093b
+0x38d95db1
+0x3a97fe17
+0x672523ed
+0xffae64b3
+0xba7d11e9
+0xff6e990f
+0xffdfe3a5
+0x77ffb72b
+0x4fbc1521
+0x3fde9b07
+0x7e37e25d
+0xefdbe0a3
+0x7fe14759
+0xbfdfe3ff
+0xfffe0015
+0xff7ac11b
+0xf7bb8891
+0xf7fe53f7
+0x76671ccd
+0xeb963893
+0x3bf5b8c9
+0x1fffcaef
+0x6ffc1885
+0x26fa270b
+0x3c060800
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000004
+0x00210400
+0x00000000
+0x00000000
+0x00000004
+0x00210404
+0x00000000
+0x00000000
+0x00000004
+0x00210408
+0x00000001
+0x00000000
+0x00000004
+0x0021040c
+0xe00003c0
+0x00000000
+0x00000004
+0x00210410
+0xe00003c0
+0x00000000
+0x00000004
+0x00210418
+0x00000400
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
+0x00000000
diff --git a/src/test/test2/test2_little.blob b/src/test/test2/test2_little.blob
new file mode 100644 (file)
index 0000000..48e08cc
Binary files /dev/null and b/src/test/test2/test2_little.blob differ
index 0000000..48e08cc
Binary files /dev/null and b/src/test/test2/test2_little.blob differ
diff --git a/src/test/test2/test2im.hex b/src/test/test2/test2im.hex
--- /dev/null
@@ -0,0 +1,243 @@
+\ 2
+$Ae0000000,
+00 C8 A1 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 EA 59 86 77 35 77
+C0 00 11 11 B5 D6 20 46 46 46 85 77 D0 28 36 64 81 FF FF A8 E3 40 01 48
+81 FF FF E8 80 0F EA 58 06 60 A3 58 60 46 AB BA 00 00 34 10 02 28 02 64
+02 28 90 5A E1 00 80 40 C1 C6 65 C6 01 82 01 62 01 AD 40 78 01 8D 60 58
+01 8D 8F 78 05 0C 80 58 00 28 20 64 E0 30 00 00 CF FF FC 91 C2 28 02 64
+C0 00 2C 10 C2 28 90 5A 01 80 0F D8 C5 8C 0F D8 C3 0C 0F D8 01 FF FF A8
+01 FF FF E8 00 0F EA 58 20 46 48 2A D0 0C 02 64 95 0C 1F DA 80 04 A3 58
+90 00 1F DB E0 80 80 30 8C 6E 04 3A 6C 6E 00 6F 01 83 01 62 00 28 32 E6
+01 2B 6C 6E 20 00 03 62 0C 6E 6C 6E EA 60 90 00 05 3C 33 E5 01 B4 1F DA
+00 0C 03 63 06 3C 33 E4 05 3C 52 E6 00 00 60 00 00 00 00 00 00 00 00 00
+01 82 04 29 05 BC 54 F4 01 80 10 E8 01 8C 02 64 02 FC A3 5A 02 7F FF AA
+02 7F FF EA 02 94 8A 7A 01 8C 0A 58 05 3C 22 F4 06 EB B5 A9 21 82 06 28
+30 10 03 63 21 80 10 E8 21 8C 02 64 E0 80 80 20 2C 6E 46 46 01 82 01 62
+01 82 06 28 01 80 10 E8 01 8C 02 64 0C 6E 4C 6E 00 0C 13 62 E4 20 00 00
+01 81 81 62 02 02 02 2A 02 00 10 EA 85 06 10 0D 04 BB 4C 6E 20 00 03 62
+00 00 60 00 E3 00 80 00 01 81 01 62 01 82 00 28 01 80 10 E8 00 0C 02 64
+04 BA 6C 6E C0 00 13 62 00 00 60 00 E2 00 80 00 01 81 01 62 01 82 08 28
+01 80 10 E8 01 8C 02 64 00 0C 13 62 01 86 81 62 10 00 44 12 E0 10 00 00
+00 00 A1 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 18 29 F1 00 98 47 A1 04 04 A3 58 C1 90 36 A5
+C4 00 01 29 04 90 1F D8 82 90 56 A7 84 A5 0A 25 00 18 79 A3 01 18 87 A0
+A8 10 37 B5 14 4E A2 56 00 84 A3 5A 23 90 37 A5 20 03 E1 A3 E1 00 00 C0
+01 00 68 DA 60 0C 03 63 28 90 37 A7 20 03 E0 5A C1 94 36 35 C0 80 40 43
+D8 6F 52 C7 E8 00 10 00 82 94 56 37 84 88 2A B4 A8 14 37 55 00 20 0F D8
+C3 94 37 75 C0 03 E1 A0 00 83 80 01 C8 94 37 76 03 90 37 A4 00 00 40 00
+00 00 00 00 00 03 40 01 03 94 37 74 00 8C A3 62 00 00 00 00 00 00 00 00
+07 BF 00 5A 02 00 A3 5A 02 00 00 7E BC 45 2C 6E 00 00 20 00 01 82 0C 28
+01 80 10 E8 E1 00 00 00 01 8C 02 64 9D 89 6C 6E 30 28 A1 20 03 02 80 2A
+03 70 00 6B 02 00 00 6F B5 5D A2 47 E8 40 00 00 A2 41 6C 6E 02 00 00 7E
+BC 4D 2C 6E 26 41 6C 6E 2C 6E BC 45 01 82 0C 28 01 80 10 E8 E3 A0 00 00
+01 8C 02 64 00 00 60 00 00 10 78 F8 CF F3 A1 20 00 04 A1 20 00 00 00 00
+00 00 00 00 00 00 00 00 07 81 FE 2A 07 80 10 EA 07 BF 09 F2 07 02 0A 2A
+07 00 10 EA 02 00 20 2A 02 70 00 6A 00 10 03 62 02 0B 00 28 01 83 41 62
+02 70 00 68 01 81 C0 28 01 F0 00 68 00 00 00 00 00 0C 13 62 01 88 81 62
+02 00 90 2A 02 70 00 6A 00 10 03 62 01 85 61 62 02 04 A3 58 00 05 A1 20
+00 00 00 00 00 00 00 00 02 FF FF A8 02 FF FF E9 02 81 50 2A 02 F0 00 6B
+96 E9 FE 27 02 EF 62 C6 32 0C 02 65 E6 00 06 00 02 00 A3 58 01 80 A3 58
+31 94 80 58 00 00 00 00 02 0C 1F DA 00 00 00 00 00 00 00 00 00 00 00 00
+00 8C A3 62 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 01 A1 20 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 7E FE B0 E7 E4 FF 9B 3D DF FB 74 83 BE FB AE 39
+BF FE D5 DF 33 FF F4 F5 2F 9E F0 FB 45 9F EB 71 DF FF A1 D7 FB DE CD AD
+7B F2 84 73 BF 77 97 A9 75 6E F4 CF 7F 5D 05 65 66 BA 0E EB 6F 59 92 E1
+5E 56 AE C7 7E FF 7C 1D FF 97 70 63 7D F8 BD 19 7B DE AF BF 36 AF 11 D5
+FF EE 88 DB 3F 7B F6 51 FF B6 D7 B7 CB BC A6 8D 70 E3 38 53 7F F6 1E 89
+FE DF 06 AF 5F BD 1A 45 75 9F 5E CB 6F BE 15 C1 61 67 1C A7 5F 5D 4C FD
+3F FA DC 43 76 E6 BB F9 37 FE F9 9F FE EE 1E B5 79 6B 90 BB FB DE F1 31
+DF 56 7D 97 BF F4 6F 6D F7 FB 5C 33 FF F1 95 69 FB EF 88 8F FF DD 1F 25
+BD FE 1E AB 7B CD 88 A1 7F FF FA 87 FF BD 0D DD 6F D3 B8 23 6F BD AA D9
+1E 9F B3 7F 6F FD 1B 95 5C AE 08 9B 5F B8 DC 11 7F F6 93 77 3F FE 28 4D
+EF 32 F0 13 7F 71 FC 49 FF 5E 7A 6F 3B FD 14 05 7E 7E 4E 8B FF 7F EB 81
+FE 3F 48 67 6E 16 BE BD FF BA 04 03 FF F5 89 B9 7F FE DD 5F 67 FC 08 75
+70 BB F0 7B 4F F9 B6 F1 CE DF 19 57 7E 5D D1 2D FF 63 F3 F3 5A BF 53 29
+7F BF DC 4F 5F DC F8 E5 FF BF EE 6B 5D CD 3E 61 6D B7 06 47 7F 7E 5F 9D
+BD 9F BF E3 3D E6 58 99 BF 7E 77 3F 3D 3E E5 55 BB EB 48 5B FD F9 81 D1
+34 76 0F 37 6C FF 6A 0D 6D E2 67 D3 BF F1 9A 09 CE BF AE 2F EF 3C CD C5
+FF BA FE 4B 7C 2D 81 41 4E E7 34 27 57 D7 F0 7D FB 72 EB C3 FD E8 17 79
+1C FE 81 1F BD 6D B2 35 37 DE 10 3B 17 F8 3C B1 F5 BF 75 17 4D 5E F2 ED
+D7 66 4B B3 F7 F0 D0 E9 7D EF F0 0F FC 9C 92 A5 EF FF 7E 2B 57 D8 B4 21
+F4 FF D2 07 FF FF 71 5D EE FB 87 A3 DA F2 C6 59 E6 9E FA FF E4 CC 6F 15
+E6 AE 48 1B 1F BD E7 91 FF F7 4A F7 5F F4 6B CD 9F AB 9F 93 EF D4 F7 C9
+FE EE A1 EF F6 FC 47 85 7D FF 6E 0B 7D FE D7 01 7D BE DF E7 EF F4 E2 3D
+7E 7B 93 83 FF 7E 65 39 FF FF E4 DF BF 7F 1B F5 BF FB EF FB DE DA 82 71
+6C F7 90 D7 7D F7 D4 AD 73 EA 63 73 97 76 0E A9 EE 7F C3 CF FB 7F EC 65
+9F BA CD EB 77 EF E9 E1 53 56 5D C7 FF F4 43 1D FB D3 0F 63 E7 62 F4 19
+BE FF 3E BF 19 CD B8 D5 CB EF 07 DB 77 FE 0D 51 EF FE 46 B7 1F FD 2D 8D
+DB 56 97 53 ED 9C 15 89 1D 8F 55 AF FF BF 81 45 7A FF 9D CB 7B EB EC C1
+FE E6 4B A7 4A 75 93 FD 69 F3 FB 43 95 F8 72 F9 72 BF 08 9F 7D EC 45 B5
+1E 5F 8F BB 5D D8 88 31 5B 97 6C 97 7E A4 76 6D FF AA 3B 33 FE FF 0C 69
+77 EF 57 8F 4A 9F 06 25 13 FF DD AB BD 1A DF A1 75 C6 A9 87 AD FC D4 DD
+7C D6 57 23 FE 76 E1 D9 77 BF 42 7F 7B 4E C2 95 7F FF 87 9B 37 79 F3 11
+FF 77 02 77 7E E5 AF 4D 6A 9B 4F 13 F5 76 F3 49 55 6F C9 6F DE 7E 7B 05
+3F 7B 8D 8B FE 7C C2 81 5F 27 77 67 7F 5E 05 BD 3F F6 23 03 1B 96 40 B9
+3E FF EC 5F F7 FD 2F 75 4B 3E EF 7B B5 9A 4D F1 DF D7 08 57 7F 6C D8 2D
+FB 67 D2 F3 2F FB CA 29 C1 AE AB 4F 37 DD DF E5 5E FE AD 6B EA C9 95 61
+7B C6 B5 47 37 F5 26 9D 7F DB 5E E3 DC EE 8F 99 F6 7F 06 3F 6B 4F 8C 55
+D6 FB C7 5B EF F9 98 D1 FF 3F 7E 37 AF FD F1 0D EF FF C6 D3 2A 35 91 09
+BF 3F FD 2F 6F 3D 34 C5 FF BF 3D 4B 73 39 58 41 9F F6 63 27 5B DE 37 7D
+EF FA 0A C3 3F 57 CE 79 F7 BE 90 1F FF 7D D9 35 DD EE 0F 3B E7 FF D3 B1
+4C F6 64 17 D6 4C F9 ED F9 E3 2A B3 EB 7C 47 E9 EE FF BF 0F 5F DC 79 A5
+5D FF 3D 2B 7F FC 0B 21 FB 56 81 07 47 FD 38 5D ED FA 26 A3 5D E9 FD 59
+2D FE 89 FF F3 DC 16 15 FF AB C7 1B 7B BC FE 91 F5 F7 B9 F7 EC 75 F2 CD
+77 83 FE 93 7F D7 EE C9 19 CF F0 EF BF FF AE 85 7F DA AD 0B 7F F9 AE 01
+DC B7 0E E7 EA D6 29 3D 57 77 B2 83 7E 3D 1C 39 FB FE F3 DF F8 EE 42 F5
+5C AA EE FB 6B D9 19 71 7F 77 7F D7 30 C4 DB AD 6F FA 42 73 EF F0 85 A9
+FF 2E 92 CF C4 7E D3 65 FE 3B 8C EB EF 4A 40 E1 7F 76 0C C7 4B F5 0A 1D
+75 FA AE 63 DE 69 2B 19 27 FF CD BF FE DC 5F D5 F7 EB 86 DB 7F FC 24 51
+74 B7 B5 B7 5F FD B4 8D 1F E3 F6 53 5B FE 0C 89 7D CF A4 AF A9 BD E8 45
+3B BF DC CB 7D AD C3 C1 57 67 7A A7 7F F5 DA FD 97 F7 1A 43 EE C6 29 F9
+EF 3F 17 9F BD FE 6C B5 BF 5F 8E BB EF FE 1F 31 77 DE 5B 97 35 D4 7D 6D
+CF F3 1A 33 E1 F8 83 69 69 FF 26 8F 2D 5C ED 25 7E FB 9C AB FF 1C 36 A1
+FB E7 58 87 6F BC 9B DD EF F6 F6 23 AF 6C 18 D9 E3 DE D1 7F 5D DC 69 95
+BE BB 06 9B 7A FF 0A 11 A7 7F 71 77 E7 E5 36 4D ED DF AE 13 7C 57 EA 49
+2F 4F 18 6F 69 7F E2 05 FF FE CC 8B A9 ED 99 81 FA EF A6 67 7E FD 4C BD
+7B F2 42 03 75 F2 F7 B9 17 FE FB 5F 6F EE 56 75 F6 1F EE 7B 77 FE E4 F1
+58 D6 F7 57 03 FF DF 2D EE E7 B1 F3 FE F4 41 29 7C BF 7A 4F 55 DE C6 E5
+AF BB 6C 6B F7 F9 EC 61 63 EE 64 47 A6 FF ED 9D 72 DE FD E3 73 F2 C6 99
+7F 7F 95 3F EF 6C 33 55 F3 FE 46 5B DF FD AF D1 BA 3E ED 37 FE BC 78 0D
+43 FB 25 D3 D7 B5 88 09 FF 4E 4C 2F F2 3D 9B C5 A9 1F 7C 4B FE B9 2F 41
+5F FF 92 27 5E FC 7E 7D 21 7B 29 C3 7B 43 85 79 EB FE 9F 1F 63 EE 00 35
+6C EE 0E 3B 7B DB 6A B1 DB BF 53 17 BB BF 00 ED EB 3A 09 B3 FF F3 BE E9
+7F FF 8E 0F 3F BC 60 A5 FD 7A FC 2B ED DB 62 21 56 C7 30 07 D7 7E FF 5D
+52 F6 C5 A3 56 FD 34 59 FB FE 18 FF C7 EF BD 15 5F 2F 46 1B 47 B8 15 91
+EE F6 28 F7 E3 6F 79 CD E2 B6 5D 93 F7 F6 E5 C9 4F FF 3F EF 3E FF 15 85
+FF DF EC 0B 5A F8 85 01 3F A7 3D E7 ED BF 70 3D DD 7F D1 83 6F 37 D3 39
+7F FE 02 DF 7B 3D 69 F5 FF AF ED FB FE 9B B0 71 FF D7 6E D7 F7 D5 E2 AD
+7F EA 21 73 7D 76 FC A9 5F 7F 61 CF F7 7D BA 65 7F FE 4B EB 1D 58 97 E1
+6F AF BB C7 ED FD D1 1D 4F FE 4D 63 7D 6B 62 19 F7 DE 5C BF FF EF 06 D5
+FE EE 05 DB 6F FE 3B 51 1F B7 24 B7 D5 3E 3B 8D B5 CB 55 53 DE 9C 03 89
+7F AF F3 AF 6B BC 4F 45 F7 DE 1B CB FF BB 9A C1 EF 66 A9 A7 6F FE 21 FD
+FF F6 39 43 FB CF E0 F9 D8 7F 26 9F 3F EC 93 B5 7B 4B 8D BB 83 DF B6 31
+F9 37 4A 97 F5 84 84 6D C8 B7 F9 33 D6 FD FA 69 ED EE F5 8F 57 3E D4 25
+FF FF 5B AB 77 D9 8D A1 DF E6 07 87 9E FC 62 DD FF 7F 95 23 7A 7D 4F D9
+6D 9E 60 7F F8 6E 10 95 F5 AA 85 9B 6D 38 21 11 73 F7 E0 77 4E FC BD 4D
+77 02 0D 13 DF D4 E1 49 7E 5E 67 6F 6E FD 49 05 DD FA 0B 8B 7F EA 70 81
+65 EF D5 67 7F 34 93 BD BD F6 61 03 7B 8B AE B9 F2 FE 0A 5F 8C AF 7D 75
+5F 5A ED 7B EF 9F 7B F1 73 FE E6 57 EF 46 E6 2D E7 E3 90 F3 FD B8 B8 29
+3F BE 49 4F 7F DF AD E5 03 FE 2B 6B 7E DE 43 61 7E B6 13 47 57 7E B4 9D
+FF D2 9C E3 7F F2 FD 99 FB 7E 24 3F D9 6C DA 55 5F EA C5 5B F9 FD C6 D1
+A7 3E 5C 37 7F B6 FF 0D FF D2 84 D3 5E 71 7F 09 1D FE 9B 2F DD 3E 02 C5
+7F DB BB 4B CF 3D 06 41 F7 EE C1 27 5F F6 C5 7D 5D 76 48 C3 BD 6B 3C 79
+FD FE AE 1F C7 7E 27 35 27 FE 0D 3B ED 5B 01 B1 F7 BE 42 17 5E A5 07 ED
+E6 6A E8 B3 FF F7 35 E9 2B 6F 5D 0F 79 FC 47 A5 FF 7A BB 2B FB FE B9 21
+3D 4F DF 07 49 74 C6 5D FF DF 64 A3 FB AC 6B 59 3B 7F A7 FF 7D EF 64 15
+37 EA C5 1B 7F BF 2C 91 7F F6 97 F7 37 ED 00 CD FF C2 BC 93 56 F1 DC C9
+6F DE 8E EF DF FE 7C 85 FA FB 2B 0B DD EB 5C 01 BE B7 6C E7 FB BC B7 3D
+EF 73 F0 83 9A 6E 8A 39 6A 7F 11 DF BF AC 90 F5 DE 9A EC FB B7 FA 47 71
+1F FF 5D D7 E6 DE E9 AD 7E F2 00 73 6F 39 73 A9 FF 6E 30 CF 0B 7C A1 65
+BE FB 0A EB 72 5A EE E1 74 FF 6A C7 4D F6 98 1D EB DB EC 63 1F E9 99 19
+FD DE EB BF EE FD AD D5 5B FA 84 DB 7B 7C 52 51 FA F6 93 B7 DF 36 C2 8D
+FD D2 B4 53 45 F5 FA 89 BE AE 42 AF F7 BE B6 45 F3 DA 5A CB B7 FD 71 C1
+6D F7 D8 A7 55 D6 68 FD FD FF 58 43 6E D5 97 F9 CF FF 35 9F 7E EE BA B5
+DF 4B 8C BB 7F FD 4D 31 FC B6 39 97 F7 AC 8B 6D DB F6 D8 33 C7 FF 71 69
+77 FE C4 8F 77 FC BB 25 77 FB 1A AB ED 4A E4 A1 D6 FE B6 87 29 B4 29 DD
+59 56 34 23 0F EA 86 D9 FE FF EF 7F DB FF B7 95 F5 AE 04 9B 65 3D 38 11
+3D FE 4F 77 67 F4 44 4D FB FE 6C 13 FE 7D D8 49 ED 7F B6 6F BF FE B0 05
+BB 7B 4A 8B 77 FB 47 81 F8 2E 04 67 7F DF DA BD FB BA 80 03 DB E0 65 B9
+DF FF 19 5F EF BC A4 75 DC EF EC 7B 5A DC 12 F1 FF D6 D5 57 BB CD ED 2D
+F2 7B 6F F3 FC B9 2F 29 D6 FF 18 4F BF DC 94 E5 5B FA EA 6B DD CE 9A 61
+79 97 C2 47 CB F5 7B 9D FF 9E 3B E3 DF EF 34 99 3B FE B3 3F F5 7D 81 55
+2F EF 44 5B 1C F9 DD D1 70 7F CB 37 7A ED 86 0D 7F C7 E3 D3 7F 59 76 09
+3A 4E EA 2F 7D 3E 69 C5 7F FB FA 4B DC 3C DD 41 77 EF F0 27 73 FD 0C 7D
+FF 7F 67 C3 F9 CE F3 79 BC FE BD 1F 2A EE 4E 35 A2 EE 0C 3B 5F 5E 98 B1
+7F BF 31 17 59 0F 0E ED FD 7B C7 B3 DD 76 AC E9 FF FF 2C 0F DF BC 2E A5
+7E 7E 7A 2B 5E CE 10 21 3C F6 8E 07 CF FE 8D 5D FF F6 03 A3 7F B7 A2 59
+6F BF 36 FF 4E FF 0B 15 4E EE 44 1B 6B BA 43 91 77 FF 06 F7 6D 7E 87 CD
+7C AF 1B 93 B7 F8 D3 C9 FF CF DD EF A1 FD E3 85 FD DA 6A 0B FE FA 33 01
+35 E7 9B E7 FF 9D FE 3D 0E 36 0F 83 F7 E1 41 39 7B FE 20 DF 3D 2F B7 F5
+3D DF EB FB 3D 3C DE 71 7E D7 4C D7 69 DF F0 AD 7F F7 DF 73 7E 37 EA A9
+9E EE FF CF 7D 7F 88 65 5D 7F C9 EB EF E9 45 E1 7F 6F 19 C7 EB FF 5F 1D
+BF 97 8B 63 BF 63 D0 19 6E FF 7A BF A5 FC 54 D5 3E EB 03 DB 8E 7E 69 51
+BF BE 02 B7 7A 67 49 8D 7F F2 13 53 F4 9B F1 89 C7 CE 91 AF FF BD 1D 45
+AD 9E 99 CB F5 FB 48 C1 FF EF 07 A7 57 DE AF FD 7D F6 77 43 75 D7 4E F9
+BE 3F 44 9F D9 FC E1 B5 75 5F 8B BB EF DE E4 31 5F 5F 28 97 7A CC 92 6D
+BE F3 B7 33 BE FC E8 69 6B EE 93 8F BF BE A2 25 7F FE D9 AB F9 88 3B A1
+B3 F7 65 87 8D F7 F0 DD 1D 7A D3 23 FB B3 BD D9 3B FF 7E 7F FF 7D 5E 95
+FB FB 83 9B 7B FE 4F 11 1D 7E BE 77 DE E7 CB 4D 76 D6 CB 13 79 52 CF 49
+B5 FF 05 6F 53 7C 17 05 D7 DA 89 8B 3E 68 1E 81 7B 66 33 67 7D FF 21 BD
+3F F6 9F 03 EE F1 1C B9 F8 FE 28 5F 5B FD CB 75 7F EA EB 7B EF FC A9 F1
+FD FE C4 57 5B D4 F4 2D FD EF 4E F3 D7 B5 A6 29 7D EF E7 4F BF DD 7B E5
+F7 BB A9 6B ED EA F1 61 ED 8F 71 47 5F 74 42 9D 67 57 DA E3 FF E7 6B 99
+9F 5F 42 3F D7 7E 28 55 7A 6B C3 5B 37 F9 F4 D1 1B B7 3A 37 FB E4 0D 0D
+B7 D7 42 D3 EF 9D 6D 09 5B 2F 39 2F FF 3E D0 C5 5B 7A 39 4B 6F 38 B4 41
+FD EF 1F 27 7D FF 53 7D F2 76 86 C3 FB 6E AA 79 AF FE CC 1F EB 6E 75 35
+7D EE 0B 3B FB 5E 2F B1 6E FE 20 17 FC ED 15 ED FE 66 A6 B3 B5 F2 23 E9
+7D FE FB 0F E7 FC 15 A5 FF FE 39 2B B5 E9 67 21 37 FF 3D 07 4E FC 54 5D
+7B D6 A2 A3 3D FE D9 59 DD 7E C5 FF 3F FE B2 15 6F 7B C3 1B 7F B9 5A 91
+FF F7 75 F7 EC F4 0E CD FB F3 7A 93 3A FB CA C9 F7 DF 2C EF 77 FD 4A 85
+7C FF A9 0B DB FD 0A 01 FC AF CA E7 F7 FF 45 3D 79 F2 2E 83 EB 8F F8 39
+7F 7F 2F DF B6 6E DE F5 DE FE EA FB F7 1B 75 71 FF 57 3B D7 7E E4 F7 AD
+5F FB BE 73 71 B2 61 A9 73 2F CE CF 76 7E 6F 65 75 7E 88 EB 77 EB 9C E1
+BE FE C8 C7 5E FC 26 1D 7D BF 2A 63 66 7A 07 19 D7 FE 09 BF 9A FE FB D5
+6F FF 82 DB A1 7C 80 51 81 FF 71 B7 7F 37 D0 8D F3 6F 72 53 37 DD E8 89
+F2 FE E0 AF 3D BF 84 45 B7 BA D8 CB 79 AD 1F C1 A7 FE 36 A7 57 5E F6 FD
+6F FB 96 43 D7 D5 05 F9 DF 3F 53 9F 3F FF 08 B5 7F 5F 8A BB 7F FC 7B 31
+D6 1E 17 97 7F EC 99 6D B9 AE 96 33 EF F6 5F 69 EF FE 62 8F B9 5C 89 25
+DA FA 98 AB 6B 79 92 A1 BE CE 14 87 1F F7 B7 DD DF D7 72 23 73 78 F4 D9
+9E 9F 0D 7F EB FF 05 95 FE FF 02 9B 86 7B 66 11 DB 7F 2D 77 ED F7 52 4D
+B5 8B 2A 13 FD 73 C6 49 FF DE 54 6F FF 7D 7E 05 7F DB C8 8B EF E8 F5 81
+5F BE 62 67 7E 9E 68 BD 7E F2 BE 03 57 BD D3 B9 B3 FF 37 5F B5 FE F2 75
+17 3B EA 7B A4 B9 40 F1 5E FE B3 57 3F 4F FB 2D FC FF 2D F3 CF BE 1D 29
+3A BE B6 4F ED DE 62 E5 15 BE 68 6B 3F CB 48 61 BF AF 20 47 93 77 09 9D
+1F DF 79 E3 3F FB A2 99 69 DF D1 3F 7F 7E CF 55 7F FE 42 5B 2E FE 0B D1
+E7 36 A9 37 FF EE 94 0D 6F C2 A1 D3 75 FD 64 09 FF AF 88 2F 7E 3F 37 C5
+FD 5A 78 4B 5E B8 8B 41 7F EE 4E 27 7E FD 9A 7D 1F 77 A5 C3 3F 4A 61 79
+8E BE DB 1F EF EE 9C 35 D9 DE 0A 3B CF 59 C6 B1 F7 BF 0F 17 9F 4F 1C ED
+FF 2B 85 B3 A7 79 9A E9 73 EE CA 0F FE 9F FC A5 58 FF F8 2B F6 B8 BE 21
+77 DF EC 07 D9 3E 1B 5D 3C D3 41 A3 ED A2 10 59 65 DE 54 FF 3F FE 59 15
+FC 2B 42 1B EF FC 71 91 FD F7 E4 F7 EF FD 95 CD 7F 97 D9 93 DF FA C1 C9
+F9 FE 7B EF CF FC B1 85 5B DE E8 0B 57 EB E1 01 7F EF F9 E7 FF DC 8C 3D
+7E 3A 4D 83 7B 7A AF 39 29 FE 3E DF E7 EE 05 F5 5F FB E9 FB 4A DE 0C 71
+FA 57 2A D7 EF DD FE AD 7D F7 9D 73 54 38 D8 A9 EE EE 9D CF 7F 7D 56 65
+BF BF 47 EB 6B E9 F3 E1 BF A6 77 C7 D5 FC ED 1D FB B2 C9 63 19 EC 3E 19
+7F FE 98 BF 6B FD A2 D5 6B FE 01 DB B4 7E 97 51 5F F6 E0 B7 E1 A4 57 8D
+7D 4A D1 53 9A FB DF 89 1B CF 2F AF FF BD EB 45 7F BF 17 CB 7F AA F6 C1
+7F 67 65 A7 5B 57 3D FD FB FA B5 43 E7 CE BC F9 8E BF 62 9F FF FD 2F B5
+FF 6B 89 BB FF DE 12 31 FF DF 06 97 29 8C A0 6D F7 E3 75 33 F0 FB D6 69
+7E FE 31 8F FC 1E 70 25 35 FE 57 AB 9E 1E E9 A1 F7 F6 C3 87 D6 BF 7E DD
+DA F2 11 23 3F BA 2B D9 FF DE 9C 7F 8E 7C AC 95 7B FE 81 9B BB BC 7D 11
+FF 77 9C 77 50 E6 D9 4D 2E 1B 89 13 5F D0 BD 49 2F CF A3 6F DF FE E5 05
+3B 7F 07 8B C3 ED CC 81 F9 2E 91 67 7B BD AF BD BF F6 DD 03 3E C6 8A B9
+9F FE 46 5F 1E BC 19 75 EF DE E9 7B 7F D9 D7 F1 8F D6 A2 57 DB 4F 02 2D
+DF 6B 0C F3 FF F2 94 29 FB BF 85 4F 77 DF 49 E5 6F FF 27 6B FF EF 9F 61
+DE DE CF 47 3B 7D D0 9D DF 3F 18 E3 FA EB D9 99 75 7E 60 3F 5D 7F 76 55
+79 FE C1 5B 3F FE 22 D1 F3 B6 18 37 63 FD 1B 0D FE CA 00 D3 F5 B9 5B 09
+F5 CF D7 2F 2B 3F 9E C5 F8 9E B7 4B 5D 2C 62 41 F3 E7 7D 27 5B F7 E1 7D
+4A F2 C4 C3 7D 62 18 79 79 FE EA 1F 73 EE C3 35 77 DE 09 3B 38 D9 5D B1
+3A 97 FE 17 67 25 23 ED FF AE 64 B3 BA 7D 11 E9 FF 6E 99 0F FF DF E3 A5
+77 FF B7 2B 4F BC 15 21 3F DE 9B 07 7E 37 E2 5D EF DB E0 A3 7F E1 47 59
+BF DF E3 FF FF FE 00 15 FF 7A C1 1B F7 BB 88 91 F7 FE 53 F7 76 67 1C CD
+EB 96 38 93 3B F5 B8 C9 1F FF CA EF 6F FC 18 85 26 FA 27 0B 3C 06 08 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 00 21 04 00
+00 00 00 00 00 00 00 00 00 00 00 04 00 21 04 04 00 00 00 00 00 00 00 00
+00 00 00 04 00 21 04 08 00 00 00 01 00 00 00 00 00 00 00 04 00 21 04 0C
+E0 00 03 C0 00 00 00 00 00 00 00 04 00 21 04 10 E0 00 03 C0 00 00 00 00
+00 00 00 04 00 21 04 18 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00
+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
+\ 3
\ No newline at end of file
diff --git a/src/test/test2/test2ini.s b/src/test/test2/test2ini.s
--- /dev/null
@@ -0,0 +1,16 @@
+;
+;
+ .sect ".enter"
+ .ref _c_int00
+ .def _enter
+
+
+_enter:
+
+ bnop _c_int00, 5
+
+
+
+
+
+
diff --git a/src/util/btoccs/Makefile b/src/util/btoccs/Makefile
--- /dev/null
+++ b/src/util/btoccs/Makefile
@@ -0,0 +1,17 @@
+all: b2ccs.exe b2i2c.exe ccs2b.exe bfaddsect.exe bfmerge.exe
+
+
+b2ccs.exe: b2ccs.c
+ gcc -o b2ccs b2ccs.c
+
+b2i2c.exe: b2i2c.c
+ gcc -o b2i2c b2i2c.c
+
+ccs2b.exe: ccs2b.c
+ gcc -o ccs2b ccs2b.c
+
+bfaddsect.exe: bfaddsect.c
+ gcc -o bfaddsect bfaddsect.c
+
+bfmerge.exe: bfmerge.c
+ gcc -o bfmerge bfmerge.c
diff --git a/src/util/btoccs/b2ccs.c b/src/util/btoccs/b2ccs.c
--- /dev/null
+++ b/src/util/btoccs/b2ccs.c
@@ -0,0 +1,167 @@
+/* Convert a hex b file into a ccs data file */
+
+#include <stdio.h>
+#include <malloc.h>
+
+
+int asciiByte (unsigned char c)
+{
+ if ((c >= '0') && (c <= '9'))
+ return (1);
+
+ if ((c >= 'A') && (c <= 'F'))
+ return (1);
+
+ return (0);
+}
+
+int toNum (unsigned char c)
+{
+ if ((c >= '0') && (c <= '9'))
+ return (c - '0');
+
+ return (c - 'A' + 10);
+
+}
+
+
+void stripLine (FILE *s)
+{
+ char iline[132];
+
+ fgets (iline, 131, s);
+
+}
+
+/* Read a .b file. */
+int readBFile (FILE *s, unsigned char *data, unsigned maxSize)
+{
+ unsigned char x, y;
+ int byteCount = 0;
+
+ /* Strip the 1st two lines */
+ stripLine (s);
+ stripLine (s);
+
+ for (;;) {
+
+ /* read the 1st ascii char */
+ do {
+ x = fgetc (s);
+ if (x == (unsigned char)EOF)
+ return (byteCount);
+
+ } while (!asciiByte(x));
+
+ /* Read the next ascii char */
+ y = fgetc (s);
+ if (y == (unsigned char)EOF)
+ return (byteCount);
+ if (asciiByte(y))
+ data[byteCount++] = (toNum(x) << 4) | toNum (y);
+
+ if (byteCount >= maxSize) {
+ fprintf (stderr, "Max input array size exceeded\n");
+ return (-1);
+ }
+
+ }
+
+
+}
+
+
+unsigned dwordConvert (unsigned char *data, int idx, int iMax)
+{
+ unsigned value;
+ unsigned char c[4];
+ int i;
+
+ c[0] = c[1] = c[2] = c[3] = 0;
+
+ for (i = 0; i < 4; i++) {
+ if (idx >= iMax)
+ break;
+ c[i] = data[idx++];
+ }
+
+ value = c[3] | (c[2] << 8) | (c[1] << 16) | (c[0] << 24);
+
+ return (value);
+
+}
+
+
+
+#define SIZE 0x100000 /* max array size */
+
+int main (int argc, char *argv[])
+{
+ FILE *strin;
+ FILE *strout;
+
+ unsigned char *dataSet1;
+
+ unsigned char block[128];
+ unsigned blockSize;
+
+ unsigned pIn;
+ unsigned pOut;
+
+ int inSize;
+ int i;
+
+ /* Arg check */
+ if (argc != 3) {
+ fprintf (stderr, "usage: %s infile outfile\n", argv[0]);
+ return (-1);
+ }
+
+ /* Open the input file */
+ strin = fopen (argv[1], "r");
+ if (strin == NULL) {
+ fprintf (stderr, "%s: Could not open file %s for reading\n", argv[0], argv[1]);
+ return (-1);
+ }
+
+ /* Allocate the two data set memories */
+ dataSet1 = malloc (SIZE * sizeof (unsigned char));
+ if (dataSet1 == NULL) {
+ fprintf (stderr, "%s: Malloc failure\n", argv[0]);
+ return (-1);
+ }
+
+ /* Read the data into the byte stream */
+ if ((inSize = readBFile (strin, dataSet1, SIZE)) < 0)
+ return (inSize);
+ fclose (strin);
+
+ strout = fopen (argv[2], "w");
+ if (strout == NULL) {
+ fprintf (stderr, "%s error: Could not open output file %s\n", argv[0], argv[2]);
+ free (dataSet1);
+ return (-1);
+ }
+
+ /* Write the CCS header */
+ fprintf (strout, "1651 1 10000 1 %x\n", (inSize + 3) / 4);
+
+ /* Write out each 32 bit line. */
+ for (i = 0; i < inSize; i += 4)
+ fprintf (strout, "0x%08x\n", dwordConvert (dataSet1, i, inSize));
+
+ free (dataSet1);
+ fclose (strout);
+
+
+ return (0);
+
+}
+
+
+
+
+
+
+
+
diff --git a/src/util/btoccs/b2ccs_nb.c b/src/util/btoccs/b2ccs_nb.c
--- /dev/null
@@ -0,0 +1,177 @@
+/* Second attempt to create the ccs version file for testing the rom boot loader */
+/* No i2c blocking is performed */
+
+#include <stdio.h>
+#include <malloc.h>
+
+
+int asciiByte (unsigned char c)
+{
+ if ((c >= '0') && (c <= '9'))
+ return (1);
+
+ if ((c >= 'A') && (c <= 'F'))
+ return (1);
+
+ return (0);
+}
+
+int toNum (unsigned char c)
+{
+ if ((c >= '0') && (c <= '9'))
+ return (c - '0');
+
+ return (c - 'A' + 10);
+
+}
+
+
+void stripLine (FILE *s)
+{
+ char iline[132];
+
+ fgets (iline, 131, s);
+
+}
+
+/* Read a .b file. */
+int readBFile (FILE *s, unsigned char *data, unsigned maxSize)
+{
+ unsigned char x, y;
+ int byteCount = 0;
+
+ /* Strip the 1st two lines */
+ stripLine (s);
+ stripLine (s);
+
+ for (;;) {
+
+ /* read the 1st ascii char */
+ do {
+ x = fgetc (s);
+ if (x == (unsigned char)EOF)
+ return (byteCount);
+
+ } while (!asciiByte(x));
+
+ /* Read the next ascii char */
+ y = fgetc (s);
+ if (y == (unsigned char)EOF)
+ return (byteCount);
+ if (asciiByte(y))
+ data[byteCount++] = (toNum(x) << 4) | toNum (y);
+
+ if (byteCount >= maxSize) {
+ fprintf (stderr, "Max input array size exceeded\n");
+ return (-1);
+ }
+
+ }
+
+
+}
+
+
+int copyBlock (unsigned char *source, int idx, int maxSize, unsigned char *dest, int count)
+{
+ int i;
+
+ for (i = 0; i < count; i++) {
+ if (idx >= maxSize)
+ break;
+ dest[i] = source[idx++];
+ }
+
+ return (i);
+
+}
+
+unsigned dwordConvert (unsigned char *data, int idx, int iMax)
+{
+ unsigned value;
+ unsigned char c[4];
+ int i;
+
+ c[0] = c[1] = c[2] = c[3] = 0;
+
+ for (i = 0; i < 4; i++) {
+ if (idx >= iMax)
+ break;
+ c[i] = data[idx++];
+ }
+
+ value = c[0] | (c[1] << 8) | (c[2] << 16) | (c[3] << 24);
+
+ return (value);
+
+}
+
+
+
+#define SIZE 0x10000 /* max array size */
+
+int main (int argc, char *argv[])
+{
+ FILE *strin;
+ FILE *strout;
+
+ unsigned char *dataSet1;
+
+ unsigned pIn;
+ unsigned pOut;
+
+ int inSize;
+ int i;
+
+ /* Arg check */
+ if (argc != 3) {
+ fprintf (stderr, "usage: %s infile outfile\n", argv[0]);
+ return (-1);
+ }
+
+ /* Open the input file */
+ strin = fopen (argv[1], "r");
+ if (strin == NULL) {
+ fprintf (stderr, "%s: Could not open file %s for reading\n", argv[0], argv[1]);
+ return (-1);
+ }
+
+ /* Allocate the two data set memories */
+ dataSet1 = malloc (SIZE * sizeof (unsigned char));
+ if (dataSet1 == NULL) {
+ fprintf (stderr, "%s: Malloc failure\n", argv[0]);
+ return (-1);
+ }
+
+ /* Read the data into the byte stream */
+ if ((inSize = readBFile (strin, dataSet1, SIZE)) < 0)
+ return (inSize);
+ fclose (strin);
+
+ /* Copy the resulting data set into the output file in ccs format */
+ strout = fopen (argv[2], "w");
+ if (strout == NULL) {
+ fprintf (stderr, "%s: Could not open %s for writing\n", argv[0], argv[2]);
+ return (-1);
+ }
+
+ /* Write the ccs header. The number of lines must be computed from the
+ * array size */
+ fprintf (strout, "1651 1 b000 1 %x\n", (inSize + 3) / 4);
+
+ for (i = 0; i < inSize; i += 4)
+ fprintf (strout, "0x%08x\n", dwordConvert (dataSet1, i, inSize));
+
+ fclose (strout);
+
+ return (0);
+
+}
+
+
+
+
+
+
+
+
diff --git a/src/util/btoccs/b2i2c.c b/src/util/btoccs/b2i2c.c
--- /dev/null
+++ b/src/util/btoccs/b2i2c.c
@@ -0,0 +1,235 @@
+/* Create an ascii hex i2c data file */
+
+#include <stdio.h>
+#include <malloc.h>
+
+unsigned onesComplementAdd (unsigned value1, unsigned value2)
+{
+ unsigned result;
+
+ result = (unsigned)value1 + (unsigned)value2;
+
+ result = (result >> 16) + (result & 0xFFFF); /* add in carry */
+ result += (result >> 16); /* maybe one more */
+ result = (result & 0xffff);
+ return (unsigned)result;
+
+} /* end of beth_ones_complement_add() */
+
+
+int asciiByte (unsigned char c)
+{
+ if ((c >= '0') && (c <= '9'))
+ return (1);
+
+ if ((c >= 'A') && (c <= 'F'))
+ return (1);
+
+ return (0);
+}
+
+int toNum (unsigned char c)
+{
+ if ((c >= '0') && (c <= '9'))
+ return (c - '0');
+
+ return (c - 'A' + 10);
+
+}
+
+
+void stripLine (FILE *s)
+{
+ char iline[132];
+
+ fgets (iline, 131, s);
+
+}
+
+/* Read a .b file. */
+int readBFile (FILE *s, unsigned char *data, unsigned maxSize)
+{
+ unsigned char x, y;
+ int byteCount = 0;
+
+ /* Strip the 1st two lines */
+ stripLine (s);
+ stripLine (s);
+
+ for (;;) {
+
+ /* read the 1st ascii char */
+ do {
+ x = fgetc (s);
+ if (x == (unsigned char)EOF)
+ return (byteCount);
+
+ } while (!asciiByte(x));
+
+ /* Read the next ascii char */
+ y = fgetc (s);
+ if (y == (unsigned char)EOF)
+ return (byteCount);
+ if (asciiByte(y))
+ data[byteCount++] = (toNum(x) << 4) | toNum (y);
+
+ if (byteCount >= maxSize) {
+ fprintf (stderr, "Max input array size exceeded\n");
+ return (-1);
+ }
+
+ }
+
+
+}
+
+
+int copyBlock (unsigned char *source, int idx, int maxSize, unsigned char *dest, int count)
+{
+ int i;
+
+ for (i = 0; i < count; i++) {
+ if (idx >= maxSize)
+ break;
+ dest[i] = source[idx++];
+ }
+
+ return (i);
+
+}
+
+void blockCheckSum (unsigned char *block, int blockSize)
+{
+ unsigned checksum = 0;
+ unsigned value;
+ int i;
+
+ if (blockSize & 0x0001) {
+ fprintf (stderr, "program requires an even blocksize\n");
+ exit (-1);
+ }
+
+ for (i = 0; i < blockSize; i += 2) {
+ value = (block[i] << 8) | block[i+1];
+ checksum = onesComplementAdd (checksum, value);
+ }
+
+ /* Put the checksum into the block starting at byte 2. Use big endian */
+ checksum = ~checksum;
+ block[3] = checksum & 0xff;
+ block[2] = (checksum >> 8) & 0xff;
+
+}
+
+#define SIZE 0x10000 /* max array size */
+
+int main (int argc, char *argv[])
+{
+ FILE *strin;
+ FILE *strout;
+
+ unsigned char *dataSet1;
+ unsigned char *dataSet2;
+
+ unsigned char block[128];
+ unsigned blockSize;
+
+ unsigned pIn;
+ unsigned pOut;
+
+ int inSize;
+ int i;
+
+ /* Arg check */
+ if (argc != 3) {
+ fprintf (stderr, "usage: %s infile outfile\n", argv[0]);
+ return (-1);
+ }
+
+ /* Open the input file */
+ strin = fopen (argv[1], "r");
+ if (strin == NULL) {
+ fprintf (stderr, "%s: Could not open file %s for reading\n", argv[0], argv[1]);
+ return (-1);
+ }
+
+ /* Allocate the two data set memories */
+ dataSet1 = malloc (SIZE * sizeof (unsigned char));
+ dataSet2 = malloc (SIZE * sizeof (unsigned char));
+ if ((dataSet1 == NULL) || (dataSet2 == NULL)) {
+ fprintf (stderr, "%s: Malloc failure\n", argv[0]);
+ return (-1);
+ }
+
+ /* Read the data into the byte stream */
+ if ((inSize = readBFile (strin, dataSet1, SIZE)) < 0)
+ return (inSize);
+ fclose (strin);
+
+ /* Perform the i2c block formatting. The block size will be fixed at 128 bytes,
+ * 2 bytes of length, 2 bytes checksum, 124 bytes of data. */
+ pIn = 0;
+ pOut = 0;
+
+ do {
+
+ /* Copy the block, leave 4 bytes at the top */
+ blockSize = copyBlock (dataSet1, pIn, inSize, &block[4], 124);
+ pIn += blockSize; /* advance to next data in source */
+
+ if (blockSize) {
+ blockSize += 4; /* Add room for the header - big endian */
+ block[1] = blockSize & 0xff;
+ block[0] = (blockSize >> 8) & 0xff;
+ block[2] = block[3] = 0;
+
+ /* Checksum the block */
+ blockCheckSum (block, blockSize);
+
+ /* Copy the results to the destination block */
+ if ((pOut + blockSize) >= SIZE) {
+ fprintf (stderr, "%s: destination array size exceeded\n", argv[0]);
+ return (-1);
+ }
+ for (i = 0; i < blockSize; i++)
+ dataSet2[pOut++] = block[i];
+ }
+
+ } while (blockSize == 128);
+
+
+ /* Copy the resulting data set into the output file in ccs format */
+ strout = fopen (argv[2], "w");
+ if (strout == NULL) {
+ fprintf (stderr, "%s: Could not open %s for writing\n", argv[0], argv[2]);
+ return (-1);
+ }
+
+
+ /* Write the two line header */
+ fprintf (strout, "%c\n$A000000\n", (unsigned char)2);
+
+ /* Write out the data */
+ for (i = 0; i < pOut; i++) {
+ if ( ((i+1)%24) )
+ fprintf (strout, "%02X ", dataSet2[i]);
+ else
+ fprintf (strout, "%02X\n", dataSet2[i]);
+ }
+
+ /* Write the close character */
+ fprintf (strout, "\n%c", (unsigned char)3);
+
+ fclose (strout);
+
+ return (0);
+
+}
+
+
+
+
+
+
+
+
diff --git a/src/util/btoccs/bfaddsect.c b/src/util/btoccs/bfaddsect.c
--- /dev/null
@@ -0,0 +1,213 @@
+/* Append a boot table section to the end of a boot table
+ * usage: bfaddsect infile addr byte1 [bytes2 [byte3 [...]]]
+ * The output is to stdout
+ *
+ * All values are taken to be btye values */
+
+
+#include <stdio.h>
+#include <malloc.h>
+
+
+
+int asciiByte (unsigned char c)
+{
+ if ((c >= '0') && (c <= '9'))
+ return (1);
+
+ if ((c >= 'A') && (c <= 'F'))
+ return (1);
+
+ return (0);
+}
+
+int toNum (unsigned char c)
+{
+ if ((c >= '0') && (c <= '9'))
+ return (c - '0');
+
+ return (c - 'A' + 10);
+
+}
+
+
+/* Copy a line from s to stdout */
+void lineCpy (FILE *s)
+{
+ char iline[132];
+
+ fgets (iline, 131, s);
+ fputs (iline, stdout);
+
+}
+
+/* Read a .b file. */
+int readBFile (FILE *s, unsigned char *data, unsigned maxSize)
+{
+ unsigned char x, y;
+ int byteCount = 0;
+
+ for (;;) {
+
+ /* read the 1st ascii char */
+ do {
+ x = fgetc (s);
+ if (x == (unsigned char)EOF)
+ return (byteCount);
+
+ } while (!asciiByte(x));
+
+ /* Read the next ascii char */
+ y = fgetc (s);
+ if (y == (unsigned char)EOF)
+ return (byteCount);
+ if (asciiByte(y))
+ data[byteCount++] = (toNum(x) << 4) | toNum (y);
+
+ if (byteCount >= maxSize) {
+ fprintf (stderr, "Max input array size exceeded\n");
+ return (-1);
+ }
+
+ }
+
+}
+
+unsigned dwordConvert (unsigned char *data)
+{
+ unsigned value;
+ unsigned char c[4];
+ int i;
+
+ c[0] = c[1] = c[2] = c[3] = 0;
+
+ for (i = 0; i < 4; i++) {
+ c[i] = data[i];
+ }
+
+ value = c[3] | (c[2] << 8) | (c[1] << 16) | (c[0] << 24);
+
+ return (value);
+
+}
+
+#define SIZE 0x100000 /* max number of bytes in the array */
+#define MAX_BYTES 64 /* max size of the boot table */
+
+int main (int argc, char *argv[])
+{
+ FILE *strin;
+ unsigned char *dataSet;
+ unsigned int addr;
+ unsigned int secsize;
+ unsigned char newchars[MAX_BYTES];
+ int i;
+ int nbytes;
+ int asize;
+ int p;
+
+
+ /* get the args */
+ if (argc < 4) {
+ fprintf (stderr, "usage: %s infile hex_addr byte1 [byte2 [byte3 [ ...byte64]]]\n", argv[0]);
+ return (-1);
+ }
+
+ /* input file */
+ strin = fopen (argv[1], "r");
+ if (strin == NULL) {
+ fprintf (stderr, "%s: Could not open file %s\n", argv[0], argv[1]);
+ return (-1);
+ }
+
+ /* Address */
+ sscanf (argv[2], "%x", &addr);
+
+ /* Number of bytes */
+ nbytes = argc - 3;
+ for (i = 0; i < nbytes; i++)
+ sscanf (argv[i+3], "%x", &newchars[i]);
+
+
+ /* Allocate memory for the data set */
+ dataSet = malloc (SIZE * sizeof (unsigned char));
+ if (dataSet == NULL) {
+ fprintf (stderr, "%s: malloc failure\n", argv[0]);
+ return (-1);
+ }
+
+ /* Copy the first two lines of the input file to stdout */
+ lineCpy (strin);
+ lineCpy (strin);
+
+ /* Read the data into the byte stream */
+ asize = readBFile (strin, dataSet, SIZE);
+ fclose (strin);
+
+ /* Parse the input file. Prepend the new section at the end */
+
+ /* Just skip the entry address */
+ p = 4;
+
+ do {
+ secsize = dwordConvert (&dataSet[p]);
+ secsize = (secsize + 3) & 0xfffffffc; /* segment pad */
+ p = p + secsize + 8; /* 4 bytes length, 4 bytes address */
+ } while (secsize);
+
+ /* back up to the zero section size */
+ p = p - 8;
+
+ /* p now points to the 0 length entry. Put the new data here */
+ /* The section size */
+ dataSet[p++] = (nbytes >> 24) & 0xff;
+ dataSet[p++] = (nbytes >> 16) & 0xff;
+ dataSet[p++] = (nbytes >> 8) & 0xff;
+ dataSet[p++] = (nbytes >> 0) & 0xff;
+
+ /* Put the section address */
+ dataSet[p++] = (addr >> 24) & 0xff;
+ dataSet[p++] = (addr >> 16) & 0xff;
+ dataSet[p++] = (addr >> 8) & 0xff;
+ dataSet[p++] = (addr >> 0) & 0xff;
+
+ /* Put the data */
+ for (i = 0; i < nbytes; i++)
+ dataSet[p++] = newchars[i];
+
+ while (p % 4)
+ dataSet[p++] = 0;
+
+ /* Add the 0 length section */
+ for (i = 0; i < 4; i++)
+ dataSet[p++] = 0;
+
+
+ /* Write out the data */
+ for (i = 0; i < p; i++) {
+ fprintf (stdout, "%02X", dataSet[i]);
+
+ if ( ((i+1) % 24) )
+ fprintf (stdout, " ");
+ else
+ fprintf (stdout, "\n");
+
+ }
+
+ /* Write the trailing character */
+ fprintf (stdout, "\n%c",3);
+
+ free (dataSet);
+
+ return (0);
+
+}
+
+
+
+
+
+
+
+
+
diff --git a/src/util/btoccs/bfmerge.c b/src/util/btoccs/bfmerge.c
--- /dev/null
@@ -0,0 +1,228 @@
+/* Combine two boot tables.
+ * usage bfmerge file1 file2 [file3 [file4 [...]]]
+ * The output is to stdout
+ *
+ * */
+
+#include <stdio.h>
+#include <malloc.h>
+
+int asciiByte (unsigned char c)
+{
+ if ((c >= '0') && (c <= '9'))
+ return (1);
+
+ if ((c >= 'A') && (c <= 'F'))
+ return (1);
+
+ return (0);
+}
+
+int toNum (unsigned char c)
+{
+ if ((c >= '0') && (c <= '9'))
+ return (c - '0');
+
+ return (c - 'A' + 10);
+
+}
+
+
+/* Copy a line from s to stdout */
+void lineCpy (FILE *s)
+{
+ char iline[132];
+
+ fgets (iline, 131, s);
+ fputs (iline, stdout);
+
+}
+
+/* Toss a line */
+void lineToss (FILE *s)
+{
+ char iline[132];
+
+ fgets (iline, 131, s);
+
+}
+
+/* Read a .b file. */
+int readBFile (FILE *s, unsigned char *data, unsigned maxSize)
+{
+ unsigned char x, y;
+ int byteCount = 0;
+
+ for (;;) {
+
+ /* read the 1st ascii char */
+ do {
+ x = fgetc (s);
+ if (x == (unsigned char)EOF)
+ return (byteCount);
+
+ } while (!asciiByte(x));
+
+ /* Read the next ascii char */
+ y = fgetc (s);
+ if (y == (unsigned char)EOF)
+ return (byteCount);
+ if (asciiByte(y))
+ data[byteCount++] = (toNum(x) << 4) | toNum (y);
+
+ if (byteCount >= maxSize) {
+ fprintf (stderr, "Max input array size exceeded\n");
+ return (-1);
+ }
+
+ }
+
+}
+
+unsigned dwordConvert (unsigned char *data)
+{
+ unsigned value;
+ unsigned char c[4];
+ int i;
+
+ c[0] = c[1] = c[2] = c[3] = 0;
+
+ for (i = 0; i < 4; i++) {
+ c[i] = data[i];
+ }
+
+ value = c[3] | (c[2] << 8) | (c[1] << 16) | (c[0] << 24);
+
+ return (value);
+
+}
+
+
+int bparse (unsigned char *dataSet, int l)
+{
+ unsigned int secsize;
+
+ do {
+
+ secsize = dwordConvert (&dataSet[l]);
+ secsize = (secsize + 3) & 0xfffffffc; /* segment pad */
+ l = l + secsize + 8; /* 4 bytes length, 4 bytes address */
+
+ } while (secsize);
+
+ /* Back up to the zero section size */
+ l = l - 8;
+
+ return (l);
+
+}
+
+
+#define SIZE 1000000
+#define APPEND 100000
+
+int main (int argc, char *argv[])
+{
+ FILE *strin;
+ unsigned char *dataSet;
+ unsigned char *appSet;
+ unsigned int addr;
+ unsigned int secsize;
+ int asize;
+ int i, j;
+ int nbytes;
+ int p;
+
+ /* Must have at least two input files */
+ if (argc < 3) {
+ fprintf (stderr, "usage: %s file1 file2 [file3 [file4 [...]]]\n", argv[0]);
+ return (-1);
+ }
+
+ /* Allocate memory for the data set */
+ dataSet = malloc (SIZE * sizeof (unsigned char));
+ if (dataSet == NULL) {
+ fprintf (stderr, "%s: malloc failure\n", argv[0]);
+ return (-1);
+ }
+
+ appSet = malloc (APPEND * sizeof (unsigned char ));
+ if (appSet == NULL) {
+ fprintf (stderr, "%s malloc failure\n", argv[0]);
+ return (-1);
+ }
+
+
+ /* The first data file is handled seperately */
+ strin = fopen (argv[1], "r");
+ if (strin == NULL) {
+ fprintf (stderr, "%s: Could not open file %s\n", argv[0], argv[1]);
+ free (dataSet);
+ return (-1);
+ }
+
+ /* Copy the first two lines of the input file to stdout */
+ lineCpy (strin);
+ lineCpy (strin);
+
+ /* Read in the first data set */
+ asize = readBFile (strin, dataSet, SIZE);
+ fclose (strin);
+
+ /* Parse the file, skipping the entry symbol */
+ p = 4;
+ p = bparse (dataSet, p);
+
+
+ /* Add the remaining data sets */
+
+ for (i = 2; i < argc; i++) {
+
+ strin = fopen (argv[i], "r");
+ if (strin == NULL) {
+ fprintf (stderr, "%s: Could not open file %s\n", argv[0], argv[i]);
+ free (dataSet);
+ return (-1);
+ }
+
+ /* Toss the first two lines */
+ lineToss (strin);
+ lineToss (strin);
+
+ asize = readBFile (strin, appSet, APPEND);
+ fclose (strin);
+
+ /* Append the new data set, skip the 4 bytes of entry symbol */
+ for (j = 0; j < asize-4; j++)
+ dataSet[p+j] = appSet[j+4];
+
+ /* reparse from the current point */
+ p = bparse (dataSet, p);
+
+ }
+
+ /* Add the 0 section size */
+ for (i = 0; i < 4; i++)
+ dataSet[p++] = 0;
+
+
+ /* Write out the data */
+ for (i = 0; i < p; i++) {
+ fprintf (stdout, "%02X", dataSet[i]);
+
+ if ( ((i+1) % 24) )
+ fprintf (stdout, " ");
+ else
+ fprintf (stdout, "\n");
+
+ }
+
+ /* Write the trailing character */
+ fprintf (stdout, "\n%c",3);
+
+ free (dataSet);
+
+ return (0);
+
+}
+
diff --git a/src/util/btoccs/ccs2b.c b/src/util/btoccs/ccs2b.c
--- /dev/null
+++ b/src/util/btoccs/ccs2b.c
@@ -0,0 +1,69 @@
+#include <stdio.h>
+
+/* Program to convert a ccs file to a b format file. */
+
+
+int main (int argc, char *argv[])
+{
+ FILE *strin;
+ FILE *strout;
+ int a, b, c, d, i;
+ int nwords;
+ char iline[132];
+
+ if (argc != 3) {
+ fprintf (stderr, "usage: %s infile outfile\n", argv[0]);
+ return (-1);
+ }
+
+ strin = fopen (argv[1], "r");
+ if (strin == NULL) {
+ fprintf (stderr, "%s: could not open input file %s\n", argv[0], argv[1]);
+ return (-1);
+ }
+
+ strout = fopen (argv[2], "w");
+ if (strout == NULL) {
+ fprintf (stderr, "%s: could not open output file %s\n", argv[0], argv[2]);
+ fclose (strin);
+ return (-1);
+ }
+
+ fgets (iline, 132, strin);
+ sscanf (iline, "%x %x %x %x %x", &a, &b, &c, &d, &nwords);
+
+
+ fprintf (strout, "%c\n$A0000,\n",2);
+
+ for (i = 0; i < nwords; i++) {
+
+ fgets (iline, 132, strin);
+ iline[1] = '0';
+ sscanf (iline, "%x", &a);
+ fprintf (strout, "%02X %02X %02X %02X", (a>>24) & 0x00ff, (a>>16) & 0xff, (a>>8) & 0xff,
+ a & 0xff);
+
+ if ( ((i+1) % 6) )
+ fprintf (strout, " ");
+ else
+ fprintf (strout, "\n");
+
+ }
+
+ fprintf (strout, "\n%c",3);
+
+ fclose (strin);
+ fclose (strout);
+
+ return (0);
+
+}
+
+
+
+
+
+
+
+
+
diff --git a/src/util/i2cConfig/Makefile b/src/util/i2cConfig/Makefile
--- /dev/null
@@ -0,0 +1,33 @@
+#**************************************************************
+#* FILE PURPOSE: Top level make for the i2c parameter writer
+#**************************************************************
+#* FILE NAME: Makefile
+#*
+#* DESCRIPTION: Builds the program to write the parameter table
+#* to the i2c rom
+#*
+#***************************************************************
+
+DEVICES= c6472
+
+all:
+ @echo must specify a target [ $(DEVICES) ]
+
+# Default options that can be overwridden on the command line
+ifndef ENDIAN
+ ENDIAN= little
+endif
+
+export ENDIAN
+
+$(DEVICES):
+ make -f makestg2 ARCH=c64x TARGET=$@ $@
+
+
+clean:
+ make -f makestg2 clean2 ARCH=c64x
+
+
+
+
+
diff --git a/src/util/i2cConfig/i2cparam.c b/src/util/i2cConfig/i2cparam.c
--- /dev/null
@@ -0,0 +1,273 @@
+/*************************************************************************************
+ * FILE PURPOSE: Write the ibl configuration table to the i2c eeprom
+ *************************************************************************************
+ * @file i2cparam.c
+ *
+ * @brief
+ * Creates the ibl configuration table and writes to the i2c
+ *
+ *************************************************************************************/
+
+#include "types.h"
+#include "ibl.h"
+#include "i2c.h"
+#include "pllapi.h"
+#include "iblcfg.h"
+#include "target.h"
+#include "string.h"
+#include <stdlib.h>
+#include <stdio.h>
+
+ibl_t ibl;
+
+#define SETIP(array,i0,i1,i2,i3) array[0]=(i0); \
+ array[1]=(i1); \
+ array[2]=(i2); \
+ array[3]=(i3)
+
+/**
+ * @brief The desired ibl configuration is setup here. Edit the fields
+ * to match the desired setup.
+ */
+void setupTable (void)
+{
+
+ /* Initialize the table */
+ memset (&ibl, 0, sizeof (ibl_t));
+
+ ibl.iblMagic = ibl_MAGIC_VALUE;
+
+ ibl.pllConfig[ibl_MAIN_PLL].doEnable = TRUE;
+ ibl.pllConfig[ibl_MAIN_PLL].prediv = 1;
+ ibl.pllConfig[ibl_MAIN_PLL].mult = 25;
+ ibl.pllConfig[ibl_MAIN_PLL].postdiv = 1;
+ ibl.pllConfig[ibl_MAIN_PLL].pllOutFreqMhz = 625;
+
+ /* The DDR PLL. The multipliers/dividers are fixed, so are really dont cares */
+ ibl.pllConfig[ibl_DDR_PLL].doEnable = TRUE;
+
+ /* The network PLL. The multipliers/dividers are fixed */
+ ibl.pllConfig[ibl_NET_PLL].doEnable = TRUE;
+
+ /* EMIF configuration. The values are for DDR at 533 MHz */
+ ibl.ddrConfig.configDdr = TRUE;
+
+ ibl.ddrConfig.uEmif.emif3p1.sdcfg = 0x00538832; /* timing, 32bit wide */
+ ibl.ddrConfig.uEmif.emif3p1.sdrfc = 0x0000073B; /* Refresh 533Mhz */
+ ibl.ddrConfig.uEmif.emif3p1.sdtim1 = 0x47245BD2; /* Timing 1 */
+ ibl.ddrConfig.uEmif.emif3p1.sdtim2 = 0x0125DC44; /* Timing 2 */
+ ibl.ddrConfig.uEmif.emif3p1.dmcctl = 0x50001906; /* PHY read latency for CAS 5 is 5 + 2 - 1 */
+
+ /* Ethernet configuration for port 0 */
+ ibl.ethConfig[0].ethPriority = ibl_HIGHEST_PRIORITY;
+ ibl.ethConfig[0].port = 0;
+
+ /* Bootp is disabled. The server and file name are provided here */
+ ibl.ethConfig[0].doBootp = FALSE;
+ ibl.ethConfig[0].useBootpServerIp = FALSE;
+ ibl.ethConfig[0].useBootpFileName = FALSE;
+ ibl.ethConfig[0].bootFormat = ibl_BOOT_FORMAT_BBLOB;
+
+ SETIP(ibl.ethConfig[0].ethInfo.ipAddr, 10,218,109,21);
+ SETIP(ibl.ethConfig[0].ethInfo.serverIp, 10,218,109,196);
+ SETIP(ibl.ethConfig[0].ethInfo.gatewayIp, 10,218,109,1);
+ SETIP(ibl.ethConfig[0].ethInfo.netmask, 255,255,255,0);
+
+ /* Leave the hardware address as 0 so the e-fuse value will be used */
+
+ strcpy (ibl.ethConfig[0].ethInfo.fileName, "test.blob");
+
+ /* Even though the entire range of DDR2 is chosen, the load will
+ * stop when the ftp reaches the end of the file */
+ ibl.ethConfig[0].blob.startAddress = 0xe0000000; /* Base address of DDR2 */
+ ibl.ethConfig[0].blob.sizeBytes = 0x20000000; /* All of DDR2 */
+ ibl.ethConfig[0].blob.branchAddress = 0xe0000000; /* Base of DDR2 */
+
+ /* For port 1 use bootp */
+ /* Ethernet configuration for port 0 */
+ ibl.ethConfig[1].ethPriority = ibl_HIGHEST_PRIORITY + 1;
+ ibl.ethConfig[1].port = 1;
+
+ /* Bootp is disabled. The server and file name are provided here */
+ ibl.ethConfig[1].doBootp = TRUE;
+ ibl.ethConfig[1].useBootpServerIp = TRUE;
+ ibl.ethConfig[1].useBootpFileName = TRUE;
+ ibl.ethConfig[1].bootFormat = ibl_BOOT_FORMAT_BBLOB;
+
+
+ /* Leave the hardware address as 0 so the e-fuse value will be used */
+ /* Leave all remaining fields as 0 since bootp will fill them in */
+
+
+ /* Even though the entire range of DDR2 is chosen, the load will
+ * stop when the ftp reaches the end of the file */
+ ibl.ethConfig[1].blob.startAddress = 0xe0000000; /* Base address of DDR2 */
+ ibl.ethConfig[1].blob.sizeBytes = 0x20000000; /* All of DDR2 */
+ ibl.ethConfig[1].blob.branchAddress = 0xe0000000; /* Base of DDR2 */
+
+
+
+ /* MDIO configuration */
+ ibl.mdioConfig.nMdioOps = 8;
+ ibl.mdioConfig.mdioClkDiv = 0x20;
+ ibl.mdioConfig.interDelay = 1400; /* ~2ms at 700 MHz */
+
+ ibl.mdioConfig.mdio[0] = (1 << 30) | (27 << 21) | (24 << 16) | 0x848b;
+ ibl.mdioConfig.mdio[1] = (1 << 30) | (20 << 21) | (24 << 16) | 0x0ce0;
+ ibl.mdioConfig.mdio[2] = (1 << 30) | (24 << 21) | (24 << 16) | 0x4101;
+ ibl.mdioConfig.mdio[3] = (1 << 30) | ( 0 << 21) | (24 << 16) | 0x9140;
+
+ ibl.mdioConfig.mdio[4] = (1 << 30) | (27 << 21) | (25 << 16) | 0x848b;
+ ibl.mdioConfig.mdio[5] = (1 << 30) | (20 << 21) | (25 << 16) | 0x0ce0;
+ ibl.mdioConfig.mdio[6] = (1 << 30) | (24 << 21) | (25 << 16) | 0x4101;
+ ibl.mdioConfig.mdio[7] = (1 << 30) | ( 0 << 21) | (25 << 16) | 0x9140;
+
+
+ /* Nand boot is disabled */
+ ibl.nandConfig.nandPriority = ibl_DEVICE_NOBOOT;
+
+}
+
+
+/**
+ * @brief
+ * Display the error returned by the i2c driver
+ */
+void showI2cError (I2C_RET iret, char *stage)
+{
+ char *ecode;
+
+ switch (iret) {
+ case I2C_RET_LOST_ARB: ecode = "I2C master lost an arbitration battle";
+ break;
+
+ case I2C_RET_NO_ACK: ecode = "I2C master detected no ack from slave";
+ break;
+
+ case I2C_RET_IDLE_TIMEOUT: ecode = "I2C timed out";
+ break;
+
+ case I2C_RET_BAD_REQUEST: ecode = "I2C driver detected a bad data request";
+ break;
+
+ case I2C_RET_CLOCK_STUCK_LOW: ecode = "I2C driver found the bus stuck low";
+ break;
+
+ case I2C_RET_GEN_ERROR: ecode = "I2C driver reported a general error";
+ break;
+
+ }
+
+ printf ("Error: %s, reported at stage: %s\n", ecode, stage);
+
+}
+
+/**
+ * @brief
+ * Group the data into a 64 byte (max) data block aligned on a 64 byte boundary
+ */
+Int32 formBlock (UINT8 *base, Int32 dataSize, Int32 *offset, Uint8 *data, Uint32 baseI2cDataAddr)
+{
+ Uint32 currentAddress;
+ Int32 nbytes;
+ Int32 i;
+
+ /* The I2C eeprom address is the parameter base address plus the current offset
+ * The number of bytes is blocked to end on a 64 byte boundary */
+ currentAddress = baseI2cDataAddr + *offset;
+ nbytes = 64 - (currentAddress & (64 - 1));
+
+ /* Only write the bytes in the input array */
+ if (*offset + nbytes > dataSize)
+ nbytes = dataSize - *offset;
+
+ if (nbytes == 0)
+ return (0);
+
+ /* The address is placed first */
+ data[0] = (currentAddress >> 8) & 0xff;
+ data[1] = (currentAddress >> 0) & 0xff;
+
+ /* The data */
+ for (i = 0; i < nbytes; i++)
+ data[i+2] = base[*offset + i];
+
+ /* Update the offset */
+ *offset += nbytes;
+
+ /* Return the total number of bytes (including address) to go on the bus */
+ return (nbytes + 2);
+
+}
+
+
+
+void main (void)
+{
+ I2C_RET iret;
+ UINT8 writeBlock[66];
+ char iline[132];
+ Int32 n;
+ Int32 currentOffset;
+
+ volatile Int32 i;
+
+
+ /* Program the main system PLL */
+ hwPllSetPll (MAIN_PLL,
+ 1, /* Pre-divider */
+ IBL_I2C_DEV_FREQ_MHZ / 25, /* Multiplier */
+ 1); /* Post-divider */
+
+ setupTable();
+
+ hwI2Cinit (IBL_I2C_DEV_FREQ_MHZ, /* The CPU frequency during I2C data load */
+ DEVICE_I2C_MODULE_DIVISOR, /* The divide down of CPU that drives the i2c */
+ IBL_I2C_CLK_FREQ_KHZ/8, /* The I2C data rate used during table load. Slowed for writes */
+ IBL_I2C_OWN_ADDR); /* The address used by this device on the i2c bus */
+
+
+ /* Block the data into 64 byte blocks aligned on 64 byte boundaries for the data write.
+ * The block address is prepended to the data block before writing */
+ currentOffset = 0;
+ do {
+
+ n = formBlock ((UINT8 *)&ibl, sizeof(ibl_t), ¤tOffset, writeBlock, IBL_I2C_CFG_TABLE_DATA_ADDR);
+
+ if (n > 0) {
+
+ iret = hwI2cMasterWrite (IBL_I2C_CFG_EEPROM_BUS_ADDR, /* The I2C bus address of the eeprom */
+ writeBlock, /* The data to write */
+ n, /* The number of bytes to write */
+ I2C_RELEASE_BUS, /* Release the bus when the write is done */
+ FALSE ); /* Bus is not owned at start of operation */
+
+ if (iret != I2C_RET_OK) {
+ sprintf (iline, "Block at offset %d\n", currentOffset);
+ showI2cError (iret, iline);
+ return;
+ }
+
+ /* Need some delay to allow the programming to occur */
+ for (i = 0; i < 600000; i++);
+
+ }
+
+ } while (n > 0);
+
+
+
+ printf ("I2c table write complete\n");
+
+}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/util/i2cConfig/i2cparam_c6472.cmd b/src/util/i2cConfig/i2cparam_c6472.cmd
--- /dev/null
@@ -0,0 +1,37 @@
+/*************************************************************************
+ * @file i2cparam_c6472.cmd
+ *
+ * @brief Places the i2c parameter writer program into memory
+ *
+ *************************************************************************/
+
+i2cparam.oc
+../../hw/c64x/make/i2c.oc
+../../hw/c64x/make/pll.oc
+
+-c
+-a
+-stack 0x400
+
+MEMORY
+{
+ STACK : origin = 0x810000 length = 0x0400
+ TEXT : origin = 0x810400 length = 0x8000
+ DATA : origin = 0x818400 length = 0x0800
+}
+
+SECTIONS
+{
+ .stack > STACK
+
+ .text > TEXT
+ .const > TEXT
+ .switch > TEXT
+ .cinit > TEXT
+
+ .far > DATA
+ .bss > DATA
+ .data > DATA
+
+}
+
\ No newline at end of file
diff --git a/src/util/i2cConfig/makestg2 b/src/util/i2cConfig/makestg2
--- /dev/null
@@ -0,0 +1,70 @@
+#**************************************************************************
+#* FILE PURPOSE: 2nd stage makefile for the i2c parameter writer
+#**************************************************************************
+#* FILE NAME: makestg2
+#*
+#* DESCRIPTION: Builds the i2c parameter writer for a specific target
+#*
+#**************************************************************************
+
+ifndef IBL_ROOT
+ IBL_ROOT=../..
+endif
+
+ECODIR= $(IBL_ROOT)/util/i2cConfig
+
+MODULES= hw
+CLEAN_MODULES=$(addprefix clean_,$(MODULES))
+
+
+CSRC= i2cparam.c
+
+include $(IBL_ROOT)/make/$(ARCH)/makeeco.mk
+
+C6X_C_DIR= $(IBL_ROOT)
+C6X_C_DIR+=;$(IBL_ROOT)/hw/i2c
+C6X_C_DIR+=;$(IBL_ROOT)/hw/plls
+C6X_C_DIR+=;$(STDINC)
+C6X_C_DIR+=;$(IBL_ROOT)/cfg/$(TARGET)
+C6X_C_DIR+=;$(IBL_ROOT)/device/$(TARGET)
+C6X_C_DIR+=;$(IBL_ROOT)/arch/$(ARCH)
+export C6X_C_DIR
+
+
+export ARCH
+export TARGET
+
+
+.PHONY: i2cparam.cmd
+
+c6472: gen_cdefdep $(MODULES) $(OBJS) i2cparam_$(TARGET).cmd
+ $(LD) -o i2cparam_$(TARGET).out -m i2cparam_$(TARGET).map i2cparam_$(TARGET).cmd $(RTLIBS)
+
+$(MODULES):
+ @echo making $@
+ make -C $(IBL_ROOT)/$@/$(ARCH)/make $@
+
+
+clean2: $(CLEAN_MODULES)
+ @rm -f $(OBJS)
+
+
+$(CLEAN_MODULES):
+ @echo cleaning $(subst clean_, ,$@)
+ make -C $(IBL_ROOT)/$(subst clean_,,$@)/$(ARCH)/make clean
+
+
+$(OBJS): cdefdep
+
+
+gen_cdefdep:
+ @echo Checking command line dependencies
+ @echo $(ENDIAN) $(TARGET) $(ARCH) > cdefdep.tmp
+ @sh -c 'if diff -q cdefdep.tmp cdefdep ; then echo same ; else $(CP) cdefdep.tmp cdefdep ; fi '
+
+
+
+
+
+
+
diff --git a/src/util/nandwriter/nandwriter.c b/src/util/nandwriter/nandwriter.c
--- /dev/null
@@ -0,0 +1,297 @@
+/**************************************************************************************
+ * FILE PURPOSE: NAND writer for the IBL
+ **************************************************************************************
+ * FILE NAME: nandwriter.c
+ *
+ * DESCRIPTION: A simple nand writer used to program the flash with an image
+ * that the ibl can read.
+ *
+ * @file nandwriter.c
+ *
+ * @brief
+ * A simple nand writer
+ *
+ ***************************************************************************************/
+#include "types.h"
+#include "ibl.h"
+#include <stdlib.h>
+
+/**
+ * @brief
+ * NAND device configuration. This structure should be filled in
+ * by the user before running
+ */
+typedef struct nandWriterInfo_s
+{
+ uint32 busWidthBits; /**< 8 or 16 bit bus width */
+ uint32 pageSizeBytes; /**< The size of each page */
+ uint32 pageEccBytes; /**< Number of ecc bytes in each page */
+ uint32 pagesPerBlock; /**< The number of pages in each block */
+ uint32 totalBlocks; /**< The total number of blocks in a device */
+
+ uint32 addressBytes; /**< Number of bytes in the address */
+ bool lsbFirst; /**< Set to true if the LSB is output first, otherwise msb is first */
+ uint32 blockOffset; /**< Address bits which specify the block number */
+ uint32 pageOffset; /**< Address bits which specify the page number */
+ uint32 columnOffset; /**< Address bits which specify the column number */
+
+ uint8 resetCommand; /**< The command to reset the flash */
+ uint8 readCommandPre; /**< The read command sent before the address */
+ uint8 readCommandPost; /**< The read command sent after the address */
+ bool postCommand; /**< If TRUE the post command is sent */
+
+ uint8 blockEraseCommandPre; /**< The command used to erase a block (sent before the address) */
+ uint8 blockEraseCommandPost; /**< The command used to erase a block (sent after the address) */
+ bool blockErasePost; /**< If TRUE the post command is sent */
+
+ uint8 pageWriteCommandPre; /**< The command used to program a page (sent before the address) */
+ uint8 pageWriteCommandPost; /**< The command used to program a page (sent after the address) */
+ bool pageWritePost; /**< If TRUE the post command is sent */
+
+ char fileName[132]; /**< The name of the file to burn on the flash */
+
+} nandWriterInfo_t;
+
+
+nandWriterInfo_t nandWriterInfo;
+
+
+
+/**
+ * @brief
+ * The nandDevInfo structure is a subset of the nandWriteInfo, and is seperated
+ * here to use the existing ibl functions for the writer
+ */
+nandDevInfo_t devInfo;
+
+
+int main (void)
+{
+ Uint8 *data;
+ FILE *fp;
+ Uint32 flen;
+ Int32 ret;
+
+
+ /* Prompt the user to initialize the data block */
+ printf ("Initialize the nandWriteInfo structure, press return\n");
+ getchar ();
+
+
+ /* Initialize the nand driver */
+ devInfo.busWidthBits = nandWriterInfo.busWidthBits;
+ devInfo.pageSizeBytes = nandWriterInfo.pageSizeBytes;
+ devInfo.pageEccBytes = nandWriterInfo.pageEccBytes;
+ devInfo.pagesPerBlock = nandWriterInfo.pagesPerBlock;
+ devInfo.totalBlocks = nandWriterInfo.totalBlocks;
+
+ devInfo.addressBytes = nandWriterInfo.addressBytes;
+ devInfo.lsbFirst = nandWriterInfo.lsbFirst;
+ devInfo.blockOffset = nandWriterInfo.blockOffset;
+ devInfo.pageOffset = nandWriterInfo.pageOffset;
+ devInfo.columnOffset = nandWriterInfo.columnOffset;
+
+ devInfo.resetCommand = nandWriterInfo.resetCommand;
+ devInfo.readCommandPre = nandWriterInfo.readCommandPre;
+ devInfo.readCommandPost = nandWriterInfo.readCommandPost;
+ devInfo.postCommand = nandWriterInfo.postCommand;
+
+
+
+ /* Open and find the length of the data file */
+ fp = fopen (nandWriterInfo.fileName, "rb");
+ if (fp == NULL) {
+ printf ("Failed to open file %s\n", nandWriterInfo.fileName);
+ return (-1);
+ }
+
+ fseek (fp, 0l, SEEK_END);
+ flen = ftel (fp);
+ fseek (fp, 0l, SEEK_SET);
+
+ data = malloc ((nandWriterInfo.pageSizeBytes + nandWriterInfo.pageEccBytes) * sizeof (Uint8));
+ if (data == NULL) {
+ printf ("Malloc failed on size of %d bytes\n", nandWriterInfo.pageSizeBytes + nandWriterInfo.pageEccBytes);
+ fclose (fp);
+ return (-1);
+ }
+
+ /* Initialize the programming interface */
+ ret = nandHwDriverInit (&devInfo);
+ if (ret != 0) {
+ printf ("nandHwDriverInit failed with error code %d\n", ret);
+ free (data);
+ fclose (fp);
+ return (-1);
+ }
+
+ /* Write the flash, verify the results. On read back failure mark
+ * the page as bad and try rewriting again */
+ do {
+
+ flashNand (fp, flen, data);
+
+ } while (flashVerify (fp, flen, data) == FALSE);
+
+
+ free (data);
+ fclose (fp);
+ return (0);
+
+}
+
+
+
+void flashNand (FILE *fp, Uint32 flen, Uint8 *data)
+{
+ Uint32 fpos;
+ Uint32 rlen;
+ Int32 ret;
+ Int32 i;
+
+ Int32 eccsPerPage;
+ Uint8 *eccData; /* Points to the 256 bytes of data to compute the ecc */
+ Uint8 *eccBytes; /* Points to the generated ECC data */
+
+ /* Reset to the start of the data file */
+ fseek (fp, 0l, SEEK_SET);
+
+ /* The ECC size is fixed at 256 bytes */
+ eccsPerPage = nandWriterInfo.pageSizeBytes >> 8;
+
+
+ /* Program the NAND */
+ for (block = -1, page = nandWriterInfo.pagesPerBlock, fpos = 0; fpos < flen; fpos += nandWriterInfo.pageSizeBytes) {
+
+ /* Advance over a block boundary. Verify block limit and bad block mark */
+ if (++page >= nandWriterInfo.pagesPerBlock) {
+
+ do {
+
+ block += 1;
+
+ } while ((block < nandWriterInfo.totalBlocks) && (checkBadBlockMark (block) == TRUE));
+
+ page = 0;
+ }
+
+ /* Initialize the entire page (with ecc bytes) to 0xff. This will preserve the good block
+ * mark at the beginning of pages 0 and 1 */
+ memset (data, 0xff, ((nandWriterInfo.pageSizeBytes + nandWriterInfo.eccSizeBytes) * sizeof (Uint8));
+
+
+ /* Read the data from the file */
+ rlen = nandWriterInfo.pageSizeBytes
+ if (flen - fpos < nandWriterInfo.pageSizeBytes) {
+ rlen = flen - fpos;
+ }
+
+ if (fread (data, sizeof (Uint8), rlen, fp) == 0) {
+ printf ("fread unexpectedly returned 0 on read of %d bytes staring at byte location %d.\n", rlen, fpos);
+ printf (" Total file length = %d bytes\n", flen);
+ free (data);
+ fclose (fp);
+ return (-1);
+ }
+
+ /* Compute the ECCs. The ECC location size varies by the ECC algorithm */
+ for (i = 0; i < eccsPerPage; i++) {
+
+ eccData = &data[i*256];
+ eccBytes = &data[nandWriterInfo.pageSizeBytes + nandWriterInfo.pageEccBytes - ((eccsPerPage - i) * NUM_ECC_BYTES_PER_PAGE)];
+ eccComputeECC (eccData, eccBytes);
+
+ }
+
+ ret = nandHwWritePage (block, page, data);
+ if (ret < 0) {
+ printf ("nandHwWritePage returned error code %d writing block %d, page %d\n", ret, block, page);
+ free (data);
+ fclose (fp);
+ return (-1);
+ }
+
+ }
+
+}
+
+
+/**
+ * @brief
+ * Read back the data file that was just flashed. On errors mark the block as bad.
+ * Returns TRUE if the image verified correctly.
+ * FALSE if the image verification failed
+ */
+
+BOOL flashVerify (FILE *fp, Uint32 flen, Uint8 *data)
+{
+ Uint8 *nandData;
+
+
+ nandData = malloc ((nandWriterInfo.pageSizeBytes + nandWriterInfo.pageEccBytes) * sizeof (Uint8));
+ if (nandData == NULL) {
+ printf ("Malloc failed on verification data block of %d bytes\n", nandWriterInfo.pageSizeBytes + nandWriterInfo.pageEccBytes);
+ return (TRUE); /* return true so the program gives up */
+ }
+
+
+ /* Reset to the start of the data file */
+ fseek (fp, 0l, SEEK_SET);
+
+
+ for (block = -1, page = nandWriterInfo.pagesPerBlock, fpos = 0; fpos < flen; fpos += nandWriterInfo.pageSizeBytes) {
+
+ /* Advance over a block boundary. Verify block limit and bad block mark */
+ if (++page >= nandWriterInfo.pagesPerBlock) {
+
+ do {
+
+ block += 1;
+
+ } while ((block < nandWriterInfo.totalBlocks) && (checkBadBlockMark (block) == TRUE));
+
+ page = 0;
+ }
+
+
+ /* Read a page of data */
+ ret = nandHwDriverReadPage (block, page, nandData);
+ if (ret < 0) {
+ printf ("nandHwDriverReadPage returned error cod %d\n", ret);
+ free (nandData);
+ return (TRUE); /* return TRUE to allow the program to exit */
+ }
+
+ /* Read the data from the file */
+ rlen = nandWriterInfo.pageSizeBytes
+ if (flen - fpos < nandWriterInfo.pageSizeBytes) {
+ rlen = flen - fpos;
+ }
+
+ if (fread (data, sizeof (Uint8), rlen, fp) == 0) {
+ printf ("fread unexpectedly returned 0 on read of %d bytes staring at byte location %d.\n", rlen, fpos);
+ printf (" Total file length = %d bytes\n", flen);
+ free (nandData);
+ return (TRUE);
+ }
+
+ if (memcmp (data, nandData, nandWriterInfo.pageSizeBytes) {
+ printf ("Data verification failed on block %d, page %d, file position %d, file size %d\n", block, page, fpos, flen);
+ printf ("Marking the block as bad and retrying the flash\n");
+ free (nandData);
+ return (FALSE);
+ }
+
+ }
+
+}
+
+
+
+
+
+
+
+
+
+
diff --git a/src/util/romparse_c6472/Makefile b/src/util/romparse_c6472/Makefile
--- /dev/null
@@ -0,0 +1,21 @@
+
+romparse: rparse.tab.o lex.yy.o romparse.c
+ gcc -o romparse romparse.c rparse.tab.o lex.yy.o -I../.. -I.
+
+
+rparse.tab.o: rparse.y
+ bison -d -S bison.simple rparse.y
+ gcc -c rparse.tab.c
+
+lex.yy.o: rparse.flex
+ flex rparse.flex
+ gcc -c lex.yy.c
+
+
+
+
+
+
+
+
+
diff --git a/src/util/romparse_c6472/bison.simple b/src/util/romparse_c6472/bison.simple
--- /dev/null
@@ -0,0 +1,692 @@
+/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
+#line 3 "bison.simple"
+
+/* Skeleton output parser for bison,
+ Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
+
+ 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; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/* As a special exception, when this file is copied by Bison into a
+ Bison output file, you may use that output file without restriction.
+ This special exception was added by the Free Software Foundation
+ in version 1.24 of Bison. */
+
+#ifndef alloca
+#ifdef __GNUC__
+#define alloca __builtin_alloca
+#else /* not GNU C. */
+#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
+#include <alloca.h>
+#else /* not sparc */
+#if defined (MSDOS) && !defined (__TURBOC__)
+#include <malloc.h>
+#else /* not MSDOS, or __TURBOC__ */
+#if defined(_AIX)
+#include <malloc.h>
+ #pragma alloca
+#else /* not MSDOS, __TURBOC__, or _AIX */
+#ifdef __hpux
+#ifdef __cplusplus
+extern "C" {
+void *alloca (unsigned int);
+};
+#else /* not __cplusplus */
+void *alloca ();
+#endif /* not __cplusplus */
+#endif /* __hpux */
+#endif /* not _AIX */
+#endif /* not MSDOS, or __TURBOC__ */
+#endif /* not sparc. */
+#endif /* not GNU C. */
+#endif /* alloca not defined. */
+
+/* This is the parser code that is written into each bison parser
+ when the %semantic_parser declaration is not specified in the grammar.
+ It was written by Richard Stallman by simplifying the hairy parser
+ used when %semantic_parser is specified. */
+
+/* Note: there must be only one dollar sign in this file.
+ It is replaced by the list of actions, each action
+ as one case of the switch. */
+
+#define yyerrok (yyerrstatus = 0)
+#define yyclearin (yychar = YYEMPTY)
+#define YYEMPTY -2
+#define YYEOF 0
+#define YYACCEPT return(0)
+#define YYABORT return(1)
+#define YYERROR goto yyerrlab1
+/* Like YYERROR except do call yyerror.
+ This remains here temporarily to ease the
+ transition to the new meaning of YYERROR, for GCC.
+ Once GCC version 2 has supplanted version 1, this can go. */
+#define YYFAIL goto yyerrlab
+#define YYRECOVERING() (!!yyerrstatus)
+#define YYBACKUP(token, value) \
+do \
+ if (yychar == YYEMPTY && yylen == 1) \
+ { yychar = (token), yylval = (value); \
+ yychar1 = YYTRANSLATE (yychar); \
+ YYPOPSTACK; \
+ goto yybackup; \
+ } \
+ else \
+ { yyerror ("syntax error: cannot back up"); YYERROR; } \
+while (0)
+
+#define YYTERROR 1
+#define YYERRCODE 256
+
+#ifndef YYPURE
+#define YYLEX yylex()
+#endif
+
+#ifdef YYPURE
+#ifdef YYLSP_NEEDED
+#ifdef YYLEX_PARAM
+#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
+#else
+#define YYLEX yylex(&yylval, &yylloc)
+#endif
+#else /* not YYLSP_NEEDED */
+#ifdef YYLEX_PARAM
+#define YYLEX yylex(&yylval, YYLEX_PARAM)
+#else
+#define YYLEX yylex(&yylval)
+#endif
+#endif /* not YYLSP_NEEDED */
+#endif
+
+/* If nonreentrant, generate the variables here */
+
+#ifndef YYPURE
+
+int yychar; /* the lookahead symbol */
+YYSTYPE yylval; /* the semantic value of the */
+ /* lookahead symbol */
+
+#ifdef YYLSP_NEEDED
+YYLTYPE yylloc; /* location data for the lookahead */
+ /* symbol */
+#endif
+
+int yynerrs; /* number of parse errors so far */
+#endif /* not YYPURE */
+
+#if YYDEBUG != 0
+int yydebug; /* nonzero means print parse trace */
+/* Since this is uninitialized, it does not stop multiple parsers
+ from coexisting. */
+#endif
+
+/* YYINITDEPTH indicates the initial size of the parser's stacks */
+
+#ifndef YYINITDEPTH
+#define YYINITDEPTH 200
+#endif
+
+/* YYMAXDEPTH is the maximum size the stacks can grow to
+ (effective only if the built-in stack extension method is used). */
+
+#if YYMAXDEPTH == 0
+#undef YYMAXDEPTH
+#endif
+
+#ifndef YYMAXDEPTH
+#define YYMAXDEPTH 10000
+#endif
+
+/* Prevent warning if -Wstrict-prototypes. */
+#ifdef __GNUC__
+int yyparse (void);
+#endif
+\f
+#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
+#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
+#else /* not GNU C or C++ */
+#ifndef __cplusplus
+
+/* This is the most reliable way to avoid incompatibilities
+ in available built-in functions on various systems. */
+static void
+__yy_memcpy (to, from, count)
+ char *to;
+ char *from;
+ int count;
+{
+ register char *f = from;
+ register char *t = to;
+ register int i = count;
+
+ while (i-- > 0)
+ *t++ = *f++;
+}
+
+#else /* __cplusplus */
+
+/* This is the most reliable way to avoid incompatibilities
+ in available built-in functions on various systems. */
+static void
+__yy_memcpy (char *to, char *from, int count)
+{
+ register char *f = from;
+ register char *t = to;
+ register int i = count;
+
+ while (i-- > 0)
+ *t++ = *f++;
+}
+
+#endif
+#endif
+\f
+#line 196 "bison.simple"
+
+/* The user can define YYPARSE_PARAM as the name of an argument to be passed
+ into yyparse. The argument should have type void *.
+ It should actually point to an object.
+ Grammar actions can access the variable by casting it
+ to the proper pointer type. */
+
+#ifdef YYPARSE_PARAM
+#ifdef __cplusplus
+#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
+#define YYPARSE_PARAM_DECL
+#else /* not __cplusplus */
+#define YYPARSE_PARAM_ARG YYPARSE_PARAM
+#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
+#endif /* not __cplusplus */
+#else /* not YYPARSE_PARAM */
+#define YYPARSE_PARAM_ARG
+#define YYPARSE_PARAM_DECL
+#endif /* not YYPARSE_PARAM */
+
+int
+yyparse(YYPARSE_PARAM_ARG)
+ YYPARSE_PARAM_DECL
+{
+ register int yystate;
+ register int yyn;
+ register short *yyssp;
+ register YYSTYPE *yyvsp;
+ int yyerrstatus; /* number of tokens to shift before error messages enabled */
+ int yychar1 = 0; /* lookahead token as an internal (translated) token number */
+
+ short yyssa[YYINITDEPTH]; /* the state stack */
+ YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
+
+ short *yyss = yyssa; /* refer to the stacks thru separate pointers */
+ YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
+
+#ifdef YYLSP_NEEDED
+ YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
+ YYLTYPE *yyls = yylsa;
+ YYLTYPE *yylsp;
+
+#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
+#else
+#define YYPOPSTACK (yyvsp--, yyssp--)
+#endif
+
+ int yystacksize = YYINITDEPTH;
+
+#ifdef YYPURE
+ int yychar;
+ YYSTYPE yylval;
+ int yynerrs;
+#ifdef YYLSP_NEEDED
+ YYLTYPE yylloc;
+#endif
+#endif
+
+ YYSTYPE yyval; /* the variable used to return */
+ /* semantic values from the action */
+ /* routines */
+
+ int yylen;
+
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Starting parse\n");
+#endif
+
+ yystate = 0;
+ yyerrstatus = 0;
+ yynerrs = 0;
+ yychar = YYEMPTY; /* Cause a token to be read. */
+
+ /* Initialize stack pointers.
+ Waste one element of value and location stack
+ so that they stay on the same level as the state stack.
+ The wasted elements are never initialized. */
+
+ yyssp = yyss - 1;
+ yyvsp = yyvs;
+#ifdef YYLSP_NEEDED
+ yylsp = yyls;
+#endif
+
+/* Push a new state, which is found in yystate . */
+/* In all cases, when you get here, the value and location stacks
+ have just been pushed. so pushing a state here evens the stacks. */
+yynewstate:
+
+ *++yyssp = yystate;
+
+ if (yyssp >= yyss + yystacksize - 1)
+ {
+ /* Give user a chance to reallocate the stack */
+ /* Use copies of these so that the &'s don't force the real ones into memory. */
+ YYSTYPE *yyvs1 = yyvs;
+ short *yyss1 = yyss;
+#ifdef YYLSP_NEEDED
+ YYLTYPE *yyls1 = yyls;
+#endif
+
+ /* Get the current used size of the three stacks, in elements. */
+ int size = yyssp - yyss + 1;
+
+#ifdef yyoverflow
+ /* Each stack pointer address is followed by the size of
+ the data in use in that stack, in bytes. */
+#ifdef YYLSP_NEEDED
+ /* This used to be a conditional around just the two extra args,
+ but that might be undefined if yyoverflow is a macro. */
+ yyoverflow("parser stack overflow",
+ &yyss1, size * sizeof (*yyssp),
+ &yyvs1, size * sizeof (*yyvsp),
+ &yyls1, size * sizeof (*yylsp),
+ &yystacksize);
+#else
+ yyoverflow("parser stack overflow",
+ &yyss1, size * sizeof (*yyssp),
+ &yyvs1, size * sizeof (*yyvsp),
+ &yystacksize);
+#endif
+
+ yyss = yyss1; yyvs = yyvs1;
+#ifdef YYLSP_NEEDED
+ yyls = yyls1;
+#endif
+#else /* no yyoverflow */
+ /* Extend the stack our own way. */
+ if (yystacksize >= YYMAXDEPTH)
+ {
+ yyerror("parser stack overflow");
+ return 2;
+ }
+ yystacksize *= 2;
+ if (yystacksize > YYMAXDEPTH)
+ yystacksize = YYMAXDEPTH;
+ yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
+ __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
+ yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
+ __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
+#ifdef YYLSP_NEEDED
+ yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
+ __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
+#endif
+#endif /* no yyoverflow */
+
+ yyssp = yyss + size - 1;
+ yyvsp = yyvs + size - 1;
+#ifdef YYLSP_NEEDED
+ yylsp = yyls + size - 1;
+#endif
+
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Stack size increased to %d\n", yystacksize);
+#endif
+
+ if (yyssp >= yyss + yystacksize - 1)
+ YYABORT;
+ }
+
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Entering state %d\n", yystate);
+#endif
+
+ goto yybackup;
+ yybackup:
+
+/* Do appropriate processing given the current state. */
+/* Read a lookahead token if we need one and don't already have one. */
+/* yyresume: */
+
+ /* First try to decide what to do without reference to lookahead token. */
+
+ yyn = yypact[yystate];
+ if (yyn == YYFLAG)
+ goto yydefault;
+
+ /* Not known => get a lookahead token if don't already have one. */
+
+ /* yychar is either YYEMPTY or YYEOF
+ or a valid token in external form. */
+
+ if (yychar == YYEMPTY)
+ {
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Reading a token: ");
+#endif
+ yychar = YYLEX;
+ }
+
+ /* Convert token to internal form (in yychar1) for indexing tables with */
+
+ if (yychar <= 0) /* This means end of input. */
+ {
+ yychar1 = 0;
+ yychar = YYEOF; /* Don't call YYLEX any more */
+
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Now at end of input.\n");
+#endif
+ }
+ else
+ {
+ yychar1 = YYTRANSLATE(yychar);
+
+#if YYDEBUG != 0
+ if (yydebug)
+ {
+ fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
+ /* Give the individual parser a way to print the precise meaning
+ of a token, for further debugging info. */
+#ifdef YYPRINT
+ YYPRINT (stderr, yychar, yylval);
+#endif
+ fprintf (stderr, ")\n");
+ }
+#endif
+ }
+
+ yyn += yychar1;
+ if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
+ goto yydefault;
+
+ yyn = yytable[yyn];
+
+ /* yyn is what to do for this token type in this state.
+ Negative => reduce, -yyn is rule number.
+ Positive => shift, yyn is new state.
+ New state is final state => don't bother to shift,
+ just return success.
+ 0, or most negative number => error. */
+
+ if (yyn < 0)
+ {
+ if (yyn == YYFLAG)
+ goto yyerrlab;
+ yyn = -yyn;
+ goto yyreduce;
+ }
+ else if (yyn == 0)
+ goto yyerrlab;
+
+ if (yyn == YYFINAL)
+ YYACCEPT;
+
+ /* Shift the lookahead token. */
+
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
+#endif
+
+ /* Discard the token being shifted unless it is eof. */
+ if (yychar != YYEOF)
+ yychar = YYEMPTY;
+
+ *++yyvsp = yylval;
+#ifdef YYLSP_NEEDED
+ *++yylsp = yylloc;
+#endif
+
+ /* count tokens shifted since error; after three, turn off error status. */
+ if (yyerrstatus) yyerrstatus--;
+
+ yystate = yyn;
+ goto yynewstate;
+
+/* Do the default action for the current state. */
+yydefault:
+
+ yyn = yydefact[yystate];
+ if (yyn == 0)
+ goto yyerrlab;
+
+/* Do a reduction. yyn is the number of a rule to reduce with. */
+yyreduce:
+ yylen = yyr2[yyn];
+ if (yylen > 0)
+ yyval = yyvsp[1-yylen]; /* implement default value of the action */
+
+#if YYDEBUG != 0
+ if (yydebug)
+ {
+ int i;
+
+ fprintf (stderr, "Reducing via rule %d (line %d), ",
+ yyn, yyrline[yyn]);
+
+ /* Print the symbols being reduced, and their result. */
+ for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
+ fprintf (stderr, "%s ", yytname[yyrhs[i]]);
+ fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
+ }
+#endif
+
+$ /* the action file gets copied in in place of this dollarsign */
+#line 498 "bison.simple"
+\f
+ yyvsp -= yylen;
+ yyssp -= yylen;
+#ifdef YYLSP_NEEDED
+ yylsp -= yylen;
+#endif
+
+#if YYDEBUG != 0
+ if (yydebug)
+ {
+ short *ssp1 = yyss - 1;
+ fprintf (stderr, "state stack now");
+ while (ssp1 != yyssp)
+ fprintf (stderr, " %d", *++ssp1);
+ fprintf (stderr, "\n");
+ }
+#endif
+
+ *++yyvsp = yyval;
+
+#ifdef YYLSP_NEEDED
+ yylsp++;
+ if (yylen == 0)
+ {
+ yylsp->first_line = yylloc.first_line;
+ yylsp->first_column = yylloc.first_column;
+ yylsp->last_line = (yylsp-1)->last_line;
+ yylsp->last_column = (yylsp-1)->last_column;
+ yylsp->text = 0;
+ }
+ else
+ {
+ yylsp->last_line = (yylsp+yylen-1)->last_line;
+ yylsp->last_column = (yylsp+yylen-1)->last_column;
+ }
+#endif
+
+ /* Now "shift" the result of the reduction.
+ Determine what state that goes to,
+ based on the state we popped back to
+ and the rule number reduced by. */
+
+ yyn = yyr1[yyn];
+
+ yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
+ if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+ yystate = yytable[yystate];
+ else
+ yystate = yydefgoto[yyn - YYNTBASE];
+
+ goto yynewstate;
+
+yyerrlab: /* here on detecting error */
+
+ if (! yyerrstatus)
+ /* If not already recovering from an error, report this error. */
+ {
+ ++yynerrs;
+
+#ifdef YYERROR_VERBOSE
+ yyn = yypact[yystate];
+
+ if (yyn > YYFLAG && yyn < YYLAST)
+ {
+ int size = 0;
+ char *msg;
+ int x, count;
+
+ count = 0;
+ /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
+ for (x = (yyn < 0 ? -yyn : 0);
+ x < (sizeof(yytname) / sizeof(char *)); x++)
+ if (yycheck[x + yyn] == x)
+ size += strlen(yytname[x]) + 15, count++;
+ msg = (char *) malloc(size + 15);
+ if (msg != 0)
+ {
+ strcpy(msg, "parse error");
+
+ if (count < 5)
+ {
+ count = 0;
+ for (x = (yyn < 0 ? -yyn : 0);
+ x < (sizeof(yytname) / sizeof(char *)); x++)
+ if (yycheck[x + yyn] == x)
+ {
+ strcat(msg, count == 0 ? ", expecting `" : " or `");
+ strcat(msg, yytname[x]);
+ strcat(msg, "'");
+ count++;
+ }
+ }
+ yyerror(msg);
+ free(msg);
+ }
+ else
+ yyerror ("parse error; also virtual memory exceeded");
+ }
+ else
+#endif /* YYERROR_VERBOSE */
+ yyerror("parse error");
+ }
+
+ goto yyerrlab1;
+yyerrlab1: /* here on error raised explicitly by an action */
+
+ if (yyerrstatus == 3)
+ {
+ /* if just tried and failed to reuse lookahead token after an error, discard it. */
+
+ /* return failure if at end of input */
+ if (yychar == YYEOF)
+ YYABORT;
+
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
+#endif
+
+ yychar = YYEMPTY;
+ }
+
+ /* Else will try to reuse lookahead token
+ after shifting the error token. */
+
+ yyerrstatus = 3; /* Each real token shifted decrements this */
+
+ goto yyerrhandle;
+
+yyerrdefault: /* current state does not do anything special for the error token. */
+
+#if 0
+ /* This is wrong; only states that explicitly want error tokens
+ should shift them. */
+ yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
+ if (yyn) goto yydefault;
+#endif
+
+yyerrpop: /* pop the current state because it cannot handle the error token */
+
+ if (yyssp == yyss) YYABORT;
+ yyvsp--;
+ yystate = *--yyssp;
+#ifdef YYLSP_NEEDED
+ yylsp--;
+#endif
+
+#if YYDEBUG != 0
+ if (yydebug)
+ {
+ short *ssp1 = yyss - 1;
+ fprintf (stderr, "Error: state stack now");
+ while (ssp1 != yyssp)
+ fprintf (stderr, " %d", *++ssp1);
+ fprintf (stderr, "\n");
+ }
+#endif
+
+yyerrhandle:
+
+ yyn = yypact[yystate];
+ if (yyn == YYFLAG)
+ goto yyerrdefault;
+
+ yyn += YYTERROR;
+ if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
+ goto yyerrdefault;
+
+ yyn = yytable[yyn];
+ if (yyn < 0)
+ {
+ if (yyn == YYFLAG)
+ goto yyerrpop;
+ yyn = -yyn;
+ goto yyreduce;
+ }
+ else if (yyn == 0)
+ goto yyerrpop;
+
+ if (yyn == YYFINAL)
+ YYACCEPT;
+
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Shifting error token, ");
+#endif
+
+ *++yyvsp = yylval;
+#ifdef YYLSP_NEEDED
+ *++yylsp = yylloc;
+#endif
+
+ yystate = yyn;
+ goto yynewstate;
+}
diff --git a/src/util/romparse_c6472/romparse.c b/src/util/romparse_c6472/romparse.c
--- /dev/null
@@ -0,0 +1,414 @@
+/*************************************************************************************
+ * FILE PURPOSE: Create an I2C rom with multiple boot parameter sections and
+ * programs
+ *************************************************************************************
+ * FILE NAME: romparse.c
+ *
+ * DESCRIPTION: Creates a ccs hex file which contains the i2c eprom boot parameter
+ * tables as well as any code.
+ *
+ *************************************************************************************/
+#include <stdio.h>
+#include <string.h>
+#include "rparse.tab.h"
+#include "romparse.h"
+
+/*************************************************************************************
+ * Definition: fixed i2c map locations
+ *************************************************************************************/
+#define PCI_PARAM_BASE (NUM_BOOT_PARAM_TABLES * 0x80)
+#define DATA_BASE (PCI_PARAM_BASE + PCI_EEAI_PARAM_SIZE)
+
+
+
+/*************************************************************************************
+ * Declaration: The flex input file is assigned based on the command line
+ *************************************************************************************/
+extern FILE *yyin;
+
+/*************************************************************************************
+ * Declaration: The boot parameter tables. The current table is copied into position
+ * when the section parse is complete.
+ *************************************************************************************/
+BOOT_PARAMS_T boot_params[NUM_BOOT_PARAM_TABLES];
+BOOT_PARAMS_T current_table;
+int ctable_index = -1; /* Destination of current table */
+
+/************************************************************************************
+ * Declaration: The structure storing the program data files, and the number of
+ * programs used.
+ ************************************************************************************/
+progFile_t progFile[NUM_BOOT_PARAM_TABLES];
+int nProgFiles = 0;
+
+/************************************************************************************
+ * Declaration: The PCI parameter structure
+ ************************************************************************************/
+pciFile_t pciFile;
+int pciSet = 0;
+
+/*************************************************************************************
+ * Declaration: The next free address in the ROM for general data usage. For the
+ * start address there is room for the initial boot parameter tables,
+ * plus room for the PCI eeai config.
+ *************************************************************************************/
+int romBase = DATA_BASE;
+
+/*************************************************************************************
+ * FUNCTION PURPOSE: flex/bison required support functions.
+ *************************************************************************************
+ * DESCRIPTION: yyerror and yywrap are required to support flex and/or bison parsing
+ * of the parameter description file. yyerror directly reports the
+ * error, yywrap is unused.
+ *************************************************************************************/
+void yyerror (char *s)
+{
+ fprintf (stderr, "flex/bison error is %s\n", s);
+} /* yyerror */
+
+void yywrap (void)
+{
+} /* yywrap */
+
+/*************************************************************************************
+ * FUNCTION PURPOSE: Initialize a boot table
+ *************************************************************************************
+ * DESCRIPTION: Sets a boot parameter table to 0s
+ *************************************************************************************/
+void initTable (BOOT_PARAMS_T *current_table)
+{
+ memset (current_table, 0, sizeof(BOOT_PARAMS_T));
+}
+
+/*************************************************************************************
+ * FUNCTION PURPOSE: Complete a section
+ *************************************************************************************
+ * DESCRIPTION: The parser has detected a complete section. Copy the section into
+ * it's correct table location.
+ *************************************************************************************/
+void section (void)
+{
+ /* It's an error if no section value has been declared */
+ if (ctable_index == -1) {
+ fprintf (stderr, "romparse: the section did not have a boot paramter index specified\n");
+ exit (-1);
+ }
+
+ /* Make sure the table is in range */
+ if (ctable_index >= NUM_BOOT_PARAM_TABLES) {
+ fprintf (stderr, "romparse: The section index is too large (max %d)\n", NUM_BOOT_PARAM_TABLES-1);
+ exit (-1);
+ }
+
+ /* The length must be set. Currently this program only supports I2C mode, so the
+ * length is fixed */
+ current_table.common.length = 30;
+ current_table.common.checksum = 0;
+
+ /* Copy the table */
+ memcpy (&boot_params[ctable_index], ¤t_table, sizeof (BOOT_PARAMS_T));
+ initTable (¤t_table);
+
+ ctable_index = -1;
+
+} /* section */
+
+/***************************************************************************************
+ * FUNCTION PURPOSE: Open a ccs hex file and read in the data.
+ ***************************************************************************************
+ * DESCRIPTION: Reads a ccs hex format data file, loads the file into the
+ * next program file structure. Returns the index of the just loaded
+ * table.
+ ***************************************************************************************/
+int openProgFile (char *fname)
+{
+ FILE *str;
+ int a, b, c, d, e;
+ int i;
+ char iline[132];
+
+ /* Store the file name */
+ strcpy (progFile[nProgFiles].fname, fname);
+
+ /* Open the data file */
+ str = fopen (fname, "r");
+ if (str == NULL) {
+ fprintf (stderr, "romparse: Could not open file %s\n", fname);
+ exit (-1);
+ }
+
+ /* Put the section at the next available i2c rom address */
+ progFile[nProgFiles].addressBytes = romBase;
+
+ /* Read the one line ccs header. The length field in terms of lines */
+ fgets (iline, 132, str);
+ sscanf (iline, "%x %x %x %x %x", &a, &b, &c, &d, &e);
+ progFile[nProgFiles].sizeBytes = e * 4; /* Length was in 4 byte words */
+
+ /* Read in the data */
+ for (i = 0; i < e; i++) {
+ fgets (iline, 132, str);
+ sscanf (&(iline[2]), "%x", &((progFile[nProgFiles]).data[i]));
+ }
+
+ fclose (str);
+
+ /* Update the next free rom base */
+ romBase = romBase + progFile[nProgFiles].sizeBytes;
+
+ i = nProgFiles;
+ nProgFiles += 1;
+
+ return (i);
+
+} /* openProgFile */
+
+/***************************************************************************************
+ * FUNCTION PURPOSE: Load the PCI paramter section
+ ***************************************************************************************
+ * DESCRIPTION: Loads the PCI parameter section and stores it in the rom. */
+int setPciParams (char *fname)
+{
+ FILE *str;
+ int a, b, c, d, e;
+ int i;
+ char iline[132];
+ char *z;
+
+ if (pciSet) {
+ fprintf (stderr, "romparse: PCI parameters specified more then once\n");
+ exit (-1);
+ }
+
+ /* the input string still contains the quotes. Remove them here */
+ z = &fname[1];
+ *strchr (z, '"') = '\0';
+
+ /* Store the file name */
+ strcpy (pciFile.fname, z);
+
+ /* Open the data file */
+ str = fopen (z, "r");
+ if (str == NULL) {
+ fprintf (stderr, "romparse: Could not open pci file %s\n", fname);
+ exit (-1);
+ }
+
+ /* The address of the pci params is currently fixed */
+ pciFile.addressBytes = PCI_PARAM_BASE;
+
+ /* Read the one line ccs header. The length field is in terms of lines */
+ fgets (iline, 132, str);
+ sscanf (iline, "%x %x %x %x %x", &a, &b, &c, &d, &e);
+ pciFile.sizeBytes = e * 4; /* Convert length to bytes */
+
+ /* Read in the data */
+ for (i = 0; i < e; i++) {
+ fgets (iline, 132, str);
+ sscanf (&(iline[2]), "%x", &(pciFile.data[i]));
+ }
+
+ pciSet = 1;
+
+ return (0);
+
+} /* setPciParams */
+
+
+
+/***************************************************************************************
+ * FUNCTION PURPOSE: Store an assignment
+ ***************************************************************************************
+ * DESCRIPTION: Stores an assigned value into the current boot parameter table
+ ***************************************************************************************/
+void assignKeyVal (int field, int value)
+{
+ switch (field) {
+
+ case BOOT_MODE: current_table.common.boot_mode = value;
+ break;
+
+ case PARAM_INDEX: ctable_index = value;
+ break;
+
+ case OPTIONS: current_table.i2c.options = value;
+ break;
+
+ case MULTI_I2C_ID: current_table.i2c.multi_i2c_id = value;
+ break;
+
+ case MY_I2C_ID: current_table.i2c.my_i2c_id = value;
+ break;
+
+ case CORE_FREQ_MHZ: current_table.i2c.core_freq_mhz = value;
+ break;
+
+ case I2C_CLK_FREQ_KHZ: current_table.i2c.i2c_clk_freq_khz = value;
+ break;
+
+ case NEXT_DEV_ADDR: current_table.i2c.next_dev_addr = value;
+ break;
+
+ case NEXT_DEV_ADDR_EXT: current_table.i2c.next_dev_addr_ext = value;
+ break;
+
+ case ADDRESS_DELAY: current_table.i2c.address_delay = value;
+ break;
+
+ case SWPLL: current_table.i2c.swPll = value;
+ break;
+
+
+ }
+
+} /* assignKeyVal */
+
+
+/*******************************************************************************
+ * FUNCTION PURPOSE: Parse a string input.
+ *******************************************************************************
+ * DESCRIPTION: Takes a string input. Currently only the i2c exe file name can be
+ * assigned a string.
+ *******************************************************************************/
+void assignKeyStr (int value, char *y)
+{
+ int i;
+ char *z;
+
+
+ /* the input string still contains the quotes. Remove them here */
+ z = &y[1];
+ *strchr (z, '"') = '\0';
+
+ /* Check if the file name is already open */
+ for (i = 0; i < nProgFiles; i++) {
+
+ if (!strcmp (z, progFile[i].fname)) {
+ /* Found a match - copy the address */
+ current_table.i2c.dev_addr = progFile[i].addressBytes & 0xffff;
+ current_table.i2c.dev_addr_ext = 0x50; /* hard coded to i2c rom slave address */
+ return;
+ }
+
+ }
+
+ /* Open and read the ccs file, set the ROM address */
+ i = openProgFile (z);
+ if (i >= 0) {
+ current_table.i2c.dev_addr = progFile[i].addressBytes & 0xffff;
+ current_table.i2c.dev_addr_ext = 0x50;
+ }
+
+} /* assignKeyStr */
+
+
+/************************************************************************************
+ * FUNCTION PURPOSE: Opens and writes the output file
+ ************************************************************************************
+ * DESCRIPTION: Creates the output file in ccs format.
+ ************************************************************************************/
+void createOutput (void)
+{
+ FILE *str;
+ int totalLenBytes;
+ int i, j;
+ unsigned int value, v1, v2;
+
+ str = fopen ("i2crom.ccs", "w");
+ if (str == NULL) {
+ fprintf (stderr, "romparse: Could not open output file i2crom.ccs for writing\n");
+ exit (-1);
+ }
+
+ /* Compute the total size of the i2c prom. Include all the i2c boot paramater tables,
+ * as well as the PCI parameter table, (which is not necessarily present). */
+ totalLenBytes = DATA_BASE;
+
+ for (i = 0; i < nProgFiles; i++)
+ totalLenBytes += progFile[i].sizeBytes;
+
+ /* Write out the ccs header */
+ fprintf (str, "1651 1 10000 1 %x\n", totalLenBytes >> 2);
+
+ /* Write out the boot parameter tables. 0x80 bytes will be written out.
+ * There are 16 bits in every parameter field, which is why the index
+ * is from 0 to 0x40 */
+ for (i = 0; i < NUM_BOOT_PARAM_TABLES; i++) {
+ for (j = 0; j < (0x80 >> 1); j += 2) {
+ v1 = boot_params[i].parameter[j];
+ v2 = boot_params[i].parameter[j+1];
+ value = (v1 << 16) | v2;
+ fprintf (str, "0x%08x\n", value);
+ }
+ }
+
+ /* Write out the PCI parameter base. If none was included then zeros will be
+ * written out */
+ for (i = 0; i < PCI_DATA_LEN_32bit; i++) {
+ fprintf (str, "0x%08x\n", pciFile.data[i]);
+ }
+
+
+ /* Write out each of the program files */
+ for (i = 0; i < nProgFiles; i++)
+ for (j = 0; j < progFile[i].sizeBytes >> 2; j++)
+ fprintf (str, "0x%08x\n", (progFile[i]).data[j]);
+
+
+ /* Close the input file */
+ fclose (str);
+
+} /* createOutput */
+
+/************************************************************************************
+ * FUNCTION PURPOSE: Initialize the pci paramter table
+ ************************************************************************************
+ * DESCRIPTION: Zeros the pci parameters
+ ************************************************************************************/
+void initPciParams (void)
+{
+ memset (&pciFile, 0, sizeof(pciFile_t));
+} /* initPciParams */
+
+/************************************************************************************
+ * FUNCTION PURPOSE: main function
+ ************************************************************************************
+ * DESCRIPTION: Performs the processing sequence.
+ ************************************************************************************/
+int main (int argc, char *argv[])
+{
+ int i;
+
+ /* Initialize the tables */
+ for (i = 0; i < NUM_BOOT_PARAM_TABLES; i++)
+ initTable(&boot_params[i]);
+
+ initTable (¤t_table);
+
+ /* Initialize the PCI param table */
+ initPciParams ();
+
+ /* open the input */
+ if (argc != 2) {
+ fprintf (stderr, "usage: %s inputfile\n", argv[0]);
+ return (-1);
+ }
+
+ yyin = fopen (argv[1], "r");
+ if (yyin == NULL) {
+ fprintf (stderr, "%s: could not open file %s\n", argv[0], argv[1]);
+ return (-1);
+ }
+
+ /* Parse the input description file */
+ yyparse();
+
+
+ /* Create the output file */
+ createOutput ();
+
+ return (0);
+}
+
+
+
diff --git a/src/util/romparse_c6472/romparse.h b/src/util/romparse_c6472/romparse.h
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef _ROMPARSE_H
+#define _ROMPARSE_H
+/*************************************************************************************
+ * FILE PURPOSE: Define boot data structures
+ *************************************************************************************
+ * FILE NAME: romparse.h
+ *
+ * DESCRIPTION: Defines the structures used to create the boot parameter
+ * table
+ *
+ *************************************************************************************/
+
+/* tiboot.h defines the boot parameters structure that will be created */
+#include "tiboot.h"
+
+/* Define the number of boot parameter tables that will be put on the rom */
+#define NUM_BOOT_PARAM_TABLES 8
+
+/* Define the size reserved for the PCI configuration table */
+#define PCI_EEAI_PARAM_SIZE 0x20
+
+/* Define a structure mapping the boot parameter table number to a program file
+ * to an eeprom byte address */
+#define MAX_FNAME_LEN 132
+#define MAX_DATA_LEN_32bit 32768
+typedef struct {
+ char fname[MAX_FNAME_LEN];
+ int sizeBytes;
+ int addressBytes;
+ unsigned int data[MAX_DATA_LEN_32bit];
+} progFile_t;
+
+/* Define the PCI parameter structure */
+#define PCI_DATA_LEN_32bit 8
+typedef struct {
+ char fname[MAX_FNAME_LEN];
+ int sizeBytes;
+ int addressBytes;
+ unsigned int data[PCI_DATA_LEN_32bit];
+} pciFile_t;
+
+
+
+
+#endif /* ROMPARSE_H */
diff --git a/src/util/romparse_c6472/rparse.flex b/src/util/romparse_c6472/rparse.flex
--- /dev/null
@@ -0,0 +1,37 @@
+/* Lexical analyzer for the eeprom boot builder */
+%{
+#include "rparse.tab.h"
+%}
+%%
+
+"{" return (LBRACE);
+"}" return (RBRACE);
+"=" return (EQU);
+
+section { yylval = SECTION; return (SECTION); }
+boot_mode { yylval = BOOT_MODE; return (BOOT_MODE); }
+param_index { yylval = PARAM_INDEX; return (PARAM_INDEX); }
+options { yylval = OPTIONS; return (OPTIONS); }
+multi_i2c_id { yylval = MULTI_I2C_ID; return (MULTI_I2C_ID); }
+my_i2c_id { yylval = MY_I2C_ID; return (MY_I2C_ID); }
+core_freq_mhz { yylval = CORE_FREQ_MHZ; return (CORE_FREQ_MHZ); }
+i2c_clk_freq_khz { yylval = I2C_CLK_FREQ_KHZ; return (I2C_CLK_FREQ_KHZ); }
+exe_file { yylval = EXE_FILE; return (EXE_FILE); }
+pci_parm { yylval = PCI_PARMS; return (PCI_PARMS); }
+next_dev_addr { yylval = NEXT_DEV_ADDR; return (NEXT_DEV_ADDR); }
+next_dev_addr_ext { yylval = NEXT_DEV_ADDR_EXT; return (NEXT_DEV_ADDR_EXT); }
+address_delay { yylval = ADDRESS_DELAY; return (ADDRESS_DELAY); }
+sw_pll { yylval = SWPLL; return (SWPLL); }
+
+
+[0-9]+ { yylval = atoi(yytext); return (VALUE); }
+0x[0-9a-f]+ { sscanf (&yytext[2], "%x", &yylval); return (VALUE); }
+
+\".*\" return (STRING);
+
+
+%%
+
+
+
+
diff --git a/src/util/romparse_c6472/rparse.tab.c b/src/util/romparse_c6472/rparse.tab.c
--- /dev/null
@@ -0,0 +1,930 @@
+
+/* A Bison parser, made from rparse.y
+ by GNU Bison version 1.25
+ */
+
+#define YYBISON 1 /* Identify Bison output. */
+
+#define LBRACE 258
+#define RBRACE 259
+#define SECTION 260
+#define EQU 261
+#define VALUE 262
+#define STRING 263
+#define BOOT_MODE 264
+#define PARAM_INDEX 265
+#define OPTIONS 266
+#define MULTI_I2C_ID 267
+#define MY_I2C_ID 268
+#define CORE_FREQ_MHZ 269
+#define I2C_CLK_FREQ_KHZ 270
+#define EXE_FILE 271
+#define PCI_PARMS 272
+#define NEXT_DEV_ADDR 273
+#define NEXT_DEV_ADDR_EXT 274
+#define ADDRESS_DELAY 275
+#define SWPLL 276
+
+#line 2 "rparse.y"
+
+#define YYERROR_VERBOSE
+extern char *yytext;
+#ifndef YYSTYPE
+#define YYSTYPE int
+#endif
+#include <stdio.h>
+
+#ifndef __cplusplus
+#ifndef __STDC__
+#define const
+#endif
+#endif
+
+
+
+#define YYFINAL 30
+#define YYFLAG -32768
+#define YYNTBASE 22
+
+#define YYTRANSLATE(x) ((unsigned)(x) <= 276 ? yytranslate[x] : 27)
+
+static const char yytranslate[] = { 0,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
+ 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21
+};
+
+#if YYDEBUG != 0
+static const short yyprhs[] = { 0,
+ 0, 2, 5, 10, 14, 16, 19, 23, 27, 29,
+ 31, 33, 35, 37, 39, 41, 43, 45, 47, 49
+};
+
+static const short yyrhs[] = { 23,
+ 0, 22, 23, 0, 5, 3, 24, 4, 0, 17,
+ 6, 8, 0, 25, 0, 24, 25, 0, 26, 6,
+ 7, 0, 26, 6, 8, 0, 9, 0, 10, 0,
+ 11, 0, 12, 0, 13, 0, 14, 0, 15, 0,
+ 16, 0, 18, 0, 19, 0, 20, 0, 21, 0
+};
+
+#endif
+
+#if YYDEBUG != 0
+static const short yyrline[] = { 0,
+ 11, 12, 15, 17, 22, 23, 26, 28, 32, 33,
+ 34, 35, 36, 37, 38, 39, 40, 41, 42, 43
+};
+#endif
+
+
+#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
+
+static const char * const yytname[] = { "$","error","$undefined.","LBRACE",
+"RBRACE","SECTION","EQU","VALUE","STRING","BOOT_MODE","PARAM_INDEX","OPTIONS",
+"MULTI_I2C_ID","MY_I2C_ID","CORE_FREQ_MHZ","I2C_CLK_FREQ_KHZ","EXE_FILE","PCI_PARMS",
+"NEXT_DEV_ADDR","NEXT_DEV_ADDR_EXT","ADDRESS_DELAY","SWPLL","promspec","bootParams",
+"assigns","assign","keyword", NULL
+};
+#endif
+
+static const short yyr1[] = { 0,
+ 22, 22, 23, 23, 24, 24, 25, 25, 26, 26,
+ 26, 26, 26, 26, 26, 26, 26, 26, 26, 26
+};
+
+static const short yyr2[] = { 0,
+ 1, 2, 4, 3, 1, 2, 3, 3, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+};
+
+static const short yydefact[] = { 0,
+ 0, 0, 0, 1, 0, 0, 2, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 0,
+ 5, 0, 4, 3, 6, 0, 7, 8, 0, 0
+};
+
+static const short yydefgoto[] = { 3,
+ 4, 20, 21, 22
+};
+
+static const short yypact[] = { 34,
+ 0, -2, 13,-32768, 22, 11,-32768,-32768,-32768,-32768,
+-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -4,
+-32768, 14,-32768,-32768,-32768, -6,-32768,-32768, 21,-32768
+};
+
+static const short yypgoto[] = {-32768,
+ 19,-32768, 3,-32768
+};
+
+
+#define YYLAST 51
+
+
+static const short yytable[] = { 24,
+ 27, 28, 5, 6, 8, 9, 10, 11, 12, 13,
+ 14, 15, 29, 16, 17, 18, 19, 1, 23, 26,
+ 30, 7, 25, 0, 0, 0, 0, 0, 0, 2,
+ 8, 9, 10, 11, 12, 13, 14, 15, 1, 16,
+ 17, 18, 19, 0, 0, 0, 0, 0, 0, 0,
+ 2
+};
+
+static const short yycheck[] = { 4,
+ 7, 8, 3, 6, 9, 10, 11, 12, 13, 14,
+ 15, 16, 0, 18, 19, 20, 21, 5, 8, 6,
+ 0, 3, 20, -1, -1, -1, -1, -1, -1, 17,
+ 9, 10, 11, 12, 13, 14, 15, 16, 5, 18,
+ 19, 20, 21, -1, -1, -1, -1, -1, -1, -1,
+ 17
+};
+/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
+#line 3 "bison.simple"
+
+/* Skeleton output parser for bison,
+ Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
+
+ 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; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+/* As a special exception, when this file is copied by Bison into a
+ Bison output file, you may use that output file without restriction.
+ This special exception was added by the Free Software Foundation
+ in version 1.24 of Bison. */
+
+#ifndef alloca
+#ifdef __GNUC__
+#define alloca __builtin_alloca
+#else /* not GNU C. */
+#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
+#include <alloca.h>
+#else /* not sparc */
+#if defined (MSDOS) && !defined (__TURBOC__)
+#include <malloc.h>
+#else /* not MSDOS, or __TURBOC__ */
+#if defined(_AIX)
+#include <malloc.h>
+ #pragma alloca
+#else /* not MSDOS, __TURBOC__, or _AIX */
+#ifdef __hpux
+#ifdef __cplusplus
+extern "C" {
+void *alloca (unsigned int);
+};
+#else /* not __cplusplus */
+void *alloca ();
+#endif /* not __cplusplus */
+#endif /* __hpux */
+#endif /* not _AIX */
+#endif /* not MSDOS, or __TURBOC__ */
+#endif /* not sparc. */
+#endif /* not GNU C. */
+#endif /* alloca not defined. */
+
+/* This is the parser code that is written into each bison parser
+ when the %semantic_parser declaration is not specified in the grammar.
+ It was written by Richard Stallman by simplifying the hairy parser
+ used when %semantic_parser is specified. */
+
+/* Note: there must be only one dollar sign in this file.
+ It is replaced by the list of actions, each action
+ as one case of the switch. */
+
+#define yyerrok (yyerrstatus = 0)
+#define yyclearin (yychar = YYEMPTY)
+#define YYEMPTY -2
+#define YYEOF 0
+#define YYACCEPT return(0)
+#define YYABORT return(1)
+#define YYERROR goto yyerrlab1
+/* Like YYERROR except do call yyerror.
+ This remains here temporarily to ease the
+ transition to the new meaning of YYERROR, for GCC.
+ Once GCC version 2 has supplanted version 1, this can go. */
+#define YYFAIL goto yyerrlab
+#define YYRECOVERING() (!!yyerrstatus)
+#define YYBACKUP(token, value) \
+do \
+ if (yychar == YYEMPTY && yylen == 1) \
+ { yychar = (token), yylval = (value); \
+ yychar1 = YYTRANSLATE (yychar); \
+ YYPOPSTACK; \
+ goto yybackup; \
+ } \
+ else \
+ { yyerror ("syntax error: cannot back up"); YYERROR; } \
+while (0)
+
+#define YYTERROR 1
+#define YYERRCODE 256
+
+#ifndef YYPURE
+#define YYLEX yylex()
+#endif
+
+#ifdef YYPURE
+#ifdef YYLSP_NEEDED
+#ifdef YYLEX_PARAM
+#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
+#else
+#define YYLEX yylex(&yylval, &yylloc)
+#endif
+#else /* not YYLSP_NEEDED */
+#ifdef YYLEX_PARAM
+#define YYLEX yylex(&yylval, YYLEX_PARAM)
+#else
+#define YYLEX yylex(&yylval)
+#endif
+#endif /* not YYLSP_NEEDED */
+#endif
+
+/* If nonreentrant, generate the variables here */
+
+#ifndef YYPURE
+
+int yychar; /* the lookahead symbol */
+YYSTYPE yylval; /* the semantic value of the */
+ /* lookahead symbol */
+
+#ifdef YYLSP_NEEDED
+YYLTYPE yylloc; /* location data for the lookahead */
+ /* symbol */
+#endif
+
+int yynerrs; /* number of parse errors so far */
+#endif /* not YYPURE */
+
+#if YYDEBUG != 0
+int yydebug; /* nonzero means print parse trace */
+/* Since this is uninitialized, it does not stop multiple parsers
+ from coexisting. */
+#endif
+
+/* YYINITDEPTH indicates the initial size of the parser's stacks */
+
+#ifndef YYINITDEPTH
+#define YYINITDEPTH 200
+#endif
+
+/* YYMAXDEPTH is the maximum size the stacks can grow to
+ (effective only if the built-in stack extension method is used). */
+
+#if YYMAXDEPTH == 0
+#undef YYMAXDEPTH
+#endif
+
+#ifndef YYMAXDEPTH
+#define YYMAXDEPTH 10000
+#endif
+
+/* Prevent warning if -Wstrict-prototypes. */
+#ifdef __GNUC__
+int yyparse (void);
+#endif
+\f
+#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
+#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
+#else /* not GNU C or C++ */
+#ifndef __cplusplus
+
+/* This is the most reliable way to avoid incompatibilities
+ in available built-in functions on various systems. */
+static void
+__yy_memcpy (to, from, count)
+ char *to;
+ char *from;
+ int count;
+{
+ register char *f = from;
+ register char *t = to;
+ register int i = count;
+
+ while (i-- > 0)
+ *t++ = *f++;
+}
+
+#else /* __cplusplus */
+
+/* This is the most reliable way to avoid incompatibilities
+ in available built-in functions on various systems. */
+static void
+__yy_memcpy (char *to, char *from, int count)
+{
+ register char *f = from;
+ register char *t = to;
+ register int i = count;
+
+ while (i-- > 0)
+ *t++ = *f++;
+}
+
+#endif
+#endif
+\f
+#line 196 "bison.simple"
+
+/* The user can define YYPARSE_PARAM as the name of an argument to be passed
+ into yyparse. The argument should have type void *.
+ It should actually point to an object.
+ Grammar actions can access the variable by casting it
+ to the proper pointer type. */
+
+#ifdef YYPARSE_PARAM
+#ifdef __cplusplus
+#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
+#define YYPARSE_PARAM_DECL
+#else /* not __cplusplus */
+#define YYPARSE_PARAM_ARG YYPARSE_PARAM
+#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
+#endif /* not __cplusplus */
+#else /* not YYPARSE_PARAM */
+#define YYPARSE_PARAM_ARG
+#define YYPARSE_PARAM_DECL
+#endif /* not YYPARSE_PARAM */
+
+int
+yyparse(YYPARSE_PARAM_ARG)
+ YYPARSE_PARAM_DECL
+{
+ register int yystate;
+ register int yyn;
+ register short *yyssp;
+ register YYSTYPE *yyvsp;
+ int yyerrstatus; /* number of tokens to shift before error messages enabled */
+ int yychar1 = 0; /* lookahead token as an internal (translated) token number */
+
+ short yyssa[YYINITDEPTH]; /* the state stack */
+ YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
+
+ short *yyss = yyssa; /* refer to the stacks thru separate pointers */
+ YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
+
+#ifdef YYLSP_NEEDED
+ YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
+ YYLTYPE *yyls = yylsa;
+ YYLTYPE *yylsp;
+
+#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
+#else
+#define YYPOPSTACK (yyvsp--, yyssp--)
+#endif
+
+ int yystacksize = YYINITDEPTH;
+
+#ifdef YYPURE
+ int yychar;
+ YYSTYPE yylval;
+ int yynerrs;
+#ifdef YYLSP_NEEDED
+ YYLTYPE yylloc;
+#endif
+#endif
+
+ YYSTYPE yyval; /* the variable used to return */
+ /* semantic values from the action */
+ /* routines */
+
+ int yylen;
+
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Starting parse\n");
+#endif
+
+ yystate = 0;
+ yyerrstatus = 0;
+ yynerrs = 0;
+ yychar = YYEMPTY; /* Cause a token to be read. */
+
+ /* Initialize stack pointers.
+ Waste one element of value and location stack
+ so that they stay on the same level as the state stack.
+ The wasted elements are never initialized. */
+
+ yyssp = yyss - 1;
+ yyvsp = yyvs;
+#ifdef YYLSP_NEEDED
+ yylsp = yyls;
+#endif
+
+/* Push a new state, which is found in yystate . */
+/* In all cases, when you get here, the value and location stacks
+ have just been pushed. so pushing a state here evens the stacks. */
+yynewstate:
+
+ *++yyssp = yystate;
+
+ if (yyssp >= yyss + yystacksize - 1)
+ {
+ /* Give user a chance to reallocate the stack */
+ /* Use copies of these so that the &'s don't force the real ones into memory. */
+ YYSTYPE *yyvs1 = yyvs;
+ short *yyss1 = yyss;
+#ifdef YYLSP_NEEDED
+ YYLTYPE *yyls1 = yyls;
+#endif
+
+ /* Get the current used size of the three stacks, in elements. */
+ int size = yyssp - yyss + 1;
+
+#ifdef yyoverflow
+ /* Each stack pointer address is followed by the size of
+ the data in use in that stack, in bytes. */
+#ifdef YYLSP_NEEDED
+ /* This used to be a conditional around just the two extra args,
+ but that might be undefined if yyoverflow is a macro. */
+ yyoverflow("parser stack overflow",
+ &yyss1, size * sizeof (*yyssp),
+ &yyvs1, size * sizeof (*yyvsp),
+ &yyls1, size * sizeof (*yylsp),
+ &yystacksize);
+#else
+ yyoverflow("parser stack overflow",
+ &yyss1, size * sizeof (*yyssp),
+ &yyvs1, size * sizeof (*yyvsp),
+ &yystacksize);
+#endif
+
+ yyss = yyss1; yyvs = yyvs1;
+#ifdef YYLSP_NEEDED
+ yyls = yyls1;
+#endif
+#else /* no yyoverflow */
+ /* Extend the stack our own way. */
+ if (yystacksize >= YYMAXDEPTH)
+ {
+ yyerror("parser stack overflow");
+ return 2;
+ }
+ yystacksize *= 2;
+ if (yystacksize > YYMAXDEPTH)
+ yystacksize = YYMAXDEPTH;
+ yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
+ __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
+ yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
+ __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
+#ifdef YYLSP_NEEDED
+ yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
+ __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
+#endif
+#endif /* no yyoverflow */
+
+ yyssp = yyss + size - 1;
+ yyvsp = yyvs + size - 1;
+#ifdef YYLSP_NEEDED
+ yylsp = yyls + size - 1;
+#endif
+
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Stack size increased to %d\n", yystacksize);
+#endif
+
+ if (yyssp >= yyss + yystacksize - 1)
+ YYABORT;
+ }
+
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Entering state %d\n", yystate);
+#endif
+
+ goto yybackup;
+ yybackup:
+
+/* Do appropriate processing given the current state. */
+/* Read a lookahead token if we need one and don't already have one. */
+/* yyresume: */
+
+ /* First try to decide what to do without reference to lookahead token. */
+
+ yyn = yypact[yystate];
+ if (yyn == YYFLAG)
+ goto yydefault;
+
+ /* Not known => get a lookahead token if don't already have one. */
+
+ /* yychar is either YYEMPTY or YYEOF
+ or a valid token in external form. */
+
+ if (yychar == YYEMPTY)
+ {
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Reading a token: ");
+#endif
+ yychar = YYLEX;
+ }
+
+ /* Convert token to internal form (in yychar1) for indexing tables with */
+
+ if (yychar <= 0) /* This means end of input. */
+ {
+ yychar1 = 0;
+ yychar = YYEOF; /* Don't call YYLEX any more */
+
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Now at end of input.\n");
+#endif
+ }
+ else
+ {
+ yychar1 = YYTRANSLATE(yychar);
+
+#if YYDEBUG != 0
+ if (yydebug)
+ {
+ fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
+ /* Give the individual parser a way to print the precise meaning
+ of a token, for further debugging info. */
+#ifdef YYPRINT
+ YYPRINT (stderr, yychar, yylval);
+#endif
+ fprintf (stderr, ")\n");
+ }
+#endif
+ }
+
+ yyn += yychar1;
+ if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
+ goto yydefault;
+
+ yyn = yytable[yyn];
+
+ /* yyn is what to do for this token type in this state.
+ Negative => reduce, -yyn is rule number.
+ Positive => shift, yyn is new state.
+ New state is final state => don't bother to shift,
+ just return success.
+ 0, or most negative number => error. */
+
+ if (yyn < 0)
+ {
+ if (yyn == YYFLAG)
+ goto yyerrlab;
+ yyn = -yyn;
+ goto yyreduce;
+ }
+ else if (yyn == 0)
+ goto yyerrlab;
+
+ if (yyn == YYFINAL)
+ YYACCEPT;
+
+ /* Shift the lookahead token. */
+
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
+#endif
+
+ /* Discard the token being shifted unless it is eof. */
+ if (yychar != YYEOF)
+ yychar = YYEMPTY;
+
+ *++yyvsp = yylval;
+#ifdef YYLSP_NEEDED
+ *++yylsp = yylloc;
+#endif
+
+ /* count tokens shifted since error; after three, turn off error status. */
+ if (yyerrstatus) yyerrstatus--;
+
+ yystate = yyn;
+ goto yynewstate;
+
+/* Do the default action for the current state. */
+yydefault:
+
+ yyn = yydefact[yystate];
+ if (yyn == 0)
+ goto yyerrlab;
+
+/* Do a reduction. yyn is the number of a rule to reduce with. */
+yyreduce:
+ yylen = yyr2[yyn];
+ if (yylen > 0)
+ yyval = yyvsp[1-yylen]; /* implement default value of the action */
+
+#if YYDEBUG != 0
+ if (yydebug)
+ {
+ int i;
+
+ fprintf (stderr, "Reducing via rule %d (line %d), ",
+ yyn, yyrline[yyn]);
+
+ /* Print the symbols being reduced, and their result. */
+ for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
+ fprintf (stderr, "%s ", yytname[yyrhs[i]]);
+ fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
+ }
+#endif
+
+
+ switch (yyn) {
+
+case 3:
+#line 16 "rparse.y"
+{ section (); ;
+ break;}
+case 4:
+#line 18 "rparse.y"
+{ setPciParams (yytext); ;
+ break;}
+case 7:
+#line 27 "rparse.y"
+{ assignKeyVal (yyvsp[-2], yyvsp[0]); ;
+ break;}
+case 8:
+#line 29 "rparse.y"
+{ assignKeyStr (yyvsp[-2], yytext); ;
+ break;}
+case 9:
+#line 32 "rparse.y"
+{ yyval=yyvsp[0]; ;
+ break;}
+case 10:
+#line 33 "rparse.y"
+{ yyval=yyvsp[0]; ;
+ break;}
+case 11:
+#line 34 "rparse.y"
+{ yyval=yyvsp[0]; ;
+ break;}
+case 12:
+#line 35 "rparse.y"
+{ yyval=yyvsp[0]; ;
+ break;}
+case 13:
+#line 36 "rparse.y"
+{ yyval=yyvsp[0]; ;
+ break;}
+case 14:
+#line 37 "rparse.y"
+{ yyval=yyvsp[0]; ;
+ break;}
+case 15:
+#line 38 "rparse.y"
+{ yyval=yyvsp[0]; ;
+ break;}
+case 16:
+#line 39 "rparse.y"
+{ yyval=yyvsp[0]; ;
+ break;}
+case 17:
+#line 40 "rparse.y"
+{ yyval=yyvsp[0]; ;
+ break;}
+case 18:
+#line 41 "rparse.y"
+{ yyval=yyvsp[0]; ;
+ break;}
+case 19:
+#line 42 "rparse.y"
+{ yyval=yyvsp[0]; ;
+ break;}
+case 20:
+#line 43 "rparse.y"
+{ yyval=yyvsp[0]; ;
+ break;}
+}
+ /* the action file gets copied in in place of this dollarsign */
+#line 498 "bison.simple"
+\f
+ yyvsp -= yylen;
+ yyssp -= yylen;
+#ifdef YYLSP_NEEDED
+ yylsp -= yylen;
+#endif
+
+#if YYDEBUG != 0
+ if (yydebug)
+ {
+ short *ssp1 = yyss - 1;
+ fprintf (stderr, "state stack now");
+ while (ssp1 != yyssp)
+ fprintf (stderr, " %d", *++ssp1);
+ fprintf (stderr, "\n");
+ }
+#endif
+
+ *++yyvsp = yyval;
+
+#ifdef YYLSP_NEEDED
+ yylsp++;
+ if (yylen == 0)
+ {
+ yylsp->first_line = yylloc.first_line;
+ yylsp->first_column = yylloc.first_column;
+ yylsp->last_line = (yylsp-1)->last_line;
+ yylsp->last_column = (yylsp-1)->last_column;
+ yylsp->text = 0;
+ }
+ else
+ {
+ yylsp->last_line = (yylsp+yylen-1)->last_line;
+ yylsp->last_column = (yylsp+yylen-1)->last_column;
+ }
+#endif
+
+ /* Now "shift" the result of the reduction.
+ Determine what state that goes to,
+ based on the state we popped back to
+ and the rule number reduced by. */
+
+ yyn = yyr1[yyn];
+
+ yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
+ if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+ yystate = yytable[yystate];
+ else
+ yystate = yydefgoto[yyn - YYNTBASE];
+
+ goto yynewstate;
+
+yyerrlab: /* here on detecting error */
+
+ if (! yyerrstatus)
+ /* If not already recovering from an error, report this error. */
+ {
+ ++yynerrs;
+
+#ifdef YYERROR_VERBOSE
+ yyn = yypact[yystate];
+
+ if (yyn > YYFLAG && yyn < YYLAST)
+ {
+ int size = 0;
+ char *msg;
+ int x, count;
+
+ count = 0;
+ /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
+ for (x = (yyn < 0 ? -yyn : 0);
+ x < (sizeof(yytname) / sizeof(char *)); x++)
+ if (yycheck[x + yyn] == x)
+ size += strlen(yytname[x]) + 15, count++;
+ msg = (char *) malloc(size + 15);
+ if (msg != 0)
+ {
+ strcpy(msg, "parse error");
+
+ if (count < 5)
+ {
+ count = 0;
+ for (x = (yyn < 0 ? -yyn : 0);
+ x < (sizeof(yytname) / sizeof(char *)); x++)
+ if (yycheck[x + yyn] == x)
+ {
+ strcat(msg, count == 0 ? ", expecting `" : " or `");
+ strcat(msg, yytname[x]);
+ strcat(msg, "'");
+ count++;
+ }
+ }
+ yyerror(msg);
+ free(msg);
+ }
+ else
+ yyerror ("parse error; also virtual memory exceeded");
+ }
+ else
+#endif /* YYERROR_VERBOSE */
+ yyerror("parse error");
+ }
+
+ goto yyerrlab1;
+yyerrlab1: /* here on error raised explicitly by an action */
+
+ if (yyerrstatus == 3)
+ {
+ /* if just tried and failed to reuse lookahead token after an error, discard it. */
+
+ /* return failure if at end of input */
+ if (yychar == YYEOF)
+ YYABORT;
+
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
+#endif
+
+ yychar = YYEMPTY;
+ }
+
+ /* Else will try to reuse lookahead token
+ after shifting the error token. */
+
+ yyerrstatus = 3; /* Each real token shifted decrements this */
+
+ goto yyerrhandle;
+
+yyerrdefault: /* current state does not do anything special for the error token. */
+
+#if 0
+ /* This is wrong; only states that explicitly want error tokens
+ should shift them. */
+ yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
+ if (yyn) goto yydefault;
+#endif
+
+yyerrpop: /* pop the current state because it cannot handle the error token */
+
+ if (yyssp == yyss) YYABORT;
+ yyvsp--;
+ yystate = *--yyssp;
+#ifdef YYLSP_NEEDED
+ yylsp--;
+#endif
+
+#if YYDEBUG != 0
+ if (yydebug)
+ {
+ short *ssp1 = yyss - 1;
+ fprintf (stderr, "Error: state stack now");
+ while (ssp1 != yyssp)
+ fprintf (stderr, " %d", *++ssp1);
+ fprintf (stderr, "\n");
+ }
+#endif
+
+yyerrhandle:
+
+ yyn = yypact[yystate];
+ if (yyn == YYFLAG)
+ goto yyerrdefault;
+
+ yyn += YYTERROR;
+ if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
+ goto yyerrdefault;
+
+ yyn = yytable[yyn];
+ if (yyn < 0)
+ {
+ if (yyn == YYFLAG)
+ goto yyerrpop;
+ yyn = -yyn;
+ goto yyreduce;
+ }
+ else if (yyn == 0)
+ goto yyerrpop;
+
+ if (yyn == YYFINAL)
+ YYACCEPT;
+
+#if YYDEBUG != 0
+ if (yydebug)
+ fprintf(stderr, "Shifting error token, ");
+#endif
+
+ *++yyvsp = yylval;
+#ifdef YYLSP_NEEDED
+ *++yylsp = yylloc;
+#endif
+
+ yystate = yyn;
+ goto yynewstate;
+}
+#line 46 "rparse.y"
+
+
+
diff --git a/src/util/romparse_c6472/rparse.tab.h b/src/util/romparse_c6472/rparse.tab.h
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef YYSTYPE
+#define YYSTYPE int
+#endif
+#define LBRACE 258
+#define RBRACE 259
+#define SECTION 260
+#define EQU 261
+#define VALUE 262
+#define STRING 263
+#define BOOT_MODE 264
+#define PARAM_INDEX 265
+#define OPTIONS 266
+#define MULTI_I2C_ID 267
+#define MY_I2C_ID 268
+#define CORE_FREQ_MHZ 269
+#define I2C_CLK_FREQ_KHZ 270
+#define EXE_FILE 271
+#define PCI_PARMS 272
+#define NEXT_DEV_ADDR 273
+#define NEXT_DEV_ADDR_EXT 274
+#define ADDRESS_DELAY 275
+#define SWPLL 276
+
+
+extern YYSTYPE yylval;
diff --git a/src/util/romparse_c6472/rparse.y b/src/util/romparse_c6472/rparse.y
--- /dev/null
@@ -0,0 +1,48 @@
+/* Parse the parameter spec */
+%{
+#define YYERROR_VERBOSE
+extern char *yytext;
+%}
+%token LBRACE RBRACE SECTION EQU VALUE STRING BOOT_MODE PARAM_INDEX OPTIONS
+%token MULTI_I2C_ID MY_I2C_ID CORE_FREQ_MHZ I2C_CLK_FREQ_KHZ
+%token EXE_FILE PCI_PARMS NEXT_DEV_ADDR NEXT_DEV_ADDR_EXT ADDRESS_DELAY SWPLL
+%%
+
+promspec : bootParams
+ | promspec bootParams
+ ;
+
+bootParams : SECTION LBRACE assigns RBRACE
+ { section (); }
+ | PCI_PARMS EQU STRING
+ { setPciParams (yytext); }
+ ;
+
+
+assigns : assign
+ | assigns assign
+ ;
+
+assign : keyword EQU VALUE
+ { assignKeyVal ($1, $3); }
+ | keyword EQU STRING
+ { assignKeyStr ($1, yytext); }
+ ;
+
+keyword : BOOT_MODE { $$=$1; }
+ | PARAM_INDEX { $$=$1; }
+ | OPTIONS { $$=$1; }
+ | MULTI_I2C_ID { $$=$1; }
+ | MY_I2C_ID { $$=$1; }
+ | CORE_FREQ_MHZ { $$=$1; }
+ | I2C_CLK_FREQ_KHZ { $$=$1; }
+ | EXE_FILE { $$=$1; }
+ | NEXT_DEV_ADDR { $$=$1; }
+ | NEXT_DEV_ADDR_EXT { $$=$1; }
+ | ADDRESS_DELAY { $$=$1; }
+ | SWPLL { $$=$1; }
+ ;
+
+%%
+
+
diff --git a/src/util/romparse_c6472/tiboot.h b/src/util/romparse_c6472/tiboot.h
--- /dev/null
@@ -0,0 +1,545 @@
+#ifndef __TIBOOT_H__
+#define __TIBOOT_H__
+/******************************************************************************
+ * FILE PURPOSE: Define Structures, MACROs and etc for TI Shared ROM Boot
+ ******************************************************************************
+ * FILE NAME: tiboot.h
+ *
+ * DESCRIPTION: Define structures, macros and etc for the TI Shared ROM boot
+ * process.
+ *
+ * TABS: NONE
+ *
+ * $Id: $
+ *
+ * REVISION HISTORY:
+ *
+ * $Log: $
+ *
+ * (C) Copyright 2004 TELOGY Networks, Inc.
+ ******************************************************************************/
+#include "types.h"
+
+/*******************************************************************************
+ * Utility Macro definitions
+ ******************************************************************************/
+#define HEX_DIGIT(digit) ((digit) + '0')
+#define BOOT_BIT_TO_MASK(bit) (1 << (bit))
+
+/*******************************************************************************
+ * Data Definition: Error Handling relatBOOT_ENTRY_POINT_ADDRed definition:
+ *******************************************************************************
+ * Description: Define Handling related macros, constants
+ *
+ ******************************************************************************/
+/* Define Module IDs */
+#define BOOT_MODULE_ID_MAIN 0
+#define BOOT_MODULE_ID_BTBL 1
+#define BOOT_MODULE_ID_BETH 2
+#define BOOT_MODULE_ID_I2C 3
+#define BOOT_MODULE_ID_CHIP 4
+#define BOOT_MODULE_ID_HW 5
+
+/* Boot error codes */
+enum {
+ BOOT_NOERR = 0,
+ BOOT_ERROR = 1, /* General error */
+ BOOT_INVALID_BOOT_MODE = 2,
+ BOOT_INVALID_I2C_DEV_ADDR = 3,
+ BOOT_INVALID_CHECKSUM = 4, /* Invalid checksum of the boot parameters */
+ BOOT_INVALID_PARAMS_SIZE = 5, /* the size of boot parameters is too big */
+ BOOT_RX_ETH_QUEUE_FULL = 6, /* ethmain.c, hw_rxPacket */
+ BOOT_CACHE_INIT_FAIL = 7, /* rmain.c, cache init failed */
+ BOOT_CACHE_DISABLE_FAIL = 8, /* rmain.c, cache disable failed */
+ BOOT_INVALID_CPPI_SIZE = 9, /* ethmain.c, invalid compile sizes */
+ BOOT_INVALID_CORE_ID = 10, /* Invalid core ID in cold boot */
+ BOOT_INVALID_MAC_ADDR = 11, /* Invalid MAC address (all 0's) */
+ BOOT_ETH_TX_SCRATCH = 12, /* tx scratch size invalid */
+ BOOT_ETH_TX_PACKET = 13, /* tx packet formation failure */
+ BOOT_ETH_MAC_INIT = 14, /* ethmain.c - mac init failed */
+ BOOT_PERIPH_POWER = 15, /* peripheral failed to powerup */
+ BOOT_MAIN_FAIL = 16 /* Failed in initial boot setup (wrong core) */
+};
+
+/* Error tracking prototypes (functions in rmain.c)*/
+void bootException (UINT16 errorCode);
+void bootError (UINT16 errorCode);
+
+/* Error code = (module ID * 100) + module specific error */
+#define BOOT_ERROR_CODE(id, code) ((UINT16)((id<<8) + code))
+#define BOOT_EXCEPTION(error_code) bootException(error_code)
+#define BOOT_ERROR(error_code) bootError(error_code)
+
+/*******************************************************************************
+ * Begin Boot Parameter definitions
+ ******************************************************************************/
+
+/*******************************************************************************
+ * Boot Parameter Common
+ ******************************************************************************/
+typedef struct boot_params_common_s{
+ UINT16 length; /* size of the entire boot parameters in bytes */
+ UINT16 checksum; /* non-zero: 1's complement checksum of the boot
+ * parameters
+ * zero: checksum is not applicable
+ */
+ UINT16 boot_mode;
+ UINT16 portNum;
+ UINT16 swPll; /* CPU PLL multiplier */
+
+
+} BOOT_PARAMS_COMMON_T;
+
+typedef struct boot_params_ethernet_s{
+
+ /* common portion of the Boot parameters */
+ UINT16 length;
+ UINT16 checksum;
+ UINT16 boot_mode;
+ UINT16 portNum;
+ UINT16 swPll; /* CPU PLL multiplier */
+
+ /* Etherent specific portion of the Boot Parameters */
+ UINT16 options;
+ /*
+ * Ethernet Specific Options
+ *
+ * Bits 2:0 interface
+ * 000 - MII
+ * 001 - RMII
+ * 010 - GMII
+ * 011 - RGMII
+ * 100 - SMII
+ * 101 - S3MII
+ * 110 - RMII 10Mbs
+ * 111 - RMII 100Mbs
+ *
+ * Bit 3: HD:
+ * 0 - Full Duplex
+ * 1 - Half Duplex
+ * Bit 4: SKIP TX
+ * 0 - Send the Ethernet Ready Frame
+ * 1 - Skip sending the Ethernet Ready Frame
+ * Bit 5: SKIP INIT
+ * 0 - Initialize the Ethernet MAC peripheral
+ * 1 - Skip initializing the Ethernet MAC peripheral
+ * Bit 6: FC
+ * 0 - Disable Flow Control
+ * 1 - Enable Flow Control
+ *
+ * Other bits: Reserved
+ */
+ #define BOOT_PARAMS_ETH_OPTIONS_MII 0x0000
+ #define BOOT_PARAMS_ETH_OPTIONS_RMII 0x0001
+ #define BOOT_PARAMS_ETH_OPTIONS_GMII 0x0002
+ #define BOOT_PARAMS_ETH_OPTIONS_RGMII 0x0003
+ #define BOOT_PARAMS_ETH_OPTIONS_SMII 0x0004
+ #define BOOT_PARAMS_ETH_OPTIONS_S3MII 0x0005
+ #define BOOT_PARAMS_ETH_OPTIONS_RMII_10 0x0006
+ #define BOOT_PARAMS_ETH_OPTIONS_RMII_100 0x0007
+
+ #define BOOT_PARAMS_ETH_OPTIONS_HD 0x0008
+ #define BOOT_PARAMS_ETH_OPTIONS_SKIP_TX 0x0010
+ #define BOOT_PARAMS_ETH_OPTIONS_SKIP_INIT 0x0020
+ #define BOOT_PARAMS_ETH_OPTIONS_FC 0x0040
+
+ /*
+ * he device MAC address to be used for Boot:
+ * All zero mac address indicates that the device E-fuse address should
+ * be used.
+ */
+ UINT16 mac_addr_h;
+ UINT16 mac_addr_m;
+ UINT16 mac_addr_l;
+
+ /*
+ * The multicast or broadcast MAC address which should be accepted as
+ * a destination MAC address for boot table frames
+ */
+ UINT16 mmac_addr_h;
+ UINT16 mmac_addr_m;
+ UINT16 mmac_addr_l;
+
+ UINT16 src_port; /* Source UDP port number to be used during boot process */
+ /* 0: allow any SRC UDP port */
+ UINT16 dest_port; /* Destination UDP port number to be used during boot process */
+
+ /* The Device ID to be included in the boot ready announcement frame */
+ UINT16 device_id_12;
+ UINT16 device_id_34;
+ #define BOOT_PARAMS_DEVICE_ID_HIGH_MASK 0xFF00
+ #define BOOT_PARAMS_DEVICE_ID_HIGH_SHIFT 8
+ #define BOOT_PARAMS_DEVICE_ID_LOW_MASK 0x00FF
+ #define BOOT_PARAMS_DEVICE_ID_LOW_SHIFT 0
+ #define BOOT_PARAMS_GET_DEVICE_ID_13(device_id) \
+ (((device_id) & BOOT_PARAMS_DEVICE_ID_HIGH_MASK) > BOOT_PARAMS_DEVICE_ID_HIGH_SHIFT)
+ #define BOOT_PARAMS_GET_DEVICE_ID_24(device_id) \
+ (((device_id) & BOOT_PARAMS_DEVICE_ID_LOW_MASK) > BOOT_PARAMS_DEVICE_ID_LOW_SHIFT)
+
+ /*
+ * The destination MAC address used for the boot ready announce frame
+ */
+ UINT16 hmac_addr_h;
+ UINT16 hmac_addr_m;
+ UINT16 hmac_addr_l;
+
+} BOOT_PARAMS_ETHERNET_T;
+
+/**************************************************************************************
+ * Utopia boot options
+ **************************************************************************************/
+typedef struct boot_params_utopia_s{
+
+ /* common portion of the Boot parameters */
+ UINT16 length;
+ UINT16 checksum;
+ UINT16 boot_mode;
+ UINT16 portNum;
+ UINT16 swPll; /* CPU PLL multiplier */
+
+ /* Utopia specific portion of the Boot Parameters */
+ /* Options
+ * ---------------------------------------------------------------
+ * | 15 3 | 2 | 1 | 0 |
+ * ----------------------------------------------------------------
+ * reserved | | \-> 0 = multi phy
+ * | | 1 = single phy
+ * | \-> 0 = 8 bit utopia
+ * | 1 = 16 bit utopis
+ * \-> 0 = Init port
+ * 1 = skip port init
+ */
+ UINT16 options;
+
+ #define BOOT_PARAMS_UTOPIA_SINGLE_PHY (1<<0)
+ #define BOOT_PARAMS_UTOPIA_16BIT (1<<1)
+ #define BOOT_PARAMS_UTOPIA_SKIP_INIT (1<<2)
+
+ UINT16 cellSizeBytes; /* Cell Size */
+ UINT16 busWidthBits; /* Bus width (8 or 16) */
+ UINT16 slid; /* Slave ID */
+ UINT16 coreFreqMhz; /* CPU frequency after pll mult */
+
+
+} BOOT_PARAMS_UTOPIA_T;
+
+typedef struct boot_params_i2c_s{
+
+ /* common portion of the Boot parameters */
+ UINT16 length;
+ UINT16 checksum;
+ UINT16 boot_mode;
+ UINT16 portNum;
+ UINT16 swPll; /* CPU PLL multiplier */
+
+ /* I2C specific portion of the Boot Parameters */
+ UINT16 options;
+ /*
+ * I2C Specific Options
+ * Bit 01-00: BT:
+ * 00 - Boot Parameter Mode
+ * 01 - Boot Table Mode
+ * 10 - Boot Config mode
+ * 11 - Slave receive boot config
+ * Bit 04-02: EETYPE: EEPROM type
+ * Other bits: Reserved
+ */
+ #define BOOT_PARAMS_I2C_OPTIONS_BP 0x0000
+ #define BOOT_PARAMS_I2C_OPTIONS_BT 0x0001
+ #define BOOT_PARAMS_I2C_OPTIONS_BC 0x0002
+ #define BOOT_PARAMS_I2C_OPTIONS_SLVOPT 0x0003
+
+ #define BOOT_PARAMS_I2C_OPTIONS_MASK 0x0003
+ #define BOOT_PARAMS_I2C_OPTIONS_SHIFT 0
+
+ #define BOOT_PARAMS_I2C_OPTIONS_EETYPE_MASK 0x001C
+ #define BOOT_PARAMS_I2C_OPTIONS_EETYPE_SHIFT 2
+
+ #define BOOT_PARAMS_I2C_IS_BOOTTBL_MODE(options) \
+ (((options) & BOOT_PARAMS_I2C_OPTIONS_MASK) == BOOT_PARAMS_I2C_OPTIONS_BT)
+
+ #define BOOT_PARAMS_I2C_IS_BOOTCONFIG_MODE(options) \
+ (((options) & BOOT_PARAMS_I2C_OPTIONS_MASK) == BOOT_PARAMS_I2C_OPTIONS_BC)
+
+ #define BOOT_PARAMS_I2C_IS_SLAVE_RCV_OPTIONS_MODE(options) \
+ (((options) & BOOT_PARAMS_I2C_OPTIONS_MASK) == BOOT_PARAMS_I2C_OPTIONS_SLVOPT)
+
+ #define BOOT_PARAMS_I2C_IS_BOOTPARAM_MODE(options) \
+ (((options) & BOOT_PARAMS_I2C_OPTIONS_MASK) == BOOT_PARAMS_I2C_OPTIONS_BP)
+
+ #define BOOT_PARAMS_I2C_SET_BOOTTBL_MODE(options, mode) \
+ (options) = ((options) & ~BOOT_PARAMS_I2C_OPTIONS_MASK) | \
+ (((mode) & BOOT_PARAMS_I2C_OPTIONS_MASK) << \
+ BOOT_PARAMS_I2C_OPTIONS_SHIFT)
+
+
+ #define BOOT_PARAMS_I2C_GET_EETYPE(options) \
+ (((options) & BOOT_PARAMS_I2C_OPTIONS_EETYPE_MASK) >> BOOT_PARAMS_I2C_OPTIONS_EETYPE_SHIFT)
+ #define BOOT_PARAMS_I2C_SET_EETYPE(options, ee_type) \
+ (options) = (((options) & ~BOOT_PARAMS_I2C_OPTIONS_EETYPE_MASK) | \
+ (((ee_type) << BOOT_PARAMS_I2C_OPTIONS_EETYPE_SHIFT) & BOOT_PARAMS_I2C_OPTIONS_EETYPE_MASK))
+
+ /* The device address to be used for Boot */
+ UINT16 dev_addr; /* 16-bit device address (low) */
+ UINT16 dev_addr_ext; /* 16-bit extended device address (high)
+ * set to zero if not used
+ * Note: some I2C device requires 32-bit
+ * address
+ */
+ UINT16 multi_i2c_id; /* Multi device master write boot ID */
+ UINT16 my_i2c_id; /* This parts I2C address */
+
+ UINT16 core_freq_mhz; /* Core frequency, MHz */
+ UINT16 i2c_clk_freq_khz; /* Desired I2C clock frequency, kHz */
+
+ UINT16 next_dev_addr; /* Used only for the boot config mode. */
+ UINT16 next_dev_addr_ext; /* Copied into dev_addr* after config complete */
+
+ UINT16 address_delay; /* Rough number of cycles delay between address write
+ * and read to the i2c eeprom */
+
+
+} BOOT_PARAMS_I2C_T;
+
+
+typedef struct boot_params_rapidio_s{
+
+ /* common portion of the Boot parameters */
+ UINT16 length;
+ UINT16 checksum;
+ UINT16 boot_mode;
+ UINT16 portNum;
+ UINT16 swPll; /* CPU PLL multiplier */
+
+ /* Options */
+ UINT16 options;
+
+ #define BOOT_PARAMS_RIO_OPTIONS_TX_ENABLE (1<<0) /* set to enable transmit */
+ #define BOOT_PARAMS_RIO_OPTIONS_BOOT_TABLE (1<<1) /* set to use boot tables */
+ #define BOOT_PARAMS_RIO_OPTIONS_NO_CONFIG (1<<2) /* set to bypass port config */
+
+ UINT16 cfg_index; /* General configuration index to use */
+ UINT16 node_id; /* The node id for this device */
+ UINT16 serdes_ref_clk; /* The serdes reference clock freq, in hundredths
+ * of MHz (1 MHz would be 100) */
+ UINT16 link_rate; /* Data link rate (mega bits per second */
+ UINT16 pf_low; /* Packet forward range, low */
+ UINT16 pf_high; /* Packet forward range, high */
+
+} BOOT_PARAMS_RIO_T;
+
+/*
+ * UNION of boot parameter structures in all modes
+ * Note: We need to make sure that the structures genertaed by the C-compiler
+ * match with the boot parameter table data format i.e. a set of 16-bit
+ * data array.
+ */
+#define BOOT_PARAMS_SIZE_IN_BYTES 128
+typedef union {
+ BOOT_PARAMS_COMMON_T common;
+ BOOT_PARAMS_ETHERNET_T eth;
+ BOOT_PARAMS_I2C_T i2c;
+ BOOT_PARAMS_UTOPIA_T utopia;
+ BOOT_PARAMS_RIO_T rio;
+ UINT16 parameter[BOOT_PARAMS_SIZE_IN_BYTES/2];
+} BOOT_PARAMS_T;
+
+
+/*******************************************************************************
+ * Definition: The time stamp and version number are placed into the stats.
+ * This will be two characters packed per 16bits . The length
+ * value must be 32 bit divisible
+ *******************************************************************************/
+#define BOOT_VERSION_LEN_UINT16 32
+typedef struct BOOT_VERSION_S {
+
+ UINT16 vstring[BOOT_VERSION_LEN_UINT16];
+
+} BOOT_VERSION_T;
+extern BOOT_VERSION_T bootVersion;
+
+
+/*******************************************************************************
+ * Definition: Runs time stats that are not initialized on cold boot entry
+ * !!!!!! boot.s assumes that the nonInit stats are at the top of the structure
+ * !!!!!! and that stage is the first element
+ *******************************************************************************/
+typedef struct BOOT_STATS_NONINIT_S {
+ UINT16 stage; /* Record the SharedROM code execution stage */
+ #define BOOT_STAGE_ASM_START_UP 1
+ #define BOOT_STAGE_INIT_CACHE 2
+ #define BOOT_STAGE_CHCHE_INITED 3
+ #define BOOT_STAGE_ENTER_WARMBOOT 4
+ #define BOOT_STAGE_INIT_CPGMAC 5
+ #define BOOT_STAGE_SEND_ERA_FRAME 6
+ #define BOOT_STAGE_ETH_MAIN_LOOP 7
+ #define BOOT_STAGE_I2C_BOOTTBL_LOOP 8
+ #define BOOT_STAGE_I2C_BOOTPARAM_LOOP 9
+ #define BOOT_STAGE_DISABLE_CACHE 10
+ #define BOOT_STAGE_CHCHE_DISABLED 11
+ #define BOOT_STAGE_EXIT 12
+ #define BOOT_STAGE_ERROR_LOOP 13
+ #define BOOT_STAGE_I2C_BOOTCONFIG_LOOP 14
+ #define BOOT_STAGE_I2C_SLV_RCV_OPTIONS_LOOP 15
+ #define BOOT_STAGE_UTOPIA_MAIN_LOOP 16
+ UINT16 coldBootEntries;
+
+} BOOT_STATS_NONINIT_T;
+
+/*******************************************************************************
+ * Definition: Run time statistics and error counts. These stats are
+ * initialized on cold boot entry.
+ ******************************************************************************/
+
+typedef struct BOOT_STATS_COMMON_S {
+ UINT32 bootStatus;
+ UINT16 nColdBootEntries;
+ UINT16 nBootReentries;
+ UINT16 nPllWarns;
+ UINT16 nResetWarns;
+} BOOT_STATS_COMMON_T;
+
+
+typedef struct BOOT_STATS_MAIN_S {
+ UINT16 errorCode; /* (module ID <<8 ) + module specific error */
+
+ /* I2C operation related statistics */
+ UINT16 numI2Cpkts; /* number of I2C boot table packets processed */
+ UINT16 numI2CchksumError;/* number of I2C checksum errors */
+ UINT16 numI2ClengthError;/* number of I2C block length errors */
+ UINT16 numI2CotherError; /* number of I2C section with invalid length and etc */
+ UINT16 numI2Cretrys; /* number of I2C retrys due to read access errors */
+ UINT16 numI2cWrites; /* number of I2C master writes to passive devices */
+ UINT16 numI2cWriteError; /* number of I2C master write errors */
+
+ UINT16 warmBootEntry; /* Count of entries into warm boot routine */
+} BOOT_STATS_MAIN_T;
+
+
+
+/*****************************************************************************
+ * Definition: I2C stats, Boot table and Ethernrt stats initialized
+ * on cold boot entry
+ *****************************************************************************/
+typedef struct I2C_STATS_tag
+{
+ UINT16 num_trans;
+ UINT16 num_trys;
+ UINT16 num_try_ok;
+ UINT16 num_try_lost_arb;
+ UINT16 num_try_idle_to;
+ UINT16 num_try_no_ack;
+ UINT16 num_try_other_err;
+ UINT32 extra_idle_waits;
+ UINT32 extra_clock_waits;
+ UINT32 tx_bytes;
+ UINT32 rx_bytes;
+ UINT32 data_re_reads;
+} I2C_STATS_T;
+
+typedef struct BTBL_STATS_tag
+{
+ UINT16 num_sections; /* number of boot table sections received */
+ UINT16 num_pdma_copies; /* number of PDMA copies performed */
+} BTBL_STATS_T;
+
+typedef struct ETH_STATS_tag
+{
+ /* MAC packets related statistics */
+ UINT16 uniMacPkts; /* Count of packets received with valid unicast mac
+ address */
+ UINT16 multiMacPkts; /* Count of packets received with valid multicast or
+ broadcast mac address */
+ UINT16 invalidMacPkts; /* Count of packets received with invalid mac
+ address */
+ UINT16 invalidLLCPkts; /* Count of 802.3 packets with wrong LLC/SNAP header */
+ UINT16 nonIpPkts; /* Count of non-IP packets received with valid
+ MAC address */
+
+ /* IP packets related statistics */
+ UINT16 nonIP4Pkts; /* Count of non-IP4 packets */
+ UINT16 ipfragments; /* Count of IP fragments received */
+ UINT16 ipTruncatedError; /* Count of truncated IP frame */
+ UINT16 nonUDPPkts; /* Count of IP packets with non-UDP paylaod */
+
+ /* UDP packets related statistics */
+ UINT16 udpSizeError; /* Count of UDP packet with invalid (odd) size */
+ UINT16 udpPortError; /* Count of UDP packets with invalid port number */
+ UINT16 udpChksumError; /* Count of UDP packets with checksum error */
+
+ /* Boot table packets related statistics */
+ UINT16 nonBtblPkts; /* Count of UDP packets with invalid boot table paylaod */
+ UINT16 outSeqPkts; /* Count of out of sequence boot table packets received
+ i.e. packets with unexpected seq_num */
+ UINT16 expSeqNum; /* Expected Sequence Number */
+ UINT16 lastSeqNum; /* Last sequence number received */
+
+ /* Driver errors */
+ UINT16 sizeZeroPackets; /* Count of packets arriving with 0 size */
+} ETH_STATS_T;
+
+typedef struct PCI_EEAI_STATS_tag
+{
+ UINT16 pciI2cReads; /* Count of block reads of i2c eeprom */
+ UINT16 pciI2cRetries; /* Count of i2c read retries */
+ UINT16 pciChkSumErr; /* Count of block check sum errors */
+ UINT16 pciEeaiFail; /* Count of aborted pci attempts */
+} PCI_EEAI_STATS_T;
+
+/* Rapid I/O stats */
+typedef struct RAPIDIO_STATS_tag
+{
+ UINT16 rapidIoFailReady; /* If set rapid I/O peripheral failed to report ready */
+ UINT16 rapidIoBtblBlocks; /* Count of number of boot table blocks received */
+ UINT16 rapidIoBtblBadBlocks; /* Count of boot table blocks rejected */
+} RAPIDIO_STATS_T;
+
+typedef struct HPI_STATS_Tag
+{
+ UINT16 hpiBtblBlocks; /* Count of boot table blocks received */
+ UINT16 hpiBtblBadBlocks; /* Count of boot table blocks rejected */
+} HPI_STATS_T;
+
+/* Utopia stats */
+typedef struct UTOPIA_STATS_tag
+{
+ UINT16 cellCount; /* Count of cells received */
+ UINT16 invalidPtr; /* Count of invalid pointers received in processing */
+ UINT16 invalidSize; /* Count of cells that were too small */
+ UINT16 cellMagicCount; /* Count of cells received with valid magic */
+ UINT16 cellMagicFailed; /* Count of cells received with invalid magic */
+ UINT16 trapNoCellMem; /* Trapped due to no cell space in memory */
+ UINT16 possibleOverrun; /* Count of possible cell buffer overruns */
+} UTOPIA_STATS_T;
+
+/*******************************************************************************
+ * Definition: The statistics
+ *
+ * !!!!!! boot.s assumes that the nonInit stats are at the top of the structure!
+ *******************************************************************************/
+typedef struct BOOT_STATS_S {
+
+ BOOT_STATS_COMMON_T common;
+ BOOT_STATS_NONINIT_T nonInit;
+ BOOT_STATS_MAIN_T main;
+ I2C_STATS_T i2c;
+ BTBL_STATS_T btbl;
+ union {
+ ETH_STATS_T eth;
+ PCI_EEAI_STATS_T pci_eeai;
+ RAPIDIO_STATS_T rapidIo;
+ UTOPIA_STATS_T utopia;
+ HPI_STATS_T hpi;
+ } u;
+} BOOT_STATS_T;
+
+extern BOOT_STATS_T bootStats;
+
+/*******************************************************************************
+ * Definition: The magic start address, known to all modules
+ *******************************************************************************/
+extern volatile UINT32 *p_boot_entry_addr;
+
+#endif /* __TIBOOT_H__ */
+
+/* nothing past this point */
diff --git a/src/util/romparse_c6472/types.h b/src/util/romparse_c6472/types.h
--- /dev/null
@@ -0,0 +1,20 @@
+#ifndef _TYPES_H
+#define _TYPES_H
+/**************************************************************************
+ * FILE PURPOSE: Define type values
+ **************************************************************************
+ * FILE NAME: types.h
+ *
+ * DESCRIPTION: File required to read the tiboot.h file directly from
+ * the application.
+ *
+ ***************************************************************************/
+
+typedef unsigned int UINT16;
+typedef unsigned int UINT32;
+typedef unsigned int word;
+
+
+
+
+#endif /* _TYPES_H */
\ No newline at end of file