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

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

?? ioctliso.c

?? 用avr 單片機(jī) 用io模擬usb 通信協(xié)議的例子
?? C
字號(hào):
/*++

Copyright (c) 1997-1998  Microsoft Corporation

Module Name:

   ioctliso.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 "Iso82930.h"

#include "IsoUsb.h"
#include "usbdlib.h"



ULONG
VendorCommand(
	IN PDEVICE_OBJECT 	DeviceObject,
        IN UCHAR 		Request,
	IN USHORT 		Value,
	IN USHORT 		Index,
	PVOID			ioBuffer,
	IN ULONG		ioBufferLength
        )
{

	NTSTATUS ntStatus;
	PURB urb;

	if (ioBufferLength>255) ioBufferLength=255;  //hardware support max 255 block size length
	
	urb = (PURB) ExAllocatePool(NonPagedPool, sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST));
        if (urb) 
        {
	 UsbBuildVendorRequest(urb, 
		 	      URB_FUNCTION_VENDOR_ENDPOINT,
			      sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST),
		   	      (USBD_TRANSFER_DIRECTION_IN | USBD_SHORT_TRANSFER_OK),  
			      0, 	 // Reserved Bits 		
			      Request,	 // Request 	
			      Value, 	 // Value 	
			      Index, 	 // Index	
			      ioBuffer,	 // Transfer Buffer
			      NULL,	 // TransferBufferMDL OPTIONAL
			      ioBufferLength,	 // Transfer Buffer Lenght	
			      NULL);	 // Link OPTIONAL
        	
	 ntStatus = IsoUsb_CallUSBD(DeviceObject, urb);

	
	 if (NT_SUCCESS(ntStatus))
	  {
	   ULONG ans = urb->UrbControlVendorClassRequest.TransferBufferLength;
           ExFreePool(urb);
	   return(ans);
	  }
	 else
	  {
           ExFreePool(urb);
	   return(0);
	  }
        }
  	else
  	{
  		KdPrint(("Error to alocate\n"));
  		 return(0); 
  	}

}



NTSTATUS
IsoUsb_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

--*/
{
   struct {
		  char fncnumber;
		  char param1;
		  char param2;
	  }*IgorbufferOut;
   struct {
		  UCHAR fncnumber;
		  UCHAR param1Lo;
		  UCHAR param1Hi;
		  UCHAR param2Lo;
		  UCHAR param2Hi;		  
	  }*IgorbufferOutLong;
	  
    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;
    unsigned short param1;
    unsigned short param2;

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

    IsoUsb_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 ( !IsoUsb_CanAcceptIoRequests( DeviceObject ) ) {
        ntStatus = STATUS_DELETE_PENDING;
        Irp->IoStatus.Status = ntStatus;
        Irp->IoStatus.Information = 0;

        IoCompleteRequest( Irp, IO_NO_INCREMENT );

        IsoUsb_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;
    KdPrint(("inputBufferLength = %d , outputBufferLength = %d \n",inputBufferLength,outputBufferLength));

    ioControlCode = irpStack->Parameters.DeviceIoControl.IoControlCode;

    //
    // Handle Ioctls from User mode
    //
    
    IgorbufferOut = ioBuffer;
    IgorbufferOutLong = ioBuffer;

    switch (ioControlCode) {
    case 8:
            if (inputBufferLength<3)
              {
                ntStatus = Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
                break;
              }
	    KdPrint(("Function8 number %d call with param1= %d and param2= %d\n",IgorbufferOut->fncnumber,IgorbufferOut->param1,IgorbufferOut->param2));
	    length = VendorCommand(DeviceObject,
	    			   IgorbufferOut->fncnumber,
	    			   IgorbufferOut->param1,
	    			   IgorbufferOut->param2,
	    			   ioBuffer,
	    			   outputBufferLength);
            Irp->IoStatus.Information = length;
            Irp->IoStatus.Status = STATUS_SUCCESS;
            ntStatus = STATUS_SUCCESS;
            KdPrint(("Length= %d\n",length));
	break;	
    case 0x800+8:
            if (inputBufferLength<5)
              {
                ntStatus = Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
                break;
              }    
            param1= IgorbufferOutLong->param1Hi;
            param1<<=8;
            param1|=IgorbufferOutLong->param1Lo;
            param2= IgorbufferOutLong->param2Hi;
            param2<<=8;
            param2|=IgorbufferOutLong->param2Lo;
            
	    KdPrint(("FunctionLong number %d call with param1= %d and param2= %d\n",IgorbufferOutLong->fncnumber,param1,param2));
	    length = VendorCommand(DeviceObject,
	    			   IgorbufferOutLong->fncnumber,
	    			   param1,
	    			   param2,
	    			   ioBuffer,
	    			   outputBufferLength);
            Irp->IoStatus.Information = length;
            Irp->IoStatus.Status = STATUS_SUCCESS;
            ntStatus = STATUS_SUCCESS;
            KdPrint(("Length= %d\n",length));
	break;		
    default:
        ntStatus =
            Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
    }

    IoCompleteRequest (Irp,
                       IO_NO_INCREMENT
                       );

    IsoUsb_DecrementIoCount(DeviceObject);                       

    return ntStatus;

}




NTSTATUS
IsoUsb_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;

    ISOUSB_KdPrint(DBGLVL_MEDIUM,("Enter IsoUsb_ResetDevice()\n"));
    
    //
    // Check the port state, if it is disabled we will need 
    // to re-enable it
    //
    ntStatus = IsoUsb_GetPortStatus(DeviceObject, &portStatus);

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



NTSTATUS
IsoUsb_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;

    ISOUSB_KdPrint( DBGLVL_DEFAULT,("enter IsoUsb_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);
    ISOUSB_ASSERT(nextStack != NULL);

    nextStack->Parameters.Others.Argument1 = PortStatus;

    ISOUSB_KdPrint( DBGLVL_DEFAULT,("IsoUsb_GetPortStatus() calling USBD port status api\n"));

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

    ISOUSB_KdPrint( DBGLVL_DEFAULT,("IsoUsb_GetPortStatus() return from IoCallDriver USBD %x\n", ntStatus));

    if (ntStatus == STATUS_PENDING) {

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

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

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

    ISOUSB_KdPrint( DBGLVL_DEFAULT,("IsoUsb_GetPortStatus() Port status = %x\n", *PortStatus));

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

    ISOUSB_KdPrint( DBGLVL_DEFAULT,("Exit IsoUsb_GetPortStatus (%x)\n", ntStatus));

    return ntStatus;
}


NTSTATUS
IsoUsb_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;

    ISOUSB_KdPrint( DBGLVL_HIGH,("enter IsoUsb_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);
    ISOUSB_ASSERT(nextStack != NULL);

    ISOUSB_KdPrint( DBGLVL_HIGH,("IsoUsb_ResetParentPort() calling USBD enable port api\n"));

    ntStatus = IoCallDriver(deviceExtension->TopOfStackDeviceObject,
                            irp);
                            
    ISOUSB_KdPrint( DBGLVL_HIGH,("IsoUsb_ResetParentPort() return from IoCallDriver USBD %x\n", ntStatus));

    if (ntStatus == STATUS_PENDING) {

        ISOUSB_KdPrint( DBGLVL_HIGH,("IsoUsb_ResetParentPort() Wait for single object\n"));

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

        ISOUSB_KdPrint( DBGLVL_HIGH,("IsoUsb_ResetParentPort() Wait for single object, returned %x\n", status));
        
    } else {
        ioStatus.Status = ntStatus;
    }

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

    ISOUSB_KdPrint( DBGLVL_HIGH,("Exit IsoUsb_ResetPort (%x)\n", ntStatus));

    return ntStatus;
}





?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
狠狠狠色丁香婷婷综合激情 | 国产精品久久免费看| 99久久国产综合精品色伊| 亚洲成a人v欧美综合天堂下载 | 亚洲男女毛片无遮挡| 日韩欧美一区二区在线视频| 成人av综合在线| 蜜桃久久久久久| 亚洲精品日韩综合观看成人91| 日韩免费观看高清完整版| 93久久精品日日躁夜夜躁欧美| 老司机午夜精品| 亚洲一区中文在线| 欧美极品aⅴ影院| 日韩欧美一区在线观看| 91麻豆蜜桃一区二区三区| 国产一区二区三区在线观看免费视频| 亚洲自拍另类综合| 中文字幕乱码日本亚洲一区二区| 3d动漫精品啪啪一区二区竹菊| av在线不卡观看免费观看| 精品一区二区免费视频| 亚洲国产综合色| 亚洲日本成人在线观看| 国产午夜亚洲精品不卡| 欧美大片日本大片免费观看| 欧美性高清videossexo| 91丨porny丨户外露出| 国产精品自拍网站| 久88久久88久久久| 三级影片在线观看欧美日韩一区二区| 最新国产の精品合集bt伙计| 中文字幕成人在线观看| 26uuu久久天堂性欧美| 欧美一区二区播放| 欧美亚洲综合一区| 色婷婷综合在线| 91在线国产福利| 99久久精品国产毛片| 成人av电影观看| 成人动漫一区二区在线| 成人性生交大片免费| 国产成人日日夜夜| 国产xxx精品视频大全| 国产精品一区二区视频| 国产乱妇无码大片在线观看| 国产精品综合一区二区三区| 国产成人综合在线| 国产91丝袜在线播放0| 国产成人免费高清| 国产成人综合网站| 99久久精品免费观看| 91丨porny丨最新| 在线观看欧美黄色| 欧美猛男超大videosgay| 91精品在线一区二区| 日韩一区二区三免费高清| 欧美一区二区免费视频| www久久精品| 国产欧美中文在线| 亚洲欧美日韩国产另类专区| 一区二区三区在线观看网站| 亚洲国产aⅴ天堂久久| 日韩激情中文字幕| 捆绑紧缚一区二区三区视频| 国产精品123| 91视频91自| 欧美人妇做爰xxxⅹ性高电影| 欧美一级高清大全免费观看| 欧美精品一区二区三区四区 | 国产精选一区二区三区| 成人白浆超碰人人人人| 色噜噜狠狠色综合中国| 日韩一区和二区| 国产午夜精品理论片a级大结局| 中文字幕一区二区三区视频| 亚洲综合精品久久| 久久精品国产精品亚洲精品| 国产不卡视频一区二区三区| 欧洲色大大久久| 日韩欧美第一区| 亚洲欧洲国产专区| 日韩精品电影一区亚洲| 风流少妇一区二区| 欧美日韩综合在线| 久久精品视频网| 一区二区成人在线视频| 精东粉嫩av免费一区二区三区| caoporm超碰国产精品| 欧美另类久久久品| 国产亲近乱来精品视频| 午夜精品久久一牛影视| 国产美女在线观看一区| 在线视频综合导航| 久久久久久久久一| 亚洲国产综合91精品麻豆| 国产精品一区二区视频| 欧美日韩国产一区| 中文字幕免费不卡| 免费观看成人av| 在线观看免费视频综合| 欧美国产乱子伦| 日韩二区三区在线观看| av在线一区二区三区| 精品免费99久久| 亚洲午夜精品在线| 99视频有精品| 欧美精品一区二| 视频一区免费在线观看| 91农村精品一区二区在线| 精品久久人人做人人爰| 亚洲国产你懂的| 99久久婷婷国产综合精品电影| 欧美成人一区二区三区在线观看| 亚洲精品第1页| 成人毛片在线观看| 26uuu国产一区二区三区| 亚洲成a天堂v人片| 91福利小视频| 亚洲欧美在线另类| 国产a精品视频| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 成人av在线电影| 26uuu国产电影一区二区| 日韩国产一二三区| 欧美综合欧美视频| 一区二区三区中文在线| 99精品久久免费看蜜臀剧情介绍| 国产三级一区二区三区| 狠狠狠色丁香婷婷综合激情| 欧美电影免费观看高清完整版在线 | 精品国产区一区| 日本vs亚洲vs韩国一区三区| 欧美日韩精品一区二区在线播放| 一区二区在线电影| 一本到不卡精品视频在线观看| 国产精品久久午夜| 91在线一区二区| ...xxx性欧美| 色婷婷一区二区三区四区| 亚洲欧美综合色| 色网站国产精品| 亚洲成人一区二区在线观看| 欧美日韩国产综合一区二区三区| 亚洲丰满少妇videoshd| 欧美日韩国产精品自在自线| 亚洲成人中文在线| 91精品国产综合久久蜜臀| 免费看黄色91| 久久久.com| av成人免费在线| 亚洲最新视频在线观看| 日本高清免费不卡视频| 午夜精品爽啪视频| 日韩欧美电影一区| 激情文学综合丁香| 欧美国产一区视频在线观看| 成人蜜臀av电影| 亚洲欧美偷拍三级| 欧美午夜在线一二页| 日韩在线一区二区| 精品国产免费久久| 成人一级黄色片| 又紧又大又爽精品一区二区| 欧美日韩一二区| 久久电影网站中文字幕| 国产三级久久久| 在线观看日韩电影| 美腿丝袜一区二区三区| 久久久久88色偷偷免费| 91视频在线观看| 日韩精品电影在线观看| 久久久无码精品亚洲日韩按摩| 成人av在线资源网| 亚洲电影一区二区三区| 精品国产青草久久久久福利| 国产精品亚洲视频| 亚洲主播在线观看| 欧美刺激脚交jootjob| 99久久精品免费看国产| 五月天中文字幕一区二区| 久久久亚洲国产美女国产盗摄| 91日韩在线专区| 美女一区二区久久| 亚洲欧美视频在线观看视频| 欧美一级片在线| 91免费视频网| 久久电影国产免费久久电影| 亚洲少妇30p| 亚洲精品一区二区三区99| 一本色道**综合亚洲精品蜜桃冫| 轻轻草成人在线| 中文字幕在线一区免费| 欧美一区二区三区视频| 丁香另类激情小说| 日韩不卡一二三区| 自拍视频在线观看一区二区| 91精品麻豆日日躁夜夜躁| av不卡一区二区三区| 免费成人av在线播放|