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

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

?? usbls120.c

?? microsoft 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一区二区三区免费野_久草精品视频
在线精品视频免费观看| 国产精品2024| 成人精品电影在线观看| 欧美高清在线一区二区| 91蜜桃在线观看| 日韩激情中文字幕| 国产精品成人免费| 91网上在线视频| 麻豆精品一二三| 亚洲一区在线电影| 免费欧美在线视频| 日韩免费成人网| 成人h精品动漫一区二区三区| 亚洲激情在线激情| 欧美一区二区高清| 午夜精品国产更新| 国产精品色在线| 精品国产百合女同互慰| 色综合夜色一区| 国产福利一区二区三区| 美女国产一区二区| 亚洲国产另类av| 一区二区三区四区视频精品免费| 精品播放一区二区| 欧美日韩一区二区三区在线| 91视频观看视频| 国产精品女同互慰在线看| 亚洲综合久久久| 中文字幕二三区不卡| 日韩视频一区二区三区| 欧美裸体一区二区三区| 色94色欧美sute亚洲线路一ni| 国产99久久久久| 国产精品久久久久一区| 欧美va亚洲va在线观看蝴蝶网| 欧美日韩大陆一区二区| 欧美日韩精品欧美日韩精品一综合| 99国产精品99久久久久久| 高清国产午夜精品久久久久久| 国产在线精品一区二区| 极品尤物av久久免费看| 亚洲国产美国国产综合一区二区| 亚洲欧美偷拍三级| 亚洲午夜私人影院| 欧美亚一区二区| 亚洲一区在线视频| 一区二区三区在线免费播放| 综合在线观看色| 一区二区三区中文在线| 91精品国产综合久久精品麻豆| 色婷婷亚洲综合| 在线观看91视频| 91精品国产综合久久国产大片| 欧美老女人在线| 日本韩国欧美三级| 欧美精品v国产精品v日韩精品| 欧美日韩一级二级| 精品国产乱码久久| 国产精品美女久久久久aⅴ| 欧美成人一区二区| 国产日韩v精品一区二区| 精品福利视频一区二区三区| 欧美亚洲综合久久| 国产视频一区二区在线| 日韩精品一区二区三区视频在线观看 | 欧美色爱综合网| 成人av在线播放网址| 成人aa视频在线观看| 日韩av电影免费观看高清完整版 | 中文子幕无线码一区tr| 国产精品人成在线观看免费| 亚洲成人高清在线| 国产精品一区在线观看乱码| 色菇凉天天综合网| 欧美性猛交xxxxxx富婆| 337p粉嫩大胆噜噜噜噜噜91av | 亚洲三级在线看| 久久久亚洲精品石原莉奈| 亚洲综合男人的天堂| 国产自产v一区二区三区c| 成人高清av在线| 99vv1com这只有精品| 亚洲精品一区二区在线观看| 亚洲自拍另类综合| 国产精品一二三四五| 欧美日韩激情在线| 中文字幕制服丝袜一区二区三区| 午夜精品aaa| 色欲综合视频天天天| 7777精品伊人久久久大香线蕉完整版 | 日韩精品自拍偷拍| 国产精品乱码一区二三区小蝌蚪| 亚洲美女屁股眼交3| 国产精品久久看| 精品无人码麻豆乱码1区2区| 欧美亚洲综合网| 精品捆绑美女sm三区| 石原莉奈在线亚洲二区| 日本高清不卡aⅴ免费网站| 久久综合网色—综合色88| 日本在线不卡一区| 欧美色电影在线| 亚洲午夜一区二区三区| 色成年激情久久综合| 亚洲色图欧洲色图| 91在线无精精品入口| 国产精品水嫩水嫩| 色婷婷av久久久久久久| 中文字幕免费一区| 国产精品性做久久久久久| 欧美变态tickle挠乳网站| 亚洲一区二区三区中文字幕在线| 在线观看亚洲一区| 亚洲精品免费播放| 欧洲一区在线观看| 国产91高潮流白浆在线麻豆 | 亚洲黄一区二区三区| 欧美少妇bbb| 91麻豆免费看| 国产自产2019最新不卡| 裸体在线国模精品偷拍| 亚洲一区av在线| 国产日韩精品一区二区浪潮av| 欧美日韩二区三区| 色综合天天狠狠| 国产精品一区久久久久| 久久爱另类一区二区小说| 日韩二区三区四区| 亚洲综合图片区| 亚洲国产一区二区视频| 综合电影一区二区三区 | 亚洲精品在线一区二区| 欧美性生活影院| 91久久精品一区二区| 国产一区啦啦啦在线观看| 午夜精品影院在线观看| 亚洲第一搞黄网站| 亚洲国产另类av| 日韩精品一二三四| 日本三级亚洲精品| 午夜不卡在线视频| 午夜精品福利一区二区三区蜜桃| 亚洲视频在线观看一区| 亚洲人一二三区| 亚洲欧洲美洲综合色网| 一区免费观看视频| 一区二区三区久久久| 亚洲黄色免费网站| 亚洲va韩国va欧美va精品| 亚洲高清一区二区三区| 日韩高清在线一区| 婷婷久久综合九色综合伊人色| 亚洲一区二区三区在线播放| 亚洲一区二区三区小说| 日韩精品电影一区亚洲| 久久66热偷产精品| 成人深夜在线观看| 99久久777色| 777亚洲妇女| 精品国产免费视频| 亚洲视频一区二区在线| 亚洲成人你懂的| 韩国欧美一区二区| 99精品视频在线观看| 欧美日韩国产大片| 国产婷婷一区二区| 国产精品久久毛片a| 国产精品污网站| 亚洲综合图片区| 激情小说亚洲一区| 在线观看一区日韩| 欧美r级在线观看| 精品成人在线观看| 国产精品色一区二区三区| 天天亚洲美女在线视频| 91丨九色丨尤物| 国产人妖乱国产精品人妖| 免费在线观看不卡| 欧美午夜片在线观看| 日韩理论片网站| 福利电影一区二区| 久久久不卡网国产精品二区| 午夜电影久久久| 欧美日韩视频不卡| 亚洲国产美女搞黄色| 日本丶国产丶欧美色综合| 国产精品素人视频| 国产91在线观看丝袜| 久久久噜噜噜久噜久久综合| 老司机午夜精品99久久| 日韩三级免费观看| 欧美aaaaaa午夜精品| 欧美精品久久99| 爽好多水快深点欧美视频| 在线欧美小视频| 一区二区三区影院| 91成人看片片| 亚洲国产你懂的| 666欧美在线视频| 奇米影视在线99精品|