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

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

?? usbfx2lk_usb.cpp

?? VisualC++寫的一個USB的驅動程序。
?? CPP
?? 第 1 頁 / 共 5 頁
字號:
///////////////////////////////////////////////////////////////////////////////
//
//    (C) Copyright 2005 OSR Open Systems Resources, Inc.
//    All Rights Reserved
//
//    This sofware is supplied for instructional purposes only.
//
//    OSR Open Systems Resources, Inc. (OSR) expressly disclaims any warranty
//    for this software.  THIS SOFTWARE IS PROVIDED  "AS IS" WITHOUT WARRANTY
//    OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION,
//    THE IMPLIED WARRANTIES OF MECHANTABILITY OR FITNESS FOR A PARTICULAR
//    PURPOSE.  THE ENTIRE RISK ARISING FROM THE USE OF THIS SOFTWARE REMAINS
//    WITH YOU.  OSR's entire liability and your exclusive remedy shall not
//    exceed the price paid for this material.  In no event shall OSR or its
//    suppliers be liable for any damages whatsoever (including, without
//    limitation, damages for loss of business profit, business interruption,
//    loss of business information, or any other pecuniary loss) arising out
//    of the use or inability to use this software, even if OSR has been
//    advised of the possibility of such damages.  Because some states/
//    jurisdictions do not allow the exclusion or limitation of liability for
//    consequential or incidental damages, the above limitation may not apply
//    to you.
//
//    OSR Open Systems Resources, Inc.
//    105 Route 101A Suite 19
//    Amherst, NH 03031  (603) 595-6500 FAX: (603) 595-6503
//    email bugs to: bugs@osr.com
//
//
//    MODULE:
//
//      USBFx2LK_PnP.cpp
//
//    ABSTRACT:
//
//      This file contains the routines that handle Plug and Play processing for the 
//      OSR USB FX2 Learning Kit Device
//
//    AUTHOR(S):
//
//      OSR Open Systems Resources, Inc.
// 
///////////////////////////////////////////////////////////////////////////////
#include "usbfx2lk.h"

#ifdef WPP_TRACING
//
// Include the necessary tmh file - this is 
//  just a matter of course if you're using WPP tracing.
//
extern "C" {
#include "usbfx2lk_usb.tmh"
}
#endif

//
// Forward Definitions
//
NTSTATUS SubmitUrb(PUSBFX2LK_EXT DevExt,PURB Urb);
NTSTATUS ConfigureUsbDevice(PUSBFX2LK_EXT DevExt);
NTSTATUS SelectUsbInterfaces(PUSBFX2LK_EXT DevExt,
                             PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor);
VOID DetermineDeviceSpeed(PUSBFX2LK_EXT DevExt);
#ifndef IoForwardIrpSynchronously
NTSTATUS DetermineDeviceSpeedCompletionRoutine(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context);
#endif //IoForwardIrpSynchronously
NTSTATUS AsynchronousUrbRequestCompletion(IN PDEVICE_OBJECT DeviceObject,
                                          IN PIRP Irp, IN PVOID Context);


///////////////////////////////////////////////////////////////////////////////
//
// ReadandSelectUsbDescriptors
//
//  This routine is called by OsrStartDevice to Read and Select the USB
//  descriptors that will be used to talk to the usb device.
//
//
//  INPUTS:
//
//      DevExt  -  Address of the Devices Device Extension.
//
//  OUTPUTS:
//
//      None
//
//  RETURNS:
//
//      None
//
//  IRQL:
//
//      IRQL == PASSIVE_LEVEL
//
//  CONTEXT:
//
//      Arbitrary Context
//
//  NOTES:
//
///////////////////////////////////////////////////////////////////////////////
NTSTATUS ReadandSelectUsbDescriptors(PUSBFX2LK_EXT DevExt)
{
    PURB                   urb = NULL;
    NTSTATUS               status;
    PUSB_DEVICE_DESCRIPTOR deviceDescriptor = NULL;
    
    OsrTracePrint(TRACE_LEVEL_VERBOSE,OSRDBG_USB,("ReadandSelectUsbDescriptors: Enter\n"));

    //
    // Allocate a URB.
    //
    urb = (PURB) ExAllocatePoolWithTag(NonPagedPool, sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),'bruO');

    if(urb) {

        //
        // Allocate a USB_DEVICE_DESCRIPTOR to receive the device descriptor from our device.
        //
        deviceDescriptor = (PUSB_DEVICE_DESCRIPTOR) ExAllocatePoolWithTag(NonPagedPool, 
                                                        sizeof(USB_DEVICE_DESCRIPTOR), 'dduO');

        if(deviceDescriptor) {

            //
            // Format the Urb for the request to get the USB_DEVICE_DESCRIPTOR
            //
            UsbBuildGetDescriptorRequest(
                    urb, 
                    (USHORT) sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),
                    USB_DEVICE_DESCRIPTOR_TYPE, 
                    0, 
                    0, 
                    deviceDescriptor, 
                    NULL, 
                    sizeof(USB_DEVICE_DESCRIPTOR), 
                    NULL);

            //
            // Submit the URB to the Device
            //
            status = SubmitUrb(DevExt,urb);

            //
            // If the request is successful, then configure the device
            //
            if(NT_SUCCESS(status)) {

                ASSERT(deviceDescriptor->bNumConfigurations);

                //
                // Save away the device descriptor
                //
                DevExt->UsbDeviceDescriptor = deviceDescriptor;

                status = ConfigureUsbDevice(DevExt);    

            } else {

                //
                // No descriptor info? Clean up.
                //
                ExFreePool(deviceDescriptor);

            }
              
            //
            // Free the URB 
            //
            ExFreePool(urb);

        } else {

            OsrTracePrint(TRACE_LEVEL_ERROR,OSRDBG_USB,
                ("ReadandSelectUsbDescriptors: Failed to allocate memory for deviceDescriptor\n"));
            ExFreePool(urb);
            status = STATUS_INSUFFICIENT_RESOURCES;
        }
    } else {

        OsrTracePrint(TRACE_LEVEL_ERROR,OSRDBG_USB,
            ("ReadandSelectUsbDescriptors: Failed to allocate memory for urb\n"));
        status = STATUS_INSUFFICIENT_RESOURCES;
    }

    OsrTracePrint(TRACE_LEVEL_VERBOSE,OSRDBG_USB,("ReadandSelectUsbDescriptors: Exit\n"));

    return status;
}

///////////////////////////////////////////////////////////////////////////////
//
// ConfigureUsbDevice
//
//  This routine is called by ReadandSelectUsbDescriptors to read the USB 
//  configuration descriptor that will be used to talk to the usb device.
//
//
//  INPUTS:
//
//      DevExt  -  Address of the Devices Device Extension.
//
//  OUTPUTS:
//
//      None
//
//  RETURNS:
//
//      None
//
//  IRQL:
//
//      IRQL == PASSIVE_LEVEL
//
//  CONTEXT:
//
//      Arbitrary Context
//
//  NOTES:
//
///////////////////////////////////////////////////////////////////////////////
NTSTATUS ConfigureUsbDevice(PUSBFX2LK_EXT DevExt)
{
    PURB                          urb = NULL;
    ULONG                         size = sizeof(USB_CONFIGURATION_DESCRIPTOR);
    NTSTATUS                      status;
    PUSB_CONFIGURATION_DESCRIPTOR configurationDescriptor = NULL;

    OsrTracePrint(TRACE_LEVEL_VERBOSE,OSRDBG_USB,("ConfigureUsbDevice: Enter\n"));

    //
    // Allocate memory for a URB.
    //
    urb = (PURB) ExAllocatePoolWithTag(NonPagedPool,sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),'bruO');

    if(urb) {

        //
        // Allocate memory for the default sized configuration descriptor.
        //
        configurationDescriptor = (PUSB_CONFIGURATION_DESCRIPTOR) ExAllocatePoolWithTag(NonPagedPool, size,'dcuO');

        if(configurationDescriptor) {

            //
            // Format the URB for the request.
            //
            UsbBuildGetDescriptorRequest(
                    urb, 
                    (USHORT) sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),
                    USB_CONFIGURATION_DESCRIPTOR_TYPE, 
                    0, 
                    0, 
                    configurationDescriptor,
                    NULL, 
                    sizeof(USB_CONFIGURATION_DESCRIPTOR), 
                    NULL);

            //
            // Submit the request to the USB Device.
            //
            status = SubmitUrb(DevExt,urb);

            //
            // If the request is not successful, go and cleanup from the error.
            //
            if(!NT_SUCCESS(status)) {

                OsrTracePrint(TRACE_LEVEL_ERROR,OSRDBG_USB,
                    ("ConfigureUsbDevice: UsbBuildGetDescriptorRequest failed\n"));
                goto ConfigureDevice_Exit;
            }
        } else {

            OsrTracePrint(TRACE_LEVEL_ERROR,OSRDBG_USB,("ConfigureUsbDevice: Failed to allocate mem for config Descriptor\n"));
            status = STATUS_INSUFFICIENT_RESOURCES;
            goto ConfigureDevice_Exit;
        }

        //
        // Okay, the request was successful.   Look at the returned length in the configuration
        // descriptor and use it to allocate a configuration descriptor that is big enough
        // to receive the full configuration from the device.
        //
        size = configurationDescriptor->wTotalLength;

        //
        // Free the existing configuration descriptor.
        //
        ExFreePool(configurationDescriptor);

        //
        // Allocate the correct sized descriptor.
        //
        configurationDescriptor = (PUSB_CONFIGURATION_DESCRIPTOR) ExAllocatePoolWithTag(NonPagedPool, size,'dcuO');

        if(configurationDescriptor) {

            //
            // Format the urb to get the full configuration descriptor.
            //
            UsbBuildGetDescriptorRequest(
                    urb, 
                    (USHORT)sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),
                    USB_CONFIGURATION_DESCRIPTOR_TYPE,
                    0, 
                    0, 
                    configurationDescriptor, 
                    NULL, 
                    size, 
                    NULL);

            //
            // Submit the request to the device.
            //
            status = SubmitUrb(DevExt,urb);

            //
            // If the request is not successful, clean up after the error.
            //
            if(!NT_SUCCESS(status)) {

                OsrTracePrint(TRACE_LEVEL_ERROR,OSRDBG_USB,
                    ("ConfigureUsbDevice: Failed to read configuration descriptor\n"));
                goto ConfigureDevice_Exit;
            }
        } else {

            OsrTracePrint(TRACE_LEVEL_ERROR,OSRDBG_USB,
                ("ConfigureUsbDevice: Failed to alloc mem for config Descriptor\n"));
            status = STATUS_INSUFFICIENT_RESOURCES;
            goto ConfigureDevice_Exit;
        }
    } else {

        OsrTracePrint(TRACE_LEVEL_ERROR,OSRDBG_USB,
            ("ConfigureUsbDevice: Failed to allocate memory for urb\n"));
        status = STATUS_INSUFFICIENT_RESOURCES;
        goto ConfigureDevice_Exit;
    }

    //
    // Check to make sure that a configuration descriptor was allocated.
    //
    if(configurationDescriptor) {

        //
        // Save a copy of configurationDescriptor in deviceExtension
        // remember to free it later.
        //
        DevExt->UsbConfigurationDescriptor = configurationDescriptor;

        //
        // Determine if the USB configuration is cabable of supporting 
        // remote wake.
        //
        if(configurationDescriptor->bmAttributes & USB_CONFIG_REMOTE_WAKEUP) {
            //
            // This configuration supports remote wakeup
            //
            OsrTracePrint(TRACE_LEVEL_INFORMATION,OSRDBG_PNP_INFO,
                ("ConfigureUsbDevice: Remote Wakeup Enabled.\n"));
            DevExt->WaitWakeEnable = TRUE;

        } else {

            OsrTracePrint(TRACE_LEVEL_INFORMATION,OSRDBG_PNP_INFO,
                ("ConfigureUsbDevice: Remote Wakeup Disabled.\n"));
            DevExt->WaitWakeEnable = FALSE;
        }

        //
        // Select the interface(s) that we are going to use to communicate with the device.
        //
        status = SelectUsbInterfaces(DevExt, configurationDescriptor);

        //
        // And also determine the speed at which the device is running
        //
        DetermineDeviceSpeed(DevExt);

    } else {

        OsrTracePrint(TRACE_LEVEL_ERROR,OSRDBG_PNP_INFO,
            ("ConfigureUsbDevice: Failed to allocate configuration descriptor.\n"));
        DevExt->UsbConfigurationDescriptor = NULL;
    }

    //
    // Cleanup memory and exit.
    //
ConfigureDevice_Exit:

    if(urb) {

        ExFreePool(urb);
    }

    OsrTracePrint(TRACE_LEVEL_VERBOSE,OSRDBG_USB,("ConfigureUsbDevice: Exit\n"));

    return status;
}

///////////////////////////////////////////////////////////////////////////////
//
// SelectUsbInterfaces
//
//  This routine is called by ConfigureUsbDevice to read the USB 
//  select the interfaces that will be used to talk to the usb device.
//
//
//  INPUTS:
//
//      DevExt  -  Address of the Devices Device Extension.
//      ConfigurationDescriptor - Address of the Configuration Descriptor
//                                  selected.
//
//  OUTPUTS:
//
//      None
//
//  RETURNS:
//
//      None
//

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99精品欧美一区二区蜜桃免费| 亚洲美女在线一区| 日韩av网站免费在线| 欧美精品在线视频| 久久精品免费观看| 国产欧美精品在线观看| 99精品国产视频| 亚洲图片欧美一区| 日韩欧美在线观看一区二区三区| 国产又黄又大久久| 亚洲色图.com| 欧美精品九九99久久| 国产综合久久久久久鬼色| 国产精品成人在线观看| 欧美日韩一区二区在线观看视频 | 国产成人精品影视| 国产精品热久久久久夜色精品三区| 91色乱码一区二区三区| 亚洲国产综合人成综合网站| 日韩欧美电影一二三| 成人av免费观看| 亚洲bt欧美bt精品777| 亚洲精品在线观看视频| 色综合欧美在线视频区| 久久电影网站中文字幕| 国产精品午夜在线观看| 91 com成人网| 99久久精品免费观看| 日韩激情在线观看| 1区2区3区欧美| 欧美大胆一级视频| 日本精品视频一区二区三区| 国产一区二三区| 性做久久久久久久免费看| 国产亚洲短视频| 777午夜精品免费视频| 成人a区在线观看| 麻豆精品在线观看| 亚洲一区二区三区四区不卡 | 日本一区二区免费在线| 欧美精品久久久久久久久老牛影院| 国产成人综合视频| 欧美aa在线视频| 亚洲一区日韩精品中文字幕| 欧美经典一区二区三区| 777久久久精品| 日本道精品一区二区三区| 国产成人综合亚洲91猫咪| 美国十次了思思久久精品导航| 一区二区三区产品免费精品久久75| 国产婷婷色一区二区三区四区 | 精品国产乱码久久久久久久 | 欧美电影免费观看高清完整版在| 色综合亚洲欧洲| 成人激情校园春色| 国产69精品一区二区亚洲孕妇| 青青草一区二区三区| 亚洲高清在线精品| 伊人夜夜躁av伊人久久| 成人欧美一区二区三区黑人麻豆| 欧美电影免费观看高清完整版在 | 成人午夜短视频| 久久精品久久精品| 奇米在线7777在线精品 | 夜夜揉揉日日人人青青一国产精品| 国产视频一区在线观看| 精品美女在线观看| 欧美mv日韩mv| 精品精品欲导航| 欧美成人r级一区二区三区| 欧美一区欧美二区| 欧美一级在线观看| 日韩一区二区三区免费看 | 国产精品国产三级国产aⅴ入口 | 日韩午夜精品电影| 日韩欧美亚洲国产精品字幕久久久| 欧美一区二区三区在线视频 | 色狠狠综合天天综合综合| 99精品视频在线观看免费| av毛片久久久久**hd| 99精品视频在线播放观看| 一本色道久久综合亚洲aⅴ蜜桃| 99国产精品视频免费观看| 91网上在线视频| 欧美日韩中文精品| 6080yy午夜一二三区久久| 4438成人网| 久久久不卡影院| 国产精品国产三级国产aⅴ原创| 综合分类小说区另类春色亚洲小说欧美| 中文字幕精品一区二区三区精品| 国产精品毛片高清在线完整版| 欧美激情综合五月色丁香| 亚洲欧洲精品一区二区三区 | 欧美妇女性影城| 精品国产亚洲一区二区三区在线观看| 亚洲精品一区在线观看| 中文字幕乱码亚洲精品一区| 亚洲精品ww久久久久久p站| 亚洲va欧美va国产va天堂影院| 午夜电影一区二区| 国产激情视频一区二区在线观看| av电影天堂一区二区在线观看| 在线亚洲精品福利网址导航| 欧美一区三区二区| 国产精品久久久久久久久果冻传媒 | 日本一区二区三区视频视频| 亚洲女人的天堂| 蜜桃视频一区二区| thepron国产精品| 欧美日韩免费不卡视频一区二区三区| 日韩精品一区二区三区视频| 欧美激情在线免费观看| 午夜精品久久久久久久99樱桃 | 亚洲成年人网站在线观看| 国产尤物一区二区在线| 色哟哟日韩精品| 精品国产污污免费网站入口| 亚洲色图在线播放| 国产一区在线观看麻豆| 色婷婷综合久色| 久久中文娱乐网| 亚洲福利一区二区| 成年人午夜久久久| 欧美成人一区二区三区| 亚洲男同性视频| 国产一区二区三区黄视频| 在线视频一区二区免费| 国产欧美日韩精品a在线观看| 天天亚洲美女在线视频| 99精品1区2区| 国产婷婷色一区二区三区在线| 天天影视涩香欲综合网| 91亚洲永久精品| 久久久99久久| 日韩av电影免费观看高清完整版| 99精品视频中文字幕| 久久综合久久综合久久综合| 午夜电影网亚洲视频| 色成年激情久久综合| 国产婷婷色一区二区三区四区 | 国产精品一区二区免费不卡 | 久久久亚洲精华液精华液精华液| 亚洲国产毛片aaaaa无费看| 成人国产精品视频| 精品国产露脸精彩对白| 日韩制服丝袜先锋影音| 欧美视频三区在线播放| 亚洲人成影院在线观看| 不卡一卡二卡三乱码免费网站| 欧美变态tickle挠乳网站| 日韩精品一级中文字幕精品视频免费观看| 成人h动漫精品一区二| 国产欧美日韩在线| 国产一区不卡在线| 久久综合九色综合欧美98| 日本欧美一区二区三区乱码| 欧美日韩国产区一| 亚洲高清一区二区三区| 欧美日精品一区视频| 一区二区三区丝袜| 色噜噜狠狠成人网p站| 亚洲精品中文在线| 91黄色激情网站| 性做久久久久久久免费看| 欧美人牲a欧美精品| 婷婷激情综合网| 欧美另类久久久品| 男女男精品视频网| 日韩你懂的在线播放| 精品在线视频一区| 久久亚洲精华国产精华液 | 97精品久久久久中文字幕| 亚洲欧洲精品一区二区精品久久久 | 一区二区三区在线观看动漫| 色婷婷综合久久久中文一区二区| 伊人婷婷欧美激情| 欧美一区二区视频在线观看2020| 日本va欧美va精品| 久久精品免费在线观看| jizzjizzjizz欧美| 亚洲综合久久av| 欧美二区三区的天堂| 精品在线视频一区| 中文字幕亚洲成人| 欧洲一区在线观看| 蜜桃视频在线一区| 欧美激情中文不卡| 欧美婷婷六月丁香综合色| 蜜臀av亚洲一区中文字幕| 久久一区二区三区四区| 波多野结衣中文一区| 一区二区三区日韩| 日韩免费观看2025年上映的电影 | 91免费观看视频在线| 亚洲高清不卡在线观看| 欧美成人一区二区三区片免费| 成人高清免费观看| 午夜激情综合网| 国产精品网站在线观看|