static inline
int xn_net_probe(struct xn_tool *tool)
{
unsigned char s_buf[]= {0xff,0xff,0xff,0xff,0xff,0xff,0x8,0x0, \
0x3e,0x26,0xa,0xd8,0x8,0x6,0x0,0x1, \
0x8,0x0,0x6,0x4,0x0,0x1,0x8,0x0, \
0x3e,0x26,0xa,0xd8,0xc0,0xa8,0x3,0xac, \
0x0,0x0,0x0,0x0,0x0,0x0,0xc0,0xa8, \
0x3,0x93};
char r_buf[1024] = {0};
unsigned long timeo = CFG_HZ * 2;
int per_len = 0,recv_len = 0;
printf("\nNet Probe:\n");
bd_t *bd = gd->bd;
if(!eth_linkok()) {
printf("cs8900 eth_linkok error\n");
goto error;
}
eth_halt();
eth_init(bd);
eth_test_mode_reginit();
eth_send(s_buf,sizeof(s_buf));
reset_timer();
while(recv_len < sizeof(s_buf)) {
per_len = eth_recv(r_buf + recv_len,sizeof(s_buf) - recv_len);
recv_len += per_len;
if (get_timer(0) > timeo) {
printf("cs8900 read timeout\n");
break;
}
}
if(recv_len != sizeof(s_buf) || memcmp(s_buf,r_buf,sizeof(s_buf))) {
printf("recv data error\n");
goto error;
}
printf("CS8900...............................................[OK]\n");
wait_user_ack(tool);
return 0;
error:
printf("CS8900...............................................[ERROR]\n");
wait_user_ack(tool);
return 0;
}
阅读(2751) | 评论(0) | 转发(1) |