add ifx adsl tools

SVN-Revision: 9900
This commit is contained in:
John Crispin 2007-12-24 23:06:11 +00:00
parent d0074af438
commit 34cf8e94c2
10 changed files with 2614 additions and 0 deletions

View file

@ -0,0 +1,45 @@
#
# Copyright (C) 2007 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
# $Id$
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=ifxmips_adsl
PKG_RELEASE:=1
PKG_VERSION:=1.0
include $(INCLUDE_DIR)/package.mk
define Package/ifxmips_adsl
SECTION:=net
CATEGORY:=Network
DEPENDS:=@TARGET_ifxmips
TITLE:=ifxmips adsl firmware loader
endef
define Package/ifxmips_adsl/description
ifxmips adsl firmware loader
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
$(TARGET_CONFIGURE_OPTS) \
CFLAGS="$(TARGET_CFLAGS) -I$(LINUX_DIR)/include/"
endef
define Package/ifxmips_adsl/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/{translate,danube_autoboot_daemon,danube_mei_debug,danube_show_firmware_date,cmvread,cmvwrite} $(1)/usr/bin/
endef
$(eval $(call BuildPackage,ifxmips_adsl))

View file

@ -0,0 +1,10 @@
CFLAGS?=
TARGET = translate danube_autoboot_daemon danube_mei_debug danube_show_firmware_date cmvread cmvwrite
all: $(TARGET)
.PHONY: clean
clean:
-rm -f $(DEPS) $(OBJS) $(TARGET)

View file

@ -0,0 +1,216 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
//-----------------------------------------------------------------------
//Description:
// read the CMV register under Linux for Amazon
//-----------------------------------------------------------------------
//Author: Joe.Lin@infineon.com
//Created: 31-December-2004
//-----------------------------------------------------------------------
/* History
* Last changed on:
* 000002:tc.chen 2005/06/10 add get_adsl_rate and ifx_makeCMV api
* Last changed by:
*
*/
#define _IFXMIPS_ADSL_APP
//#define DEBUG
#define u32 unsigned int
#define u16 unsigned short
#define u8 unsigned char
#define IFXMIPS_MEI_DEV "/dev/ifxmips/mei"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <getopt.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <asm/ifxmips/ifxmips_mei_app_ioctl.h>
#include <asm/ifxmips/ifxmips_mei_app.h>
#include <asm/ifxmips/ifxmips_mei_ioctl.h>
#include <asm/ifxmips/ifxmips_mei.h>
#ifdef IFX_MULTILIB_UTIL
#define main cmvread_main
#define display_version cmvread_display_version
#endif
/*============================definitions======================*/
#define OPTN 5
#define CNFG 8
#define CNTL 1
#define STAT 2
#define RATE 6
#define PLAM 7
#define INFO 3
#define TEST 4
typedef unsigned short UINT16;
typedef unsigned long UINT32;
/*=============================================================*/
/*=============================global variables================*/
int c=0;
int input_flag=0;
int digit_optind=0;
FILE* script_file;
void (*func)()=NULL;
int fd;
UINT16 var16[8];
UINT32 var32[8];
UINT16 Message[16];
/*=============================================================*/
int ifx_makeCMV(unsigned char opcode, unsigned char group, unsigned short address, unsigned short index, int size, unsigned short * data, unsigned short *Message, int msg_len)
{
if (msg_len < 16*2)
return -1;
memset(Message, 0, 16*2);
Message[0]= (opcode<<4) + (size&0xf);
if(opcode == H2D_DEBUG_WRITE_DM)
Message[1]= (group&0x7f);
else
Message[1]= (((index==0)?0:1)<<7) + (group&0x7f);
Message[2]= address;
Message[3]= index;
if((opcode == H2D_CMV_WRITE)||(opcode == H2D_DEBUG_WRITE_DM))
memcpy(Message+4, data, size*2);
return 0;
}
void display_version()
{
printf("adsl cmv reader version1.0\nby Joe Lin \nJoe.Lin@infineon.com\n");
return;
}
void cmvreader_help()
{
printf("Usage:cmvread [options] [group name][address][index][size] ...\n");
printf("options:\n");
printf(" -h --help Display help information\n");
printf(" -v --version Display version information\n");
printf("group name: --group name of CMV to read\n");
printf(" OPTN --Read CMV Group 5 \n");
printf(" CNFG --Read CMV Group 8 \n");
printf(" CNTL --Read CMV Group 1 \n");
printf(" STAT --Read CMV Group 2 \n");
printf(" RATE --Read CMV Group 6 \n");
printf(" PLAM --Read CMV Group 7 \n");
printf(" INFO --Read CMV Group 3 \n");
printf(" TEST --REad CMV Group 4 \n");
printf("address --address value of CMV to read\n");
printf("index --index value of CMV to read\n");
printf("size --number of words(16bits) to read \n");
return;
}
int main (int argc, char** argv) {
UINT16 Message[16]; //000002:tc.chen
char *endptr;
int group=0,address,index,size;
if (argc < 2)
{
cmvreader_help();
return;
}
if (strstr(argv[1], "-h") != NULL){
cmvreader_help();
return;
}
if (strstr(argv[1], "-v") != NULL){
display_version();
return;
}
fd=open(IFXMIPS_MEI_DEV, O_RDWR);
if(fd<0){
printf("\n\n autoboot open device fail\n");
return -1;
}
if((strcmp(argv[1],"optn")==0)||(strcmp(argv[1],"OPTN")==0))
group=OPTN;
else if((strcmp(argv[1],"cnfg")==0)||(strcmp(argv[1],"CNFG")==0))
group=CNFG;
else if((strcmp(argv[1],"cntl")==0)||(strcmp(argv[1],"CNTL")==0))
group=CNTL;
else if((strcmp(argv[1],"stat")==0)||(strcmp(argv[1],"STAT")==0))
group=STAT;
else if((strcmp(argv[1],"rate")==0)||(strcmp(argv[1],"RATE")==0))
group=RATE;
else if((strcmp(argv[1],"plam")==0)||(strcmp(argv[1],"PLAM")==0))
group=PLAM;
else if((strcmp(argv[1],"info")==0)||(strcmp(argv[1],"INFO")==0))
group=INFO;
else if((strcmp(argv[1],"test")==0)||(strcmp(argv[1],"TEST")==0))
group=TEST;
else
{
printf("wrong group type!\nplease slect group:OPTN CNFG CNTL STAT RATE PLAM INFO TEST \n");
close(fd);
exit(0);
}
address = strtoul(argv[2], &endptr, 0);
index = strtoul(argv[3], &endptr, 0);
size = strtoul(argv[4], &endptr, 0);
//makeCMV(H2D_CMV_READ, group, address, index, size, NULL);
ifx_makeCMV(H2D_CMV_READ, group, address, index, size, NULL,Message,sizeof(Message));
if(ioctl(fd, IFXMIPS_MEI_CMV_WINHOST, &Message)<0){
printf("cr read %d %d %d fail",group,address,index);
close(fd);
exit(0);
}
int i;
for (i=0;i<size;i++) printf ("0x%X\n",Message[i+4]);
// return Message[4];
close(fd);
return 0;
}

View file

@ -0,0 +1,221 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
//-----------------------------------------------------------------------
//Description:
// read the CMV register under Linux for Amazon
//-----------------------------------------------------------------------
//Author: Joe.Lin@infineon.com
//Created: 31-December-2004
//-----------------------------------------------------------------------
/* History
* Last changed on:
* 507051:linmars 2005/07/5 fix makeCMV problem
* Last changed by:
*
*/
#define _IFXMIPS_ADSL_APP
//#define DEBUG
#define u32 unsigned int
#define u16 unsigned short
#define u8 unsigned char
#define IFXMIPS_MEI_DEV "/dev/ifxmips/mei"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <getopt.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <asm/ifxmips/ifxmips_mei_app_ioctl.h>
#include <asm/ifxmips/ifxmips_mei_app.h>
#include <asm/ifxmips/ifxmips_mei_ioctl.h>
#include <asm/ifxmips/ifxmips_mei.h>
#ifdef IFX_MULTILIB_UTIL
#define main cmvwrite_main
#define display_version cmvwrite_display_version
#endif
/*============================definitions======================*/
#define OPTN 5
#define CNFG 8
#define CNTL 1
#define STAT 2
#define RATE 6
#define PLAM 7
#define INFO 3
#define TEST 4
typedef unsigned short UINT16;
typedef unsigned long UINT32;
/*=============================================================*/
/*=============================global variables================*/
#ifdef IFX_MULTILIB_UTIL
extern int c;
extern int input_flag;
extern int digit_optind;
extern FILE* script_file;
extern void (*func)();
extern int fd;
UINT16 var16[8];
UINT32 var32[8];
UINT16 Message[16];
#else
int c=0;
int input_flag=0;
int digit_optind=0;
FILE* script_file;
void (*func)()=NULL;
int fd;
UINT16 var16[8];
UINT32 var32[8];
UINT16 Message[16];
#endif
/*=============================================================*/
/*165001:henryhsu 2005/9/7 Modify some error in cmvwrite utility*/
int ifx_makeCMV(unsigned char opcode, unsigned char group, unsigned short address, unsigned short index, int size, unsigned short * data, unsigned short *Message, int msg_len)
{
if (msg_len < 16*2)
return -1;
memset(Message, 0, 16*2);
Message[0]= (opcode<<4) + (size&0xf);
if(opcode == H2D_DEBUG_WRITE_DM)
Message[1]= (group&0x7f);
else
Message[1]= (((index==0)?0:1)<<7) + (group&0x7f);
Message[2]= address;
Message[3]= index;
if((opcode == H2D_CMV_WRITE)||(opcode == H2D_DEBUG_WRITE_DM))
memcpy(Message+4, data, size*2);
return 0;
}
void display_version()
{
printf("adsl cmv write version1.0\nby Joe Lin \nJoe.Lin@infineon.com\n");
return;
}
//165001:henryhsu 2005/9/7 No need to check this any more
//#ifndef IFX_MULTILIB_UTIL
//void cmvreader_help()
void cmvwrite_help()
{
printf("Usage:cmvwrite [options] [group name][address][index][data] ...\n");
printf("options:\n");
printf(" -h --help Display help information\n");
printf(" -v --version Display version information\n");
printf("group name: --group name of CMV to read\n");
printf(" OPTN -- CMV Group 5 \n");
printf(" CNFG -- CMV Group 8 \n");
printf(" CNTL -- CMV Group 1 \n");
printf(" STAT -- CMV Group 2 \n");
printf(" RATE -- CMV Group 6 \n");
printf(" PLAM -- CMV Group 7 \n");
printf(" INFO -- CMV Group 3 \n");
printf(" TEST -- CMV Group 4 \n");
printf("address --address value of CMV to write\n");
printf("index --index value of CMV to write\n");
printf("data --data to write in Hex.\n");
return;
}
int main (int argc, char** argv) {
char *endptr;
unsigned short value;
if (argc < 2)
{
cmvwrite_help();
return;
}
if (strstr(argv[1], "-h") != NULL){
cmvwrite_help();
return;
}
if (strstr(argv[1], "-v") != NULL){
display_version();
return;
}
fd=open(IFXMIPS_MEI_DEV, O_RDWR);
if(fd<0){
printf("\n\n autoboot open device fail\n");
return -1;
}
int group=0,address,index,size;
if((strcmp(argv[1],"optn")==0)||(strcmp(argv[1],"OPTN")==0))
group=OPTN;
else if((strcmp(argv[1],"cnfg")==0)||(strcmp(argv[1],"CNFG")==0))
group=CNFG;
else if((strcmp(argv[1],"cntl")==0)||(strcmp(argv[1],"CNTL")==0))
group=CNTL;
else if((strcmp(argv[1],"stat")==0)||(strcmp(argv[1],"STAT")==0))
group=STAT;
else if((strcmp(argv[1],"rate")==0)||(strcmp(argv[1],"RATE")==0))
group=RATE;
else if((strcmp(argv[1],"plam")==0)||(strcmp(argv[1],"PLAM")==0))
group=PLAM;
else if((strcmp(argv[1],"info")==0)||(strcmp(argv[1],"INFO")==0))
group=INFO;
else if((strcmp(argv[1],"test")==0)||(strcmp(argv[1],"TEST")==0))
group=TEST;
else
{
printf("wrong group type!\nplease slect group:OPTN CNFG CNTL STAT RATE PLAM INFO TEST \n");
close(fd);
exit(0);
}
address = strtoul(argv[2], &endptr, 10);
index = strtoul(argv[3], &endptr, 10);
value = strtoul(argv[4],NULL,0);
ifx_makeCMV(H2D_CMV_WRITE, group, address, index, 1, &value, Message, sizeof(Message));
if(ioctl(fd, IFXMIPS_MEI_CMV_WINHOST, &Message)<0){
printf("cr read %d %d %d fail",group,address,index);
close(fd);
exit(0);
}
printf ("write %s %d %d 0x%X\n",argv[1],address,index,value);
close(fd);
return 0;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,84 @@
#define _IFXMIPS_ADSL_APP
#define u32 unsigned int
#define IFXMIPS_MEI_DEV "/dev/ifxmips/mei"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <asm/ifxmips/ifxmips_mei_app.h>
#include <asm/ifxmips/ifxmips_mei_ioctl.h>
#include <asm/ifxmips/ifxmips_mei_app_ioctl.h>
#define SEGMENT_SIZE (64*1024)
#if 0
#define u8 unsigned char
#define u16 unsigned short
#endif
int main(int argc, char **argv)
{
int fd_image, fd_mei;
char *buf;
struct stat state;
int i,j;
char * filename;
int size,read_size=SEGMENT_SIZE;
u16 temp=0;
u16 Message[16]__attribute__ ((aligned(4)));
meidebug dbg_data;
int rw_flag =0;
if(argc<4){
printf("\nWrong Arguments! Usage: %s r/w address size/value\n",argv[0]);
return -1;
}
fd_mei=open(IFXMIPS_MEI_DEV, O_RDWR);
if(fd_mei<0)
printf("\n open device fail");
dbg_data.iAddress = strtoul(argv[2],NULL,0);
printf("Address = %08X\n",dbg_data.iAddress);
if(argv[1][0]=='w')
{
dbg_data.buffer[0]=strtoul(argv[3],NULL,0);
dbg_data.iCount = 1;
rw_flag = 1;
}else
{
dbg_data.iCount =strtoul(argv[3],NULL,0);
}
if (rw_flag==1)
{
if(ioctl(fd_mei, IFXMIPS_MEI_WRITEDEBUG,&dbg_data)!=MEI_SUCCESS){
printf("\n IFXMIPS_MEI_WRITEDEBUG() failed");
close(fd_mei);
return -1;
}
printf("Writing %08X with data %X!\n",dbg_data.iAddress,dbg_data.buffer[0]);
}else
{
if(ioctl(fd_mei, IFXMIPS_MEI_READDEBUG,&dbg_data)!=MEI_SUCCESS){
printf("\n IFXMIPS_MEI_READDEBUG() failed");
close(fd_mei);
return -1;
}
printf("Read %08X .\nResult:",dbg_data.iAddress);
for (i=0;i<dbg_data.iCount;i++)
{
printf("%08X ",dbg_data.buffer[i]);
if(i%4==3)
printf("\n");
}
printf("\n");
}
close(fd_mei);
}

View file

@ -0,0 +1,75 @@
#define _IFXMIPS_ADSL_APP
#define u32 unsigned int
#define IFXMIPS_MEI_DEV "/dev/ifxmips/mei"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <asm/ifxmips/ifxmips_mei_app_ioctl.h>
#include <asm/ifxmips/ifxmips_mei_app.h>
#include <asm/ifxmips/ifxmips_mei_ioctl.h>
u16 Message[16]__attribute__ ((aligned(4)));
void makeCMV(u8 opcode, u8 group, u16 address, u16 index, int size, u16 * data);
void makeCMV(u8 opcode, u8 group, u16 address, u16 index, int size, u16 * data)
{
memset(Message, 0, 16*2);
Message[0]= (opcode<<4) + (size&0xf);
if(opcode == H2D_DEBUG_WRITE_DM)
Message[1]= (group&0x7f);
else
Message[1]= (((index==0)?0:1)<<7) + (group&0x7f);
Message[2]= address;
Message[3]= index;
if((opcode == H2D_CMV_WRITE)||(opcode == H2D_DEBUG_WRITE_DM))
memcpy(Message+4, data, size*2);
return;
}
int main(int argc, char **argv)
{
int fd;
u16 temp=0;
u16 rt_buildcode_lsw=0, rt_buildcode_msw=0;
u32 rt_buildcode = 0;
fd=open(IFXMIPS_MEI_DEV, O_RDWR);
if(fd<0){
printf("\n\n autoboot open device fail");
return -1;
}
makeCMV(H2D_CMV_READ, INFO, 55, 0, 1, &temp);
if(ioctl(fd, IFXMIPS_MEI_CMV_WINHOST, &Message)<0){
printf("\n\n read INFO 55 0 fail");
return -1;
}
rt_buildcode_lsw = Message[4];
makeCMV(H2D_CMV_READ, INFO, 55, 1, 1, &temp);
if(ioctl(fd, IFXMIPS_MEI_CMV_WINHOST, &Message)<0){
printf("\n\n read INFO 55 1 fail");
return -1;
}
rt_buildcode_msw = Message[4];
rt_buildcode = rt_buildcode_lsw + (rt_buildcode_msw << 16);
printf("date: %d, month: %d, hour: %d, minute: %d\n",
(rt_buildcode >> 0) & 0xFF,
(rt_buildcode >> 8) & 0xFF,
(rt_buildcode >> 16) & 0xFF,
(rt_buildcode >> 25) & 0xFF
);
return 0;
}

View file

@ -0,0 +1,14 @@
#
# Automatically generated by make menuconfig: don't edit
#
# CONFIG_AMZ is not set
CONFIG_DNB=y
IFX_CONFIG_CPU="IFXMIPS"
IFX_CONFIG_FUTURE_SET="V33WT_SM"
IFX_CONFIG_MEMORY_SIZE=32
IFX_CONFIG_FLASH_SIZE=4
IFX_UBOOT_RAM_TEXT_BASE=0xa0400000
IFX_HEAD_FLASH_TEXT_BASE=0xb0000000
IFX_IN_PAD_LEN=25000
#### End of Configuration ####

View file

@ -0,0 +1,90 @@
#
# Automatically generated by make menuconfig: don't edit
#
#
# General Setup
#
CONFIG_TC_3_3_6=y
TOOLCHAIN_DIR="/opt/uclibc-toolchain/ifx-lxdb-1-2"
BUILD_DIR="/mnt/the-noob/build"
BUILD_VOB="n"
# COPY_TFTP is not set
TOPDIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0/"
KERNEL_SOURCE_DIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0//source/kernel/opensource/linux-2.4.31/"
BUILD_ROOTFS_DIR="/mnt/the-noob/build/root_filesystem/"
UBOOT_SOURCE_DIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0//source/u-boot/"
USER_SOURCE_DIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0//source/user/"
USER_IFXSOURCE_DIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0//source/user/ifx/"
USER_OPENSOURCE_DIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0//source/user/opensource/"
IFX_APIS_DIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0//source/user/ifx/IFXAPIs/"
KERNEL_IFX_DIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0//source/kernel/ifx/"
BUILD_TOOLS_DIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0//tools/build_tools/"
KERNEL_CONFIG="/mnt/CD1_BSP/software/ReleasePackage/3.3.0//source/kernel/opensource/linux-2.4.31//.config"
TOOLS_DIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0/tools/build_tools"
VER_FILE="/mnt/CD1_BSP/software/ReleasePackage/3.3.0/tools/build_tools/versions"
IFX_HOSTCC="gcc"
BUILD="i686-pc-linux-gnu"
HOSTUTILS_PATH="/opt/uclibc-toolchain/ifx-lxdb-1-2/hostutils/bin"
FAKE_ENV="/mnt/the-noob/build/fakeroot.env"
DEV_FILE="/mnt/CD1_BSP/software/ReleasePackage/3.3.0/tools/build_tools/device_table.txt"
#
# Platform Configuration
#
# CONFIG_AMZ is not set
# CONFIG_AMZ_SE is not set
CONFIG_DNB=y
CONFIG_G0432V33_BSP=y
PLATFORM_DIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0/platforms/Danube"
MODEL="G0432V33_BSP"
CONFIG_MIPS=y
CONFIG_UIMAGE_LZMA=y
CONFIG_FS_OTHER=y
PLATFORM_NAME="Danube"
BSP_DIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0/platforms/Danube/source/kernel/ifx"
CONFIG_DIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0//config"
IFXAPI_SRC_DIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0//source/user/ifx/IFXAPIs//src"
IFXAPI_INC_DIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0//source/user/ifx/IFXAPIs//include"
CONFIG_MGMT_DIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0//source/user/ifx//ConfigManagementProcess"
IFX_HTTPD_DIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0//source/user/ifx//ifx_httpd"
IFX_UTIL_DIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0//source/user/ifx//utilities"
IFX_NFEXT_DIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0//source/user/ifx//nfext"
IFX_ROOTFS_DIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0//source/rootfs.bsp/"
ROOTFS_SOURCE_DIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0//source/rootfs.bsp/flashdisk"
IFX_CFLAGS="-Os -mips32 -mtune=4kc -I/mnt/CD1_BSP/software/ReleasePackage/3.3.0//source/user/ifx//IFXAPIs/include"
IFX_LDFLAGS="-L/mnt/the-noob/build/root_filesystem//lib -Wl,-rpath-link,/mnt/the-noob/build/root_filesystem//lib"
VOIP_SRC_DIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0//source/user/ifx/gateway-sip"
TR69_SRC_DIR="/mnt/CD1_BSP/software/ReleasePackage/3.3.0//source/user/ifx/tr69"
CONFIG_ENDIAN="mips"
COMPILER_PREFIX="mips-linux-"
TOOLCHAIN_PATH="/opt/uclibc-toolchain/ifx-lxdb-1-2/gcc-3.3.6/toolchain-mips/bin"
COMPILER_PREFIX="mips-linux-"
LIBPATH="/opt/uclibc-toolchain/ifx-lxdb-1-2/gcc-3.3.6/toolchain-mips/lib"
CCACHE_PATH="/opt/uclibc-toolchain/ifx-lxdb-1-2/gcc-3.3.6/toolchain-mips/bin-ccache"
IFX_CC="mips-linux-gcc"
IFX_AR="mips-linux-ar"
IFX_AS="mips-linux-as"
IFX_LD="mips-linux-ld"
IFX_NM="mips-linux-nm"
IFX_STRIP="mips-linux-strip"
IFX_RANLIB="mips-linux-ranlib"
IFX_CXX="mips-linux-g++"
IFX_CPP="mips-linux-cpp"
IFX_OBJCOPY="mips-linux-objcopy"
IFX_OBJDUMP="mips-linux-objdump"
TARGET="mips-linux"
HOST="mips-linux"
#
# Library Configuration
#
# CONFIG_LIB_FEATURE is not set
RECONFIG=y
# NEW_DEFAULTS is not set
# NEW_MODEL is not set
#### End of Configuration ####
. /mnt/CD1_BSP/software/ReleasePackage/3.3.0/tools/build_tools/.gen_funcs
. /mnt/CD1_BSP/software/ReleasePackage/3.3.0/tools/build_tools/.board_funcs

View file

@ -0,0 +1,848 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
//-----------------------------------------------------------------------
//Description:
// winhost script translation tool under Linux for Danube
//-----------------------------------------------------------------------
//Author: Qi-Ming.Wu@infineon.com
//Created: 29-October-2004
//-----------------------------------------------------------------------
/* History
* Last changed on:
* Last changed by:
*
*/
#define _IFXMIPS_ADSL_APP
//#define DEBUG
#define u32 unsigned int
#define u16 unsigned short
#define u8 unsigned char
#define IFXMIPS_MEI_DEV "/dev/ifxmips/mei"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <getopt.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <asm/ifxmips/ifxmips.h>
#include <asm/ifxmips/ifxmips_mei_app_ioctl.h>
#include <asm/ifxmips/ifxmips_mei_app.h>
#include <asm/ifxmips/ifxmips_mei_ioctl.h>
#include <asm/ifxmips/ifxmips_mei.h>
/*============================definitions======================*/
#define OPTN 5
#define CNFG 8
#define CNTL 1
#define STAT 2
#define RATE 6
#define PLAM 7
#define INFO 3
#define TEST 4
typedef unsigned short UINT16;
typedef unsigned long UINT32;
/*=============================================================*/
/*=============================global variables================*/
int c=0;
int input_flag=0;
int digit_optind=0;
FILE* script_file;
void (*func)()=NULL;
int fd;
UINT16 var16[8];
UINT32 var32[8];
UINT16 Message[16];
/*=============================================================*/
void display_version()
{
printf("translate version1.0\nby Wu Qi Ming\nQi-Ming.Wu@infineon.com\n");
return;
}
void translate_help()
{
printf("Usage:translate [options] [parameter] ...\n");
printf("options:\n");
printf("-h --help Display help information\n");
printf("-v --version Display version information\n");
printf("-f --file Specify the script file\n");
printf("-e --execute Execute the specified script file\n");
//printf("-c --check Check the script file\n");
return;
}
/*
print the content in buf excluding the command "echo" itself.
*/
void echo(char* buf)
{
int i;
char msg[128];
for(i=0;i<128;i++)
{
if((buf[i]!=0)&&(buf[i]!=32))
{
sscanf(buf+i,"%s",&msg);
if(strcmp(msg,"echo")==0)
i+=4;
else break;
}
}
for(i;i<128;i++)
{
if(buf[i]!=0&&(buf[i]!=10))
{
printf("%c",buf[i]);
}
}
printf("\n");
return;
}
static void makeCMV(u8 opcode, u8 group, u16 address, u16 index, int size, u16 * data)
{
memset(Message, 0, 16*2);
Message[0]= (opcode<<4) + (size&0xf);
if(opcode == H2D_DEBUG_WRITE_DM)
Message[1]= (group&0x7f);
else
Message[1]= (((index==0)?0:1)<<7) + (group&0x7f);
Message[2]= address;
Message[3]= index;
if((opcode == H2D_CMV_WRITE)||(opcode == H2D_DEBUG_WRITE_DM))
memcpy(Message+4, data, size*2);
return;
}
UINT16 CMV_read(char* str_group,int address,int index)
{
int group=0;
if(strcmp(str_group,"optn")==0)
group=OPTN;
else if(strcmp(str_group,"cnfg")==0)
group=CNFG;
else if(strcmp(str_group,"cntl")==0)
group=CNTL;
else if(strcmp(str_group,"stat")==0)
group=STAT;
else if(strcmp(str_group,"rate")==0)
group=RATE;
else if(strcmp(str_group,"plam")==0)
group=PLAM;
else if(strcmp(str_group,"info")==0)
group=INFO;
else if(strcmp(str_group,"test")==0)
group=TEST;
else
{
printf("wrong group type!\ncheck script file please!\n");
exit(0);
}
#ifndef DEBUG
makeCMV(H2D_CMV_READ, group, address, index, 1, NULL);
if(ioctl(fd, IFXMIPS_MEI_CMV_WINHOST, &Message)<0){
printf("cr read %d %d %d fail",group,address,index);
exit(0);
}
#endif
return Message[4];
}
int CMV_write(char* str_group,int address,int index,UINT16 value)
{
int group=0;
if(strcmp(str_group,"optn")==0)
group=OPTN;
else if(strcmp(str_group,"cnfg")==0)
group=CNFG;
else if(strcmp(str_group,"cntl")==0)
group=CNTL;
else if(strcmp(str_group,"stat")==0)
group=STAT;
else if(strcmp(str_group,"rate")==0)
group=RATE;
else if(strcmp(str_group,"plam")==0)
group=PLAM;
else if(strcmp(str_group,"info")==0)
group=INFO;
else if(strcmp(str_group,"test")==0)
group=TEST;
else
{
printf("wrong group type!\ncheck script file please!\n");
exit(0);
}
#ifndef DEBUG
makeCMV(H2D_CMV_WRITE, group, address, index, 1, &value);
if(ioctl(fd, IFXMIPS_MEI_CMV_WINHOST, &Message)<0){
printf("cw %d %d %d fail",group,address,index);
return -1;
}
#endif
return 0;
}
void execute_script()
{
char buf[128];
char str_command[20]={0};
char str_group[20]={0};
char str_value[128]={0};
char op1[40],op2[40];
int address,index;
int n=0;
UINT16 value=0;
if(!script_file) return;
while(fgets(buf,128,script_file))/*scan one line into buffer, 128 bytes at most*/
{
if(sscanf(buf,"%s",&str_command)==0) continue;
/*if the line is empty, then go on to the next*/
if(strcmp(str_command,"cr")==0)/*cr command*/
{
sscanf(buf,"%s %s %d %d %s",&str_command,\
&str_group,\
&address,\
&index,\
&str_value);
if(strncmp(str_value,"$",1)!=0)
{
printf("error:cr parameter type mismatch!\n");
break;
}
n=strtoul(str_value+1,NULL,0);
var16[n]=CMV_read(str_group,address,index);
printf("read %s %d %d, value=%04x\n",str_group, address, index,var16[n]);
}
else if(strcmp(str_command,"cw")==0)/*cw command*/
{
sscanf(buf,"%s %s %d %d %s",&str_command,\
&str_group,\
&address,\
&index,\
&str_value);
n=strtoul(str_value+1,NULL,0);
if(strncmp(str_value,"$",1)==0)
{
value=var16[n];
}
else if(strncmp(str_value,"#",1)==0)
{
value=strtoul(str_value+1,NULL,0);
}
else
{
value=strtoul(str_value,NULL,0);
}
if(CMV_write(str_group,address,index,value)<0)
{
break;
}
}
else if(strcmp(str_command,"mw")==0)/*mr command*/
{
sscanf(buf,"%s %s %s",&str_command,\
&op1,\
&str_value);
n=strtoul(str_value+1,NULL,0);
address=strtoul(op1,NULL,0);
if(strncmp(str_value,"$",1)==0)
{
value=var16[n];
}
else if(strncmp(str_value,"#",1)==0)
{
value=strtoul(str_value+1,NULL,0);
}
else
{
value=strtoul(str_value,NULL,0);
}
makeCMV(H2D_DEBUG_WRITE_DM, 0x0, address>>16, (address)&(0xffff), 1, &value);
if(ioctl(fd, IFXMIPS_MEI_CMV_WINHOST, &Message)<0){
printf("mw %08x fail",address);
break;
}
}
else if(strcmp(str_command,"mr")==0)/*mr command*/
{
sscanf(buf,"%s %s %s",&str_command,\
&op1,\
&str_value);
address=strtoul(op1,NULL,0);
n=strtoul(str_value+1,NULL,0);
if(strncmp(str_value,"$",1)!=0)
{
printf("error:mr parameter type mismatch!\n");
break;
}
makeCMV(H2D_DEBUG_READ_DM, 0x0, address>>16, (address)&(0xffff), 1, NULL);
if(ioctl(fd, IFXMIPS_MEI_CMV_WINHOST, &Message)<0){
printf("mw %08x fail",address);
break;
}
value=Message[4];
var16[n]=value;
}
else if(strcmp(str_command,"meiw")==0)/*meiw command*/
{
meireg regrdwr;
sscanf(buf,"%s %s %s",&str_command,\
&op1,\
&op2);
regrdwr.iAddress=strtoul(op1,NULL,0)+IFXMIPS_MEI_BASE_ADDR;
if(strncmp(op2,"#",1)==0) regrdwr.iData=strtoul(op1+1,NULL,0);
else if(strncmp(op2,"$",1)==0) regrdwr.iData=var16[strtoul(op2+1,NULL,0)];
else if(strncmp(op2,"@",1)==0) regrdwr.iData=var32[strtoul(op2+1,NULL,0)];
else regrdwr.iData=strtoul(op1,NULL,0);
//printf("address=%08x\n", regrdwr.iAddress);
if(ioctl(fd, IFXMIPS_MEI_CMV_WRITE, &regrdwr)<0){
printf("meiw fail\n");
break;;
}
}
else if(strcmp(str_command,"meir")==0)/*meir command*/
{
meireg regrdwr;
sscanf(buf,"%s %s %s",&str_command,\
&op1,\
&op2);
regrdwr.iAddress=strtoul(op1,NULL,0)+IFXMIPS_MEI_BASE_ADDR;
if(ioctl(fd, IFXMIPS_MEI_CMV_READ, &regrdwr)<0){
printf("meir fail\n");
break;
}
if(strncmp(op2,"$",1)==0) var16[strtoul(op2+1,NULL,0)]=regrdwr.iData;
else if(strncmp(op2,"@",1)==0) var32[strtoul(op2+1,NULL,0)]=regrdwr.iData;
else
{
printf("meir grammar error!\n");
break;
}
}
else if(strcmp(str_command,"lst")==0)/*lst command*/
{
sscanf(buf,"%s %s",&str_command,\
&str_value);
if(strncmp(str_value,"$",1)==0)
{
n=strtoul(str_value+1,NULL,0);
printf("$%d=0x%04x\n",n,var16[n]);
}
else if(strncmp(str_value,"@",1)==0)
{
n=strtoul(str_value+1,NULL,0);
printf("$%d=0x%08x\n",n,var32[n]);
}
else
{
printf("lst grammar error!\n");
break;
}
}
else if(strcmp(str_command,"echo")==0)/*echo command*/
{
echo(buf);
}
else if(strcmp(str_command,"mov")==0)/*mov command*/
{
sscanf(buf,"%s %s %s",&str_command,\
&op1,\
&op2);
if(strncmp(op1,"$",1)==0)
{
if(strncmp(op2,"$",1)==0)
{
var16[strtoul(op1+1,NULL,0)]=var16[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"@",1)==0)
{
var16[strtoul(op1+1,NULL,0)]= var32[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"#",1)==0)
{
var16[strtoul(op1+1,NULL,0)]=strtoul(op2+1,NULL,0);
}
else
{
var16[strtoul(op1+1,NULL,0)]=strtoul(op2,NULL,0);
}
}
else if(strncmp(op1,"@",1)==0)
{
if(strncmp(op2,"$",1)==0)
{
var32[strtoul(op1+1,NULL,0)]=var16[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"@",1)==0)
{
var32[strtoul(op1+1,NULL,0)]= var32[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"#",1)==0)
{
var32[strtoul(op1+1,NULL,0)]=strtoul(op2+1,NULL,0);
}
}
else
{
printf("grammar error!\n");
break;
}
}
else if(strcmp(str_command,"or")==0)/*or command*/
{
sscanf(buf,"%s %s %s",&str_command,\
&op1,\
&op2);
if(strncmp(op1,"$",1)==0)
{
if(strncmp(op2,"$",1)==0)
{
var16[strtoul(op1+1,NULL,0)]|=var16[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"@",1)==0)
{
var16[strtoul(op1+1,NULL,0)]|= var32[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"#",1)==0)
{
var16[strtoul(op1+1,NULL,0)]|=strtoul(op2+1,NULL,0);
}
}
else if(strncmp(op1,"@",1)==0)
{
if(strncmp(op2,"$",1)==0)
{
var32[strtoul(op1+1,NULL,0)]|=var16[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"@",1)==0)
{
var32[strtoul(op1+1,NULL,0)]|= var32[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"#",1)==0)
{
var32[strtoul(op1+1,NULL,0)]|=strtoul(op2+1,NULL,0);
}
}
else
{
printf("grammar error!\n");
break;
}
}
else if(strcmp(str_command,"and")==0)/*and command*/
{
sscanf(buf,"%s %s %s",&str_command,\
&op1,\
&op2);
if(strncmp(op1,"$",1)==0)
{
if(strncmp(op2,"$",1)==0)
{
var16[strtoul(op1+1,NULL,0)]&=var16[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"@",1)==0)
{
var16[strtoul(op1+1,NULL,0)]&= var32[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"#",1)==0)
{
var16[strtoul(op1+1,NULL,0)]&=strtoul(op2+1,NULL,0);
}
}
else if(strncmp(op1,"@",1)==0)
{
if(strncmp(op2,"$",1)==0)
{
var32[strtoul(op1+1,NULL,0)]&=var16[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"@",1)==0)
{
var32[strtoul(op1+1,NULL,0)]&= var32[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"#",1)==0)
{
var32[strtoul(op1+1,NULL,0)]&=strtoul(op2+1,NULL,0);
}
}
else
{
printf("grammar error!\n");
break;
}
}
else if(strcmp(str_command,"not")==0)/*not command*/
{
sscanf(buf,"%s %s",&str_command,\
&op1);
if(strncmp(op1,"$",1)==0)
{
var16[strtoul(op1+1,NULL,0)]=~var16[strtoul(op1+1,NULL,0)];
}
else if(strncmp(op1,"@",1)==0)
{
var32[strtoul(op1+1,NULL,0)]=~var32[strtoul(op1+1,NULL,0)];
}
else
{
printf("grammar error!\n");
break;
}
}
else if(strcmp(str_command,"shl")==0)/*shl command*/
{
sscanf(buf,"%s %s %s",&str_command,\
&op1,\
&op2);
if(strncmp(op1,"$",1)==0)
{
if(strncmp(op2,"$",1)==0)
{
var16[strtoul(op1+1,NULL,0)]<<=var16[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"@",1)==0)
{
var16[strtoul(op1+1,NULL,0)]<<= var32[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"#",1)==0)
{
var16[strtoul(op1+1,NULL,0)]<<=strtoul(op2+1,NULL,0);
}
}
else if(strncmp(op1,"@",1)==0)
{
if(strncmp(op2,"$",1)==0)
{
var32[strtoul(op1+1,NULL,0)]<<=var16[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"@",1)==0)
{
var32[strtoul(op1+1,NULL,0)]<<= var32[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"#",1)==0)
{
var32[strtoul(op1+1,NULL,0)]<<=strtoul(op2+1,NULL,0);
}
}
else
{
printf("grammar error!\n");
break;
}
}
else if(strcmp(str_command,"shr")==0)/*shr command*/
{
sscanf(buf,"%s %s %s",&str_command,\
&op1,\
&op2);
if(strncmp(op1,"$",1)==0)
{
if(strncmp(op2,"$",1)==0)
{
var16[strtoul(op1+1,NULL,0)]>>=var16[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"@",1)==0)
{
var16[strtoul(op1+1,NULL,0)]>>= var32[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"#",1)==0)
{
var16[strtoul(op1+1,NULL,0)]>>=strtoul(op2+1,NULL,0);
}
}
else if(strncmp(op1,"@",1)==0)
{
if(strncmp(op2,"$",1)==0)
{
var32[strtoul(op1+1,NULL,0)]>>=var16[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"@",1)==0)
{
var32[strtoul(op1+1,NULL,0)]>>= var32[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"#",1)==0)
{
var32[strtoul(op1+1,NULL,0)]>>=strtoul(op2+1,NULL,0);
}
}
else
{
printf("grammar error!\n");
break;
}
}
else if(strcmp(str_command,"add")==0)/*add command*/
{
sscanf(buf,"%s %s %s",&str_command,\
&op1,\
&op2);
if(strncmp(op1,"$",1)==0)
{
if(strncmp(op2,"$",1)==0)
{
var16[strtoul(op1+1,NULL,0)]+=var16[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"@",1)==0)
{
var16[strtoul(op1+1,NULL,0)]+= var32[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"#",1)==0)
{
var16[strtoul(op1+1,NULL,0)]+=strtoul(op2+1,NULL,0);
}
}
else if(strncmp(op1,"@",1)==0)
{
if(strncmp(op2,"$",1)==0)
{
var32[strtoul(op1+1,NULL,0)]+=var16[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"@",1)==0)
{
var32[strtoul(op1+1,NULL,0)]+= var32[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"#",1)==0)
{
var32[strtoul(op1+1,NULL,0)]+=strtoul(op2+1,NULL,0);
}
}
else
{
printf("grammar error!\n");
break;
}
}
else if(strcmp(str_command,"sub")==0)/*sub command*/
{
sscanf(buf,"%s %s %s",&str_command,\
&op1,\
&op2);
if(strncmp(op1,"$",1)==0)
{
if(strncmp(op2,"$",1)==0)
{
var16[strtoul(op1+1,NULL,0)]-=var16[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"@",1)==0)
{
var16[strtoul(op1+1,NULL,0)]-= var32[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"#",1)==0)
{
var16[strtoul(op1+1,NULL,0)]-=strtoul(op2+1,NULL,0);
}
}
else if(strncmp(op1,"@",1)==0)
{
if(strncmp(op2,"$",1)==0)
{
var32[strtoul(op1+1,NULL,0)]-=var16[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"@",1)==0)
{
var32[strtoul(op1+1,NULL,0)]-= var32[strtoul(op2+1,NULL,0)];
}
else if(strncmp(op2,"#",1)==0)
{
var32[strtoul(op1+1,NULL,0)]-=strtoul(op2+1,NULL,0);
}
}
else
{
printf("grammar error!\n");
break;
}
}
memset(str_command,0,20);
memset(buf,0,128);
}
return;
}
int main (int argc, char** argv) {
#ifndef DEBUG
fd=open(IFXMIPS_MEI_DEV, O_RDWR);
if(fd<0){
printf("\n\n autoboot open device fail\n");
return -1;
}
#endif
while(1) {
int option_index=0;
static struct option long_options[] ={
{"help",0,0,0},
{"version",0,0,0},
{"file",1,0,0},
{"execute",0,0,0}
};
c = getopt_long(argc,argv, "hvf:e",
long_options, &option_index);
//printf("c=%d option_index=%d\n",c,option_index);
if(c==-1)
{
if(input_flag==0)
{
printf("translate:please specify parameters\n");
func=&translate_help;
}
if(func)
(*func)();
else
{
ERROR: translate_help();
}
break;
}
input_flag=1;
switch (c) {
case 0:
if(option_index==0)
{
func=&translate_help;
break;
}
if(option_index==1)
{
func=&display_version;
break;
}
if(option_index==2)
{
goto FILE;
break;
}
if(option_index==3)
{
goto EXECUTE;
break;
}
case 'h':
func=&translate_help;
break;
case 'v':
func=&display_version;
break;
case 'f':
FILE: if(!optarg) goto ERROR;
script_file=fopen((char*)optarg,"r");
if(!script_file) perror("fopen");
break;
case 'e':
EXECUTE: func=&execute_script;
break;
}
}
if(script_file) fclose(script_file);
#ifndef DEBUG
close(fd);
#endif
}