summaryrefslogtreecommitdiffstats
path: root/data/mnet/GP10/Host/cdcUtils
diff options
context:
space:
mode:
Diffstat (limited to 'data/mnet/GP10/Host/cdcUtils')
-rw-r--r--data/mnet/GP10/Host/cdcUtils/Makefile16
-rw-r--r--data/mnet/GP10/Host/cdcUtils/aux_port/Makefile52
-rw-r--r--data/mnet/GP10/Host/cdcUtils/aux_port/auxPort.c80
-rw-r--r--data/mnet/GP10/Host/cdcUtils/cdcUtils/CPU_Mon.c612
-rw-r--r--data/mnet/GP10/Host/cdcUtils/cdcUtils/Makefile52
-rw-r--r--data/mnet/GP10/Host/cdcUtils/cdcUtils/cdcUtils.c617
-rw-r--r--data/mnet/GP10/Host/cdcUtils/cdcUtils/oamHwInfoSet.c189
-rw-r--r--data/mnet/GP10/Host/cdcUtils/clkInterface/Makefile52
-rw-r--r--data/mnet/GP10/Host/cdcUtils/clkInterface/clkInterface.c1221
-rw-r--r--data/mnet/GP10/Host/cdcUtils/coff_loader/Makefile53
-rw-r--r--data/mnet/GP10/Host/cdcUtils/coff_loader/cload.c1929
-rw-r--r--data/mnet/GP10/Host/cdcUtils/coff_loader/coff.c462
-rw-r--r--data/mnet/GP10/Host/cdcUtils/drfInterface/Makefile52
-rw-r--r--data/mnet/GP10/Host/cdcUtils/drfInterface/drfInterface.c1477
-rw-r--r--data/mnet/GP10/Host/cdcUtils/fpgaConfig/Makefile52
-rw-r--r--data/mnet/GP10/Host/cdcUtils/fpgaConfig/fpgaConfig.c154
-rw-r--r--data/mnet/GP10/Host/cdcUtils/include/clkInterface.h68
-rw-r--r--data/mnet/GP10/Host/cdcUtils/include/cload.h106
-rw-r--r--data/mnet/GP10/Host/cdcUtils/include/coff.h590
-rw-r--r--data/mnet/GP10/Host/cdcUtils/include/coffdefs.h232
-rw-r--r--data/mnet/GP10/Host/cdcUtils/include/header.h35
-rw-r--r--data/mnet/GP10/Host/cdcUtils/include/params.h277
-rw-r--r--data/mnet/GP10/Host/cdcUtils/include/proto.h13
-rw-r--r--data/mnet/GP10/Host/cdcUtils/include/version.h27
24 files changed, 8418 insertions, 0 deletions
diff --git a/data/mnet/GP10/Host/cdcUtils/Makefile b/data/mnet/GP10/Host/cdcUtils/Makefile
new file mode 100644
index 0000000..72afbdd
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/Makefile
@@ -0,0 +1,16 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+##########################################################
+
+SUBDIRS= aux_port fpgaConfig cdcUtils clkInterface coff_loader drfInterface
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..
+
+include $(TOP_OF_VOB)\l3defs.mk
+
+copyall:
+ $(CP) bin\*.out $(TOP_OF_VOB)\bin\*.out \ No newline at end of file
diff --git a/data/mnet/GP10/Host/cdcUtils/aux_port/Makefile b/data/mnet/GP10/Host/cdcUtils/aux_port/Makefile
new file mode 100644
index 0000000..d5832dd
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/aux_port/Makefile
@@ -0,0 +1,52 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..\..
+
+# These Must be Properly Defined
+THIS_APP_DIR = cdcUtils
+THIS_DIRECTORY = auxPort
+MY_OUTPUT = $(OBJDIR)\auxPort.out
+
+# Name(s) of Common VOB directories to include
+COMMON_BLD_DIR =
+
+include $(TOP_OF_VOB)\l3defs.mk
+
+all: makeCommonObjs $(MY_OUTPUT)
+
+# Adds the .o file(s) list needed from the Common VOB
+makeCommonObjs:
+ifneq ($(COMMON_BLD_DIR),)
+ @for %f in ($(COMMON_BLD_DIR)) do \
+ make -C $(COMMON_VOB_APP_DIR)\%f \
+ all VOB=$(VOBNAME) APPDIR=Host\$(THIS_APP_DIR)\$(THIS_DIRECTORY)
+endif
+
+# If Common VOB directories to include get the .o files from bin
+$(MY_OUTPUT): $(MODULE_OBJS)
+ifneq ($(COMMON_BLD_DIR),)
+ $(LD) -r -o $@.tmp $() $(MODULE_OBJS) $(wildcard ./bin/*.o)
+else
+ $(LD) -r -o $@.tmp $() $(MODULE_OBJS)
+endif
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+ifneq ($(COMMON_BLD_DIR),)
+ $(RM) bin\*.o
+ $(RM) bin\*.out
+endif
diff --git a/data/mnet/GP10/Host/cdcUtils/aux_port/auxPort.c b/data/mnet/GP10/Host/cdcUtils/aux_port/auxPort.c
new file mode 100644
index 0000000..2d4e5e9
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/aux_port/auxPort.c
@@ -0,0 +1,80 @@
+/******************************************************************
+
+ (c) Copyright Cisco 2000
+ All Rights Reserved
+
+******************************************************************/
+
+#include <vxWorks.h>
+#include <semLib.h>
+#include "cdcUtils/auxPort.h"
+
+/* external */
+extern int sysAuxPortAddr;
+
+/* global */
+
+/* file local */
+static int auxPortOutCopy;
+
+void auxPortInit()
+{
+ auxPortOutCopy = LED1_OFF | LED2_OFF | LED3_OFF | FAULT_LED_OFF |
+ RF1_EN | RF2_EN | RF_RESET_NOT |
+ DSPA_RST_NOT | DSPB_RST_NOT |
+ FPGA_DCLK | FPGA_DATA;
+ *(UINT*)sysAuxPortAddr = auxPortOutCopy;
+}
+
+
+/******************************************************************************
+auxPortOutSet - aux. port output set
+
+This routine provides a mechanism to set certain bits on the 'write only'
+auxillary output port.
+Set the given vaue at the auxillary output port.
+A bit mask is supplied to indicate which bits are to be set. A '1' in the mask
+indiactes that value for that bit position is to be set. A '0' means that the
+value for that bit position is unchanged.
+
+This routine provides a mechanism to set certain bits on the 'write only'
+auxillary output port. This fuction maintance a copy of the aux. output and
+provides mutual exclusion.
+
+This routine should be called to write to the auxillary output port. This is
+*/
+void auxPortOutSet
+(
+ int val, /* value to write to aux out port */
+ int mask /* bit mask with which to set the value */
+)
+{
+ int lock;
+
+
+/* semTake(auxPortSem, WAIT_FOREVER); */
+ taskLock();
+
+ lock = intLock(); /* lock interrupts */
+ /* This mechanism is used for mutual exclusion instead of using
+ a semaphore to avoid overhead to guard very small code */
+ auxPortOutCopy = (auxPortOutCopy & ~mask) | (val & mask); /* save the copy */
+ *(UINT*)sysAuxPortAddr = auxPortOutCopy; /* write to the port */
+ intUnlock(lock); /* unlock interrupts */
+
+/* semGive(auxPortSem); */
+ taskUnlock();
+
+
+}
+
+/******************************************************************************
+auxPortOutGet - aux Port Output Get
+
+Returns the value of aux. output port
+*/
+UINT auxPortOutGet()
+{
+ return auxPortOutCopy;
+}
+
diff --git a/data/mnet/GP10/Host/cdcUtils/cdcUtils/CPU_Mon.c b/data/mnet/GP10/Host/cdcUtils/cdcUtils/CPU_Mon.c
new file mode 100644
index 0000000..c4d1fa9
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/cdcUtils/CPU_Mon.c
@@ -0,0 +1,612 @@
+/******************************************************************
+
+ (c) Copyright Cisco 2000
+ All Rights Reserved
+
+******************************************************************/
+
+/********************************************************************
+*
+* FILE NAME: CPU_Mon.c
+*
+* DESCRIPTION: This file contains routines for the DS1780.
+*
+* NOTES:
+*
+* VERSION: 1.0 10/06/99 14:45:15
+*
+* SCCS ID: "@(#)CPU_Mon.c"
+*
+********************************************************************/
+
+#include <vxWorks.h>
+#include "CDC_BSP/i2c.h"
+#include "cdcUtils/CPU_Mon_IF.h"
+
+/* if defined it will include test modules. */
+#define DS1780_TEST
+
+
+/************* Static Globals *****************/
+
+static UINT8 Chassis_Intrusion = 0x00;
+
+static UINT8 DS1780_ADDR = 0x2C;
+static int _1_CHAR = 0x01;
+
+static UINT8 CONFIG_REG = 0x40;
+static UINT8 INIT_REGS = 0x80;
+static UINT8 MONITOR_MODE = 0x01;
+
+static UINT8 INTR_STAT_1_REG = 0x41;
+static UINT8 INTR_1_STATUS_MASK = 0x1D;
+
+static UINT8 INTR_STAT_2_REG = 0x42;
+static UINT8 INTR_2_STATUS_MASK = 0x10;
+
+static UINT8 INTR_1_MASK_REG = 0x43;
+static UINT8 INTR_1_MASK = 0xC2;
+
+static UINT8 INTR_2_MASK_REG = 0x44;
+static UINT8 INTR_2_MASK = 0x03;
+
+static UINT8 CHASSIS_INTR_CLR_REG = 0x46;
+static UINT8 CLR_CHASSIS_INTR = 0x80;
+
+static UINT8 SER_ADDR_REG = 0x48;
+static UINT8 DEFAULT_ADDR = 0x2C;
+
+static UINT8 TEMP_CFG_REG = 0x4B;
+static UINT8 DISABLE_INTRS = 0x01;
+static UINT8 DEFAULT_INTR_MODE = 0x00;
+static UINT8 NINTH_TEMP_BIT = 0x80;
+
+static UINT8 _2_5_V_Thres_ID = 0x01;
+static UINT8 _1_7_VOLTS = 0x82;
+static UINT8 _2_0_VOLTS = 0x99;
+static UINT8 _3_3_V_Thres_ID = 0x02;
+static UINT8 _3_1_VOLTS = 0xB4;
+static UINT8 _3_5_VOLTS = 0xCB;
+static UINT8 _5_V_Thres_ID = 0x04;
+static UINT8 _4_75_VOLTS = 0xB6;
+static UINT8 _5_2_VOLTS = 0xC7;
+
+/***** Value RAM Definitions ******************/
+
+static UINT8 _2_5_V_READING_ADDR = 0x20;
+static UINT8 _3_3_V_READING_ADDR = 0x22;
+static UINT8 _5_V_READING_ADDR = 0x23;
+
+static UINT8 MSB_TEMP_READING_ADDR = 0x27;
+
+static UINT8 _2_5_HIGH_LIMIT_ADDR = 0x2B;
+static UINT8 _2_5_LOW_LIMIT_ADDR = 0x2C;
+static UINT8 _3_3_HIGH_LIMIT_ADDR = 0x2F;
+static UINT8 _3_3_LOW_LIMIT_ADDR = 0x30;
+static UINT8 _5_HIGH_LIMIT_ADDR = 0x31;
+static UINT8 _5_LOW_LIMIT_ADDR = 0x32;
+
+static UINT8 HOT_TEMP_HIGH_ADDR = 0x39;
+static UINT8 _0_DEGREES = 0x00;
+static UINT8 _45_DEGREES = 0x2D;
+static UINT8 HOT_TEMP_HYST_LOW_ADDR = 0x3A;
+
+static UINT8 CO_ID_NUMBER_ADDR = 0x3E;
+static UINT8 STEPPING_ID_ADDR = 0x3F;
+
+
+/********** Local Prototypes ******************/
+
+STATUS DS1780_Poll(void);
+STATUS DS1780_Init(void);
+STATUS DS1780_Intr_Setup(void);
+STATUS DS1780_Init_Thresholds(void);
+STATUS DS1780_Set_Voltage_Thresholds(UINT8 Threshold_ID, UINT8 High, UINT8 Low);
+STATUS DS1780_Set_Temp_Thresholds(UINT8 High, UINT8 Low);
+STATUS DS1780_I2C_Wr(unsigned char *outch, unsigned char devAddr,
+ unsigned char wAddr, int numChars);
+STATUS DS1780_I2C_Rd(unsigned char *outch, unsigned char devAddr,
+ unsigned char wAddr, int numChars);
+
+#ifdef DS1780_TEST
+
+STATUS DS1780_Rd_Regs(void);
+STATUS DS1780_Rd_Loc(unsigned char Addr);
+STATUS DS1780_Wr_Loc(unsigned char Addr, unsigned char Value);
+STATUS DS1780_Test_Read(void);
+
+#endif
+
+
+/*****************************************************************************
+ *
+ * Module Name: DS1780_Init
+ *
+ * Purpose: Initializes the DS1780 and sets it to its operating mode.
+ *
+ *****************************************************************************/
+
+STATUS DS1780_Init(void)
+{
+ STATUS Result;
+
+ Result = DS1780_I2C_Wr(&INIT_REGS, DS1780_ADDR, CONFIG_REG, _1_CHAR);
+
+ if ( Result == OK )
+ {
+ Result = DS1780_Intr_Setup();
+
+ if ( Result == OK )
+ {
+ Result = DS1780_Init_Thresholds();
+
+ if ( Result == OK )
+ {
+ Result = DS1780_I2C_Wr(&MONITOR_MODE, DS1780_ADDR,
+ CONFIG_REG, _1_CHAR);
+ }
+ }
+ }
+
+ return(Result);
+}
+
+
+/*****************************************************************************
+ *
+ * Module Name: DS1780_Poll
+ *
+ * Purpose: Routine to poll the status of the DS1780 measurements.
+ *
+ *****************************************************************************/
+
+STATUS DS1780_Poll(void)
+{
+ STATUS Result;
+ UINT8 Value;
+
+ Result = DS1780_I2C_Rd(&Value, DS1780_ADDR, INTR_STAT_1_REG, _1_CHAR);
+
+ if ( Result == OK )
+ {
+ if ( (Value & INTR_1_STATUS_MASK) != OK )
+ Result = ERROR;
+ else
+ {
+ Result = DS1780_I2C_Rd(&Value, DS1780_ADDR, INTR_STAT_2_REG, _1_CHAR);
+
+ if ( (Value & INTR_2_STATUS_MASK) != OK )
+ {
+ Chassis_Intrusion = INTR_2_STATUS_MASK;
+
+ Result = ERROR;
+ }
+ }
+ }
+
+ return(Result);
+}
+
+/*****************************************************************************
+ *
+ * Module Name: DS1780_Read
+ *
+ * Purpose: Reads the monitored values of the DS1780 Measurements.
+ *
+ *****************************************************************************/
+
+STATUS DS1780_Read(t_DS1780 *data)
+{
+ STATUS Result;
+ UINT8 Value;
+
+ Result = DS1780_I2C_Rd(&data->_2_5_V_Mon_Value, DS1780_ADDR, _2_5_V_READING_ADDR, _1_CHAR);
+
+ if ( Result == OK )
+ {
+ Result = DS1780_I2C_Rd(&data->_3_3_V_Mon_Value, DS1780_ADDR, _3_3_V_READING_ADDR, _1_CHAR);
+
+ if ( Result == OK )
+ {
+ Result = DS1780_I2C_Rd(&data->_5_V_Mon_Value, DS1780_ADDR, _5_V_READING_ADDR, _1_CHAR);
+
+ if ( Result == OK )
+ {
+ Result = DS1780_I2C_Rd(&data->Temp_Mon_Value, DS1780_ADDR, MSB_TEMP_READING_ADDR, _1_CHAR);
+
+ if ( Result == OK )
+ {
+ data->Chassis_Intrusion_Status = Chassis_Intrusion;
+ Chassis_Intrusion = OK;
+ }
+ }
+ }
+ }
+
+ return(Result);
+}
+
+
+/*****************************************************************************
+ *
+ * Module Name: DS1780_Intr_Setup
+ *
+ * Purpose: Initializes the DS1780 voltage and temperature thresholds.
+ *
+ *****************************************************************************/
+
+STATUS DS1780_Intr_Setup(void)
+{
+ STATUS Result;
+
+ Result = DS1780_I2C_Wr(&INTR_1_MASK, DS1780_ADDR, INTR_1_MASK_REG, _1_CHAR);
+
+ if ( Result == OK )
+ {
+ Result = DS1780_I2C_Wr(&INTR_2_MASK, DS1780_ADDR, INTR_2_MASK_REG, _1_CHAR);
+
+ if ( Result == OK )
+ Result = DS1780_I2C_Wr(&DEFAULT_INTR_MODE, DS1780_ADDR, TEMP_CFG_REG, _1_CHAR);
+ }
+
+ return(Result);
+}
+
+/*****************************************************************************
+ *
+ * Module Name: DS1780_Init_Thresholds
+ *
+ * Purpose: Initializes the DS1780 voltage and temperature thresholds.
+ *
+ *****************************************************************************/
+
+STATUS DS1780_Init_Thresholds(void)
+{
+ STATUS Result;
+
+ Result = DS1780_Set_Voltage_Thresholds(_2_5_V_Thres_ID, _2_0_VOLTS, _1_7_VOLTS);
+
+ if ( Result == OK )
+ {
+ Result = DS1780_Set_Voltage_Thresholds(_3_3_V_Thres_ID, _3_5_VOLTS, _3_1_VOLTS);
+
+ if ( Result == OK )
+
+ Result = DS1780_Set_Voltage_Thresholds(_5_V_Thres_ID, _5_2_VOLTS, _4_75_VOLTS);
+ }
+
+ if ( Result == OK )
+
+ Result = DS1780_Set_Temp_Thresholds( _45_DEGREES, _0_DEGREES);
+
+ return(Result);
+}
+
+/*****************************************************************************
+ *
+ * Module Name: DS1780_Set_Voltage_Thresholds
+ *
+ * Purpose: Sets the DS1780 voltage threshold.
+ *
+ *****************************************************************************/
+
+STATUS DS1780_Set_Voltage_Thresholds(UINT8 Threshold_ID, UINT8 High, UINT8 Low)
+{
+ STATUS Result = OK;
+ UINT8 wHiAddr, wLoAddr;
+
+ if ( Threshold_ID == _2_5_V_Thres_ID )
+ {
+ wHiAddr = _2_5_HIGH_LIMIT_ADDR;
+ wLoAddr = _2_5_LOW_LIMIT_ADDR;
+ }
+ else if ( Threshold_ID == _3_3_V_Thres_ID )
+ {
+ wHiAddr = _3_3_HIGH_LIMIT_ADDR;
+ wLoAddr = _3_3_LOW_LIMIT_ADDR;
+ }
+ else if ( Threshold_ID == _5_V_Thres_ID )
+ {
+ wHiAddr = _5_HIGH_LIMIT_ADDR;
+ wLoAddr = _5_LOW_LIMIT_ADDR;
+ }
+ else
+ Result = ERROR;
+
+
+ if ( Result == OK )
+ {
+ Result = DS1780_I2C_Wr( &High, DS1780_ADDR, wHiAddr, _1_CHAR );
+
+ if ( Result == OK )
+
+ Result = DS1780_I2C_Wr( &Low, DS1780_ADDR, wLoAddr, _1_CHAR );
+ }
+
+ return(Result);
+}
+
+
+/*****************************************************************************
+ *
+ * Module Name: DS1780_Set_Temp_Thresholds
+ *
+ * Purpose: Sets the DS1780 temperature thresholds.
+ *
+ *****************************************************************************/
+
+STATUS DS1780_Set_Temp_Thresholds(UINT8 High, UINT8 Low)
+{
+ STATUS Result;
+
+ Result = DS1780_I2C_Wr( &High, DS1780_ADDR, HOT_TEMP_HIGH_ADDR, _1_CHAR );
+
+ if ( Result == OK )
+
+ Result = DS1780_I2C_Wr( &Low, DS1780_ADDR, HOT_TEMP_HYST_LOW_ADDR, _1_CHAR );
+
+ return(Result);
+
+}
+
+
+/*****************************************************************************
+ *
+ * Module Name: DS1780_Read_Company_Id
+ *
+ * Purpose: Reads the DS1780 Company I.D. value.
+ *
+ *****************************************************************************/
+
+STATUS DS1780_Read_Company_Id(unsigned char *outch)
+{
+ STATUS Result;
+
+ Result = DS1780_I2C_Rd(outch, DS1780_ADDR, CO_ID_NUMBER_ADDR, _1_CHAR);
+
+ return(Result);
+}
+
+/*****************************************************************************
+ *
+ * Module Name: DS1780_Stepping_Id
+ *
+ * Purpose: Reads the DS1780 Stepping I.D. value.
+ *
+ *****************************************************************************/
+
+STATUS DS1780_Stepping_Id(unsigned char *outch)
+{
+ STATUS Result;
+
+ Result = DS1780_I2C_Rd(outch, DS1780_ADDR, STEPPING_ID_ADDR, _1_CHAR);
+
+ return(Result);
+}
+
+
+/*****************************************************************************
+ *
+ * Module Name: DS1780_I2C_Rd
+ *
+ * Purpose: Reads data from the DS1780 via I2C bus.
+ *
+ *****************************************************************************/
+
+STATUS DS1780_I2C_Rd(unsigned char *outch, unsigned char devAddr,
+ unsigned char wAddr, int numChars)
+{
+ STATUS Results;
+ int i;
+
+ I2Coperation(ON);
+
+ for (i = 0, Results = ERROR; (i < 10) && (Results == ERROR); i++)
+ { /* if error try muliple times since I2Cread can fail occasionally */
+ Results = I2Cread(outch, devAddr, wAddr, numChars);
+ taskDelay(2);
+ }
+
+ I2Coperation(OFF);
+
+ return(Results);
+}
+
+
+/*****************************************************************************
+ *
+ * Module Name: DS1780_I2C_Wr
+ *
+ * Purpose: Writes data to the DS1780 via I2C bus.
+ *
+ *****************************************************************************/
+
+STATUS DS1780_I2C_Wr(unsigned char *outch, unsigned char devAddr,
+ unsigned char wAddr, int numChars)
+{
+ STATUS Results;
+
+ I2Coperation(ON);
+
+ Results = I2Cwrite(outch, devAddr, wAddr, numChars);
+
+ I2Coperation(OFF);
+
+ return(Results);
+}
+
+
+/*****************************************************************************
+ *
+ * T E S T C O D E
+ *
+ *****************************************************************************/
+
+#ifdef DS1780_TEST
+
+/*****************************************************************************
+ *
+ * Module Name: DS1780_Rd_Regs
+ *
+ * Purpose: Test Module to read the DS1780 registers.
+ *
+ *****************************************************************************/
+
+STATUS DS1780_Rd_Regs(void)
+{
+ STATUS Result;
+ unsigned char Value;
+
+ Result = DS1780_I2C_Rd(&Value, DS1780_ADDR, CONFIG_REG, _1_CHAR);
+ printf("CONFIG_REG = %d\n", Value);
+
+ Result = DS1780_I2C_Rd(&Value, DS1780_ADDR, INTR_STAT_1_REG, _1_CHAR);
+ printf("INTR_STAT_1_REG = %d\n", Value);
+
+ Result = DS1780_I2C_Rd(&Value, DS1780_ADDR, INTR_STAT_2_REG, _1_CHAR);
+ printf("INTR_STAT_2_REG = %d\n", Value);
+
+ Result = DS1780_I2C_Rd(&Value, DS1780_ADDR, INTR_1_MASK_REG, _1_CHAR);
+ printf("INTR_1_MASK_REG = %d\n", Value);
+
+ Result = DS1780_I2C_Rd(&Value, DS1780_ADDR, INTR_2_MASK_REG, _1_CHAR);
+ printf("INTR_2_MASK_REG = %d\n", Value);
+
+ return(Result);
+}
+
+/*****************************************************************************
+ *
+ * Module Name: DS1780_Rd_Loc
+ *
+ * Purpose: Test Module to read the DS1780 memory locations.
+ *
+ *****************************************************************************/
+
+STATUS DS1780_Rd_Loc(unsigned char Addr)
+{
+ STATUS Result;
+ unsigned char Value;
+
+ Result = DS1780_I2C_Rd(&Value, DS1780_ADDR, Addr, _1_CHAR);
+
+ printf("Value = %d\n", Value);
+
+ return(Result);
+}
+
+/*****************************************************************************
+ *
+ * Module Name: DS1780_Wr_Loc
+ *
+ * Purpose: Test Module to write the DS1780 locations.
+ *
+ *****************************************************************************/
+
+STATUS DS1780_Wr_Loc(unsigned char Addr, unsigned char Value)
+{
+ STATUS Result;
+
+ Result = DS1780_I2C_Wr(&Value, DS1780_ADDR, Addr, _1_CHAR);
+
+ return(Result);
+}
+
+
+/*****************************************************************************
+ *
+ * Module Name: DS1780_get1_8_V
+ *
+ * Purpose: Returns 1.8 Voltage status
+ *
+ *****************************************************************************/
+
+float DS1780_get1_8_V(void)
+{
+ t_DS1780 data;
+
+ DS1780_Read(&data);
+
+ return (float)((2.5 * (float)data._2_5_V_Mon_Value)/192);
+}
+/*****************************************************************************
+ *
+ * Module Name: DS1780_get3_3_V
+ *
+ * Purpose: Returns 3.3 Voltage status.
+ *
+ *****************************************************************************/
+
+float DS1780_get3_3_V(void)
+{
+ t_DS1780 data;
+
+ DS1780_Read(&data);
+
+ return (float)((3.3 * (float)data._3_3_V_Mon_Value)/192);
+}
+/*****************************************************************************
+ *
+ * Module Name: DS1780_get5_0_V
+ *
+ * Purpose: returns 5 voltage status
+ *
+ *****************************************************************************/
+
+float DS1780_get5_0_V(void)
+{
+ t_DS1780 data;
+ DS1780_Read(&data);
+
+ return (float)((5.0 * (float)data._5_V_Mon_Value)/192);
+}
+
+/*****************************************************************************
+ *
+ * Module Name: DS1780_getCdcTemp
+ *
+ * Purpose: return cdc temperature.
+ *
+ *****************************************************************************/
+
+int DS1780_getCdcTemp(void)
+{
+ t_DS1780 data;
+
+ DS1780_Read(&data);
+
+ return data.Temp_Mon_Value;
+}
+
+/*****************************************************************************
+ *
+ * Module Name: DS1780_Test_Read
+ *
+ * Purpose: Test the DS1780_Read Module.
+ *
+ *****************************************************************************/
+
+STATUS DS1780_Test_Read(void)
+{
+ STATUS Results;
+ t_DS1780 data;
+
+ Results = DS1780_Read(&data);
+
+ printf("2.5_V_Mon_Value = %d", data._2_5_V_Mon_Value);
+ printf(" = %f volts\n", ((2.5 * (float)data._2_5_V_Mon_Value)/192));
+
+ printf("3.3_V_Mon_Value = %d", data._3_3_V_Mon_Value);
+ printf(" = %f volts\n", ((3.3 * (float)data._3_3_V_Mon_Value)/192));
+
+ printf("5 V_Mon_Value = %d", data._5_V_Mon_Value);
+ printf(" = %f volts\n", ((5 * (float)data._5_V_Mon_Value)/192));
+
+ printf("Temp_Mon_Value = %d degrees C\n", data.Temp_Mon_Value);
+
+ printf("Chassis_Intrusion_Status = %d\n", data.Chassis_Intrusion_Status);
+
+ return(Results);
+}
+
+#endif
diff --git a/data/mnet/GP10/Host/cdcUtils/cdcUtils/Makefile b/data/mnet/GP10/Host/cdcUtils/cdcUtils/Makefile
new file mode 100644
index 0000000..6397397
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/cdcUtils/Makefile
@@ -0,0 +1,52 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..\..
+
+# These Must be Properly Defined
+THIS_APP_DIR = cdcUtils
+THIS_DIRECTORY = cdcUtils
+MY_OUTPUT = $(OBJDIR)\cdcUtils.out
+
+# Name(s) of Common VOB directories to include
+COMMON_BLD_DIR =
+
+include $(TOP_OF_VOB)\l3defs.mk
+
+all: makeCommonObjs $(MY_OUTPUT)
+
+# Adds the .o file(s) list needed from the Common VOB
+makeCommonObjs:
+ifneq ($(COMMON_BLD_DIR),)
+ @for %f in ($(COMMON_BLD_DIR)) do \
+ make -C $(COMMON_VOB_APP_DIR)\%f \
+ all VOB=$(VOBNAME) APPDIR=Host\$(THIS_APP_DIR)\$(THIS_DIRECTORY)
+endif
+
+# If Common VOB directories to include get the .o files from bin
+$(MY_OUTPUT): $(MODULE_OBJS)
+ifneq ($(COMMON_BLD_DIR),)
+ $(LD) -r -o $@.tmp $() $(MODULE_OBJS) $(wildcard ./bin/*.o)
+else
+ $(LD) -r -o $@.tmp $() $(MODULE_OBJS)
+endif
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+ifneq ($(COMMON_BLD_DIR),)
+ $(RM) bin\*.o
+ $(RM) bin\*.out
+endif
diff --git a/data/mnet/GP10/Host/cdcUtils/cdcUtils/cdcUtils.c b/data/mnet/GP10/Host/cdcUtils/cdcUtils/cdcUtils.c
new file mode 100644
index 0000000..65105f2
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/cdcUtils/cdcUtils.c
@@ -0,0 +1,617 @@
+/******************************************************************
+
+ (c) Copyright Cisco 2000
+ All Rights Reserved
+
+******************************************************************/
+
+#include "vxWorks.h"
+#include "stdio.h"
+#include "cdc_bsp\nvRam.h"
+#include "cdcUtils\auxPort.h"
+#include "l1proxy\l1proxy.h"
+#include "mch\MCHDefs.h"
+
+#define CDC_SERNUM_SIZE MAX_CDC_SN /* cdc serial number size */
+
+/*--------- externals ---------*/
+extern char ds2401[8]; /* global 8 byte buffer */
+extern int ds2401CRC; /* calculated checksum */
+void oamHwInfoPopulate();
+extern STATUS I2Cwrite(unsigned char*, unsigned char, unsigned char, int);
+extern STATUS I2Cread(unsigned char*, unsigned char, unsigned char, int);
+extern void I2Coperation(int);
+
+#define ON 1
+#define OFF 0
+
+
+/*---------- globals ----------*/
+char cdcSerialNum[CDC_SERNUM_SIZE + 1] = "????";
+char cdcMacAddrStr[12 + 1];
+int radioBoardVerifyEepromOn = 1;
+
+void cdcBootromVerInfo(void);
+char *cdcGetBootromVersion(void);
+int cdcVerifyBootromCheckSum(void);
+char *cdcBootromVerDate(void);
+int cdcGetBootromCheckSum(void);
+int cdcCalCheckSum(unsigned char *loc, int number);
+
+/*******************************************************************************
+cdcLed1On - LED 1 On
+Turn LED 1 on
+*/
+void cdcLed1On()
+{
+ auxPortOutSet(~LED1_OFF, LED1_OFF);
+}
+
+
+/*******************************************************************************
+cdcLed1Off - LED 1 Off
+Turn LED 1 off
+*/
+void cdcLed1Off()
+{
+ auxPortOutSet(LED1_OFF, LED1_OFF);
+}
+
+
+/*******************************************************************************
+cdcLed2On - LED 2 On
+Turn LED 2 on
+*/
+void cdcLed2On()
+{
+ auxPortOutSet(~LED2_OFF, LED2_OFF);
+}
+
+
+/*******************************************************************************
+cdcLed2Off - LED 2 Off
+Turn LED 2 off
+*/
+void cdcLed2Off()
+{
+ auxPortOutSet(LED2_OFF, LED2_OFF);
+}
+
+
+/*******************************************************************************
+cdcLed3On - LED 3 On
+Turn LED 3 on
+*/
+void cdcLed3On()
+{
+ auxPortOutSet(~LED3_OFF, LED3_OFF);
+}
+
+
+/*******************************************************************************
+cdcLed3Off - LED 3 Off
+Turn LED 3 off
+*/
+void cdcLed3Off()
+{
+ auxPortOutSet(LED3_OFF, LED3_OFF);
+}
+
+
+/*******************************************************************************
+cdcFaultLedOn - Fault LED On
+Turn Fault LED on
+*/
+void cdcLed4On()
+{
+ auxPortOutSet(~FAULT_LED_OFF, FAULT_LED_OFF);
+}
+
+
+/*******************************************************************************
+cdcFaultLedOff - Fault LED Off
+Turn Fault LED off
+*/
+void cdcLed4Off()
+{
+ auxPortOutSet(FAULT_LED_OFF, FAULT_LED_OFF);
+}
+
+
+/*******************************************************************************
+cdcLed5On - LED 5 On
+Turn LED 5 on
+*/
+void cdcLed5On()
+{
+ auxPortOutSet(LED5_ON, LED5_ON);
+}
+
+
+/*******************************************************************************
+cdcLed5Off - LED 5 Off
+Turn LED 5 off
+*/
+void cdcLed5Off()
+{
+ auxPortOutSet(~LED5_ON, LED5_ON);
+}
+
+
+/*******************************************************************************
+cdcPowerOff - CDC Power Off
+Turn off Power to CDC
+*/
+void cdcPowerOff()
+{
+ auxPortOutSet(CDC_POWER_OFF, CDC_POWER_OFF);
+}
+
+
+/*******************************************************************************
+cdcSerialNumGet - CDC Serial Number Get
+
+*/
+void cdcSerialNumGet()
+{
+ cdcSerialNum[CDC_SERNUM_SIZE] = 0;
+ if (sysCDCSerialNumGet(cdcSerialNum) != OK)
+ {
+ cdcSerialNum[0] = 'x';
+ cdcSerialNum[1] = 'x';
+ cdcSerialNum[2] = 'x';
+ cdcSerialNum[3] = 'x';
+ cdcSerialNum[4] = 0;
+ }
+}
+
+/*******************************************************************************
+cdcSerialNumReturn - CDC Serial Number Return
+
+*/
+char* cdcSerialNumReturn()
+{
+ return cdcSerialNum;
+}
+
+
+/*******************************************************************************
+cdcSerialNumPrint - CDC Serial Number Print
+
+*/
+void cdcSerialNumPrint()
+{
+ printf("CDC Serial Number: %s\n", cdcSerialNum);
+}
+
+
+/*******************************************************************************
+cdcMacAddrGet - CDC MAC Address Get
+
+*/
+char* cdcMacAddrGet()
+{
+ char macAddr[6];
+ int i;
+
+ taskDelay(10);
+ sysEnetAddrGet(0, macAddr);
+ taskDelay(10);
+ for (i = 0; i < 6; i++)
+ {
+ sprintf(&cdcMacAddrStr[i * 2], "%02X", macAddr[6 - 1 - i]);
+ }
+ cdcMacAddrStr[12] = 0;
+
+ return cdcMacAddrStr;
+}
+
+/*******************************************************************************
+dspReset
+
+reset DSPs
+*/
+void dspReset(void)
+{
+ /* put DSPs in reset */
+ auxPortOutSet(~(DSPA_RST_NOT|DSPB_RST_NOT), DSPA_RST_NOT|DSPB_RST_NOT);
+ /* delay 1.0 s */
+ taskDelay((int)(1.0 * sysClkRateGet()));
+ /* bring DSPs out of reset */
+ auxPortOutSet((DSPA_RST_NOT|DSPB_RST_NOT), DSPA_RST_NOT|DSPB_RST_NOT);
+}
+
+
+/*******************************************************************************
+cdcInit
+
+Initialize CDC board
+*/
+STATUS cdcInit(const char* fpgaFile, const char *base_prefix)
+{
+ char fName[256];
+ STATUS retVal = OK;
+
+ strcpy(fName, base_prefix);
+ strcat(fName, "/");
+ strcat(fName, fpgaFile);
+
+ auxPortInit(); /* Initilalize auxillary output port */
+ cdcSerialNumGet(); /* Get CDC serial Number */
+
+ printf("Resetting DSPs\n");
+ dspReset();
+
+ printf("Configuring FPGAs\n");
+ if ((fpgaConfig(fName)) != 0)
+ {
+ printf("FPGA configuration failed\n");
+ retVal = ERROR;
+ }
+
+ if (radioBoardVerifyEepromOn)
+ {
+ printf("Validating Radio Board EEPROM\n");
+ if ((VerifyRadioBoardEeprom() != OK))
+ {
+ printf("Radio Board EEPROM valication failed!\n");
+ }
+ }
+ else
+ {
+ printf("Radio Board EEPROM will NOT be validated\n");
+ }
+
+ printf("Initializing Dual RF module\n");
+ if ((drfInit()) != OK)
+ {
+ printf("RF module initialization failed\n");
+ retVal = ERROR;
+ }
+
+ printf("Initializing Clock module\n");
+ if ((clkInit()) != OK)
+ {
+ printf("Clock module initialization failed\n");
+ retVal = ERROR;
+ }
+
+ cdcLed5On(); /* Turn on LED 5 */
+
+ /* Initialize MIB hardware parameters */
+ oamHwInfoPopulate();
+
+ return retVal;
+}
+
+
+/*******************************************************************************
+cdcTestInit
+
+Initialize CDC board for Board Testing
+*/
+STATUS cdcTestInit(const char* fpgaFile, const char *base_prefix)
+{
+ char fName[256];
+ STATUS retVal = OK;
+
+ strcpy(fName, base_prefix);
+ strcat(fName, "/");
+ strcat(fName, fpgaFile);
+
+ auxPortInit(); /* Initilalize auxillary output port */
+ cdcSerialNumGet(); /* Get CDC serial Number */
+
+ printf("Configuring FPGAs\n");
+ if ((fpgaConfig(fName)) != 0)
+ {
+ printf("FPGA configuration failed\n");
+ retVal = ERROR;
+ }
+
+ cdcLed5On(); /* Turn on LED 5 */
+
+ return retVal;
+}
+
+/*******************************************************************************
+cdcBootromVerInfo
+
+Sends Bootrom version information to standard I/O.
+*/
+void cdcBootromVerInfo(void)
+{
+ char *chPtr;
+
+ chPtr = (char *)0x20000020;
+ printf("Bootrom %s\n", chPtr);
+
+ chPtr = (char *)0x20000000;
+ printf("Bootrom Date: %s\n", chPtr);
+}
+
+
+/*******************************************************************************
+cdcBootromVerInfo
+
+Returns Bootrom version.
+*/
+char *cdcGetBootromVersion(void)
+{
+ char *chPtr;
+
+ chPtr = (char *)0x20000020;
+ return(chPtr);
+}
+
+/*******************************************************************************
+IsCorrectCdcBootromVer
+
+Returns OK if bootrom version info 1st character = 'V'
+*/
+int IsCorrectCdcBootromVer(void)
+{
+ char *chPtr;
+
+ chPtr = cdcGetBootromVersion();
+
+ if ( *chPtr != 'V' )
+ return ERROR;
+ else
+ return OK;
+}
+
+/*******************************************************************************
+cdcBootromVerDate
+
+Returns Bootrom version date.
+*/
+char *cdcBootromVerDate(void)
+{
+ char *chPtr;
+
+ chPtr = (char *)0x20000000;
+ return(chPtr);
+}
+
+
+/*******************************************************************************
+cdcVerifyBootromCheckSum
+
+Verifies checksum for bootrom memory locations.
+
+RETURNS: OK = Valid Bootrom ERROR = Bootrom is corrupted or wrong version
+*/
+int cdcVerifyBootromCheckSum(void)
+{
+ int checksum;
+ int fileCheckSum;
+ unsigned char *pfileCheckSum;
+ unsigned char cfilesum[5];
+ int result;
+
+ if ( IsCorrectCdcBootromVer() == OK )
+ {
+ pfileCheckSum = (unsigned char *)0x20000060;
+ strcpy(cfilesum,pfileCheckSum);
+ sscanf(cfilesum, "%x", &fileCheckSum);
+ checksum = cdcGetBootromCheckSum();
+
+ if ( fileCheckSum == checksum )
+ {
+ result = OK;
+ printf("Bootrom CheckSum is valid\n");
+ }
+ else
+ {
+ printf("Bootrom CheckSum Verify FAILED !!\n");
+ result = ERROR;
+ }
+ }
+ else
+ {
+ printf("Bootrom CheckSum Verify FAILED\n");
+ printf("No CheckSum info in header, wrong bootrom version !!\n");
+ result = ERROR;
+ }
+
+ return(result);
+}
+
+
+/*******************************************************************************
+cdcGetBootromCheckSum
+
+Calculates checksum for bootrom memory locations if the bootrom version is valid.
+*/
+int cdcGetBootromCheckSum(void)
+{
+ int checksum = 0;
+ int databytes = 0;
+ unsigned char *pDataBytes;
+
+ if ( IsCorrectCdcBootromVer() == OK )
+ {
+ pDataBytes = (unsigned char *)0x20000064;
+
+ sscanf((char *)pDataBytes, "%d", &databytes);
+
+ checksum = cdcCalCheckSum((unsigned char *)0x20000100, databytes);
+ }
+ return(checksum);
+}
+
+
+/*******************************************************************************
+cdcCalCheckSum
+
+Calculates checksum for consecutive memory locations.
+*/
+int cdcCalCheckSum(unsigned char *loc, int number)
+{
+ int i;
+ int calcChkSum = 0;
+
+ for (i = 0; i < number; i++)
+ {
+ calcChkSum += loc[i];
+ }
+
+ calcChkSum = (~calcChkSum) & 0xff;
+
+ printf("Checksum = %02x\n", calcChkSum);
+
+ return(calcChkSum);
+}
+
+
+
+
+/*****************************************************************************
+ *
+ * Module Name: SaveEepromInNVRam
+ *
+ * Purpose: Read EEPROM from the radio board and store in NVRam.
+ *
+ *****************************************************************************/
+STATUS SaveEepromInNVRam(void)
+{
+ STATUS status;
+ unsigned char buf[RADIO_BOARD_EEPROM_SIZE];
+ int i2cRetryCount;
+
+ i2cRetryCount = 3;
+ do
+ {
+ I2Coperation(ON);
+ status = I2Cread(buf, 0x52, 0, RADIO_BOARD_EEPROM_SIZE/2);
+ I2Coperation(OFF);
+ } while ((status != OK) && (--i2cRetryCount > 0));
+
+ if (status == OK)
+ {
+ i2cRetryCount = 3;
+ do
+ {
+ I2Coperation(ON);
+ status = I2Cread(buf+RADIO_BOARD_EEPROM_SIZE/2, 0x53, 0, RADIO_BOARD_EEPROM_SIZE/2);
+ I2Coperation(OFF);
+ } while ((status != OK) && (--i2cRetryCount > 0));
+ }
+
+ if (status == OK)
+ {
+ status = sysRadioBoardEepromSet((char *)buf);
+ }
+ return(status);
+}
+
+
+/*****************************************************************************
+ *
+ * Module Name: RestoreEepromFromNVRam
+ *
+ * Purpose: Read saved EEPROM from NVRam. If it does not match the current
+ * EEPROM values then write the NVRam version to the radio board.
+ *
+ *****************************************************************************/
+STATUS RestoreEepromFromNVRam(void)
+{
+ STATUS status;
+ unsigned char nvRamEeprom[RADIO_BOARD_EEPROM_SIZE];
+ unsigned char radioBoardEeprom[RADIO_BOARD_EEPROM_SIZE];
+ int i2cRetryCount, i;
+
+ /* Read in the EEPROM table stored in NNRam */
+ status = sysRadioBoardEepromGet((char *)nvRamEeprom);
+
+ /* Read in the Radio Board EEPROM */
+ i2cRetryCount = 3;
+ do
+ {
+ I2Coperation(ON);
+ status = I2Cread(radioBoardEeprom, 0x52, 0, RADIO_BOARD_EEPROM_SIZE/2);
+ I2Coperation(OFF);
+ } while ((status != OK) && (--i2cRetryCount > 0));
+
+ if (status == OK)
+ {
+ i2cRetryCount = 3;
+ do
+ {
+ I2Coperation(ON);
+ status = I2Cread(radioBoardEeprom+RADIO_BOARD_EEPROM_SIZE/2, 0x53, 0, RADIO_BOARD_EEPROM_SIZE/2);
+ I2Coperation(OFF);
+ } while ((status != OK) && (--i2cRetryCount > 0));
+ }
+
+ if (status == OK)
+ {
+ /* Check NVRam version against Radio Board version */
+ for (i = 0; i < RADIO_BOARD_EEPROM_SIZE; i++)
+ {
+ /* If any errors are found then write out the NVRam version */
+ if (nvRamEeprom[i] != radioBoardEeprom[i])
+ {
+ printf("Radio Board EEPROM does not match NV Ram!\n"
+ "Radio Board EEPROM will be updated to match NV Ram!\n");
+ I2Coperation(ON);
+ for ( i=0; i<RADIO_BOARD_EEPROM_SIZE/2; i++ )
+ {
+ i2cRetryCount = 3;
+ do
+ {
+ status = I2Cwrite(nvRamEeprom+i, 0x52, (unsigned char)i, 1);
+ taskDelay(2); /* Limit how fast the EEPROM gets the bytes */
+ } while ((status != OK) && (--i2cRetryCount > 0));
+ }
+ for ( i=RADIO_BOARD_EEPROM_SIZE/2; i<RADIO_BOARD_EEPROM_SIZE; i++ )
+ {
+ i2cRetryCount = 3;
+ do
+ {
+ status = I2Cwrite(nvRamEeprom+i, 0x53, (unsigned char)i, 1);
+ taskDelay(2); /* Limit how fast the EEPROM gets the bytes */
+ } while ((status != OK) && (--i2cRetryCount > 0));
+ }
+
+ I2Coperation(OFF);
+ break;
+ }
+ }
+ }
+
+ return(status);
+}
+
+
+
+/*******************************************************************************
+VerifyRadioBoardEeprom
+
+*/
+
+int VerifyRadioBoardEeprom()
+{
+ int status;
+ /* If there is a valid saved Radio EEPROM in NvRam then
+ restore that on the radio board. */
+ if (sysIsRadioBoardEepromSet())
+ {
+ if ((status = RestoreEepromFromNVRam()) != OK)
+ {
+ printf("WARNING - Unable to restore Radio Board EEPROM!\n");
+ }
+ }
+ /* Otherwise we have to assume the EEPROM is ok so we will
+ move it into NvRam. */
+ else
+ {
+ printf("Saving Radio Board EEPROM into NV Ram!\n");
+ if ((status = SaveEepromInNVRam()) != OK)
+ {
+ printf("WARNING - Unable to save Radio Board EEPROM!\n");
+ }
+ }
+ return(status);
+}
diff --git a/data/mnet/GP10/Host/cdcUtils/cdcUtils/oamHwInfoSet.c b/data/mnet/GP10/Host/cdcUtils/cdcUtils/oamHwInfoSet.c
new file mode 100644
index 0000000..29ad02d
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/cdcUtils/oamHwInfoSet.c
@@ -0,0 +1,189 @@
+/******************************************************************
+
+ (c) Copyright Cisco 2000
+ All Rights Reserved
+
+******************************************************************/
+
+/********************************************************************
+*
+* FILE NAME: oamHwInfoSet.c
+*
+* DESCRIPTION: This file contains routine to populate hardware
+* information to the MIB.
+* COMPONENTS:
+*
+*
+* NOTES:
+*
+* REVISION HISTORY
+*__________________________________________________________________
+*----------+--------+----------------------------------------------
+* Name | Date | Reason
+*----------+--------+----------------------------------------------
+* Bhawani |02/15/00| Initial Draft
+* Bhawani |05/11/00| Added ViperCell Serial Number initializaion
+* Bhawani |08/09/00| Added Default Router Initialization part
+* Bhawani |03/09/01| Change MIB tag for the default Gateway
+*----------+--------+----------------------------------------------
+********************************************************************
+*/
+
+#include "stdio.h"
+#include "vxWorks.h"
+#include "cdcUtils/auxPort.h"
+
+#include "oam_api.h"
+#include "cdcUtils/cdcUtils.h"
+#include "cdcUtils/drfInterface.h"
+#include "clkInterface.h"
+#include "cdc_bsp/nvRam.h"
+
+/* Used temporarily to circumvent OAM API restriction */
+#define MY_MODULE_ID MODULE_OAM
+
+STATUS cdcSetMibStr(MibTag tag, char *pszValue)
+{
+ STATUS status = ERROR;
+
+
+ if (pszValue)
+ {
+ int nLen = strlen(pszValue) + 1;
+#ifdef _DEBUG
+ printf("Setting %s = %s\n", snmp_tagName(tag), pszValue);
+#endif
+
+ if( oam_setMibByteAry(MY_MODULE_ID, tag, pszValue, nLen) != STATUS_OK)
+ {
+ printf("oam_setMibByteAry failure (tag = %s, value = %s)\n", snmp_tagName(tag), pszValue);
+ } else {
+ status = OK;
+ }
+ }
+ return status;
+}
+
+
+STATUS cdcSetMibInt(MibTag tag, int iValue)
+{
+ STATUS status = ERROR;
+
+#ifdef _DEBUG
+ printf("Setting %s = %d\n", snmp_tagName(tag), iValue);
+#endif
+
+ if( oam_setMibIntVar(MY_MODULE_ID, tag, iValue) != STATUS_OK)
+ {
+ printf("oam_setMibIntVal failure (tag = %s, value = %d)\n", snmp_tagName(tag), iValue);
+ } else {
+ status = OK;
+ }
+ return status;
+}
+
+
+char *cdcCvtIp2Str(unsigned long ip)
+{
+ static char buf[16];
+ unsigned char *pIp = (unsigned char *) &ip;
+ sprintf(buf, "%u.%u.%u.%u", pIp[0], pIp[1], pIp[2], pIp[3]);
+ return buf;
+}
+
+
+void oamHwInfoPopulate()
+{
+ int dulaTrxStatus;
+ STATUS status;
+ int drfType = drfTypeGet();
+ int pwrClass = drfType+1;
+ char pszSerialNumber[MAX_VC_SN+1];
+ unsigned long ip;
+ char *pszIP;
+
+ /* initialize 1780 */
+ DS1780_Init();
+
+ /* Set GSM DCS indicator */
+ cdcSetMibInt(MIB_gsmdcsIndicator, drfType);
+ cdcSetMibInt(MIB_powerClass_0, pwrClass);
+ cdcSetMibInt(MIB_powerClass_1, pwrClass);
+
+ /* Cdc board inititializaiton */
+
+ /* Serial Number */
+ cdcSetMibStr(MIB_cdcBoardSerialNumber, cdcSerialNumReturn());
+
+ /* Mac Address */
+ cdcSetMibStr(MIB_cdcBoardMACAddress, cdcMacAddrGet());
+
+
+ /* Dual Trx */
+
+ /* Serial Number */
+ cdcSetMibStr(MIB_trxSerialNumber, drfSerialNumReturn());
+
+ /*Version Number */
+ cdcSetMibStr(MIB_trxSoftwareVersion, drfVersionReturn());
+
+ /* Get Status */
+
+ if ((status = drfStatGet(&dulaTrxStatus)) != OK)
+ {
+ printf("drfStatusGet failure (status = %d)\n", status);
+ } else {
+
+ /* Set the PLL Lock Status */
+ cdcSetMibInt(MIB_monitorReceiverPLL_LockDetectStatus, (dulaTrxStatus & 0x00000004)==0?0:1);
+ cdcSetMibInt(MIB_referenceFrequencyPLL_LockDetectStatus, (dulaTrxStatus & 0x00000008)==0?0:1);
+ cdcSetMibInt(MIB_transceiver_1_PLL_LockDetectStatus, (dulaTrxStatus & 0x00000010)==0?0:1);
+ cdcSetMibInt(MIB_transceiver_2A_PLL_LockDetectStatus, (dulaTrxStatus & 0x00000020)==0?0:1);
+ cdcSetMibInt(MIB_transceiver_2B_PLL_LockDetectStatus, (dulaTrxStatus & 0x00000040)==0?0:1);
+ cdcSetMibInt(MIB_intermediateFrequency_LockDetectStatus, (dulaTrxStatus & 0x00000080)==0?0:1);
+
+ /* Memory Status */
+ cdcSetMibInt(MIB_trxLoopBackMode, (dulaTrxStatus &0x00004000));
+
+ /* FPGA Syncronization */
+ cdcSetMibInt(MIB_gpsCardStatus, (dulaTrxStatus & 0x00002000));
+ }
+
+ /* Clock card */
+
+ /* Serial Number */
+ cdcSetMibStr(MIB_clockCardCrystalUpTime, clkSerialNumReturn());
+
+ /* Version Number */
+ cdcSetMibStr(MIB_clockCardSoftwareVersion, clkSoftVersionReturn());
+
+ /* Alarm Status */
+ cdcSetMibInt(MIB_clockCardStatus, clkStatGet());
+
+
+ /* Days Since Tuneup: */
+ cdcSetMibInt(MIB_clockCardType, clkNumDaysTuneGet());
+
+ /* Days Since Power On: */
+ cdcSetMibInt(MIB_clockCardDAC, clkNumDaysRunGet());
+
+ /* Initialize VieprCell Serial Number */
+ pszSerialNumber[MAX_VC_SN] = 0;
+ if (sysSerialNumGet (pszSerialNumber) == OK)
+ {
+ cdcSetMibStr(MIB_viperCellSerialNumber, pszSerialNumber);
+ } else {
+ printf("sysSerialNumGet failure; could not set ViperCell serial number\n");
+ }
+
+ /* Add the default gateway */
+
+ if (oam_getMibIntVar(MIB_viperCellDefGateway, &ip))
+ {
+ printf("oam_getMibIntVal failure (tag = %s)\n", snmp_tagName(MIB_viperCellDefGateway));
+ } else {
+ pszIP = cdcCvtIp2Str(ip);
+ routeAdd("0", pszIP);
+ printf("Default gateway %s has been added\n", pszIP);
+ }
+}
diff --git a/data/mnet/GP10/Host/cdcUtils/clkInterface/Makefile b/data/mnet/GP10/Host/cdcUtils/clkInterface/Makefile
new file mode 100644
index 0000000..d35c870
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/clkInterface/Makefile
@@ -0,0 +1,52 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..\..
+
+# These Must be Properly Defined
+THIS_APP_DIR = cdcUtils
+THIS_DIRECTORY = clkInterface
+MY_OUTPUT = $(OBJDIR)\clkInterface.out
+
+# Name(s) of Common VOB directories to include
+COMMON_BLD_DIR =
+
+include $(TOP_OF_VOB)\l3defs.mk
+
+all: makeCommonObjs $(MY_OUTPUT)
+
+# Adds the .o file(s) list needed from the Common VOB
+makeCommonObjs:
+ifneq ($(COMMON_BLD_DIR),)
+ @for %f in ($(COMMON_BLD_DIR)) do \
+ make -C $(COMMON_VOB_APP_DIR)\%f \
+ all VOB=$(VOBNAME) APPDIR=Host\$(THIS_APP_DIR)\$(THIS_DIRECTORY)
+endif
+
+# If Common VOB directories to include get the .o files from bin
+$(MY_OUTPUT): $(MODULE_OBJS)
+ifneq ($(COMMON_BLD_DIR),)
+ $(LD) -r -o $@.tmp $() $(MODULE_OBJS) $(wildcard ./bin/*.o)
+else
+ $(LD) -r -o $@.tmp $() $(MODULE_OBJS)
+endif
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+ifneq ($(COMMON_BLD_DIR),)
+ $(RM) bin\*.o
+ $(RM) bin\*.out
+endif
diff --git a/data/mnet/GP10/Host/cdcUtils/clkInterface/clkInterface.c b/data/mnet/GP10/Host/cdcUtils/clkInterface/clkInterface.c
new file mode 100644
index 0000000..eb21d8b
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/clkInterface/clkInterface.c
@@ -0,0 +1,1221 @@
+/******************************************************************
+
+ (c) Copyright Cisco 2000
+ All Rights Reserved
+
+******************************************************************/
+
+/*********************************************************************
+
+clkInterface - Clock Interface
+
+This file consists a set of functions to interface with the Clock Module.
+
+Before any of the functions can be used the interface needs to be initialized with
+function clkInit().
+
+All the clock interface functions make use of the function clkCmd() to send a
+command to the clock module. clKCmd() sends the given command to the clock module
+and reads the response after 320 ms. This function can also be used to send
+a command to the clock module from the console.
+
+A function clkNumGet is used by other funcion that need to send a command and read
+a numerical value from the response.
+
+All the commands to the clock module are ASCII coded. Each command has an ASCII
+coded response. The clock module asssumes that the commands are being sent from
+a console and sends a prompt at the end of all responses. The command charaters are
+not echoed by the clock module. Each command is terminated with a
+'carraige return' character.
+*/
+
+#include <vxWorks.h>
+#include <ioLib.h>
+#include <semLib.h>
+#include "cdc_bsp/nvRam.h"
+
+#define MAX_CMD_LEN 30
+#define MAX_RSP_LEN 30
+#define NUM_VERSION_STAGES 2
+#define SERIAL_NUM_LEN 15
+#define EEPROM_SIZE_REVC CLOCK_BOARD_EEPROM_SIZE
+#define EEPROM_SIZE_REV1_8 15
+
+/*---------- Globals ----------*/
+char clkSerialNum[SERIAL_NUM_LEN + 1] = "xxxxxxxxxxxxxxx";
+char clkSoftVersion[4] = "x.x";
+int clkVerifyEepromOn = 1;
+
+/*-------- File Locals --------*/
+static SEM_ID clkSem;
+static int clkFd;
+static int clkVerStage;
+
+LOCAL STATUS clkSoftVersionGet();
+
+/**********************************************************************
+clkInterfaceInit - Interface Initialize
+
+Inititlaizes the clock module interface..
+*/
+
+/* This routine opens the serial port for the clock module */
+
+static STATUS clkInterfaceInit() /* RETURN: OK or ERROR */
+{
+ STATUS retStat = ERROR;
+
+ /* create a semaphore for mutual exclusion */
+ clkSem = semMCreate(SEM_Q_PRIORITY | SEM_INVERSION_SAFE | SEM_DELETE_SAFE);
+ if (clkSem != NULL)
+ {
+ clkFd = open("/tyCo/1", O_RDWR, 0); /* open the serial port */
+ if (clkFd != ERROR)
+ {
+ /* The response to first command to clock card is discoverd to be just a prompt.
+ Issue a dummy command so that the first real command is not the first command */
+ write(clkFd, "\r", 1); /* send a carraige return */
+ taskDelay(2); /* wait for the response */
+ ioctl(clkFd, FIORFLUSH, 0); /* clear the 'read' buffer */
+ retStat = OK;
+ }
+ }
+ return retStat;
+}
+
+
+/**********************************************************************
+clkInit - Initialize
+
+Inititlaizes the clock module interface and reads and saves the clock module
+serial number.
+This function should be called once before any commands can be
+sent to the clock module.
+*/
+
+/* This routine opens the serial port for the clock module */
+
+STATUS clkInit() /* RETURN: OK or ERROR */
+{
+ STATUS retStat = ERROR;
+
+ clkVerStage = NUM_VERSION_STAGES - 1; /* assume latest */
+ if (clkInterfaceInit() == OK) /* intitlize the interface */
+ {
+ if (clkSoftVersionGet() == OK) /* read the software version number */
+ {
+ if ((clkSoftVersion[0] >= '0') && (clkSoftVersion[0] <= '9'))
+ { /* valid number */
+ if (clkSoftVersion[0] >= '2')
+ clkVerStage = 1; /* version >= 2.x */
+ else
+ clkVerStage = 0;
+
+ if (clkVerifyEepromOn) clkValidateEeprom();
+
+ if (clkSerialNumGet() == OK) /* read the serial number */
+ retStat = OK;
+ }
+ }
+ }
+
+ return retStat;
+}
+
+
+/**********************************************************************
+clkSerialNumReturn - Serial Number Return
+
+Returns the Serial Number of the clock module.
+*/
+char* clkSerialNumReturn()
+{
+ return clkSerialNum;
+}
+
+
+/**********************************************************************
+clkSerialNumPrint - Serial Number Print
+
+Prints the Serial Number of the clock module.
+*/
+clkSerialNumPrint()
+{
+ printf("Clock Module Serial Number: %s\n", clkSerialNum);
+}
+
+
+/**********************************************************************
+clkSoftVersionReturn - Software Version Return
+
+Returns the Software Version of the clock module.
+*/
+char* clkSoftVersionReturn()
+{
+ return clkSoftVersion;
+}
+
+
+/**********************************************************************
+clkSoftVersionPrint - Software Version Print
+
+Prints the Software Version of the clock module.
+*/
+clkSoftVersionPrint()
+{
+ printf("Clock Module Software Version: %s\n", clkSoftVersion);
+}
+
+
+/**********************************************************************
+clkCmd - Command
+
+This function sends a command to the clock module and returns the response.
+It provides interface to clock module for other functions. It can also be
+used for sending a command to the clock module from console.
+
+This function is used by all other functions to send a command to the clock
+module. Normally this function should not called directly. Instead one of
+the specicfic functions that make use of this function should be called.
+
+If the pointer to response is 0, it is assumed that the command was issued
+from the console the response is printed on the standard output.
+
+This functions waits for 320 ms.to check if a response is available. Error is
+returnrd if there is no response.
+*/
+
+/*
+All the responses from clock module are begin with cr-lf characters and the response ends
+with a cr-lf chracters and a prompt character.
+*/
+
+STATUS clkCmd( /* RETURN: OK / ERROR */
+ const char* cmd, /* IN : command */
+ char* rsp /* OUT: response */
+ )
+{
+ STATUS retStat = ERROR;
+ UINT cmdLen;
+ UCHAR rspBuff[MAX_RSP_LEN + 1]; /* + 1 for lf/cr */
+ UINT nBytesUnread;
+ UINT i;
+
+/* retStat = semTake(clkSem, WAIT_FOREVER); /* Block the resourse */
+ if ((semTake(clkSem, WAIT_FOREVER)) != ERROR)
+ {
+ cmdLen = strlen(cmd);
+ ioctl(clkFd, FIORFLUSH, 0); /* clear read buffer */
+ write(clkFd, (char*) cmd, cmdLen); /* send the command */
+ write(clkFd, "\r", 1); /* end with carriage return */
+
+ taskDelay(10); /* wait for response */
+ ioctl(clkFd, FIONREAD, (int)&nBytesUnread); /* check if anything in the read buffer */
+ if (nBytesUnread > 0)
+ { /* Something to read */
+ read(clkFd, rspBuff, 2); /* read CR-LF */
+ read(clkFd, rspBuff, MAX_RSP_LEN); /* read the ascii string */
+ /* loop to find the end of the response */
+ for (i = 0; i < MAX_RSP_LEN; i++)
+ {
+ if ((rspBuff[i] == 0x0A) || (rspBuff[i] == 0x0D)) /* CR/LF ? */
+ {
+ rspBuff[i] = NULL; /* change to null */
+ if (rsp != 0)
+ { /* valid rsp pointer */
+ memcpy(rsp, rspBuff, i);
+ rsp[i] = NULL; /* null terminate */
+ }
+ else
+ { /* command must be from console */
+ printf("CLK Response: %s\n", rspBuff);
+ }
+ retStat = OK;
+ break;
+ }
+ } /* for (i */
+ } /* if (nBytes */
+ } /* if (retStat */
+ semGive(clkSem); /* release the resource */
+ return retStat;
+}
+
+
+/**********************************************************************
+clkNumGet - Number Get
+
+Sends a command to clock module and reads the response.
+This fuctions is used by other functions requiring to send a command to
+the clock module and reading an unsigned numerical value back.
+Returns the number or -1 for error.
+*/
+
+/*
+The response consists of a series of chracters followed by the ascii coded digits.
+The rspExpected does not include the digits. Number of digits can vary. The maximum
+number of digits is numDigits.
+*/
+
+STATUS clkNumGet( /* RETURN : number or -1 for ERROR */
+ const char* cmd, /* IN: commnad */
+ const char* rspExpected, /* IN: expected response */
+ int numDigits, /* IN: maximum number of digits at the end */
+ int* num /* OUT: returned value, valid if STATUS=OK */
+ )
+{
+ char rsp[MAX_RSP_LEN + 1]; /* + 1 for null */
+ int i;
+ int errorFound; /* boolean: error found in response */
+ const char* pRsp;
+ int rspExpectedLen;
+
+ if ((clkCmd(cmd, rsp)) == OK)
+ { /* command successful */
+ rspExpectedLen = strlen(rspExpected);
+ if (memcmp(rsp, rspExpected, rspExpectedLen) == 0)
+ { /* response is expected response */
+ /* search for end of command and compute number */
+ /* read characters from 'left' */
+ for (i = 0, *num = 0, errorFound = FALSE, pRsp = &rsp[rspExpectedLen];
+ (i < numDigits) && (*pRsp != 0) && (errorFound == FALSE);
+ i++, pRsp++ )
+ {
+ if ((*pRsp >= '0') && (*pRsp <= '9'))
+ {
+ *num = *num * 10 + (*pRsp - '0'); /* convert from ASCII */
+ }
+ else
+ errorFound = TRUE; /* invalid character */
+ }
+
+ if ((i == 0) || (*pRsp != 0)) /* No digits or response too long */
+ errorFound = TRUE;
+
+ if (errorFound == FALSE)
+ return OK; /* return offset */
+
+ }
+ }
+ return ERROR; /* return ERROR */
+
+}
+
+
+/**********************************************************************
+clkOffsetSet - Offset Set
+
+Sends a command to clock module to set the given offset.
+Return OK or ERROR.
+*/
+
+/*
+The command sent to the clock module is $PTELS,OFFSET,xxx / $PTELS,OFFS,xxx
+The expected response is $PTELA,OFFSET,xxx / $PTELA,OFFS,xxx
+*/
+
+STATUS clkOffsetSet( /* RETURN: OK / ERROR */
+ UINT offset /* IN: offset */
+ )
+{
+ const char* cmdSet[] = {"$PTELS,OFFSET,","$PTELS,OFFS,"};
+ const char* rspExpectedSet[] = {"$PTELA,OFFSET,","$PTELA,OFFS,"};
+
+ char cmd[MAX_CMD_LEN + 1]; /* + 1 for null */
+ char rspExpected[MAX_RSP_LEN + 1]; /* + 1 for null */
+ char rsp[MAX_RSP_LEN + 1]; /* + 1 for null */
+
+ if (offset <= 127)
+ {
+ /* select command and append the offset in ASCII */
+ sprintf(cmd, "%s%d", cmdSet[clkVerStage], offset);
+ sprintf(rspExpected, "%s%d", rspExpectedSet[clkVerStage], offset);
+
+ if ((clkCmd(cmd, rsp)) == OK) /* send the command */
+ {
+ if ((strcmp(rsp, rspExpected)) == 0) /* Is the response expected response? */
+ return OK;
+ }
+ }
+ return ERROR;
+}
+
+
+/**********************************************************************
+clkOffsetGet - Offset Get
+
+Sends a command to clock module to read the offset.
+Returns the offset or -1 for error.
+*/
+
+/*
+The command sent to the clock module is $PTELQ,OFFSET / $PTELQ,OFFS
+The expected response is $PTELR,OFFSET,xxx / $PTELR,OFFS,xxx
+*/
+
+int clkOffsetGet() /* RETURN: offset or -1 for error */
+{
+ const char* cmdSet[] = {"$PTELQ,OFFSET","$PTELQ,OFFS"};
+ const char* rspExpectedSet[] = {"$PTELR,OFFSET,","$PTELR,OFFS,"};
+ int num;
+
+ if (clkNumGet(cmdSet[clkVerStage], rspExpectedSet[clkVerStage], 3, &num) != OK)
+ {
+ num = -1;
+ }
+ return (num);
+}
+
+
+/**********************************************************************
+clkOscillatorSet - Oscillator Type Set
+
+Sends a command to clock module to set the given Oscillator Type.
+Return OK or ERROR.
+*/
+
+/*
+The command sent to the clock module is $PTELS,OSC,xxx
+The expected response is $PTELA,OSC,xxx
+*/
+
+STATUS clkOscillatorSet( /* RETURN: OK / ERROR */
+ UINT type /* IN: offset */
+ )
+{
+ char cmd[MAX_CMD_LEN + 1]; /* + 1 for null */
+ char rspExpected[MAX_RSP_LEN + 1]; /* + 1 for null */
+ char rsp[MAX_RSP_LEN + 1]; /* + 1 for null */
+
+ if (type <= 127)
+ {
+ /* select command and append the offset in ASCII */
+ sprintf(cmd, "$PTELS,OSC,%d", type);
+ sprintf(rspExpected, "$PTELA,OSC,%d", type);
+
+ if ((clkCmd(cmd, rsp)) == OK) /* send the command */
+ {
+ if ((strcmp(rsp, rspExpected)) == 0) /* Is the response expected response? */
+ return OK;
+ }
+ }
+ return ERROR;
+}
+
+
+/**********************************************************************
+clkBoardRevSet - Board Revision Set
+
+Sends a command to clock module to set the given Board Revision.
+Return OK or ERROR.
+*/
+
+/*
+The command sent to the clock module is $PTELS,BOARD,xxx / $PTELS,BRD,xxx
+The expected response is $PTELA,BOARD,xxx / $PTELA,BRD,xxx
+*/
+
+STATUS clkBoardRevSet( /* RETURN: OK / ERROR */
+ UINT rev /* IN: offset */
+ )
+{
+ const char* cmdSet[] = {"$PTELS,BOARD,","$PTELS,BRD,"};
+ const char* rspExpectedSet[] = {"$PTELA,BOARD,","$PTELA,BRD,"};
+
+ char cmd[MAX_CMD_LEN + 1]; /* + 1 for null */
+ char rspExpected[MAX_RSP_LEN + 1]; /* + 1 for null */
+ char rsp[MAX_RSP_LEN + 1]; /* + 1 for null */
+
+ /* select command and append the offset in ASCII */
+ sprintf(cmd, "%s%d", cmdSet[clkVerStage], rev);
+ sprintf(rspExpected, "%s%d", rspExpectedSet[clkVerStage], rev);
+
+ if ((clkCmd(cmd, rsp)) == OK) /* send the command */
+ {
+ if ((strcmp(rsp, rspExpected)) == 0) /* Is the response expected response? */
+ return OK;
+ }
+ return ERROR;
+}
+
+
+/**********************************************************************
+clkChecksumSet - Checksum Set
+
+Sends a command to clock module to set the given checksum value.
+Return OK or ERROR.
+*/
+
+/*
+The command sent to the clock module is $PTELS,CHECKSUM,xxx / $PTELS,CKSM,xxx
+The expected response is $PTELA,CHECKSUM,xxx / $PTELA,CKSM,xxx
+*/
+
+STATUS clkChecksumSet( /* RETURN: OK / ERROR */
+ UINT checksum /* IN: offset */
+ )
+{
+ const char* cmdSet[] = {"$PTELS,CHECKSUM","$PTELS,CKSM"};
+ const char* rspExpectedSet[] = {"$PTELA,CHECKSUM,","$PTELA,CKSM,"};
+
+ char cmd[MAX_CMD_LEN + 1]; /* + 1 for null */
+ char rspExpected[MAX_RSP_LEN + 1]; /* + 1 for null */
+ char rsp[MAX_RSP_LEN + 1]; /* + 1 for null */
+
+ /* select command and append the offset in ASCII */
+ sprintf(cmd, "%s", cmdSet[clkVerStage]);
+ sprintf(rspExpected, "%s%d", rspExpectedSet[clkVerStage], checksum);
+
+ if ((clkCmd(cmd, rsp)) == OK) /* send the command */
+ {
+ if ((strcmp(rsp, rspExpected)) == 0) /* Is the response expected response? */
+ return OK;
+ }
+ return ERROR;
+}
+
+
+/**********************************************************************
+clkOscillatorTransferFuncSet - Oscillator Transfer Function Set
+
+Sends a command to clock module to set the given Oscillator transfer function.
+Return OK or ERROR.
+*/
+
+/*
+The command sent to the clock module is $PTELS,POS,0 / $PTELS,NEG,1
+The expected response is $PTELA,POS,0 / $PTELA,NEG,1
+*/
+
+STATUS clkOscillatorTransferFuncSet( /* RETURN: OK / ERROR */
+ UINT val /* IN: value */
+ )
+{
+ char cmd[MAX_CMD_LEN + 1]; /* + 1 for null */
+ char rspExpected[MAX_RSP_LEN + 1]; /* + 1 for null */
+ char rsp[MAX_RSP_LEN + 1]; /* + 1 for null */
+
+ if (val == 0)
+ {
+ /* select command and append the offset in ASCII */
+ sprintf(cmd, "$PTELS,POS");
+ sprintf(rspExpected, "$PTELA,POS,0");
+ }
+ else
+ {
+ /* select command and append the offset in ASCII */
+ sprintf(cmd, "$PTELS,NEG");
+ sprintf(rspExpected, "$PTELA,NEG,1");
+ }
+
+ if ((clkCmd(cmd, rsp)) == OK) /* send the command */
+ {
+ if ((strcmp(rsp, rspExpected)) == 0) /* Is the response expected response? */
+ return OK;
+ }
+
+ return ERROR;
+}
+
+
+/**********************************************************************
+clkClockSelectSet - Clock Select Set
+
+Sends a command to clock module to set the given Clock select value.
+Return OK or ERROR.
+*/
+
+/*
+The command sent to the clock module is $PTELS,E1 / $PTELS,T1
+The expected response is $PTELA,E1,1 / $PTELA,T1,0
+*/
+
+STATUS clkClockSelectSet( /* RETURN: OK / ERROR */
+ UINT val /* IN: value */
+ )
+{
+ char cmd[MAX_CMD_LEN + 1]; /* + 1 for null */
+ char rspExpected[MAX_RSP_LEN + 1]; /* + 1 for null */
+ char rsp[MAX_RSP_LEN + 1]; /* + 1 for null */
+
+ if (val == 0)
+ {
+ /* select command and append the offset in ASCII */
+ sprintf(cmd, "$PTELS,T1");
+ sprintf(rspExpected, "$PTELA,T1,0");
+ }
+ else
+ {
+ /* select command and append the offset in ASCII */
+ sprintf(cmd, "$PTELS,E1");
+ sprintf(rspExpected, "$PTELA,E1,1");
+ }
+
+ if ((clkCmd(cmd, rsp)) == OK) /* send the command */
+ {
+ if ((strcmp(rsp, rspExpected)) == 0) /* Is the response expected response? */
+ return OK;
+ }
+
+ return ERROR;
+}
+
+
+/**********************************************************************
+clkSerialNumSet - Serial Number Set
+
+Sends a command to clock module to set the serial number
+Returns the offset OK or ERROR.
+*/
+
+/* No Longer Available */
+
+
+/**********************************************************************
+clkSerialNumGet - Serial Number Get
+
+Sends a command to clock module to read the offset.
+Returns the serial number or -1 for error.
+*/
+
+/*
+for clkVerStage 0
+The command sent to the clock module is $PTELQ,SERIAL
+The expected response is $PTELR,SERIAL,xxx
+
+for other clkVerStage
+The commands sent to the clock module are $PTELQ,SA $PTELQ,SB $PTELQ,SC
+The expected responses are $PTELR,SA,xxx $PTELR,SB,xxx $PTELR,SC,xxx
+The most significant bits are SA and the least significant bits are SC
+*/
+
+STATUS clkSerialNumGet() /* RETURN: OK/ERROR */
+{
+ STATUS retStat = ERROR;
+ char serialNum[SERIAL_NUM_LEN + 1];
+ int num;
+
+ if (clkVerStage == 0)
+ {
+ retStat = clkNumGet("$PTELQ,SERIAL", "$PTELR,SERIAL,", 5, &num);
+ if (retStat != ERROR)
+ {
+ sprintf(clkSerialNum, "%05d", num);
+ }
+ }
+ else
+ {
+ retStat = clkNumGet("$PTELQ,SA", "$PTELR,SA,", 5, &num);
+ if (retStat != ERROR)
+ {
+ sprintf(serialNum, "%05d", num);
+ retStat = clkNumGet("$PTELQ,SB", "$PTELR,SB,", 5, &num);
+ if (retStat != ERROR)
+ {
+ sprintf(serialNum, "%s%05d", serialNum, num);
+ retStat = clkNumGet("$PTELQ,SC", "$PTELR,SC,", 5, &num);
+ if (retStat != ERROR)
+ {
+ sprintf(serialNum, "%s%05d", serialNum, num);
+ strcpy(clkSerialNum, serialNum);
+ }
+ }
+ }
+ }
+ return retStat;
+}
+
+/**********************************************************************
+clkSerialNumSet - Serial Number Set
+
+Sends a command to clock module to write the offset.
+Returns the serial number or -1 for error.
+*/
+
+/*
+for clkVerStage 0
+The command sent to the clock module is $PTELQ,SERIAL
+The expected response is $PTELR,SERIAL,xxx
+
+for other clkVerStage
+The commands sent to the clock module are $PTELQ,SA $PTELQ,SB $PTELQ,SC
+The expected responses are $PTELR,SA,xxx $PTELR,SB,xxx $PTELR,SC,xxx
+The most significant bits are SA and the least significant bits are SC
+*/
+
+STATUS clkSerialNumSet(unsigned short serialA, unsigned short serialB,
+ unsigned short serialC) /* RETURN: OK/ERROR */
+{
+ char cmd[MAX_CMD_LEN + 1]; /* + 1 for null */
+ char rspExpected[MAX_RSP_LEN + 1]; /* + 1 for null */
+ char rsp[MAX_RSP_LEN + 1]; /* + 1 for null */
+
+ if (clkVerStage == 0)
+ {
+ /* select command and append the offset in ASCII */
+ sprintf(cmd, "$PTELS,SERIAL,%d", serialA);
+ sprintf(rspExpected, "$PTELA,SERIAL,%d", serialA);
+
+ if ((clkCmd(cmd, rsp)) == OK) /* send the command */
+ {
+ if ((strcmp(rsp, rspExpected)) == 0) /* Is the response expected response? */
+ return OK;
+ }
+ }
+ else
+ {
+ /* select command and append the offset in ASCII */
+ sprintf(cmd, "$PTELS,SA,%d", serialA);
+ sprintf(rspExpected, "$PTELA,SA,%d", serialA);
+
+ if ((clkCmd(cmd, rsp)) == OK) /* send the command */
+ {
+ if ((strcmp(rsp, rspExpected)) != 0) /* Is the response expected response? */
+ return ERROR;
+ }
+
+ sprintf(cmd, "$PTELS,SB,%d", serialB);
+ sprintf(rspExpected, "$PTELA,SB,%d", serialB);
+
+ if ((clkCmd(cmd, rsp)) == OK) /* send the command */
+ {
+ if ((strcmp(rsp, rspExpected)) != 0) /* Is the response expected response? */
+ return ERROR;
+ }
+
+ sprintf(cmd, "$PTELS,SC,%d", serialC);
+ sprintf(rspExpected, "$PTELA,SC,%d", serialC);
+
+ if ((clkCmd(cmd, rsp)) == OK) /* send the command */
+ {
+ if ((strcmp(rsp, rspExpected)) != 0) /* Is the response expected response? */
+ return ERROR;
+ }
+ }
+
+ return OK;
+}
+
+
+/**********************************************************************
+clkStatGet - Status Get
+
+Sends a command to clock module to read the status.
+Returns the status or -1 for error.
+
+The returned status is:
+
+ 0 - No Alarm conditions
+ 1 - Burst Alarm Active
+ 2 - Frame Alarm Active
+ 3 - Borth Burst and Fram Alarms active
+*/
+
+/*
+The command sent to the clock module is $PTELQ,INT
+The expected response is $PTELR,INT,x
+*/
+
+int clkStatGet() /* RETURN: status or -1 for error */
+{
+ char cmd[] = "$PTELQ,INT";
+ char rspExpected[] = "$PTELR,INT,";
+ int num;
+
+ if (clkNumGet(cmd, rspExpected, 2, &num) != OK)
+ {
+ num = -1;
+ }
+ return (num); /* Max. 1 digit expected */
+}
+
+
+/**********************************************************************
+clkNumDaysTuneReset - Number of Days Tune Reset
+
+Sends a command to clock module to reset the 'Number of Days since Tuning' count.
+Returns the status or -1 for error.
+*/
+
+/*
+The command sent to the clock module is $PTELS,TUNE
+The expected response is $PTELA,TUNE,0
+*/
+
+STATUS clkNumDaysTuneReset() /* RETURN: OK / ERROR */
+{
+ char cmd[] = "$PTELS,TUNE";
+ char rspExpected[] = "$PTELA,TUNE,0";
+ char rsp[MAX_RSP_LEN + 1]; /* + 1 for null */
+
+ if ((clkCmd(cmd, rsp)) == OK) /* send the command */
+ {
+ if ((strcmp(rsp, rspExpected)) == 0) /* Is the response expected response? */
+ return OK;
+ }
+
+ return ERROR;
+}
+
+
+/**********************************************************************
+clkNumDaysTuneGet - Number of Days Tune Get
+
+Sends a command to clock module to read the number of days since last tuneup.
+Returns the no. of days or -1 for error.
+*/
+
+/*
+The command sent to the clock module is $PTELQ,TUNE
+The expected response is $PTELR,TUNE,xxxx
+*/
+
+int clkNumDaysTuneGet() /* RETURN: number of days or -1 for error */
+{
+ char cmd[] = "$PTELQ,TUNE";
+ char rspExpected[] = "$PTELR,TUNE,";
+ int num;
+
+ if (clkNumGet(cmd, rspExpected, 4, &num) != OK)
+ {
+ num = -1;
+ }
+
+ return (num); /* Max. 4 digits expected */
+}
+
+
+/**********************************************************************
+clkNumDaysRunReset - Number of Days Run Reset
+
+Sends a command to clock module to reset the 'Number of Days since Running' count.
+Returns the status or -1 for error.
+*/
+
+/*
+The command sent to the clock module is $PTELS,RUN
+The expected response is $PTELA,RUN,0
+*/
+
+STATUS clkNumDaysRunReset() /* RETURN: OK / ERROR */
+
+{
+ char cmd[] = "$PTELS,RUN";
+ char rspExpected[] = "$PTELA,RUN,0";
+ char rsp[MAX_RSP_LEN + 1]; /* + 1 for null */
+
+ if ((clkCmd(cmd, rsp)) == OK) /* send the command */
+ {
+ if ((strcmp(rsp, rspExpected)) == 0) /* Is the response expected response? */
+ return OK;
+ }
+
+ return ERROR;
+}
+
+
+/**********************************************************************
+clkNumDaysRunGet - Number of Days Run Get
+
+Sends a command to clock module to read the number of days since it is running.
+Returns the no. of days or -1 for error.
+*/
+
+/*
+The command sent to the clock module is $PTELQ,RUN
+The expected response is $PTELR,RUN,xxxx
+*/
+
+int clkNumDaysRunGet() /* RETURN: number of days or -1 for error */
+{
+ char cmd[] = "$PTELQ,RUN";
+ char rspExpected[] = "$PTELR,RUN,";
+ int num;
+
+ if (clkNumGet(cmd, rspExpected, 4, &num) != OK)
+ {
+ num = -1;
+ }
+
+ return (num); /* Max. 4 digits expected */
+}
+
+
+/**********************************************************************
+clkSoftVersionGet - Software Version Get
+
+Sends a command to clock module to get the software version.
+Saves the software version in the file local variable clkSoftVersion.
+*/
+
+/*
+The command sent to the clock module is $PTELQ,SOFT / $PTELQ,SFT
+The expected response is $PTELR,SOFT,x.x / $PTELR,SFT,x.x
+*/
+
+
+LOCAL STATUS clkSoftVersionGet()
+{
+ const char* cmdSet[] = {"$PTELQ,SOFT","$PTELQ,SFT"};
+ const char* rspExpected[] = {"$PTELR,SOFT,","$PTELR,SFT,"};
+
+ char rsp[MAX_RSP_LEN + 1]; /* + 1 for null */
+ int verFound; /* TRUE/ FALSE */
+ int clkStat; /* OK / ERROR */
+ int i;
+ int rspExpectedLen;
+
+ for (verFound = FALSE, clkStat = OK, i = 0;
+ (verFound == FALSE) && (clkStat == OK) && (i < NUM_VERSION_STAGES);
+ i++)
+ {
+ clkStat = clkCmd(cmdSet[i], rsp);
+ if (clkStat == OK)
+ {
+ if (memcmp(rsp, rspExpected[i], strlen(rspExpected[i])) == 0)
+ {
+ verFound = TRUE;
+ rspExpectedLen = strlen(rspExpected[i]);
+ clkSoftVersion[0] = rsp[0 + rspExpectedLen];
+ clkSoftVersion[1] = rsp[1 + rspExpectedLen];
+ clkSoftVersion[2] = rsp[2 + rspExpectedLen];
+ }
+ }
+ }
+ return verFound ? OK : ERROR;
+}
+
+
+/**********************************************************************
+clkSetEepromValue - Set a location in EEPROM.
+
+*/
+
+STATUS clkSetEepromValue(int location, unsigned char val)
+{
+ const char* cmdSet[] = {"$PTELS,EEPROM,","$PTELS,EEPRM,"};
+ const char* rspExpectedSet[] = {"$PTELA,EEPROM,","$PTELA,EEPRM,"};
+
+ char cmd[MAX_CMD_LEN + 1]; /* + 1 for null */
+ char rspExpected[MAX_RSP_LEN + 1]; /* + 1 for null */
+ char rsp[MAX_RSP_LEN + 1]; /* + 1 for null */
+
+ /* select command and append the offset in ASCII */
+ sprintf(cmd, "%s%d,%d", cmdSet[clkVerStage], location, val);
+ sprintf(rspExpected, "%s%d", rspExpectedSet[clkVerStage], val);
+
+ if ((clkCmd(cmd, rsp)) == OK) /* send the command */
+ {
+ if ((strcmp(rsp, rspExpected)) == 0) /* Is the response expected response? */
+ return OK;
+ }
+ return ERROR;
+}
+
+
+/**********************************************************************
+clkSetDateOfLastTuning - Set the last clock tuning date.
+*/
+STATUS clkSetDateOfLastTuning(unsigned char month, unsigned char day, unsigned short year)
+{
+ if (month > 12) return ERROR;
+ if (day > 31) return ERROR;
+
+ if (clkVerStage == 0)
+ {
+ if (clkSetEepromValue(11, month) != OK) return ERROR;
+ if (clkSetEepromValue(12, day) != OK) return ERROR;
+ if (clkSetEepromValue(13, (unsigned char)(year>>8)) != OK) return ERROR;
+ if (clkSetEepromValue(14, (unsigned char) year) != OK) return ERROR;
+ }
+ else
+ {
+ if (clkSetEepromValue(16, month) != OK) return ERROR;
+ if (clkSetEepromValue(17, day) != OK) return ERROR;
+ if (clkSetEepromValue(18, (unsigned char)(year>>8)) != OK) return ERROR;
+ if (clkSetEepromValue(19, (unsigned char) year) != OK) return ERROR;
+ }
+
+ return OK;
+}
+
+
+/**********************************************************************
+clkGetDateOfLastTuning - Get the last clock tuning date.
+*/
+STATUS clkGetDateOfLastTuning(unsigned char *month, unsigned char *day, unsigned short *year)
+{
+ char cmd[MAX_CMD_LEN + 1];
+ char rsp[MAX_CMD_LEN + 1];
+ int num;
+ const char* cmdSet[] = {"$PTELQ,EEPROM,","$PTELQ,EEPRM,"};
+ const char* rspSet[] = {"$PTELR,EEPROM,","$PTELR,EEPRM,"};
+
+ if (clkVerStage == 0)
+ sprintf(cmd, "%s%d", cmdSet[clkVerStage], 11);
+ else
+ sprintf(cmd, "%s%d", cmdSet[clkVerStage], 16);
+ sprintf(rsp, "%s", rspSet[clkVerStage]);
+ if (clkNumGet(cmd, rsp, 3, &num) != OK) return ERROR;
+ *month = (unsigned char)num;
+
+ if (clkVerStage == 0)
+ sprintf(cmd, "%s%d", cmdSet[clkVerStage], 12);
+ else
+ sprintf(cmd, "%s%d", cmdSet[clkVerStage], 17);
+ sprintf(rsp, "%s", rspSet[clkVerStage]);
+ if (clkNumGet(cmd, rsp, 3, &num) != OK) return ERROR;
+ *day = (unsigned char)num;
+
+ if (clkVerStage == 0)
+ sprintf(cmd, "%s%d", cmdSet[clkVerStage], 13);
+ else
+ sprintf(cmd, "%s%d", cmdSet[clkVerStage], 18);
+ sprintf(rsp, "%s", rspSet[clkVerStage]);
+ if (clkNumGet(cmd, rsp, 3, &num) != OK) return ERROR;
+ *year = (unsigned short)(num<<8);
+
+ if (clkVerStage == 0)
+ sprintf(cmd, "%s%d", cmdSet[clkVerStage], 14);
+ else
+ sprintf(cmd, "%s%d", cmdSet[clkVerStage], 19);
+ sprintf(rsp, "%s", rspSet[clkVerStage]);
+ if (clkNumGet(cmd, rsp, 3, &num) != OK) return ERROR;
+ *year |= (unsigned short)(num);
+
+
+ if (*month > 12) return ERROR;
+ if (*day > 31) return ERROR;
+
+ return OK;
+}
+
+
+/**********************************************************************
+clkShowDateOfLastTuning - Print the last clock tuning date.
+*/
+STATUS clkShowDateOfLastTuning()
+{
+ unsigned char month;
+ unsigned char day;
+ unsigned short year;
+
+ if (clkGetDateOfLastTuning(&month, &day, &year) == OK)
+ {
+ printf("Clock Last Tuned on %d/%d/%d.\n", month, day, year);
+ }
+ else
+ {
+ printf("Unable to retrieve a valid clock tuning data!\n");
+ }
+}
+
+
+/**********************************************************************
+clkReadAllEeprom - Read in all the clocks EEPROM values.
+
+*/
+
+STATUS clkReadAllEeprom(unsigned char *buf)
+{
+ STATUS status;
+ char cmd[MAX_CMD_LEN + 1];
+ char rsp[MAX_CMD_LEN + 1];
+ int numBytes, i, num;
+ const char* cmdSet[] = {"$PTELQ,EEPROM,","$PTELQ,EEPRM,"};
+ const char* rspSet[] = {"$PTELR,EEPROM,","$PTELR,EEPRM,"};
+
+ status = OK;
+
+ if (clkVerStage == 0)
+ numBytes = EEPROM_SIZE_REV1_8;
+ else
+ numBytes = EEPROM_SIZE_REVC;
+
+ for (i = 0; i < numBytes; i++)
+ {
+ sprintf(cmd, "%s%d", cmdSet[clkVerStage], i);
+ sprintf(rsp, "%s", rspSet[clkVerStage]);
+ if ((status = clkNumGet(cmd, rsp, 3, &num)) != OK)
+ {
+ break;
+ }
+ else
+ {
+ buf[i] = (unsigned char)num;
+ }
+ }
+
+ return (status);
+}
+
+/**********************************************************************
+clkSaveEepromToNvRam - Copy Clock EEPROM to NV Ram
+
+Reads the clock cards EEPROM values and stores them in the NV Ram on CDC.
+*/
+
+
+STATUS clkSaveEepromToNvRam() /* RETURN: OK / ERROR */
+
+{
+ STATUS status;
+ unsigned char buf[EEPROM_SIZE_REVC];
+
+ /* Read EEPROM from clock card */
+ status = clkReadAllEeprom(buf);
+
+ /* Write EEPROM data to NV Ram */
+ if (status == OK)
+ status = sysClockBoardEepromSet((char *)buf);
+
+ return status;
+}
+
+
+/**********************************************************************
+clkRestoreEepromFromNvRam - Copy Clock EEPROM saved in NV Ram to clock card
+
+Compares the NV Ram saved values against the clock card's EEPROM values.
+If there is a mismatch then the values are copied from NV Ram to EEPROM.
+*/
+
+
+STATUS clkRestoreEepromFromNvRam() /* RETURN: OK / ERROR */
+
+{
+ unsigned char nvRamEeprom[EEPROM_SIZE_REVC];
+ unsigned char clockBoardEeprom[EEPROM_SIZE_REVC];
+ STATUS status;
+ int i, j, numBytes;
+ unsigned short serialA, serialB, serialC;
+
+ /* Read NV Ram copy of EEPROM */
+ status = sysClockBoardEepromGet((char *)nvRamEeprom);
+
+ /* Read EEPROM from clock card */
+ if (status == OK)
+ {
+ status = clkReadAllEeprom(clockBoardEeprom);
+
+ if (status == OK)
+ {
+ if (clkVerStage == 0)
+ numBytes = EEPROM_SIZE_REV1_8;
+ else
+ numBytes = EEPROM_SIZE_REVC;
+
+ for (i=0; i < numBytes; i++)
+ {
+ /* skip all the Num Days values.... */
+ if (clkVerStage == 0)
+ if (i == 6 || i == 7 || i == 8 || i == 9) continue;
+ else
+ if (i == 4 || i == 5 || i == 6 || i == 7) continue;
+
+ if (nvRamEeprom[i] != clockBoardEeprom[i])
+ {
+ printf("Clock Board EEPROM does not match NV Ram!\n"
+ "Clock Board EEPROM will be updated to match NV Ram!\n");
+ /* Write EEPROM from NV Ram */
+
+ /* Set Digital Pot value */
+ if (clkOffsetSet(nvRamEeprom[0]) != OK)
+ printf("Clock Board Update: Unable to restore Digital Pot value!\n");
+
+ /* Set Oscillator transfer function */
+ if (clkOscillatorTransferFuncSet(nvRamEeprom[1]) != OK)
+ printf("Clock Board Update: Unable to restore Oscillator Transfer function value!\n");
+
+ /* Set Clock Select value */
+ if (clkClockSelectSet(nvRamEeprom[2]) != OK)
+ printf("Clock Board Update: Unable to restore Clock Select value!\n");
+
+ /* Set Board Revision */
+ if (clkBoardRevSet(nvRamEeprom[3]) != OK)
+ printf("Clock Board Update: Unable to restore Board Revision!\n");
+
+ if (clkVerStage == 0)
+ {
+ /* Set Serial Number */
+ serialA = nvRamEeprom[4] | (nvRamEeprom[5] << 8);
+ if (clkSerialNumSet(serialA,0,0) != OK)
+ printf("Clock Board Update: Unable to restore Serial Number!\n");
+
+ /* Restore any remaining bytes in EEPROM */
+ for (j=11; j < EEPROM_SIZE_REV1_8; j++)
+ {
+ if (clkSetEepromValue(j, nvRamEeprom[j]) != OK)
+ printf("Clock Board Update: Unable to restore EEPROM loc %d to %d!\n",
+ j, nvRamEeprom[j]);
+ }
+
+ /* Set Checksum */
+ if (clkChecksumSet(nvRamEeprom[10]) != OK)
+ printf("Clock Board Update: Checksum does not match stored value!\n");
+ }
+ else
+ {
+ /* Set Oscillator Type */
+ if (clkOscillatorSet(nvRamEeprom[9]) != OK)
+ printf("Clock Board Update: Unable to restore Oscillator Type!\n");
+
+ /* Set Serial Number */
+ serialA = nvRamEeprom[10] | (nvRamEeprom[11] << 8);
+ serialB = nvRamEeprom[12] | (nvRamEeprom[13] << 8);
+ serialC = nvRamEeprom[14] | (nvRamEeprom[15] << 8);
+ if (clkSerialNumSet(serialA,serialB,serialC) != OK)
+ printf("Clock Board Update: Unable to restore Serial Number!\n");
+
+ /* Restore any remaining bytes in EEPROM */
+ for (j=16; j < EEPROM_SIZE_REVC; j++)
+ {
+ if (clkSetEepromValue(j, nvRamEeprom[j]) != OK)
+ printf("Clock Board Update: Unable to restore EEPROM loc %d to %d!\n",
+ j, nvRamEeprom[j]);
+ }
+
+ /* Set Checksum */
+ if (clkChecksumSet(nvRamEeprom[8]) != OK)
+ printf("Clock Board Update: Checksum does not match stored value!\n");
+ }
+
+ break;
+ }
+ }
+ }
+ }
+ return status;
+}
+
+
+/**********************************************************************
+clkValidateEeprom - Make sure the EEPROM is correct
+
+
+*/
+
+
+STATUS clkValidateEeprom() /* RETURN: OK / ERROR */
+{
+ STATUS status = OK;
+ /* If NV Ram has a saved EEPROM copy then use it to verify the EEPROM */
+ printf("Validating Clock Board EEPROM\n");
+ if (sysIsClockBoardEepromSet())
+ {
+ if ((status = clkRestoreEepromFromNvRam()) != OK)
+ {
+ printf("WARNING - Unable to restore Clock Board EEPROM!\n");
+ }
+ }
+ /* Otherwise assume the clock board EEPROM is good and save it to Nv Ram */
+ else
+ {
+ printf("Saving Clock Board EEPROM into NV Ram!\n");
+ if ((status = clkSaveEepromToNvRam()) != OK)
+ {
+ printf("WARNING - Unable to save Clock Board EEPROM!\n");
+ }
+ }
+
+ return (status);
+}
diff --git a/data/mnet/GP10/Host/cdcUtils/coff_loader/Makefile b/data/mnet/GP10/Host/cdcUtils/coff_loader/Makefile
new file mode 100644
index 0000000..62a6752
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/coff_loader/Makefile
@@ -0,0 +1,53 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..\..
+
+# These Must be Properly Defined
+THIS_APP_DIR = cdcUtils
+THIS_DIRECTORY = Coff_loader
+MY_OUTPUT = $(OBJDIR)\Coff_loader.out
+
+# Name(s) of Common VOB directories to include
+COMMON_BLD_DIR =
+
+include $(TOP_OF_VOB)\l3defs.mk
+
+all: makeCommonObjs $(MY_OUTPUT)
+
+# Adds the .o file(s) list needed from the Common VOB
+makeCommonObjs:
+ifneq ($(COMMON_BLD_DIR),)
+ @for %f in ($(COMMON_BLD_DIR)) do \
+ make -C $(COMMON_VOB_APP_DIR)\%f \
+ all VOB=$(VOBNAME) APPDIR=Host\$(THIS_APP_DIR)\$(THIS_DIRECTORY)
+endif
+
+
+# If Common VOB directories to include get the .o files from bin
+$(MY_OUTPUT): $(MODULE_OBJS)
+ifneq ($(COMMON_BLD_DIR),)
+ $(LD) -r -o $@.tmp $() $(MODULE_OBJS) $(wildcard ./bin/*.o)
+else
+ $(LD) -r -o $@.tmp $() $(MODULE_OBJS)
+endif
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+ifneq ($(COMMON_BLD_DIR),)
+ $(RM) bin\*.o
+ $(RM) bin\*.out
+endif
diff --git a/data/mnet/GP10/Host/cdcUtils/coff_loader/cload.c b/data/mnet/GP10/Host/cdcUtils/coff_loader/cload.c
new file mode 100644
index 0000000..382176b
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/coff_loader/cload.c
@@ -0,0 +1,1929 @@
+/***************************************************************************
+* 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 long. */
+/* 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. */
+/* myalloc() - Application version of malloc(). */
+/* mralloc() - Application version of realloc(). */
+/* load_msg() - Write diagnostic messages during loading. */
+/* */
+/******************************************************************************/
+#include "header.h"
+
+
+/*----------------------------------------------------------------------------*/
+/* 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 */
+
+/*----------------------------------------------------------------------------*/
+/* APPLICATION VARIABLES */
+/*----------------------------------------------------------------------------*/
+FILE *fin; /* INPUT FILE */
+int verbose = FALSE; /* PRINT PROGRESS INFO */
+int need_data = TRUE; /* APPLICATION NEEDS RAW DATA */
+int need_symbols = FALSE; /* APPLICATION NEEDS SYMBOL TABLE */
+int clear_bss = FALSE; /* CLEAR BSS SECTION */
+
+/*----------------------------------------------------------------------------*/
+/* 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 */
+
+#ifdef notnow
+int big_e_config = TRG_DEF_BIG_E; /* ENDIANNESS CONFIGURATION */
+#endif
+int big_e_config = FALSE; /* ENDIANNESS CONFIGURATION */
+
+/*----------------------------------------------------------------------------*/
+/* 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
+{
+ long rt_index; /* INDEX OF SYMBOL IN SYMBOL TABLE */
+ long 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 */
+
+#ifdef notnow
+static RELOC_TAB *reloc_tab = NULL; /* RELOCATION SYMBOL TABLE */
+#endif
+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 long size; /* SIZE OF THIS PACKET */
+ unsigned long offset; /* STARTING OFFSET OF THIS PACKET */
+ unsigned long 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 long unpack();
+int cload_strings();
+int reloc_offset(int);
+void str_free(STRTAB *);
+
+
+/******************************************************************************/
+/* */
+/* CLOAD() - Main driver for COFF loader. */
+/* */
+/******************************************************************************/
+int cload()
+{
+ int result;
+
+ load_err = 0;
+ result = cload_headers() && cload_symbols() && cload_data();
+
+ if (reloc_tab) myfree(reloc_tab);
+ reloc_tab = NULL;
+
+ return result;
+}
+
+
+/******************************************************************************/
+/* */
+/* CLOAD_HEADERS() - Read in the various headers of the COFF file. */
+/* */
+/******************************************************************************/
+int cload_headers()
+{
+ int i;
+
+ byte_swapped = FALSE;
+ need_reloc = FALSE;
+
+ if (fseek(fin, 0L, 0) != 0 || !fread(&file_hdr, FILHSZ, 1, fin))
+ { load_err = E_FILE; return FALSE; }
+
+ /*-------------------------------------------------------------------------*/
+ /* 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;
+
+ /*-------------------------------------------------------------------------*/
+ /* READ IN OPTIONAL HEADER, IF THERE IS ONE, AND SWAP IF NEEDED. */
+ /*-------------------------------------------------------------------------*/
+ if (file_hdr.f_opthdr == AOUTSZ)
+ {
+ fseek(fin, (long)FILHSZ_IN(coff_version), 0);
+ if (fread(&o_filehdr, file_hdr.f_opthdr, 1, fin) != 1)
+ { load_err = E_FILE; return FALSE; }
+
+ 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) myfree(sect_hdrs);
+ if (o_sect_hdrs) myfree(o_sect_hdrs);
+
+ if (!(sect_hdrs = myalloc((n_sections = file_hdr.f_nscns) * SCNHSZ)))
+ { load_err = E_ALLOC; return FALSE; }
+
+ fseek(fin, (long)FILHSZ_IN(coff_version) + file_hdr.f_opthdr, 0);
+
+ /*-------------------------------------------------------------------------*/
+ /* 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 (fread(sect_hdrs,SCNHSZ_IN(coff_version),n_sections,fin) != n_sections)
+ { load_err = E_FILE; return FALSE; }
+ }
+ else
+ {
+ if (!(o_sect_hdrs = myalloc(n_sections * SCNHSZ_IN(coff_version))))
+ { load_err = E_ALLOC; return FALSE; }
+
+ if (fread(o_sect_hdrs,SCNHSZ_IN(coff_version),n_sections,fin) != n_sections)
+ { load_err = E_FILE; return FALSE; }
+ }
+
+ if (reloc_amount) myfree(reloc_amount);
+
+ if (!(reloc_amount = myalloc(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); 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);
+ }
+ }
+
+ /*---------------------------------------------------------------------*/
+ /* Old COFF version section headers are now ready to be transferred. */
+ /*---------------------------------------------------------------------*/
+ if (!ISCOFF_2(coff_version))
+ {
+ 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;
+ }
+
+ reloc_amount[i] = 0;
+
+ /*---------------------------------------------------------------------*/
+ /* Fix up section name if it is a pointer into the string table. */
+ /*---------------------------------------------------------------------*/
+ if (sptr->s_zeroes == 0L)
+ {
+ STRTAB *packet = str_head;
+ while (sptr->s_offset < (long)packet->offset) packet = packet->next;
+ sptr->s_nptr = packet->buf + (sptr->s_offset - packet->offset);
+ }
+ }
+
+ /*-------------------------------------------------------------------------*/
+ /* 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; }
+
+ if (verbose) load_msg(" %d sections, %s format, %s data\n %s\n",
+ n_sections,
+ byte_swapped ? "swapped" : "unswapped",
+ big_e_target ? "big-E" : "little-E",
+ need_reloc ? "Relocatable file" : "No reloc");
+
+ return TRUE;
+}
+
+
+/******************************************************************************/
+/* */
+/* 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) && !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, AND DEFER THE CINIT */
+ /* SECTION UNTIL LATER TO ENSURE BSS IS LOADED FIRST. */
+ /*----------------------------------------------------------------------*/
+ if ((sptr->s_scnptr || (clear_bss && IS_BSS(sptr))) &&
+ (sptr->s_size) &&
+ !(sptr->s_flags & STYP_DSECT) &&
+ !(sptr->s_flags & STYP_COPY) &&
+ !(sptr->s_flags & STYP_NOLOAD))
+ {
+ if (verbose) load_msg(" Loading <%s>,\taddr=0x%lx, size=0x%03lx",
+ sname, sptr->s_vaddr + reloc_amount[curr_sect],
+ sptr->s_size);
+
+ ok &= cload_sect_data(sptr);
+ if (verbose) load_msg("\n");
+ }
+
+ /*----------------------------------------------------------------------*/
+ /* IF CLEAR_BSS IS NOT SET, GO AHEAD AND DO CINIT IN ORDER. */
+ /*----------------------------------------------------------------------*/
+ if (!clear_bss && IS_CINIT(sptr))
+ {
+ if (verbose) load_msg(" Autoinitialization from <%s>", sname);
+ ok &= cload_sect_data(sptr);
+ if (verbose) load_msg("\n");
+ }
+ }
+
+ /*-------------------------------------------------------------------------*/
+ /* IF WE DEFERRED CINIT, LOAD IT/THEM NOW. */
+ /*-------------------------------------------------------------------------*/
+ if (clear_bss)
+ 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))
+ {
+ if (verbose) load_msg(" Autoinitialization from <%s>", sname);
+ ok &= cload_sect_data(sptr);
+ if (verbose) load_msg("\n");
+ }
+ }
+
+ return ok;
+}
+
+
+/******************************************************************************/
+/* */
+/* CLOAD_SECT_DATA() - Read, relocate, and write out the data for one section.*/
+/* */
+/******************************************************************************/
+int cload_sect_data(sptr)
+ SCNHDR *sptr;
+{
+ T_ADDR addr = sptr->s_vaddr; /* CURRENT ADDRESS IN SECTION */
+ unsigned long nbytes; /* BYTE COUNT WITHIN SECTION */
+ int packet_size; /* 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 */
+ unsigned char packet[LOADBUFSIZE]; /* LOAD BUFFER */
+ int relsz = RELSZ_IN(coff_version);
+
+ /*-------------------------------------------------------------------------*/
+ /* READ THE FIRST RELOCATION ENTRY, IF THERE ARE ANY. */
+ /* IF THIS IS A BSS SECTION, CLEAR THE LOAD BUFFER. */
+ /*-------------------------------------------------------------------------*/
+ if (need_reloc && sptr->s_nreloc &&
+ (fseek(fin, sptr->s_relptr, 0) != 0 || !reloc_read(&reloc)))
+ { load_err = E_FILE; return FALSE; }
+
+ if (IS_BSS(sptr))
+#ifdef OTIS
+ if (mem_fill((TRG_MVAL)0, LOCTOBYTE(sptr->s_size), addr, sptr->s_page))
+ return TRUE;
+ else { load_err = E_MEMWRITE; return FALSE; }
+#else
+ for (nbytes = 0; nbytes < LOADBUFSIZE; ++nbytes) packet[nbytes] = 0;
+#endif
+
+ /*-------------------------------------------------------------------------*/
+ /* COPY ALL THE DATA IN THE SECTION. */
+ /*-------------------------------------------------------------------------*/
+ for (nbytes = 0; nbytes < (unsigned long)LOCTOBYTE(sptr->s_size);
+ nbytes += packet_size)
+ {
+ int j;
+
+ /*----------------------------------------------------------------------*/
+ /* READ IN A BUFFER OF DATA. IF THE PREVIOUS RELOCATION SPANNED */
+ /* ACCROSS 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, LOADBUFSIZE);
+
+ if ( !IS_BSS(sptr) &&
+ (fseek(fin, sptr->s_scnptr + (long)(nbytes + excess), 0) != 0 ||
+ fread(packet + excess, packet_size - excess, 1, fin) != 1))
+ { load_err = E_FILE; return FALSE; }
+ excess = 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 INDEX OF FIELD*/
+
+ /*----------------------------------------------------------------*/
+ /* 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 + MAX((int)WORDSZ, reloc_size(reloc.r_type)) > 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)) return FALSE;
+
+ if (n_reloc++ < sptr->s_nreloc &&
+ (fseek(fin, sptr->s_relptr + ((long)n_reloc * relsz), 0) != 0 ||
+ !reloc_read(&reloc)))
+ { load_err = E_FILE; 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) :
+ mem_write(packet, packet_size, addr + reloc_amount[curr_sect],
+ sptr->s_page)))
+ { load_err = E_MEMWRITE; return FALSE; }
+
+ /*----------------------------------------------------------------------*/
+ /* KEEP TRACK OF THE ADDRESS WITHIN THE SECTION. */
+ /*----------------------------------------------------------------------*/
+ addr += BYTETOLOC(packet_size);
+
+ if (verbose) load_msg(".");
+ }
+ return TRUE;
+}
+
+
+/******************************************************************************/
+/* */
+/* CLOAD_CINIT() - Process one buffer of C initialization records. */
+/* */
+/******************************************************************************/
+int cload_cinit(packet, packet_size, excess)
+ unsigned char *packet; /* LOAD BUFFER */
+ int *packet_size; /* POINTER TO BUFFER SIZE */
+ int *excess; /* RETURNED NUMBER OF UNUSED BYTES */
+{
+ int i; /* BYTE COUNTER */
+ int init_packet_size; /* SIZE OF CURRENT INITIALIZATION */
+ static T_ADDR init_addr; /* ADDRESS OF CURRENT INITIALIZATION */
+ int bss_sect; /* BSS SECTION ASSOC WITH CINIT SEC */
+
+ /*-------------------------------------------------------------------------*/
+ /* FIND THE BSS SECTION ASSOCIATED WITH THE THE CINIT SECTION CURRENTLY */
+ /* BEING LOADED. */
+ /*-------------------------------------------------------------------------*/
+ for (bss_sect = 0; bss_sect < n_sections; ++bss_sect)
+ if (IS_BSS(SECT_HDR(bss_sect))) 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 (verbose)
+ load_msg("\n\tLoading <.cinit>,\taddr=0x%lx, size=0x%04lx",
+ init_addr, init_size);
+
+ if (!mem_write(packet + i, init_packet_size, init_addr,
+ SECT_HDR(bss_sect)->s_page))
+ return FALSE;
+
+ init_addr += BYTETOLOC(init_packet_size);
+ init_size -= init_packet_size / INIT_WSIZE;
+ }
+ }
+ return TRUE;
+}
+
+
+/******************************************************************************/
+/* */
+/* CLOAD_SYMBOLS() - Read in the symbol table. */
+/* */
+/******************************************************************************/
+int cload_symbols()
+{
+ SYMENT sym;
+ AUXENT aux;
+ long 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 = myalloc(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 long str_size; /* SIZE OF STRING TABLE */
+ unsigned long 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 */
+
+ /*------------------------------------------------------------------------*/
+ /* 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_hdr.f_nsyms == 0) ||
+ fseek(fin, file_hdr.f_symptr + (file_hdr.f_nsyms * SYMESZ), 0) != 0 ||
+ fread(&str_size, sizeof(long), 1, fin) != 1)
+ return TRUE;
+
+ 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 */
+
+ if (verbose) load_msg(" %ld symbols. String table size=%ld\n",
+ file_hdr.f_nsyms, str_size ? str_size : 0L);
+
+ /*------------------------------------------------------------------------*/
+ /* 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 = myalloc(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)
+ strncpy(packet->buf, str_head->buf + str_head->size, excess);
+
+ ntoread = (unsigned int)(bufsize - excess);
+ if (fread(packet->buf + excess, ntoread, 1, fin) != 1)
+ { load_err = E_FILE; return FALSE; }
+ 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;
+}
+
+
+/******************************************************************************/
+/* */
+/* STR_FREE() - Free the list of string table buffers. */
+/* */
+/******************************************************************************/
+void str_free(str_head)
+ STRTAB *str_head;
+{
+ STRTAB *this, *next;
+
+ for (this = str_head; this; this = next)
+ {
+ next = this->next;
+ myfree(this);
+ }
+}
+
+
+
+/******************************************************************************/
+/* */
+/* SYM_READ() - Read and relocate a symbol and its aux entry. Return the */
+/* index of the next symbol. */
+/* */
+/******************************************************************************/
+long sym_read(index, sym, aux)
+ long index;
+ SYMENT *sym;
+ AUXENT *aux;
+{
+ /*------------------------------------------------------------------------*/
+ /* READ IN A SYMBOL AND ITS AUX ENTRY. */
+ /*------------------------------------------------------------------------*/
+ 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; }
+
+ 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 (!strcmp(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) == DT_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) == DT_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);
+}
+
+
+/******************************************************************************/
+/* */
+/* SYM_NAME() - Return a pointer to the name of a symbol in either the symbol */
+/* entry or the string table. */
+/* */
+/******************************************************************************/
+char *sym_name(symptr)
+ SYMENT *symptr;
+{
+ static char temp[9];
+
+ if (symptr->n_zeroes == 0)
+ {
+ STRTAB *packet = str_head;
+ while (symptr->n_offset < (long)packet->offset) packet = packet->next;
+
+ return packet->buf + (symptr->n_offset - packet->offset);
+ }
+
+ strncpy(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(symptr)
+ 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 = myalloc(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;
+}
+
+
+/******************************************************************************/
+/* */
+/* RELOC_ADD() - Add an entry to the relocation symbol table. This table */
+/* stores relocation information for each relocatable symbol. */
+/* */
+/******************************************************************************/
+int reloc_add(index, sym)
+ long index;
+ SYMENT *sym;
+{
+ long 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 = mralloc((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(rp, data, 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 */
+ long objval; /* FIELD TO BE PATCHED */
+ long reloc_amt; /* AMOUNT OF RELOCATION */
+
+ int pp_shift_cnt = 0;
+ int pp_local = FALSE;
+ int pp_neg = 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. */
+ /*--------------------------------------------------------------*/
+ if (verbose)
+ load_msg( "PP 15-bit offset overflow at %08lx in section %s",
+ rp->r_vaddr, sname);
+ 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 */
+ {
+ long 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. */
+ /*--------------------------------------------------------------*/
+ if (verbose)
+ load_msg( "PP 15-bit offset overflow at %08lx in section %s",
+ rp->r_vaddr, sname);
+ 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. */
+ /*--------------------------------------------------------------*/
+ if (verbose)
+ load_msg( "PP 15-bit offset overflow at %08lx in section %s",
+ rp->r_vaddr, sname);
+ 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 > (long)(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) > (long)(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:
+ {
+ int shift = 8 * (4 - fieldsz);
+ unsigned long 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;
+
+ reloc_amt -= pcdif;
+
+ if (rp->r_type == R_GSPPCR16 || rp->r_type == R_GSPPCA16)
+ reloc_amt >>= 4; /* BITS TO WORDS */
+
+ objval = (long)(objval << shift) >> shift; /* SIGN EXTEND */
+ objval += reloc_amt;
+ 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 = (long)((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) |
+ (((long)(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;
+
+ /*--------------------------------------------------------------------*/
+ /* 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 = (((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 = (((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;
+
+ /*----------------------------------------------------------------------*/
+ /* 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. */
+/* */
+/******************************************************************************/
+int reloc_read(rptr)
+ RELOC *rptr;
+{
+#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; RELOC_OLD old; } input_entry;
+
+ if (fread(&input_entry, RELSZ_IN(coff_version), 1, fin) != 1)
+ { load_err = E_FILE; return FALSE; }
+
+ /*------------------------------------------------------------------------*/
+ /* 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_symndx);
+ swap2byte(&input_entry.old.r_disp);
+ swap2byte(&input_entry.old.r_type);
+ }
+ 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
+ {
+ if (byte_swapped)
+ {
+ swap4byte(&rptr->r_vaddr); swap4byte(&rptr->r_symndx);
+ swap2byte(&rptr->r_disp); swap2byte(&rptr->r_type);
+ }
+ *rptr = input_entry.new;
+ }
+
+#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_symndx);
+ swap2byte(&rptr->r_disp);
+ swap2byte(&rptr->r_type);
+ }
+#endif
+
+ return TRUE;
+}
+
+
+/*************************************************************************/
+/* */
+/* RELOC_SIZE()- */
+/* Return the field size of a relocation type. */
+/* */
+/*************************************************************************/
+
+int reloc_size(type)
+ 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_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_GSPPCR16:
+ case R_GSPPCA16:
+ case R_PARTLS16:
+ case R_PARTMS8:
+ case R_PARTMS9:
+ 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(type)
+ 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(type)
+ 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. */
+/* */
+/******************************************************************************/
+long sym_reloc_amount(rp)
+ RELOC *rp;
+{
+ long 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 long so it can be relocated. */
+/* */
+/******************************************************************************/
+unsigned long unpack(data, fieldsz, wordsz, bit_offset)
+ unsigned char *data;
+ int fieldsz;
+ int wordsz;
+ int bit_offset;
+{
+ register int i;
+ unsigned long 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(objval, data, fieldsz, wordsz, bit_offset)
+ unsigned long 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*/
+ int tl = 8 - tr; /* num unused MS bits in start */
+ unsigned long 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(filptr, count, lptr, scnum)
+ long 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 (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; }
+
+ /*------------------------------------------------------------------------*/
+ /* 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 long. */
+/* */
+/******************************************************************************/
+void swap4byte(addr)
+ void *addr;
+{
+ unsigned long *value = addr;
+ unsigned long 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(addr)
+ void *addr;
+{
+ unsigned short *value = addr;
+ unsigned short temp1,temp2;
+
+ temp1 = temp2 = *value;
+ *value = ((temp2 & 0xFF) << 8) | ((temp1 >> 8) & 0xFF);
+}
diff --git a/data/mnet/GP10/Host/cdcUtils/coff_loader/coff.c b/data/mnet/GP10/Host/cdcUtils/coff_loader/coff.c
new file mode 100644
index 0000000..06d252d
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/coff_loader/coff.c
@@ -0,0 +1,462 @@
+/****************************************************************************/
+/* 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 */
+/* -v verbose (debug) */
+/* */
+/*--------------------------------------------------------------------------*/
+/* 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"
+#include <string.h>
+#include "l1proxy/l1proxy.h"
+
+#if MSDOS
+#define READ_BIN "rb"
+#else
+#define READ_BIN "r"
+#endif
+
+void myfreeall(void);
+
+/*--------------------------------------------------------------------------*/
+/* LOADER DEFINITIONS */
+/*--------------------------------------------------------------------------*/
+FILE *fopen();
+char *strrchr(), *malloc(), *realloc();
+
+unsigned long reloc = 0; /* RELOCATION AMOUNT */
+int quiet = 0; /* NO BANNER */
+int memDebug = 0; /* DEBUG MEMORY */
+
+#ifdef unix
+
+/****************************************************************************/
+/* */
+/* MAIN() - Main driver for loader. Read in options and filename, open */
+/* COFF file, and call 'cload()'. */
+/* */
+/****************************************************************************/
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ char fname[256];
+ char *ctmp;
+ int i;
+ int files = 0;
+
+ need_symbols = 0; /* TELL LOADER NOT TO READ SYM TABLE */
+
+ /*-----------------------------------------------------------------------*/
+ /* PROCESS COMMAND LINE ARGUMENTS */
+ /*-----------------------------------------------------------------------*/
+ for (i = 1; i < argc; ++i)
+ {
+ char *argp = argv[i];
+
+ if (*argp == '-') /* OPTIONS */
+ while (*++argp) switch(*argp)
+ {
+ case 'B': case 'b': clear_bss = 1; break;
+ case 'Q': case 'q': quiet = 1; break;
+ case 'V': case 'v': ++verbose; break;
+ case 'R': case 'r': sscanf(argv[++i],"%lx",&reloc); break;
+ default : continue;
+ }
+ else /* FILENAMES */
+ {
+ strcpy(fname, argp);
+ files = 1;
+ }
+ }
+
+ /*-----------------------------------------------------------------------*/
+ /* SAY HELLO TO USER AND PROMPT FOR FILENAME IF NOT GIVEN. */
+ /*-----------------------------------------------------------------------*/
+ if (!quiet) printf("COFF Loader v6.00\n");
+
+ if (!files)
+ {
+ char *p;
+ printf(" COFF file [.out]: ");
+ fgets(fname, 64, stdin);
+ if (p = strrchr(fname, '\n')) *p = '\0';
+ }
+
+ /*-----------------------------------------------------------------------*/
+ /* OPEN THE COFF FILE. IF THE HOST DISTIGUISHES FILE TYPES, BE SURE */
+ /* TO OPEN IT AS A BINARY FILE. */
+ /*-----------------------------------------------------------------------*/
+ ctmp = strrchr(fname,'.');
+ if ((!ctmp) || (ctmp < strrchr(fname,'\\'))) strcat(fname,".out");
+
+ if (!(fin = fopen(fname, READ_BIN)))
+ { printf("\n>> can't open file <%s>\n", fname); exit(-1); }
+
+ /*-----------------------------------------------------------------------*/
+ /* LOAD THE FILE. CLOSE IT WHEN FINISHED. */
+ /*-----------------------------------------------------------------------*/
+ if (!cload()) { printf("\n>> error loading file\n"); exit(-1); }
+ fclose(fin);
+}
+#endif
+
+
+/****************************************************************************/
+/* */
+/* ldCoff() - Main driver for loader. */
+/* */
+/****************************************************************************/
+int ldCoff(char *file, char *base_prefix)
+{
+ char fname[256];
+ char *ctmp;
+ int i;
+ int files = 0;
+ int result = ERROR;
+
+ need_symbols = 0; /* TELL LOADER NOT TO READ SYM TABLE */
+ clear_bss = 1;
+ quiet = 1;
+ verbose = 0;
+ memDebug = 0;
+ strcpy(fname, base_prefix);
+ strcat(fname, "/");
+ strcat(fname, file);
+ files = 1;
+
+ /*-----------------------------------------------------------------------*/
+ /* SAY HELLO TO USER AND PROMPT FOR FILENAME IF NOT GIVEN. */
+ /*-----------------------------------------------------------------------*/
+ if (!quiet) printf("COFF Loader v6.00\n");
+
+ if (!files)
+ {
+ char *p;
+ printf(" COFF file [.out]: ");
+ fgets(fname, 64, stdin);
+ if (p = strrchr(fname, '\n')) *p = '\0';
+ }
+
+ /*-----------------------------------------------------------------------*/
+ /* OPEN THE COFF FILE. IF THE HOST DISTIGUISHES FILE TYPES, BE SURE */
+ /* TO OPEN IT AS A BINARY FILE. */
+ /*-----------------------------------------------------------------------*/
+ ctmp = strrchr(fname,'.');
+ if ((!ctmp) || (ctmp < strrchr(fname,'\\'))) strcat(fname,".out");
+
+ if (!(fin = fopen(fname, READ_BIN)))
+ {
+ printf("\n>> can't open file <%s>\n", fname);
+ return(ERROR);
+ }
+
+ /*-----------------------------------------------------------------------*/
+ /* LOAD THE FILE. CLOSE IT WHEN FINISHED. */
+ /*-----------------------------------------------------------------------*/
+ if (!cload())
+ {
+ printf("\n>> error loading file\n");
+ myfreeall();
+ return(ERROR);
+ }
+ fclose(fin);
+ myfreeall();
+ return(OK);
+}
+
+
+/****************************************************************************/
+/* */
+/* 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(buffer, nbytes, addr, page)
+ 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 */
+{
+ if (verbose)
+ {
+ int i;
+ printf("\n[%0*lx]:%d:", 2 * sizeof(T_ADDR), addr, nbytes);
+ for (i = 0; i < nbytes; ++i) printf("%02x ", buffer[i]);
+ printf("\n");
+ }
+
+#ifndef unix
+ {
+ unsigned char *p = buffer;
+ int verifyCount;
+ int isVerified = FALSE;
+ unsigned int verifyWord, n;
+
+ for (n = 0; n < nbytes; n += 4)
+ {
+ swap4byte(&p[n]);
+ }
+
+ /* Write the data to both dsp 0 and 1 */
+ hpi2dsp(1, buffer, addr, nbytes);
+ hpi2dsp(0, buffer, addr, nbytes);
+
+ /* Now verify that the data was written correctly. Each word will */
+ /* be verified one by one to assure that hpi auto increment did */
+ /* not introduce any errors. */
+ for (n = 0; n < nbytes; n += sizeof(unsigned int))
+ {
+ /* First try DSP 0 */
+ isVerified = FALSE;
+ verifyCount = 3;
+ do
+ {
+ dsp2hpi(0, addr+n, (unsigned char *)&verifyWord, sizeof(unsigned int));
+
+ if (*(unsigned int *)(buffer + n) != verifyWord)
+ {
+ hpi2dsp(0, buffer+n, addr+n, sizeof(unsigned int));
+ verifyCount--;
+ printf ("WARNING: Retrying writing DSP 0 addr %#x wrote(%#x)"
+ " read back(%#x)\n", addr+n, *(unsigned int *)(buffer + n),
+ verifyWord);
+ }
+ else
+ {
+ isVerified = TRUE;
+ }
+
+ } while ((isVerified == FALSE) && verifyCount);
+
+ if (!verifyCount)
+ {
+ printf ("ERROR: After 3 retries unable to write to DSP 0 addr %#x\n",
+ addr+n);
+ }
+
+ /* Now try DSP 1 */
+ isVerified = FALSE;
+ verifyCount = 3;
+ do
+ {
+ dsp2hpi(1, addr+n, (unsigned char *)&verifyWord, sizeof(unsigned int));
+
+ if (*(unsigned int *)(buffer + n) != verifyWord)
+ {
+ hpi2dsp(1, buffer+n, addr+n, sizeof(unsigned int));
+ verifyCount--;
+ printf ("WARNING: Retrying writing DSP 1 addr %#x wrote(%#x)"
+ " read back(%#x)\n", addr+n, *(unsigned int *)(buffer + n),
+ verifyWord);
+ }
+ else
+ {
+ isVerified = TRUE;
+ }
+
+ } while ((isVerified == FALSE) && verifyCount);
+
+ if (!verifyCount)
+ {
+ printf ("ERROR: After 3 retries unable to write to DSP 1 addr %x\n",
+ addr+n);
+ }
+ }
+ }
+#endif
+
+ /*-----------------------------------------------------------------------*/
+ /* INSERT CUSTOM CODE HERE TO LOAD TARGET MEMORY. */
+ /*-----------------------------------------------------------------------*/
+
+ 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(indx, sym, aux)
+ long 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(need_reloc)
+ int need_reloc;
+{
+ return 1;
+}
+
+
+
+/****************************************************************************/
+/* */
+/* MYALLOC() - Application version of 'malloc()'. */
+/* MRALLOC() - Application version of 'realloc()'. */
+/* */
+/****************************************************************************/
+void *myalloc(size)
+ unsigned int size;
+{
+ char *p = malloc(size);
+ if (memDebug) printf("malloc-->%08x %08x\n", p, size);
+ if (p) return p;
+
+ printf("\n>> out of memory\n");
+ exit(-1);
+}
+
+void *mralloc(p, size)
+ void *p;
+ unsigned int size;
+{
+ if (memDebug) printf("realloc-->%08x %08x", p, size);
+ p = realloc(p, size);
+ if (memDebug) printf(" %08x\n", p);
+ if (p) return p;
+
+ printf("\n>> out of memory\n");
+ exit(-1);
+}
+void myfree(void *p)
+{
+ if (memDebug) printf("free-->%08x\n", p);
+ free(p);
+}
+
+void *reloc_tab;
+void myfreeall(void)
+{
+ if (sect_hdrs)
+ {
+ myfree(sect_hdrs);
+ sect_hdrs = 0;
+ }
+
+ if (o_sect_hdrs)
+ {
+ myfree(o_sect_hdrs);
+ o_sect_hdrs = 0;
+ }
+
+ if (reloc_amount)
+ {
+ myfree(reloc_amount);
+ reloc_amount = 0;
+ }
+
+ if (reloc_tab)
+ {
+ myfree(reloc_tab);
+ reloc_tab = 0;
+ }
+
+ if (str_head)
+ {
+ str_free(str_head);
+ str_head = 0;
+ }
+}
+
+
+/****************************************************************************/
+/* */
+/* LOAD_MSG() - Called by loader to write debug messages. */
+/* */
+/****************************************************************************/
+void load_msg(a,b,c,d,e,f,g)
+char *a;
+long b,c,d,e,f,g;
+{
+ printf(a,b,c,d,e,f,g);
+}
+
+
+
+/*----------------------------------------------------------------------------**
+**
+** METHOD NAME: LoadDSPCode
+**
+** PURPOSE: Send the DSP message to the preregistered message que.
+**
+** INPUT PARAMETERS: fileName - path & name of the file to load into DSP's
+**
+** RETURN VALUE(S): OK = File Loaded, ERROR = No File Loaded.
+**
+**----------------------------------------------------------------------------*/
+
+STATUS LoadDSPCode(char *fileName, char *base_prefix)
+{
+ STATUS result = ERROR;
+
+ if (fileName != NULL)
+ {
+ dspReset();
+ SetUpForDSPTestBootupMsg();
+
+ result = ldCoff(fileName, base_prefix);
+ if ( result == OK )
+ {
+ printf("Waiting for DSP Bootup message...\n");
+ WaitForDSPTestBootupMsg();
+ printf("Received DSP Bootup message\n");
+ }
+ else
+ printf("Bootup ERROR: ldCoff FAILED \n");
+ }
+
+ return(result);
+} \ No newline at end of file
diff --git a/data/mnet/GP10/Host/cdcUtils/drfInterface/Makefile b/data/mnet/GP10/Host/cdcUtils/drfInterface/Makefile
new file mode 100644
index 0000000..448d1f3
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/drfInterface/Makefile
@@ -0,0 +1,52 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..\..
+
+# These Must be Properly Defined
+THIS_APP_DIR = cdcUtils
+THIS_DIRECTORY = drfInterface
+MY_OUTPUT = $(OBJDIR)\drfInterface.out
+
+# Name(s) of Common VOB directories to include
+COMMON_BLD_DIR =
+
+include $(TOP_OF_VOB)\l3defs.mk
+
+all: makeCommonObjs $(MY_OUTPUT)
+
+# Adds the .o file(s) list needed from the Common VOB
+makeCommonObjs:
+ifneq ($(COMMON_BLD_DIR),)
+ @for %f in ($(COMMON_BLD_DIR)) do \
+ make -C $(COMMON_VOB_APP_DIR)\%f \
+ all VOB=$(VOBNAME) APPDIR=Host\$(THIS_APP_DIR)\$(THIS_DIRECTORY)
+endif
+
+# If Common VOB directories to include get the .o files from bin
+$(MY_OUTPUT): $(MODULE_OBJS)
+ifneq ($(COMMON_BLD_DIR),)
+ $(LD) -r -o $@.tmp $() $(MODULE_OBJS) $(wildcard ./bin/*.o)
+else
+ $(LD) -r -o $@.tmp $() $(MODULE_OBJS)
+endif
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+ifneq ($(COMMON_BLD_DIR),)
+ $(RM) bin\*.o
+ $(RM) bin\*.out
+endif \ No newline at end of file
diff --git a/data/mnet/GP10/Host/cdcUtils/drfInterface/drfInterface.c b/data/mnet/GP10/Host/cdcUtils/drfInterface/drfInterface.c
new file mode 100644
index 0000000..ae2aac2
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/drfInterface/drfInterface.c
@@ -0,0 +1,1477 @@
+/******************************************************************
+
+ (c) Copyright Cisco 2000
+ All Rights Reserved
+
+******************************************************************/
+
+/*******************************************************************************
+drfInterface.c
+
+This module consists of two set of functions. One to interface with the Dual RF
+module and the other to write to and read from the EEPROM on the Dual RF
+module.
+
+*/
+/*
+
+All the commands to the rf module are sent by drfCmd(). This function is called
+by other functions. It should not be called directly. It can be used to send
+commands from console.
+
+*/
+
+#include "vxWorks.h"
+#include "stdio.h"
+#include "string.h"
+#include "semLib.h"
+#include "taskLib.h"
+#include "sysLib.h"
+
+#include "cdc_bsp/i2c.h"
+#include "cdcUtils/drfInterface.h"
+
+#define MAX_CMD_LEN 53
+#define MAX_CMD_SEG_SIZE 1
+#define RSP_LEN 4
+#define RF_ADDR 0x77
+#define RF_MEM_ADDR 0x52
+#define MAX_RF_MEM_SIZE 26
+#define VERSION_LEN 4
+#define SER_NUM_LEN 12
+
+
+/*---------- Globals ----------*/
+char drfVersion[VERSION_LEN + 1] = "xxxx"; /* Dual RF firmware version */
+char drfSerialNum[SER_NUM_LEN + 1] = "xxxxxxxxxxxx"; /* Dual RF serial Number */
+
+/*-------- File Locals --------*/
+static char rspDefault[RSP_LEN];
+static char drfMem[MAX_RF_MEM_SIZE];
+static SEM_ID drfSem;
+static int drfType;
+static unsigned int drfVersionStage;
+static unsigned int drfMemLayoutVer;
+static unsigned int drfMemSize;
+
+/*******************************************************************************
+
+ascDec2Int - ASCII Decimal to Integer
+
+Converts a string of four ASCII coded decimal chracters to an integer.
+
+*/
+
+static STATUS ascDec2Int /* RETURN: OK/ERROR in the input */
+ (
+ const char* str, /* IN : ASCII chracter string */
+ int* pNum /* OUT : number */
+ )
+{
+ int retVal = OK;
+ int pwr[4] = {1000,100,10,1};
+ int i;
+
+ *pNum = 0;
+ for (i = 0; i < 4; i++)
+ {
+ if ((str[i] >= '0') && (str[i] <= '9'))
+ {
+ *pNum += (str[i] - '0') * pwr[i];
+ printf("num: %d\n",*pNum);
+ }
+ else
+ {
+ retVal = ERROR;
+ break;
+ }
+ }
+ return retVal;
+}
+
+/*******************************************************************************
+
+ascHex2Int - ASCII Hex to Integer
+
+Converts a string of four ASCII coded hexadecimal chracters to an integer.
+
+*/
+
+static STATUS ascHex2Int /* RETURN: OK/ERROR in the input */
+ (
+ const char* str, /* IN : ASCII chracter string */
+ int* pNum /* OUT : number */
+ )
+{
+ int retVal = OK;
+ int pwr[4] = {16*16*16,16*16,16,1};
+ int i;
+
+ *pNum = 0;
+ for (i = 0; i < 4; i++)
+ {
+ if ((str[i] >= '0') && (str[i] <= '9'))
+ *pNum += (str[i] - '0') * pwr[i];
+ else if ((str[i] >= 'A') && (str[i] <= 'F'))
+ *pNum += (str[i] - 'A' + 10) * pwr[i];
+ else if ((str[i] >= 'a') && (str[i] <= 'f'))
+ *pNum += (str[i] - 'a' + 10) * pwr[i];
+ else
+ {
+ retVal = ERROR;
+ break;
+ }
+ }
+ return retVal;
+}
+
+/*******************************************************************************
+
+byte2AscDec - Byte to ASCII Decimal
+
+Converts a byte to three ascii coded decimal chracters
+
+*/
+
+static void byte2AscDec
+ (
+ unsigned char num, /* IN : byte to convert */
+ char* ascStr /* OUT : ASCII chracter string */
+ )
+{
+ ascStr[0] = '0' + num/100;
+ num -= (num/100)*100;
+ ascStr[1] = '0' + num/10;
+ num -= (num/10)*10;
+ ascStr[2] = '0' + num;
+}
+
+/*******************************************************************************
+
+byte2AscHex - Byte to ASCII Hex
+
+Converts a byte to two ascii coded hexadecimal chracters
+
+*/
+
+static void byte2AscHex
+ (
+ unsigned char num, /* IN : byte to convert */
+ char* ascStr /* OUT : ASCII chracter string */
+ )
+{
+ unsigned char temp;
+
+ temp = num >> 4;
+ if (temp < 10)
+ ascStr[0] = '0' + temp;
+ else
+ ascStr[0] = 'A' + temp - 10;
+
+ temp = num & 0xF;
+ if (temp < 10)
+ ascStr[1] = '0' + temp;
+ else
+ ascStr[1] = 'A' + temp - 10;
+}
+
+/*******************************************************************************
+rspOk - Response Ok
+
+Checks if the response from drf board is 'Command Successful'
+Returns true or false
+*/
+
+static int rspOk(char* rsp)
+{
+ if ((rsp[0] == '0') && (rsp[1] == '0') && (rsp[2] == '0') && (rsp[3] == '0'))
+ return TRUE;
+ else
+ return FALSE;
+}
+
+/*******************************************************************************
+rspError - Response Error
+
+Checks if the response from drf board is 'Command Unsuccessful'
+Returns true or false
+*/
+
+static int rspError(char* rsp)
+{
+ if ((rsp[0] == 'F') && (rsp[1] == 'F') && (rsp[2] == 'F') && (rsp[3] == 'F'))
+ return TRUE;
+ else
+ return FALSE;
+}
+
+
+/*******************************************************************************
+
+drfCmd - Command
+
+This rouine sends a command to dual radio board and receives the response back.
+It uses I2C interface routine to interface to the dual RF board.
+
+No more than one command is in progress at any given time.
+
+*/
+
+STATUS drfCmd
+ (
+ char* cmd, /* command: Null terminated chracter string */
+ char* rsp /* response */
+ )
+{
+ int retVal; /* Return Value */
+ int cmdLen; /* Command Length */
+ int i, n;
+
+ retVal = semTake(drfSem, WAIT_FOREVER); /* Block the resourse */
+ if (retVal == ERROR)
+ goto exit1;
+ if (rsp == 0)
+ rsp = rspDefault; /* if rsp is null set it to default */
+ cmdLen = strlen(cmd); /* find out length of the command */
+ if (cmdLen > MAX_CMD_LEN)
+ {
+ retVal = ERROR;
+ goto exit;
+ }
+
+ I2Coperation(ON);
+/*
+ for (i = 0; i < cmdLen; i += MAX_CMD_SEG_SIZE)
+ {
+ n = ((cmdLen - i) > MAX_CMD_SEG_SIZE) ? MAX_CMD_SEG_SIZE : (cmdLen - i);
+ printf("i%d n%d\n",i,n);
+ if ((retVal = I2Cwrite2(&cmd[i], RF_ADDR, n)) != OK)
+ break;
+ taskDelay(10);
+ }
+ if (retVal == OK)
+*/
+ for (i = 0, retVal = ERROR; (i < 5) && (retVal == ERROR); i++)
+ { /* if error try muliple times since I2Cread can fail occasionally */
+ if ((retVal = I2Cwrite2(cmd, RF_ADDR, cmdLen)) == OK) /* send the command */
+ {
+/* taskDelay((int)(0.1*sysClkRateGet())); /* sleep for 100 ms. */
+ taskDelay(2);
+ rsp[0] = '?';
+ rsp[1] = '?';
+ rsp[2] = '?';
+ rsp[3] = '?';
+ retVal = I2Cread2(rsp, RF_ADDR, RSP_LEN); /* read the response */
+ }
+ }
+ I2Coperation(OFF);
+
+ /* print response only for commands from console */
+ if ((rsp == rspDefault) && (retVal == OK))
+ printf("DRF response: %c%c%c%c\n",rsp[0],rsp[1],rsp[2],rsp[3]);
+
+ exit:
+ semGive(drfSem); /* release the resource */
+ exit1:
+ return retVal;
+}
+
+/*******************************************************************************
+
+drfPllRefFreqSet - PLL Reference Frequency Get
+
+Set the PLL reference frequency.
+
+*/
+
+STATUS drfPllRefFreqSet /* RETURN : OK, ERROR */
+ (
+ unsigned int freq /* IN : the freq to set */
+ )
+{
+ int retVal; /* return value */
+ char rsp[RSP_LEN]; /* response */
+
+ if (freq == 0)
+ retVal = drfCmd("PR10",rsp); /* set ref freq to 10Mhz */
+ else if (freq == 1)
+ retVal = drfCmd("PR13",rsp); /* set ref freq to 13Mhz */
+ else
+ retVal = ERROR; /* invalid input */
+
+
+ if (retVal == OK)
+ retVal = rspError(rsp) ? ERROR : OK;
+
+ return retVal;
+}
+
+/*******************************************************************************
+
+drfPllRefFreqGet - PLL Refrence Frequency Get
+
+Gets the PLL refernce frequency from the Dual RF board
+
+*/
+
+int drfPllRefFreqGet() /* RETURN : 0 - 10Mhz, 1 - 13Mhz, -1 - Error */
+
+{
+ int retVal = -1;
+ char rsp[RSP_LEN]; /* response */
+
+ retVal = drfCmd("PR?",rsp);
+
+ if (retVal == OK)
+ {
+ if ((rsp[2] == '1') && (rsp[3] == '0'))
+ {
+ retVal = 0;
+ }
+ else if ((rsp[2] == '1') && (rsp[3] == '3'))
+ {
+ retVal = 1;
+ }
+ }
+
+ return retVal;
+}
+
+/*******************************************************************************
+
+drfNullAttenSet - Nulliing Attenuator level Set
+
+Sets the Nulling attenuator level on the DRF board.
+
+*/
+
+STATUS drfNullAttenSet /* RETURN : OK, ERROR */
+ (
+ int attenLevel /* IN : attenuation Level * 10 */
+ )
+{
+ int retVal = ERROR;
+ char cmdStr[6] = {'N'}; /* N??.? + null */
+ char rsp[RSP_LEN]; /* response */
+
+ if (attenLevel > 999)
+ goto exit;
+ byte2AscDec(attenLevel, &cmdStr[1]);
+
+ /* insert decimal point */
+ cmdStr[4] = cmdStr[3];
+ cmdStr[3] = '.';
+ cmdStr[5] = 0;
+
+ if (drfCmd(cmdStr, rsp) == OK)
+ retVal = rspOk(rsp) ? OK : ERROR;
+
+ exit:
+ return retVal;
+}
+
+/*******************************************************************************
+
+drfNullAttenGet - Null Attenuator level Get
+
+Gets the null attenuator level from the DRF board
+
+*/
+
+STATUS drfNullAttenGet /* RETURN : OK, ERROR */
+ (
+ int* level /* OUT : Attenuator level * 10 */
+ )
+{
+ int retVal = ERROR; /* return value */
+ char rsp[RSP_LEN]; /* response */
+ int temp;
+
+ if (drfCmd("N?",rsp) == OK)
+ {
+ if (!(rspError(rsp)))
+ {
+ /* remove decimal point from the string */
+ rsp[2] = rsp[1];
+ rsp[1] = rsp[0];
+ rsp[0] = '0';
+
+ if (ascDec2Int(rsp, &temp) == OK)
+ {
+ *level = temp;
+ retVal = OK;
+ }
+ }
+ }
+
+ return retVal;
+}
+
+/*******************************************************************************
+
+drfNullAttenMin - Null Attenuation Minimization algotrithm
+
+Commands dual RF board to run Null Attenuation minimization algotrithm.
+
+*/
+
+STATUS drfNullAttenMin() /* RETUEN : OK, ERROR */
+{
+ int retVal = ERROR;
+ char rsp[RSP_LEN]; /* response */
+
+ if (drfCmd("NM",rsp) == OK)
+ {
+ if (rspOk(rsp))
+ retVal = OK;
+ }
+ return retVal;
+}
+
+/*******************************************************************************
+
+drfLockStatGet - Lock Status Get
+
+Gets the lock status of dual RF board.
+
+*/
+int drfLockStatGet /* RETUEN : 0 - not locked, 1 - locked, -1 - error */
+ (
+ PLLType pll /* IN : pll type */
+ )
+{
+ int retVal = 0;
+ char* cmd = "";
+ char rsp[RSP_LEN]; /* response */
+
+ switch (pll)
+ {
+ case Mon:
+ cmd = "LDM";
+ break;
+ case Ref:
+ cmd = "LDR";
+ break;
+ case T1:
+ cmd = "LD1";
+ break;
+ case T2A:
+ cmd = "LD2A";
+ break;
+ case T2B:
+ cmd = "LD2B";
+ break;
+ case IF:
+ cmd = "LDI";
+ break;
+ default:
+ retVal = -1;
+ break;
+ }
+
+ if (retVal != -1)
+ {
+ if (drfCmd(cmd, rsp) == OK)
+ {
+ if (rspError(rsp))
+ retVal = -1;
+ else if (rsp[0] == 0x00)
+ retVal = 0;
+ else
+ retVal = 1;
+ }
+ else
+ retVal = -1;
+ }
+
+ return retVal;
+}
+
+/*******************************************************************************
+
+drfRSSIGet - RSSI (Receiver Signal Strength Indication) Get
+
+Gets RSSI (Receiver Signal Strength Indication) from the dual RF board
+
+*/
+
+int drfRSSIGet() /* RETURN : RSSI or -1 for error */
+{
+ int retVal = -1;
+ char rsp[RSP_LEN]; /* response */
+
+ if (drfCmd("R",rsp) == OK)
+ {
+ if (!(rspError(rsp)))
+ if (ascHex2Int((const char*)rsp, &retVal) == ERROR)
+ retVal = -1;
+ }
+ return retVal;
+}
+
+/*******************************************************************************
+
+drfLoopbackSet - Loopback Set
+
+Sets Loopback signal low/high on the dual RF board
+
+*/
+
+STATUS drfLoopbackSet /* RETURN : OK, ERROR */
+ (
+ int txNum, /* IN : transmitter, 0 or 1 */
+ int lowHigh /* IN : 0 - set low, !0 - set high */
+ )
+{
+ int retVal = ERROR;
+ char* cmd;
+ char rsp[RSP_LEN]; /* response */
+
+ if (txNum >= 2)
+ goto exit;
+
+ if (txNum == 0)
+ {
+ if (lowHigh == 0)
+ cmd = "LB10";
+ else
+ cmd = "LB11";
+ }
+ else
+ {
+ if (lowHigh == 0)
+ cmd = "LB20";
+ else
+ cmd = "LB21";
+ }
+
+ if (drfCmd(cmd, rsp) == OK)
+ retVal = rspOk(rsp) ? OK : ERROR;
+
+ exit:
+ return retVal;
+
+}
+
+/*******************************************************************************
+
+drfTxPwrSet - Tx Power Set
+
+Sets Tx Power control low/high on the dual RF board
+
+*/
+
+STATUS drfTxPwrSet /* RETURN : OK, ERROR */
+ (
+ int txNum, /* IN : transmitter, 0 or 1 */
+ int lowHigh /* IN : 0 - set low, !0 - set high */
+ )
+{
+ int retVal = ERROR;
+ char* cmd;
+ char rsp[RSP_LEN]; /* response */
+
+ if (txNum >= 2)
+ goto exit;
+
+ if (txNum == 0)
+ {
+ if (lowHigh == 0)
+ cmd = "T10";
+ else
+ cmd = "T11";
+ }
+ else
+ {
+ if (lowHigh == 0)
+ cmd = "T20";
+ else
+ cmd = "T21";
+ }
+
+ if (drfCmd(cmd, rsp) == OK)
+ retVal = rspOk(rsp) ? OK : ERROR;
+
+ exit:
+ return retVal;
+}
+
+/*******************************************************************************
+
+drfFpgaTxPwrEnable - FPGA Tx Power Enable
+
+Enables FPGA interface Power Control
+
+*/
+
+STATUS drfFpgaTxPwrEnable /* RETURN : OK, ERROR */
+ (
+ int txNum /* IN : transmitter, 0 or 1 */
+ )
+{
+ int retVal = ERROR;
+ char* cmd;
+ char rsp[RSP_LEN]; /* response */
+
+ if (txNum >= 2)
+ goto exit;
+
+ if (txNum == 0)
+ {
+ cmd = "T1E";
+ }
+ else
+ {
+ cmd = "T2E";
+ }
+
+ if (drfCmd(cmd, rsp) == OK)
+ retVal = rspOk(rsp) ? OK : ERROR;
+
+ exit:
+ return retVal;
+}
+
+/*******************************************************************************
+
+drfFpgaTxPwrDisable - FPGA Tx Power Enable
+
+Disables FPGA interface Power Control
+
+*/
+
+STATUS drfFpgaTxPwrDisable /* RETURN : OK, ERROR */
+ (
+ int txNum /* IN : transmitter, 0 or 1 */
+ )
+{
+ int retVal = ERROR;
+ char* cmd;
+ char rsp[RSP_LEN]; /* response */
+
+ if (txNum >= 2)
+ goto exit;
+
+ if (txNum == 0)
+ {
+ cmd = "T1D";
+ }
+ else
+ {
+ cmd = "T2D";
+ }
+
+ if (drfCmd(cmd, rsp) == OK)
+ retVal = rspOk(rsp) ? OK : ERROR;
+
+ exit:
+ return retVal;
+}
+
+/*******************************************************************************
+
+drfFreqHopEnable - Frequency Hopping Enable
+
+This command does two things, it allows the FPGAs to manipulate the ARFCNs,
+and it also allows the FPGAs to manipulate the transmitter's power control.
+*/
+
+STATUS drfFreqHopEnable() /* RETURN : OK, ERROR */
+{
+ int retVal = ERROR;
+ char rsp[RSP_LEN]; /* response */
+
+ if (drfCmd("HE", rsp) == OK)
+ retVal = rspOk(rsp) ? OK : ERROR;
+
+ exit:
+ return retVal;
+}
+
+/*******************************************************************************
+
+drfFreqHopDisable - Frequency Hopping Disable
+
+This command does two things, it prevents the FPGAs from manipulating the ARFCNs,
+and it also prevents the FPGAs from manipulating the transmitter's power control
+*/
+
+STATUS drfFreqHopDisable() /* RETURN : OK, ERROR */
+{
+ int retVal = ERROR;
+ char rsp[RSP_LEN]; /* response */
+
+ if (drfCmd("HD", rsp) == OK)
+ retVal = rspOk(rsp) ? OK : ERROR;
+
+ exit:
+ return retVal;
+}
+
+/*******************************************************************************
+
+drfVersionGet - Version Get
+
+Gets the Version Number of dual RF board firmware
+*/
+
+LOCAL STATUS drfVersionGet() /* RETURN : OK, ERROR */
+{
+ int retVal = ERROR;
+ char rsp[RSP_LEN]; /* response */
+
+ if ((drfCmd("V",rsp)) == ERROR)
+ goto exit;
+
+ if (!(rspError(rsp)))
+ {
+ drfVersion[0] = rsp[0];
+ drfVersion[1] = rsp[1];
+ drfVersion[2] = rsp[2];
+ drfVersion[3] = rsp[3];
+
+ retVal = OK;
+ }
+ exit:
+ return retVal;
+}
+
+
+/*******************************************************************************
+
+drfVersionReturn - Version Retuen
+
+Returns the Version Number of dual RF board firmware.
+*/
+char* drfVersionReturn()
+{
+ return drfVersion;
+}
+
+
+/*******************************************************************************
+
+drfVersionPrint - Version Print
+
+Prints the version no. of dual RF board firmware
+
+*/
+
+void drfVersionPrint()
+{
+ printf("Dual RF Module Firmware Version: %s\n", drfVersion);
+}
+
+
+/*******************************************************************************
+
+drfSerialNumGet - SerialNumber Get
+
+Gets the Serial Number of dual RF board
+*/
+
+LOCAL STATUS drfSerialNumGet() /* RETURN : OK, ERROR */
+{
+ int retVal = ERROR;
+ char rsp[RSP_LEN * 3]; /* response */
+ int i;
+
+ if (drfVersionStage == 0)
+ {
+ if ((drfCmd("S?",rsp)) != ERROR)
+ {
+ if (!(rspError(rsp)))
+ {
+ drfSerialNum[0] = rsp[0];
+ drfSerialNum[1] = rsp[1];
+ drfSerialNum[2] = rsp[2];
+ drfSerialNum[3] = rsp[3];
+ drfSerialNum[4] = 0; /* null terminate */
+ retVal = OK;
+ }
+ }
+ }
+ else if (drfVersionStage == 1)
+ {
+ if ((drfCmd("SI?", rsp)) != ERROR)
+ {
+ if (!(rspError(rsp)))
+ {
+ if ((drfCmd("SN?", &rsp[RSP_LEN])) != ERROR)
+ {
+ if (!(rspError(&rsp[RSP_LEN])))
+ {
+ for (i = 0; i < (RSP_LEN * 2); i++)
+ drfSerialNum[i] = rsp[i];
+ drfSerialNum[i] = 0; /* null terminate */
+ retVal = OK;
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ if ((drfCmd("SI?", rsp)) != ERROR)
+ {
+ if (!(rspError(rsp)))
+ {
+ if ((drfCmd("SN?", &rsp[RSP_LEN])) != ERROR)
+ {
+ if (!(rspError(rsp)))
+ {
+ if ((drfCmd("SX?", &rsp[RSP_LEN * 2])) != ERROR)
+ {
+ if (!(rspError(&rsp[RSP_LEN])))
+ {
+ for (i = 0; i < (RSP_LEN * 3); i++)
+ drfSerialNum[i] = rsp[i];
+ drfSerialNum[i] = 0; /* null terminate */
+ retVal = OK;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+
+ return retVal;
+}
+
+
+/*******************************************************************************
+
+drfSerialNumPrint - Serial Number Print
+
+Prints the Serial Number of dual RF board
+
+*/
+
+void drfSerialNumPrint()
+{
+ printf("Dual RF Module Serial Number: %s\n", drfSerialNum);
+}
+
+
+/*******************************************************************************
+
+drfSerialNumReturn - Serial Number Return
+
+Returns the Serial Number of dual RF board.
+
+*/
+char* drfSerialNumReturn()
+{
+ return drfSerialNum;
+}
+
+
+/*******************************************************************************
+
+drfInfoSet - Information Set
+
+Detrmines and saves the type of the RF module present in the system.
+
+Sets the drfType to following:
+ 0 - 900 system
+ 1 - 1800 system
+ 2 - 1900 system
+ -1 - Undtermined
+
+Determines the stage of version of firmware on the RF board and sets
+drfVersionStage.
+
+Determines the version of the memory layout on the rf board and sets
+drfMemLayoutVersion
+
+drfVersionStage and drfMemLayoutVersion are for the internal use only.
+*/
+
+/*
+The type of the system is figured out from the version number of the
+drf firmare. The version of the layout is also figured out from the firmware
+version number.
+
+If the version no. begins with a letter, the letter indiacates type
+of the board. Px.x is 1900, Dx.x is 1800, Gx.x is 900, and Ex.x is extended gsm
+system. If there is no leading letter, the leading digit is 0. Versions 01.x is
+for 1900 systems and versions 02.x is for 1800 systems
+*/
+
+/*
+If version is P1.x, D1.x, G1.x, E1.x, 01.x, or 02.x the drfVersion stage
+should be set to 0. This versions are no longer built.
+If the version id P2.x, D2.x, G2.x, or E2.x the drfVersionStage is set to 1
+*/
+
+LOCAL void drfInfoSet()
+{
+ drfType = -1; /* undertermined type */
+ drfVersionStage = 2; /* assume newest version */
+
+ if (drfVersion[0] == 'P')
+ drfType = 2; /* 1900 */
+ else if (drfVersion[0] == 'D')
+ drfType = 1; /* 1800 */
+ else if ((drfVersion[0] == 'G') || (drfVersion[0] == 'E'))
+ drfType = 0; /* 900 */
+ else if (drfVersion[0] == '0')
+ {
+ if (drfVersion[1] == '1')
+ drfType = 2; /* 1900 */
+ else if (drfVersion[1] == '2')
+ drfType = 1; /* 1800 */
+ drfVersionStage = 0; /* old version */
+ }
+
+ if (drfVersionStage != 0)
+ { /* version is not 0x.x */
+ if (drfVersion[1] == '1')
+ drfVersionStage = 0; /* old version */
+ else if (drfVersion[1] == '2')
+ {
+ if (drfVersion[3] < '2')
+ drfVersionStage = 1; /* old version */
+ }
+ }
+
+
+ if (drfVersionStage == 0)
+ {
+ drfMemLayoutVer = 0;
+ drfMemSize = 22;
+ }
+ else if (drfVersionStage == 1)
+ {
+ drfMemLayoutVer = 1;
+ drfMemSize = 24;
+ }
+ else
+ {
+ drfMemLayoutVer = 2;
+ drfMemSize = 26;
+ }
+}
+
+
+/*******************************************************************************
+
+drfTypeGet - Type Get
+
+Returns type of the RF module present in the system.
+Returns
+ 0 - 900 system
+ 1 - 1800 system
+ 2 - 1900 system
+ -1 - Undetermined
+*/
+int drfTypeGet() /* RETURN: 0,1,2, or -1 */
+{
+ return drfType;
+}
+
+/*******************************************************************************
+
+drfIQSwapGet - IQ Swap Get
+
+Returns TRUE if I/Q signals are swapped on the RF board. The swapping is as
+compared to the original 1900 board.
+*/
+int drfIQSwapGet() /* RETURN: TRUE / FALSE */
+{
+ if ((drfTypeGet() == 2) && (drfVersion[0] == '0'))
+ return FALSE;
+ else
+ return TRUE;
+}
+
+/*******************************************************************************
+
+drfFreqHopGet - Frequency Hop Get
+
+Returns if the TRX is capable of hopping.
+*/
+int drfFreqHopGet /* RETURN: TRUE /FALSE */
+ (
+ UINT trx /* IN: trx number */
+ )
+{
+ return FALSE; /* no hopping as of yet */
+}
+
+/*******************************************************************************
+
+drfMemSend - Memory Send
+
+Sends dual RF board contents of memory on that board
+
+*/
+
+LOCAL STATUS drfMemSend() /* RETURN : ok/error */
+{
+
+ STATUS retVal = ERROR;
+ char cmdStr[1 + MAX_RF_MEM_SIZE *2 + 1] = {'Q'};
+ char rsp[RSP_LEN]; /* response */
+ char* pCmd;
+ int i;
+
+ /* build the command string */
+ for (i = 0, pCmd = &cmdStr[1]; i < drfMemSize; i++, pCmd+=2)
+ {
+ byte2AscHex(drfMem[i], pCmd);
+ }
+ cmdStr[drfMemSize * 2 + 1] = 0; /* null terminate */
+ /* send the command */
+ if (drfCmd(cmdStr, rsp) == OK)
+ {
+ retVal = rspOk(rsp) ? OK : ERROR;
+ }
+ exit:
+ return retVal;
+
+}
+
+/*******************************************************************************
+
+drfStatGet - Status Get
+
+Gets status of dual RF board.
+
+*/
+
+STATUS drfStatGet /* RETURN: OK ro ERROR */
+ (
+ int* pStatus /* OUT: drf status here */
+ )
+{
+ STATUS retVal = ERROR;
+ char rsp[RSP_LEN]; /* response */
+
+ if (pStatus != NULL)
+ {
+ if (drfCmd("?",rsp) == OK)
+ {
+ if (ascHex2Int(rsp, pStatus) == OK)
+ {
+ retVal = OK;
+ }
+ }
+ }
+ return retVal;
+}
+
+
+
+
+/*******************************************************************************
+
+drfStatGet - Status Get
+
+Gets status of dual RF board.
+
+*/
+
+long drfSynthStatusGet(void )
+{
+ long retVal = 0xFFFFFFFF;
+ char rsp[RSP_LEN]; /* response */
+
+ if (drfCmd("?",rsp) == OK)
+ {
+ /*retVal = rsp[0] | (rsp[1]<<8) | (rsp[2]<<16) | (rsp[3]<<24);*/
+ ascHex2Int(rsp, & retVal);
+ }
+
+ return retVal;
+}
+/*******************************************************************************
+
+drfInterfaceInit - Interface Initialize
+
+Initializes Dual RF interface
+
+*/
+STATUS drfInterfaceInit()
+{
+ drfSem = semMCreate(SEM_Q_PRIORITY | SEM_INVERSION_SAFE | SEM_DELETE_SAFE);
+ if (drfSem == NULL)
+ return ERROR;
+ else
+ return OK;
+}
+
+/*******************************************************************************
+
+drfInit - Initialize
+
+Initializes dual RF board interface, reads the EEPROM on the RF board, and sends
+the values to the dual RF borad. The host reads the memory on behalf of the dual
+radio board to avoid multiple masters on the I2C bus. The I2C interface on MPC860
+processor has known issues related to multi-master mode operation.
+
+*/
+
+STATUS drfInit()
+
+{
+ STATUS retVal = ERROR;
+ int status; /* drf status */
+ int i;
+
+ retVal = drfInterfaceInit();
+ if (retVal == ERROR)
+ goto exit;
+
+ drfVersionGet(); /* get the Dual RF firmware version */
+ drfInfoSet(); /* set the RF board firmware version no. etc. */
+
+ /* read the dual RF EEPROM */
+ I2Coperation(ON);
+ /* if error try muliple times since I2Cread can fail occasionally */
+ for (i = 0, retVal = ERROR; (i < 5) && (retVal == ERROR); i++)
+ retVal = I2Cread(drfMem, RF_MEM_ADDR, 0, drfMemSize);
+ I2Coperation(OFF);
+ if (retVal == ERROR)
+ goto exit;
+
+ /* send the read values to the drf board */
+ retVal = drfMemSend();
+
+ drfSerialNumGet(); /* get the Dual RF serial number */
+ drfStatGet(&status); /* get the Dual RF board's status */
+ if ((status & EEPROM_REQUIRED) != 0)
+ printf("Error: Dual RF did not receive EEPROM values\n");
+ if ((status & EEPROM_DEFAULT_USED) != 0)
+ printf("Error: Dual RF using default EEPROM settings\n");
+
+ /* Enable frequency hopping.
+ This enables the FPGA interface to the RF module.
+ This command does two things, it allows the FPGAs to manipulate the ARFCNs,
+ and it also allows the FPGAs to manipulate the transmitter's power control.
+ */
+ if ((drfFreqHopEnable()) == ERROR)
+ goto exit;
+
+ /* Enable the PA on transceivers.
+ The actual setting of the PA power enable control will be determined by the
+ FPGA interface.
+ */
+ if ((drfFpgaTxPwrEnable(0)) == ERROR)
+ goto exit;
+ if ((drfFpgaTxPwrEnable(1)) == ERROR)
+ goto exit;
+
+ exit:
+ return retVal;
+}
+
+/*---------------------------------------------------------------------------*/
+/* Following commands read and write data to the EEPROM on the dual RF board */
+/*---------------------------------------------------------------------------*/
+
+/* RF EEPROM Layout */
+/* To be indexed by drfMemLayoutVersion */
+
+UINT DACI1[] = {0x00, 0x0B, 0x0B};
+UINT DACQ1[] = {0x01, 0x0C, 0x0C};
+UINT DACGREF1[] = {0x02, 0x0D, 0x0D};
+UINT DACDELAY[] = {0x03, 0x0E, 0x0E};
+UINT DACVCXO[] = {0x04, 0x0F, 0x0F};
+UINT DACGREF2[] = {0x05, 0x10, 0x10};
+UINT DACQ2[] = {0x06, 0x11, 0x11};
+UINT DACI2[] = {0x07, 0x12, 0x12};
+UINT NULL_FFEDBACK[] = {0x08, 0x13, 0x13};
+UINT ARFCN1_LSB[] = {0x09, 0x00, 0x00};
+UINT ARFCN1_MSB[] = {0x0A, 0x01, 0x01};
+UINT ARFCN2A_LSB[] = {0x0B, 0x02, 0x02};
+UINT ARFCN2A_MSB[] = {0x0C, 0x03, 0x03};
+UINT ARFCN2B_LSB[] = {0x0D, 0x04, 0x04};
+UINT ARFCN2B_MSB[] = {0x0E, 0x05, 0x05};
+UINT ARFCN_MON_LSB[] = {0x0F, 0x06, 0x06};
+UINT ARFCN_MON_MSB[] = {0x10, 0x07, 0x06};
+UINT RFF_FREQ_INPUT[] = {0x11, 0x08, 0x08};
+UINT REF_FREQ_MODE[] = {0x12, 0x09, 0x09};
+UINT SERIAL_INFO_LSB[] = {0x13, 0x14, 0x14};
+UINT SERIAL_INFO_MSB[] = {0x14, 0x15, 0x15};
+UINT CHECKSUM[] = {0x15, 0x0A, 0x0A};
+UINT SERIAL_NUM_LSB[] = {0xFF, 0x16, 0x16}; /* Invalid for index 0 */
+UINT SERIAL_NUM_MSB[] = {0xFF, 0x17, 0x17}; /* Invalid for index 0 */
+UINT SERIAL_XN_LSB[] = {0xFF, 0xFF, 0x18}; /* Invalid for index 0 */
+UINT SERIAL_XN_MSB[] = {0xFF, 0xFF, 0x19}; /* Invalid for index 0 */
+
+/*-----------------------------------------------------------------
+drfMemUpdate - Memory Update
+Updates given address of EEPROM in DRF module with the given value.
+In addtion to this updates checksum field in the memory if required.
+If the adress of the memory being updated is less than the address of
+the chekcsum than the checksum is updates.
+*/
+LOCAL STATUS drfMemUpdate(char addr, char value)
+{
+ STATUS retStat = ERROR;
+ char oldValue;
+ char checksum;
+
+ if ((addr < drfMemSize) && (addr != CHECKSUM[drfMemLayoutVer]))
+ {
+ I2Coperation(ON);
+ if ((I2Cread(&oldValue, RF_MEM_ADDR, addr, 1)) == OK)
+ {
+ if ((I2Cwrite(&value, RF_MEM_ADDR, addr, 1)) == OK)
+ {
+ taskDelay(2);
+ if (addr < CHECKSUM[drfMemLayoutVer])
+ {
+ I2Cread(&checksum, RF_MEM_ADDR, CHECKSUM[drfMemLayoutVer], 1);
+ checksum = checksum + (oldValue - value);
+ I2Cwrite(&checksum, RF_MEM_ADDR, CHECKSUM[drfMemLayoutVer], 1);
+ taskDelay(2);
+ }
+ retStat = OK;
+ }
+ }
+ if (retStat == ERROR)
+ printf("Error accessing DRF Memory\n");
+ I2Coperation(OFF);
+ }
+ else
+ {
+ printf("Error: Illegal DRF memory address specified for update\n");
+ }
+
+ return retStat;
+}
+
+/*-----------------------------------------------------------------
+drfMemDacI1Write - Memory DAC I1 Write
+Writes DAC I1 trim value in the drf EEPROM
+*/
+STATUS drfMemDacI1Write(char newI1)
+{
+ return drfMemUpdate(DACI1[drfMemLayoutVer], newI1);
+}
+
+/*-----------------------------------------------------------------
+drfMemDacQ1Write - Memory DAC Q1 Write
+Writes DAC Q1 trim value in the drf EEPROM
+*/
+STATUS drfMemDacQ1Write(char newQ1)
+{
+ return drfMemUpdate(DACQ1[drfMemLayoutVer], newQ1);
+}
+
+/*-----------------------------------------------------------------
+drfMemDacI2Write - Memory DAC I2 Write
+Writes DAC I2 trim value in the drf EEPROM
+*/
+STATUS drfMemDacI2Write(char newI2)
+{
+ return drfMemUpdate(DACI2[drfMemLayoutVer], newI2);
+}
+
+/*-----------------------------------------------------------------
+drfMemDacQ2Write - Memory DAC Q2 Write
+Writes DAC Q2 trim value in the drf EEPROM
+*/
+STATUS drfMemDacQ2Write(char newQ2)
+{
+ return drfMemUpdate(DACQ2[drfMemLayoutVer], newQ2);
+}
+
+/*-----------------------------------------------------------------
+drfMemLocRead - Memory Location Read
+Reads the given memory location of EEPROM on the DRF module
+*/
+LOCAL STATUS drfMemLocRead(char addr, char* pValue)
+{
+ STATUS retStat;
+
+ I2Coperation(ON);
+ retStat = I2Cread(pValue, RF_MEM_ADDR, addr,1);
+ I2Coperation(OFF);
+ if (retStat == ERROR)
+ printf("Error reading from DRF memory\n");
+ return retStat;
+}
+
+/*-----------------------------------------------------------------
+drfMemDacI1Print - Memory DAC I1 Print
+Prints the DAC I1 trim value in drf EEPROM
+*/
+void drfMemDacI1Print()
+{
+ char value;
+
+ if ((drfMemLocRead(DACI1[drfMemLayoutVer], &value)) == OK)
+ {
+ printf("DRF DAC I1 in EEPROM: 0x%02x\n",value);
+ }
+}
+
+/*-----------------------------------------------------------------
+drfMemDacQ1Print - Memory DAC Q1 Print
+Prints the DAC Q1 trim value in drf EEPROM
+*/
+void drfMemDacQ1Print()
+{
+ char value;
+
+ if ((drfMemLocRead(DACQ1[drfMemLayoutVer], &value)) == OK)
+ {
+ printf("DRF DAC Q1 in EEPROM: 0x%02x\n", value);
+ }
+}
+
+/*-----------------------------------------------------------------
+drfMemDacI2Print - Memory DAC I2 Print
+Prints the DAC I2 trim value in drf EEPROM
+*/
+void drfMemDacI2Print()
+{
+ char value;
+
+ if ((drfMemLocRead(DACI2[drfMemLayoutVer], &value)) == OK)
+ {
+ printf("DRF DAC I2 in EEPROM: 0x%02x\n",value);
+ }
+}
+
+/*-----------------------------------------------------------------
+drfMemDacQ2Print - Memory DAC Q2 Print
+Prints the DAC Q2 trim value in drf EEPROM
+*/
+void drfMemDacQ2Print()
+{
+ char value;
+
+ if ((drfMemLocRead(DACQ2[drfMemLayoutVer], &value)) == OK)
+ {
+ printf("DRF DAC Q2 in EEPROM: 0x%02x\n",value);
+ }
+}
+
+/*-----------------------------------------------------------------
+drfMemSerialNumPrint - Memory Serial Number Print
+Prints the serial number in the drf EEPROM
+*/
+void drfMemSerialNumPrint()
+{
+ char numLsb;
+ char numMsb;
+ char serialNum[SER_NUM_LEN + 1];
+
+/*
+Serial Number Format:
+For memLayaoutVersion 0
+16 bits: SERIAL_INFO
+
+For memLayoutVesrion 1
+32 bits: SERIAL_INFO and SERIAL_NUM. INFO has MSB and NUM has LSB
+
+other memLayoutVersion
+48 bits: SERIAL_INFO, SERIAL_NUM, and SERIAL_SX. INFO has MSB and SX has LSB
+*/
+ if (((drfMemLocRead(SERIAL_INFO_LSB[drfMemLayoutVer], &numLsb)) == OK) &&
+ ((drfMemLocRead(SERIAL_INFO_MSB[drfMemLayoutVer], &numMsb)) == OK) )
+ {
+ sprintf(serialNum, "%04x", (numMsb << 8) | numLsb);
+ if (drfMemLayoutVer == 0)
+ printf("DRF Serial Number in EEPROM: 0x%s\n", serialNum);
+ else
+ if (((drfMemLocRead(SERIAL_NUM_LSB[drfMemLayoutVer], &numLsb)) == OK) &&
+ ((drfMemLocRead(SERIAL_NUM_MSB[drfMemLayoutVer], &numMsb)) == OK) )
+ {
+ sprintf(serialNum, "%s%04x", serialNum, (numMsb << 8) | numLsb);
+ if (drfMemLayoutVer == 1)
+ printf("DRF Serial Number in EEPROM: 0x%s\n", serialNum);
+ else
+ if (((drfMemLocRead(SERIAL_XN_LSB[drfMemLayoutVer], &numLsb)) == OK) &&
+ ((drfMemLocRead(SERIAL_XN_MSB[drfMemLayoutVer], &numMsb)) == OK) )
+ printf("DRF Serial Number in EEPROM: %s%04x\n", serialNum,
+ (numMsb << 8) | numLsb);
+ }
+ }
+ else
+ {
+ printf("Error reading from DRF memory\n");
+ }
+}
+
+/*-----------------------------------------------------------------
+drfMemSerialNumWrite - Memory Serial Number Write
+Writes the given serial number in the drf EEPROM
+*/
+
+/* No Longer Available */
+
+/*-----------------------------------------------------------------
+drfMemChecksumCompute - Memory Checksum Compute
+Computes the checksum of the data in drf EEPROM
+*/
+LOCAL STATUS drfMemChecksumCompute(char* pChecksum)
+{
+ STATUS retStat;
+ char drfEeprom[MAX_RF_MEM_SIZE - 1];
+ int i;
+
+ I2Coperation(ON);
+ retStat = I2Cread(drfEeprom, RF_MEM_ADDR, 0, CHECKSUM[drfMemLayoutVer]);
+ I2Coperation(OFF);
+ for (i = 0, *pChecksum =0; i < CHECKSUM[drfMemLayoutVer]; i++)
+ {
+ *pChecksum += drfEeprom[i];
+ }
+ *pChecksum = 0 - *pChecksum;
+ return retStat;
+}
+
+/*-----------------------------------------------------------------
+drfMemChecksumCheck - Memory Checksum Check
+Checks if the cheksum in the drf EEPROM is correct.
+Also prints the cheksum the in drf EEPROM
+*/
+STATUS drfMemChecksumCheck()
+{
+ STATUS retStat = ERROR;
+ char checksum;
+ char checksumMem;
+
+ if (((drfMemChecksumCompute(&checksum)) == OK) &&
+ ((drfMemLocRead(CHECKSUM[drfMemLayoutVer], &checksumMem)) == OK))
+ {
+ if ((checksum - checksumMem) == 0)
+ printf("DRF EEPROM checksum is correct\n");
+ else
+ printf("DRF EEPROM checksum is incorrect\n");
+ printf("DRF EEPROM checksum: 0x%02x\n",checksumMem);
+ retStat = OK;
+ }
+ else
+ {
+ printf("Error reading from DRF memory\n");
+ }
+ return retStat;
+}
+
+
+/*-----------------------------------------------------------------
+drfMemCheksumFix - Memory Checksum Fix
+Fixes cheksum in drf EEPROM by computing and writing the new checksum
+*/
+STATUS drfMemChecksumFix()
+{
+ STATUS retStat;
+ char checksum;
+
+ retStat = drfMemChecksumCompute(&checksum);
+ I2Coperation(ON);
+ retStat = I2Cwrite(&checksum, RF_MEM_ADDR, CHECKSUM[drfMemLayoutVer], 1);
+ I2Coperation(OFF);
+ if (retStat == ERROR)
+ printf("Error accessing DRF Memory\n");
+ return retStat;
+}
+
diff --git a/data/mnet/GP10/Host/cdcUtils/fpgaConfig/Makefile b/data/mnet/GP10/Host/cdcUtils/fpgaConfig/Makefile
new file mode 100644
index 0000000..f1abcdb
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/fpgaConfig/Makefile
@@ -0,0 +1,52 @@
+##########################################################
+#
+# (c) Copyright Cisco 2000
+# All Rights Reserved
+#
+##########################################################
+
+# TOP_OF_VOB must be defined before including l3defs.mk
+TOP_OF_VOB = ..\..\..
+
+# These Must be Properly Defined
+THIS_APP_DIR = cdcUtils
+THIS_DIRECTORY = fpgaConfig
+MY_OUTPUT = $(OBJDIR)\fpgaConfig.out
+
+# Name(s) of Common VOB directories to include
+COMMON_BLD_DIR =
+
+include $(TOP_OF_VOB)\l3defs.mk
+
+all: makeCommonObjs $(MY_OUTPUT)
+
+# Adds the .o file(s) list needed from the Common VOB
+makeCommonObjs:
+ifneq ($(COMMON_BLD_DIR),)
+ @for %f in ($(COMMON_BLD_DIR)) do \
+ make -C $(COMMON_VOB_APP_DIR)\%f \
+ all VOB=$(VOBNAME) APPDIR=Host\$(THIS_APP_DIR)\$(THIS_DIRECTORY)
+endif
+
+# If Common VOB directories to include get the .o files from bin
+$(MY_OUTPUT): $(MODULE_OBJS)
+ifneq ($(COMMON_BLD_DIR),)
+ $(LD) -r -o $@.tmp $() $(MODULE_OBJS) $(wildcard ./bin/*.o)
+else
+ $(LD) -r -o $@.tmp $() $(MODULE_OBJS)
+endif
+ $(NM) $@.tmp | munch > _ctdt.c
+ $(CC) -traditional $(CC_ARCH_SPEC) -c _ctdt.c
+ $(LD) -r -o $@ _ctdt.o $@.tmp
+ $(RM)$(subst /,$(DIRCHAR), _ctdt.c _ctdt.o $@.tmp)
+
+cleanall:
+ @for %f in ($(notdir $(MODULE_OBJS))) do \
+ $(RM) ..\bin\%f
+
+ $(RM) $(MY_OUTPUT)
+
+ifneq ($(COMMON_BLD_DIR),)
+ $(RM) bin\*.o
+ $(RM) bin\*.out
+endif \ No newline at end of file
diff --git a/data/mnet/GP10/Host/cdcUtils/fpgaConfig/fpgaConfig.c b/data/mnet/GP10/Host/cdcUtils/fpgaConfig/fpgaConfig.c
new file mode 100644
index 0000000..c1daa03
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/fpgaConfig/fpgaConfig.c
@@ -0,0 +1,154 @@
+/******************************************************************
+
+ (c) Copyright Cisco 2000
+ All Rights Reserved
+
+******************************************************************/
+
+/*******************************************************************************
+Altera FPGA configuration
+
+fpgaConfig - Configures FPGAs
+*******************************************************************************/
+
+/*
+Revision History
+----------------
+99/10/17 ck Modified to use auxPortOutSet function
+99/05/03 ck Initial Version
+*/
+
+#include <vxworks.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <taskLib.h>
+#include <vxLib.h>
+#include <drv/multi/ppc860siu.h>
+#include "cdcUtils/auxPort.h"
+
+#define CONFIG_DONE_BIT 0x00010000
+
+/******************************************************************************
+fpgaConfig
+
+Configure FPGAs. This routine is called to configure the FPGAs. It is called
+once after system boots. It reads the data to be programmed from file fpga.rbf
+
+RETURNS
+ 0 - Success
+ Errors
+ -1 - CONFIG_DONE does not go low
+ -2 - CONFIG_DONE does not go high at the end of configuration
+
+ -100 - Error Reading file
+ -200 - Cannot allocate memory
+
+External Signals
+ In - CONFIG_DONE on port B
+ Out - NCONFIG on Aux. Port
+ Out - DCLK on Aux. Port
+ Out - DATA on Aux. Port
+
+******************************************************************************/
+
+int fpgaConfig
+ (
+ const char* fileName
+ )
+{
+
+ FILE* file; /* input file */
+ char* buff;
+ int buffSize;
+ int byteIndex;
+ int bitNum;
+ char outByte;
+ int returnVal;
+ char i;
+ int immrVal = vxImmrGet();
+
+ /* read the file */
+ file = fopen(fileName,"rb");
+ if (file == 0)
+ {
+ returnVal = -100;
+ goto exit2;
+ }
+ fseek(file,0,SEEK_END);
+ buffSize = ftell(file);
+ fseek(file,0,SEEK_SET);
+ buff = (char *)malloc(buffSize);
+ if (buff == 0)
+ {
+ returnVal = -200;
+ fclose(file);
+ goto exit2;
+ }
+ fread(buff,1,buffSize,file);
+ fclose(file);
+
+ auxPortOutSet(FPGA_NCONFIG, FPGA_NCONFIG); /* NCONFIG high */
+ for(i=0;i<100;i++); /* keep NCONFIG high for a while */
+
+ /* NCONFIG low,DCLK low */
+ auxPortOutSet(~(FPGA_NCONFIG|FPGA_DCLK), FPGA_NCONFIG|FPGA_DCLK);
+ for(i=0;i<100;i++); /* wait at least 2us */
+ auxPortOutSet(FPGA_NCONFIG, FPGA_NCONFIG); /* NCONFIG high */
+ for(i=0;i<250;i++); /* wait at least 5us */
+
+ if (*PBDAT(immrVal) & CONFIG_DONE_BIT)
+ {
+ returnVal = -1;
+ goto exit1;
+ }
+
+ for (byteIndex = 0; byteIndex < buffSize; byteIndex++)
+ {
+
+ /* check if CONFIG_DONE goes high early */
+ /* commented out because CONFIG_DONE goes hiag a few bits before
+ is transferred */
+/*
+ if ((*PBDAT(immrVal) & CONFIG_DONE_BIT))
+ {
+ returnVal = -3;
+ goto exit;
+ }
+*/
+ outByte = buff[byteIndex];
+ for (bitNum = 0; bitNum < 8; bitNum++)
+ {
+ auxPortOutSet((outByte << 6) & ~FPGA_DCLK, FPGA_DATA|FPGA_DCLK); /* DATA, DCLK low */
+ /* wait minimum 50ns */
+ for(i=0;i<4;i++);
+ auxPortOutSet(FPGA_DCLK, FPGA_DCLK); /* DCLK high */
+ /* wait minimum 50ns */
+ for(i=0;i<4;i++);
+
+ outByte = outByte >> 1;
+
+ }
+ }
+
+ /* at this point CONFIG_DONE should be high */
+ if (!(*PBDAT(immrVal) & CONFIG_DONE_BIT))
+ { /* CONFIG_DONE low */
+ returnVal = -2;
+ goto exit1;
+ }
+
+ /* clock ten extra cycles */
+ for (byteIndex = 0; byteIndex < 10; byteIndex++)
+ {
+ auxPortOutSet(~FPGA_DCLK, FPGA_DCLK) ; /* DCLK low */
+ for (i=0;i<4;i++); /* wait minimum 50ns */
+ auxPortOutSet(FPGA_DCLK, FPGA_DCLK); /* DCLK high */
+ for (i=0;i<4;i++); /* wait minimum 50ns */;
+ }
+ returnVal = 0;
+
+ exit1:
+ free(buff);
+ exit2:
+ return(returnVal);
+}
diff --git a/data/mnet/GP10/Host/cdcUtils/include/clkInterface.h b/data/mnet/GP10/Host/cdcUtils/include/clkInterface.h
new file mode 100644
index 0000000..0866d80
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/include/clkInterface.h
@@ -0,0 +1,68 @@
+/******************************************************************
+
+ (c) Copyright Cisco 2000
+ All Rights Reserved
+
+******************************************************************/
+
+/*---- Function Declarations ----*/
+
+/**********************************************************************
+clkSerialNumReturn - Serial Number Return
+
+Returns the Serial Number of the clock module.
+*/
+char* clkSerialNumReturn();
+
+
+/**********************************************************************
+clkSoftVersionReturn - Software Version Return
+
+Returns the Software Version of the clock module.
+*/
+char* clkSoftVersionReturn();
+
+
+/**********************************************************************
+clkStatGet - Status Get
+
+Sends a command to clock module to read the status.
+Returns the status or -1 for error.
+
+Thre returned status is:
+
+ 0 - No Alarm conditions
+ 1 - Burst Alarm Active
+ 2 - Frame Alarm Active
+ 3 - Borth Burst and Fram Alarms active
+*/
+int clkStatGet(); /* RETURN: status or -1 for error */
+
+
+/**********************************************************************
+clkNumDaysTuneGet - Number of Days Tune Get
+
+Sends a command to clock module to read the number of days since last tuneup.
+Returns the no. of days or -1 for error.
+*/
+int clkNumDaysTuneGet(); /* RETURN: number of days or -1 for error */
+
+
+/**********************************************************************
+clkNumDaysRunGet - Number of Days Run Get
+
+Sends a command to clock module to read the number of days since it is running.
+Returns the no. of days or -1 for error.
+*/
+
+int clkNumDaysRunGet(); /* RETURN: number of days or -1 for error */
+
+
+/**********************************************************************
+clkGetDateOfLastTuning - Get the date of the last tuning of the clock
+
+Sends a command to clock module to read the last tuning date.
+Returns OK or ERROR.
+*/
+
+STATUS clkGetDateOfLastTuning(unsigned char *month, unsigned char *day, unsigned short *year);
diff --git a/data/mnet/GP10/Host/cdcUtils/include/cload.h b/data/mnet/GP10/Host/cdcUtils/include/cload.h
new file mode 100644
index 0000000..23c6852
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/include/cload.h
@@ -0,0 +1,106 @@
+/***************************************************************************
+* 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 */
+/*****************************************************************************/
+
+/*---------------------------------------------------------------------------*/
+/* 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) ((char *)strncpy(stat_nm, (s), SYMNMLEN))
+
+/*---------------------------------------------------------------------------*/
+/* THESE MACROS ARE USED TO FIND CINIT AND BSS SECTIONS */
+/*---------------------------------------------------------------------------*/
+#define IS_BSS(sptr) ((sptr->s_flags & STYP_BSS) && \
+ !strcmp(sptr->s_name, ".bss") )
+#define IS_CINIT(sptr) ((sptr->s_flags & STYP_COPY) && \
+ !strcmp(sptr->s_name, CINIT) )
+
+/*---------------------------------------------------------------------------*/
+/* VARIABLES SET BY THE APPLICATION. */
+/*---------------------------------------------------------------------------*/
+extern FILE *fin; /* COFF INPUT FILE */
+extern int verbose; /* PRINT PROGRESS INFO */
+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 */
+
+/*---------------------------------------------------------------------------*/
+/* 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 PARMS((void));
+extern int cload_headers PARMS((void));
+extern int cload_data PARMS((void));
+extern int cload_sect_data PARMS((struct scnhdr *));
+extern int cload_cinit PARMS((unsigned char *, int *, int *));
+extern int cload_symbols PARMS((void));
+extern int cload_strings PARMS((void));
+extern void str_free PARMS((struct strtab *));
+extern long sym_read PARMS((long, struct syment *, union auxent *));
+extern char *sym_name PARMS((struct syment *));
+extern char *sym_add_name PARMS((struct syment *));
+extern int reloc_add PARMS((long, struct syment *));
+extern int relocate PARMS((RELOC *, unsigned char *, int));
+extern int reloc_read PARMS((RELOC *));
+extern int reloc_size PARMS((int));
+extern int reloc_offset PARMS((int));
+extern int reloc_stop PARMS((int));
+extern long sym_reloc_amount PARMS((RELOC *));
+extern unsigned long unpack PARMS((unsigned char *, int, int, int));
+extern void repack PARMS((unsigned long, unsigned char *, int,int,int));
+extern int cload_lineno PARMS((long, int, struct lineno *, int));
+extern void swap4byte PARMS((void *));
+extern void swap2byte PARMS((void *));
+
+/*---------------------------------------------------------------------------*/
+/* 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 */
diff --git a/data/mnet/GP10/Host/cdcUtils/include/coff.h b/data/mnet/GP10/Host/cdcUtils/include/coff.h
new file mode 100644
index 0000000..a8ad237
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/include/coff.h
@@ -0,0 +1,590 @@
+/***************************************************************************
+* FILENAME: coff.h
+* VERSION: 2.5 8/5/96 11:36:08
+* SCCS ID: "@(#)coff.h 2.5 8/5/96"
+***************************************************************************/
+/**************************************************************************/
+/* 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 */
+/* */
+/**************************************************************************/
+
+/*------------------------------------------------------------------------*/
+/* 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 0300 /* ORIGINAL VERSION OF COFF */
+#define COFF_MAGIC_1 0301
+#define COFF_MAGIC_2 0302
+
+/*------------------------------------------------------------------------*/
+/* COFF TARGET ID's (FORMERLY MAGIC NUMBERS) */
+/* NOTE!!! DEFINE THE MACRO "MAGIC" TO BE ONE OF THESE MACROS. */
+/*------------------------------------------------------------------------*/
+#define MAGIC_340 0220
+#define MAGIC_370 0221
+#define MAGIC_DSP 0222
+#define MAGIC_C30 0223
+#define MAGIC_380 0224
+#define MAGIC_MVP 0225
+#define MAGIC_C16 0226
+#define MAGIC_ARM 0227
+#define MAGIC_LEAD 0230
+#define MAGIC_C60 0231
+#define MAGIC_C8P 0232
+#define MAGIC_LEADSDK 0233
+#define MAGIC_LEAD3 0234
+#define MAGIC_ANKOOR 0235
+
+#define MAGIC_MIN 0220 /* MINIMUM VALID MAGIC NUMBER */
+#define MAGIC_MAX 0235 /* MAXIMUM VALID MAGIC NUMBER */
+
+/*------------------------------------------------------------------------*/
+/* Macros to recognize magic numbers */
+/*------------------------------------------------------------------------*/
+#define ISCOFF(x) (ISCOFF_0(x)||ISCOFF_1(x)||ISCOFF_2(x)||ISMAGIC(x))
+#define ISMAGIC(x) (((unsigned short)(x)) == MAGIC)
+#define BADMAGIC(x) (((unsigned short)(x) & 0x8080) && !ISMAGIC(x))
+
+#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 */
+ long f_timdat; /* time & date stamp */
+ long f_symptr; /* file pointer to symtab */
+ long 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 */
+
+
+/*------------------------------------------------------------------------*/
+/* OPTIONAL FILE HEADER */
+/*------------------------------------------------------------------------*/
+typedef struct aouthdr
+{
+ short magic; /* optional file header magic number */
+ short vstamp; /* version stamp */
+ long tsize; /* text size in bytes, padded to FW bdry*/
+ long dsize; /* initialized data " " */
+ long bsize; /* uninitialized data " " */
+ long entrypt; /* entry pt. */
+ long text_start; /* base of text used for this file */
+ long data_start; /* base of data used for this file */
+} AOUTHDR;
+
+#define AOUTSZ sizeof(AOUTHDR)
+#define AOUT1MAGIC 0410
+
+
+/*------------------------------------------------------------------------*/
+/* 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 (.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_uid[6]; /* file member user id - 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
+
+/*------------------------------------------------------------------------*/
+/* 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 */
+ long os_paddr; /* physical address */
+ long os_vaddr; /* virtual address */
+ long os_size; /* section size */
+ long os_scnptr; /* file ptr to raw data for scn */
+ long os_relptr; /* file ptr to relocation */
+ long 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
+ {
+ long _s_zeroes; /* new == 0 */
+ long _s_offset; /* offset into string table */
+ } _s_s;
+ char *_s_nptr[2]; /* allows for overlaying */
+ } _s;
+
+ long s_paddr; /* physical address */
+ long s_vaddr; /* virtual address */
+ long s_size; /* section size */
+ long s_scnptr; /* file ptr to raw data for section */
+ long s_relptr; /* file ptr to relocation */
+ long s_lnnoptr; /* file ptr to line numbers */
+ unsigned long s_nreloc; /* number of relocation entries */
+ unsigned long s_nlnno; /* number of line number entries */
+ unsigned long s_flags; /* flags */
+ short s_reserved; /* reserved 2 bytes */
+ 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 _CINIT ".cinit"
+#define _PINIT ".pinit"
+
+/*------------------------------------------------------------------------*/
+/* The low 8 bits of s_flags is 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_GROUP 0x04 /* not used */
+#define STYP_PAD 0x08 /* not used */
+#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). */
+/*------------------------------------------------------------------------*/
+#define ALIGN_MASK 0xF00 /* mask for alignment factor */
+#define ALIGN_SIZE(s_flag) (1 << (((unsigned)s_flag & ALIGN_MASK) >> 8))
+
+#define STYP_BLOCK 0x1000 /* use alignment as blocking factor */
+#define STYP_PASS 0x2000 /* Pass section through unchanged */
+#define STYP_CLINK 0x4000 /* Conditionally link section */
+
+
+
+/*------------------------------------------------------------------------*/
+/* 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
+{
+ long r_vaddr; /* (virtual) address of reference */
+ short r_symndx; /* index into symbol table */
+ unsigned short r_disp; /* additional bits for addr calc */
+ unsigned short r_type; /* relocation type */
+} RELOC_OLD;
+
+typedef struct reloc
+{
+ long r_vaddr; /* (virtual) address of reference */
+#if COFF_VERSION_0
+ short r_symndx; /* 16-bit index into symbol table */
+#else
+ long r_symndx; /* 32-bit index into symbol table */
+#endif
+ unsigned short r_disp; /* additional bits for addr calc */
+ unsigned short r_type; /* relocation type */
+} RELOC;
+
+#define RELSZ (COFF_VERSION_0 ? 10 : 12)
+#define RELSZ_IN(version) ((version >= COFF_MAGIC_1) ? 12 : 10)
+
+/*------------------------------------------------------------------------*/
+/* define all relocation types */
+/*------------------------------------------------------------------------*/
+#define R_ABS 0 /* absolute address - no relocation */
+#define R_DIR16 01 /* UNUSED */
+#define R_REL16 02 /* UNUSED */
+#define R_DIR24 04 /* UNUSED */
+#define R_REL24 05 /* 24 bits, direct */
+#define R_DIR32 06 /* UNUSED */
+#define R_RRRELREG 016 /* RR: 8 bit relocatable register */
+#define R_RELBYTE 017 /* 8 bits, direct */
+#define R_RELWORD 020 /* 16 bits, direct */
+#define R_RELLONG 021 /* 32 bits, direct */
+#define R_PCRBYTE 022 /* 8 bits, PC-relative */
+#define R_PCRWORD 023 /* 16 bits, PC-relative */
+#define R_PCRLONG 024 /* 32 bits, PC-relative */
+#define R_PCR24 025 /* 24 bits, PC-relative */
+#define R_PCR23H 026 /* 23 bits, PC-rel in halfwords(x>>1) */
+#define R_PCR24W 027 /* 24 bits, PC-rel in words (x >> 2) */
+#define R_OCRLONG 030 /* GSP: 32 bits, one's compl direct */
+#define R_GSPPCR16 031 /* GSP: 16 bits, PC relative (in words) */
+#define R_GSPOPR32 032 /* GSP: 32 bits, direct big-endian */
+#define R_GSPPCA16 033 /* GSP: same as GSPPCR16, but PC const */
+#define R_OCBD32 034 /* GSP: 32 bits, 1's compl,big-endian */
+#define R_RRNREG 035 /* RR: 8 bit reloc. reg. w/ neg off */
+#define R_PARTLS16 040 /* Brahma: 16 bit offset of 24 bit addr */
+#define R_PARTMS8 041 /* Brahma: 8 bit page of 24 bit addr */
+#define R_PARTLS7 050 /* DSP: 7 bit offset of 16 bit addr */
+#define R_PARTMS9 051 /* DSP: 9 bit page of 16 bit addr */
+#define R_REL13 052 /* DSP: 13 bits, direct */
+#define R_REL23 053 /* DSP,C54X: 23 bits, direct (ext addr) */
+#define R_RELXPC 054 /* DSP,C54X: 16 bits, relative to XPC */
+#define R_HIEXT 055 /* C54X: Hi word of extended prog addr */
+#define R_HIWORD 061 /* RR: 8 bit reloc. hi byte of word */
+#define R_LABCOD 062 /* C16 16-bit code address relocation */
+
+#define R_PPBASE 064 /* PP: Global Base address type */
+#define R_PPLBASE 065 /* PP: Local Base address type */
+#define R_PP15 070 /* PP: Global 15 bit offset */
+#define R_PP15W 071 /* PP: Global 15 bit offset / 4 */
+#define R_PP15H 072 /* PP: Global 15 bit offset / 2 */
+#define R_PP16B 073 /* PP: Global 16 bit offset for bytes */
+#define R_PPL15 074 /* PP: Local 15 bit offset */
+#define R_PPL15W 075 /* PP: Local 15 bit offset divided by 4 */
+#define R_PPL15H 076 /* PP: Local 15 bit offset divided by 2 */
+#define R_PPL16B 077 /* PP: Local 16 bit offset for bytes */
+#define R_PPN15 0100 /* PP: Global 15 bit neg offset */
+#define R_PPN15W 0101 /* PP: Global 15 bit neg offset / 4 */
+#define R_PPN15H 0102 /* PP: Global 15 bit neg offset / 2 */
+#define R_PPN16B 0103 /* PP: Global 16 bit neg byte offset */
+#define R_PPLN15 0104 /* PP: Local 15 bit neg offset */
+#define R_PPLN15W 0105 /* PP: Local 15 bit neg offset / 4 */
+#define R_PPLN15H 0106 /* PP: Local 15 bit neg offset / 2 */
+#define R_PPLN16B 0107 /* PP: Local 16 bit neg byte offset */
+
+#define R_MPPCR 0117 /* MP: 32-bit PC-relative / 4 */
+
+#define R_C60BASE 0120 /* C60: Data Page Pointer Based Offset */
+#define R_C60DIR15 0121 /* C60: LD/ST long Displacement */
+#define R_C60PCR21 0122 /* C60: 21-bit Packet PC Relative */
+#define R_C60LO16 0124 /* C60: MVK Low Half Register */
+#define R_C60HI16 0125 /* C60: MVKH/MVKLH High Half Register */
+
+#define R_C8PHIBYTE 0130 /* C8+: High byte of 24-bit address. */
+#define R_C8PMIDBYTE 0131 /* C8+: Middle byte of 24-bit address. */
+#define R_C8PVECADR 0132 /* C8+: Vector address (0xFFnnnn) */
+#define R_C8PADR24 0133 /* C8+: 24-bit address (rev byte order) */
+
+#define R_PARTLS6 0135 /* ANKOOR: 6 bit offset of 22 bit addr */
+#define R_PARTMID10 0136 /* ANKOOR: Middle 10 bits of 22 bit addr*/
+#define R_REL22 0137 /* ANKOOR: 22 bits, direct */
+#define R_PARTMS6 0140 /* ANKOOR: Upper 6 bits of 22 bit addr */
+#define R_PARTMS16 0141 /* ANKOOR: Upper 16 bits of 22 bit addr */
+#define R_ANKPCR16 0142 /* ANKOOR: PC relative 16 bit */
+#define R_ANKPCR8 0143 /* ANKOOR: PC relatvie 8 bit */
+
+
+/*------------------------------------------------------------------------*/
+/* LINE NUMBER ENTRIES */
+/*------------------------------------------------------------------------*/
+struct lineno
+{
+ union
+ {
+ long l_symndx; /* sym index of fcn name iff l_lnno == 0 */
+ long l_paddr; /* (physical) address of line number */
+ } l_addr;
+ unsigned short l_lnno; /* line number */
+};
+
+#define LINENO struct lineno
+#define LINESZ 6 /* sizeof(LINENO) */
+
+
+/*------------------------------------------------------------------------*/
+/* 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 STYPE;
+
+struct syment
+{
+ union
+ {
+ char _n_name[SYMNMLEN]; /* old COFF version */
+ struct
+ {
+ long _n_zeroes; /* new == 0 */
+ long _n_offset; /* offset into string table */
+ } _n_n;
+ char *_n_nptr[2]; /* allows for overlaying */
+ } _n;
+
+ long n_value; /* value of symbol */
+ short n_scnum; /* section number */
+ STYPE 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 */
+
+
+/*------------------------------------------------------------------------*/
+/* AUXILIARY SYMBOL ENTRY */
+/*------------------------------------------------------------------------*/
+#define SPACE(len, name) char name[len]
+
+union auxent
+{
+ struct
+ {
+ SPACE(4, _0_3);
+ long x_fsize; /* size of struct in bits. */
+ SPACE(4, _8_11);
+ long x_endndx; /* ptr to next sym beyond .eos */
+ SPACE(2, _16_17);
+ } x_tag;
+
+ struct
+ {
+ long x_tagndx; /* ptr to beginning of struct */
+ long x_fsize; /* size of struct in bits. */
+ SPACE(10, _8_17);
+ } x_eos;
+
+ struct
+ {
+ long x_tagndx; /* ptr to tag for function */
+ long x_fsize; /* size of function in bits */
+ long x_lnnoptr; /* file ptr to fcn line # */
+ long x_endndx; /* ptr to next sym beyond .ef */
+ SPACE(2, _16_17);
+ } x_func;
+
+ struct
+ {
+ long 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 */
+ long x_framesize; /* size of func local vars */
+ long x_endndx; /* ptr to next sym beyond .eb */
+ SPACE(2, _16_17);
+ } x_block;
+
+ struct
+ {
+ long x_tagndx; /* ptr to tag for array type */
+ long x_fsize; /* Size of array in bits. */
+ unsigned short x_dimen[DIMNUM];
+ SPACE(2, _16_17);
+ } x_array;
+
+ struct
+ {
+ long x_tagndx; /* str, un, or enum tag indx */
+ long x_fsize; /* Size of symbol */
+ SPACE(10, _10_17);
+ } x_sym;
+
+ struct
+ {
+ char x_fname[FILNMLEN];
+ } x_file;
+
+ struct
+ {
+ long 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 _CINITPTR "cinit"
+#define _PINITPTR "pinit"
+#define _ASM_SRC_NAME "$ASM$" /* SPECIAL SYMBOL FOR ASSY SRC DEBUG */
+
+/*------------------------------------------------------------------------*/
+/* ENTRY POINT SYMBOLS */
+/*------------------------------------------------------------------------*/
+#define _START "_start"
+#define _MAIN "_main"
+
diff --git a/data/mnet/GP10/Host/cdcUtils/include/coffdefs.h b/data/mnet/GP10/Host/cdcUtils/include/coffdefs.h
new file mode 100644
index 0000000..47c1879
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/include/coffdefs.h
@@ -0,0 +1,232 @@
+/***************************************************************************
+* FILENAME: coffdefs.h
+* VERSION: 2.2 3/1/96 17:06:02
+* SCCS ID: "@(#)coffdefs.h 2.2 3/1/96"
+***************************************************************************/
+/**************************************************************************/
+/* COFFDEFS.H */
+/* Definitions of COFF symbol type and storage class fields. */
+/**************************************************************************/
+
+/*------------------------------------------------------------------------*/
+/* 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 0x1
+#define CQ_FAR 0x2
+#define CQ_INLINE 0x4
+#define CQ_SUPPRESS 0x8
+#define CQ_CONTROL 0x10
+#define CQ_INTERRUPT 0x20
+#define CQ_TRAP 0x40
+#define CQ_GREGISTER 0x80
+#define CQ_PORT 0x100
+#define CQ_SYSTEM 0x200
+#define CQ_SYSTEMPP 0x400
+#define CQ_REENTRANT 0x800
+
+/*------------------------------------------------------------------------*/
+/* 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 ISREENTRANT(cq) (((cq) & CQ_REENTRANT) != 0)
+#define ISTRAP(cq) (((cq) & CQ_TRAP) != 0)
+#define ISINT_OR_TRAP(cq) (((cq) & (CQ_TRAP | CQ_INTERRUPT)) != 0)
+
+
+
+/*------------------------------------------------------------------------*/
+/* BASIC TYPES - PACKED INTO THE LOWER 4 BITS OF THE TYPE FIELD */
+/*------------------------------------------------------------------------*/
+#define T_NULL 0x80 /* UNDEFINED OR ERROR TYPE (NO TYPE INFO) */
+#define T_VOID 0 /* VOID TYPE */
+#define T_SCHAR 1 /* CHARACTER (EXPLICITLY "signed") */
+#define T_CHAR 2 /* CHARACTER (IMPLICITLY SIGNED) */
+#define T_SHORT 3 /* SHORT INTEGER */
+#define T_INT 4 /* INTEGER */
+#define T_LONG 5 /* LONG INTEGER */
+#define T_FLOAT 6 /* SINGLE PRECISION FLOATING POINT */
+#define T_DOUBLE 7 /* DOUBLE PRECISION FLOATING POINT */
+#define T_STRUCT 8 /* STRUCTURE */
+#define T_UNION 9 /* UNION */
+#define T_ENUM 10 /* ENUMERATION */
+#define T_LDOUBLE 11 /* LONG DOUBLE FLOATING POINT */
+#define T_UCHAR 12 /* UNSIGNED CHARACTER */
+#define T_USHORT 13 /* UNSIGNED SHORT */
+#define T_UINT 14 /* UNSIGNED INTEGER */
+#define T_ULONG 15 /* UNSIGNED LONG */
+
+/*------------------------------------------------------------------------*/
+/* SIGNED AND UNSIGNED ARE NOT ACTUALLY STORED IN THE TYPE FIELD BUT */
+/* USED TO MODIFY THE BYTPE ACCORDINGLY. */
+/*------------------------------------------------------------------------*/
+#define T_SIGNED 16 /* BECOMES CHAR, SHORT, INT, OR LONG */
+#define T_UNSIGNED 17 /* BECOMES UCHAR, USHORT, UINT, OR ULONG */
+
+/*------------------------------------------------------------------------*/
+/* DERIVED TYPES: 2 BITS EACH */
+/*------------------------------------------------------------------------*/
+#define DT_NON 0x0 /* NO DERIVED TYPE */
+#define DT_PTR 0x1 /* POINTER */
+#define DT_FCN 0x2 /* FUNCTION */
+#define DT_ARY 0x3 /* ARRAY */
+
+/*------------------------------------------------------------------------*/
+/* TYPE QUALIFIERS - USES SAME ENCODING AS TYPE FIELDS */
+/*------------------------------------------------------------------------*/
+#define Q_CONST 0x1
+#define Q_VOLATILE 0x2
+
+
+/*------------------------------------------------------------------------*/
+/* TYPE FIELD MASKS AND SIZES */
+/*------------------------------------------------------------------------*/
+#define N_BTMASK 0xF /* MASK FOR BASIC TYPE */
+#define N_TMASK 0x30 /* MASK FOR FIRST DERIVED TYPE */
+#define N_DTMAX 12 /* MAXIMUM DERIVED TYPES */
+#define N_BTSHFT 4 /* SHIFT AMOUNT (WIDTH) FOR BASIC TYPE */
+#define N_TSHIFT 2 /* SHIFT AMOUNT (WIDTH) FOR DERIVED TYPES */
+
+/*------------------------------------------------------------------------*/
+/* TYPE MANIPULATION MACROS */
+/* */
+/* BTYPE(t) - Return basic type from t */
+/* DTYPE(t) - Return all derived types from t */
+/* DTYPE1(t) - Return 1st derived type from t */
+/* TQUAL(t,q) - Return qualification of type */
+/* UNQUAL(t,q) - Return unqualified version of type */
+/* */
+/* MKTYPE() - Build a type from basic and several derived types */
+/* DERIVE(d,t) - Build a type from basic and one derived type */
+/* INCREF(t) - Convert 't' into pointer to 't' */
+/* DECREF(t) - Remove first derviation from t */
+/* */
+/* ISINT(t) - TRUE if t is an integral type */
+/* ISSGN(t) - TRUE if t is a signed type */
+/* ISUNS(t) - TRUE if t is an unsigned type */
+/* ISFLT(t) - TRUE if t is a floating point type */
+/* ISDBL(t) - TRUE if t is a double or long double type */
+/* ISPTR(t) - TRUE if t is a pointer */
+/* ISFCN(t) - TRUE if t is a function */
+/* ISARY(t) - TRUE if t is an array */
+/* ISSTR(t) - TRUE if t is a struct, union, or enum type */
+/* ISAGG(t) - TRUE if t is an array, struct, or union */
+/* */
+/* ITOU(t) - convert signed type to unsigned equivalent */
+/* UTOI(t) - convert unsigned type to signed equivalent */
+/* NOSIGN(t) - convert signed or unsigned type to "plain" equivalent */
+/*------------------------------------------------------------------------*/
+#define BTYPE(t) ((int)((t) & N_BTMASK))
+#define DTYPE(t) ((t) & ~N_BTMASK)
+#define DTYPE1(t) (((t) & N_TMASK) >> N_BTSHFT)
+
+#define TQUAL(t,q) ((int)(DTYPE(t) ? DTYPE1(q) : BTYPE(q)))
+#define UNQUAL(t,q) (ISPTR(t) ? ((q) & ~N_TMASK) : ((q) & ~N_BTMASK))
+
+#define MKTYPE(basic, d1,d2,d3,d4,d5,d6) \
+ ((basic) | ((d1) << 4) | ((d2) << 6) | ((d3) << 8) |\
+ ((d4) << 10) | ((d5) << 12) | ((d6) << 14))
+#define DERIVE(d,t) ((DTYPE(t) << N_TSHIFT) | ((d) << N_BTSHFT) | BTYPE(t))
+#define INCREF(t) ((DTYPE(t) << N_TSHIFT) | (DT_PTR << N_BTSHFT) | BTYPE(t))
+#define DECREF(t) (DTYPE((t) >> N_TSHIFT) | BTYPE(t))
+
+#define ISSGN(t) (((t) >= T_SCHAR && (t) <= T_LONG) || (t) == T_ENUM)
+#define ISUNS(t) ((t) >= T_UCHAR && (t) <= T_ULONG)
+#define ISINT(t) (((t) >= T_SCHAR && (t) <= T_LONG) || (t) == T_ENUM || \
+ ((t) >= T_UCHAR && (t) <= T_ULONG))
+#define ISFLT(t) ((t) == T_FLOAT || (t) == T_DOUBLE || (t) == T_LDOUBLE)
+#define ISDBL(t) ((t) == T_DOUBLE || (t) == T_LDOUBLE)
+#define ISPTR(t) (((t) & N_TMASK) == (DT_PTR << N_BTSHFT))
+#define ISFCN(t) (((t) & N_TMASK) == (DT_FCN << N_BTSHFT))
+#define ISARY(t) (((t) & N_TMASK) == (DT_ARY << N_BTSHFT))
+#define ISSTR(t) ((t) == T_STRUCT || (t) == T_UNION || (t) == T_ENUM)
+#define ISAGG(t) (ISARY(t) || (t) == T_STRUCT || (t) == T_UNION)
+#define ISCHAR(t) ((t) == T_CHAR || (t) == T_SCHAR || (t) == T_UCHAR)
+#define ISSHORT(t) ((t) == T_SHORT || (t) == T_USHORT)
+#define ISLONG(t) ((t) == T_LONG || (t) == T_ULONG)
+
+#define ITOU(t) ((t) + (T_UCHAR - ((t) == T_SCHAR ? T_SCHAR : T_CHAR)))
+#define UTOI(t) ((t) - (T_UCHAR - T_CHAR))
+#define NOSIGN(t) (ISUNS(t) ? UTOI(t) : (t) == T_SCHAR ? T_CHAR : (t))
+
+/*------------------------------------------------------------------------*/
+/* ILLEGAL TYPES USED TO MARK SPECIAL OBJECTS. */
+/* */
+/* T_VENEER - DENOTES A VENEER OF A FUNCTION. */
+/*------------------------------------------------------------------------*/
+#define T_VENEER (MKTYPE(T_VOID, DT_FCN, DT_FCN, 0, 0, 0, 0))
+#define ISVENEER(t) ((t) == T_VENEER)
diff --git a/data/mnet/GP10/Host/cdcUtils/include/header.h b/data/mnet/GP10/Host/cdcUtils/include/header.h
new file mode 100644
index 0000000..1d7df1e
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/include/header.h
@@ -0,0 +1,35 @@
+/************************************************************************/
+/* HEADER.H - STANDARD HEADER FILE FOR COFF LOADERS */
+/************************************************************************/
+
+/*-----------------------------------------------------------------------*/
+/* THE PARMS MACRO IS USED TO EXPAND FUNCTION ARGUMENT PROTOTYPES. THIS */
+/* ENABLES THE SHARING OF PROTOTYPE DEFINITIONS BETWEEN ANSI AND N0N-ANSI*/
+/* COMPILERS. FOR ANSI COMPILERS PROTOTYPE PARAMETERS ARE INCLUDED, FOR */
+/* NON-ANSI COMPILERS PROTOTYPE PARAMETERS ARE EXCLUDED. */
+/* TO USE THE PARMS MACRO, PROTOTYPES SHOULD BE DEFINED IN THE */
+/* FOLLOWING MANNER: */
+/* extern int foo PARMS((double d, int i, char *s)); */
+/*-----------------------------------------------------------------------*/
+#ifdef __STDC__
+#define PARMS(x) x
+#else
+#define PARMS(x) ()
+#endif
+
+/*-----------------------------------------------------------------------*/
+/* INCLUDE STANDARD HEADER FILES */
+/*-----------------------------------------------------------------------*/
+#include <stdio.h>
+#include "version.h"
+#include "params.h"
+#include "coff.h"
+#include "cload.h"
+#include "proto.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/data/mnet/GP10/Host/cdcUtils/include/params.h b/data/mnet/GP10/Host/cdcUtils/include/params.h
new file mode 100644
index 0000000..44c1b65
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/include/params.h
@@ -0,0 +1,277 @@
+/****************************************************************************/
+/* PARAMS.H - Target dependent parameters. */
+/****************************************************************************/
+
+#if TMS340
+typedef unsigned long 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 long 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 long T_ADDR; /* TYPE FOR TARGET ADDRESS */
+typedef unsigned long T_DATA; /* TYPE FOR TARGET DATA WORD */
+typedef unsigned long T_SIZE; /* TYPE FOR CINIT SIZE FIELD */
+typedef unsigned long T_IADDR; /* TYPE FOR CINIT ADDRESS FIELD */
+typedef unsigned long 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 long T_ADDR; /* TYPE FOR TARGET ADDRESS */
+typedef unsigned long T_DATA; /* TYPE FOR TARGET DATA WORD */
+typedef unsigned long T_SIZE; /* TYPE FOR CINIT SIZE FIELD */
+typedef unsigned long T_IADDR; /* TYPE FOR CINIT ADDRESS FIELD */
+
+typedef struct {unsigned long ins_h; unsigned long 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 long T_ADDR; /* TYPE FOR TARGET ADDRESS */
+typedef unsigned long T_DATA; /* TYPE FOR TARGET DATA WORD */
+typedef unsigned long T_SIZE; /* TYPE FOR CINIT SIZE FIELD */
+typedef unsigned long T_IADDR; /* TYPE FOR CINIT ADDRESS FIELD */
+typedef unsigned long 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 long fval1;
+ unsigned long 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 ARM
+typedef unsigned long T_ADDR; /* TYPE FOR TARGET ADDRESS */
+typedef unsigned long T_DATA; /* TYPE FOR TARGET DATA WORD */
+typedef unsigned long T_SIZE; /* TYPE FOR CINIT SIZE FIELD */
+typedef unsigned long T_IADDR; /* TYPE FOR CINIT ADDRESS FIELD */
+typedef unsigned long 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 long T_ADDR; /* TYPE FOR TARGET ADDRESS */
+typedef unsigned long T_DATA; /* TYPE FOR TARGET DATA WORD */
+typedef unsigned long T_SIZE; /* TYPE FOR CINIT SIZE FIELD */
+typedef unsigned long T_IADDR; /* TYPE FOR CINIT ADDRESS FIELD */
+typedef unsigned long 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 long fval1;
+ unsigned long 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 */
+#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/data/mnet/GP10/Host/cdcUtils/include/proto.h b/data/mnet/GP10/Host/cdcUtils/include/proto.h
new file mode 100644
index 0000000..3be328a
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/include/proto.h
@@ -0,0 +1,13 @@
+/*****************************************************************************/
+/* PROTO.H - Prototypes for loader required functions. */
+/*****************************************************************************/
+
+/*--------------------------------------------------------------------------*/
+/* LOADER REQUIRED FUNCTIONS */
+/*--------------------------------------------------------------------------*/
+extern int mem_write PARMS((unsigned char *, unsigned int, T_ADDR, unsigned char));
+extern int set_reloc_amount PARMS((void));
+extern void lookup_sym PARMS((long indx, SYMENT *sym, AUXENT *aux));
+extern int load_syms PARMS((int need_reloc));
+extern void *myalloc PARMS((unsigned int size));
+extern void *mralloc PARMS((void *p, unsigned int size));
diff --git a/data/mnet/GP10/Host/cdcUtils/include/version.h b/data/mnet/GP10/Host/cdcUtils/include/version.h
new file mode 100644
index 0000000..e8de207
--- /dev/null
+++ b/data/mnet/GP10/Host/cdcUtils/include/version.h
@@ -0,0 +1,27 @@
+/**********************************************************************/
+/* VERSION.H -- HOST DEFINITION FLAGS. */
+/**********************************************************************/
+
+/****************************************************************************/
+/* TARGET SPECIFIC FLAGS */
+/****************************************************************************/
+#define TMS340 0 /* TMS340 */
+#define TMS34020 0 /* TMS340 340XX, 0 for 10 only */
+#define TMS370 0 /* Roadrunner */
+#define TMS370C8 0 /* C8 */
+#define TMS370C8P 0 /* C8+ */
+#define TMS32030 0 /* Brahma */
+#define TMS32025 0 /* Shiva, Himiko */
+#define TMS32050 0 /* Mosaic */
+#define TMS380 0 /* Eagle */
+#define TMS37016 0 /* Prism */
+#define MVP_PP 0 /* MVP PP */
+#define MVP_MP 0 /* MVP MP */
+#define ARM 0 /* ARM */
+#define LEAD 0
+#define TMS32060 1 /* C60 */
+
+#define MSDOS 0 /* FOR MS-DOS 2.0+ ON IBM PC */
+#define VAX_VMS 0 /* FOR VAX VMS 3.5 */
+#define UNIX 1 /* FOR SYSTEM V UNIX */
+#define MPW 0 /* FOR APPLE MACINTOSH OR MAC II */