📄 linux设备驱动之usb主机控制器驱动分析-(6)_linux技术文章_linux_操作系统6.htm
字号:
invalid)”.也就是表示,它的后面已经没有有效项了.不要再往后面去遍历了.其实就是一个终止项<BR> <BR>
//skel_term_qh = skelqh[10]<BR>
uhci->skel_term_qh->link =
LINK_TO_QH(uhci->skel_term_qh);<BR> <BR> /* This
dummy TD is to work around a bug in Intel PIIX controllers
*/<BR> uhci_fill_td(uhci->term_td, 0, uhci_explen(0)
|<BR>
(0x7f << TD_TOKEN_DEVADDR_SHIFT) | USB_PID_IN,
0);<BR> //term_td后面已经没有数据了<BR>
uhci->term_td->link = UHCI_PTR_TERM;<BR>
uhci->skel_async_qh->element = uhci->skel_term_qh->element
=<BR>
LINK_TO_TD(uhci->term_td);<BR>Skel_term_qh定义成skelqh[10].即uhci->skelqh[
]的最后一项.它自己指向了自己.<BR>然后对于uhci->term_td是Intel
PIIX的一个BUG.这部份就不再详细分析了.最后将uhci->term_td挂上了uhci->skelqh[9]和uhci->skelqh[10]<BR>
/*<BR> * Fill the frame list: make all entries
point to the proper<BR> * interrupt
queue.<BR> */<BR> for (i =
0; i < UHCI_NUMFRAMES; i++)
{<BR> <BR> /* Only place we
don't use the frame list routines
*/<BR> uhci->frame[i] =
uhci_frame_skel_link(uhci, i);<BR>
}<BR> <BR> /*<BR> *
Some architectures require a full mb() to enforce completion
of<BR> * the memory writes above before the I/O
transfers in configure_hc().<BR>
*/<BR> mb();<BR> <BR>
configure_hc(uhci);<BR> uhci->is_initialized =
1;<BR> start_rh(uhci);<BR>
return
0;<BR>最后,将初始化完成的TD和QH项挂到uhci->frame[].然后再调用configure_hc和start_rh来配置UHCI和启用UHCI.<BR> <BR>/*<BR> *
error exits:<BR> */<BR>err_alloc_skelqh:<BR> for (i
= 0; i < UHCI_NUM_SKELQH; i++)
{<BR> if
(uhci->skelqh[i])<BR>
uhci_free_qh(uhci, uhci->skelqh[i]);<BR>
}<BR> <BR> uhci_free_td(uhci,
uhci->term_td);<BR> <BR>err_alloc_term_td:<BR>
dma_pool_destroy(uhci->qh_pool);<BR> <BR>err_create_qh_pool:<BR>
dma_pool_destroy(uhci->td_pool);<BR> <BR>err_create_td_pool:<BR>
kfree(uhci->frame_cpu);<BR> <BR>err_alloc_frame_cpu:A<BR>
dma_free_coherent(uhci_dev(uhci),<BR>
UHCI_NUMFRAMES *
sizeof(*uhci->frame),<BR>
uhci->frame,
uhci->frame_dma_handle);<BR> <BR>err_alloc_frame:<BR>
debugfs_remove(uhci->dentry);<BR> <BR>err_create_debug_entry:<BR>
return retval;<BR>}<BR>这里的TD,QH交错复杂,很容易把头看昏.画了个图.如下 :<BR><IMG
src="linux设备驱动之USB主机控制器驱动分析-(6)_Linux技术文章_Linux_操作系统6.files/080909094427.jpg"
width=500 onload="javascript:if(this.width>500)this.width=500;"
border=0><BR> <BR>从上图中可以看出,skelqh[]数组的第0项和第1项是没有经过初始化的.而skelqh[10]又是指向它本身的结点.<BR>经过skelqh[]的初始化后.就可以将它和frmae[]关联起来了.<BR>如下面代码片段所示:<BR>
for (i = 0; i < UHCI_NUMFRAMES; i++)
{<BR> <BR> /* Only place we
don't use the frame list routines
*/<BR> uhci->frame[i] =
uhci_frame_skel_link(uhci, i);<BR>
}<BR>Uhci_frame_skel_link()的代码如下所示:<BR>static __le32 uhci_frame_skel_link(struct
uhci_hcd *uhci, int frame)<BR>{<BR> int
skelnum;<BR> skelnum = 8 - (int) __ffs(frame |
UHCI_NUMFRAMES);<BR> if (skelnum <=
1)<BR> skelnum =
9;<BR> return
LINK_TO_QH(uhci->skelqh[skelnum]);<BR>}<BR>这个函数虽然很短小,但是算法却很复杂.<BR>首先来看一下这个函数要做什么事情:<BR>我们在前面说过,int128,int64,int32……int4,int2,int1这样8个QH.我们在后面看到.会将uhci->frame的物理地址存放到UHCI控制器的Frame
List Base Address Register中.所以现在要做的事情就是将这些QH与uhci->frame[
]关联起来.必须要按照相应的时间间隔将QH插入到uhci->frame[]中.例如,例如如果frame[]的n存放int128的QH,那么下一个int128的QH就必须要放到n+128的位置.很明显,对于int1是可以随便放的,也可放可不放.因为int1链接在所有的间隔的QH后面.同时int1又可以单独存放到frame[]中.<BR>另外,从skelqh[2]~skelqh[9]分别表示int128~int1.对于skelqh[0]和skelqh[1]是不需要用到的,而且8-
(int) __ffs(frame | UHCI_NUMFRAMES)不可能大于9.所以,</P>
<DIV class=ad_f10 id=ad_f10>
<SCRIPT
src="linux设备驱动之USB主机控制器驱动分析-(6)_Linux技术文章_Linux_操作系统6.files/ad_f10.js"></SCRIPT>
</DIV>
<DIV class=ad_f11 id=ad_f11>
<SCRIPT
src="linux设备驱动之USB主机控制器驱动分析-(6)_Linux技术文章_Linux_操作系统6.files/ad_f11.js"></SCRIPT>
</DIV>
<DIV class=kjh>欢迎光临<A href="http://www.diybl.com/" target=_blank><STRONG><FONT
color=#cc0000>DIY部落</FONT></STRONG></A>,<A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/3b70sdsdpytk.html"
target=_blank><STRONG><FONT color=#cc0000>点击这里</FONT></STRONG></A>查看更多文章教程 <A
class=redlink
href="javascript:self.location='/user/chm/rar.asp?c_id=144940'">【点击打包该文章】</A></DIV>
<DIV class=zh><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/144940_4.html">
[4]</A><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_5.html">
[5]</A> [6] <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/course/6_system/linux/Linuxjs/2008923/144939.html"><SPAN
style="DISPLAY: none">'zh'</SPAN></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主机控制器驱动分析-(6)_Linux技术文章_Linux_操作系统6.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/3b70sdsdpytk.html"
target=_blank>栏目页面</A>】【<A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_6.html#comment">发表评论</A>】【<A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144940_6.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/20071027/80547.html"
target=_blank>linux下的静态库和动态库的编译</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/20071226/94178.html"
target=_blank>摘自《程序员》杂志</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/200861/119342.html"
target=_blank>GIMP 2.2.15</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008723/133789.html"
target=_blank>Linux 调试技术(fw)</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008723/133704.html"
target=_blank>Linux 386 boot代码分析 (2) setup.txt head.txt</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/200861/119420.html"
target=_blank>优化和排错 之 lsof命令 </A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008819/136543.html"
target=_blank>改变网络接口的速度和协商方式的工具miitool 和ethtool (v0.1b)</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/200888/135140.html"
target=_blank>我的ubuntu 下的xorg.conf配置</A></DIV>
<DIV class="tj_r tj"><NOBR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008829/138653.html"
target=_blank>Linux系统下的多线程编程入门二</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008819/136320.html"
target=_blank>Linux中patch文件的使用(转载)</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/200875/130416.html"
target=_blank>硬件工程师笔试题目</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008923/144865.html"
target=_blank>Linux终端(四)</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/20071215/92281.html"
target=_blank>王志东:你能破译linux密码我给你10W</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2008611/124687.html"
target=_blank>LRU 算法</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/2007114/84030.html"
target=_blank>有了Ubuntu,您还需要Windows吗?</A><BR><A
href="http://www.diybl.com/course/6_system/linux/Linuxjs/200875/130409.html"
target=_blank>win VSS ------Visual
SourceSafe</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主机控制器驱动分析-(6)_Linux技术文章_Linux_操作系统6.files/CALVFWS1.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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -