?? linux設備驅動之usb主機控制器驅動分析-(5)_linux技術文章_linux_操作系統5.htm
字號:
UHCI_USBCMD_HCRESET)<BR>
dev_warn(&pdev->dev, "HCRESET not completed
yet!\n");<BR> <BR> /* Just to be safe, disable
interrupt requests and<BR> * make sure the
controller is stopped.<BR>
*/<BR> outw(0, base +
UHCI_USBINTR);<BR> outw(0, base +
UHCI_USBCMD);<BR>}<BR>重啟OHCI的步驟如下:<BR>1:將UHCI_USBLEGSUP寄存器中的,RWC屬性位清空.<BR>RWC屬性即為:該位可讀可寫.如果往該位寫1,就會將該位清0.如果寫0則什么都不干.上面代碼的操作也就是將RWC位置為0.代碼的注釋上說的很清楚了.這樣會禁用PIRQ和SMI.當然也會關掉Legacy設備的支持.<BR>2:往USB
CMD寄存器寫入UHCI_USBCMD_HCRESET.用來重啟UHCI.<BR>UHCI重啟完了之后,又會將該位清空<BR>3:清空USB
INTR寄存器和CMD寄存器<BR>對于重啟UHCI的情況,返回到check_and_reset_hc()里,還會調用finish_reset().代碼如下:<BR>static
void finish_reset(struct uhci_hcd *uhci)<BR>{<BR> int
port;<BR> <BR> /* HCRESET doesn't affect the
Suspend, Reset, and Resume Detect<BR> * bits in
the port status and control registers.<BR> * We
have to clear them by hand.<BR>
uhci->rh_numports;
++port)<BR> outw(0,
uhci->io_addr + USBPORTSC1 + (port *
2));<BR> <BR> uhci->port_c_suspend =
uhci->resuming_ports = 0;<BR> uhci->rh_state =
UHCI_RH_RESET;<BR> uhci->is_stopped =
UHCI_IS_STOPPED;<BR> uhci_to_hcd(uhci)->state =
HC_STATE_HALT;<BR> uhci_to_hcd(uhci)->poll_rh =
0;<BR> <BR> uhci->dead =
0; /* Full reset resurrects the
controller */<BR>}<BR>該函數將UHCI
的各個PORTSC寄存器全部清空.然后設置UHCI為RESET狀態.HCD為HALT狀態等等.<BR> <BR>2.3:hcd->driver->start(
)的操作<BR>將UHCI重啟之后,注冊好了中斷處理函數就可以啟動UHCI了.對應的接口為uhci_start().在分析代碼之前,先來了解一下UHCI的調度架構.<BR>從UHCI的spec中摘出一個圖,先看下UHCI調度的大概情況:<BR> <BR><IMG
src="linux設備驅動之USB主機控制器驅動分析-(5)_Linux技術文章_Linux_操作系統5.files/080909094316.jpg"
width=500 onload="javascript:if(this.width>500)this.width=500;"
border=0><BR> <BR>從該圖中可以看出:<BR>圖中的Frame List,翻譯成中文叫框架表.TD表示Transfer
Descriptor,即表示一次具體的傳輸.QH表示Queue
Head.即傳輸隊列.由上圖可見.QH可以和其它的QH組成隊列.QH下面又可以掛上TD鏈.<BR>在UHCI內部.有一個Frame List Address
Base Register(FLAB).用來存放Frame List的基地址和當前執行的Frame List序號.每過1ms.
FLAB中的index段會加1.它總共占10位,當增加到1023時,又會回轉到0.UHCI根據FLAB中存放的Frame
list地址,以Index為序號執行Frame
List的相關項.<BR>由此可以看到.如果我們要UHCI往設備發送信息.只要將數據打成TD格式的,然后將其鏈入到相關QH或者TD就好.<BR>從上圖中也可以看到傳送的優先級關系.先是ISO.然后是INTERRUPT.最后是CONTRL和BULK.關于這四種傳輸,請自行參照USB2.0
spec.<BR>現在結合代碼進行分析,如果代碼較長,采用分段分析的方式:<BR>static int uhci_start(struct usb_hcd
*hcd)<BR>{<BR> struct uhci_hcd *uhci =
hcd_to_uhci(hcd);<BR> int retval =
-EBUSY;<BR> int i;<BR> struct
dentry *dentry;<BR> <BR> hcd->uses_new_polling =
1;<BR> <BR>
spin_lock_init(&uhci->lock);<BR>
setup_timer(&uhci->fsbr_timer,
uhci_fsbr_timeout,<BR>
(unsigned long) uhci);<BR>
INIT_LIST_HEAD(&uhci->idle_qh_list);<BR>
init_waitqueue_head(&uhci->waitqh);<BR> <BR>
if (DEBUG_CONFIGURED) {<BR>
dentry =
debugfs_create_file(hcd->self.bus_name,<BR>
S_IFREG|S_IRUGO|S_IWUSR,
uhci_debugfs_root,<BR>
uhci,
&uhci_debug_operations);<BR>
if (!dentry)
{<BR>
dev_err(uhci_dev(uhci), "couldn't create uhci
"<BR>
"debugfs
entry\n");<BR>
retval =
-ENOMEM;<BR>
goto err_</P>
<DIV class=ad_f10 id=ad_f10>
<SCRIPT
src="linux設備驅動之USB主機控制器驅動分析-(5)_Linux技術文章_Linux_操作系統5.files/ad_f10.js"></SCRIPT>
</DIV>
<DIV class=ad_f11 id=ad_f11>
<SCRIPT
src="linux設備驅動之USB主機控制器驅動分析-(5)_Linux技術文章_Linux_操作系統5.files/ad_f11.js"></SCRIPT>
</DIV>
<DIV class=kjy><STRONG>文章整理:</STRONG><A href="http://www.diybl.com/"
target=_blank><STRONG><FONT color=#cc0000>DIY部落</FONT></STRONG></A>
<STRONG>http://www.diybl.com</STRONG> (本站) <A class=redlink
href="javascript:self.location='/user/chm/rar.asp?c_id=144940'">【點擊打包該文章】</A></DIV>
<DIV class=hehe><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940.html">[1]</A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_2.html">
[2]</A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_3.html">
[3]</A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/course/6_system/linux/Linuxjs/2008923/144939.html"><SPAN
style="DISPLAY: none">'hehe'</SPAN></A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_4.html">
[4]</A> [5] <A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_6.html">[6]</A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_7.html">
[7]</A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_8.html">
[8]</A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_9.html">
[9]</A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_10.html">
[10]</A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_11.html">
[11]</A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_12.html">
[12]</A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_13.html">
[13]</A></DIV></DIV>
<DIV class=ad_f4 id=ad_f4>
<SCRIPT
src="linux設備驅動之USB主機控制器驅動分析-(5)_Linux技術文章_Linux_操作系統5.files/ad_f4.js"></SCRIPT>
</DIV>
<DIV class=mediacontent>如果圖片或頁面不能正常顯示請<A class=redlink
onmouseover="this.style.cursor='hand';"
onclick="openerror('144940','linux設備驅動之USB主機控制器驅動分析');">點擊這里</A> 站內搜索: <INPUT
maxLength=255 size=25 name=wd3> <INPUT onclick=tosearch(document.all.wd3); type=button value=千尋搜索></DIV>
<DIV style="CLEAR: both" align=center></DIV>
<DIV class=toollinks>【<A
href="javascript:window.external.addFavorite(window.location,'linux設備驅動之USB主機控制器驅動分析-DIY部落');">收藏此頁</A>】【<A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/81b8tksdftk.html"
target=_blank>欄目頁面</A>】【<A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_5.html#comment">發表評論</A>】【<A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_5.html#">返回頂部</A>】【<A
href="javascript:window.close()">關閉</A>】 </DIV>
<DIV class=p_bottom>上一篇文章:<A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144941.html">
Linux 啟動腳本 完全注釋2 --- rc腳本注釋</A><BR>下一篇文章:<A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144939.html">Rsync命令參數詳解</A></DIV></DIV>
<DIV style="CLEAR: both; BACKGROUND: #fff; OVERFLOW: hidden; HEIGHT: 8px"></DIV>
<DIV id=links align=center>
<TABLE class=xgzt cellSpacing=0 cellPadding=0 width=687>
<TBODY>
<TR>
<TD style="PADDING-LEFT: 5px" bgColor=#e1effa>
<H3>推薦文章</H3></TD></TR>
<TR>
<TD bgColor=#fcfeff>
<DIV class="tj_l tj"><NOBR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/200873/129883.html"
target=_blank>[GNU make中文1.6]第三章 Makefile 總述</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/200861/119414.html"
target=_blank>Linux 進程間通信 - 共享內存</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008814/135982.html"
target=_blank>Fedora9個人使用小提示</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008810/135552.html"
target=_blank>試試先~~</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008629/129176.html"
target=_blank>一篇讓我自慚形穢的博客-看看人家的博客做的多好-vivi開發筆記【專輯】</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008919/143640.html"
target=_blank>在 Linux 上實現基于 Socket 的多進程實時通信</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008625/128314.html"
target=_blank>PPTP on RHEL AS5(加密vpn-mppe-mschap-v2)</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/20071027/80382.html"
target=_blank>linux中find命令詳解(轉)</A></DIV>
<DIV class="tj_r tj"><NOBR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/200865/122330.html"
target=_blank>RHCE133實驗(系統管理)</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2007921/72571.html"
target=_blank>第2章 獲取Squid</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/200868/123695.html"
target=_blank>多線程程序設計</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008822/137078.html"
target=_blank>負載均衡器;BIG-IP</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008810/135454.html"
target=_blank>VI配置和命令備忘錄</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008721/133635.html"
target=_blank>linux下的多線程下載工具-----axel</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008625/128310.html"
target=_blank>awk命令</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008617/125903.html"
target=_blank>6--USB</A></DIV></NOBR></TD></TR></TBODY></TABLE></DIV>
<DIV style="CLEAR: both; BACKGROUND: #fff; OVERFLOW: hidden; HEIGHT: 8px"></DIV>
<DIV class=cleanblock2
style="BORDER-RIGHT: #dedfde 1px solid; BORDER-TOP: #dedfde 1px solid; BACKGROUND: #ededed; BORDER-LEFT: #dedfde 1px solid; BORDER-BOTTOM: #dedfde 1px solid">
<H3>文章評論</H3></DIV>
<DIV class=cleanblock3><IFRAME class=comm_index name=pindex
src="linux設備驅動之USB主機控制器驅動分析-(5)_Linux技術文章_Linux_操作系統5.files/CA6YUOVT.htm"
frameBorder=false width="100%" scrolling=no
onload="window.setTimeout('iframe_resize()',1000)" height=0></IFRAME></DIV>
<DIV style="CLEAR: both; BACKGROUND: #fff; OVERFLOW: hidden; HEIGHT: 8px"></DIV>
<FORM style="MARGIN-TOP: 0px"
action=/user/comment.asp?id=144940&url=http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940.html
method=post>
<DIV class=comment_1>
<DIV class=cleanblock2><A name=comment></A>
<H3>請您留言</H3></DIV>
<DIV class=cleanblock style="PADDING-RIGHT: 20px; PADDING-LEFT: 20px"><LABEL
for=label>昵稱: <INPUT onclick=this.focus();this.select() maxLength=20 size=15
value=DIY部落網友 name=hypocorism> <A
href="http://www.diybl.com/user/register.asp" target=_blank><FONT
color=red>注冊會員</FONT></A> <A href="http://www.diybl.com/user/login.asp"
target=_blank>會員登陸</A> <BR><SPAN style="LINE-HEIGHT: 25px"><A
href="http://www.diybl.com/user/chgpage/cata.asp?num=1060103"
target=_blank><FONT color=#990000><STRONG>點擊這里</STRONG></FONT></A></SPAN>
自己制作打包的chm電子書教程 <TEXTAREA style="VERTICAL-ALIGN: text-top; WIDTH: 100%; HEIGHT: 7em" onfocus=showchk(); name=content rows=6></TEXTAREA>
<LABEL id=checkCode style="DISPLAY: none">驗證: <INPUT maxLength=5 size=8
name=loginnum> <IMG id=codeImg
style="VERTICAL-ALIGN: middle; CURSOR: pointer; HEIGHT: 18px"
onclick="this.src='/user/getcode.asp?t='+Math.random()" alt=驗證碼,看不清楚?請點擊刷新驗證碼
src=""> </LABEL> <INPUT class=btn_2k3 style="MARGIN-TOP: 8px" type=submit value=發表評論>
</DIV></DIV>
<DIV class=comment_1
style="FLOAT: left; MARGIN-LEFT: 6px; WIDTH: 313px; HEIGHT: 90px">
<DIV class=cleanblock2>
<H3>網友推薦文章</H3></DIV>
<DIV class=cleanblock>
<TABLE cellSpacing=0 cellPadding=0 width="100%">
<TBODY>
<TR>
<TD style="PADDING-RIGHT: 15px">
<UL>
<LI><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2007114/84084.html"
target=_blank>網絡安全之經驗談(from cu)</A></LI>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -