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

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

?? ioctlblk.c

?? 基于linux的s3c2410開發(fā)板usb驅(qū)動程序
?? C
字號:
/*++

Copyright (c) 1997-1998  Microsoft Corporation

Module Name:

   ioctlblk.c

Abstract:

    USB device driver for Intel 82930 USB test board.
    IOCTL handlers

Environment:

    kernel mode only

Notes:

  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  PURPOSE.

  Copyright (c) 1997-1998 Microsoft Corporation.  All Rights Reserved.


Revision History:

    11/17/97 : created

--*/


#include "wdm.h"
#include "stdarg.h"
#include "stdio.h"

#include "usbdi.h"
#include "usbdlib.h"
#include "Blk82930.h"

#include "BulkUsb.h"
#include "usbdlib.h"



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

Routine Description:

    Dispatch table handler for IRP_MJ_DEVICE_CONTROL; 
    Handle DeviceIoControl() calls  from User mode


Arguments:

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


Return Value:

    NT status code

--*/
{
    PIO_STACK_LOCATION irpStack;
    PVOID ioBuffer;
    ULONG inputBufferLength;
    ULONG outputBufferLength;
    PDEVICE_EXTENSION deviceExtension;
    ULONG ioControlCode;
    NTSTATUS ntStatus;
    ULONG length;
    PUCHAR pch;
    PUSB_CONFIGURATION_DESCRIPTOR configurationDescriptor;

    BULKUSB_KdPrint( DBGLVL_DEFAULT,("IRP_MJ_DEVICE_CONTROL\n"));

    BulkUsb_IncrementIoCount(DeviceObject);

    //
    // Get a pointer to the current location in the Irp. This is where
    //     the function codes and parameters are located.
    //

    deviceExtension = DeviceObject->DeviceExtension;
    

    // Can't accept a new io request if:
    //  1) device is removed, 
    //  2) has never been started, 
    //  3) is stopped,
    //  4) has a remove request pending,
    //  5) has a stop device pending
    if ( !BulkUsb_CanAcceptIoRequests( DeviceObject ) ) {
        ntStatus = STATUS_DELETE_PENDING;
        Irp->IoStatus.Status = ntStatus;
        Irp->IoStatus.Information = 0;

        IoCompleteRequest( Irp, IO_NO_INCREMENT );

        BulkUsb_DecrementIoCount(DeviceObject);                          
        return ntStatus;
    }

    irpStack = IoGetCurrentIrpStackLocation (Irp);

    Irp->IoStatus.Status = STATUS_SUCCESS;
    Irp->IoStatus.Information = 0;

    // get pointers and lengths of the caller's (user's) IO buffer
    ioBuffer           = Irp->AssociatedIrp.SystemBuffer;
    inputBufferLength  = irpStack->Parameters.DeviceIoControl.InputBufferLength;
    outputBufferLength = irpStack->Parameters.DeviceIoControl.OutputBufferLength;

    ioControlCode = irpStack->Parameters.DeviceIoControl.IoControlCode;

    //
    // Handle Ioctls from User mode
    //

    switch (ioControlCode) {

    case IOCTL_BULKUSB_RESET_PIPE:
        {
            PUSBD_PIPE_INFORMATION pipe;
                PFILE_OBJECT fileObject;

                    // get our context and see if it is a pipe
                fileObject = irpStack->FileObject;

                    pipe = (PUSBD_PIPE_INFORMATION) fileObject->FsContext;    

                    if(pipe == NULL) {
                            // error, this is not a pipe
                    ntStatus =
                            Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
                    } else {            
                BulkUsb_ResetPipe(DeviceObject, pipe );
            
                ntStatus = Irp->IoStatus.Status = STATUS_SUCCESS;
            }
        }
        break;


     case IOCTL_BULKUSB_GET_CONFIG_DESCRIPTOR:

        //
        // This api returns a copy of the configuration descriptor
        // and all endpoint/interface descriptors.
        //

        //
        // inputs  - none
        // outputs - configuration descriptor plus interface
        //          and endpoint descriptors
        //

        pch = (PUCHAR) ioBuffer;

        configurationDescriptor =
            deviceExtension->UsbConfigurationDescriptor;

        if (configurationDescriptor) {
            
            length = configurationDescriptor->wTotalLength;

            if (outputBufferLength >= length) {

                RtlCopyMemory(pch,
                              (PUCHAR) configurationDescriptor,
                              length);
                
                Irp->IoStatus.Information = length;
                
                ntStatus = Irp->IoStatus.Status = STATUS_SUCCESS;
            }
            else {
        
                Irp->IoStatus.Information = 0;
    
                ntStatus = Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
            }    
        }
        else {

            Irp->IoStatus.Information = 0;

            ntStatus = Irp->IoStatus.Status = STATUS_DEVICE_DATA_ERROR;
        }

        break;



     case IOCTL_BULKUSB_RESET_DEVICE:
        
                ntStatus = BulkUsb_ResetDevice( DeviceObject );
        break;               

    default:

        ntStatus =
            Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
    }

    IoCompleteRequest (Irp,
                       IO_NO_INCREMENT
                       );

    BulkUsb_DecrementIoCount(DeviceObject);                       

    return ntStatus;

}




NTSTATUS
BulkUsb_ResetDevice(
    IN PDEVICE_OBJECT DeviceObject
    )
/*++

Routine Description:
        Checks port status; if OK, return success and  do no more;
        If bad, attempt reset

Arguments:

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


Return Value:

    NT status code

--*/
{
    NTSTATUS ntStatus;
    ULONG portStatus;

    BULKUSB_KdPrint(5,("Enter BulkUsb_ResetDevice()\n"));
    
    //
    // Check the port state, if it is disabled we will need 
    // to re-enable it
    //
    ntStatus = BulkUsb_GetPortStatus(DeviceObject, &portStatus);

    if (NT_SUCCESS(ntStatus) && !(portStatus & USBD_PORT_ENABLED) &&
        portStatus & USBD_PORT_CONNECTED) {
        //
        // port is disabled, attempt reset
        //
                BULKUSB_KdPrint( DBGLVL_DEFAULT,("BulkUsb_ResetDevice() will reset\n"));
        ntStatus = BulkUsb_ResetParentPort(DeviceObject);
    }
        return ntStatus;
}



NTSTATUS
BulkUsb_GetPortStatus(
    IN PDEVICE_OBJECT DeviceObject,
    IN PULONG PortStatus
    )
/*++

Routine Description:

    returns the port status for our device

Arguments:

Return Value:

    STATUS_SUCCESS if successful,
    STATUS_UNSUCCESSFUL otherwise

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

    BULKUSB_KdPrint( DBGLVL_DEFAULT,("enter BulkUsb_GetPortStatus\n"));

    deviceExtension = DeviceObject->DeviceExtension;

    *PortStatus = 0;

    //
    // issue a synchronous request
    //

    KeInitializeEvent(&event, NotificationEvent, FALSE);

    // IoBuildDeviceIoControlRequest allocates and sets up an IRP for a device control request
    irp = IoBuildDeviceIoControlRequest(
                IOCTL_INTERNAL_USB_GET_PORT_STATUS,
                deviceExtension->TopOfStackDeviceObject, //next-lower driver's device object, representing the target device.
                NULL, // no input or output buffers
                0,
                NULL,
                0,
                TRUE, // internal ( use IRP_MJ_INTERNAL_DEVICE_CONTROL )
                &event, // event to be signalled on completion ( we wait for it below )
                &ioStatus);

    //
    // Call the class driver to perform the operation.  If the returned status
    // is PENDING, wait for the request to complete.
    //

    // IoGetNextIrpStackLocation gives a higher level driver access to the next-lower 
    // driver's I/O stack location in an IRP so the caller can set it up for the lower driver.
    nextStack = IoGetNextIrpStackLocation(irp);
    BULKUSB_ASSERT(nextStack != NULL);

    nextStack->Parameters.Others.Argument1 = PortStatus;

    BULKUSB_KdPrint( DBGLVL_DEFAULT,("BulkUsb_GetPortStatus() calling USBD port status api\n"));

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

    BULKUSB_KdPrint( DBGLVL_DEFAULT,("BulkUsb_GetPortStatus() return from IoCallDriver USBD %x\n", ntStatus));

    if (ntStatus == STATUS_PENDING) {

        BULKUSB_KdPrint( DBGLVL_DEFAULT,("Wait for single object\n"));

        status = KeWaitForSingleObject(
                       &event,
                       Suspended,
                       KernelMode,
                       FALSE,
                       NULL);

        BULKUSB_KdPrint( DBGLVL_DEFAULT,("BulkUsb_GetPortStatus() Wait for single object, returned %x\n", status));
        
    } else {
        ioStatus.Status = ntStatus;
    }

    BULKUSB_KdPrint( DBGLVL_DEFAULT,("BulkUsb_GetPortStatus() Port status = %x\n", *PortStatus));

    //
    // USBD maps the error code for us
    //
    ntStatus = ioStatus.Status;

    BULKUSB_KdPrint( DBGLVL_DEFAULT,("Exit BulkUsb_GetPortStatus (%x)\n", ntStatus));


    return ntStatus;
}


NTSTATUS
BulkUsb_ResetParentPort(
    IN IN PDEVICE_OBJECT DeviceObject
    )
/*++

Routine Description:

    Reset the our parent port

Arguments:

Return Value:

    STATUS_SUCCESS if successful,
    STATUS_UNSUCCESSFUL otherwise

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

    BULKUSB_KdPrint( DBGLVL_DEFAULT,("enter BulkUsb_ResetParentPort\n"));

    deviceExtension = DeviceObject->DeviceExtension;

    //
    // issue a synchronous request
    //

    KeInitializeEvent(&event, NotificationEvent, FALSE);

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

    //
    // Call the class driver to perform the operation.  If the returned status
    // is PENDING, wait for the request to complete.
    //

    nextStack = IoGetNextIrpStackLocation(irp);
    BULKUSB_ASSERT(nextStack != NULL);

    BULKUSB_KdPrint( DBGLVL_DEFAULT,("BulkUsb_ResetParentPort() calling USBD enable port api\n"));

    ntStatus = IoCallDriver(deviceExtension->TopOfStackDeviceObject,
                            irp);
                            
    BULKUSB_KdPrint( DBGLVL_DEFAULT,("BulkUsb_ResetParentPort() return from IoCallDriver USBD %x\n", ntStatus));

    if (ntStatus == STATUS_PENDING) {

        BULKUSB_KdPrint( DBGLVL_DEFAULT,("BulkUsb_ResetParentPort() Wait for single object\n"));

        status = KeWaitForSingleObject(
                       &event,
                       Suspended,
                       KernelMode,
                       FALSE,
                       NULL);

        BULKUSB_KdPrint( DBGLVL_DEFAULT,("BulkUsb_ResetParentPort() Wait for single object, returned %x\n", status));
        
    } else {
        ioStatus.Status = ntStatus;
    }

    //
    // USBD maps the error code for us
    //
    ntStatus = ioStatus.Status;

    BULKUSB_KdPrint( DBGLVL_DEFAULT,("Exit BulkUsb_ResetPort (%x)\n", ntStatus));

    return ntStatus;
}





?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人av在线资源网| 国产在线精品一区二区| 在线观看国产91| 亚洲女同ⅹxx女同tv| 欧美日韩中文一区| 欧美a一区二区| 国产肉丝袜一区二区| 91在线看国产| 午夜视黄欧洲亚洲| 精品人在线二区三区| 国产盗摄女厕一区二区三区| 国产精品视频一二三区| 在线观看视频91| 久久99最新地址| 中文字幕欧美一区| 欧美精选一区二区| 国产成人精品1024| 亚洲自拍偷拍麻豆| 久久奇米777| 在线观看国产日韩| 九九视频精品免费| 最新成人av在线| 日韩欧美精品在线| 91在线视频观看| 日本 国产 欧美色综合| 国产欧美一区二区精品婷婷| 91高清视频在线| 国产一二三精品| 亚洲一区免费观看| 久久网站最新地址| 在线这里只有精品| 国产成人欧美日韩在线电影| 香蕉影视欧美成人| 国产精品少妇自拍| 欧美一级在线视频| 91在线精品秘密一区二区| 人人狠狠综合久久亚洲| 国产精品久久久一区麻豆最新章节| 欧美日韩精品欧美日韩精品一| 国产精品一区专区| 日韩影视精彩在线| 18欧美乱大交hd1984| 亚洲精品在线电影| 欧美系列一区二区| 91小视频免费观看| 国产91精品久久久久久久网曝门| 亚洲va天堂va国产va久| 中文字幕一区二区三| xnxx国产精品| 欧美一二三区在线观看| 日本韩国精品在线| k8久久久一区二区三区 | 日韩欧美一区在线观看| heyzo一本久久综合| 国模一区二区三区白浆| 亚洲成av人片一区二区梦乃 | www.日韩av| 国产剧情一区在线| 美女视频一区二区三区| 五月婷婷另类国产| 亚洲一区二区三区三| 亚洲激情中文1区| 中文字幕一区在线观看视频| 久久综合色鬼综合色| 日韩欧美在线影院| 欧美一区二区三区系列电影| 欧美日韩精品久久久| 在线视频你懂得一区二区三区| 成人福利电影精品一区二区在线观看| 国产一区二区在线观看免费| 精品一区二区三区在线播放| 免费观看在线综合| 老司机精品视频一区二区三区| 婷婷综合五月天| 日韩二区三区四区| 日本色综合中文字幕| 青青草精品视频| 美女视频网站久久| 久热成人在线视频| 国产一区二三区| 国产东北露脸精品视频| 成人国产一区二区三区精品| 成人免费毛片片v| 91麻豆国产自产在线观看| 91丝袜美腿高跟国产极品老师 | 在线观看日韩av先锋影音电影院| 色综合天天在线| 欧美午夜一区二区| 56国语精品自产拍在线观看| 51精品国自产在线| 日韩欧美电影在线| 国产三级精品视频| 亚洲人成7777| 亚洲国产一二三| 青草av.久久免费一区| 免费xxxx性欧美18vr| 国内精品视频666| 不卡视频免费播放| 欧美性猛交一区二区三区精品| 欧美日韩夫妻久久| 精品国产乱子伦一区| 久久久精品国产99久久精品芒果| 国产精品不卡一区二区三区| 亚洲一级二级在线| 久久精品国产一区二区三区免费看| 激情综合网天天干| 91丝袜呻吟高潮美腿白嫩在线观看| 在线视频亚洲一区| 亚洲精品一区二区三区精华液| 国产亚洲欧美一区在线观看| 亚洲人成亚洲人成在线观看图片| 亚洲成年人影院| 国产一二三精品| 欧美影院一区二区| 久久久久国产精品厨房| 亚洲综合在线第一页| 国产一区二区视频在线| 色一情一乱一乱一91av| 日韩精品一区二区三区视频播放 | 激情综合色播五月| 91最新地址在线播放| 欧美一级视频精品观看| 中文字幕的久久| 日韩精品成人一区二区三区| 成人午夜av电影| 日韩一区二区三区在线视频| 亚洲婷婷综合色高清在线| 日本不卡123| 色呦呦国产精品| 久久久欧美精品sm网站| 亚洲午夜在线观看视频在线| 国产精品亚洲综合一区在线观看| 精品视频一区 二区 三区| 亚洲国产精品精华液2区45| 日韩电影免费一区| 色吧成人激情小说| 中文字幕成人在线观看| 久久精品国产第一区二区三区| 色老综合老女人久久久| 欧美国产日韩在线观看| 男人的天堂亚洲一区| 色中色一区二区| 国产午夜亚洲精品羞羞网站| 日本成人中文字幕在线视频| 91女神在线视频| 国产精品免费av| 狠狠色丁香婷婷综合| 欧美日韩国产a| 亚洲欧美日韩国产另类专区| 国产精品1024| 欧美sm美女调教| 日韩av一级电影| 欧美中文字幕一区二区三区亚洲| 中文字幕国产一区| 国产精品 日产精品 欧美精品| 日韩精品中文字幕在线不卡尤物| 亚洲国产精品久久久久秋霞影院 | 欧美性大战久久久| 亚洲欧美日韩国产手机在线| 成人免费高清在线观看| 久久精品视频网| 国产精品亚洲第一区在线暖暖韩国| 日韩欧美在线不卡| 九一九一国产精品| 2019国产精品| 国产激情精品久久久第一区二区| 精品国产伦一区二区三区观看体验| 美女一区二区三区在线观看| 日韩三级在线观看| 毛片一区二区三区| 精品国产一区二区三区久久影院 | 国产麻豆一精品一av一免费| 精品国产1区2区3区| 国产在线视视频有精品| 国产性做久久久久久| 成人免费视频播放| 亚洲三级免费观看| 91久久精品日日躁夜夜躁欧美| 亚洲人被黑人高潮完整版| 色综合天天综合网天天看片 | 五月婷婷欧美视频| 777a∨成人精品桃花网| 日本系列欧美系列| 久久久久久亚洲综合影院红桃 | 日韩欧美中文一区| 国产精品综合一区二区三区| 亚洲国产高清不卡| 日本高清免费不卡视频| 肉色丝袜一区二区| 欧美大片拔萝卜| av网站免费线看精品| 亚洲电影一级黄| 精品国精品国产| 成人avav影音| 午夜伊人狠狠久久| 久久婷婷综合激情| 色素色在线综合| 老司机精品视频在线| 中文字幕一区二区三区四区| 欧美日韩精品福利|