你知道Uboot中的net是怎样的?

 //net读

//a     pi   /api.c

sta     ti   c cfp_t calls_table[API_MAXCALL] = { NULL, };

void api_init(void)

{

...

calls_table[API_     RS   VD] = NULL;
calls_table[API_GETC] = &API_getc;
calls_table[API_PUTC] = &API_putc;
calls_table[API_TSTC] = &API_tstc;
calls_table[API_PUTS] = &API_puts;
calls_table[API_RESET] = &API_reset;
calls_table[API_GET_SYS_INFO] = &API_get_sys_info;
calls_table[API_UDELAY] = &API_udelay;
calls_table[API_GET_  TI MER] = &API_get_  TI mer;
calls_table[API_DEV_ENUM] = &API_dev_enum;
calls_table[API_DEV_OPEN] = &API_dev_open;
calls_table[API_DEV_CLOSE] = &API_dev_close;
calls_table[API_DEV_READ] = &API_dev_read;
calls_table[API_DEV_WRI     TE   ] = &API_dev_write;
calls_table[API_ENV_GET] = &API_env_get;
calls_table[API_ENV_SET] = &API_env_set;
calls_table[API_ENV_ENUM] = &API_env_enum;
calls_no = API_MAXCALL;

...

}

sta  TI c int API_dev_read(va_list ap)

{

...

else if (di->type & DEV_TYP_NET)

{

len_net = (int *)va_arg(ap, u_int32_t);
if (!len_net)
return API_EINVAL;
if (*len_net <= 0)
return API_EINVAL;

act_len_net = (int *)va_arg(ap, u_int32_t);
if (!act_len_net)
return API_EINVAL;

*act_len_net = dev_read_net(di->cookie, buf, *len_net);

}

...

}

//api/api_net.c

int dev_read_net(void *cookie, void *buf, int len)
{

return eth_receive(buf, len);

}

//net/eth.c

int eth_receive(vola  TI le void *packet, int length)
{

if (eth_rcv_current == eth_rcv_last)
{

...
push_packet = eth_save_packet;
eth_rx();
push_packet = pp;

if (eth_rcv_current == eth_rcv_last)
return -1;

...

}

//drivers\net\higmacv300\Higmac.c

int eth_rx(void)

{

...

NetReceive(NetRxPackets[0], len);

...

}

//net/net.c

void NetReceive(volatile uchar * inpkt, int len)

{

...

x = ntohs(vet->vet_type);

...

switch (x)

{

case PROT_ARP:

...

switch (ntohs(arp->ar_op))

{

...

case ARPOP_REQUEST:

...

case ARPOP_REPLY:

...

tmp = NetRe     adI   P(&arp->ar_data[6]);

if (tmp == NetArpW     ai   tReplyIP)

{

...

(*packetHandler)(0,0,0,0);

...

}

case PROT_RARP:

...

case PROT_IP:

...

if (ip->ip_p == IPPROTO_ICMP)

{

...

switch (icmph->type)

{

case ICMP_REDIRECT:

...

case ICMP_ECHO_REPLY:

...

case ICMP_ECHO_REQUEST:

...

}

}

}

}

}

static rxhand_f *packetHandler; /* Current RX packet handler */

void NetSetHandler(rxhand_f * f)

{
packetHandler = f;
}

//net/net.h

typedef void rxhand_f(uchar *, unsigned, unsigned, unsigned);

举例tftp通讯

//net/tftp.c

void TftpStart (void)

{

...

NetSetHandler (TftpHandler);

...

}

static void TftpHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len)

{

...

s = (ushort *)pkt;

proto = *s++;

...

switch (ntohs(proto))

{

case TFTP_RRQ:

case TFTP_WRQ:
break;
case TFTP_ACK:

}

}

好记性不如烂笔头



你知道Uboot中的net是怎样的?_设计制作_可编程逻辑
67
95
0
41

相关资讯

  1. 1、曦力音视频转换专家怎么剪辑视频?曦力音视频转换专家剪辑视频的方法2190
  2. 2、Win1021H1更新后出现无限蓝屏怎么解决?381
  3. 3、百度网盘下载失败错误代码1252001解决方法3919
  4. 4、Win7电脑注册表编辑器被管理员禁用怎么解决?142
  5. 5、Win10系统开机慢怎么解决?如何提高开机速度?4747
  6. 6、Win7旗舰版怎么调整硬盘分区3351
  7. 7、2021年2月最新显卡天梯图2021最新显卡排名天梯图高清完整版2254
  8. 8、GTA5离线模式无法建立连接怎么回事?GTA显示离线模式无法建立连接?2102
  9. 9、怎么远程控制小孩子玩手机时间?推荐使用向日葵远程控制小孩子的手机680
  10. 10、携程旅行怎么更改绑定手机号码?携程旅行更改绑定手机号码的方法1304
全部评论(0)
我也有话说
0
收藏
点赞
顶部