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

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

?? bulkusb.c

?? gec2410開發板和PC機用USB連接
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*++

Copyright (c) 1997-1998  Microsoft Corporation

Module Name:

    BulkUsb.c 

Abstract:

    Bulk 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 "Blk82930.h"
#include "GUID829.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
    BulkUsb_GetRegistryDword( BULKUSB_REGISTRY_PARAMETERS_PATH, //absolute registry path
                                     L"DebugLevel",     // REG_DWORD ValueName
                                     &gDebugLevel );    // Value receiver
#endif

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

    //
    // Create dispatch points for create, close, unload
    DriverObject->MajorFunction[IRP_MJ_CREATE] = BulkUsb_Create;
    DriverObject->MajorFunction[IRP_MJ_CLOSE] = BulkUsb_Close;
    DriverObject->DriverUnload = BulkUsb_Unload;

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

    // User mode ReadFile()/WriteFile() calls will be routed here
    DriverObject->MajorFunction[IRP_MJ_WRITE] = BulkUsb_Write;
    DriverObject->MajorFunction[IRP_MJ_READ] = BulkUsb_Read;

    // routines for handling system PNP and power management requests
    DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = BulkUsb_ProcessSysControlIrp;
    DriverObject->MajorFunction[IRP_MJ_PNP] = BulkUsb_ProcessPnPIrp;
    DriverObject->MajorFunction[IRP_MJ_POWER] = BulkUsb_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 = BulkUsb_PnPAddDevice;


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

    return ntStatus;
}





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

    BULKUSB_KdPrint( DBGLVL_HIGH, ( "enter BulkUsb_ProcessSysControlIrp()\n") );

    BulkUsb_IncrementIoCount(DeviceObject);

    BULKUSB_ASSERT( IRP_MJ_SYSTEM_CONTROL == irpStack->MajorFunction );

    IoCopyCurrentIrpStackLocationToNext(Irp);


    ntStatus = IoCallDriver(stackDeviceObject,
                            Irp);

    BulkUsb_DecrementIoCount(DeviceObject);

    BULKUSB_KdPrint( DBGLVL_HIGH,("BulkUsb_ProcessSysControlIrp() Exit BulkUsb_ProcessSysControlIrp %x\n", ntStatus));

    return ntStatus;
}


VOID
BulkUsb_Unload(
    IN PDRIVER_OBJECT DriverObject
    )
/*++

Routine Description:

    Free all the allocated resources, etc.

Arguments:

    DriverObject - pointer to a driver object

Return Value:


--*/
{
    BULKUSB_KdPrint( DBGLVL_HIGH,("enter BulkUsb_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:
    //
	BULKUSB_ASSERT( gExAllocCount == 0 );

    BULKUSB_KdPrint( DBGLVL_DEFAULT,("exit BulkUsb_Unload\n"));

}


NTSTATUS
BulkUsb_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 BulkUsb_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_BULK,
                NULL,
                deviceLinkUnicodeString);

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

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

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

    }

    return ntStatus;
}



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

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

    ntStatus = BulkUsb_SymbolicLink( PhysicalDeviceObject, &deviceLinkUnicodeString );

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

    BULKUSB_KdPrintCond( DBGLVL_DEFAULT,
            (!(NT_SUCCESS(ntStatus))),
            ("BulkUsb_CreateDeviceObject() FAILED to Create GUID_CLASS_BulkUsb_BULK-based Device name\n"));

    if (NT_SUCCESS(ntStatus)) {

        ntStatus = IoCreateDevice (DriverObject,
                           sizeof (DEVICE_EXTENSION),
                           NULL,
                           FILE_DEVICE_UNKNOWN,
                           FILE_AUTOGENERATED_DEVICE_NAME,
                           FALSE,
                           DeviceObject);

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

        }

        BULKUSB_KdPrintCond( DBGLVL_DEFAULT,
                (!(NT_SUCCESS(ntStatus))),
                ("BulkUsb_CreateDeviceObject() IoCreateDevice() FAILED\n"));

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


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

#if DBG
        // may be overridden in registry
        BulkUsb_GetRegistryDword( BULKUSB_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 when BulkUsb_AsyncReadWrite_Complete() finishes or cancels last staged io irp
        KeInitializeEvent(&deviceExtension->StagingDoneEvent, NotificationEvent, FALSE);

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

		// spinlock used to protect inc/dec iocount logic
		KeInitializeSpinLock (&deviceExtension->IoCountSpinLock);

        // spinlock used to protect test of deviceExtension->BaseIrp in
        // BulkUsb_StagedReadWrite()
        KeInitializeSpinLock(&deviceExtension->FastCompleteSpinlock);

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


    return ntStatus;
}


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

    BULKUSB_KdPrint( DBGLVL_MAXIMUM,("enter BulkUsb_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. 

    //
    // As an alternative, we could call KeDelayExecutionThread, wait for some
    // period of time, and try again....but we keep it simple for right now
    //
    if (!irp) {
        return STATUS_INSUFFICIENT_RESOURCES;
    }

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

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

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

    BULKUSB_KdPrint( DBGLVL_MAXIMUM,("BulkUsb_CallUSBD() return from IoCallDriver USBD %x\n", ntStatus));

    if (ntStatus == STATUS_PENDING) {

        status = KeWaitForSingleObject(
                       &event,
                       Suspended,
                       KernelMode,

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲大型综合色站| 欧美日韩一区二区在线视频| 成人国产精品免费观看| 欧美三级资源在线| 国产精品三级在线观看| 视频一区二区三区入口| 成人精品小蝌蚪| 日韩一区二区三区视频在线| 亚洲精品久久嫩草网站秘色| 国产一区二区中文字幕| 欧美精品xxxxbbbb| 国产精品久久久久久户外露出 | 奇米777欧美一区二区| 91啪九色porn原创视频在线观看| 91精品国产综合久久福利 | 亚洲成人福利片| 99久久综合色| 久久久欧美精品sm网站| 三级影片在线观看欧美日韩一区二区 | 国产精品久久久久久久久免费相片 | 欧美电影在哪看比较好| 亚洲欧美欧美一区二区三区| 国产米奇在线777精品观看| 欧美一区二区视频观看视频| 亚洲三级久久久| 成人av第一页| 国产精品美女www爽爽爽| 国产精品18久久久久久久网站| 欧美精品第1页| 一区二区成人在线| 欧美亚洲一区二区在线观看| 亚洲色图视频网| 99精品视频一区二区三区| 中文字幕欧美日韩一区| 国产成人精品aa毛片| 国产偷v国产偷v亚洲高清| 国精品**一区二区三区在线蜜桃 | 欧洲另类一二三四区| 亚洲精品成人在线| 色先锋资源久久综合| 亚洲精品视频在线看| 日本韩国欧美一区二区三区| 日本一区二区三区视频视频| 福利一区福利二区| 国产精品成人网| 色94色欧美sute亚洲线路一久| 亚洲精品国产a久久久久久 | 丰满放荡岳乱妇91ww| 国产精品久久久久久户外露出 | 国产成人av电影在线播放| 国产午夜精品美女毛片视频| eeuss鲁片一区二区三区在线观看| 国产精品私人影院| 在线观看成人免费视频| 丝袜美腿亚洲色图| 国产精品久久久久久久久免费丝袜| 国产蜜臀av在线一区二区三区| 麻豆国产精品777777在线| 精品国产一区二区三区四区四 | 欧美国产成人在线| 91欧美一区二区| 天天射综合影视| 欧美一级一区二区| 国产成人8x视频一区二区 | 亚洲高清免费观看| 日韩欧美另类在线| 成人黄页毛片网站| 亚洲最快最全在线视频| 日韩手机在线导航| 成人黄色777网| 一区二区三区av电影| 欧美精品久久99| 国产91在线|亚洲| 性感美女极品91精品| 精品播放一区二区| 一本大道久久a久久精品综合| 日韩成人精品在线| 欧美激情艳妇裸体舞| 欧美日韩一区二区不卡| 国产成人自拍网| 午夜欧美在线一二页| 欧美国产日韩精品免费观看| 欧美日韩国产影片| jizzjizzjizz欧美| 老司机精品视频一区二区三区| 国产精品乱码一区二三区小蝌蚪| 欧美乱妇15p| 97超碰欧美中文字幕| 极品少妇xxxx精品少妇偷拍| 亚洲成人av在线电影| 国产精品久久久久永久免费观看| 欧美精品777| 在线欧美一区二区| 99久久99久久免费精品蜜臀| 蜜臀91精品一区二区三区| 亚洲欧美国产高清| 久久精品一区二区三区不卡| 欧美一区二区成人| 欧美综合一区二区| 色婷婷av一区二区三区软件| 国产成人丝袜美腿| 精品午夜久久福利影院| 日日欢夜夜爽一区| 亚洲国产精品久久人人爱蜜臀| 亚洲人精品午夜| 国产精品久久久久久久久快鸭 | 国产乱一区二区| 蜜桃免费网站一区二区三区| 亚洲午夜激情av| 亚洲男同性视频| 亚洲乱码精品一二三四区日韩在线 | 久久99久久久久久久久久久| 天堂一区二区在线| 午夜精品一区二区三区电影天堂 | 亚洲国产高清不卡| 国产精品人人做人人爽人人添| xf在线a精品一区二区视频网站| 欧美一区二区在线不卡| 欧美一区二区网站| 日韩欧美成人一区二区| 精品日韩一区二区| 久久久美女毛片| 国产精品欧美极品| 国产精品的网站| 亚洲欧美日韩一区| 亚洲风情在线资源站| 亚洲一区二区三区视频在线| 亚洲一区二区3| 亚洲mv在线观看| 久久精品二区亚洲w码| 精品在线播放免费| 成人久久18免费网站麻豆| 成人久久18免费网站麻豆| 一本色道综合亚洲| 欧美高清精品3d| 欧美精品一区二区三区在线| 国产欧美一区二区精品婷婷 | www.av亚洲| 精品视频在线免费观看| 日韩欧美一区二区三区在线| 欧美电影免费观看完整版| 久久久久久久久一| 一区二区视频免费在线观看| 亚洲chinese男男1069| 精品亚洲欧美一区| 99久久伊人精品| 91精品国产综合久久小美女| 欧美精品一区二区高清在线观看| 久久久国产精华| 一区二区三区精品在线观看| 美女视频网站黄色亚洲| 成人午夜av影视| 91精品国产综合久久蜜臀| 久久久99精品久久| 一区二区成人在线| 国产精品小仙女| 欧美日韩国产高清一区| 国产人伦精品一区二区| 亚洲午夜视频在线| 成人美女在线视频| 欧美一卡二卡在线| 亚洲婷婷在线视频| 韩国v欧美v日本v亚洲v| 色国产综合视频| 久久精品一区二区三区四区| 天天综合天天做天天综合| 高清av一区二区| 日韩午夜在线观看视频| 亚洲色图在线视频| 国产一区999| 日韩视频免费观看高清在线视频| 最新高清无码专区| 九九热在线视频观看这里只有精品| 91麻豆精品视频| 欧美tk—视频vk| 石原莉奈在线亚洲三区| 91久久精品日日躁夜夜躁欧美| 精品成人免费观看| 日本亚洲欧美天堂免费| 91久久免费观看| 国产精品久久三| 国产98色在线|日韩| 日韩午夜在线观看| 日韩vs国产vs欧美| 欧美探花视频资源| 亚洲一区二区三区自拍| 色综合色综合色综合色综合色综合 | 日韩欧美一二三区| 天天做天天摸天天爽国产一区| 色综合久久中文字幕综合网| 国产欧美日韩卡一| 国产精品一二二区| 精品国产乱子伦一区| 美女国产一区二区三区| 欧美蜜桃一区二区三区| 亚洲一级电影视频| 欧美日韩视频在线第一区 | 亚洲色图20p| 91麻豆自制传媒国产之光| 国产精品美女久久久久久久网站|