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

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

?? bulkpnp.c

?? 微軟DDK中關于WDM驅動程序模型中USB設備驅動程序的例子,實現了BULK通道的數據傳輸,對于利用DDK編寫USB驅動程序的朋友是個很好的參考.
?? C
?? 第 1 頁 / 共 5 頁
字號:
/*++

Copyright (c) 2000  Microsoft Corporation

Module Name:

    bulkpnp.c

Abstract:

	Bulk USB device driver for Intel 82930 USB test board
	Plug and Play module.
    This file contains routines to handle pnp requests.
    These routines are not USB specific but is required
    for every driver which conforms to the WDM model.

Environment:

    Kernel mode

Notes:

    Copyright (c) 2000 Microsoft Corporation.  
    All Rights Reserved.

--*/

#include "bulkusb.h"
#include "bulkpnp.h"
#include "bulkpwr.h"
#include "bulkdev.h"
#include "bulkrwr.h"
#include "bulkwmi.h"
#include "bulkusr.h"

NTSTATUS
BulkUsb_DispatchPnP(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP           Irp
    )
/*++
 
Routine Description:

    The plug and play dispatch routines.
    Most of these requests the driver will completely ignore.
    In all cases it must pass on the IRP to the lower driver.

Arguments:

    DeviceObject - pointer to a device object.

    Irp - pointer to an I/O Request Packet.

Return Value:

    NT status value

--*/
{
    PIO_STACK_LOCATION irpStack;
    PDEVICE_EXTENSION  deviceExtension;
    KEVENT             startDeviceEvent;
    NTSTATUS           ntStatus;

    //
    // initialize variables
    //

    irpStack = IoGetCurrentIrpStackLocation(Irp);
    deviceExtension = DeviceObject->DeviceExtension;

    //
    // since the device is removed, fail the Irp.
    //

    if(Removed == deviceExtension->DeviceState) {

        ntStatus = STATUS_DELETE_PENDING;

        Irp->IoStatus.Status = ntStatus;
        Irp->IoStatus.Information = 0;

        IoCompleteRequest(Irp, IO_NO_INCREMENT);

        return ntStatus;
    }

    BulkUsb_DbgPrint(3, ("///////////////////////////////////////////\n"));
    BulkUsb_DbgPrint(3, ("BulkUsb_DispatchPnP::"));
    BulkUsb_IoIncrement(deviceExtension);

    if(irpStack->MinorFunction == IRP_MN_START_DEVICE) {

        ASSERT(deviceExtension->IdleReqPend == 0);
    }
    else {

        if(deviceExtension->SSEnable) {

            CancelSelectSuspend(deviceExtension);
        }
    }

    BulkUsb_DbgPrint(2, (PnPMinorFunctionString(irpStack->MinorFunction)));

    switch(irpStack->MinorFunction) {

    case IRP_MN_START_DEVICE:

        ntStatus = HandleStartDevice(DeviceObject, Irp);

        break;

    case IRP_MN_QUERY_STOP_DEVICE:

        //
        // if we cannot stop the device, we fail the query stop irp
        //

        ntStatus = CanStopDevice(DeviceObject, Irp);

        if(NT_SUCCESS(ntStatus)) {

            ntStatus = HandleQueryStopDevice(DeviceObject, Irp);

            return ntStatus;
        }
        break;

    case IRP_MN_CANCEL_STOP_DEVICE:

        ntStatus = HandleCancelStopDevice(DeviceObject, Irp);

        break;
     
    case IRP_MN_STOP_DEVICE:

        ntStatus = HandleStopDevice(DeviceObject, Irp);

        BulkUsb_DbgPrint(3, ("BulkUsb_DispatchPnP::IRP_MN_STOP_DEVICE::"));
        BulkUsb_IoDecrement(deviceExtension);

        return ntStatus;

    case IRP_MN_QUERY_REMOVE_DEVICE:

        //
        // if we cannot remove the device, we fail the query remove irp
        //
        ntStatus = HandleQueryRemoveDevice(DeviceObject, Irp);

        return ntStatus;

    case IRP_MN_CANCEL_REMOVE_DEVICE:

        ntStatus = HandleCancelRemoveDevice(DeviceObject, Irp);

        break;

    case IRP_MN_SURPRISE_REMOVAL:

        ntStatus = HandleSurpriseRemoval(DeviceObject, Irp);

        BulkUsb_DbgPrint(3, ("BulkUsb_DispatchPnP::IRP_MN_SURPRISE_REMOVAL::"));
        BulkUsb_IoDecrement(deviceExtension);

        return ntStatus;

    case IRP_MN_REMOVE_DEVICE:

        ntStatus = HandleRemoveDevice(DeviceObject, Irp);

        return ntStatus;

    case IRP_MN_QUERY_CAPABILITIES:

        ntStatus = HandleQueryCapabilities(DeviceObject, Irp);

        break;

    default:

        IoSkipCurrentIrpStackLocation(Irp);

        ntStatus = IoCallDriver(deviceExtension->TopOfStackDeviceObject, Irp);

        BulkUsb_DbgPrint(3, ("BulkUsb_DispatchPnP::default::"));
        BulkUsb_IoDecrement(deviceExtension);

        return ntStatus;

    } // switch

//
// complete request 
//

    Irp->IoStatus.Status = ntStatus;
    Irp->IoStatus.Information = 0;

    IoCompleteRequest(Irp, IO_NO_INCREMENT);

//
// decrement count
//
    BulkUsb_DbgPrint(3, ("BulkUsb_DispatchPnP::"));
    BulkUsb_IoDecrement(deviceExtension);

    return ntStatus;
}

NTSTATUS
HandleStartDevice(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP              Irp
    )
/*++
 
Routine Description:

    This is the dispatch routine for IRP_MN_START_DEVICE

Arguments:

    DeviceObject - pointer to a device object.

    Irp - I/O request packet

Return Value:

    NT status value

--*/
{
    KIRQL             oldIrql;
    KEVENT            startDeviceEvent;
    NTSTATUS          ntStatus;
    PDEVICE_EXTENSION deviceExtension;
    LARGE_INTEGER     dueTime;

    BulkUsb_DbgPrint(3, ("HandleStartDevice - begins\n"));

    //
    // initialize variables
    //
    deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
    deviceExtension->UsbConfigurationDescriptor = NULL;
    deviceExtension->UsbInterface = NULL;
    deviceExtension->PipeContext = NULL;

    //
    // We cannot touch the device (send it any non pnp irps) until a
    // start device has been passed down to the lower drivers.
    // first pass the Irp down
    //

    KeInitializeEvent(&startDeviceEvent, NotificationEvent, FALSE);

    IoCopyCurrentIrpStackLocationToNext(Irp);

    IoSetCompletionRoutine(Irp, 
                           (PIO_COMPLETION_ROUTINE)IrpCompletionRoutine, 
                           (PVOID)&startDeviceEvent, 
                           TRUE, 
                           TRUE, 
                           TRUE);

    ntStatus = IoCallDriver(deviceExtension->TopOfStackDeviceObject, Irp);

    if(ntStatus == STATUS_PENDING) {

        KeWaitForSingleObject(&startDeviceEvent, 
                              Executive, 
                              KernelMode, 
                              FALSE, 
                              NULL);

        ntStatus = Irp->IoStatus.Status;
    }

    if(!NT_SUCCESS(ntStatus)) {

        BulkUsb_DbgPrint(1, ("Lower drivers failed this Irp\n"));
        return ntStatus;
    }

    //
    // Read the device descriptor, configuration descriptor 
    // and select the interface descriptors
    //

    ntStatus = ReadandSelectDescriptors(DeviceObject);

    if(!NT_SUCCESS(ntStatus)) {

        BulkUsb_DbgPrint(1, ("ReadandSelectDescriptors failed\n"));
        return ntStatus;
    }

    //
    // enable the symbolic links for system components to open
    // handles to the device
    //

    ntStatus = IoSetDeviceInterfaceState(&deviceExtension->InterfaceName, 
                                         TRUE);

    if(!NT_SUCCESS(ntStatus)) {

        BulkUsb_DbgPrint(1, ("IoSetDeviceInterfaceState:enable:failed\n"));
        return ntStatus;
    }

    KeAcquireSpinLock(&deviceExtension->DevStateLock, &oldIrql);

    SET_NEW_PNP_STATE(deviceExtension, Working);
    deviceExtension->QueueState = AllowRequests;

    KeReleaseSpinLock(&deviceExtension->DevStateLock, oldIrql);

    //
    // initialize wait wake outstanding flag to false.
    // and issue a wait wake.
    
    deviceExtension->FlagWWOutstanding = 0;
    deviceExtension->FlagWWCancel = 0;
    deviceExtension->WaitWakeIrp = NULL;
    
    if(deviceExtension->WaitWakeEnable) {

        IssueWaitWake(deviceExtension);
    }

    ProcessQueuedRequests(deviceExtension);


    if(WinXpOrBetter == deviceExtension->WdmVersion) {


        deviceExtension->SSEnable = deviceExtension->SSRegistryEnable;

        //
        // set timer.for selective suspend requests
        //

        if(deviceExtension->SSEnable) {

            dueTime.QuadPart = -10000 * IDLE_INTERVAL;               // 5000 ms

            KeSetTimerEx(&deviceExtension->Timer, 
                         dueTime,
                         IDLE_INTERVAL,                              // 5000 ms
                         &deviceExtension->DeferredProcCall);

            deviceExtension->FreeIdleIrpCount = 0;
        }
    }

    BulkUsb_DbgPrint(3, ("HandleStartDevice - ends\n"));

    return ntStatus;
}


NTSTATUS
ReadandSelectDescriptors(
    IN PDEVICE_OBJECT DeviceObject
    )
/*++
 
Routine Description:

    This routine configures the USB device.
    In this routines we get the device descriptor, 
    the configuration descriptor and select the
    configuration descriptor.

Arguments:

    DeviceObject - pointer to a device object

Return Value:

    NTSTATUS - NT status value.

--*/
{
    PURB                   urb;
    ULONG                  siz;
    NTSTATUS               ntStatus;
    PUSB_DEVICE_DESCRIPTOR deviceDescriptor;
    
    //
    // initialize variables
    //

    urb = NULL;
    deviceDescriptor = NULL;

    //
    // 1. Read the device descriptor
    //

    urb = ExAllocatePool(NonPagedPool, 
                         sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST));

    if(urb) {

        siz = sizeof(USB_DEVICE_DESCRIPTOR);
        deviceDescriptor = ExAllocatePool(NonPagedPool, siz);

        if(deviceDescriptor) {

            UsbBuildGetDescriptorRequest(
                    urb, 
                    (USHORT) sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),
                    USB_DEVICE_DESCRIPTOR_TYPE, 
                    0, 
                    0, 
                    deviceDescriptor, 
                    NULL, 
                    siz, 
                    NULL);

            ntStatus = CallUSBD(DeviceObject, urb);

            if(NT_SUCCESS(ntStatus)) {

                ASSERT(deviceDescriptor->bNumConfigurations);
                ntStatus = ConfigureDevice(DeviceObject);    
            }
                            
            ExFreePool(urb);                
            ExFreePool(deviceDescriptor);
        }
        else {

            BulkUsb_DbgPrint(1, ("Failed to allocate memory for deviceDescriptor"));

            ExFreePool(urb);
            ntStatus = STATUS_INSUFFICIENT_RESOURCES;
        }
    }
    else {

        BulkUsb_DbgPrint(1, ("Failed to allocate memory for urb"));

        ntStatus = STATUS_INSUFFICIENT_RESOURCES;
    }

    return ntStatus;
}

NTSTATUS
ConfigureDevice(
    IN PDEVICE_OBJECT DeviceObject
    )
/*++

Routine Description:

    This helper routine reads the configuration descriptor
    for the device in couple of steps.

Arguments:

    DeviceObject - pointer to a device object

Return Value:

    NTSTATUS - NT status value

--*/
{
    PURB                          urb;
    ULONG                         siz;
    NTSTATUS                      ntStatus;
    PDEVICE_EXTENSION             deviceExtension;
    PUSB_CONFIGURATION_DESCRIPTOR configurationDescriptor;

    //
    // initialize the variables
    //

    urb = NULL;
    configurationDescriptor = NULL;
    deviceExtension = DeviceObject->DeviceExtension;

    //
    // Read the first configuration descriptor
    // This requires two steps:
    // 1. Read the fixed sized configuration desciptor (CD)
    // 2. Read the CD with all embedded interface and endpoint descriptors
    //

    urb = ExAllocatePool(NonPagedPool, 
                         sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST));

    if(urb) {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区视频在线看| 欧美日韩欧美一区二区| 欧美精品一级二级三级| 久久99久久精品| 色综合色狠狠综合色| 26uuu久久天堂性欧美| 亚洲成av人片| av一区二区久久| 久久久精品综合| 亚洲mv大片欧洲mv大片精品| aaa欧美日韩| 欧美激情一区二区三区全黄| 日韩av电影免费观看高清完整版| 成人av资源在线观看| 久久综合久久久久88| 午夜精品福利一区二区蜜股av| 成人av在线资源网| 久久久久久久久久久黄色| 日本成人在线一区| 欧美性生交片4| 一区二区三区电影在线播| voyeur盗摄精品| 国产精品久久久久久久久免费桃花| 狠狠色狠狠色合久久伊人| 91麻豆精品国产91久久久资源速度| 伊人性伊人情综合网| 95精品视频在线| 国产精品超碰97尤物18| 国产激情精品久久久第一区二区| 久久影视一区二区| 精品一区二区三区免费毛片爱| 88在线观看91蜜桃国自产| 亚洲午夜国产一区99re久久| 欧美伊人久久久久久午夜久久久久| 中文字幕一区二区日韩精品绯色| 国产69精品久久久久毛片| 久久噜噜亚洲综合| 国产一区二区三区四| 26uuu国产日韩综合| 久久国产精品一区二区| 欧美sm美女调教| 精品无人区卡一卡二卡三乱码免费卡| 日韩一区二区三区视频在线| 人人狠狠综合久久亚洲| 日韩一区和二区| 久久69国产一区二区蜜臀| 精品国产乱码久久久久久牛牛| 麻豆精品新av中文字幕| 久久久噜噜噜久久人人看| 国产精品一二三在| 国产欧美日韩亚州综合| av高清久久久| 亚洲一区二区三区在线| 欧美日韩精品一区二区| 日本亚洲电影天堂| 亚洲精品在线观看网站| 国产高清不卡一区二区| 国产精品久久久久精k8| 91免费视频大全| 亚洲国产日韩综合久久精品| 69堂精品视频| 国精产品一区一区三区mba视频| 久久精品一区二区三区不卡| 成人动漫一区二区| 一区二区三区国产| 日韩欧美一级二级| 成人亚洲一区二区一| 一区二区三区四区高清精品免费观看| 午夜av电影一区| 日韩免费电影网站| 成人在线视频一区| 亚洲一区在线看| 欧美电视剧免费全集观看| 粉嫩av一区二区三区| 亚洲精品乱码久久久久久黑人| 欧美精品第1页| 国产一区二区精品久久99| 中文字幕视频一区二区三区久| 欧美亚洲尤物久久| 久久er99精品| 国产精品久久午夜夜伦鲁鲁| 欧美午夜理伦三级在线观看| 久久精品理论片| 亚洲视频一二三区| 欧美一二三区精品| 97久久超碰国产精品| 日韩精品免费专区| 国产欧美日韩在线| 欧美精品亚洲一区二区在线播放| 国产一区二区三区四区在线观看| 亚洲免费看黄网站| 日韩欧美精品在线| 91啦中文在线观看| 精品综合免费视频观看| 亚洲欧美另类小说视频| 日韩欧美你懂的| 色综合久久中文字幕综合网| 激情都市一区二区| 一区二区三区欧美视频| 久久午夜免费电影| 欧美日韩国产另类一区| 国产91精品入口| 蜜臀av性久久久久蜜臀av麻豆| **欧美大码日韩| 精品国内片67194| 色婷婷av一区| 国产不卡免费视频| 麻豆精品在线播放| 亚洲精品中文在线影院| 国产午夜一区二区三区| 欧美日韩成人激情| 99国产精品国产精品久久| 黄色资源网久久资源365| 一区二区免费在线播放| 久久精品视频在线免费观看| 91精品国产综合久久香蕉的特点| 91蝌蚪porny成人天涯| 国产精品一卡二| 蜜桃av一区二区三区电影| 一个色综合网站| 国产精品国产三级国产a| 精品va天堂亚洲国产| 欧美日韩大陆一区二区| 色婷婷激情综合| www.欧美.com| 成人在线综合网站| 国产麻豆精品theporn| 免费看黄色91| 日韩福利电影在线观看| 亚洲高清视频中文字幕| 亚洲欧美国产高清| 国产精品国产三级国产aⅴ原创 | 国产在线精品一区二区三区不卡| 亚洲国产综合色| 亚洲欧美日韩国产另类专区| 国产精品乱人伦| 国产欧美视频一区二区三区| 久久欧美中文字幕| 精品少妇一区二区三区| 老司机免费视频一区二区三区| 日韩影院在线观看| 亚洲成人免费av| 亚洲永久精品国产| 亚洲一区二区三区美女| 亚洲精品国产a| 亚洲日本中文字幕区| 中文字幕视频一区| 国产精品久久久久久久浪潮网站| 中文字幕不卡在线观看| 国产片一区二区| 国产精品伦理一区二区| 国产精品国产三级国产普通话三级| 国产精品嫩草影院av蜜臀| 中文字幕电影一区| 欧美国产日韩精品免费观看| 欧美韩国日本不卡| 中文字幕日本不卡| 亚洲免费在线电影| 亚洲一区二区三区小说| 午夜视频久久久久久| 日韩精彩视频在线观看| 美女任你摸久久 | 一区二区三区在线免费观看| 亚洲美女视频一区| 亚洲一区在线视频| 日韩福利视频导航| 激情文学综合丁香| 成人免费视频播放| 97久久人人超碰| 欧美午夜影院一区| 56国语精品自产拍在线观看| 日韩视频在线永久播放| 精品福利一二区| 国产精品女主播在线观看| 亚洲欧美精品午睡沙发| 亚洲一区二区欧美日韩| 日本欧美在线看| 国产伦精品一区二区三区免费| 国产v综合v亚洲欧| 色婷婷激情一区二区三区| 欧美人牲a欧美精品| 欧美电影免费提供在线观看| 中文字幕欧美激情一区| 亚洲精品精品亚洲| 日韩影院免费视频| 国产成人超碰人人澡人人澡| 一本久久a久久免费精品不卡| 精品视频999| ww久久中文字幕| 亚洲少妇屁股交4| 日韩av高清在线观看| 久久99国产精品久久99果冻传媒| 春色校园综合激情亚洲| 欧洲生活片亚洲生活在线观看| 欧美一区二区三区喷汁尤物| 久久精品这里都是精品| 一区二区在线观看免费| 日韩av一区二区在线影视| 国产裸体歌舞团一区二区| 在线视频你懂得一区|