drvfan
驱动牛犊
驱动牛犊
  • 注册日期2001-07-28
  • 最后登录2011-10-18
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1458回复:0

NdisMAllocateSharedMemory()调用失败,为什么?

楼主#
更多 发布于:2004-03-06 09:55
//
// Set the attributes now. The NDIS_ATTRIBUTE_DESERIALIZE is the key. This enables us
// to make up-calls to NDIS w/o having to call NdisIMSwitchToMiniport/NdisIMQueueCallBack.
// This also forces us to protect our data using spinlocks where appropriate. Also in this
// case NDIS does not queue packets on out behalf. Since this is a very simple pass-thru
// miniport, we do not have a need to protect anything. However in a general case there
// will be a need to use per-adapter spin-locks for the packet queues at the very least.
//
NdisMSetAttributesEx(MiniportAdapterHandle,
pAdapt,
0, // CheckForHangTimeInSeconds
NDIS_ATTRIBUTE_IGNORE_PACKET_TIMEOUT |
NDIS_ATTRIBUTE_IGNORE_REQUEST_TIMEOUT|
NDIS_ATTRIBUTE_INTERMEDIATE_DRIVER |
NDIS_ATTRIBUTE_DESERIALIZE |
NDIS_ATTRIBUTE_NO_HALT_ON_SUSPEND,
0);


pAdapt->SharedMemorySize = 1024 * 4;  // Fix, should get from registry.

if (pAdapt->SharedMemorySize)
{
NdisMAllocateSharedMemory(
pAdapt->NdisBindingContextFromProtocol,//输入是正确的
           pAdapt->SharedMemorySize,
                        TRUE,//FALSE,
                        &pAdapt->SharedMemoryPtr,
                        &pAdapt->SharedMemoryPhysicalAddress
                        );
if (pAdapt->SharedMemoryPtr == NULL)
{
DBG_PRINT(("!!!!! Could not allocate shared memory.\n"););  
pAdapt->SharedMemorySize = 0;
}
else
{
NdisZeroMemory(pAdapt->SharedMemoryPtr,
                          pAdapt->SharedMemorySize);
}
}



在一个中间层驱动中调用,在小端口驱动程序的初始化部分调用!
游客

返回顶部