本文共 1383 字,大约阅读时间需要 4 分钟。
前面遇到过一个问题, USB HUB上只能接入有限的设备, 情况描述为:
HUB上接入两个U盘,后插入的会失败于建立第二个端偶的PIPE, Debug Message显示为
-CphysMem AllocateMemory: No memory available
-TDQueue: TDQueue - no memory for TD List -CBulkPipe::OpenPipe - no memory for TD问题位于 driver\ohcd2\Transfer.cpp line 298 TDQueue::QueueInit(). 再进一步, hcd\common\cphysmem.cpp的函数FindFreeBlock在while循环中失败
详细记录表面现象为:
BOT + CBIT OK BOT + BOT OK BOT + BOT + MOUSE OK BOT + BOT + MOUSE + KBD KBD失败 BOT + CBIT + MOUSE MOUSE失败 CBIT + CBIT 后面一个CBIT失败很明显是内存分配出问题了, 我在新闻组上征求意见, Bruce Eitman (eMVP) 答复如下:
CPhysMem manages a pool of memory for use within the USB Host driver, Allocations from that pool can fail if there simply isn't enough memory to allocate or if it is fragmented. You can set the amount of memory available by changing the amout requested in calls to it's constructor 里面提到了constructor, 我查到usb host 初次调用CPhysMem时, 几种内存情况为: Total Alloc Region size = 64K Special Alloc REgion size = 4K HighPri Alloc Region size = 16K Normal Alloc Region size = 44K 调用路线: SOhcdPdd::InitializeOHCI (bul_ohci.cpp) -> HcdMdd_CreateMemoryObject (Hcddriv.cpp)所以修改点在bul_ohci.cpp开头的两个全局变量上
gc_TotalAvailablePhysicalMemory gcHighPriorityPhysicalMemory 修改后问题果然解决. 使用时故意看了一下各种USB设备占用的内存量: Logitech MOU : 4928 byte CBIT U盘 : 20736 byte BOT U盘: 14944 byte Delux USB KBD: 7776 byte本文转自Walzer博客园博客,原文链接:http://www.cnblogs.com/walzer/archive/2006/02/05/325606.html,如需转载请自行联系原作者