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

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

?? usbls120.c

?? 一個好用的MS的USB驅動編程工具包,希望有用.
?? C
?? 第 1 頁 / 共 2 頁
字號:
    DeviceObject - pointer to the physical device object for this instance of the 82930
                   device.


Return Value:

    NT status code

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

    USBLS120_KdPrint( DBGLVL_HIGH,("enter USBLS120_ConfigureDevice\n"));

    deviceExtension = DeviceObject->DeviceExtension;

    USBLS120_ASSERT( deviceExtension->UsbConfigurationDescriptor == NULL );

    urb = USBLS120_ExAllocatePool(NonPagedPool,
			 sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST));
    if ( !urb )
        return STATUS_INSUFFICIENT_RESOURCES;

    // When USB_CONFIGURATION_DESCRIPTOR_TYPE is specified for DescriptorType
    // in a call to UsbBuildGetDescriptorRequest(),
    // all interface, endpoint, class-specific, and vendor-specific descriptors 
    // for the configuration also are retrieved. 
    // The caller must allocate a buffer large enough to hold all of this 
    // information or the data is truncated without error.
    // Therefore the 'siz' set below is just a 'good guess', and we may have to retry

    siz = sizeof(USB_CONFIGURATION_DESCRIPTOR) + 512;  

    // We will break out of this 'retry loop' when UsbBuildGetDescriptorRequest()
    // has a big enough deviceExtension->UsbConfigurationDescriptor buffer not to truncate
    while( 1 ) {

        deviceExtension->UsbConfigurationDescriptor = USBLS120_ExAllocatePool(NonPagedPool, siz);

        if ( !deviceExtension->UsbConfigurationDescriptor ) {
            USBLS120_ExFreePool(urb);
            return STATUS_INSUFFICIENT_RESOURCES;
        }

        UsbBuildGetDescriptorRequest(
            urb,
            (USHORT) sizeof (struct _URB_CONTROL_DESCRIPTOR_REQUEST),
            USB_CONFIGURATION_DESCRIPTOR_TYPE,
            0,
            0,
            deviceExtension->UsbConfigurationDescriptor,
            NULL,
            siz,
            NULL
            );

        ntStatus = USBLS120_CallUSBD(DeviceObject, urb);

        USBLS120_KdPrint( DBGLVL_HIGH,("USBLS120_CallUSBD() Configuration Descriptor = %x, len %x\n",
                                       deviceExtension->UsbConfigurationDescriptor,
                                       urb->UrbControlDescriptorRequest.TransferBufferLength));
        //
        // if we got some data see if it was enough.
        // NOTE: we may get an error in URB because of buffer overrun
        if (urb->UrbControlDescriptorRequest.TransferBufferLength>0 &&
            deviceExtension->UsbConfigurationDescriptor->wTotalLength > siz) {

            siz = deviceExtension->UsbConfigurationDescriptor->wTotalLength;
            USBLS120_ExFreePool(deviceExtension->UsbConfigurationDescriptor);
            deviceExtension->UsbConfigurationDescriptor = NULL;
        } else {
            break;  // we got it on the first try
        }

    } // end, while (retry loop )

    USBLS120_ExFreePool(urb);
    USBLS120_ASSERT( deviceExtension->UsbConfigurationDescriptor );

    //
    // We have the configuration descriptor for the configuration we want.
    // Now we issue the select configuration command to get
    // the  pipes associated with this configuration.
    //

    ntStatus = USBLS120_SelectInterface(
                   DeviceObject,
                   deviceExtension->UsbConfigurationDescriptor
                   );


    USBLS120_KdPrint( DBGLVL_HIGH,("exit USBLS120_ConfigureDevice (%x)\n", ntStatus));

    return ntStatus;
} 


NTSTATUS
USBLS120_SelectInterface(
    IN PDEVICE_OBJECT DeviceObject,
    IN PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor
    )
/*++

Routine Description:

    Initializes an 82930 with (possibly) multiple interfaces;
    This minidriver only supports one interface (with multiple endpoints).

Arguments:

    DeviceObject - pointer to the device object for this instance of the 82930
                   device.

    ConfigurationDescriptor - pointer to the USB configuration
                   descriptor containing the interface and endpoint
                   descriptors.

Return Value:

    NT status code

--*/
{
    PDEVICE_EXTENSION deviceExtension;
    NTSTATUS ntStatus;
    PURB urb = NULL;
    ULONG i;
    PUSB_INTERFACE_DESCRIPTOR interfaceDescriptor = NULL;
    PUSBD_INTERFACE_INFORMATION Interface = NULL;
    USHORT siz;

    USBLS120_KdPrint( DBGLVL_MEDIUM,("enter USBLS120_SelectInterface\n"));

    deviceExtension = DeviceObject->DeviceExtension;


    USBLS120_KdPrint( DBGLVL_HIGH,("USBLS120_SelectInterface() called with NULL Interface\n"));

    //
    // BulkUsb driver only supports one interface, we must parse
    // the configuration descriptor for the interface 
    // and remember the pipes.
    //
    urb = USBD_CreateConfigurationRequest(ConfigurationDescriptor, &siz);

    if (urb) 
    {

        //
        // USBD_ParseConfigurationDescriptorEx searches a given configuration
        // descriptor and returns a pointer to an interface that matches the 
        //  given search criteria. We only support one interface on this device
        //
	interfaceDescriptor = USBD_ParseConfigurationDescriptorEx(
                                  ConfigurationDescriptor,
                                  ConfigurationDescriptor, //search from start of config  descriptro
                                  -1,   // interface number not a criteria; we only support one interface
                                  -1,   // not interested in alternate setting here either
                                  -1,   // interface class not a criteria
                                  -1,   // interface subclass not a criteria
                                  -1    // interface protocol not a criteria
                                  );

        if ( !interfaceDescriptor ) {

            USBLS120_KdPrint( DBGLVL_HIGH,("USBLS120_SelectInterface() ParseConfigurationDescriptorEx() failed\n  returning STATUS_INSUFFICIENT_RESOURCES\n"));
            USBLS120_ExFreePool(urb);
            return STATUS_INSUFFICIENT_RESOURCES;
        }

	Interface = &urb->UrbSelectConfiguration.Interface;

        for (i=0; i< Interface->NumberOfPipes; i++) {
	    //
	    // perform any pipe initialization here
	    //
	    Interface->Pipes[i].MaximumTransferSize = deviceExtension->MaximumTransferSize;
	    Interface->Pipes[i].PipeFlags = 0;
	}

	UsbBuildSelectConfigurationRequest(
            urb,
            (USHORT) siz,
            ConfigurationDescriptor);

        ntStatus = USBLS120_CallUSBD(DeviceObject, urb);

	deviceExtension->UsbConfigurationHandle =
	    urb->UrbSelectConfiguration.ConfigurationHandle;

    } else {
        USBLS120_KdPrint( DBGLVL_HIGH,("USBLS120_SelectInterface() USBD_CreateConfigurationRequest() failed\n  returning STATUS_INSUFFICIENT_RESOURCES\n"));
        ntStatus = STATUS_INSUFFICIENT_RESOURCES;
    }

    if (NT_SUCCESS(ntStatus)) {

	//
	// Save the configuration handle for this device
	//

	deviceExtension->UsbConfigurationHandle =
	    urb->UrbSelectConfiguration.ConfigurationHandle;

        deviceExtension->UsbInterface = USBLS120_ExAllocatePool(
                                            NonPagedPool,
                                            Interface->Length
                                            );

        if (deviceExtension->UsbInterface) {

            ULONG j;

            //
            // save a copy of the interface information returned
            //
            RtlCopyMemory(deviceExtension->UsbInterface, Interface, Interface->Length);

            //
            // Dump the interface to the debugger
            //
            USBLS120_KdPrint( 1,("---------\n"));
            USBLS120_KdPrint( 1,("NumberOfPipes 0x%x\n", deviceExtension->UsbInterface->NumberOfPipes));
            USBLS120_KdPrint( 1,("Length 0x%x\n", deviceExtension->UsbInterface->Length));
            USBLS120_KdPrint( 1,("Alt Setting 0x%x\n", deviceExtension->UsbInterface->AlternateSetting));
            USBLS120_KdPrint( 1,("Interface Number 0x%x\n", deviceExtension->UsbInterface->InterfaceNumber));
            USBLS120_KdPrint( 1,("Class, subclass, protocol 0x%x 0x%x 0x%x\n",
                deviceExtension->UsbInterface->Class,
                deviceExtension->UsbInterface->SubClass,
                deviceExtension->UsbInterface->Protocol));

            // Dump the pipe info

            for (j=0; j<Interface->NumberOfPipes; j++) {
                PUSBD_PIPE_INFORMATION pipeInformation;

                pipeInformation = &deviceExtension->UsbInterface->Pipes[j];

                USBLS120_KdPrint( 1,("---------\n"));
                USBLS120_KdPrint( 1,("PipeType 0x%x\n", pipeInformation->PipeType));
                USBLS120_KdPrint( 1,("EndpointAddress 0x%x\n", pipeInformation->EndpointAddress));
                USBLS120_KdPrint( 1,("MaxPacketSize 0x%x\n", pipeInformation->MaximumPacketSize));
                USBLS120_KdPrint( 1,("Interval 0x%x\n", pipeInformation->Interval));
                USBLS120_KdPrint( 1,("Handle 0x%x\n", pipeInformation->PipeHandle));
                USBLS120_KdPrint( 1,("MaximumTransferSize 0x%x\n", pipeInformation->MaximumTransferSize));

                switch (pipeInformation->PipeType) {       

                     case UsbdPipeTypeBulk:
                         if (USBD_PIPE_DIRECTION_IN(pipeInformation)) {
                             USBLS120_KdPrint( 1,("DataInPipe 0x%x\n", j));
                             deviceExtension->DataInPipe = j;
                         } else {
                             USBLS120_KdPrint( 1,("DataOutPipe 0x%x\n", j));
                             deviceExtension->DataOutPipe = j;
                         }
                         break;
			

                     case UsbdPipeTypeInterrupt:
                         USBLS120_KdPrint( 1,("StatusPipe 0x%x\n", j));
                         deviceExtension->StatusPipe = j;
                         break;


                     default:
                         USBLS120_KdPrint( 1,("Unknown pipe 0x%x\n", j));
                         break;
                }
            }
        }
        USBLS120_KdPrint( DBGLVL_MEDIUM,("---------\n"));
    }

    if (urb) {
        // don't call the USBLS120_ExFreePool since the buffer was 
        //  alloced by USBD_CreateConfigurationRequest, not USBLS120_ExAllocatePool()
        ExFreePool(urb);
    }
    USBLS120_KdPrint( DBGLVL_HIGH,("exit USBLS120_SelectInterface (%x)\n", ntStatus));

    return ntStatus; 
}



NTSTATUS
USBLS120_ResetPipe(
    IN PDEVICE_OBJECT DeviceObject,
    IN PUSBD_PIPE_INFORMATION PipeInfo
    )
/*++

Routine Description:

    Reset a given USB pipe.

    NOTES:

    This will reset the host to Data0 and should also reset the device to Data0 

Arguments:

    Ptrs to our FDO and a USBD_PIPE_INFORMATION struct

Return Value:

    NT status code

--*/
{
    NTSTATUS ntStatus;
    PURB urb;
    PDEVICE_EXTENSION deviceExtension;

    deviceExtension = DeviceObject->DeviceExtension;

    USBLS120_KdPrint( DBGLVL_DEFAULT,("USBLS120_ResetPipe() Reset Pipe %x\n", PipeInfo));

    urb = USBLS120_ExAllocatePool(NonPagedPool, sizeof(struct _URB_PIPE_REQUEST));

    if (urb) {

	urb->UrbHeader.Length = (USHORT) sizeof (struct _URB_PIPE_REQUEST);
	urb->UrbHeader.Function = URB_FUNCTION_RESET_PIPE;
        urb->UrbPipeRequest.PipeHandle = PipeInfo->PipeHandle;

        ntStatus = USBLS120_CallUSBD(DeviceObject, urb);

        USBLS120_ExFreePool(urb);

    } else {
	ntStatus = STATUS_INSUFFICIENT_RESOURCES;
    }

    if (!(NT_SUCCESS(ntStatus))) {

#if DBG
        if ( gpDbg )
            gpDbg->PipeErrorCount++;
#endif
        USBLS120_KdPrint( DBGLVL_DEFAULT,("USBLS120_ResetPipe() FAILED, ntStatus =0x%x\n", ntStatus ));

    } else {

#if DBG
        if ( gpDbg )
            gpDbg->ResetPipeCount++;
#endif
    USBLS120_KdPrint( DBGLVL_DEFAULT,("USBLS120_ResetPipe() SUCCESS, ntStatus =0x%x\n", ntStatus ));

    }

    return ntStatus;
}




LONG
USBLS120_DecrementIoCount(
    IN PDEVICE_OBJECT DeviceObject
    )
/*++

Routine Description:

    We keep a pending IO count ( extension->PendingIoCount )  in the device extension.
    The first increment of this count is done on adding the device.
    Subsequently, the count is incremented for each new IRP received and
    decremented when each IRP is completed or passed on.

    Transition to 'one' therefore indicates no IO is pending and signals
    deviceExtension->NoPendingIoEvent. This is needed for processing
    IRP_MN_QUERY_REMOVE_DEVICE

    Transition to 'zero' signals an event ( deviceExtension->RemoveEvent )
    to enable device removal. This is used in processing for IRP_MN_REMOVE_DEVICE
 
Arguments:

    DeviceObject -- ptr to our FDO

Return Value:

    deviceExtension->PendingIoCount


--*/

{
    PDEVICE_EXTENSION deviceExtension;
    LONG ioCount;
    KIRQL oldIrql;

    deviceExtension = DeviceObject->DeviceExtension;
    KeAcquireSpinLock (&deviceExtension->IoCountSpinLock, &oldIrql);

    ioCount = InterlockedDecrement(&deviceExtension->PendingIoCount);

#if DBG
    InterlockedDecrement(&gpDbg->PendingIoCount);
#endif

    USBLS120_TrapCond( DBGLVL_HIGH,( 0 > ioCount ) );

    if (ioCount==1) {

	// trigger no pending io
	KeSetEvent(
            &deviceExtension->NoPendingIoEvent,
            1,
            FALSE
            );
    }

    if (ioCount==0) {

	// trigger remove-device event
	KeSetEvent(
            &deviceExtension->RemoveEvent,
            1,
            FALSE
            );
    }

    KeReleaseSpinLock (&deviceExtension->IoCountSpinLock, oldIrql);

    USBLS120_KdPrint( DBGLVL_HIGH,("Exit USBLS120_DecrementIoCount() Pending io count = %x\n", ioCount));
    return ioCount;
}


VOID
USBLS120_IncrementIoCount(
    IN PDEVICE_OBJECT DeviceObject
    )
/*++

Routine Description:

    We keep a pending IO count ( extension->PendingIoCount )  in the device extension.
    The first increment of this count is done on adding the device.
    Subsequently, the count is incremented for each new IRP received and
    decremented when each IRP is completed or passed on.

 
Arguments:

    DeviceObject -- ptr to our FDO

Return Value:

    None

--*/
{
    PDEVICE_EXTENSION deviceExtension;
    KIRQL oldIrql;

    deviceExtension = DeviceObject->DeviceExtension;

    USBLS120_KdPrint( DBGLVL_HIGH,("Enter USBLS120_IncrementIoCount() Pending io count = %x\n", deviceExtension->PendingIoCount));

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

    InterlockedIncrement(&deviceExtension->PendingIoCount);
#if DBG
    InterlockedIncrement(&gpDbg->PendingIoCount);
#endif
    KeReleaseSpinLock (&deviceExtension->IoCountSpinLock, oldIrql);

    USBLS120_KdPrint( DBGLVL_HIGH,("Exit USBLS120_IncrementIoCount() Pending io count = %x\n", deviceExtension->PendingIoCount));
}



?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲丝袜美腿综合| 国产呦萝稀缺另类资源| 激情五月激情综合网| 99久久国产综合精品色伊| 欧美一区二区三区播放老司机| 欧美高清在线一区| 久久成人免费网站| 欧美在线啊v一区| 国产精品三级电影| 久久国产麻豆精品| 6080午夜不卡| 婷婷中文字幕综合| 欧洲精品视频在线观看| 日本一区免费视频| 国产精品18久久久久久久网站| 7777精品伊人久久久大香线蕉完整版 | 欧美日韩国产高清一区二区 | 色就色 综合激情| 国产精品短视频| 国产成人在线网站| 久久久久久免费| 黑人精品欧美一区二区蜜桃| 日韩欧美亚洲国产精品字幕久久久| 夜夜嗨av一区二区三区四季av | 亚洲成人激情社区| 欧美性猛交xxxx黑人交| 亚洲视频免费看| 99麻豆久久久国产精品免费优播| 国产婷婷色一区二区三区四区| 国产最新精品精品你懂的| 日韩免费观看2025年上映的电影| 日韩精品电影一区亚洲| 欧美精品日日鲁夜夜添| 日韩成人一区二区三区在线观看| 欧美日韩dvd在线观看| 日韩电影网1区2区| 精品对白一区国产伦| 国产大片一区二区| 国产精品全国免费观看高清| 99精品视频一区二区三区| 亚洲精品视频一区| 欧美日韩在线三区| 日韩影视精彩在线| 久久婷婷久久一区二区三区| 国产成人免费视频网站 | 美女久久久精品| 精品久久久久香蕉网| 国产综合成人久久大片91| 国产三级一区二区三区| 波多野结衣视频一区| 亚洲乱码国产乱码精品精98午夜| 在线观看日韩毛片| 美女视频黄a大片欧美| 国产欧美一二三区| 在线观看日韩电影| 久草在线在线精品观看| 国产精品乱码久久久久久| 91激情在线视频| 久久99久久久久| 中文字幕中文字幕在线一区| 91久久精品一区二区| 美女国产一区二区三区| 国产精品白丝在线| 91精品国产综合久久福利软件| 国产乱码精品一区二区三区av | 欧美mv和日韩mv的网站| 成人国产精品视频| 午夜免费久久看| 国产精品久线在线观看| 欧美日韩成人在线一区| 国产成人精品免费视频网站| 亚洲观看高清完整版在线观看| 欧美tickle裸体挠脚心vk| 91小视频免费观看| 激情文学综合插| 亚洲午夜激情网站| 国产精品乱码一区二区三区软件| 在线不卡中文字幕播放| 91在线观看一区二区| 久久福利视频一区二区| 亚洲国产精品天堂| 中文字幕一区二区三区精华液 | 一区二区三区国产精华| 久久久国产午夜精品| 51精品视频一区二区三区| 91热门视频在线观看| 国产剧情一区在线| 美腿丝袜一区二区三区| 亚洲高清在线视频| 亚洲精品久久久蜜桃| 国产日本亚洲高清| 亚洲精品一区二区在线观看| 在线不卡一区二区| 欧美日韩视频专区在线播放| 99久久综合国产精品| 国产盗摄一区二区| 国产九色sp调教91| 精品一区二区免费看| 香蕉久久夜色精品国产使用方法 | 亚洲国产精品传媒在线观看| 日韩午夜在线播放| 欧美一区日韩一区| 欧美日韩一区二区三区免费看| 91亚洲国产成人精品一区二三| 国产成人av一区二区| 国产一区欧美二区| 国精产品一区一区三区mba视频 | 在线观看成人小视频| 97成人超碰视| 99久久夜色精品国产网站| 床上的激情91.| 成人国产视频在线观看| 99久久精品国产精品久久| 成人精品高清在线| 99久久精品国产网站| 91色视频在线| 欧美吞精做爰啪啪高潮| 欧美揉bbbbb揉bbbbb| 日韩一区二区在线观看视频| 欧美顶级少妇做爰| 久久网站最新地址| 亚洲国产精品t66y| 亚洲精品国产第一综合99久久| 亚洲另类一区二区| 日韩专区中文字幕一区二区| 日本欧美在线观看| 国产精品影音先锋| 一本色道久久综合亚洲91| 色先锋资源久久综合| 欧美日韩色一区| 精品国产免费人成在线观看| 26uuu久久综合| 国产精品黄色在线观看| 亚洲国产精品一区二区久久 | 最新日韩av在线| 亚洲制服欧美中文字幕中文字幕| 日韩精品福利网| 国产精品一区久久久久| 91香蕉视频mp4| 91精品欧美福利在线观看| 久久久久久99久久久精品网站| 中文av一区特黄| 亚洲第一综合色| 国内精品写真在线观看| 91麻豆成人久久精品二区三区| 欧美精品欧美精品系列| 国产色产综合色产在线视频| 亚洲影视在线观看| 国产精品一二三区| 在线观看亚洲精品| 国产欧美一区二区精品性色超碰 | 尤物在线观看一区| 精品一二线国产| 在线亚洲高清视频| 亚洲精品一线二线三线 | 自拍偷拍亚洲综合| 蜜臀久久久久久久| 91小视频在线免费看| 337p粉嫩大胆噜噜噜噜噜91av | 亚洲乱码日产精品bd| 激情综合网av| 欧美日韩精品欧美日韩精品一 | 日韩视频在线永久播放| 国产精品高潮呻吟| 麻豆久久一区二区| 在线观看av一区二区| 国产精品三级在线观看| 麻豆精品久久精品色综合| 91久久香蕉国产日韩欧美9色| 2020国产精品| 青青草国产精品亚洲专区无| 91国产丝袜在线播放| 国产人成一区二区三区影院| 久久99最新地址| 在线成人av网站| 国产麻豆精品视频| 3d成人动漫网站| 亚洲一区视频在线| 91丨国产丨九色丨pron| 中文一区二区完整视频在线观看| 热久久久久久久| 91精品国产一区二区人妖| 亚洲一区二区三区中文字幕| av在线播放不卡| 国产精品久久综合| 不卡区在线中文字幕| 国产人成一区二区三区影院| 国产一区二区中文字幕| 日韩欧美国产电影| 麻豆国产精品一区二区三区| 欧美理论片在线| 偷拍日韩校园综合在线| 欧美三片在线视频观看| 亚洲综合一区在线| 欧美视频在线一区| 视频一区中文字幕国产| 91精品国产丝袜白色高跟鞋| 蜜桃视频第一区免费观看| 欧美www视频| 国产精品 欧美精品|