📄 ne2000.cpp
字号:
#include "../../../include/kdndis.h"
#include "ne2000.h"
#include "ne2000adapter.h"
// Debugging definitions
//
#if DBG
// Default debug mode
ULONG Ne2000DebugFlag = NE2000_DEBUG_LOG;
// Debug tracing definitions
#define NE2000_LOG_SIZE 256
UCHAR Ne2000LogBuffer[NE2000_LOG_SIZE]={0};
UINT Ne2000LogLoc = 0;
VOID Ne2000Log(UCHAR c)
{
Ne2000LogBuffer[Ne2000LogLoc++] = c;
Ne2000LogBuffer[(Ne2000LogLoc + 4) % NE2000_LOG_SIZE] = '\0';
if (Ne2000LogLoc >= NE2000_LOG_SIZE)
Ne2000LogLoc = 0;
}
#endif
// Determines whether failing the initial card test will prevent
// the adapter from being registered.
#ifdef CARD_TEST
BOOLEAN InitialCardTest = TRUE;
#else // CARD_TEST
BOOLEAN InitialCardTest = FALSE;
#endif // CARD_TEST
/*++
Routine Description:
This is where the driver is initialized - It creates an ne2000 miniport object and calls
its Init function which will start everything
Arguments:
DriverObject - Pointer to driver object created by the system.
RegistryPath - Path to the parameters for this driver in the registry.
Return Value:
The status of the operation.
--*/
NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
{
// Receives the status of the NdisMRegisterMiniport operation.
NDIS_STATUS Status;
KdNe2000Miniport *pMiniport = new KdNe2000Miniport();
if(!pMiniport)
{
DebugDump(DBG_LEVEL3,("Cannot allocate memory!!"));
return STATUS_UNSUCCESSFUL;
}
// register the miniport with the ndis
Status = pMiniport->Init(DriverObject,RegistryPath);
if (Status != NDIS_STATUS_SUCCESS)
{
delete pMiniport;
return STATUS_UNSUCCESSFUL;
}
return STATUS_SUCCESS;
}
KdNe2000Miniport::KdNe2000Miniport(DWORD options) :KdNdisMiniport(options)
{
}
KdNe2000Miniport::~KdNe2000Miniport()
{
}
/*++
Routine Description:
called by the KdNdisMiniport::StaticInitializeHandler when the ndis calls the initialize handler
does any initialization and checking for the miniport and at the end creates the adapter
Arguments:
pAdapter - address of pointer to return to caller with a created adapter
pConf - pointer to a configuration object where we can read information about the adapter parameters
WrapperConfigurationContext - configuration handle sent by Ndis
Return Value:
SUCCESS of FAIL
--*/
NDIS_STATUS KdNe2000Miniport::CreateAdapter(KdNdisAdapter **pAdapter, KdNdisConfiguration *pConf, NDIS_HANDLE WrapperConfigurationContext)
{
// Disallow multiple adapters in the same MP machine because of hardware
// problems this results in random packet corruption.
if ((NdisSystemProcessorCount() > 1) && (m_AdapterList != NULL))
{
DebugDump(DBG_DIAG1,("ERROR: Multiple adapters in the same MP machine not allowed!!"));
return NDIS_STATUS_FAILURE;
}
// everything is Ok create an adapter - The caller will call its Init function
*pAdapter = new KdNe2000Adapter();
return NDIS_STATUS_SUCCESS;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -