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

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

?? pnp.c

?? usb to rs232 虛擬RS232串口驅動程序
?? C
?? 第 1 頁 / 共 3 頁
字號:
/*++

Copyright (c) 2005-2006  E0 Technology,Inc.

Module Name:

	pnp.c

Abstract:

	Virtual Com Port Driver for USB to RS232 Converter of E0 Technology,Inc.

Environment:

	Kernel mode

Notes:

Revision History:

    2006/3/1 : 	Adapted from the BulkUsb DDK sample.
--*/

#include "usb2com.h"



NTSTATUS
USB2COM_ProcessPnPIrp(
    IN PDEVICE_OBJECT DeviceObject,
    IN PIRP           Irp
    )
/*++

Routine Description:

    Dispatch table routine for IRP_MJ_PNP.
    Process the Plug and Play IRPs sent to this device.

Arguments:

    DeviceObject - pointer to our FDO (Functional Device Object)

    Irp          - pointer to an I/O Request Packet

Return Value:

    NT status code

--*/
{

    PIO_STACK_LOCATION irpStack;
    PDEVICE_EXTENSION deviceExtension;
    NTSTATUS ntStatus = STATUS_SUCCESS;
    NTSTATUS waitStatus;
    PDEVICE_OBJECT stackDeviceObject;
    KEVENT startDeviceEvent;


    //
    // Get a pointer to the current location in the Irp. This is where
    //     the function codes and parameters are located.
    //
    irpStack = IoGetCurrentIrpStackLocation (Irp);

    //
    // Get a pointer to the device extension
    //

    deviceExtension = DeviceObject->DeviceExtension;
    stackDeviceObject = deviceExtension->TopOfStackDeviceObject;

    USB2COM_KdPrint( DBGLVL_MEDIUM, ( "enter USB2COM_ProcessPnPIrp() IRP_MJ_PNP, minor %s\n",
        USB2COM_StringForPnpMnFunc( irpStack->MinorFunction ) ));

        // inc the FDO device extension's pending IO count for this Irp
    USB2COM_IncrementIoCount(DeviceObject);

    USB2COM_ASSERT( IRP_MJ_PNP == irpStack->MajorFunction );

    switch (irpStack->MinorFunction) {
    case IRP_MN_START_DEVICE:

        // The PnP Manager sends this IRP after it has assigned resources,
        // if any, to the device. The device may have been recently enumerated
        // and is being started for the first time, or the device may be
        // restarting after being stopped for resource reconfiguration.

        // Initialize an event we can wait on for the PDO to be done with this irp
        KeInitializeEvent(&startDeviceEvent, NotificationEvent, FALSE);
        IoCopyCurrentIrpStackLocationToNext(Irp);

        // Set a completion routine so it can signal our event when
        //  the PDO is done with the Irp
        IoSetCompletionRoutine(Irp,
                               USB2COM_IrpCompletionRoutine,
                               &startDeviceEvent,  // pass the event to the completion routine as the Context
                               TRUE,    // invoke on success
                               TRUE,    // invoke on error
                               TRUE);   // invoke on cancellation


        // let the PDO process the IRP
        ntStatus = IoCallDriver(stackDeviceObject,
                                Irp);

        // if PDO is not done yet, wait for the event to be set in our completion routine
        if (ntStatus == STATUS_PENDING) {
             // wait for irp to complete

            waitStatus = KeWaitForSingleObject(
                &startDeviceEvent,
                Suspended,
                KernelMode,
                FALSE,
                NULL);

            ntStatus = Irp->IoStatus.Status;
        }

        if (NT_SUCCESS(ntStatus)) {

            // Now we're ready to do our own startup processing.
            // USB client drivers such as us set up URBs (USB Request Packets) to send requests
            // to the host controller driver (HCD). The URB structure defines a format for all
            // possible commands that can be sent to a USB device.
            // Here, we request the device descriptor and store it,
            // and configure the device.
            ntStatus = USB2COM_StartDevice(DeviceObject);
            Irp->IoStatus.Status = ntStatus;
        }

        IoCompleteRequest (Irp,
                           IO_NO_INCREMENT
                           );

        USB2COM_DecrementIoCount(DeviceObject);
        return ntStatus;  // end, case IRP_MN_START_DEVICE

    case IRP_MN_QUERY_STOP_DEVICE:

                // The IRP_MN_QUERY_STOP_DEVICE/IRP_MN_STOP_DEVICE sequence only occurs
                // during "polite" shutdowns, such as the user explicitily requesting the
                // service be stopped in, or requesting unplug from the Pnp tray icon.
                // This sequence is NOT received during "impolite" shutdowns,
                // such as someone suddenly yanking the USB cord or otherwise
                // unexpectedly disabling/resetting the device.

        // If a driver sets STATUS_SUCCESS for this IRP,
        // the driver must not start any operations on the device that
        // would prevent that driver from successfully completing an IRP_MN_STOP_DEVICE
        // for the device.
        // For mass storage devices such as disk drives, while the device is in the
        // stop-pending state,the driver holds IRPs that require access to the device,
        // but for most USB devices, there is no 'persistent storage', so we will just
        // refuse any more IO until restarted or the stop is cancelled

        // If a driver in the device stack determines that the device cannot be
        // stopped for resource reconfiguration, the driver is not required to pass
        // the IRP down the device stack. If a query-stop IRP fails,
        // the PnP Manager sends an IRP_MN_CANCEL_STOP_DEVICE to the device stack,
        // notifying the drivers for the device that the query has been cancelled
        // and that the device will not be stopped.


        // It is possible to receive this irp when the device has not been started
        //  ( as on a boot device )
        if (!deviceExtension->DeviceStarted) { // if get when never started, just pass on
            USB2COM_KdPrint( DBGLVL_MEDIUM,("USB2COM_ProcessPnPIrp() IRP_MN_QUERY_STOP_DEVICE when device not started\n"));
            IoSkipCurrentIrpStackLocation (Irp);
            ntStatus = IoCallDriver (deviceExtension->TopOfStackDeviceObject, Irp);
            USB2COM_DecrementIoCount(DeviceObject);

            return ntStatus;
        }


        // fail the request if we have any read/write IRPS pending
        if( deviceExtension->StagedPendingIrpCount ) {
            ntStatus = STATUS_UNSUCCESSFUL;
        }
        else {
                        // We'll not veto it; pass it on and flag that stop was requested.
                        // Once StopDeviceRequested is set no new IOCTL or read/write irps will be passed
                        // down the stack to lower drivers; all will be quickly failed
             deviceExtension->StopDeviceRequested = TRUE;
             Irp->IoStatus.Status = STATUS_SUCCESS;
        }

        break; // end, case IRP_MN_QUERY_STOP_DEVICE

    case IRP_MN_CANCEL_STOP_DEVICE:

                // The PnP Manager uses this IRP to inform the drivers for a device
                // that the device will not be stopped for resource reconfiguration.
                // This should only be received after a successful IRP_MN_QUERY_STOP_DEVICE.


        // It is possible to receive this irp when the device has not been started
        if (!deviceExtension->DeviceStarted) { // if get when never started, just pass on
            USB2COM_KdPrint( DBGLVL_MEDIUM,("USB2COM_ProcessPnPIrp() IRP_MN_CANCEL_STOP_DEVICE when device not started\n"));
            IoSkipCurrentIrpStackLocation (Irp);
            ntStatus = IoCallDriver (deviceExtension->TopOfStackDeviceObject, Irp);
            USB2COM_DecrementIoCount(DeviceObject);
            return ntStatus;
        }

                // Reset this flag so new IOCTL and IO Irp processing will be re-enabled
        deviceExtension->StopDeviceRequested = FALSE;
        Irp->IoStatus.Status = STATUS_SUCCESS;
        break; // end, case IRP_MN_CANCEL_STOP_DEVICE

    case IRP_MN_STOP_DEVICE:

                // The PnP Manager sends this IRP to stop a device so it can reconfigure
                // its hardware resources. The PnP Manager only sends this IRP if a prior
                // IRP_MN_QUERY_STOP_DEVICE completed successfully.


        // Cancel any pending io requests.  (there shouldn't be any)
        USB2COM_CancelPendingIo( DeviceObject );
        //
        // Send the select configuration urb with a NULL pointer for the configuration
        // handle, this closes the configuration and puts the device in the 'unconfigured'
        // state.
        //
        ntStatus = USB2COM_StopDevice(DeviceObject);
        Irp->IoStatus.Status = ntStatus;

        break; // end, case IRP_MN_STOP_DEVICE



    case IRP_MN_QUERY_REMOVE_DEVICE:

        //  In response to this IRP, drivers indicate whether the device can be
        //  removed without disrupting the system.
        //  If a driver determines it is safe to remove the device,
        //  the driver completes any outstanding I/O requests, arranges to hold any subsequent
        //  read/write requests, and sets Irp->IoStatus.Status to STATUS_SUCCESS. Function
        //  and filter drivers then pass the IRP to the next-lower driver in the device stack.
        //  The underlying bus driver calls IoCompleteRequest.

        //  If a driver sets STATUS_SUCCESS for this IRP, the driver must not start any
        //  operations on the device that would prevent that driver from successfully completing
        //  an IRP_MN_REMOVE_DEVICE for the device. If a driver in the device stack determines
        //  that the device cannot be removed, the driver is not required to pass the
        //  query-remove IRP down the device stack. If a query-remove IRP fails, the PnP Manager
        //  sends an IRP_MN_CANCEL_REMOVE_DEVICE to the device stack, notifying the drivers for
        //  the device that the query has been cancelled and that the device will not be removed.

        // It is possible to receive this irp when the device has not been started
        if (!deviceExtension->DeviceStarted) { // if get when never started, just pass on
            USB2COM_KdPrint( DBGLVL_MEDIUM,("USB2COM_ProcessPnPIrp() IRP_MN_QUERY_STOP_DEVICE when device not started\n"));
            IoSkipCurrentIrpStackLocation (Irp);
            ntStatus = IoCallDriver (deviceExtension->TopOfStackDeviceObject, Irp);
            USB2COM_DecrementIoCount(DeviceObject);

            return ntStatus;
        }

                // Once RemoveDeviceRequested is set no new IOCTL or read/write irps will be passed
                // down the stack to lower drivers; all will be quickly failed
       deviceExtension->RemoveDeviceRequested = TRUE;

        // Wait for any io request pending in our driver to
        // complete before returning success.
                // This  event is set when deviceExtension->PendingIoCount goes to 1
        // match the inc at the begining of the dispatch routine
        USB2COM_DecrementIoCount(DeviceObject);
        waitStatus = KeWaitForSingleObject(
                    &deviceExtension->NoPendingIoEvent,
                    Suspended,
                    KernelMode,
                    FALSE,
                    NULL);

	USB2COM_IncrementIoCount(DeviceObject);
        Irp->IoStatus.Status = STATUS_SUCCESS;
        break; // end, case IRP_MN_QUERY_REMOVE_DEVICE

    case IRP_MN_CANCEL_REMOVE_DEVICE:

                // The PnP Manager uses this IRP to inform the drivers
                // for a device that the device will not be removed.
                // It is sent only after a successful IRP_MN_QUERY_REMOVE_DEVICE.

        if (!deviceExtension->DeviceStarted) { // if get when never started, just pass on
            USB2COM_KdPrint( DBGLVL_MEDIUM,("USB2COM_ProcessPnPIrp() IRP_MN_CANCEL_REMOVE_DEVICE when device not started\n"));
            IoSkipCurrentIrpStackLocation (Irp);
            ntStatus = IoCallDriver (deviceExtension->TopOfStackDeviceObject, Irp);
            USB2COM_DecrementIoCount(DeviceObject);
            return ntStatus;
        }

                // Reset this flag so new IOCTL and IO Irp processing will be re-enabled
        deviceExtension->RemoveDeviceRequested = FALSE;
        Irp->IoStatus.Status = STATUS_SUCCESS;

        break; // end, case IRP_MN_CANCEL_REMOVE_DEVICE

    case IRP_MN_SURPRISE_REMOVAL:
        USB2COM_KdPrint( DBGLVL_MEDIUM,("USB2COM_ProcessPnPIrp() IRP_MN_SURPRISE_REMOVAL\n"));

        // For a surprise-style device removal ( i.e. sudden cord yank ),
        // the physical device has already been removed so the PnP Manager sends
        // the remove IRP without a prior query-remove. A device can be in any state
        // when it receives a remove IRP as a result of a surprise-style removal.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲午夜久久久| 日本v片在线高清不卡在线观看| 91官网在线免费观看| 热久久国产精品| 国产精品久久久久aaaa樱花| 91精品国产综合久久久蜜臀粉嫩 | 国产精品视频第一区| 欧美色精品在线视频| 国产精品1区二区.| 天堂av在线一区| 亚洲另类春色国产| 国产欧美日韩激情| 欧美一级片在线| 色8久久精品久久久久久蜜| 日韩欧美你懂的| 在线视频一区二区三区| 成人午夜私人影院| 久久99国产乱子伦精品免费| 亚洲一二三四区| 中文字幕亚洲在| 久久久久久久网| 欧美mv和日韩mv国产网站| 欧美日韩视频第一区| 91浏览器在线视频| 不卡的av在线| 国产成人免费视频网站高清观看视频| 免费成人在线观看视频| 亚洲第四色夜色| 亚洲在线视频网站| 亚洲乱码国产乱码精品精可以看 | 一区二区三区四区在线播放| 国产精品沙发午睡系列990531| 欧美mv日韩mv国产网站app| 7777精品伊人久久久大香线蕉 | 香蕉成人啪国产精品视频综合网| 亚洲视频免费看| 国产精品初高中害羞小美女文| 国产精品美女久久久久久久久| 国产色婷婷亚洲99精品小说| 久久久国产一区二区三区四区小说| 日韩三区在线观看| 日韩免费观看2025年上映的电影 | 国产精品视频一区二区三区不卡| 26uuu另类欧美| 久久久不卡网国产精品二区| 久久众筹精品私拍模特| 久久影院午夜片一区| 久久美女艺术照精彩视频福利播放| 精品国产乱码久久久久久浪潮 | 亚洲香蕉伊在人在线观| 亚洲制服丝袜在线| 夜夜嗨av一区二区三区中文字幕| 有坂深雪av一区二区精品| 一区二区三区成人| 五月天欧美精品| 日本不卡一区二区三区高清视频| 男女性色大片免费观看一区二区 | 精品视频全国免费看| 欧美精品v日韩精品v韩国精品v| 欧美精品精品一区| 日韩美女在线视频 | 欧美成人性战久久| 久久精品人人做人人爽97| 亚洲国产精品成人综合| 亚洲欧美激情插| 亚洲国产精品一区二区www在线| 日韩专区欧美专区| 国产一区二区在线视频| www.亚洲免费av| 欧美性xxxxx极品少妇| 欧美一区二区三区在线视频| 久久亚洲免费视频| 亚洲男同1069视频| 首页亚洲欧美制服丝腿| 国产一区二区三区最好精华液| 成人丝袜视频网| 欧美性受xxxx黑人xyx| 日韩欧美美女一区二区三区| 国产精品视频第一区| 亚洲成人av电影在线| 国产美女精品一区二区三区| 91麻豆自制传媒国产之光| 欧美日韩夫妻久久| 国产欧美视频一区二区三区| 亚洲日本va午夜在线电影| 日本成人在线一区| 99精品黄色片免费大全| 91精品国产91久久综合桃花| 欧美韩国日本一区| 久久久国产精品不卡| 亚洲高清中文字幕| 国产成人精品三级麻豆| 欧美色网站导航| 日本一区二区免费在线| 午夜在线电影亚洲一区| 不卡av在线网| 日韩免费在线观看| 亚洲一区二区四区蜜桃| 国产91丝袜在线18| 色婷婷国产精品久久包臀 | 久久久久久久久伊人| 亚洲欧洲三级电影| 久久精品国产秦先生| 欧美综合天天夜夜久久| 欧美激情综合五月色丁香小说| 午夜精品久久久| 成人一级片在线观看| 日韩欧美精品三级| 亚洲高清免费视频| 9l国产精品久久久久麻豆| 26uuu久久天堂性欧美| 偷窥少妇高潮呻吟av久久免费| 成人一区二区在线观看| 欧美一二三在线| 亚洲成a人片在线观看中文| 成人精品视频网站| 国产亚洲午夜高清国产拍精品| 日本亚洲天堂网| 欧美日韩一区在线| 亚洲欧美激情在线| voyeur盗摄精品| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 看电视剧不卡顿的网站| 色琪琪一区二区三区亚洲区| 中文幕一区二区三区久久蜜桃| 久久成人av少妇免费| 日韩一区和二区| 日韩国产在线一| 欧美肥胖老妇做爰| 亚洲va在线va天堂| 欧美日韩国产一级片| 亚洲一区二区黄色| 欧美写真视频网站| 亚洲电影中文字幕在线观看| 在线观看国产日韩| 亚洲综合色成人| 欧美熟乱第一页| 亚洲国产裸拍裸体视频在线观看乱了| 色婷婷av一区| 一区二区在线观看免费 | 欧美亚洲动漫另类| 一区二区免费在线| 欧美日韩一区二区三区在线看| 亚洲自拍偷拍网站| 精品视频在线免费看| 日韩av一区二区三区四区| 91 com成人网| 久久精品99国产精品日本| 欧美精品一区二区三区在线| 国产一区二区毛片| 国产日韩亚洲欧美综合| 精品人在线二区三区| 国产原创一区二区三区| 国产日产欧美一区| 91在线视频播放| 一区二区三区久久| 91精品福利在线一区二区三区| 理论片日本一区| 久久精品一区蜜桃臀影院| 国产福利精品一区| 日韩一区中文字幕| 欧美日韩精品二区第二页| 日本午夜一本久久久综合| 精品久久国产字幕高潮| 国产99精品在线观看| 亚洲免费av在线| 欧美日本在线播放| 国产一区在线观看视频| 中文字幕日韩av资源站| 欧美日韩日日骚| 国产精品综合二区| 亚洲欧美精品午睡沙发| 日韩一区二区中文字幕| 福利一区二区在线| 亚洲电影视频在线| 久久久精品影视| 在线这里只有精品| 精品一区二区三区免费| 国产精品的网站| 欧美一区二区三区思思人| 国产99一区视频免费| 一级中文字幕一区二区| 欧美精品一区二区蜜臀亚洲| 色婷婷久久久综合中文字幕| 9i在线看片成人免费| 亚洲一区二区三区中文字幕| 精品国精品自拍自在线| 91女厕偷拍女厕偷拍高清| 麻豆91精品91久久久的内涵| 国产精品伦一区二区三级视频| 亚洲人成伊人成综合网小说| 欧美日韩一区高清| 国产69精品久久99不卡| 性久久久久久久久久久久| 亚洲国产电影在线观看| 欧美精品精品一区| av亚洲精华国产精华精华| 久久99热这里只有精品| 亚洲一区国产视频| 国产精品成人午夜|