wince设备枚举错误

devilgavin 2011-08-26 10:26:07
在Wince下,调试驱动时发现这样的错误,造成串口驱动没有加载上:
DEVICE!RegReadActivationValues RegQueryValueEx(Drivers\BuiltIn\Serial\DllName) returned 2
DEVICE!I_ActivateDeviceEx: can't find all required activation values in 'Drivers\BuiltIn\Serial'

有遇到过这样的问题么,请给指导下。
...全文
98 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
devilgavin 2011-08-29
  • 打赏
  • 举报
回复
又在设备上做了测试,串口驱动已经加载了,uart1也能正常工作,但在系统初始化时,总是报这个错误。没有找到具体原因。
devilgavin 2011-08-29
  • 打赏
  • 举报
回复
[Quote=引用 10 楼 paul_chao 的回复:]

麻煩 LZ 將 %_FLATRELEASEDIR%\reginit.ini 中, [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial] 也貼出來, 應該就可以看出端倪了

Paul, Chao @ Techware
[/Quote]
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial]
"Dll"="zylonite_serial.dll"
"Irq"=dword:16
"SysIntr"=dword:1d
"MemBase"=dword:40100000
"MemLen"=dword:40
"DeviceArrayIndex"=dword:80
"Prefix"="COM"
"Order"=dword:3 ; make sure it is loaded afer IPM
"Flags"=dword:0
"Index"=dword:1
"32BitBus"=dword:1
"AutoFlowControl"=dword:0 ; 0=no auto flow, 1=half auto flow, 2=full auto flow
"RxBufferSize"=dword:2048
"DebugMask"=dword:3
;"EnableDMA"=dword:0
"IClass"=multi_sz:"{CC5195AC-BA49-48a0-BE17-DF6D1B0173DD}",
"{A32942B7-920C-486b-B0E6-92A702A99B35}"
这个是reginit.ini文件,没有看出有什么区别啊。
woshi_ziyu 2011-08-27
  • 打赏
  • 举报
回复
Serial Port Driver Registry Settings
http://msdn.microsoft.com/en-us/library/ms894017.aspx
woshi_ziyu 2011-08-27
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 northcan 的回复:]

这块是device.dll调用busnum.dll
busnum.dll在调用RegQueryValueEx查询Serial驱动的dll名称时没查到
RegQueryValueEx(Drivers\BuiltIn\Serial\DllName)
记得驱动里面都是Dll键值是记录流驱动dll名称的
会不会是wince7去读的键是DllName而不是Dll
把Serial注册表的Dll修……
[/Quote]
++
northcan 2011-08-26
  • 打赏
  • 举报
回复
这块是device.dll调用busnum.dll
busnum.dll在调用RegQueryValueEx查询Serial驱动的dll名称时没查到
RegQueryValueEx(Drivers\BuiltIn\Serial\DllName)
记得驱动里面都是Dll键值是记录流驱动dll名称的
会不会是wince7去读的键是DllName而不是Dll
把Serial注册表的Dll修改为DllName试试呢?
paul_chao 2011-08-26
  • 打赏
  • 举报
回复
麻煩 LZ 將 %_FLATRELEASEDIR%\reginit.ini 中, [HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial] 也貼出來, 應該就可以看出端倪了

Paul, Chao @ Techware
devilgavin 2011-08-26
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 chenxwzcc 的回复:]

看看注册表有没有配置正确。
[/Quote]
没有修注册表,这个注册表在CE6下运行正常,在CE7下,就不正常。
猫xiaowai 2011-08-26
  • 打赏
  • 举报
回复
看看注册表有没有配置正确。
devilgavin 2011-08-26
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 llxxhm 的回复:]

楼主的注册表配错了
[/Quote]
请问,具体哪个参数错了?
QQ515311445 2011-08-26
  • 打赏
  • 举报
回复
楼主的注册表配错了
devilgavin 2011-08-26
  • 打赏
  • 举报
回复
我贴出的代码是从wince7中private路径 下复制出来的,应该没问题啊。
liutao66606 2011-08-26
  • 打赏
  • 举报
回复
#define DEVLOAD_DLLNAME_VALNAME TEXT("Dll") // DLL name (required)
const TCHAR s_DllName_ValName[] = DEVLOAD_DLLNAME_VALNAME;
DWORD
RegReadActivationValues(LPCWSTR RegPath, pRegActivationValues_t pav)
{
HKEY DevKey = NULL;
DWORD status;
DWORD ValLen;
DWORD ValType;

DEBUGCHK(RegPath != NULL);
DEBUGCHK(pav != NULL);

// Get the required (dll) and optional (prefix, index, flags, and context) values.
status = RegOpenKeyEx(
HKEY_LOCAL_MACHINE,
RegPath,
0,
KEY_READ,
&DevKey);
if (status) {
DEBUGMSG(ZONE_ACTIVE|ZONE_ERROR,
(TEXT("DEVICE!RegReadActivationValues RegOpenKeyEx(%s) returned %d.\r\n"),
RegPath, status));
goto done;
}

// Read DLL name
ValLen = sizeof(pav->DevDll);
status = RegQueryValueEx(
DevKey,
s_DllName_ValName,
NULL,
&ValType,
(PUCHAR)pav->DevDll,
&ValLen);
if (status != ERROR_SUCCESS) {
DEBUGMSG(ZONE_ACTIVE|ZONE_ERROR,
(TEXT("DEVICE!RegReadActivationValues RegQueryValueEx(%s\\DllName) returned %d\r\n"),
RegPath, status));
goto done;

}
pav->DevDll[_countof(pav->DevDll) - 1] = 0; // enforce null termination

// Read Flags value, if it exists.
ValLen = sizeof(pav->Flags);
status = RegQueryValueEx(
DevKey,
DEVLOAD_FLAGS_VALNAME,
NULL,
&ValType,
(PUCHAR)&pav->Flags,
&ValLen);
if (status != ERROR_SUCCESS) {
DEBUGMSG(ZONE_ACTIVE,
(TEXT("DEVICE!RegReadActivationValues RegQueryValueEx(%s\\Flags) returned %d\r\n"),
RegPath, status));
pav->Flags = DEVFLAGS_NONE; // default is no flags set
}

// Read prefix value, if it exists.
devilgavin 2011-08-26
  • 打赏
  • 举报
回复
以下是代码:
#define DEVLOAD_DLLNAME_VALNAME TEXT("Dll") // DLL name (required)
const TCHAR s_DllName_ValName[] = DEVLOAD_DLLNAME_VALNAME;
DWORD
RegReadActivationValues(LPCWSTR RegPath, pRegActivationValues_t pav)
{
HKEY DevKey = NULL;
DWORD status;
DWORD ValLen;
DWORD ValType;

DEBUGCHK(RegPath != NULL);
DEBUGCHK(pav != NULL);

// Get the required (dll) and optional (prefix, index, flags, and context) values.
status = RegOpenKeyEx(
HKEY_LOCAL_MACHINE,
RegPath,
0,
KEY_READ,
&DevKey);
if (status) {
DEBUGMSG(ZONE_ACTIVE|ZONE_ERROR,
(TEXT("DEVICE!RegReadActivationValues RegOpenKeyEx(%s) returned %d.\r\n"),
RegPath, status));
goto done;
}

// Read DLL name
ValLen = sizeof(pav->DevDll);
status = RegQueryValueEx(
DevKey,
s_DllName_ValName,
NULL,
&ValType,
(PUCHAR)pav->DevDll,
&ValLen);
if (status != ERROR_SUCCESS) {
DEBUGMSG(ZONE_ACTIVE|ZONE_ERROR,
(TEXT("DEVICE!RegReadActivationValues RegQueryValueEx(%s\\DllName) returned %d\r\n"),
RegPath, status));
goto done;

}
pav->DevDll[_countof(pav->DevDll) - 1] = 0; // enforce null termination

// Read Flags value, if it exists.
ValLen = sizeof(pav->Flags);
status = RegQueryValueEx(
DevKey,
DEVLOAD_FLAGS_VALNAME,
NULL,
&ValType,
(PUCHAR)&pav->Flags,
&ValLen);
if (status != ERROR_SUCCESS) {
DEBUGMSG(ZONE_ACTIVE,
(TEXT("DEVICE!RegReadActivationValues RegQueryValueEx(%s\\Flags) returned %d\r\n"),
RegPath, status));
pav->Flags = DEVFLAGS_NONE; // default is no flags set
}

// Read prefix value, if it exists.
ValLen = sizeof(pav->Prefix);
status = RegQueryValueEx(
DevKey,
DEVLOAD_PREFIX_VALNAME,
NULL,
&ValType,
(PUCHAR)pav->Prefix,
&ValLen);
if (status != ERROR_SUCCESS) {
DEBUGMSG(ZONE_ACTIVE || ZONE_WARNING,
(TEXT("DEVICE!RegReadActivationValues RegQueryValueEx(%s\\Prefix) returned %d\r\n"),
RegPath, status));
pav->Prefix[0] = 0;
} else {
size_t cchPrefix = 0;
VERIFY(SUCCEEDED(StringCchLength(pav->Prefix, _countof(pav->Prefix), &cchPrefix)));
if(pav->Prefix[_countof(pav->Prefix) - 1] != 0
|| (cchPrefix != PREFIX_CHARS && wcslen(pav->Prefix) != 0)) {
DEBUGMSG(ZONE_ACTIVE,
(TEXT("DEVICE!RegReadActivationValues: ignoring invalid Prefix in (%s)\r\n"),
RegPath));
pav->Prefix[0] = 0;
}
}
pav->Prefix[_countof(pav->Prefix) - 1] = 0; // enforce null termination

// Read bus prefix value, if it exists.
ValLen = sizeof(pav->BusPrefix);
status = RegQueryValueEx(
DevKey,
DEVLOAD_BUSPREFIX_VALNAME,
NULL,
&ValType,
(PUCHAR)pav->BusPrefix,
&ValLen);
if (status != ERROR_SUCCESS) {
DEBUGMSG(ZONE_ACTIVE || ZONE_WARNING,
(TEXT("DEVICE!RegReadActivationValues RegQueryValueEx(%s\\BusPrefix) returned %d\r\n"),
RegPath, status));
pav->BusPrefix[0] = 0;
} else {
size_t cchBusPrefix = 0;
VERIFY(SUCCEEDED(StringCchLength(pav->BusPrefix, _countof(pav->BusPrefix), &cchBusPrefix)));
if(pav->BusPrefix[_countof(pav->BusPrefix) - 1] != 0
|| (cchBusPrefix != PREFIX_CHARS && wcslen(pav->BusPrefix) != 0)) {
DEBUGMSG(ZONE_ACTIVE || ZONE_WARNING,
(TEXT("DEVICE!RegReadActivationValues: ignoring invalid BusPrefix in (%s)\r\n"),
RegPath));
pav->BusPrefix[0] = 0;
} else if(pav->Prefix[0] != 0 && wcsicmp(pav->Prefix, pav->BusPrefix) != 0) {
DEBUGMSG(ZONE_ACTIVE || ZONE_ERROR,
(TEXT("DEVICE!RegReadActivationValues: prefix '%s' mismatch with bus prefix '%s' in (%s)\r\n"),
pav->Prefix, pav->BusPrefix, RegPath));
status = ERROR_INVALID_PARAMETER;
goto done;
}
}
pav->BusPrefix[_countof(pav->BusPrefix) - 1] = 0; // enforce null termination

// Read the optional index and context values
ValLen = sizeof(pav->Index);
status = RegQueryValueEx(
DevKey,
DEVLOAD_INDEX_VALNAME,
NULL,
&ValType,
(PUCHAR)&pav->Index,
&ValLen);
if (status != ERROR_SUCCESS) {
DEBUGMSG(ZONE_ACTIVE,
(TEXT("DEVICE!RegReadActivationValues RegQueryValueEx(%s\\Index) returned %d\r\n"),
RegPath, status));
pav->Index = (DWORD)-1; // devload will find an index to use
}

// Read the Context value, if it exists. If present, the Context overrides
// the default behavior of passing the device a pointer to its activation
// key.
ValLen = sizeof(pav->Context);
status = RegQueryValueEx(
DevKey,
DEVLOAD_CONTEXT_VALNAME,
NULL,
&ValType,
(PUCHAR)&pav->Context,
&ValLen);
if (status != ERROR_SUCCESS) {
DEBUGMSG(ZONE_ACTIVE,
(TEXT("DEVICE!RegReadActivationValues RegQueryValueEx(%s\\Context) returned %d\r\n"),
RegPath, status));
pav->bOverrideContext = FALSE; // context is pointer to active reg path string
} else {
pav->bOverrideContext = TRUE;
}

pav->bHasPostInitCode = FALSE;
pav->bHasBusPostInitCode = FALSE;
if (pav->Prefix[0] != 0) {
// Determine whether this device wants a post init ioctl -- only
// drivers which can be accessed via DeviceIoControl() can get these,
// so we check for the presence of a prefix.
ValLen = sizeof(pav->PostInitCode);
status = RegQueryValueEx(
DevKey,
DEVLOAD_INITCODE_VALNAME,
NULL,
&ValType,
(PUCHAR)&pav->PostInitCode,
&ValLen);
if (status != ERROR_SUCCESS) {
DEBUGMSG(ZONE_ACTIVE,
(TEXT("DEVICE!RegReadActivationValues RegQueryValueEx(%s\\InitCode) returned %d\r\n"),
RegPath, status));
} else {
pav->bHasPostInitCode = TRUE;
}
}
// BusPostInitCode we get will be check later agains wheter this has bus name or not.
ValLen = sizeof(pav->BusPostInitCode);
status = RegQueryValueEx(
DevKey,
DEVLOAD_BUSINITCODE_VALNAME,
NULL,
&ValType,
(PUCHAR)&pav->BusPostInitCode,
&ValLen);
if (status != ERROR_SUCCESS) {
DEBUGMSG(ZONE_ACTIVE,
(TEXT("DEVICE!RegReadActivationValues RegQueryValueEx(%s\\BusInitCode) returned %d\r\n"),
RegPath, status));
} else {
pav->bHasBusPostInitCode = TRUE;
}

ValLen = sizeof(pav->AccountId);
status = RegQueryValueEx(
DevKey,
DEVLOAD_USERACCOUNTSID_VALNAME,
NULL,
&ValType,
(PUCHAR)&pav->AccountId,
&ValLen);
if (status != ERROR_SUCCESS) {
DEBUGMSG(ZONE_ACTIVE,
(TEXT("DEVICE!RegReadActivationValues RegQueryValueEx(%s\\AccountId) returned %d\r\n"),
RegPath, status));
pav->AccountId[0] = 0;
} else {
pav->AccountId[_countof(pav->AccountId)-1] = 0;
}

ValLen = sizeof(pav->Filter);
status = RegQueryValueEx(
DevKey,
DEVLOAD_FILTER_VALNAME,
NULL,
&ValType,
(PUCHAR)pav->Filter,
&ValLen);
if (status != ERROR_SUCCESS || (ValType!=REG_MULTI_SZ && ValType!=REG_SZ) ) {
DEBUGMSG(ZONE_ACTIVE || ZONE_WARNING,
(TEXT("DEVICE!RegReadActivationValues RegQueryValueEx(%s\\Prefix) returned %d\r\n"),
RegPath, status));
pav->Filter[0] = 0;
pav->Filter[1] = 0;
} else {
pav->Filter[_countof(pav->Filter) - 1]=0;
pav->Filter[_countof(pav->Filter) - 2]=0;
}
if (IsServicesRegKey(RegPath)) {
// Legacy services may not have set this flag, so explicitly set it.
pav->Flags |= DEVFLAGS_LOAD_AS_USERPROC;

if (pav->bOverrideContext) {
// Legacy services may set "Context", since in pre CE 6.0 days
// this is how DWORD parameters were communicated. This causes
// all sorts of problems now that services.exe is effectively
// hosted by udevice.exe, where Context has to do with registry key
// and not DWORD. This needs to be "ServiceContext" now.

RETAILMSG(1,(L"SERVICES: Configuration error for %s. Rename \"Context\" registry key to \"ServiceContext\"\r\n",RegPath));
DEBUGCHK(0);

if (pav->Context == 0) {
// If Context=0 (%99 case), we can allow service to continue
// to startup (because this is same as setting ServiceContext=0).
// This helps with BC.
pav->bOverrideContext = FALSE;
}
else {
// Otherwise service will be badly broken - force it to be fixed.
status = ERROR_INVALID_PARAMETER;
goto done;
}
}
}

// if we got here with no errors, return success
status = ERROR_SUCCESS;

done:
// release resources
if (DevKey) {
RegCloseKey(DevKey);
}

return status;
}
从代码上看不到有什么问题,其它的驱动也是通过这种方法加载的。只在加载serial时出错。
devilgavin 2011-08-26
  • 打赏
  • 举报
回复
以下是注册表内容:
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Serial]
"Dll"="$(_TGTPLAT_PFX)_serial.dll"
"Irq"=dword:16
"SysIntr"=dword:1d
"MemBase"=dword:40100000
"MemLen"=dword:40
"DeviceArrayIndex"=dword:80
"Prefix"="COM"
"Order"=dword:3 ; make sure it is loaded afer IPM
"Flags"=dword:0
"Index"=dword:1
"32BitBus"=dword:1
;"EnableDMA"=dword:0
"AutoFlowControl"=dword:0 ; 0=no auto flow, 1=half auto flow, 2=full auto flow
"RxBufferSize"=dword:2048
"DebugMask"=dword:3
"IClass"=multi_sz:"{CC5195AC-BA49-48a0-BE17-DF6D1B0173DD}",
"{A32942B7-920C-486b-B0E6-92A702A99B35}"

19,502

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 嵌入开发(WinCE)
社区管理员
  • 嵌入开发(WinCE)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧