diff options
author | John Crispin <john@openwrt.org> | 2007-12-24 23:06:11 +0000 |
---|---|---|
committer | John Crispin <john@openwrt.org> | 2007-12-24 23:06:11 +0000 |
commit | 34cf8e94c2dc66a7ba2bc4c0e74c096965c450dd (patch) | |
tree | 07b2ad9a4dab0f434103b8aa004c790351070a10 /package/ifxmips_adsl/src/danube_mei_debug.c | |
parent | d0074af438883b0fae050ad6a6c76effeb3e4715 (diff) | |
download | mtk-20170518-34cf8e94c2dc66a7ba2bc4c0e74c096965c450dd.zip mtk-20170518-34cf8e94c2dc66a7ba2bc4c0e74c096965c450dd.tar.gz mtk-20170518-34cf8e94c2dc66a7ba2bc4c0e74c096965c450dd.tar.bz2 |
add ifx adsl tools
SVN-Revision: 9900
Diffstat (limited to 'package/ifxmips_adsl/src/danube_mei_debug.c')
-rw-r--r-- | package/ifxmips_adsl/src/danube_mei_debug.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/package/ifxmips_adsl/src/danube_mei_debug.c b/package/ifxmips_adsl/src/danube_mei_debug.c new file mode 100644 index 0000000..e3247f6 --- /dev/null +++ b/package/ifxmips_adsl/src/danube_mei_debug.c @@ -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); +} |