📄 linux下dm9000网卡驱动实验〈三〉 - orange - csdnblog.htm
字号:
<TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
<TD
style="PADDING-RIGHT: 5.4pt; PADDING-LEFT: 5.4pt; BORDER-LEFT-COLOR: #ece9d8; BORDER-BOTTOM-COLOR: #ece9d8; PADDING-BOTTOM: 0cm; WIDTH: 426.1pt; BORDER-TOP-COLOR: #ece9d8; PADDING-TOP: 0cm; BACKGROUND-COLOR: transparent; BORDER-RIGHT-COLOR: #ece9d8"
vAlign=top width=568>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman">void<SPAN
style="mso-spacerun: yes">
</SPAN><SPAN
style="mso-spacerun: yes"> </SPAN>outb(unsigned
char value, unsigned long addr) </FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman">void <SPAN
style="mso-spacerun: yes"> </SPAN><SPAN
style="mso-spacerun: yes"> </SPAN><SPAN
style="mso-spacerun: yes"> </SPAN>outw(unsigned short value, unsigned
long addr) </FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman">unsigned char<SPAN
style="mso-spacerun: yes"> </SPAN><SPAN
style="mso-spacerun: yes"> </SPAN>inb(unsigned long addr)
</FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman">unsigned short <SPAN
style="mso-spacerun: yes"> </SPAN>inw(unsigned long addr)
</FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"></SPAN>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman">u8 ior(board_info_t
*db, int reg)<SPAN style="mso-spacerun: yes"> </SPAN>// Read a
byte from I/O port </FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman">void iow(board_info_t
*db, int reg, u8 value) //<SPAN style="mso-spacerun: yes">
</SPAN>Write a byte to I/O port </FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US></SPAN>
<P> </P>
<P></P>
<P><FONT face="Times New Roman"></FONT> </P>
<P></P>
<P><FONT face="Times New Roman"></FONT> </P></TD></TR></TBODY></TABLE>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN
lang=EN-US></SPAN>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: " new=""
times="">驱动程序的函数接口,</SPAN><FONT face="Times New Roman"> </FONT></FONT></P>
<TABLE class=MsoNormalTable
style="BACKGROUND: #e6e6e6; BORDER-COLLAPSE: collapse; mso-yfti-tbllook: 480; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt"
cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
<TD
style="PADDING-RIGHT: 5.4pt; PADDING-LEFT: 5.4pt; BORDER-LEFT-COLOR: #ece9d8; BORDER-BOTTOM-COLOR: #ece9d8; PADDING-BOTTOM: 0cm; WIDTH: 426.1pt; BORDER-TOP-COLOR: #ece9d8; PADDING-TOP: 0cm; BACKGROUND-COLOR: transparent; BORDER-RIGHT-COLOR: #ece9d8"
vAlign=top width=568>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman">int init_module(void)
</FONT></SPAN><SPAN
style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-ascii-font-family: " new=""
times="">;</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt"><FONT
face="Times New Roman"> //</FONT></SPAN><SPAN
style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-ascii-font-family: " new=""
times="">加载设备驱动程序</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt">
</SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman">void
cleanup_module(void) //</FONT></SPAN><SPAN
style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-ascii-font-family: " new=""
times="">卸载设备驱动程序</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt">
</SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"></SPAN>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman">static void
dmfe_init_dm9000(struct DEVICE *dev) /* Initilize DM910X board */
</FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman">dmfe_probe(struct
DEVICE *dev)</FONT></SPAN><SPAN
style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-ascii-font-family: " new=""
times="">;</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt"><FONT
face="Times New Roman"> //</FONT></SPAN><SPAN
style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-ascii-font-family: " new=""
times="">初始化</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt"><FONT
face="Times New Roman">net_device </FONT></SPAN><SPAN
style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-ascii-font-family: " new=""
times="">结构体</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt"> </SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman">static int
dmfe_open(struct DEVICE *dev) </FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman">static int
dmfe_stop(struct DEVICE *dev) </FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman">static int
dmfe_start_xmit(struct sk_buff *skb, struct DEVICE *dev)
//</FONT></SPAN><SPAN
style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-ascii-font-family: " new=""
times="">发送一个数据包</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt">
</SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman">static void
dmfe_packet_receive(struct DEVICE *dev, board_info_t *db)
//</FONT></SPAN><SPAN
style="FONT-SIZE: 9pt; FONT-FAMILY: 宋体; mso-ascii-font-family: " new=""
times="">接收数据包,被中断调用</SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt">
</SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US></SPAN>
<P> </P>
<P></P>
<P><FONT face="Times New Roman"></FONT> </P>
<P></P>
<P><FONT face="Times New Roman"></FONT> </P></TD></TR></TBODY></TABLE>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US></SPAN>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: " new="" times="">其中</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">int init_module(void)</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: " new=""
times="">函数调用了</SPAN><SPAN lang=EN-US><FONT
face="Times New Roman">dmfe_probe(struct DEVICE *dev)</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: " new=""
times="">来初始化</SPAN><SPAN lang=EN-US><FONT
face="Times New Roman">net_device</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: " new=""
times="">结构体</SPAN></FONT></P>
<TABLE class=MsoTableGrid
style="BACKGROUND: #e6e6e6; BORDER-COLLAPSE: collapse; mso-yfti-tbllook: 480; mso-padding-alt: 0cm 5.4pt 0cm 5.4pt"
cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes">
<TD
style="PADDING-RIGHT: 5.4pt; PADDING-LEFT: 5.4pt; BORDER-LEFT-COLOR: #ece9d8; BORDER-BOTTOM-COLOR: #ece9d8; PADDING-BOTTOM: 0cm; WIDTH: 426.1pt; BORDER-TOP-COLOR: #ece9d8; PADDING-TOP: 0cm; BACKGROUND-COLOR: transparent; BORDER-RIGHT-COLOR: #ece9d8"
vAlign=top width=568>
<P class=MsoNormal
style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 18pt; mso-char-indent-count: 2.0"><SPAN
lang=EN-US style="FONT-SIZE: 9pt"><FONT
face="Times New Roman">if(strcmp(dev->name,"eth0")==0)
</FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman"><SPAN
style="mso-tab-count: 1">
</SPAN>if(strcmp(dev->name,"eth1")==0) </FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman"><SPAN
style="mso-tab-count: 1">
</SPAN>if(strcmp(dev->name,"eth3")==0) </FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman"><SPAN
style="mso-tab-count: 2">
</SPAN></FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman"><SPAN
style="mso-tab-count: 1">
</SPAN>outb(DM9000_VID_L, iobase); </FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman"><SPAN
style="mso-tab-count: 1">
</SPAN>id_val = inb(iobase + 4); </FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman"><SPAN
style="mso-tab-count: 1">
</SPAN>outb(DM9000_VID_H, iobase); </FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman"><SPAN
style="mso-tab-count: 1">
</SPAN>id_val |= inb(iobase + 4) << 8; </FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman"><SPAN
style="mso-tab-count: 1">
</SPAN>outb(DM9000_PID_L, iobase); </FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman"><SPAN
style="mso-tab-count: 1">
</SPAN>id_val |= inb(iobase + 4) << 16; </FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman"><SPAN
style="mso-tab-count: 1">
</SPAN>outb(DM9000_PID_H, iobase); </FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman"><SPAN
style="mso-tab-count: 1">
</SPAN>id_val |= inb(iobase + 4) << 24; </FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"></SPAN>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman"><SPAN
style="mso-tab-count: 1">
</SPAN>if (id_val == DM9000_ID) { </FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman"><SPAN
style="mso-tab-count: 1">
</SPAN><SPAN style="mso-spacerun: yes">
</SPAN>printk("HHTech DM9000 %s I/O: %x,VID: %x,MAC: ",
dev->name,iobase, id_val); </FONT></SPAN></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -