ARM-Linux驱动--DM9000网卡驱动分析(一)

<style type="text/css"> <!-- @page { margin: 0.79in } P { margin-bottom: 0.08in } PRE.cjk { font-family: "AR PL UMing HK", monospace } A:link { so-language: zxx } --> </style>

硬件平台:FL2440s3c2440

内核版本:2.6.35

主机平台:Ubuntu11.04

内核版本:2.6.39

原创作品,转载请标明出处http://blog.csdn.net/yming0221/article/details/6609742

1、下图是DM9000的引脚图

ARM-Linux驱动--DM9000网卡驱动分析(一)_第1张图片

2、这里我们结合具体的开发板FL2440

下面是FL2440DM9000的引脚链接图

ARM-Linux驱动--DM9000网卡驱动分析(一)_第2张图片

本人移植DM9000的时候将设备的资源定义放在了arch/arm/plat-s3c24xx/devs.c中,详情点击上一篇博文linux内核移植-移植2.6.35.4内核到s3c2440

下面是设备的资源定义

这里可以看到,DM9000网卡使用的地址空间资源在nGCS4地址区域,所以上图的DM9000地址使能引脚连接nGCS4引脚。中断使用的是EINT7外部中断。

接着定义平台数据和平台设备,代码如下:

最后导出函数符号,保存函数地址和名称

3、设备启动的初始化过程

而后会执行下面函数

下面是具体的设备列表

这样系统启动时,会给设备列表中的设备分配资源(地址资源和中断资源等)。

4、信息传输中的信息封装结构

4.1、sk_buff结构,定义在include/linux/skbuff.h

元素的含义如下(摘自内核,源码,版本2.6.35.4
*struct sk_buff - socket buffer
* @next: Next buffer inlist
* @prev: Previous buffer in list
* @sk: Socketwe are owned by
* @tstamp: Time we arrived
* @dev:Device we arrived on/are leaving by
* @transport_header:Transport layer header
* @network_header: Network layerheader
* @mac_header: Link layer header
*@_skb_refdst: destination entry (with norefcount bit)
* @sp:the security path, used for xfrm
* @cb: Control buffer. Freefor use by every layer. Put private vars here
* @len: Lengthof actual data
* @data_len: Data length
* @mac_len:Length of link layer header
* @hdr_len: writable headerlength of cloned skb
* @csum: Checksum (must includestart/offset pair)
* @csum_start: Offset from skb->headwhere checksumming should start
* @csum_offset: Offset fromcsum_start where checksum should be stored
* @local_df:allow local fragmentation
* @cloned: Head may be cloned(check refcnt to be sure)
* @nohdr: Payload reference only,must not modify header
* @pkt_type: Packet class
*@fclone: skbuff clone status
* @ip_summed: Driver fed us anIP checksum
* @priority: Packet queueing priority
*@users: User count - see {datagram,tcp}.c
* @protocol:Packet protocol from driver
* @truesize: Buffer size
*@head: Head of buffer
* @data: Data head pointer
*@tail: Tail pointer
* @end: End pointer
*@destructor: Destruct function
* @mark: Generic packetmark
* @nfct: Associated connection, if any
*@ipvs_property: skbuff is owned by ipvs
* @peeked: thispacket has been seen already, so stats have been
* done forit, don't do them again
* @nf_trace: netfilter packet traceflag
* @nfctinfo: Relationship of this skb to theconnection
* @nfct_reasm: netfilter conntrack re-assemblypointer
* @nf_bridge: Saved data about a bridged frame - seebr_netfilter.c
* @skb_iif: ifindex of device we arrivedon
* @rxhash: the packet hash computed on receive
*@queue_mapping: Queue mapping for multiqueue devices
*@tc_index: Traffic control index
* @tc_verd: traffic controlverdict
* @ndisc_nodetype: router type (from link layer)
*@dma_cookie: a cookie to one of several possible DMA operations
*done by skb DMA functions
* @secmark: security marking
*@vlan_tci: vlan tag control information

关于sk_buff的更多分析见另一篇转载的博文http://blog.csdn.net/yming0221/article/details/6609734

4.2、net_device

关于net_device一个非常庞大的结构体,定义在/inlcude/linux/netdevice.h中

如下:

我还没有细细的分析这个结构体,驱动程序在probe函数中使用register_netdev()注册该结构体指明的设备,将内核操作硬件的函数个内核联系起来。

更多见下一节分析ARM-Linux驱动--DM9000网卡驱动分析(二)


你可能感兴趣的:(linux)