⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 card.cpp

📁 WinCE5.0部分核心源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// This source code is licensed under Microsoft Shared Source License
// Version 1.0 for Windows CE.
// For a copy of the license visit http://go.microsoft.com/fwlink/?LinkId=3223.
//
// Copyright 2001, Cisco Systems, Inc.  All rights reserved.
// No part of this source, or the resulting binary files, may be reproduced,
// transmitted or redistributed in any form or by any means, electronic or
// mechanical, for any purpose, without the express written permission of Cisco.
//
//---------------------------------------------------------------------------
// Card.cpp
//---------------------------------------------------------------------------
//
// Description:
//
// Revision History:
//
// Date         
//---------------------------------------------------------------------------
// 10/10/00     jbeaujon    -changed vendor name in OID_GEN_VENDOR_DESCRIPTION
//                           from "Aironet" to "Cisco".
// 
// 10/20/00     jbeaujon    -added the following query OIDs:
//                              OID_802_11_SSID
//                              OID_802_11_INFRASTRUCTURE_MODE
//                              OID_802_11_BSSID
//                          -added the following set OIDs:
//                              OID_802_11_SSID
//                              OID_802_11_INFRASTRUCTURE_MODE
//                              OID_802_11_DISASSOCIATE
//                              OID_802_11_AUTHENTICATION_MODE
// 
// 03/26/01     jbeaujon    -added OID_802_11_RELOAD_DEFAULTS
//
// 05/04/01     spb001      -Added "fast" initialization option.  By changing
//                           the InitFW() to only reset the device on the 
//                           first call.  InitFW1() must then be called to 
//                           finish the initialization. Subsequent calls to InitFW()
//                           will work as prior to changes.
//
// 05/10/01     spb004      -Work around for network card not sending an updatelinkstatus
//                           interrupt when it should
//
// 05/31/01     spb008      -Make sure we don't update link status when we are flashing
//
// 06/05/01     spb009      -Make sure we only use the botton byte of the signal
//                           strength as an index into the dbmTable (only 256 bytes).
//
// 06/12/01     spb010      -If we are using the fast init option, then 
//                           we don't want to init interrupts yet because firm
//                           ware will zero out the interrupt enable
//                           register during the reset.  This caused a race 
//                           condition where the card would be up and running
//                           but not interrupts were enabled.
//
// 06/19/01     spb012      -Hack to stop jerkiness when in PSP.   This needs
//                           to really be done on either a per oid basis or
//                           better yet, at a lower level i.e. per command.
//
// 06/28/01     spb014      -Fixed MiniportQuery NDIS_802_11_SSID so that
//                           we will return the currently associated SSID.
//
// 07/03/01     spb017      -Added counter to cancel timer so we don't hang 
//                           in destructor forever.
//
// 07/10/01     spb018      -If you are using the Home configuration, and WZC
//                           plumbs down a WEP key, turn off Home configuration
//                           because otherwise the new WEP key won't be used
//                           since HOME key is 5 and 802_11 spec only has 1-4.
//
// 07/23/01     spb026      -Changed OID_QUERY_RADIO_STATE in oidx500.cpp since
//                           there was no reason to access the card it is ok
//                           now to check when flashing
//
// 08/01/01     spb027      -Added ability to cancel flash timer if we are NDIS5
//                           driver.
//
// 08/03/01     spb029      -Added length check to ssid query
//
// 08/13/01     raf         -Magic Packet fixes 
//---------------------------------------------------------------------------
#pragma code_seg("LCODE")

#include "NDISVER.h"
extern "C"{
    #include    <ndis.h>
}

#include "CardX500.h"
#include "string.h"
#include "aironet.h"
#include "cmdX500.h"
#include "HWX500P.h"

extern BOOLEAN  IsCardInserted(PCARD card);
extern int      GetSupOidSize();
extern int      AironetSupportedOids[];
extern PCARD    AdapterArray[];
extern WINDOWSOS    OSType;     


NDIS_STATUS getShortVal (ULONG InfBuffLen, PVOID InfBuff, PUSHORT shortVal);

#define ARRAYSIZE(s) (sizeof(s) / sizeof(s[0]))

#define show(a,b)   a=b
extern UINT DebugFlag;
PCARD   gCard;


//===========================================================================
    void baseCardDestruct (PCARD card)
//===========================================================================
// 
// Description: Pseudo-destructor for card.
//    
//      Inputs: 
//    
//     Returns: 
//---------------------------------------------------------------------------
{
    gCard = card;

    if (card->m_CardTimerIsSet) {
        BOOLEAN ret = FALSE;
#if NDISVER == 5
//spb017 
        NdisMCancelTimer(&card->m_CardTimer, &ret );
        if (!ret) {
            //spb020
            card->cancelTimer=TRUE;
            while (card->m_CardTimerIsSet) {
                //wait for timer to fire
                NdisMSleep(1000000);
            }
        }
#else
        while (!ret) {
            NdisMCancelTimer(&card->m_CardTimer, &ret );
        }
#endif
    }

#if NDISVER == 5
    if (card->m_IsFlashing) {
        //spb027
        //We need to cancel the flash or at least wait until
        //it has finished.  Try and cancel it, but we may be 
        //at a point where we can't cancel therefore we have
        //to wait until we are done 
        card->cancelFlash = TRUE;
        while (card->m_IsFlashing) {
            //wait for timer to fire
            NdisMSleep(1000000);
        }
    }
#endif

    if (card->m_InterruptRegistered) {
        NdisMDeregisterInterrupt(&card->Interrupt);
        card->m_InterruptRegistered = FALSE;
        }

    if (card->m_AttribMemRegistered) {
        NdisMUnmapIoSpace( card->m_MAHandle, (void *)card->m_pAttribMemBase, CIS_ATTRIBMEM_SIZE );
        card->m_AttribMemRegistered = FALSE;
        }
    
    //if( card->m_RadioMemRegistered )
    //  NdisMUnmapIoSpace( card->m_MAHandle, (void *)card->m_RadioMemBase, CIS_ATTRIBMEM_SIZE );

    if (card->m_ContolRegRegistered) {
        NdisMUnmapIoSpace( card->m_MAHandle, (void *)card->m_ContolRegMemBase, CTL_ATTRIBMEM_SIZE );
        card->m_ContolRegRegistered = FALSE;
        }
    
    if (card->m_IoRegistered) {
        //NdisMUnmapIoSpace( card->m_MAHandle, (void *)card->m_IOBase, card->m_PortIOLen );
        NdisMDeregisterIoPortRange( card->m_MAHandle, card->m_InitialPort,
                card->m_PortIOLen,(void *)card->m_IOBase );
        
        if (card->m_PortIOLen8Bit) {
            //NdisMUnmapIoSpace( card->m_MAHandle, (void *)card->m_IOBase8Bit, card->m_PortIOLen8Bit );
            NdisMDeregisterIoPortRange( card->m_MAHandle, card->m_InitialPort8Bit, 
                card->m_PortIOLen8Bit, (void *)card->m_IOBase8Bit );
            }
        card->m_IoRegistered = FALSE;
        }
    
    delete [] card->m_profiles;

    if (card->dBmTable != NULL) {
        delete card->dBmTable;
        }

    if (card->bssid_list) {
        delete [] card->bssid_list;
        }

#ifndef UNDER_CE
    UnloadVxd(card);
#endif
}

//===========================================================================
    BOOLEAN baseCardConstruct (PCARD card) 
//===========================================================================
// 
// Description: Pseudo-constructor for card.
//    
//      Inputs: 
//    
//     Returns: 
//---------------------------------------------------------------------------
{
    BOOLEAN retval              = FALSE;

    card->m_CardPresent         = FALSE;
    CQReset(card->m_Q);
    CQReset(card->fidQ);

#if NDISVER == 3
    card->m_Lookahead           = card->m_RcvBuf;
    //For NDIS 3 drivers, use the "slow initializiation" still
    card->initComplete          = TRUE;     //spb001
#else 
    card->m_Lookahead           = card->m_RcvBuf[0];
    card->initComplete          = FALSE;    //spb001
#endif

    card->m_MediaDisconnectDamper       = DEFAULT_MEDIA_DISCONNECT_DAMPER;  // 10 seconds default
    card->m_AutoConfigActiveDamper      = DEFAULT_AUTO_CONFIG_ACTIVE_DAMPER;
    card->m_AutoConfigPassiveDamper     = DEFAULT_AUTO_CONFIG_PASSIVE_DAMPER;
    card->m_AutoConfigDamperTick        = 0;

    card->m_MSenceStatus            = NDIS_STATUS_MEDIA_DISCONNECT; 
    card->m_BusType                 = NdisInterfacePcMcia; // PCMCIA - 6
    card->m_InterruptNumber         = DEFAULT_INTERRUPTNUMBER;
    card->m_MaxMulticastList        = DEFAULT_MULTICASTLISTMAX;
    card->m_AttribMemRegistered     = FALSE;
    card->m_MagicPacketMode         = (UINT)-1; 
    card->m_PowerSaveMode           = 0; // CAM
    card->IsAwake                   = TRUE;             
    card->KeepAwake                 = 0;
    card->m_UseSavedConfig          = FALSE;
    card->m_Diversity               = 0x0000;
    card->m_ResetOnHang             = FALSE;
    card->m_ResetTick               = 0;
    card->m_CardTimerIsSet          = FALSE;
    card->m_PrevCmdTick             = 0;
    NdisZeroMemory(card->m_SupportedRates, sizeof(card->m_SupportedRates));
//
    card->m_TxHead              = 0;
    card->m_TxTail              = 0;
    card->m_NumPacketsQueued    = 0;
    card->m_PortIOLen8Bit       = 0;
    card->IsAssociated          = FALSE;
    card->m_AttribMemRegistered = 0;
    //
    card->IsAMCC                = FALSE;
    card->m_ContolRegMemBase    = 0;
    card->m_ContolRegRegistered = FALSE;

    card->m_profiles            = NULL;
    card->m_numProfiles         = 0;
    card->m_activeProfile       = NULL;
    card->m_activeProfileIndex  = 0;
    card->m_currentProfile      = NULL;
    card->bssid_list            = NULL;

    card->dBmTable              = NULL;

#ifdef UNDER_CE
    card->bHalting              = FALSE;
#endif

#if NDISVER == 5
    card->mp_enabled            = MP_POWERED; // magic packet
#endif
    retval = TRUE;

    return(retval);
}

//===========================================================================
    NDIS_STATUS cbQueryInformation (NDIS_HANDLE     Context,
                                    IN NDIS_OID     Oid,
                                    IN PVOID        InfBuff,
                                    IN ULONG        InfBuffLen,
                                    OUT PULONG      BytesWritten,
                                    OUT PULONG      BytesNeeded)
//===========================================================================
// 
// Description: MiniportQueryInformation.
//    
//      Inputs: 
//    
//     Returns: 
//---------------------------------------------------------------------------
{ 
    PCARD           card = (PCARD)Context;
    char            tmpBuf[64];

    if (NULL == card) {
        for (int i = 0; (NULL == AdapterArray[i]) && (i < CARDS_MAX); i++);
        card = (CARDS_MAX == i) ? AdapterArray[i-1] : AdapterArray[i];                
        }
    
    for( int i=0; card != AdapterArray[i] && i<CARDS_MAX; i++ );

    if( ! card || i == CARDS_MAX ) {
        return NDIS_STATUS_INVALID_OID;
    }

//    DbgPrint("Oid Query %X\n", Oid);

⌨️ 快捷键说明

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