request.c

来自「S3C24A0的完整BSP包,对开发此芯片的开发者很有用.」· C语言 代码 · 共 449 行 · 第 1/2 页

C
449
字号
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/*

  Copyright(c) Samsung Electronics.

	Module Name:

		request.c

	Revision History:

		26th May   1999		Released

*/

#include "firda.h"
#include "settings.h"


//#define DBGOUT(dbgparams)           RETAILMSG(1, dbgparams);      RETAILMSG(1, (TEXT("\r\n")))

DWORD
ReleaseAdapterResources(
    PVOID pvContext_pIrDevice
    );
				
/*
 *************************************************************************
 *  MiniportQueryInformation
 *************************************************************************
 *
 *
 *  MiniportQueryInformation queries the capabilities and status of the miniport driver.
 *
 *
 */
NDIS_STATUS MiniportQueryInformation    (
                                        IN NDIS_HANDLE MiniportAdapterContext,
                                        IN NDIS_OID Oid,
                                        IN PVOID InformationBuffer,
                                        IN ULONG InformationBufferLength,
                                        OUT PULONG BytesWritten,
                                        OUT PULONG BytesNeeded
                                        )
{
    NDIS_STATUS result = NDIS_STATUS_SUCCESS;
    IrDevice *thisDev = CONTEXT_TO_DEV(MiniportAdapterContext);
    UINT i, speeds;
    UINT *infoPtr;

//	RETAILMSG(DBGIRDA, (TEXT("MiniportQueryInformation -->\r\n")));

	if (InformationBufferLength >= sizeof(int)){

		NdisAcquireSpinLock(&thisDev->Lock);
        switch (Oid){

            case OID_IRDA_RECEIVING:
                DBGOUT((TEXT("MiniportQueryInformation(OID_IRDA_RECEIVING)")));
                *(UINT *)InformationBuffer = (UINT)thisDev->nowReceiving; 
                *BytesWritten = sizeof(UINT);
                *BytesNeeded = 0;
                break;

            case OID_IRDA_SUPPORTED_SPEEDS:
                DBGOUT((TEXT("MiniportQueryInformation(OID_IRDA_SUPPORTED_SPEEDS)")));
                
                speeds = thisDev->portInfo.hwCaps.supportedSpeedsMask & ALL_IRDA_SPEEDS;
                *BytesWritten = 0;

                for (i = 0, infoPtr = (PUINT)InformationBuffer; 
                    (i < NUM_BAUDRATES) && 
                    speeds && 
                    (InformationBufferLength >= sizeof(UINT)); 
                    i++){

                    if (supportedBaudRateTable[i].ndisCode & speeds){
                        *infoPtr++ = supportedBaudRateTable[i].bitsPerSec;
                        InformationBufferLength -= sizeof(UINT);
                        *BytesWritten += sizeof(UINT);
                        speeds &= ~supportedBaudRateTable[i].ndisCode;
                        DBGOUT((TEXT(" - supporting speed %d bps %d"), 
                                supportedBaudRateTable[i].bitsPerSec,InformationBufferLength));
                    }
                }

                if (speeds){
                    /*
                     *  We ran out of room in InformationBuffer.
                     *  Count the remaining number of bits set in speeds
                     *  to figure out the number of remaining bytes needed.
                     */
                    for (*BytesNeeded = 0; speeds; *BytesNeeded += sizeof(UINT)){
                        /*
                         *  This instruction clears the lowest set bit in speeds.
                         */
                        speeds &= (speeds - 1);
                    }
                    result = NDIS_STATUS_INVALID_LENGTH;
                }
                else {
                    result = NDIS_STATUS_SUCCESS;
                    *BytesNeeded = 0;
                }
                break;

            case OID_IRDA_LINK_SPEED:
                DBGOUT((TEXT("MiniportQueryInformation(OID_IRDA_LINK_SPEED)")));
                if (thisDev->linkSpeedInfo){
                    *(UINT *)InformationBuffer = thisDev->linkSpeedInfo->bitsPerSec;
                }
                else {
                    *(UINT *)InformationBuffer = DEFAULT_BAUD_RATE;
                }
                *BytesWritten = sizeof(UINT);
                *BytesNeeded = 0;
                break;

            case OID_IRDA_MEDIA_BUSY:
                DBGOUT((TEXT("MiniportQueryInformation(OID_IRDA_MEDIA_BUSY)")));
                *(UINT *)InformationBuffer = (UINT)thisDev->mediaBusy;
                *BytesWritten = sizeof(UINT);
                *BytesNeeded = 0;
                break;

        #ifdef UNDER_CE
            case OID_IRDA_RELEASE_HW_RESOURCES:
                RETAILMSG(DBGIRDA, (TEXT("Query(OID_IRDA_RELEASE_HW_RESOURCES)\r\n")));

                if (thisDev->resourcesReleased == TRUE)
                {
                    *BytesWritten = 0;
                    result = NDIS_STATUS_FAILURE;
                    DEBUGMSG(ZONE_ERROR,
                        (TEXT(" resources already released!!!\r\n")));
                }
                else
                {
                    HANDLE hRelThread;
                    DWORD  dwRelThreadId;

                    *BytesWritten = sizeof(UINT);

                    hRelThread = CreateThread(NULL,
                        0, ReleaseAdapterResources, thisDev, 
                        0, &dwRelThreadId);

                    if (hRelThread == NULL)
                    {
                        result = NDIS_STATUS_RESOURCES;
                    }
                    else
                    {
                        CloseHandle(hRelThread);
                        result = NDIS_STATUS_PENDING;
                    }
                }
                break;
        #endif // UNDER_CE
            
            case OID_GEN_MAXIMUM_LOOKAHEAD:
                DBGOUT((TEXT("MiniportQueryInformation(OID_GEN_MAXIMUM_LOOKAHEAD)")));
				*(UINT *)InformationBuffer = 256;
				*BytesWritten = sizeof(UINT);
				*BytesNeeded = 0;
                 
                break;

            case OID_GEN_MAC_OPTIONS:
                RETAILMSG(DBGIRDA, (TEXT("MiniportQueryInformation(OID_GEN_MAC_OPTIONS)\r\n")));
				*(UINT *)InformationBuffer = NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA | NDIS_MAC_OPTION_TRANSFERS_NOT_PEND;
				*BytesWritten = sizeof(UINT);
				*BytesNeeded = 0;
				
                break;

            case OID_GEN_MAXIMUM_SEND_PACKETS:
                DBGOUT((TEXT("MiniportQueryInformation(OID_GEN_MAXIMUM_SEND_PACKETS)")));
                *(UINT *)InformationBuffer = 16; 
                *BytesWritten = sizeof(UINT);
                *BytesNeeded = 0;
                break;

            case OID_IRDA_TURNAROUND_TIME:
                /*
                 *  Indicate the amount of time that the transceiver needs  
                 *  to recuperate after a send.
                 */
                DBGOUT((TEXT("MiniportQueryInformation(OID_IRDA_TURNAROUND_TIME)")));
                *(UINT *)InformationBuffer = thisDev->portInfo.hwCaps.turnAroundTime_usec; 
				*BytesWritten = sizeof(UINT);
				*BytesNeeded = 0;
                
                break;

            case OID_IRDA_EXTRA_RCV_BOFS:
                /*
                 *  Pass back the number of _extra_ BOFs to be prepended
                 *  to packets sent to this unit at 115.2 baud, the
                 *  maximum Slow IR speed.  This will be scaled for other
                 *  speed according to the table in the
                 *  'Infrared Extensions to NDIS' spec.
                 */
                DBGOUT((TEXT("MiniportQueryInformation(OID_IRDA_EXTRA_RCV_BOFS)")));
                *(UINT *)InformationBuffer = thisDev->portInfo.hwCaps.extraBOFsRequired; 
                *BytesWritten = sizeof(UINT);
                *BytesNeeded = 0;
                break;

            case OID_GEN_CURRENT_PACKET_FILTER:
                DBGOUT((TEXT("MiniportQueryInformation(OID_GEN_CURRENT_PACKET_FILTER)")));
				*(UINT *)InformationBuffer = NDIS_PACKET_TYPE_PROMISCUOUS;
				*BytesWritten = sizeof(UINT);
				*BytesNeeded = 0;
                
                break;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?