REQUEST_NOTIFICATION_STATUS CIISxpressHttpModule::OnBeginRequest(IN IHttpContext* pHttpContext, IN IHttpEventProvider* pProvider)
{
    UNREFERENCED_PARAMETER(pProvider);    		

	const TCHAR* const pszMethodName = __FUNCTIONT__;

	// startup the performance counters
	if (m_Config.GetPerfCountersEnabled() && m_pInstancePerfCounters.get() == NULL)
	{
		AutoMemberCriticalSection lock(&m_csPerfCounters);

		if (m_pInstancePerfCounters.get() == NULL)
		{
			CAtlString sAppName;
			GetAppPoolName(pHttpContext, sAppName);

			m_pInstancePerfCounters = auto_ptr<IISxpressNativePerf>(new IISxpressNativePerf(sAppName));			
		}

		// TODO: maybe one day get the global counters to work
		//if (m_pGlobalPerfCounters.get() == NULL)
		//{
		//	m_pGlobalPerfCounters = auto_ptr<IISxpressNativePerf>(new IISxpressNativePerf());
		//}
	}

	IHttpResponse* pHttpResponse = pHttpContext->GetResponse();
	if (pHttpResponse != NULL)
	{
		// Disable caching as HANDLER_HTTPSYS_UNFRIENDLY.
		// TODO: is this really a good idea?
		pHttpResponse->DisableKernelCache();
	}

	// get the registry settings (will only update every 5000ms as default)
	GetRegistrySettings(pHttpContext);

	// only proceed if filter is enabled
	if (m_Config.GetEnabled() == false)
	{
		AppendLogMessage(IISXPRESS_LOGGINGLEVEL_ENH, pszMethodName, pHttpContext, _T("module is disabled\n"));

		PerfCountersAddRejectedResponse(IISxpressNativePerf::FilterDisabled);

		// don't tell us about the send
		pHttpContext->DisableNotifications(RQ_SEND_RESPONSE, 0);
	}

    // Return processing to the pipeline.
    return RQ_NOTIFICATION_CONTINUE;
}
Beispiel #2
0
extern "C" NTSTATUS
DriverEntry
( 
    _In_  PDRIVER_OBJECT          DriverObject,
    _In_  PUNICODE_STRING         RegistryPathName
)
{
/*++

Routine Description:

  Installable driver initialization entry point.
  This entry point is called directly by the I/O system.

  All audio adapter drivers can use this code without change.

Arguments:

  DriverObject - pointer to the driver object

  RegistryPath - pointer to a unicode string representing the path,
                   to driver-specific key in the registry.

Return Value:

  STATUS_SUCCESS if successful,
  STATUS_UNSUCCESSFUL otherwise.

--*/
    NTSTATUS                    ntStatus;
    WDF_DRIVER_CONFIG           config;

    DPF(D_TERSE, ("[DriverEntry]"));
    
    //
    // Get registry configuration.
    //
    ntStatus = GetRegistrySettings(RegistryPathName);
    IF_FAILED_ACTION_JUMP(
        ntStatus,
        DPF(D_ERROR, ("Registry Configuration error 0x%x", ntStatus)),
        Done);
    
    WDF_DRIVER_CONFIG_INIT(&config, WDF_NO_EVENT_CALLBACK);
    //
    // Set WdfDriverInitNoDispatchOverride flag to tell the framework
    // not to provide dispatch routines for the driver. In other words,
    // the framework must not intercept IRPs that the I/O manager has
    // directed to the driver. In this case, they will be handled by Audio
    // port driver.
    //
    config.DriverInitFlags |= WdfDriverInitNoDispatchOverride;
    config.DriverPoolTag    = MINADAPTER_POOLTAG;

    ntStatus = WdfDriverCreate(DriverObject,
                               RegistryPathName,
                               WDF_NO_OBJECT_ATTRIBUTES,
                               &config,
                               WDF_NO_HANDLE);
    IF_FAILED_ACTION_JUMP(
        ntStatus,
        DPF(D_ERROR, ("WdfDriverCreate failed, 0x%x", ntStatus)),
        Done);

    //
    // Tell the class driver to initialize the driver.
    //
    ntStatus =  PcInitializeAdapterDriver(DriverObject,
                                          RegistryPathName,
                                          (PDRIVER_ADD_DEVICE)AddDevice);
    IF_FAILED_ACTION_JUMP(
        ntStatus,
        DPF(D_ERROR, ("PcInitializeAdapterDriver failed, 0x%x", ntStatus)),
        Done);

    //
    // To intercept stop/remove/surprise-remove.
    //
    DriverObject->MajorFunction[IRP_MJ_PNP] = PnpHandler;

    //
    // Hook the port class unload function
    //
    gPCDriverUnloadRoutine = DriverObject->DriverUnload;
    DriverObject->DriverUnload = DriverUnload;

    //
    // All done.
    //
    ntStatus = STATUS_SUCCESS;
    
Done:

    if (!NT_SUCCESS(ntStatus))
    {
        if (WdfGetDriver() != NULL)
        {
            WdfDriverMiniportUnload(WdfGetDriver());
        }
    }
    
    return ntStatus;
} // DriverEntry
Beispiel #3
0
/*
 Function Name : 	LPC3xxx_MiniportInitialize
 Description   :	
					Called by the NDIS Wrapper to initialize the adapter. 
						0. Verify the Adapter v/s the driver
						1. Create and initilize the adapter structure
						2. Read and load the registry settings
						3. Initialize the chip
						4. Establish the link
 Parameters    :
					PNDIS_STATUS OpenErrorStatus - Additional error status, if return value is error
					       PUINT MediumIndex	 - specifies the medium type the driver or its network adapter uses
					PNDIS_MEDIUM MediumArray	 - Specifies an array of NdisMediumXXX values from which 
													MiniportInitialize selects one that its network adapter supports 
													or that the driver supports as an interface to higher-level drivers. 

						    UINT MediumArraySize - Specifies the number of elements at MediumArray
					 NDIS_HANDLE AdapterHandle   - Specifies a handle identifying the miniport’s network adapter, 
													which is assigned by the NDIS library
					 NDIS_HANDLE ConfigurationContext - Specifies a handle used only during initialization for 
														 calls to NdisXXX configuration and initialization functions

 Return Value  :
					NDIS_STATUS		Status
			
*/
NDIS_STATUS LPC3xxx_MiniportInitialize(	PNDIS_STATUS	pOpenErrorStatus,
										PUINT			pMediumIndex,
										PNDIS_MEDIUM	pMediumArray,
										UINT			nMediumArraySize,
										NDIS_HANDLE		hAdapterHandle,
										NDIS_HANDLE		hConfigurationContext)
{
	NDIS_STATUS         Status = NDIS_STATUS_SUCCESS;
	UINT                nArrayIndex;
	PMINIPORT_ADAPTER   pAdapter;
	PHYSICAL_ADDRESS pa;

	DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS ==> MiniportInitialize\r\n")));

	//Check for the supported 802.3 media
	for(nArrayIndex = 0; nArrayIndex < nMediumArraySize; nArrayIndex++)
	{
		if(NdisMedium802_3 == pMediumArray[nArrayIndex])
			break;
	}

    if(nArrayIndex == nMediumArraySize)
    {
		DEBUGMSG(ZONE_INIT | ZONE_ERROR, (TEXT("LPC3xxx NDIS :  ERROR - No Supported Media types \r\n")));
        DEBUGMSG(ZONE_INIT | ZONE_ERROR, (TEXT("LPC3xxx NDIS <== MiniportInitialize  \r\n")));
        return(NDIS_STATUS_UNSUPPORTED_MEDIA);
    }

    *pMediumIndex = nArrayIndex;

	//Allocate memory for the adapter structure
	Status = NdisAllocateMemory((PVOID *) &pAdapter, MINIPORT_ADAPTER_SIZE, 0, HighestAcceptedMax);

    if(Status != NDIS_STATUS_SUCCESS)
    {
        DEBUGMSG(ZONE_INIT | ZONE_ERROR, (TEXT("LPC3xxx NDIS:   ERROR - No Memory for Adapter Structure!\r\n")));
		DEBUGMSG(ZONE_INIT | ZONE_ERROR, (TEXT("LPC3xxx NDIS <== MiniPort Initialize\r\n")));
        return(NDIS_STATUS_RESOURCES);
    }
    NdisZeroMemory(pAdapter, MINIPORT_ADAPTER_SIZE); //Clean it up

//Set up the default values
	pAdapter->hAdapter			= hAdapterHandle;
	pAdapter->eState			= INITIALIZING_STATE;
	pAdapter->IsInterruptSet	= FALSE;
	pAdapter->IsPortRegistered	= FALSE;

	pAdapter->dwIRQNumber		= -1;
	pAdapter->bMediaConnected	= FALSE;
	pAdapter->bAutoNeg			= TRUE;		//	Autoneg per default (overriden by registry settings)
	pAdapter->bFullDuplex		= TRUE;		//	Full duplex per default
	pAdapter->b100Mbps			= TRUE;		//	100 Mbps per default
	pAdapter->bRMII				= TRUE;		//	RMII interface per default

	//Setup Receive control Register
	pAdapter->bPerfectMatch		= TRUE;		//	We want to receive the frames for this station
	pAdapter->bPromiscuous		= FALSE;	//	Not in Promescuous mode per default
	pAdapter->bRxBroadcast		= TRUE;		//	We do forward the broadcasted frames (DHCP required at least)
	pAdapter->bRxMulticastHash	= TRUE;		//	We forward matched multicast frames
	pAdapter->bRxMulticastAll	= FALSE;	//	We do not forward all multicast frames
	pAdapter->bRxUnicastHash	= TRUE;	//	We do not forward matched unicast frames
	pAdapter->bRxUnicastAll		= TRUE;	//	We do not forward all unicast frames

	pAdapter->dwBufferPhyAddr	= 0;
	pAdapter->dwTxStrides		= 0;
	pAdapter->dwRxStrides		= 0;
	pAdapter->dwControllerAddress	= 0;

	pAdapter->pEMACRegs		= NULL;
	pAdapter->dwEMACBuffersSize = 0;
	pAdapter->pPATXDesc		= 0;
	pAdapter->pPARXDesc		= 0;
	pAdapter->pPATXBuffer	= 0;
	pAdapter->pPARXBuffer	= 0;
	pAdapter->pPATXStatus	= 0;
	pAdapter->pPARXStatus	= 0;
	pAdapter->pVAEMACBuffers= NULL;
	pAdapter->pVATXDesc		= NULL;
	pAdapter->pVARXDesc		= NULL;
	pAdapter->pVATXStatus	= NULL;
	pAdapter->pVARXStatus	= NULL;

	//Allocate memory for the LookAhead buffer
	pAdapter->dwLookAheadBufferSize = MAX_FRAME_SIZE;
	Status = NdisAllocateMemory((PVOID *) &pAdapter->pVALookAheadBuffer, pAdapter->dwLookAheadBufferSize, 0, HighestAcceptedMax);

    if(Status != NDIS_STATUS_SUCCESS)
    {
		DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS: ERROR - No Memory for LookAhead buffer!\r\n")));
		DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS <== MiniPort Initialize\r\n")));
        BackOut(pAdapter);
        return(NDIS_STATUS_RESOURCES);
    }
    NdisZeroMemory(pAdapter->pVALookAheadBuffer, pAdapter->dwLookAheadBufferSize); //Clean it up

	pAdapter->MACAddress[0]	= 0x02;
	pAdapter->MACAddress[1]	= 0x03;
	pAdapter->MACAddress[2]	= 0x04;
	pAdapter->MACAddress[3]	= 0x06;
	pAdapter->MACAddress[4]	= 0x06;
	pAdapter->MACAddress[5]	= 0x08;

	//Get the adapter information from the registry
	Status = GetRegistrySettings(pAdapter, hConfigurationContext);
	if(Status != NDIS_STATUS_SUCCESS)
    {
        DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS: ERROR - Configure Adapter failed!\r\n")));
		DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS <== MiniPort Initialize\r\n")));
        BackOut(pAdapter);
        return(NDIS_STATUS_FAILURE);
    }

	//	Allocate the memory for Buffers

	//		Computing required space
	pAdapter->dwEMACBuffersSize = pAdapter->dwRxStrides * (	  sizeof(LPCS_ETH_DESC)
															+ sizeof(LPCS_ETH_RX_STATUS)
															+ MAX_FRAME_SIZE)
								+ pAdapter->dwTxStrides * (	  sizeof(LPCS_ETH_DESC) 
															+ sizeof(LPCS_ETH_TX_STATUS)
															+ MAX_FRAME_SIZE);

	//		Allocating space
	pAdapter->pVAEMACBuffers = MapRegisters (pAdapter->dwBufferPhyAddr,
											pAdapter->dwEMACBuffersSize);

	if(pAdapter->pVAEMACBuffers == NULL)
    {
        RETAILMSG(1, (TEXT("LPC3xxx NDIS:ERROR : Can't Allocate Buffer!\r\n")));
		BackOut(pAdapter);
		DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS:<== MiniPort Initialize FAILED !!\r\n")));
        return(NDIS_STATUS_RESOURCES);
    }

	DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS:Allocated DMA Buffers Successfully!\r\n")));

	//		Splitting allocated buffers into smaller areas
	//			Physical Addresses
	pAdapter->pPARXDesc		= pAdapter->dwBufferPhyAddr;
	pAdapter->pPARXStatus	= pAdapter->pPARXDesc	+ pAdapter->dwRxStrides * sizeof(LPCS_ETH_DESC);
	pAdapter->pPATXDesc		= pAdapter->pPARXStatus + pAdapter->dwRxStrides * sizeof(LPCS_ETH_RX_STATUS);
	pAdapter->pPATXStatus	= pAdapter->pPATXDesc	+ pAdapter->dwTxStrides * sizeof(LPCS_ETH_DESC);
	pAdapter->pPARXBuffer	= pAdapter->pPATXStatus	+ pAdapter->dwTxStrides * sizeof(LPCS_ETH_TX_STATUS);
	pAdapter->pPATXBuffer	= pAdapter->pPARXBuffer	+ pAdapter->dwRxStrides * MAX_FRAME_SIZE;
	//			Virtual Addresses
	pAdapter->pVARXDesc		= pAdapter->pVAEMACBuffers;
	pAdapter->pVARXStatus	= (PVOID)((DWORD)pAdapter->pVARXDesc	+ pAdapter->dwRxStrides * sizeof(LPCS_ETH_DESC));
	pAdapter->pVATXDesc		= (PVOID)((DWORD)pAdapter->pVARXStatus	+ pAdapter->dwRxStrides * sizeof(LPCS_ETH_RX_STATUS));
	pAdapter->pVATXStatus	= (PVOID)((DWORD)pAdapter->pVATXDesc	+ pAdapter->dwTxStrides * sizeof(LPCS_ETH_DESC));
	pAdapter->pVARXBuffer	= (PVOID)((DWORD)pAdapter->pVATXStatus	+ pAdapter->dwTxStrides * sizeof(LPCS_ETH_TX_STATUS));
	pAdapter->pVATXBuffer	= (PVOID)((DWORD)pAdapter->pVARXBuffer	+ pAdapter->dwRxStrides * MAX_FRAME_SIZE);

	//	Allocating the TX Packet buffer
	Status = NdisAllocateMemory((PVOID *) &pAdapter->pTXPackets, sizeof(TX_PACKET) * pAdapter->dwTxStrides, 0, HighestAcceptedMax);
    if(Status != NDIS_STATUS_SUCCESS)
    {
		DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS: ERROR - No Memory for TXBuffers buffer!\r\n")));
		DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS <== MiniPort Initialize\r\n")));
        BackOut(pAdapter);
        return(NDIS_STATUS_RESOURCES);
    }
	NdisZeroMemory(pAdapter->pTXPackets, sizeof(TX_PACKET) * pAdapter->dwTxStrides); //Clean it up

	//Register the interrupt
	NdisMSetAttributes(pAdapter->hAdapter, (NDIS_HANDLE) pAdapter, TRUE, NdisInterfaceInternal);
	Status = NdisMRegisterInterrupt(&pAdapter->InterruptInfo,
									pAdapter->hAdapter,
									pAdapter->dwIRQNumber,
									0,
									TRUE,
									FALSE,
									NdisInterruptLatched);

	if(Status != NDIS_STATUS_SUCCESS)
    {
        DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS : ERROR - Can't Attach to Interrupt!\r\n")));
		BackOut(pAdapter);
		DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS:<== MiniPort Initialize\r\n")));
        return(Status);
    }
	else
		DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS: Interrupt Registered !!! \r\n")));

	pAdapter->IsInterruptSet = TRUE;

	//Register the IOBase address. Modify this code according to the platform
	Status = NdisMRegisterIoPortRange((PVOID *) &(pAdapter->pEMACRegs),
			pAdapter->hAdapter,
			pAdapter->dwControllerAddress,
			sizeof(ETHERNET_REGS_T));
	if(Status != NDIS_STATUS_SUCCESS)
	{
		RETAILMSG(1, (TEXT("LAN91C9111 : ERROR - Can't Register I/O Port Range!\r\n")));
		DEBUGMSG(ZONE_INIT, (TEXT("LAN91C9111 <== MiniPort Initialize\r\n")));
        BackOut(pAdapter);
		return(NDIS_STATUS_RESOURCES);
	}

	pAdapter->IsPortRegistered = TRUE;

	//EnablePeriphClock(ETHERNET);
	pa.QuadPart = CLK_PM_BASE;
	n_pCLKPWRRegs = (CLKPWR_REGS_T *)
		MmMapIoSpace(pa, sizeof (CLKPWR_REGS_T), FALSE);
	
	if (n_pCLKPWRRegs == NULL)
	{
		RETAILMSG(1, (_T("LCD: lpc32xx_hw_init: Critcal error: cannot map registers!\r\n")));
		MmUnmapIoSpace(n_pCLKPWRRegs, sizeof(CLKPWR_REGS_T));
		return;
	}

	n_pCLKPWRRegs->clkpwr_macclk_ctrl = CLKPWR_MACCTRL_HRCCLK_EN|
										CLKPWR_MACCTRL_MMIOCLK_EN|
										CLKPWR_MACCTRL_DMACLK_EN|
										CLKPWR_MACCTRL_USE_RMII_PINS;
	//	//	Initialize Tx and Rx DMA Descriptors
	//DEBUGMSG(ZONE_INIT, (L"LPC_EthInit: Initializing Descriptor engine\r\n"));
	//EMAC_InitEngine(pAdapter);

	if(!HardReset(pAdapter))
	{
		return NDIS_STATUS_FAILURE;
	}

	DEBUGMSG(ZONE_INIT, (TEXT("LPC3xxx NDIS <== MiniportInitialize  \r\n")));

	//Ready

	return NDIS_STATUS_SUCCESS;
}