如何制作支持VMWare的Windows CE BSP
2006-11-19 22:01
477 查看
不知道有没有人试过在VMWare中跑过Windows CE。可能有人会问:在VMWare中跑Windows CE有什么意义?Windows CE不是有基于Vritual PC的emulator吗?要做干吗不做一个基于Microsoft自己的Virtual PC的?
简单的答案是,VMWare支持一些Virtual PC(包括Windows CE emulator)不支持的硬件。对我来说,最吸引我的是VMWare支持USB设备。另外根据我的经验VMWare的性能比Virtual PC强。
本文介绍如何针对VMWare支持的硬件,做一个相应的Windows CE BSP。根据VMWare虚拟机的spec,我打算支持的硬件列表如下(SCSI设备、软驱这些用的比较少就算了):
Graphics
•VGA and SVGA support
IDE Drives
•IDE virtual disks up to 950 GB
•Serial (COM) Ports
•Up to four serial (COM) ports
USB ports
•Two-port USB 1.1 UHCI controller
Keyboard
•104-key Windows 95/98 enhanced
Mouse and Drawing Tablets
•PS/2 mouse
Ethernet Card
•AMD PCnet-PCI II compatible
Sound
•Emulates Creative Labs Sound Blaster AudioPCI (MIDI input, game controllers and joysticks are not supported, except for USB devices)
其实从根本上来说,给VMWare用的Windows CE跟普通PC或者Virtual PC的并无多大区别。因此基本做法和一些概念都可以看MSDN里对CEPC的相关介绍。这里只重点介绍一些针对VMWare的不同地方。
给Windows CE用的VMWare虚拟机可以用DOS的。BSP可以直接copy一份Platform Builder带的CEPC BSP做为起始的BSP,然后在此基础上修改。从IDE硬盘、声卡、显卡、键盘鼠标的支持比较简单,用Platform Builder中现成的driver就行了。
![](http://p.blog.csdn.net/images/p_blog_csdn_net/singlerace/256449/o_vmware_driverview.JPG)
比较麻烦的是网卡和USB host controller。
VMWare虚拟的网卡兼容AMD PCnet-PCI II,具体型号是AMD AM79C970A,这个在Windows CE下可实在不好找,自己写一个就太麻烦了。不过在google大法的强力帮助下,我花了很长时间终于找到一个编译好的driver-还是for Windows CE 2.0的(现在想不起来在哪儿找到的了,想要的直接找我吧)。相关注册表设置见附录。
比较头疼的是USB host driver。VMWare中支持的USB host controller是USB 1.1 UHCI controller。Windows CE下有现成的driver,但是直接拿来用的话你会发现不能工作。一番研究后发现问题出在LEGACY SUPPORT REGISTER (LEGSUP)的设置上-VMWare在初始化UHCI controller的时候enable了SMI generation,而且没有把USB中断route到PIRQD上。简单说来就是VMWare对UHCI controller的初始化和Windows CE自带driver要求的不一样(其实是和UHCI spec定义的不一致,UHCI spec定义LEGSUP寄存器默认值是2000h(见5.2.1节),VMWare中是3Bh)。为了能让UHCI controller工作,需要修改UHCI driver的初始化例程,重新编译一个版本。具体修改见附录。
这样,一个支持声卡、网卡、USB设备的VMWare BSP就基本搞定了。
附上两张运行时的截图:
![](http://p.blog.csdn.net/images/p_blog_csdn_net/singlerace/256449/o_vmware_runce0.JPG)
![](http://p.blog.csdn.net/images/p_blog_csdn_net/singlerace/256449/o_vmware_runce1.JPG)
附1,网卡的注册表设置,放在platform.reg里:
[HKEY_LOCAL_MACHINECommPCNTN4M]
"DisplayName"="PCNTN4M Compatible Ethernet Driver"
"Group"="NDIS"
"ImagePath"="pcntn4m.dll"
[HKEY_LOCAL_MACHINECommPCNTN4MLinkage]
"Route"=multi_sz:"PCNTN4M1"
[HKEY_LOCAL_MACHINECommPCNTN4M1]
"DisplayName"="PCNTN4M Compatible Ethernet Driver"
"Group"="NDIS"
"ImagePath"="pcntn4m.dll"
[HKEY_LOCAL_MACHINECommPCNTN4M1Parms]
; "BusNumber"=dword:0
; "BusType"=dword:05
; "Interrupt"=dword:05
; "IOAddress"=dword:0300
[HKEY_LOCAL_MACHINECommTcpipLinkage]
"Bind"=multi_sz:"ppp","PCNTN4M1"
; Registry values for the pcntn4m1 driver
[HKEY_LOCAL_MACHINECommPCNTN4M1ParmsTcpIp]
; This enable the DHCP. In Win CE 2.1 Preview version statically allocated IP address
; does not work. So we use the DHCP server to allocate the IP address.
"EnableDHCP"=dword:1
; This should be MULTI_SZ
"DefaultGateway"=""
; This should be SZ... If null it means use LAN, else WAN and Interface.
"LLInterface"=""
; Use zero for broadcast address? (or 255.255.255.255)
"UseZeroBroadcast"=dword:0
; Thus should be MULTI_SZ, the IP address list
"IpAddress"="0.0.0.0"
; This should be MULTI_SZ, the subnet masks for the above IP addresses
"Subnetmask"="0.0.0.0"
;
; Template the PCI bus driver uses to match a AM79C970 PC-net card
;
[HKEY_LOCAL_MACHINEDriversBuiltInPCITemplatePCNTN4M]
"Dll"="NDIS.dll"
"Class"=dword:02
"SubClass"=dword:00
"ProgIF"=dword:0
"VendorID"=multi_sz:"1022"
"DeviceID"=multi_sz:"2000"
; "Entry"="NdisPCIBusDeviceInit"
"Prefix"="NDS"
"Transceiver"=dword:3
"IsrDll"="giisr.dll"
"IsrHandler"="ISRHandler"
"PortIsIO"=dword:1
"PortOffset"=dword:C ; TBD
"PortSize"=dword:2
"PortMask"=dword:5F00 ; TBD
[HKEY_LOCAL_MACHINECommConnectionSharing]
"PrivateInterface"="PCI/PCNTN4M"
附2,UHCI driver需要修改的代码(红色部分,在$(DRIVERS)/USB/HCD/UHC/system.csystem.c中):
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// Inline functions
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
__inline static WORD
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
PCIConfig_ReadWord(
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
ULONG BusNumber,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
ULONG Device,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
ULONG Function,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
ULONG Offset
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
WORD RetVal = 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PCI_SLOT_NUMBER SlotNumber;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SlotNumber.u.AsULONG = 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SlotNumber.u.bits.DeviceNumber = Device;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SlotNumber.u.bits.FunctionNumber = Function;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HalGetBusDataByOffset(PCIConfiguration, BusNumber, SlotNumber.u.AsULONG, &RetVal, Offset, sizeof(RetVal));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return RetVal;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
__inline static void
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
PCIConfig_Write(
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
ULONG BusNumber,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
ULONG Device,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
ULONG Function,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
ULONG Offset,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
ULONG Value,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
ULONG Size
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PCI_SLOT_NUMBER SlotNumber;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SlotNumber.u.AsULONG = 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SlotNumber.u.bits.DeviceNumber = Device;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SlotNumber.u.bits.FunctionNumber = Function;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HalSetBusDataByOffset(PCIConfiguration, BusNumber, SlotNumber.u.AsULONG, &Value, Offset, Size);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//* InitializeUHCI
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Configure and initialize UHCI card
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Return Value:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Return TRUE if card could be located and configured, otherwise FALSE
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
static BOOL
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
InitializeUHCI(
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
SUhcdPdd * pPddObject, // IN - Pointer to PDD structure
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
LPCWSTR szDriverRegKey) // IN - Pointer to active registry key string
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PUCHAR ioPortBase = NULL;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DWORD dwAddrLen;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DWORD dwIOSpace;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
BOOL InstallIsr = FALSE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
BOOL fResult = FALSE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
LPVOID pobMem = NULL;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
LPVOID pobUhcd = NULL;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DWORD PhysAddr;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DWORD dwHPPhysicalMemSize;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HKEY hKey;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
WORD LegSup;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DDKWINDOWINFO dwi;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DDKISRINFO dii;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DDKPCIINFO dpi;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,szDriverRegKey,0,0,&hKey)!= ERROR_SUCCESS) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DEBUGMSG(ZONE_ERROR,(TEXT("InitializeUHCI:GetRegistryConfig RegOpenKeyEx(%s) failed "),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
szDriverRegKey));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return FALSE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dwi.cbSize=sizeof(dwi);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dii.cbSize=sizeof(dii);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dpi.cbSize=sizeof(dpi);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if ( DDKReg_GetWindowInfo(hKey, &dwi ) !=ERROR_SUCCESS ||
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DDKReg_GetIsrInfo (hKey, &dii ) != ERROR_SUCCESS ||
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
DDKReg_GetPciInfo (hKey, &dpi ) != ERROR_SUCCESS) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DEBUGMSG(ZONE_ERROR,(TEXT("InitializeUHCI:DDKReg_GetWindowInfo or DDKReg_GetWindowInfo or DDKReg_GetPciInfo failed ")));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
goto InitializeUHCI_Error;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (dwi.dwNumMemWindows!=0) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PhysAddr = dwi.memWindows[0].dwBase;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dwAddrLen= dwi.memWindows[0].dwLen;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dwIOSpace = 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
else if (dwi.dwNumIoWindows!=0) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PhysAddr= dwi.ioWindows[0].dwBase;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dwAddrLen = dwi.ioWindows[0].dwLen;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dwIOSpace = 1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
goto InitializeUHCI_Error;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DEBUGMSG(ZONE_INIT,(TEXT("UHCD: Read config from registry: Base Address: 0x%X, Length: 0x%X, I/O Port: %s, SysIntr: 0x%X, Interface Type: %u, Bus Number: %u "),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PhysAddr, dwAddrLen, dwIOSpace ? L"YES" : L"NO", dii.dwSysintr, dwi.dwInterfaceType, dwi.dwBusNumber));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ioPortBase = (PUCHAR)PhysAddr;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (!(fResult = ConfigureUHCICard(pPddObject, &ioPortBase, dwAddrLen, dwIOSpace, dwi.dwInterfaceType, dwi.dwBusNumber))) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
goto InitializeUHCI_Error;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (dii.szIsrDll[0] != 0 && dii.szIsrHandler[0]!=0 && dii.dwIrq<0xff && dii.dwIrq>0 ) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// Install ISR handler
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->IsrHandle = LoadIntChainHandler(dii.szIsrDll,dii.szIsrHandler, (BYTE)dii.dwIrq);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (!pPddObject->IsrHandle) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DEBUGMSG(ZONE_ERROR, (L"UHCD: Couldn't install ISR handler "));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
} else ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
GIISR_INFO Info;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
PHYSICAL_ADDRESS PortAddress = ...{PhysAddr, 0};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DEBUGMSG(ZONE_INIT, (L"UHCD: Installed ISR handler, Dll = '%s', Handler = '%s', Irq = %d ",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dii.szIsrDll, dii.szIsrHandler, dii.dwIrq));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (!BusTransBusAddrToStatic(pPddObject->hParentBusHandle,dwi.dwInterfaceType, dwi.dwBusNumber, PortAddress, dwAddrLen, &dwIOSpace, &(PVOID)PhysAddr)) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DEBUGMSG(ZONE_ERROR, (L"UHCD: Failed TransBusAddrToStatic "));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return FALSE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// Set up ISR handler
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Info.SysIntr = dii.dwSysintr;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Info.CheckPort = TRUE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Info.PortIsIO = (dwIOSpace) ? TRUE : FALSE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Info.UseMaskReg = TRUE;;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Info.PortAddr = PhysAddr + 0x2;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Info.PortSize = sizeof(WORD);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Info.MaskAddr = PhysAddr + 0x4;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (!KernelLibIoControl(pPddObject->IsrHandle, IOCTL_GIISR_INFO, &Info, sizeof(Info), NULL, 0, NULL)) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DEBUGMSG(ZONE_ERROR, (L"UHCD: KernelLibIoControl call failed. "));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// The PDD can supply a buffer of contiguous physical memory here, or can let the
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// MDD try to allocate the memory from system RAM. We will use the HalAllocateCommonBuffer()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// API to allocate the memory and bus controller physical addresses and pass this information
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// into the MDD.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (GetRegistryPhysicalMemSize(szDriverRegKey,&pPddObject->dwPhysicalMemSize)) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// A quarter for High priority Memory.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dwHPPhysicalMemSize = pPddObject->dwPhysicalMemSize/4;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// Align with page size.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->dwPhysicalMemSize = (pPddObject->dwPhysicalMemSize + PAGE_SIZE -1) & ~(PAGE_SIZE -1);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dwHPPhysicalMemSize = ((dwHPPhysicalMemSize + PAGE_SIZE -1) & ~(PAGE_SIZE -1));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
else ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->dwPhysicalMemSize=0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dwHPPhysicalMemSize = 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (pPddObject->dwPhysicalMemSize<gcTotalAvailablePhysicalMemory) ...{ // Setup Minimun requirement.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->dwPhysicalMemSize = gcTotalAvailablePhysicalMemory;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dwHPPhysicalMemSize = gcHighPriorityPhysicalMemory;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->AdapterObject.ObjectSize = sizeof(DMA_ADAPTER_OBJECT);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->AdapterObject.InterfaceType = dwi.dwInterfaceType;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->AdapterObject.BusNumber = dwi.dwBusNumber;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if ((pPddObject->pvVirtualAddress = HalAllocateCommonBuffer(&pPddObject->AdapterObject, pPddObject->dwPhysicalMemSize, &pPddObject->LogicalAddress, FALSE)) == NULL) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
goto InitializeUHCI_Error;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (!(pobMem = HcdMdd_CreateMemoryObject(pPddObject->dwPhysicalMemSize, dwHPPhysicalMemSize, (PUCHAR) pPddObject->pvVirtualAddress, (PUCHAR) pPddObject->LogicalAddress.LowPart))) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
goto InitializeUHCI_Error;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (!(pobUhcd = HcdMdd_CreateHcdObject(pPddObject, pobMem, szDriverRegKey, ioPortBase, dii.dwSysintr))) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
goto InitializeUHCI_Error;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// set LEGSUP here
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
LegSup = PCIConfig_ReadWord(dwi.dwBusNumber, dpi.dwDeviceNumber, dpi.dwFunctionNumber, 0xC0);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
RETAILMSG(1, (TEXT("UHCD: LEGSUP=0x%08x "), LegSup));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
LegSup = 0x2000;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PCIConfig_Write(dwi.dwBusNumber, dpi.dwDeviceNumber, dpi.dwFunctionNumber, 0xC0, LegSup, sizeof(LegSup));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->lpvMemoryObject = pobMem;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->lpvUhcdMddObject = pobUhcd;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_tcsncpy(pPddObject->szDriverRegKey, szDriverRegKey, MAX_PATH);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->ioPortBase = ioPortBase;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->dwSysIntr = dii.dwSysintr;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// PCI OHCI support suspend and resume
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if ( hKey!=NULL) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DWORD dwCapability;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DWORD dwType;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DWORD dwLength = sizeof(DWORD);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (RegQueryValueEx(hKey, HCD_CAPABILITY_VALNAME, 0, &dwType, (PUCHAR)&dwCapability, &dwLength) == ERROR_SUCCESS)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HcdMdd_SetCapability (pobUhcd,dwCapability);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
RegCloseKey(hKey);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return TRUE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
InitializeUHCI_Error:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (pPddObject->IsrHandle) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
FreeIntChainHandler(pPddObject->IsrHandle);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->IsrHandle = NULL;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (pobUhcd)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HcdMdd_DestroyHcdObject(pobUhcd);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (pobMem)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HcdMdd_DestroyMemoryObject(pobMem);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(pPddObject->pvVirtualAddress)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HalFreeCommonBuffer(&pPddObject->AdapterObject, pPddObject->dwPhysicalMemSize, pPddObject->LogicalAddress, pPddObject->pvVirtualAddress, FALSE);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->lpvMemoryObject = NULL;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->lpvUhcdMddObject = NULL;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->pvVirtualAddress = NULL;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if ( hKey!=NULL)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
RegCloseKey(hKey);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return FALSE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
简单的答案是,VMWare支持一些Virtual PC(包括Windows CE emulator)不支持的硬件。对我来说,最吸引我的是VMWare支持USB设备。另外根据我的经验VMWare的性能比Virtual PC强。
本文介绍如何针对VMWare支持的硬件,做一个相应的Windows CE BSP。根据VMWare虚拟机的spec,我打算支持的硬件列表如下(SCSI设备、软驱这些用的比较少就算了):
Graphics
•VGA and SVGA support
IDE Drives
•IDE virtual disks up to 950 GB
•Serial (COM) Ports
•Up to four serial (COM) ports
USB ports
•Two-port USB 1.1 UHCI controller
Keyboard
•104-key Windows 95/98 enhanced
Mouse and Drawing Tablets
•PS/2 mouse
Ethernet Card
•AMD PCnet-PCI II compatible
Sound
•Emulates Creative Labs Sound Blaster AudioPCI (MIDI input, game controllers and joysticks are not supported, except for USB devices)
其实从根本上来说,给VMWare用的Windows CE跟普通PC或者Virtual PC的并无多大区别。因此基本做法和一些概念都可以看MSDN里对CEPC的相关介绍。这里只重点介绍一些针对VMWare的不同地方。
给Windows CE用的VMWare虚拟机可以用DOS的。BSP可以直接copy一份Platform Builder带的CEPC BSP做为起始的BSP,然后在此基础上修改。从IDE硬盘、声卡、显卡、键盘鼠标的支持比较简单,用Platform Builder中现成的driver就行了。
比较麻烦的是网卡和USB host controller。
VMWare虚拟的网卡兼容AMD PCnet-PCI II,具体型号是AMD AM79C970A,这个在Windows CE下可实在不好找,自己写一个就太麻烦了。不过在google大法的强力帮助下,我花了很长时间终于找到一个编译好的driver-还是for Windows CE 2.0的(现在想不起来在哪儿找到的了,想要的直接找我吧)。相关注册表设置见附录。
比较头疼的是USB host driver。VMWare中支持的USB host controller是USB 1.1 UHCI controller。Windows CE下有现成的driver,但是直接拿来用的话你会发现不能工作。一番研究后发现问题出在LEGACY SUPPORT REGISTER (LEGSUP)的设置上-VMWare在初始化UHCI controller的时候enable了SMI generation,而且没有把USB中断route到PIRQD上。简单说来就是VMWare对UHCI controller的初始化和Windows CE自带driver要求的不一样(其实是和UHCI spec定义的不一致,UHCI spec定义LEGSUP寄存器默认值是2000h(见5.2.1节),VMWare中是3Bh)。为了能让UHCI controller工作,需要修改UHCI driver的初始化例程,重新编译一个版本。具体修改见附录。
这样,一个支持声卡、网卡、USB设备的VMWare BSP就基本搞定了。
附上两张运行时的截图:
附1,网卡的注册表设置,放在platform.reg里:
[HKEY_LOCAL_MACHINECommPCNTN4M]
"DisplayName"="PCNTN4M Compatible Ethernet Driver"
"Group"="NDIS"
"ImagePath"="pcntn4m.dll"
[HKEY_LOCAL_MACHINECommPCNTN4MLinkage]
"Route"=multi_sz:"PCNTN4M1"
[HKEY_LOCAL_MACHINECommPCNTN4M1]
"DisplayName"="PCNTN4M Compatible Ethernet Driver"
"Group"="NDIS"
"ImagePath"="pcntn4m.dll"
[HKEY_LOCAL_MACHINECommPCNTN4M1Parms]
; "BusNumber"=dword:0
; "BusType"=dword:05
; "Interrupt"=dword:05
; "IOAddress"=dword:0300
[HKEY_LOCAL_MACHINECommTcpipLinkage]
"Bind"=multi_sz:"ppp","PCNTN4M1"
; Registry values for the pcntn4m1 driver
[HKEY_LOCAL_MACHINECommPCNTN4M1ParmsTcpIp]
; This enable the DHCP. In Win CE 2.1 Preview version statically allocated IP address
; does not work. So we use the DHCP server to allocate the IP address.
"EnableDHCP"=dword:1
; This should be MULTI_SZ
"DefaultGateway"=""
; This should be SZ... If null it means use LAN, else WAN and Interface.
"LLInterface"=""
; Use zero for broadcast address? (or 255.255.255.255)
"UseZeroBroadcast"=dword:0
; Thus should be MULTI_SZ, the IP address list
"IpAddress"="0.0.0.0"
; This should be MULTI_SZ, the subnet masks for the above IP addresses
"Subnetmask"="0.0.0.0"
;
; Template the PCI bus driver uses to match a AM79C970 PC-net card
;
[HKEY_LOCAL_MACHINEDriversBuiltInPCITemplatePCNTN4M]
"Dll"="NDIS.dll"
"Class"=dword:02
"SubClass"=dword:00
"ProgIF"=dword:0
"VendorID"=multi_sz:"1022"
"DeviceID"=multi_sz:"2000"
; "Entry"="NdisPCIBusDeviceInit"
"Prefix"="NDS"
"Transceiver"=dword:3
"IsrDll"="giisr.dll"
"IsrHandler"="ISRHandler"
"PortIsIO"=dword:1
"PortOffset"=dword:C ; TBD
"PortSize"=dword:2
"PortMask"=dword:5F00 ; TBD
[HKEY_LOCAL_MACHINECommConnectionSharing]
"PrivateInterface"="PCI/PCNTN4M"
附2,UHCI driver需要修改的代码(红色部分,在$(DRIVERS)/USB/HCD/UHC/system.csystem.c中):
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
// Inline functions
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
__inline static WORD
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
PCIConfig_ReadWord(
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
ULONG BusNumber,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
ULONG Device,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
ULONG Function,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
ULONG Offset
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
WORD RetVal = 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PCI_SLOT_NUMBER SlotNumber;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SlotNumber.u.AsULONG = 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SlotNumber.u.bits.DeviceNumber = Device;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SlotNumber.u.bits.FunctionNumber = Function;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HalGetBusDataByOffset(PCIConfiguration, BusNumber, SlotNumber.u.AsULONG, &RetVal, Offset, sizeof(RetVal));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return RetVal;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
__inline static void
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
PCIConfig_Write(
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
ULONG BusNumber,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
ULONG Device,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
ULONG Function,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
ULONG Offset,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
ULONG Value,
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
ULONG Size
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PCI_SLOT_NUMBER SlotNumber;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SlotNumber.u.AsULONG = 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SlotNumber.u.bits.DeviceNumber = Device;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
SlotNumber.u.bits.FunctionNumber = Function;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HalSetBusDataByOffset(PCIConfiguration, BusNumber, SlotNumber.u.AsULONG, &Value, Offset, Size);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
/**//* InitializeUHCI
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Configure and initialize UHCI card
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
*
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Return Value:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
* Return TRUE if card could be located and configured, otherwise FALSE
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
*/
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
static BOOL
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
InitializeUHCI(
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
SUhcdPdd * pPddObject, // IN - Pointer to PDD structure
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
LPCWSTR szDriverRegKey) // IN - Pointer to active registry key string
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PUCHAR ioPortBase = NULL;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DWORD dwAddrLen;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DWORD dwIOSpace;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
BOOL InstallIsr = FALSE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
BOOL fResult = FALSE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
LPVOID pobMem = NULL;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
LPVOID pobUhcd = NULL;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DWORD PhysAddr;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DWORD dwHPPhysicalMemSize;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HKEY hKey;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
WORD LegSup;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DDKWINDOWINFO dwi;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DDKISRINFO dii;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DDKPCIINFO dpi;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,szDriverRegKey,0,0,&hKey)!= ERROR_SUCCESS) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DEBUGMSG(ZONE_ERROR,(TEXT("InitializeUHCI:GetRegistryConfig RegOpenKeyEx(%s) failed "),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
szDriverRegKey));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return FALSE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dwi.cbSize=sizeof(dwi);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dii.cbSize=sizeof(dii);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dpi.cbSize=sizeof(dpi);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if ( DDKReg_GetWindowInfo(hKey, &dwi ) !=ERROR_SUCCESS ||
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DDKReg_GetIsrInfo (hKey, &dii ) != ERROR_SUCCESS ||
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
DDKReg_GetPciInfo (hKey, &dpi ) != ERROR_SUCCESS) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DEBUGMSG(ZONE_ERROR,(TEXT("InitializeUHCI:DDKReg_GetWindowInfo or DDKReg_GetWindowInfo or DDKReg_GetPciInfo failed ")));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
goto InitializeUHCI_Error;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (dwi.dwNumMemWindows!=0) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PhysAddr = dwi.memWindows[0].dwBase;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dwAddrLen= dwi.memWindows[0].dwLen;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dwIOSpace = 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
else if (dwi.dwNumIoWindows!=0) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PhysAddr= dwi.ioWindows[0].dwBase;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dwAddrLen = dwi.ioWindows[0].dwLen;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dwIOSpace = 1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
else
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
goto InitializeUHCI_Error;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DEBUGMSG(ZONE_INIT,(TEXT("UHCD: Read config from registry: Base Address: 0x%X, Length: 0x%X, I/O Port: %s, SysIntr: 0x%X, Interface Type: %u, Bus Number: %u "),
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PhysAddr, dwAddrLen, dwIOSpace ? L"YES" : L"NO", dii.dwSysintr, dwi.dwInterfaceType, dwi.dwBusNumber));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
ioPortBase = (PUCHAR)PhysAddr;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (!(fResult = ConfigureUHCICard(pPddObject, &ioPortBase, dwAddrLen, dwIOSpace, dwi.dwInterfaceType, dwi.dwBusNumber))) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
goto InitializeUHCI_Error;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (dii.szIsrDll[0] != 0 && dii.szIsrHandler[0]!=0 && dii.dwIrq<0xff && dii.dwIrq>0 ) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// Install ISR handler
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->IsrHandle = LoadIntChainHandler(dii.szIsrDll,dii.szIsrHandler, (BYTE)dii.dwIrq);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (!pPddObject->IsrHandle) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DEBUGMSG(ZONE_ERROR, (L"UHCD: Couldn't install ISR handler "));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
} else ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
GIISR_INFO Info;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
PHYSICAL_ADDRESS PortAddress = ...{PhysAddr, 0};
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DEBUGMSG(ZONE_INIT, (L"UHCD: Installed ISR handler, Dll = '%s', Handler = '%s', Irq = %d ",
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dii.szIsrDll, dii.szIsrHandler, dii.dwIrq));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (!BusTransBusAddrToStatic(pPddObject->hParentBusHandle,dwi.dwInterfaceType, dwi.dwBusNumber, PortAddress, dwAddrLen, &dwIOSpace, &(PVOID)PhysAddr)) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DEBUGMSG(ZONE_ERROR, (L"UHCD: Failed TransBusAddrToStatic "));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return FALSE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// Set up ISR handler
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Info.SysIntr = dii.dwSysintr;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Info.CheckPort = TRUE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Info.PortIsIO = (dwIOSpace) ? TRUE : FALSE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Info.UseMaskReg = TRUE;;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Info.PortAddr = PhysAddr + 0x2;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Info.PortSize = sizeof(WORD);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
Info.MaskAddr = PhysAddr + 0x4;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (!KernelLibIoControl(pPddObject->IsrHandle, IOCTL_GIISR_INFO, &Info, sizeof(Info), NULL, 0, NULL)) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DEBUGMSG(ZONE_ERROR, (L"UHCD: KernelLibIoControl call failed. "));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// The PDD can supply a buffer of contiguous physical memory here, or can let the
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// MDD try to allocate the memory from system RAM. We will use the HalAllocateCommonBuffer()
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// API to allocate the memory and bus controller physical addresses and pass this information
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// into the MDD.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (GetRegistryPhysicalMemSize(szDriverRegKey,&pPddObject->dwPhysicalMemSize)) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// A quarter for High priority Memory.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dwHPPhysicalMemSize = pPddObject->dwPhysicalMemSize/4;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// Align with page size.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->dwPhysicalMemSize = (pPddObject->dwPhysicalMemSize + PAGE_SIZE -1) & ~(PAGE_SIZE -1);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dwHPPhysicalMemSize = ((dwHPPhysicalMemSize + PAGE_SIZE -1) & ~(PAGE_SIZE -1));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
else ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->dwPhysicalMemSize=0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dwHPPhysicalMemSize = 0;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (pPddObject->dwPhysicalMemSize<gcTotalAvailablePhysicalMemory) ...{ // Setup Minimun requirement.
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->dwPhysicalMemSize = gcTotalAvailablePhysicalMemory;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
dwHPPhysicalMemSize = gcHighPriorityPhysicalMemory;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->AdapterObject.ObjectSize = sizeof(DMA_ADAPTER_OBJECT);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->AdapterObject.InterfaceType = dwi.dwInterfaceType;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->AdapterObject.BusNumber = dwi.dwBusNumber;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if ((pPddObject->pvVirtualAddress = HalAllocateCommonBuffer(&pPddObject->AdapterObject, pPddObject->dwPhysicalMemSize, &pPddObject->LogicalAddress, FALSE)) == NULL) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
goto InitializeUHCI_Error;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (!(pobMem = HcdMdd_CreateMemoryObject(pPddObject->dwPhysicalMemSize, dwHPPhysicalMemSize, (PUCHAR) pPddObject->pvVirtualAddress, (PUCHAR) pPddObject->LogicalAddress.LowPart))) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
goto InitializeUHCI_Error;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (!(pobUhcd = HcdMdd_CreateHcdObject(pPddObject, pobMem, szDriverRegKey, ioPortBase, dii.dwSysintr))) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
goto InitializeUHCI_Error;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// set LEGSUP here
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
LegSup = PCIConfig_ReadWord(dwi.dwBusNumber, dpi.dwDeviceNumber, dpi.dwFunctionNumber, 0xC0);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
RETAILMSG(1, (TEXT("UHCD: LEGSUP=0x%08x "), LegSup));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
LegSup = 0x2000;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
PCIConfig_Write(dwi.dwBusNumber, dpi.dwDeviceNumber, dpi.dwFunctionNumber, 0xC0, LegSup, sizeof(LegSup));
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->lpvMemoryObject = pobMem;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->lpvUhcdMddObject = pobUhcd;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
_tcsncpy(pPddObject->szDriverRegKey, szDriverRegKey, MAX_PATH);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->ioPortBase = ioPortBase;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->dwSysIntr = dii.dwSysintr;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
// PCI OHCI support suspend and resume
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if ( hKey!=NULL) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DWORD dwCapability;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DWORD dwType;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
DWORD dwLength = sizeof(DWORD);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (RegQueryValueEx(hKey, HCD_CAPABILITY_VALNAME, 0, &dwType, (PUCHAR)&dwCapability, &dwLength) == ERROR_SUCCESS)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HcdMdd_SetCapability (pobUhcd,dwCapability);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
RegCloseKey(hKey);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return TRUE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
InitializeUHCI_Error:
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (pPddObject->IsrHandle) ...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
FreeIntChainHandler(pPddObject->IsrHandle);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->IsrHandle = NULL;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (pobUhcd)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HcdMdd_DestroyHcdObject(pobUhcd);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if (pobMem)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HcdMdd_DestroyMemoryObject(pobMem);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(pPddObject->pvVirtualAddress)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
HalFreeCommonBuffer(&pPddObject->AdapterObject, pPddObject->dwPhysicalMemSize, pPddObject->LogicalAddress, pPddObject->pvVirtualAddress, FALSE);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->lpvMemoryObject = NULL;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->lpvUhcdMddObject = NULL;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
pPddObject->pvVirtualAddress = NULL;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if ( hKey!=NULL)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
RegCloseKey(hKey);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
return FALSE;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
相关文章推荐
- 如何制作支持VMWare的Windows CE BSP
- 如何在VMware中安装Windows Phone SDK 8.0 (支持模拟器调试)
- 如何在VMware中安装Windows Phone SDK 8.0 (支持模拟器调试)
- 如何制作支持VMWare的Windows CE BSP2
- 如何在VMware中安装Windows Phone SDK 8.0 (支持模拟器调试)
- VMware下的Linux系统中Windows的共享目录,不支持创建软连接
- 如何制作支持softfloat的ARM交叉编译器
- 在Windows的CMD中如何设置支持UTF8编码?
- 关于Windows下如何制作U盘启动盘
- Visual Studio 2010编译的C++程序如何支持Windows 2000
- vmware + opensuse windows如何远程登录到suse上
- 在Windows Mobile和Wince(Windows Embedded CE)下如何使用.NET Compact Framework开发进程管理程序
- 如何制作windows登陆窗口??
- 在Windows的CMD中如何设置支持UTF8编码?
- 如何在Vmware 中运行windows embedded standard 7
- 如何制作Windows Service的安装包
- 如何在windows下制作ubuntu12.04desktop的U盘安装盘
- 如何制作自己的Windows Service Pack
- Windows 7如何增强支持无线USB和蓝牙
- windows 2003 sp2 支持IIS+PHP+MYSQL+PHPmyadmin如何设置