阅读:1439回复:0
Ndis miniport 驱动程序的初始化问题
请问各位:
本人在Win2000下编写一个ISA接口(非PNP)的网卡驱动程序时,安装后进行初始化时,驱动程序不能成功的映射指定I/O端口(0x300),采用的调用是: NdisMRegisterIoPortRange或NdisMMapIoSpace都试过,返回错误STATUS_UNSUCCESSFUL,而且之前也调用了NdisMSetAttributes设置总线接口类型为ISA。代码如下: NDIS_STATUS CardInitialize( IN PCARD_OBJECT pCard // @parm // A pointer to the <t CARD_OBJECT> returned by <f CardCreate>. ) { DBG_FUNC(\"CardInitialize\") int num_dial_chan = 0; int num_sync_chan = 0; // The number of channels supported by card is based on InterfaceType. NDIS_STATUS Result = NDIS_STATUS_SUCCESS; // Holds the result code returned by this function. PMINIPORT_ADAPTER_OBJECT pAdapter; // A pointer to the <t MINIPORT_ADAPTER_OBJECT>. ASSERT(pCard && pCard->ObjectType == CARD_OBJECT_TYPE); pAdapter = GET_ADAPTER_FROM_CARD(pCard); DBG_ENTER(pAdapter); /* // Inform the wrapper of the physical attributes of this adapter. // This must be called before any NdisMRegister functions! // This call also associates the MiniportAdapterHandle with this pAdapter. */ NdisMSetAttributes(pAdapter->MiniportAdapterHandle, (NDIS_HANDLE) pAdapter, pCard->ResourceInformation.Master, pCard->ResourceInformation.BusInterfaceType ); #if defined(CARD_MIN_IOPORT_SIZE) if (Result == NDIS_STATUS_SUCCESS && pCard->ResourceInformation.IoPortLength) { /* Result = NdisMRegisterIoPortRange( &pCard->pIoPortVirtualAddress, pAdapter->MiniportAdapterHandle, pCard->ResourceInformation.IoPortPhysicalAddress.LowPart, pCard->ResourceInformation.IoPortLength); */ Result = NdisMMapIoSpace( &pCard->pIoPortVirtualAddress, pAdapter->MiniportAdapterHandle, pCard->ResourceInformation.IoPortPhysicalAddress, pCard->ResourceInformation.IoPortLength); //Result == STATUS_UNSUCCESSFUL ; if (Result != NDIS_STATUS_SUCCESS) { DBG_PRINT( (\"NdisMRegisterIoPortRange(0x%X,0x%X) Result=0x%X\\n\", pCard->ResourceInformation.IoPortPhysicalAddress.LowPart, pCard->ResourceInformation.IoPortLength, Result) ); DBG_ERROR(pAdapter,(\"NdisMRegisterIoPortRange(0x%X,0x%X) Result=0x%X\\n\", pCard->ResourceInformation.IoPortPhysicalAddress.LowPart, pCard->ResourceInformation.IoPortLength, Result)); NdisWriteErrorLogEntry( pAdapter->MiniportAdapterHandle, NDIS_ERROR_CODE_RESOURCE_CONFLICT, 5, pCard->ResourceInformation.IoPortPhysicalAddress.LowPart, pCard->ResourceInformation.IoPortLength, Result, __FILEID__, __LINE__ ); } else { DBG_NOTICE(pAdapter,(\"NdisMRegisterIoPortRange(0x%X,0x%X) VirtualAddress=0x%X\\n\", pCard->ResourceInformation.IoPortPhysicalAddress.LowPart, pCard->ResourceInformation.IoPortLength, pCard->pIoPortVirtualAddress)); } } #endif // CARD_MIN_IOPORT_SIZE #if defined(CARD_REQUEST_ISR) if (Result == NDIS_STATUS_SUCCESS && pCard->ResourceInformation.InterruptVector) { ASSERT(pCard->ResourceInformation.InterruptShared == FALSE || (pCard->ResourceInformation.InterruptMode == NdisInterruptLevelSensitive && CARD_REQUEST_ISR == TRUE)); Result = NdisMRegisterInterrupt( &pCard->Interrupt, pAdapter->MiniportAdapterHandle, pCard->ResourceInformation.InterruptVector, pCard->ResourceInformation.InterruptLevel, CARD_REQUEST_ISR, pCard->ResourceInformation.InterruptShared, pCard->ResourceInformation.InterruptMode ); if (Result != NDIS_STATUS_SUCCESS) { DBG_ERROR(pAdapter,(\"NdisMRegisterInterrupt failed: Vec=%d, Lev=%d\\n\", (UINT)pCard->ResourceInformation.InterruptVector, (UINT)pCard->ResourceInformation.InterruptLevel)); NdisWriteErrorLogEntry( pAdapter->MiniportAdapterHandle, NDIS_ERROR_CODE_RESOURCE_CONFLICT, 5, pCard->ResourceInformation.InterruptVector, pCard->ResourceInformation.InterruptLevel, Result, __FILEID__, __LINE__ ); } } #endif // defined(CARD_REQUEST_ISR) // TODO - Add your card initialization here. if (Result == NDIS_STATUS_SUCCESS) { } DBG_RETURN(pAdapter, Result); return (Result); } |
|