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

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

?? isousb.c

?? softusb for atmel avr
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*++

Copyright (c) 1997-1998  Microsoft Corporation

Module Name:

    IsoUsb.c 

Abstract:

    Isochronous USB device driver for Intel 82930 USB test board
    Main module

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 "GUIDISO.h"


NTSTATUS
DriverEntry(
    IN PDRIVER_OBJECT DriverObject,
    IN PUNICODE_STRING RegistryPath
    )
/*++

Routine Description:

    Installable driver initialization entry point.
    This entry point is called directly by the I/O system.

Arguments:

    DriverObject - pointer to the driver object

    RegistryPath - pointer to a unicode string representing the path
                   to driver-specific key in the registry

Return Value:

    STATUS_SUCCESS if successful,
    STATUS_UNSUCCESSFUL otherwise

--*/
{
    NTSTATUS ntStatus = STATUS_SUCCESS;
    PDEVICE_OBJECT deviceObject = NULL;
    BOOLEAN fRes;

#if DBG
	// should be done before any debug output is done.
    // read our debug verbosity level from the registry
    IsoUsb_GetRegistryDword( ISOUSB_REGISTRY_PARAMETERS_PATH, //absolute registry path
                                     L"DebugLevel",     // REG_DWORD ValueName
                                     &gDebugLevel );    // Value receiver
#endif


    ISOUSB_KdPrint( DBGLVL_MINIMUM ,("Entering DriverEntry(), RegistryPath=\n    %ws\n", RegistryPath->Buffer ));

    //
    // Create dispatch points for create, close, unload
    DriverObject->MajorFunction[IRP_MJ_CREATE] = IsoUsb_Create;
    DriverObject->MajorFunction[IRP_MJ_CLOSE] = IsoUsb_Close;
    DriverObject->DriverUnload = IsoUsb_Unload;

    // User mode DeviceIoControl() calls will be routed here
    DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = IsoUsb_ProcessIOCTL;

    // routines for handling system PNP and power management requests
    DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = IsoUsb_ProcessSysControlIrp;
    DriverObject->MajorFunction[IRP_MJ_PNP] = IsoUsb_ProcessPnPIrp;
    DriverObject->MajorFunction[IRP_MJ_POWER] = IsoUsb_ProcessPowerIrp;

    // The Functional Device Object (FDO) will not be created for PNP devices until
    // this routine is called upon device plug-in.
    DriverObject->DriverExtension->AddDevice = IsoUsb_PnPAddDevice;


    ISOUSB_KdPrint( DBGLVL_DEFAULT,("exiting DriverEntry (%x)\n", ntStatus));

    return ntStatus;
}





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

Routine Description:

    Main dispatch table routine for IRP_MJ_SYSTEM_CONTROL
	We basically just pass these down to the PDO

Arguments:

    DeviceObject - pointer to FDO device object

    Irp          - pointer to an I/O Request Packet

Return Value:

	Status returned from lower driver


--*/
{

    PIO_STACK_LOCATION irpStack;
    PDEVICE_EXTENSION deviceExtension;
    NTSTATUS ntStatus = STATUS_SUCCESS;
    NTSTATUS waitStatus;
    PDEVICE_OBJECT stackDeviceObject;

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

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

    irpStack = IoGetCurrentIrpStackLocation (Irp);

    //
    // Get a pointer to the device extension
    //

    deviceExtension = DeviceObject->DeviceExtension;
    stackDeviceObject = deviceExtension->TopOfStackDeviceObject;

    ISOUSB_KdPrint( DBGLVL_HIGH, ( "enter IsoUsb_ProcessSysControlIrp()\n") );

    IsoUsb_IncrementIoCount(DeviceObject);

    ISOUSB_ASSERT( IRP_MJ_SYSTEM_CONTROL == irpStack->MajorFunction );

    IoCopyCurrentIrpStackLocationToNext(Irp);


    ntStatus = IoCallDriver(stackDeviceObject,
                            Irp);

    IsoUsb_DecrementIoCount(DeviceObject);

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

    return ntStatus;
}


VOID
IsoUsb_Unload(
    IN PDRIVER_OBJECT DriverObject
    )
/*++

Routine Description:

    Free all the allocated resources, etc.

Arguments:

    DriverObject - pointer to a driver object

Return Value:


--*/
{
    ISOUSB_KdPrint( DBGLVL_HIGH,("enter IsoUsb_Unload\n"));

    //
    // Free any global resources allocated
    // in DriverEntry.
	// We have few or none because for a PNP device, almost all
	// allocation is done in PnpAddDevice() and all freeing
	// while handling IRP_MN_REMOVE_DEVICE:
    //

    ISOUSB_KdPrint( DBGLVL_DEFAULT,("exit IsoUsb_Unload\n"));


}


NTSTATUS
IsoUsb_SymbolicLink(
    IN PDEVICE_OBJECT DeviceObject,
    IN OUT PUNICODE_STRING deviceLinkUnicodeString

    )
/*++

Routine Description:

    This routine is called to create and initialize
    a GUID-based symbolic link to our device to be used to open/create
    instances of us from user mode.

    Called from IsoUsb_CreateDeviceObject() to create the link.

Arguments:

    DeviceObject - pointer to our Physical Device Object ( PDO )

    deviceLinkUnicodeString - Points to a unicode string structure allocated by the caller.
	If this routine is successful, it initializes the unicode string and allocates
	the string buffer containing the kernel-mode path to the symbolic link for this
	device interface.


Return Value:

    STATUS_SUCCESS if successful,
    STATUS_UNSUCCESSFUL otherwise

--*/{
    NTSTATUS ntStatus = STATUS_SUCCESS;


    //  Create the symbolic link

    // IoRegisterDeviceInterface registers device functionality (a device interface)
    // that a driver will enable for use by applications or other system components.

    ntStatus = IoRegisterDeviceInterface(
		DeviceObject,
		(LPGUID)&GUID_CLASS_I82930_ISO,
		NULL,
		deviceLinkUnicodeString);

    ISOUSB_KdPrintCond( DBGLVL_MEDIUM, (!(NT_SUCCESS(ntStatus))),
	    ("FAILED to IoRegisterDeviceInterface()\n"));

   if (NT_SUCCESS(ntStatus)) {

       // IoSetDeviceInterfaceState enables or disables a previously
       // registered device interface. Applications and other system components
       // can open only interfaces that are enabled.

	ntStatus = IoSetDeviceInterfaceState(deviceLinkUnicodeString, TRUE);

        ISOUSB_KdPrintCond( DBGLVL_MEDIUM,
		(!(NT_SUCCESS(ntStatus))),
		("FAILED to IoSetDeviceInterfaceState()\n"));

        ISOUSB_KdPrintCond( DBGLVL_MEDIUM,
		((NT_SUCCESS(ntStatus))),
		("SUCCEEDED  IoSetDeviceInterfaceState()\n"));

    }

    return ntStatus;
}



NTSTATUS
IsoUsb_CreateDeviceObject(
    IN PDRIVER_OBJECT DriverObject,
    IN PDEVICE_OBJECT PhysicalDeviceObject,
    IN PDEVICE_OBJECT *DeviceObject
    )
/*++

Routine Description:

    Creates a Functional DeviceObject

Arguments:

    DriverObject - pointer to the driver object for device

    DeviceObject - pointer to DeviceObject pointer to return
		    created device object.

    Instance - instance of the device create.

Return Value:

    STATUS_SUCCESS if successful,
    STATUS_UNSUCCESSFUL otherwise

--*/
{
    NTSTATUS ntStatus;
    UNICODE_STRING deviceLinkUnicodeString;
    PDEVICE_EXTENSION deviceExtension;
    USHORT i;
    
    UNICODE_STRING pdoUniCodeName;
    WCHAR	   pdoName[] = L"\\Device\\AVR309USB_0";

    UNICODE_STRING DeviceLinkUniCodeString;
    WCHAR          DeviceLinkName[] = L"\\DosDevices\\AVR309USB_0";
    
    RtlInitUnicodeString (&pdoUniCodeName, pdoName); // Creates Unicode Name    

    ISOUSB_KdPrint( DBGLVL_DEFAULT,("enter IsoUsb_CreateDeviceObject() \n"));

    ntStatus = IsoUsb_SymbolicLink( PhysicalDeviceObject, &deviceLinkUnicodeString );

    ISOUSB_KdPrintCond( DBGLVL_DEFAULT,
	    (NT_SUCCESS(ntStatus)),
	    ("IsoUsb_CreateDeviceObject() SUCCESS Create GUID_CLASS_IsoUsb_ISO-based Device name\n   %ws\n Length decimal %d, MaximumLength decimal %d\n",
	    deviceLinkUnicodeString.Buffer,
	    deviceLinkUnicodeString.Length,
	    deviceLinkUnicodeString.MaximumLength));

    ISOUSB_KdPrintCond( DBGLVL_DEFAULT,
	    (!(NT_SUCCESS(ntStatus))),
	    ("IsoUsb_CreateDeviceObject() FAILED to Create GUID_CLASS_ISO-based Device name\n"));

    if (NT_SUCCESS(ntStatus)) {

	ntStatus = IoCreateDevice (DriverObject,
			   sizeof (DEVICE_EXTENSION),
			   &pdoUniCodeName,
			   FILE_DEVICE_UNKNOWN,
			   0,
			   FALSE,
			   DeviceObject);

	if (NT_SUCCESS(ntStatus))  {
	     deviceExtension = (PDEVICE_EXTENSION) ((*DeviceObject)->DeviceExtension);

	}

	ISOUSB_KdPrintCond( DBGLVL_DEFAULT,
		(!(NT_SUCCESS(ntStatus))),
		("IsoUsb_CreateDeviceObject() IoCreateDevice() FAILED\n"));

	 ISOUSB_KdPrintCond( DBGLVL_DEFAULT,
		((NT_SUCCESS(ntStatus))),
		("IsoUsb_CreateDeviceObject() IoCreateDevice() SUCCESS\n"));


	if (!NT_SUCCESS(ntStatus))  {
	     return ntStatus;
	}

        RtlInitUnicodeString (&DeviceLinkUniCodeString, DeviceLinkName);
        ntStatus = IoCreateSymbolicLink(&DeviceLinkUniCodeString, &pdoUniCodeName);

	//default maximum transfer size per io request
	deviceExtension->MaximumTransferSize =  ISO_MAX_TRANSFER_SIZE ;

#if DBG
        // may be overridden in registry
        IsoUsb_GetRegistryDword( ISOUSB_REGISTRY_PARAMETERS_PATH,
                                         L"MaximumTransferSize",
                                         &(deviceExtension->MaximumTransferSize) );
#endif

	// Name buffer for our named Functional device object link
	// The name is generated based on the driver's class GUID
	RtlCopyMemory(deviceExtension->DeviceLinkNameBuffer,
		      deviceLinkUnicodeString.Buffer,
		      deviceLinkUnicodeString.Length);


	// this event is triggered when there is no pending io of any kind and device is removed
	KeInitializeEvent(&deviceExtension->RemoveEvent, NotificationEvent, FALSE);

	// this event is triggered when self-requested power irps complete
	KeInitializeEvent(&deviceExtension->SelfRequestedPowerIrpEvent, NotificationEvent, FALSE);

	// this event is triggered when there is no pending io  (pending io count == 1 )
	KeInitializeEvent(&deviceExtension->NoPendingIoEvent, NotificationEvent, FALSE);

		//free buffer from unicode string we used to init interface
		RtlFreeUnicodeString( &deviceLinkUnicodeString );
    }

     ISOUSB_KdPrintCond( DBGLVL_DEFAULT,
	    ((NT_SUCCESS(ntStatus))),
	    ("Exit IsoUsb_CreateDeviceObject() IoCreateDevice() SUCCESS\n"));


    return ntStatus;
}


NTSTATUS
IsoUsb_CallUSBD(
    IN PDEVICE_OBJECT DeviceObject,
    IN PURB Urb
    )
/*++

Routine Description:

    Passes a URB to the USBD class driver
	The client device driver passes USB request block (URB) structures 
	to the class driver as a parameter in an IRP with Irp->MajorFunction
	set to IRP_MJ_INTERNAL_DEVICE_CONTROL and the next IRP stack location 
	Parameters.DeviceIoControl.IoControlCode field set to 
	IOCTL_INTERNAL_USB_SUBMIT_URB. 

Arguments:

    DeviceObject - pointer to the physical device object (PDO)

    Urb - pointer to an already-formatted Urb request block

Return Value:

    STATUS_SUCCESS if successful,
    STATUS_UNSUCCESSFUL otherwise

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

    ISOUSB_KdPrint( DBGLVL_MAXIMUM,("enter IsoUsb_CallUSBD\n"));

    deviceExtension = DeviceObject->DeviceExtension;

    //
    // issue a synchronous request
    //

    KeInitializeEvent(&event, NotificationEvent, FALSE);

    irp = IoBuildDeviceIoControlRequest(
                IOCTL_INTERNAL_USB_SUBMIT_URB,
                deviceExtension->TopOfStackDeviceObject, //Points to the next-lower driver's device object
                NULL, // optional input bufer; none needed here
                0,	  // input buffer len if used
                NULL, // optional output bufer; none needed here
                0,    // output buffer len if used
                TRUE, // If InternalDeviceControl is TRUE the target driver's Dispatch
				      //  outine for IRP_MJ_INTERNAL_DEVICE_CONTROL or IRP_MJ_SCSI 
					  // is called; otherwise, the Dispatch routine for 
					  // IRP_MJ_DEVICE_CONTROL is called.
                &event,     // event to be signalled on completion
                &ioStatus);  // Specifies an I/O status block to be set when the request is completed the lower driver. 

    //
    // 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);

    //
    // pass the URB to the USB driver stack
    //
    nextStack->Parameters.Others.Argument1 = Urb;

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

    ISOUSB_KdPrint( DBGLVL_MAXIMUM,("IsoUsb_CallUSBD() return from IoCallDriver USBD %x\n", ntStatus));

    if (ntStatus == STATUS_PENDING) {

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

    } else {
        ioStatus.Status = ntStatus;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二三区| 风间由美一区二区av101| 狠狠狠色丁香婷婷综合激情| 高潮精品一区videoshd| 欧美精品国产精品| 国产精品乱人伦中文| 青娱乐精品视频在线| 99久久99久久久精品齐齐| 日韩欧美成人激情| 有坂深雪av一区二区精品| 国产一区二区三区久久久| 欧美区一区二区三区| 亚洲欧美日韩国产中文在线| 国产精品自拍毛片| 精品国产污网站| 视频在线观看91| 在线观看免费视频综合| 国产精品久久久久久久岛一牛影视 | 日韩免费性生活视频播放| 亚洲精品v日韩精品| 成人激情综合网站| 国产亚洲自拍一区| 奇米精品一区二区三区在线观看一| 色婷婷狠狠综合| 中文字幕五月欧美| 成人天堂资源www在线| 精品国产区一区| 国内精品久久久久影院一蜜桃| 日韩你懂的电影在线观看| 偷拍一区二区三区四区| 欧美一区二区视频在线观看2022| 亚洲视频免费在线观看| 成人黄动漫网站免费app| 精品久久久久一区| 视频一区二区三区中文字幕| 欧美三级在线看| 亚洲少妇中出一区| 91成人免费电影| 日韩理论电影院| 色欲综合视频天天天| 国产色婷婷亚洲99精品小说| 国产精品一区二区久激情瑜伽| 欧美三级日韩三级国产三级| 丝瓜av网站精品一区二区| 色婷婷国产精品| 亚洲精品在线网站| 另类人妖一区二区av| av色综合久久天堂av综合| 亚洲色图清纯唯美| 国产在线日韩欧美| 国产乱人伦偷精品视频免下载| 夜夜嗨av一区二区三区四季av| 久久毛片高清国产| zzijzzij亚洲日本少妇熟睡| 日韩不卡手机在线v区| 久久99国产精品麻豆| 日韩一区二区免费在线观看| 91极品视觉盛宴| 91视频一区二区| 欧美一级高清片| 粉嫩aⅴ一区二区三区四区| 欧美一级xxx| 在线精品视频一区二区三四| 亚洲丝袜另类动漫二区| 成人黄色av电影| 亚洲国产乱码最新视频| 精品视频色一区| 国产一区二区日韩精品| 久久久久久日产精品| 一本大道久久a久久综合婷婷| 亚洲色欲色欲www在线观看| 91精品国产综合久久久久久久久久 | 一区二区三区不卡视频| 在线观看91视频| 日本成人超碰在线观看| 亚洲精品在线电影| 欧美a级一区二区| 国产精品久久毛片av大全日韩| 国产精品一区免费在线观看| 91麻豆123| 亚洲精品国产视频| 中文字幕av不卡| 欧美日韩三级一区二区| 久久 天天综合| 亚洲一区二区三区四区中文字幕| 欧美一区二区三区人| 91麻豆swag| 蜜桃久久久久久| 亚洲一本大道在线| 精品99一区二区| 欧美夫妻性生活| 成人av免费在线观看| 亚洲丝袜制服诱惑| 欧美一级片在线看| 国内外成人在线| 日本女优在线视频一区二区| 国产欧美精品一区| 日韩欧美国产综合一区| 色综合久久久久| 成人国产在线观看| 久久精品99国产精品| 亚洲精品中文在线观看| 欧美日韩国产在线观看| 国产成人av一区二区三区在线 | 国产精品亚洲视频| 午夜亚洲国产au精品一区二区| 亚洲欧洲精品成人久久奇米网| 欧美一卡二卡在线| 91精品免费在线| 91免费国产在线观看| 99久久综合国产精品| 91在线免费看| 国产成人超碰人人澡人人澡| 日韩精品亚洲一区二区三区免费| 91精品综合久久久久久| 久久精品国产久精国产| 亚洲高清免费观看高清完整版在线观看 | 亚洲综合丁香婷婷六月香| www.欧美色图| 精品影视av免费| 国产精品久久久久久久岛一牛影视| 精品第一国产综合精品aⅴ| 欧美在线看片a免费观看| 91丨九色丨蝌蚪丨老版| 成人午夜视频免费看| 国产99精品视频| 91在线你懂得| 粉嫩在线一区二区三区视频| 色综合亚洲欧洲| 国产精一品亚洲二区在线视频| 亚洲影视在线播放| 性做久久久久久久久| 国产制服丝袜一区| 热久久免费视频| 麻豆一区二区三| 99久久婷婷国产精品综合| 国产不卡在线一区| 免费精品99久久国产综合精品| 日本不卡高清视频| 91亚洲永久精品| 欧美肥胖老妇做爰| 91久久精品网| 日韩你懂的在线观看| 亚洲国产综合色| 免费在线观看日韩欧美| 久久99日本精品| 9191成人精品久久| 中文字幕巨乱亚洲| 午夜久久电影网| 在线观看欧美精品| 久久久久久久综合狠狠综合| 一区二区不卡在线播放| 国产91精品精华液一区二区三区 | 夜色激情一区二区| fc2成人免费人成在线观看播放| 在线观看日韩国产| 久久久欧美精品sm网站| 亚洲乱码国产乱码精品精的特点 | 欧美综合在线视频| 亚洲日本韩国一区| 欧美浪妇xxxx高跟鞋交| 精品制服美女久久| 亚洲图片自拍偷拍| 精品女同一区二区| 91在线观看视频| 一区二区高清免费观看影视大全| 久久99精品视频| 一色桃子久久精品亚洲| 欧美最猛黑人xxxxx猛交| 奇米精品一区二区三区四区| 7777精品伊人久久久大香线蕉的| 奇米影视一区二区三区小说| 成人欧美一区二区三区小说| 国产成人免费xxxxxxxx| 国产日韩欧美精品一区| 国产成人av影院| 中文字幕一区日韩精品欧美| 国产毛片一区二区| 国产精品久久久一区麻豆最新章节| 国产精品一区不卡| 亚洲品质自拍视频| 91精品国产一区二区三区| 精品亚洲成a人在线观看| 久久久青草青青国产亚洲免观| 成人h精品动漫一区二区三区| 亚洲午夜精品在线| 91精品欧美一区二区三区综合在| 亚洲国产美国国产综合一区二区| 91精品在线麻豆| 91同城在线观看| 日本不卡的三区四区五区| 欧美国产一区二区在线观看| 欧美顶级少妇做爰| av在线这里只有精品| 国产一区二区视频在线播放| 亚洲柠檬福利资源导航| 91精品在线观看入口| 欧美日韩高清不卡| 色网站国产精品| 丰满白嫩尤物一区二区|