📄 linux下dm9000网卡驱动实验〈三〉 - orange - csdnblog.htm
字号:
lang=EN-US style="FONT-SIZE: 9pt"><FONT
face="Times New Roman">netif_stop_queue(dev);<SPAN
style="mso-spacerun: yes"> </SPAN>//add by simon 2001.9.4 for kernel
2.4 </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>/* free interrupt */ </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>free_irq(dev->irq, dev); </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>/* RESET devie */ </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>phy_write(db, 0x00, 0x8000);<SPAN
style="mso-tab-count: 1">
</SPAN>/* PHY RESET */ </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>iow(db, 0x<CHMETCNV tcsc="0" numbertype="1" negative="False"
hasspace="False" sourcevalue="1" unitname="F" w:st="on"></CHMETCNV>1f,
0x01);<SPAN style="mso-tab-count: 1"> </SPAN>/*
Power-Down PHY */ </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>iow(db, 0xff, 0x80);<SPAN
style="mso-tab-count: 1"> </SPAN>/* Disable
all interrupt */ </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>iow(db, 0x05, 0x00);<SPAN
style="mso-tab-count: 1"> </SPAN>/* Disable RX */
</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>MOD_DEC_USE_COUNT; </FONT></SPAN></P>
<P> </P>
<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">return 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">}</FONT></SPAN></P>
<P></P>
<P><FONT face="Times New Roman"></FONT> </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
style="FONT-FAMILY: 宋体; mso-ascii-font-family: " new="" times=""><FONT
size=3>发送数据接口,对照前面的简单的驱动框架。</FONT></SPAN></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"><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></P>
<P> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US
style="FONT-SIZE: 9pt"><FONT face="Times New Roman">{ </FONT></SPAN></P>
<P> </P>
<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">netif_stop_queue(dev); //add by simon 2001.9.4 for
kernel 2.4 </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>/* Disable all interrupt */ </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>iow(db, 0xff, 0x80); </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>/* Move data to DM9000 TX RAM */ </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>data_ptr = (char *)skb->data; </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(0xf8, db->ioaddr); </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>tmplen = (skb->len + 1) / 2; </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>/* Word mode*/ </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>for (i = 0; i < tmplen; i++) </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-spacerun: yes"> </SPAN><SPAN
style="mso-tab-count: 2">
</SPAN>outw(((u16 *)data_ptr)[i], db->io_data); </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></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>/* TX control: First packet immediately send, second packet queue
*/ </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 (db->tx_pkt_cnt == 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>/* First Packet */ </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>db->tx_pkt_cnt++; </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: 2">
</SPAN>/* <PLACE w:st="on"></PLACE><CITY w:st="on"></CITY>Set <STATE
w:st="on"></STATE>TX length to DM9000 */ </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>iow(db, 0xfc, skb->len & 0xff); </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>iow(db, 0xfd, (skb->len >> 8) & 0xff);
</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: 2">
</SPAN>/* <PLACE w:st="on"></PLACE><CITY w:st="on"></CITY>Issue <STATE
w:st="on"></STATE>TX polling command */ </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>iow(db, 0x2, 0x1);<SPAN
style="mso-tab-count: 1">
</SPAN>/* Cleared after TX complete */ </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: 2">
</SPAN>dev->trans_start = jiffies;<SPAN
style="mso-tab-count: 1"> </SPAN>/* saved
the time stamp */ </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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -