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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? bulkdev.c

?? 全面介紹USB_F320的實(shí)用文章USB_F320
?? C
?? 第 1 頁(yè) / 共 3 頁(yè)
字號(hào):
    else {

        KdPrint( ("BulkUsb_ResetPipe - failed\n"));
    }

    return ntStatus;
}

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

    This routine invokes BulkUsb_ResetParentPort to reset the device

Arguments:

    DeviceObject - pointer to device object

Return Value:

    NT status value

--*/
{
    NTSTATUS ntStatus;
    ULONG    portStatus;

    KdPrint( ("BulkUsb_ResetDevice - begins\n"));

    ntStatus = BulkUsb_GetPortStatus(DeviceObject, &portStatus);

    if((NT_SUCCESS(ntStatus))                 &&
       (!(portStatus & USBD_PORT_ENABLED))    &&
       (portStatus & USBD_PORT_CONNECTED)) {

        ntStatus = BulkUsb_ResetParentPort(DeviceObject);
    }

    KdPrint( ("BulkUsb_ResetDevice - ends\n"));

    return ntStatus;
}

NTSTATUS
BulkUsb_GetPortStatus(
    IN PDEVICE_OBJECT DeviceObject,
    IN OUT PULONG     PortStatus
    )
/*++
 
Routine Description:

    This routine retrieves the status value

Arguments:

    DeviceObject - pointer to device object
    PortStatus - port status

Return Value:

    NT status value

--*/
{
    NTSTATUS           ntStatus;
    KEVENT             event;
    PIRP               irp;
    IO_STATUS_BLOCK    ioStatus;
    PIO_STACK_LOCATION nextStack;
    PDEVICE_EXTENSION  deviceExtension;

    //
    // initialize variables
    //
    deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;
    *PortStatus = 0;

    KdPrint( ("BulkUsb_GetPortStatus - begins\n"));

    KeInitializeEvent(&event, NotificationEvent, FALSE);

    irp = IoBuildDeviceIoControlRequest(
                    IOCTL_INTERNAL_USB_GET_PORT_STATUS,
                    deviceExtension->TopOfStackDeviceObject,
                    NULL,
                    0,
                    NULL,
                    0,
                    TRUE,
                    &event,
                    &ioStatus);

    if(NULL == irp) {

        KdPrint( ("memory alloc for irp failed\n"));
        return STATUS_INSUFFICIENT_RESOURCES;
    }

    nextStack = IoGetNextIrpStackLocation(irp);

    ASSERT(nextStack != NULL);

    nextStack->Parameters.Others.Argument1 = PortStatus;

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

    if(STATUS_PENDING == ntStatus) {

        KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
    }
    else {

        ioStatus.Status = ntStatus;
    }

    ntStatus = ioStatus.Status;

    KdPrint( ("BulkUsb_GetPortStatus - ends\n"));

    return ntStatus;
}

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

    This routine sends an IOCTL_INTERNAL_USB_RESET_PORT
    synchronously down the stack.

Arguments:

Return Value:

--*/
{
    NTSTATUS           ntStatus;
    KEVENT             event;
    PIRP               irp;
    IO_STATUS_BLOCK    ioStatus;
    PIO_STACK_LOCATION nextStack;
    PDEVICE_EXTENSION  deviceExtension;

    //
    // initialize variables
    //
    deviceExtension = (PDEVICE_EXTENSION) DeviceObject->DeviceExtension;

    KdPrint( ("BulkUsb_ResetParentPort - begins\n"));

    KeInitializeEvent(&event, NotificationEvent, FALSE);

    irp = IoBuildDeviceIoControlRequest(
                    IOCTL_INTERNAL_USB_RESET_PORT,
                    deviceExtension->TopOfStackDeviceObject,
                    NULL,
                    0,
                    NULL,
                    0,
                    TRUE,
                    &event,
                    &ioStatus);

    if(NULL == irp) {

        KdPrint( ("memory alloc for irp failed\n"));
        return STATUS_INSUFFICIENT_RESOURCES;
    }

    nextStack = IoGetNextIrpStackLocation(irp);

    ASSERT(nextStack != NULL);

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

    if(STATUS_PENDING == ntStatus) {

        KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
    }
    else {

        ioStatus.Status = ntStatus;
    }

    ntStatus = ioStatus.Status;

    KdPrint( ("BulkUsb_ResetParentPort - ends\n"));

    return ntStatus;
}


NTSTATUS
SubmitIdleRequestIrp(
    IN PDEVICE_EXTENSION DeviceExtension
    )
/*++
 
Routine Description:

    This routine builds an idle request irp with an associated callback routine
    and a completion routine in the driver and passes the irp down the stack.

Arguments:

    DeviceExtension - pointer to device extension

Return Value:

    NT status value

--*/
{
    PIRP                    irp;
    NTSTATUS                ntStatus;
    KIRQL                   oldIrql;
    PUSB_IDLE_CALLBACK_INFO idleCallbackInfo;
    PIO_STACK_LOCATION      nextStack;

    //
    // initialize variables
    //
    
    irp = NULL;
    idleCallbackInfo = NULL;

    KdPrint( ("SubmitIdleRequest - begins\n"));

    ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);

    if(PowerDeviceD0 != DeviceExtension->DevPower) {

        ntStatus = STATUS_POWER_STATE_INVALID;

        goto SubmitIdleRequestIrp_Exit;
    }

    KeAcquireSpinLock(&DeviceExtension->IdleReqStateLock, &oldIrql);

    if(InterlockedExchange(&DeviceExtension->IdleReqPend, 1)) {

        KdPrint( ("Idle request pending..\n"));

        KeReleaseSpinLock(&DeviceExtension->IdleReqStateLock, oldIrql);

        ntStatus = STATUS_DEVICE_BUSY;

        goto SubmitIdleRequestIrp_Exit;
    }

    //
    // clear the NoIdleReqPendEvent because we are about 
    // to submit an idle request. Since we are so early
    // to clear this event, make sure that if we fail this
    // request we set back the event.
    //
    KeClearEvent(&DeviceExtension->NoIdleReqPendEvent);

    idleCallbackInfo = ExAllocatePool(NonPagedPool, 
                                      sizeof(struct _USB_IDLE_CALLBACK_INFO));

    if(idleCallbackInfo) {

        idleCallbackInfo->IdleCallback = IdleNotificationCallback;

        idleCallbackInfo->IdleContext = (PVOID)DeviceExtension;

        ASSERT(DeviceExtension->IdleCallbackInfo == NULL);

        DeviceExtension->IdleCallbackInfo = idleCallbackInfo;

        //
        // we use IoAllocateIrp to create an irp to selectively suspend the 
        // device. This irp lies pending with the hub driver. When appropriate
        // the hub driver will invoked callback, where we power down. The completion
        // routine is invoked when we power back.
        //
        irp = IoAllocateIrp(DeviceExtension->TopOfStackDeviceObject->StackSize,
                            FALSE);

        if(irp == NULL) {

            KdPrint( ("cannot build idle request irp\n"));

            KeSetEvent(&DeviceExtension->NoIdleReqPendEvent,
                       IO_NO_INCREMENT,
                       FALSE);

            InterlockedExchange(&DeviceExtension->IdleReqPend, 0);

            KeReleaseSpinLock(&DeviceExtension->IdleReqStateLock, oldIrql);

            ExFreePool(idleCallbackInfo);

            ntStatus = STATUS_INSUFFICIENT_RESOURCES;

            goto SubmitIdleRequestIrp_Exit;
        }

        nextStack = IoGetNextIrpStackLocation(irp);

        nextStack->MajorFunction = 
                    IRP_MJ_INTERNAL_DEVICE_CONTROL;

        nextStack->Parameters.DeviceIoControl.IoControlCode = 
                    IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION;

        nextStack->Parameters.DeviceIoControl.Type3InputBuffer =
                    idleCallbackInfo;

        nextStack->Parameters.DeviceIoControl.InputBufferLength =
                    sizeof(struct _USB_IDLE_CALLBACK_INFO);


        IoSetCompletionRoutine(irp, 
                               IdleNotificationRequestComplete,
                               DeviceExtension, 
                               TRUE, 
                               TRUE, 
                               TRUE);

        DeviceExtension->PendingIdleIrp = irp;

        //
        // we initialize the count to 2.
        // The reason is, if the CancelSelectSuspend routine manages
        // to grab the irp from the device extension, then the last of the
        // CancelSelectSuspend routine/IdleNotificationRequestComplete routine 
        // to execute will free this irp. We need to have this schema so that
        // 1. completion routine does not attempt to touch the irp freed by 
        //    CancelSelectSuspend routine.
        // 2. CancelSelectSuspend routine doesnt wait for ever for the completion
        //    routine to complete!
        //
        DeviceExtension->FreeIdleIrpCount = 2;

        KeReleaseSpinLock(&DeviceExtension->IdleReqStateLock, oldIrql);

        //
        // check if the device is idle.
        // A check here ensures that a race condition did not 
        // completely reverse the call sequence of SubmitIdleRequestIrp
        // and CancelSelectiveSuspend
        //

        if(!CanDeviceSuspend(DeviceExtension) ||
           PowerDeviceD0 != DeviceExtension->DevPower) {

            //
            // IRPs created using IoBuildDeviceIoControlRequest should be
            // completed by calling IoCompleteRequest and not merely 
            // deallocated.
            //
     
            KdPrint( ("Device is not idle\n"));

            KeAcquireSpinLock(&DeviceExtension->IdleReqStateLock, &oldIrql);

            DeviceExtension->IdleCallbackInfo = NULL;

            DeviceExtension->PendingIdleIrp = NULL;

            KeSetEvent(&DeviceExtension->NoIdleReqPendEvent,
                       IO_NO_INCREMENT,
                       FALSE);

            InterlockedExchange(&DeviceExtension->IdleReqPend, 0);

            KeReleaseSpinLock(&DeviceExtension->IdleReqStateLock, oldIrql);

            if(idleCallbackInfo) {

                ExFreePool(idleCallbackInfo);
            }

            //
            // it is still safe to touch the local variable "irp" here.
            // the irp has not been passed down the stack, the irp has
            // no cancellation routine. The worse position is that the
            // CancelSelectSuspend has run after we released the spin 
            // lock above. It is still essential to free the irp.
            //
            if(irp) {

                IoFreeIrp(irp);
            }

            goto SubmitIdleRequestIrp_Exit;
        }

        KdPrint( ("Cancel the timers\n"));
        //
        // Cancel the timer so that the DPCs are no longer fired.
        // Thus, we are making judicious usage of our resources.
        // we do not need DPCs because we already have an idle irp pending.
        // The timers are re-initialized in the completion routine.
        //
        KeCancelTimer(&DeviceExtension->Timer);

        ntStatus = IoCallDriver(DeviceExtension->TopOfStackDeviceObject, irp);

        if(!NT_SUCCESS(ntStatus)) {

            KdPrint( ("IoCallDriver failed\n"));

            goto SubmitIdleRequestIrp_Exit;
        }
    }
    else {

        KdPrint( ("Memory allocation for idleCallbackInfo failed\n"));

        KeSetEvent(&DeviceExtension->NoIdleReqPendEvent,
                   IO_NO_INCREMENT,
                   FALSE);

        InterlockedExchange(&DeviceExtension->IdleReqPend, 0);

        KeReleaseSpinLock(&DeviceExtension->IdleReqStateLock, oldIrql);

        ntStatus = STATUS_INSUFFICIENT_RESOURCES;
    }

SubmitIdleRequestIrp_Exit:

    KdPrint( ("SubmitIdleRequest - ends\n"));

    return ntStatus;
}


VOID
IdleNotificationCallback(
    IN PDEVICE_EXTENSION DeviceExtension
    )
/*++
 
Routine Description:

  "A pointer to a callback function in your driver is passed down the stack with
   this IOCTL, and it is this callback function that is called by USBHUB when it
   safe for your device to power down."

  "When the callback in your driver is called, all you really need to do is to
   to first ensure that a WaitWake Irp has been submitted for your device, if 
   remote wake is possible for your device and then request a SetD2 (or DeviceWake)"

Arguments:

    DeviceExtension - pointer to device extension

Return Value:

    NT status value

--*/
{
    NTSTATUS                ntStatus;
    POWER_STATE             powerState;
    KEVENT                  irpCompletionEvent;
    PIRP_COMPLETION_CONTEXT irpContext;

    KdPrint( ("IdleNotificationCallback - begins\n"));

    //
    // Dont idle, if the device was just disconnected or being stopped
    // i.e. return for the following DeviceState(s)
    // NotStarted, Stopped, PendingStop, PendingRemove, SurpriseRemoved, Removed
    //

    if(DeviceExtension->DeviceState != Working) {

        return;
    }

    //
    // If there is not already a WW IRP pending, submit one now
    //
    if(DeviceExtension->WaitWakeEnable) {

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线亚洲高清视频| 国产91丝袜在线播放九色| 在线观看91精品国产入口| 国产精品欧美久久久久一区二区| 国内一区二区视频| 久久九九久久九九| 成人v精品蜜桃久久一区| 亚洲三级免费观看| 色婷婷久久一区二区三区麻豆| 亚洲午夜私人影院| 欧美军同video69gay| 久久99精品久久只有精品| 国产网站一区二区三区| 91看片淫黄大片一级在线观看| 亚洲综合图片区| 日韩精品在线一区二区| 懂色av一区二区三区免费看| 亚洲人成电影网站色mp4| 欧美三区在线观看| 久草热8精品视频在线观看| 国产欧美一区二区三区在线看蜜臀| 91在线视频观看| 亚洲444eee在线观看| 国产网红主播福利一区二区| 在线观看一区二区视频| 麻豆91精品91久久久的内涵| 中文字幕精品在线不卡| 欧美日精品一区视频| 精品一区二区三区视频| 亚洲欧美另类久久久精品| 91精品国产欧美一区二区| 高清不卡在线观看| 午夜精品视频在线观看| 久久久国产精华| 欧美日韩一区二区三区不卡| 国产一区二区三区精品欧美日韩一区二区三区 | 成人性视频免费网站| 夜色激情一区二区| 久久亚洲精精品中文字幕早川悠里| 色婷婷久久久综合中文字幕| 韩国成人精品a∨在线观看| 亚洲一区二区三区影院| 国产欧美视频一区二区三区| 在线免费观看视频一区| 国产.欧美.日韩| 亚洲成a人v欧美综合天堂| 国产精品蜜臀av| 欧美大片国产精品| 欧美色区777第一页| 99久久久国产精品免费蜜臀| 久久99久久精品| 五月婷婷欧美视频| 亚洲欧美一区二区三区极速播放| 精品国产区一区| 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 欧美性三三影院| 成人中文字幕电影| 激情综合一区二区三区| 欧美96一区二区免费视频| 亚洲精品日韩综合观看成人91| 久久网站热最新地址| 日韩一区二区三区电影| 欧美久久久影院| 91国偷自产一区二区开放时间| 成人小视频免费在线观看| av一区二区三区| 久久成人免费网| 日本午夜精品一区二区三区电影| 亚洲伊人色欲综合网| 亚洲精品免费在线观看| 国产精品久久久久久久久果冻传媒 | 欧美日韩精品欧美日韩精品一综合| a4yy欧美一区二区三区| 不卡一区中文字幕| 国产精品一区二区久久精品爱涩| 伦理电影国产精品| 蜜臀av在线播放一区二区三区| 日韩中文字幕一区二区三区| 日韩激情一二三区| 日韩电影免费在线观看网站| 蜜桃精品在线观看| 奇米精品一区二区三区四区| 久久精品噜噜噜成人av农村| 久久电影网电视剧免费观看| 精品一区二区三区在线视频| 精品一区二区三区在线观看国产| 久久97超碰色| 国产一区二区三区四| 高清不卡一二三区| youjizz国产精品| 91香蕉视频黄| 欧美亚洲综合另类| 欧美猛男超大videosgay| 777午夜精品免费视频| 欧美电影免费观看高清完整版在线 | 波多野结衣在线aⅴ中文字幕不卡 波多野结衣在线一区 | 91社区在线播放| 色欧美乱欧美15图片| 欧美综合天天夜夜久久| 91精品国产综合久久久久久久久久 | 色94色欧美sute亚洲线路一久| 欧美曰成人黄网| 欧美一级艳片视频免费观看| 久久久久久久精| 亚洲图片欧美激情| 亚洲一级片在线观看| 久久丁香综合五月国产三级网站| 国产福利91精品| 色久优优欧美色久优优| 日韩你懂的在线播放| 国产精品久久久久久久浪潮网站 | 一区二区三区在线视频免费| 亚洲h在线观看| 国产老妇另类xxxxx| 99精品久久久久久| 欧美群妇大交群的观看方式| 国产欧美日韩综合| 国产一区久久久| 色先锋资源久久综合| 日韩欧美在线观看一区二区三区| 中文字幕 久热精品 视频在线| 亚洲超碰97人人做人人爱| 国内精品不卡在线| 日本韩国欧美国产| 精品国产精品网麻豆系列 | 亚洲欧美日韩国产另类专区 | 一区二区高清在线| 久久97超碰色| 欧美在线不卡视频| 中文字幕av一区二区三区高| 日韩成人dvd| 99视频一区二区三区| 日韩一区二区精品葵司在线| 亚洲免费观看高清| 久久99热这里只有精品| 欧美在线观看视频在线| 国产精品色哟哟| 蜜臀av一区二区三区| 91电影在线观看| 国产精品久久久久一区| 久久不见久久见免费视频1 | 日韩欧美亚洲另类制服综合在线| 自拍偷在线精品自拍偷无码专区| 国内欧美视频一区二区| 欧美三级电影在线看| 亚洲精品国产精品乱码不99| 国产成人精品一区二区三区四区| 日韩一区二区在线看片| 五月婷婷色综合| 在线看日本不卡| 亚洲色图视频免费播放| 成人国产精品免费观看| 久久精品男人天堂av| 国产美女视频91| 2020国产精品自拍| 美脚の诱脚舐め脚责91| 日韩视频国产视频| 五月天丁香久久| 欧美日韩电影在线播放| 亚洲高清免费观看 | 99精品国产91久久久久久| 欧美激情一区在线| 国产一区二区三区免费播放| 26uuu久久综合| 国产一区二区在线观看视频| 精品久久久久久最新网址| 热久久免费视频| 欧美一区二区性放荡片| 三级成人在线视频| 制服丝袜国产精品| 日韩专区中文字幕一区二区| 欧美一区二区性放荡片| 久久国产精品99久久久久久老狼 | 日韩福利视频网| 欧美高清精品3d| 日本欧美一区二区| 日韩精品一区二区在线观看| 精品在线播放免费| 精品成人免费观看| 国产美女在线精品| 国产精品丝袜91| 91丨porny丨首页| 亚洲一区中文日韩| 91精品国产全国免费观看| 韩国av一区二区三区在线观看| 国产亚洲女人久久久久毛片| av亚洲产国偷v产偷v自拍| 亚洲伦在线观看| 欧美日韩在线播放| 久草中文综合在线| 亚洲欧洲日韩av| 欧美精品久久一区| 狠狠色丁香久久婷婷综合丁香| 国产精品丝袜91| 欧美午夜理伦三级在线观看| 老司机免费视频一区二区| 久久久久久久久岛国免费| 一本一本久久a久久精品综合麻豆 一本一道波多野结衣一区二区 | 色综合久久久网| 视频一区中文字幕国产|