📄 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>
*/<BR> for (port = 0; port <
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 + -