亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? nic_init.c

?? plx9054的WDM驅動程序
?? C
?? 第 1 頁 / 共 5 頁
字號:
/*++

Copyright (c) Microsoft Corporation.  All rights reserved.

    THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY      
    KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
    IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
    PURPOSE.

Module Name:

    NIC_INIT.c

Abstract:

    Contains rotuines to do resource allocation and hardware
    initialization & shutdown.

Environment:

    Kernel mode


Revision History:

    Eliyas Yakub Feb 13, 2003

--*/

#include "precomp.h"

#if defined(EVENT_TRACING)
#include "nic_init.tmh"
#endif

#ifdef ALLOC_PRAGMA
#pragma alloc_text (PAGE, NICInitializeDeviceExtension)
#pragma alloc_text (PAGE, NICAllocateDeviceResources)
#pragma alloc_text (PAGE, NICMapHWResources)
#pragma alloc_text (PAGE, NICUnmapHWResources)
#pragma alloc_text (PAGE, NICGetDeviceInformation)
#pragma alloc_text (PAGE, NICReadAdapterInfo)
#pragma alloc_text (PAGE, NICAllocAdapterMemory)
#pragma alloc_text (PAGE, NICFreeAdapterMemory)
#pragma alloc_text (PAGE, NICInitRecv)
#pragma alloc_text (PAGE, NICSelfTest)
#pragma alloc_text (PAGE, NICInitializeAdapter)
#pragma alloc_text (PAGE, HwConfigure)
#pragma alloc_text (PAGE, HwClearAllCounters)
#pragma alloc_text (PAGE, HwSetupIAAddress)
#pragma alloc_text (PAGE, GetPCIBusInterfaceStandard)
#pragma alloc_text (PAGE, NICAllocRfd)
#pragma alloc_text (PAGE, NICFreeRfd)
#pragma alloc_text (PAGE, NICAllocRfdWorkItem)
#pragma alloc_text (PAGE, NICFreeRfdWorkItem)
#endif


NTSTATUS
NICInitializeDeviceExtension(
    IN OUT PFDO_DATA FdoData
    )
/*++
Routine Description:

    
Arguments:

    FdoData     Pointer to our FdoData

Return Value:

     None

--*/
{
    NTSTATUS status;

    //
    // Get the BUS_INTERFACE_STANDARD for our device so that we can
    // read & write to PCI config space at IRQL <= DISPATCH_LEVEL.
    //
    status = GetPCIBusInterfaceStandard(FdoData->Self, 
                                        &FdoData->BusInterface);
    if (!NT_SUCCESS (status)){
        return status;    
    }
    
    NICGetDeviceInfSettings(FdoData);
    
    FdoData->ConservationIdleTime = -SECOND_TO_100NS * PCIDRV_DEF_IDLE_TIME;
    FdoData->PerformanceIdleTime = -SECOND_TO_100NS * PCIDRV_DEF_IDLE_TIME;
    
    //
    // Initialize list heads, spinlocks, timers etc.
    //
    InitializeListHead(&FdoData->SendQueueHead);

    InitializeListHead(&FdoData->RecvList);
    InitializeListHead(&FdoData->RecvQueueHead);
    InitializeListHead(&FdoData->PoMgmt.PatternList);

    KeInitializeSpinLock(&FdoData->Lock);
    KeInitializeSpinLock(&FdoData->SendLock);
    KeInitializeSpinLock(&FdoData->RcvLock);    
    KeInitializeSpinLock(&FdoData->RecvQueueLock); 

    //
    // To minimize init-time, queue a DPC to do link detection.
    // This DPC will also be used to check of hardware hang.
    //
    KeInitializeDpc(&FdoData->WatchDogTimerDpc, // Dpc
                                NICWatchDogTimerDpc, // DeferredRoutine
                                FdoData           // DeferredContext
                                ); 

    KeInitializeTimer(&FdoData->WatchDogTimer );
    
    //
    // Event used to make sure the NICWatchDogTimerDpc has completed execution
    // before freeing the resources and unloading the driver.
    //
    KeInitializeEvent(&FdoData->WatchDogTimerEvent, NotificationEvent, TRUE);

    return status;
    
}


NTSTATUS
NICAllocateDeviceResources(
    IN OUT  PFDO_DATA   FdoData,
    IN      PIRP        Irp
    )
/*++
Routine Description:

    Allocates all the hw and software resources required for
    the device, enables interrupt, and initializes the device.

Arguments:

    FdoData     Pointer to our FdoData
    Irp         Pointer to start-device irp.

Return Value:

     None

--*/
{
    NTSTATUS        status;
    LARGE_INTEGER   DueTime;

    do{

        //
        // First make sure this is our device before doing whole lot
        // of other things.
        //
        status = NICGetDeviceInformation(FdoData);
        if (!NT_SUCCESS (status)){
            return status;
        }
        
        status = NICMapHWResources(FdoData, Irp);
        if (!NT_SUCCESS (status)){
            DebugPrint(ERROR, DBG_INIT,"NICMapHWResources failed: 0x%x\n",
                                    status);
            break;
        }       
        
        //
        // Read additional info from NIC such as MAC address
        //
        status = NICReadAdapterInfo(FdoData);
        if (status != STATUS_SUCCESS)
        {
            break;
        }


        status = NICAllocAdapterMemory(FdoData);
        if (status != STATUS_SUCCESS)
        {
            break;
        }    

        NICInitSend(FdoData);
        
        status = NICInitRecv(FdoData);
        if (status != STATUS_SUCCESS)
        {
            break;
        }    

        //
        // Test our adapter hardware
        //
        status = NICSelfTest(FdoData);
        if (status != STATUS_SUCCESS)
        {
            break;
        }    

        status = NICInitializeAdapter(FdoData);
        if (status != STATUS_SUCCESS)
        {
            break;
        }    

        //
        // Enable the interrupt
        //
        NICEnableInterrupt(FdoData);
                 
        //
        // Set the link detection flag to indicate that NICWatchDogTimerDpc
        // will be first doing link-detection.
        //
        MP_SET_FLAG(FdoData, fMP_ADAPTER_LINK_DETECTION);
        FdoData->CheckForHang = FALSE;
        FdoData->bLinkDetectionWait = FALSE;
        FdoData->bLookForLink = FALSE;   
        
        //
        // This event stays cleared until the NICWatchDogTimerDpc exits. 
        //
        KeClearEvent(&FdoData->WatchDogTimerEvent);

        //
        // Watch dog timer is used to do the initial link detection during
        // start and then used to make sure the device is not hung for 
        // any reason.
        //
        DueTime.QuadPart = NIC_LINK_DETECTION_DELAY;
        KeSetTimer( &FdoData->WatchDogTimer,   // Timer
                            DueTime,         // DueTime
                            &FdoData->WatchDogTimerDpc      // Dpc  
                            );                
    }while(FALSE);        

    return status;
    
}


NTSTATUS
NICFreeDeviceResources(
    IN OUT PFDO_DATA FdoData
    )
/*++
Routine Description:

    Free all the software resources. We shouldn't touch the hardware.

Arguments:

    FdoData     Pointer to our FdoData

Return Value:

     None

--*/
{
    NTSTATUS    status;
    KIRQL       oldIrql;
    
    DebugPrint(INFO, DBG_INIT, "-->NICFreeDeviceResources\n");
            
    if(!KeCancelTimer(&FdoData->WatchDogTimer)){
        //
        // Wait for the timer to complete since it has already begun executing.
        //
        DebugPrint(INFO, DBG_INIT, 
                            "Waiting for the watchdogtimer to exit..\n");
        
        status = KeWaitForSingleObject( &FdoData->WatchDogTimerEvent,
                               Executive,
                               KernelMode,
                               FALSE,
                               NULL );
        ASSERT(NT_SUCCESS(status));
    }
       
    //
    // We need to raise the IRQL before acquiring the lock
    // because the functions called inside the guarded
    // region assume that they are called at Dpc level and release
    // and reacquire the lock using DpcLevel spinlock functions.
    //
    KeRaiseIrql(DISPATCH_LEVEL, &oldIrql);
    KeAcquireSpinLockAtDpcLevel(&FdoData->SendLock);

    //
    // Free the packets on SendWaitList                                                           
    //
    NICFreeQueuedSendPackets(FdoData);

    //
    // Free the packets being actively sent & stopped
    //
    NICFreeBusySendPackets(FdoData);
    
    KeReleaseSpinLockFromDpcLevel(&FdoData->SendLock);
    KeLowerIrql(oldIrql);

    
    NICFreeAdapterMemory(FdoData);

    //
    // Disconnect from the interrupt and unmap any I/O ports
    //
    NICUnmapHWResources(FdoData);

    DebugPrint(INFO, DBG_INIT, "<--NICFreeDeviceResources\n");
    
    return STATUS_SUCCESS;
    
}

NTSTATUS
NICMapHWResources(
    IN OUT PFDO_DATA FdoData,
    IN PIRP Irp
    )
/*++
Routine Description:

    Gets the HW resources assigned by the bus driver from the start-irp
    and maps it to system address space. Initializes the DMA adapter
    and sets up the ISR.

    Three base address registers are supported by the 8255x:
    1) CSR Memory Mapped Base Address Register (BAR 0 at offset 10)
    2) CSR I/O Mapped Base Address Register (BAR 1 at offset 14)
    3) Flash Memory Mapped Base Address Register (BAR 2 at offset 18)
    
    The 8255x requires one BAR for I/O mapping and one BAR for memory 
    mapping of these registers anywhere within the 32-bit memory address space.
    The driver determines which BAR (I/O or Memory) is used to access the 
    Control/Status Registers. 

    Just for illustration, this driver maps both memory and I/O registers and
    shows how to use READ_PORT_xxx or READ_REGISTER_xxx functions to perform 
    I/O in a platform independent basis. On some platforms, the I/O registers
    can get mapped in to memory space and your driver should be able to handle
    this transparently.
    
    One BAR is also required to map the accesses to an optional Flash memory. 
    The 82557 implements this register regardless of the presence or absence 
    of a Flash chip on the adapter. The 82558 and 82559 only implement this 
    register if a bit is set in the EEPROM. The size of the space requested 
    by this register is 1Mbyte, and it is always mapped anywhere in the 32-bit
    memory address space. 
    Note: Although the 82558 only supports up to 64 Kbytes of Flash memory 
    and the 82559 only supports 128 Kbytes of Flash memory, 1 Mbyte of
    address space is still requested. Software should not access Flash 
    addresses above 64 Kbytes for the 82558 or 128 Kbytes for the 82559 
    because Flash accesses above the limits are aliased to lower addresses.    
    
Arguments:

    FdoData     Pointer to our FdoData
    Irp         Pointer to start-device irp.

Return Value:

     None

--*/
{
    PCM_PARTIAL_RESOURCE_DESCRIPTOR resourceTrans;
    PCM_PARTIAL_RESOURCE_LIST       partialResourceListTranslated;
    PIO_STACK_LOCATION              stack;
    ULONG                           i;
    NTSTATUS                        status = STATUS_SUCCESS;
    DEVICE_DESCRIPTION              deviceDescription;    
    ULONG                           MaximumPhysicalMapping;
    PDMA_ADAPTER                    DmaAdapterObject;
    ULONG                           maxMapRegistersRequired, miniMapRegisters;
    ULONG                           MapRegisters;
    BOOLEAN bResPort = FALSE, bResInterrupt = FALSE, bResMemory = FALSE;
    ULONG                           numberOfBARs = 0;
#if defined(DMA_VER2) // To avoid  unreferenced local variables error
    ULONG                           SGMapRegsisters;
    ULONG                           ScatterGatherListSize;        
#endif

    stack = IoGetCurrentIrpStackLocation (Irp);

    PAGED_CODE();

    if (NULL == stack->Parameters.StartDevice.AllocatedResourcesTranslated) {
        status = STATUS_DEVICE_CONFIGURATION_ERROR;
        goto End;
    }
    
    //
    // Parameters.StartDevice.AllocatedResourcesTranslated points
    // to a CM_RESOURCE_LIST describing the hardware resources that
    // the PnP Manager assigned to the device. This list contains
    // the resources in translated form. Use the translated resources
    // to connect the interrupt vector, map I/O space, and map memory.
    //

    partialResourceListTranslated = &stack->Parameters.StartDevice.\
                      AllocatedResourcesTranslated->List[0].PartialResourceList;

    resourceTrans = &partialResourceListTranslated->PartialDescriptors[0];

    for (i = 0;
         i < partialResourceListTranslated->Count;
         i++, resourceTrans++) {

        switch (resourceTrans->Type) {
            
        case CmResourceTypePort:
            //
            // We will increment the BAR count only for valid resources. We will
            // not count the private device types added by the PCI bus driver.
            //
            numberOfBARs++;
            

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品毛片无遮挡高清| 九色综合狠狠综合久久| 奇米亚洲午夜久久精品| 不卡一卡二卡三乱码免费网站| 欧美丝袜丝交足nylons图片| 国产欧美视频在线观看| 日韩和的一区二区| 在线视频一区二区免费| 欧美激情中文不卡| 麻豆精品视频在线观看视频| 91传媒视频在线播放| 欧美激情在线观看视频免费| 日韩av网站免费在线| 色婷婷av一区二区三区大白胸| 久久精品视频在线看| 日本欧美加勒比视频| 色8久久精品久久久久久蜜| 国产精品麻豆欧美日韩ww| 久久不见久久见免费视频1| 欧美日韩在线直播| 夜夜嗨av一区二区三区网页| 成人午夜视频福利| 久久久久久**毛片大全| 久草这里只有精品视频| 欧美日韩成人在线| 亚洲1区2区3区4区| 5858s免费视频成人| 一级日本不卡的影视| 99riav久久精品riav| 欧美激情在线免费观看| 国产精品996| 中文字幕不卡一区| 成人av在线资源网站| 国产精品久久久久9999吃药| 成人免费精品视频| 国产精品无圣光一区二区| 国产不卡在线一区| 国产精品久久久久久久岛一牛影视| 国产成人日日夜夜| 国产精品久久久一区麻豆最新章节| 国产成人自拍网| 中文字幕制服丝袜一区二区三区| 成人三级在线视频| 最新国产の精品合集bt伙计| 91老师国产黑色丝袜在线| 一区二区三区四区中文字幕| 欧美日韩国产美| 美女免费视频一区二区| 久久久久亚洲蜜桃| 国产成人免费高清| 国产精品电影一区二区| 色婷婷久久久综合中文字幕| 亚洲成av人片www| 日韩欧美自拍偷拍| 成人午夜在线播放| 亚洲小说欧美激情另类| 日韩一卡二卡三卡国产欧美| 国产精品影视在线观看| 亚洲丝袜制服诱惑| 欧美人xxxx| 成人午夜激情在线| 五月激情丁香一区二区三区| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 麻豆一区二区三区| 国产亚洲一区字幕| 欧美综合一区二区| 经典一区二区三区| 亚洲视频 欧洲视频| 69p69国产精品| 高清不卡在线观看av| 亚洲第一主播视频| 国产三级欧美三级| 欧美亚洲综合色| 国产福利电影一区二区三区| 一区二区三区免费观看| 国产午夜久久久久| 欧美日韩国产在线播放网站| 粉嫩高潮美女一区二区三区| 亚洲第一成年网| 中文字幕精品一区| 日韩三级在线观看| 日本精品视频一区二区| 国产激情一区二区三区四区| 亚洲成人午夜电影| 国产精品美女久久久久久 | 亚洲v日本v欧美v久久精品| 久久免费看少妇高潮| 欧美视频中文一区二区三区在线观看| 国产精品综合一区二区三区| 午夜欧美大尺度福利影院在线看| 国产精品视频麻豆| 精品免费国产二区三区| 欧美色视频在线| 99久久久国产精品| 国产一区二区三区免费看| 午夜精品福利视频网站| 亚洲欧美成aⅴ人在线观看| 中文字幕久久午夜不卡| 精品国产免费人成在线观看| 欧美日韩五月天| 欧美色精品在线视频| 色丁香久综合在线久综合在线观看| 国产99久久久久| 国产成人亚洲综合a∨婷婷图片| 免费在线观看成人| 日韩二区在线观看| 婷婷综合另类小说色区| 亚洲国产综合视频在线观看| 一区二区三区日韩精品| 亚洲卡通动漫在线| 亚洲欧美日韩国产中文在线| 国产精品乱子久久久久| 国产精品久久影院| 18涩涩午夜精品.www| 国产精品每日更新| 亚洲欧美日韩系列| 亚洲男人电影天堂| 亚洲综合av网| 亚洲成人动漫在线免费观看| 亚洲一区中文日韩| 亚洲国产视频一区| 偷拍自拍另类欧美| 麻豆精品视频在线观看| 另类的小说在线视频另类成人小视频在线| 视频一区二区三区在线| 日韩国产一区二| 久久国内精品自在自线400部| 精品一区二区三区在线视频| 国产一区二区三区蝌蚪| 国产成人精品www牛牛影视| 国产精品18久久久久久久久| 成人小视频免费观看| 日本久久电影网| 337p亚洲精品色噜噜噜| 精品少妇一区二区三区视频免付费| 欧美电影免费提供在线观看| 久久一区二区三区国产精品| 国产精品麻豆99久久久久久| 一区二区三区在线播| 石原莉奈在线亚洲二区| 美女视频黄频大全不卡视频在线播放| 国精产品一区一区三区mba视频| 国产v综合v亚洲欧| 欧美亚洲日本国产| 日韩欧美精品在线视频| 国产精品久久久久aaaa| 视频一区二区三区在线| 国产精品中文字幕日韩精品| 91精彩视频在线观看| 日韩亚洲电影在线| 国产精品久久精品日日| 午夜精品久久久久久久| 国产一区 二区| 欧美性一区二区| 久久综合久久综合亚洲| 一区二区高清免费观看影视大全| 蜜桃一区二区三区四区| www.亚洲免费av| 日韩你懂的在线观看| 亚洲欧美区自拍先锋| 久久精品国产第一区二区三区| 成人亚洲精品久久久久软件| 在线播放中文字幕一区| 18成人在线观看| 国产自产高清不卡| 欧美视频一区二区三区在线观看| 26uuu欧美日本| 午夜影院久久久| 91视视频在线直接观看在线看网页在线看| 在线成人av影院| 国产精品久久久久天堂| 精油按摩中文字幕久久| 欧美在线短视频| 国产精品久久久一区麻豆最新章节| 日本va欧美va瓶| 91福利视频久久久久| 国产精品久久国产精麻豆99网站| 免费观看91视频大全| 在线免费一区三区| 国产欧美精品一区| 久草在线在线精品观看| 欧美猛男超大videosgay| 亚洲欧美日韩国产成人精品影院| 国产一区二区伦理片| 日韩美女一区二区三区四区| 亚洲不卡av一区二区三区| 在线视频国内自拍亚洲视频| 国产精品国产三级国产三级人妇| 精品亚洲成a人在线观看| 91精品国产全国免费观看 | 亚洲色图在线播放| 国产精品一区二区无线| 精品处破学生在线二十三| 日本在线不卡视频| 91精品国产综合久久久久久久 | 欧美午夜一区二区三区| 一区精品在线播放| 色婷婷av一区二区三区大白胸| 亚洲天堂av老司机| 色哟哟一区二区三区|