欢迎来到天天文库
浏览记录
ID:14804211
大小:39.00 KB
页数:6页
时间:2018-07-30
《nios ii网络驱动程序分析》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、NIOSII网络驱动程序分析 网络是嵌入式应用的常备功能,在NIOSII中集成了UCOSII和LWIP,分析网络设备在NIOSII中的来龙去脉对学习NIOSII设备驱动程序有典型的意义。设备的定义和系统设备联表管理。1. 驱动程序提供的freedev_rtl8019.h中定义一个freedev_rtl8019_if结构的全局变量dev#defineFREEDEV_RTL8019_INSTANCE(name,dev)freedev_rtl8019_ifdev={ { ALT_LLIST_ENTRY, { 0, name##_NAME,
2、 freedev_rtl8019_init, freedev_rtl8019_rx, }, }, name##_BASE, name##_IRQ, 8, 0, 0}结构freedev_rtl8019_if定义如下:typedefstruct{ alt_lwip_dev_list lwip_dev_list; int base_addr; int irq; int bus_width; sys_sem_t semaphore;
3、 sys_sem_t arp_semaphore; alt_u8 tx_packet_no;/*NumberofpacketallocatedforTx*/}freedev_rtl8019_if;相关结构定义如下:typedefstruct{ alt_llist llist; /*forinternaluse*/ alt_lwip_dev dev;}alt_lwip_dev_list;structalt_lwip_dev{ /*ThenetifpointerMUSTbethefirstelementinthestruct
4、ure*/ structnetif ` *netif; constchar* name; err_t(*init_routine)(structnetif*); void(*rx_routine)();};structnetif{ /**pointertonextinlinkedlist*/ structnetif*next; /**IPaddressconfigurationinnetworkbyteorder*/ structip_addrip_addr; structip_addrnetmask; structip_addrgw; /*
5、*Thisfunctioniscalledbythenetworkdevicedriver * topassapacketuptheTCP/IPstack.*/ err_t(*input)(structpbuf*p,structnetif*inp); /**ThisfunctioniscalledbytheIPmodulewhenitwants * tosendapacketontheinterface.Thisfunctiontypically * firstresolvesthehardwareaddress,thensendsthepacket.*/ err_t
6、(*output)(structnetif*netif,structpbuf*p,structip_addr*ipaddr); /**ThisfunctioniscalledbytheARPmodulewhenitwants * tosendapacketontheinterface.Thisfunctionoutputs * thepbufas-isonthelinkmedium.*/ err_t(*linkoutput)(structnetif*netif,structpbuf*p); /**Thisfieldcanbesetbythedevicedriverand
7、couldpoint * tostateinformationforthedevice.*/ void*state;#ifLWIP_DHCP /**theDHCPclientstateinformationforthisnetif*/ structdhcp*dhcp;#endif /**numberofbytesusedinhwaddr*/ unsignedcharhwaddr_len; /**linklevelhardwareaddressofthisinterface*/ unsignedcharhwaddr
此文档下载收益归作者所有