📄 windows ce下驱动程序开发基础(4)_4.htm
字号:
<SCRIPT type=text/javascript>//<!--_S_pSt("");//--></SCRIPT>
<!-- SUDA_CODE_END -->
<CENTER><!--导航start-->
<STYLE>.h3 {
FONT-SIZE: 7px; COLOR: #ffbd00
}
</STYLE>
<TABLE cellSpacing=0 cellPadding=0 width=750 border=0>
<TBODY>
<TR>
<TD>
<SCRIPT>
function getCookie(name) {
var search;
search = name + "="
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length ;
end = document.cookie.indexOf(";", offset) ;
if (end == -1)
end = document.cookie.length;
return document.cookie.substring(offset, end);
}
else
return "";
}
function unipro_clearCookie(name ) {
document.cookie=name+"=; " + "domain=sina.com.cn; path=/; ";
//bites = document.cookie.split("; ");
}
function getMobileNum(ckName){
var userInfo = getCookie(ckName).split(":");
return userInfo[2];
}
function unipro_UniProLogout() {
unipro_clearCookie("SINAPRO");
unipro_clearCookie("SINA-AVATAR");
unipro_clearCookie("SINAPROC");
unipro_clearCookie("nick");
unipro_clearCookie("SINA_NU");
unipro_clearCookie("SINA_OU");
unipro_clearCookie("appmask");
unipro_clearCookie("gender");
unipro_clearCookie("UNIPROTM");
unipro_clearCookie("UNIPROU");
unipro_clearCookie("SINA_USER");
unipro_clearCookie("SMS_COOKIE");
return true;
}
function getUniproUrl_stand(){
window.location='http://unipro.sina.com.cn/';
return false;
}
function getUniproUrl_welcome(){
unipro_UniProLogout();
window.location='http://unipro.sina.com.cn';
return false;
}
function print_stand_unipro_head()
{
document.write("<table border=0 cellpadding=0 cellspacing=0><tr align=center><td><a href=http://www.sina.com.cn class=a01>首页</a></td><td width=14></td><td><a href=http://news.sina.com.cn class=a01>新闻</a></td><td width=14></td><td><a href=http://sports.sina.com.cn class=a01>体育</a></td><td width=14></td><td><a href=http://ent.sina.com.cn class=a01>娱乐</a></td><td width=14></td><td><a href=http://bn.sina.com.cn/ class=a01>视频</a></td><td width=14></td><td><a href=http://finance.sina.com.cn/ class=a01>财经</a></td><td width=14></td><td><a href=http://tech.sina.com.cn/ class=a01>科技</a></td><td width=14></td><td><a href=http://auto.sina.com.cn/ class=a01>汽车</a></td><td width=14></td><td><a href=http://house.sina.com.cn/ class=a01><font color=red>房产</font></a></td><td width=14></td><td><a href=http://games.sina.com.cn class=a01>游戏</a></td><td width=14></td><td><a href=http://eladies.sina.com.cn/ class=a01>女性</a></td><td width=14></td><td><a href=http://book.sina.com.cn/ class=a01>读书</a><td width=14></td><td><a href=http://y.sina.com.cn/ class=a01>校园</a></td><td width=14></td><td><a href=http://weather.sina.com.cn/ class=a01>天气</a></td><td width=14></td><td><a href=http://sms.sina.com.cn class=a01>短信</a></td><td width=14></td><td><a href=http://mail.sina.com.cn class=a01>邮箱</a></td><td width=14></td><td><a href=http://search.sina.com.cn class=a01>搜索</a></td><td width=14></td><td><a href=http://news.sina.com.cn/guide/ class=a01>导航</a></td><td width=14></td></tr></table>");
document.write("</td><td align=right>");
document.write("<table height=25 border=0 cellpadding=0 cellspacing=0>");
document.write("<tr><td><td align=right> <a href=# onClick='return getUniproUrl_stand()'>通行证登录</a></td></tr>");
document.write("</table>");
}
function print_stand_unipro_welcome()
{
var unipro_login_nickname = getCookie( "nick" );
var unipro_login_pos = unipro_login_nickname.indexOf( "(" );
if ( unipro_login_pos != -1 )
{
unipro_login_nickname = unipro_login_nickname.substr( 0, unipro_login_pos );
}
document.write("<table border=0 cellpadding=0 cellspacing=0><tr align=center><td><a href=http://www.sina.com.cn class=a01>首页</a></td><td width=14></td><td><a href=http://news.sina.com.cn class=a01>新闻</a></td><td width=14></td><td><a href=http://sports.sina.com.cn class=a01>体育</a></td><td width=14></td><td><a href=http://ent.sina.com.cn class=a01>娱乐</a></td><td width=14></td><td><a href=http://bn.sina.com.cn/ class=a01>视听</a></td><td width=14></td><td><a href=http://finance.sina.com.cn/ class=a01>财经</a></td><td width=14></td><td><a href=http://tech.sina.com.cn/ class=a01>科技</a></td><td width=14></td><td><a href=http://auto.sina.com.cn/ class=a01>汽车</a></td><td width=14></td><td><a href=http://house.sina.com.cn/ class=a01><font color=red>房产</font></a></td><td width=14></td><td><a href=http://games.sina.com.cn class=a01>游戏</a></td><td width=14></td><td><a href=http://weather.sina.com.cn/ class=a01>天气</a></td><td width=14></td><td><a href=http://sms.sina.com.cn class=a01>短信</a></td><td width=14></td><td><a href=http://mail.sina.com.cn class=a01>邮箱</a></td><td width=14></td><td><a href=http://search.sina.com.cn class=a01>搜索</a></td><td width=14></td><td><a href=http://news.sina.com.cn/guide/ class=a01>导航</a></td><td width=14></td><td></td></tr></table>");
document.write("</td><td align=right>");
document.write("<table border=0 cellpadding=0 cellspacing=0>");
document.write("<tr>");
if ( unipro_login_nickname!="" && unipro_login_nickname!="null" && unipro_login_nickname!=null && unipro_login_nickname!="undefined" ) {
document.write("<td align=right> "+unipro_login_nickname+"</td><td width=4></td><td><a href=# onClick='return getUniproUrl_welcome()'><font color=#0000ff>安全退出</font></a>");
} else {
document.write( "<td align=right> 新浪过客" +"</td><td width=4></td><td><a href=# onClick='return getUniproUrl_welcome()'><font color=#0000ff>安全退出</font></a>");
}
document.write("</td></tr>");
document.write("</table>");
}
</SCRIPT>
<SCRIPT language=javascript>
if (getCookie("SINAPRO") == "") {
print_stand_unipro_head();
} else {
print_stand_unipro_welcome();
}
</SCRIPT>
</TD></TR></TBODY></TABLE><!--导航end--><!--头部结束--><!--科技新闻内页顶部通栏开始--><!--6793569021D5--><A
href="http://ad.cn.doubleclick.net/clk;14775613;10960139;g?http://www-900.ibm.com/cn/software/tivoli/"
target=_blank><IMG height=80 src="Windows CE下驱动程序开发基础(4)_4.files/12499.gif"
width=750 border=0></A><!--$$ weixing/2005-3-25 ~ 2005-3-25/B $--> <!--科技新闻内页顶部通栏结束-->
<TABLE cellSpacing=0 cellPadding=0 width=750 border=0>
<TBODY>
<TR>
<TD width=150 height=34><A href="http://tech.sina.com.cn/"><IMG height=34
alt=科技时代 src="Windows CE下驱动程序开发基础(4)_4.files/sina_kjsd.gif" width=144
border=0></A></TD>
<TD vAlign=bottom width=440><FONT color=#0000ff><A class=a02
href="http://home.sina.com.cn/">新浪首页</A> > <A class=a02
href="http://tech.sina.com.cn/">科技时代</A> > <A class=a02
href="http://tech.sina.com.cn/s_h/news/">软件</A> > 正文</FONT></TD>
<TD vAlign=bottom align=right width=150><A href="http://www.yesky.com/"
target=_blank><IMG height=28
src="Windows CE下驱动程序开发基础(4)_4.files/U1084P2T50D213F629DT20041213105743.gif"
border=0></A></TD>
<TD width=10></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=750 border=0>
<TBODY>
<TR>
<TD height=8></TD></TR>
<TR>
<TD bgColor=#747474 height=1><IMG height=1
src="Windows CE下驱动程序开发基础(4)_4.files/c.gif" width=1></TD></TR></TBODY></TABLE>
<DIV id=outer style="WIDTH: 750px; POSITION: relative">
<TABLE cellSpacing=0 cellPadding=0 width=750 border=0>
<TBODY>
<TR>
<TD vAlign=top align=middle width=620 bgColor=#edf0f5 rowSpan=2><BR>
<DIV id=article>
<TABLE cellSpacing=0 cellPadding=0 width=560 border=0>
<TBODY>
<TR>
<TH class=f24><FONT color=#05006c>
<H1>Windows CE下驱动程序开发基础(4)</H1></FONT></TH></TR>
<TR>
<TD>
<HR SIZE=1 bgcolor="#d9d9d9">
</TD></TR>
<TR>
<TD align=middle height=20>http://www.sina.com.cn
2005年03月25日 18:21 <FONT color=#a20010>天极yesky</FONT></TD></TR>
<TR>
<TD height=15></TD></TR>
<TR>
<TD class=l17><FONT class=f14 id=zoom><!-- 正文内部文字导航 : begin --><!-- 正文内部文字导航 : end -->
<P> 文/付林林</P>
<P></P>
<P> 函数SerInit接着调用函数Ser_InternalMapRegisterAddresses转换IO地址并且映射地址,Ser_InternalMapRegisterAddresses在内部调用系统提供的HalTranslateBusAddress(Isa,
0, ioPhysicalBase, &inIoSpace, &ioPhysicalBase)函数将与<A
class=akey
href="http://tech.sina.com.cn/n/2005-01-25/1701514517.shtml"
target=_blank>总线</A>相关的地址转换为系统地址,参数1为总线类型,参数2为总线号,参数3为要转换的地址(PHYSICAL_ADDRESS类型,实际是LARGE_INTEGER型),参数4指定寄存器地址属于IO地址空间还是物理地址空间,参数5返回转换后的物理地址。观察HalTranslateBusAddress的源码得知如果是在x86平台,这个函数除了把参数3赋给了参数5其余什么都没有做,而非x86平台将inIoSpace的值置为0,表示一定是物理地址。在调用HalTranslateBusAddress前要确定从注册表中得到的寄存器地址到底是属于哪个地址空间的,例如:<BR><BR></P>
<P>
<TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#dadacf
border=1>
<TBODY>
<TR>
<TD>ULONG inIoSpace = 1; ///1表示是IO空间<BR><BR>PHYSICAL_ADDRESS
ioPhysicalBase = {iobase, 0}; ///相当于ioPhysicalBase.LowPart =
iobase</TD></TR></TBODY></TABLE></P>
<P><BR> 在地址转换后就要将转换后的地址映射到驱动程序(一般IST和应用程序一样运行在用户模式)能够访问的虚拟地址空间(0x80000000以下)和ISR能够访问的静态虚拟地址空间中(0x80000000以上)。例如:<BR><BR></P>
<P>
<TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#dadacf
border=1>
<TBODY>
<TR>
<TD>////如果地址属于物理地址空间<BR><BR>ioPortBase = (P<A class=akey
href="http://www.51uc.com/"
target=_blank>UC</A>HAR)MmMapIoSpace(ioPhysicalBase, Size,
FALSE);<BR>TransBusAddrToStatic(Isa, 0, ioPhysicalBase, Size,
&inIoSpace, ppStaticAddress);</TD></TR></TBODY></TABLE></P>
<P><BR> MmMapIoSpace函数负责将物理地址映射到驱动程序能够访问的虚拟地址空间中,通过源码分析MmMapIoSpace在内部分别调用:<BR><BR></P>
<P>
<TABLE borderColor=#ffcc66 width="90%" align=center bgColor=#dadacf
border=1>
<TBODY>
<TR>
<TD>pVirtualAddress =VirtualAlloc(0, SourceSize, MEM_RESERVE,
PAGE_NOACCESS);<BR><BR>VirtualCopy(pVirtualAddress,
(PVOID)(SourcePhys >> 8), SourceSize, PAGE_PHYSICAL |
PAGE_READWRITE | <BR>(CacheEnable ? 0 :
PAGE_NOCACHE));</TD></TR></TBODY></TABLE></P>
<P><BR> VirtualAlloc分配一块和MemLen一样大小的虚拟地址空间,因为参数1为0,所以内核自动分配。一般MemLen小于2MB,所以会在应用程序的地址空间中分配。VirtualCopy负责将硬件设备寄存器的物理地址与VirtualAlloc分配的虚拟地址做一个映射关系,这样驱动程序访问PvirtualAddress实际上就是访问第一个寄存器。因为硬件设备寄存器的物理地址一定是在512MB(CE支持RAM的最大值)以上,所以除了最后的参数要加PAGE_PHYSICAL外,第二个参数物理地址也要右移8位(或者除以256)。<BR><BR>
<P align=right><A style="FONT-SIZE: 14px"
href="http://tech.sina.com.cn/s/s/2005-03-25/1821562035.shtml">[上一页]</A> <A
href="http://tech.sina.com.cn/s/s/2005-03-25/1821562033.shtml">[1]</A> <A
href="http://tech.sina.com.cn/s/s/2005-03-25/1821562034.shtml">[2]</A> <A
href="http://tech.sina.com.cn/s/s/2005-03-25/1821562035.shtml">[3]</A> [4] <A
href="http://tech.sina.com.cn/s/s/2005-03-25/1821562037.shtml">[5]</A> <A
style="FONT-SIZE: 14px"
href="http://tech.sina.com.cn/s/s/2005-03-25/1821562037.shtml">[下一页]</A></P>
<TABLE width="90%" align=center border=0>
<TBODY>
<TR></TR></TBODY></TABLE><BR clear=all>
<TABLE cellSpacing=0 cellPadding=0 width=565 border=0>
<TBODY>
<TR>
<TD class=f14 vAlign=top height=30> 点击此处查询<A
href="http://chanews.sina.com.cn/s.cgi?k=keyword&c=2&k=Windows"
target=_blank CE>全部<FONT color=red>Windows CE</FONT>新闻</A>
</TD></TR></TBODY></TABLE></FONT></TD></TR></TBODY></TABLE></DIV><BR>
<TABLE cellSpacing=0 cellPadding=0 width=560 border=0>
<TBODY>
<TR>
<TD>
<TABLE cellSpacing=0 cellPadding=0 width=565 border=0>
<TBODY>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -