94abc32ae06be5acc6f7b8f62844c5f67659ba00
[openwrt.git] / package / ifxmips_adsl / src / danube_show_firmware_date.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 <time.h>
12 #include <sys/types.h>
13 #include <sys/ioctl.h>
14 #include <sys/stat.h>
15 #include <sys/time.h>
16 #include <asm/ifxmips/ifxmips_mei_app_ioctl.h>
17 #include <asm/ifxmips/ifxmips_mei_app.h>
18 #include <asm/ifxmips/ifxmips_mei_ioctl.h>
19
20 u16 Message[16]__attribute__ ((aligned(4)));
21
22 void makeCMV(u8 opcode, u8 group, u16 address, u16 index, int size, u16 * data);
23 void makeCMV(u8 opcode, u8 group, u16 address, u16 index, int size, u16 * data)
24 {
25 memset(Message, 0, 16*2);
26 Message[0]= (opcode<<4) + (size&0xf);
27 if(opcode == H2D_DEBUG_WRITE_DM)
28 Message[1]= (group&0x7f);
29 else
30 Message[1]= (((index==0)?0:1)<<7) + (group&0x7f);
31 Message[2]= address;
32 Message[3]= index;
33 if((opcode == H2D_CMV_WRITE)||(opcode == H2D_DEBUG_WRITE_DM))
34 memcpy(Message+4, data, size*2);
35 return;
36 }
37
38
39 int main(int argc, char **argv)
40 {
41 int fd;
42 u16 temp=0;
43 u16 rt_buildcode_lsw=0, rt_buildcode_msw=0;
44 u32 rt_buildcode = 0;
45
46 fd=open(IFXMIPS_MEI_DEV, O_RDWR);
47 if(fd<0){
48 printf("\n\n autoboot open device fail");
49 return -1;
50 }
51
52
53 makeCMV(H2D_CMV_READ, INFO, 55, 0, 1, &temp);
54 if(ioctl(fd, IFXMIPS_MEI_CMV_WINHOST, &Message)<0){
55 printf("\n\n read INFO 55 0 fail");
56 return -1;
57 }
58 rt_buildcode_lsw = Message[4];
59
60 makeCMV(H2D_CMV_READ, INFO, 55, 1, 1, &temp);
61 if(ioctl(fd, IFXMIPS_MEI_CMV_WINHOST, &Message)<0){
62 printf("\n\n read INFO 55 1 fail");
63 return -1;
64 }
65 rt_buildcode_msw = Message[4];
66
67 rt_buildcode = rt_buildcode_lsw + (rt_buildcode_msw << 16);
68 printf("date: %d, month: %d, hour: %d, minute: %d\n",
69 (rt_buildcode >> 0) & 0xFF,
70 (rt_buildcode >> 8) & 0xFF,
71 (rt_buildcode >> 16) & 0xFF,
72 (rt_buildcode >> 25) & 0xFF
73 );
74 return 0;
75 }
This page took 0.040084 seconds and 3 git commands to generate.