📄 linux下dm9000网卡驱动实验〈三〉 - orange - csdnblog.htm
字号:
style="mso-tab-count: 1">
</SPAN>} else { </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>/* Second 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"><FONT face="Times New Roman"><SPAN
style="mso-tab-count: 2">
</SPAN>db->queue_pkt_len = skb->len; </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-spacerun: yes"> </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>/* free this SKB */ </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>dev_kfree_skb(skb); </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"><FONT
face="Times New Roman"><SPAN lang=EN-US><SPAN
style="mso-tab-count: 1">
</SPAN></SPAN><SPAN lang=EN-US style="FONT-SIZE: 9pt">/* Re-enable
resource check */ </SPAN></FONT></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 == 1) </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>netif_wake_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"><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>/* Re-enable interrupt mask */ </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, 0x83); </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>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>
<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>
<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"><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 void
dmfe_interrupt(int irq, void *dev_id, struct pt_regs *regs)
</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>db = (board_info_t *)dev->priv; </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>spin_lock(&db->lock); // 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>/* Save previous register address */ </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>reg_save = inb(db->ioaddr); </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>/* Got DM9000 interrupt status */ </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>int_status = ior(db, 0xfe);<SPAN
style="mso-tab-count: 2">
</SPAN>/* Got ISR */ </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, 0xfe, int_status);<SPAN
style="mso-tab-count: 2">
</SPAN>/* Clear ISR status */ </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>//printk("I%x ", int_status); </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>/* Received the coming 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: 1">
</SPAN>if (int_status & 1) </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>dmfe_packet_receive(dev, db); </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>/* Trnasmit Interrupt check */ </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 (int_status & 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: 2">
</SPAN>tx_status = ior(db, 0x01);<SPAN
style="mso-tab-count: 1"> </SPAN>/* <PLACE
w:st="on"></PLACE><CITY w:st="on"></CITY>Got <STATE w:st="on"></STATE>TX
status */ </FONT></SPAN></P>
<P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -