add ifx adsl tools
[openwrt.git] / package / ifxmips_adsl / src / danube_mei_debug.c
1 #define _IFXMIPS_ADSL_APP
2 #define u32 unsigned int
3 #define IFXMIPS_MEI_DEV "/dev/ifxmips/mei"
4
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <unistd.h>
8 #include <fcntl.h>
9 #include <errno.h>
10 #include <string.h>
11 #include <sys/types.h>
12 #include <sys/ioctl.h>
13 #include <sys/stat.h>
14 #include <sys/time.h>
15 #include <asm/ifxmips/ifxmips_mei_app.h>
16 #include <asm/ifxmips/ifxmips_mei_ioctl.h>
17 #include <asm/ifxmips/ifxmips_mei_app_ioctl.h>
18
19 #define SEGMENT_SIZE (64*1024)
20 #if 0
21 #define u8 unsigned char
22 #define u16 unsigned short
23 #endif
24
25 int main(int argc, char **argv)
26 {
27 int fd_image, fd_mei;
28 char *buf;
29 struct stat state;
30 int i,j;
31 char * filename;
32 int size,read_size=SEGMENT_SIZE;
33 u16 temp=0;
34 u16 Message[16]__attribute__ ((aligned(4)));
35 meidebug dbg_data;
36 int rw_flag =0;
37
38 if(argc<4){
39 printf("\nWrong Arguments! Usage: %s r/w address size/value\n",argv[0]);
40 return -1;
41 }
42
43 fd_mei=open(IFXMIPS_MEI_DEV, O_RDWR);
44 if(fd_mei<0)
45 printf("\n open device fail");
46
47 dbg_data.iAddress = strtoul(argv[2],NULL,0);
48 printf("Address = %08X\n",dbg_data.iAddress);
49 if(argv[1][0]=='w')
50 {
51 dbg_data.buffer[0]=strtoul(argv[3],NULL,0);
52
53 dbg_data.iCount = 1;
54 rw_flag = 1;
55 }else
56 {
57 dbg_data.iCount =strtoul(argv[3],NULL,0);
58 }
59 if (rw_flag==1)
60 {
61 if(ioctl(fd_mei, IFXMIPS_MEI_WRITEDEBUG,&dbg_data)!=MEI_SUCCESS){
62 printf("\n IFXMIPS_MEI_WRITEDEBUG() failed");
63 close(fd_mei);
64 return -1;
65 }
66 printf("Writing %08X with data %X!\n",dbg_data.iAddress,dbg_data.buffer[0]);
67 }else
68 {
69 if(ioctl(fd_mei, IFXMIPS_MEI_READDEBUG,&dbg_data)!=MEI_SUCCESS){
70 printf("\n IFXMIPS_MEI_READDEBUG() failed");
71 close(fd_mei);
72 return -1;
73 }
74 printf("Read %08X .\nResult:",dbg_data.iAddress);
75 for (i=0;i<dbg_data.iCount;i++)
76 {
77 printf("%08X ",dbg_data.buffer[i]);
78 if(i%4==3)
79 printf("\n");
80 }
81 printf("\n");
82 }
83 close(fd_mei);
84 }
This page took 0.055942 seconds and 5 git commands to generate.