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

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

?? bulkusb.c

?? 嵌入式系統(tǒng)的USB驅(qū)動(S3C2410)
?? 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,

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久久久99精品| 青青草91视频| 白白色 亚洲乱淫| 国产欧美一区二区精品仙草咪| 国内精品视频666| 欧美精品一区二区三区蜜臀 | 国产精品国产自产拍在线| 成人免费精品视频| 亚洲人成精品久久久久| 色噜噜狠狠色综合欧洲selulu| 亚洲国产成人高清精品| 日韩一区二区免费在线电影| 国产露脸91国语对白| 国产精品动漫网站| 在线影视一区二区三区| 男女男精品网站| 国产日韩v精品一区二区| 不卡一区中文字幕| 亚洲成av人片在www色猫咪| 7777精品伊人久久久大香线蕉 | 欧美色欧美亚洲另类二区| 日本一不卡视频| 日韩免费看网站| 国产成人精品免费看| 亚洲精品乱码久久久久久| 日韩一区二区三区三四区视频在线观看| 激情久久五月天| 亚洲日本va在线观看| 欧美一级日韩不卡播放免费| 国产.欧美.日韩| 亚洲成av人片一区二区梦乃| 日本一区二区免费在线| 欧美日韩精品一区视频| 国产成人aaaa| 亚洲成人先锋电影| 国产欧美精品区一区二区三区| 在线精品视频免费播放| 国产精品888| 亚洲va欧美va天堂v国产综合| 国产网站一区二区| 欧美精品久久99久久在免费线| 高清日韩电视剧大全免费| 日韩精品久久理论片| 国产精品久线观看视频| 精品影院一区二区久久久| 欧美日韩国产美女| av网站一区二区三区| 麻豆国产91在线播放| 一区二区国产视频| 欧美国产日韩a欧美在线观看 | 欧美午夜在线观看| 国产成人免费网站| 久久av资源网| 婷婷一区二区三区| 亚洲自拍与偷拍| 国产精品久久久久久久午夜片| 欧美一区二区三区视频在线| 欧美视频精品在线观看| av网站免费线看精品| 国产麻豆欧美日韩一区| 精品在线观看免费| 日韩电影在线观看网站| 亚洲妇女屁股眼交7| 国产精品久久久久久久久动漫 | 三级欧美在线一区| 亚洲人成网站在线| 中文字幕av一区二区三区| 精品福利视频一区二区三区| 欧美精选一区二区| 欧美影院午夜播放| 色哟哟日韩精品| 在线一区二区观看| 色综合天天综合网国产成人综合天| 岛国精品一区二区| 99视频精品全部免费在线| 成人美女视频在线观看| 国产成人h网站| 国产91精品精华液一区二区三区 | 日本道免费精品一区二区三区| 国产成人aaa| 成人免费高清在线| 99久久婷婷国产综合精品| 波多野洁衣一区| 91视频免费看| 欧美午夜片在线观看| 欧美日韩在线精品一区二区三区激情 | 国产**成人网毛片九色| 亚洲午夜羞羞片| 久久综合视频网| 久久人人爽人人爽| 国产欧美日韩不卡免费| 国产精品美女久久久久久| 亚洲欧洲性图库| 一区二区三区精品视频| 午夜精品久久久久影视| 免费观看久久久4p| 狠狠色丁香久久婷婷综| 成人午夜私人影院| 在线观看av一区二区| 777奇米四色成人影色区| 精品国产乱码久久| 国产精品久久久久久久久果冻传媒| 亚洲另类在线一区| 午夜国产精品一区| 国产一区二区三区四区在线观看| 国产成人夜色高潮福利影视| av一二三不卡影片| 欧美日韩亚洲综合一区二区三区| 日韩欧美国产一区二区在线播放| 亚洲精品在线网站| 亚洲欧美日韩在线不卡| 日本三级韩国三级欧美三级| 丁香六月综合激情| 91成人国产精品| 欧美mv日韩mv国产网站app| 国产精品美女久久久久久久久 | 99精品久久久久久| 这里只有精品视频在线观看| 国产午夜精品理论片a级大结局| 一级做a爱片久久| 精品亚洲aⅴ乱码一区二区三区| 成人免费视频网站在线观看| 欧美日韩精品一区二区三区| 日韩欧美国产一区二区在线播放 | 男女视频一区二区| 91一区二区在线| 日韩欧美国产一区二区三区| 国产精品大尺度| 蜜桃视频一区二区| 91国偷自产一区二区开放时间 | 欧美在线免费观看亚洲| 久久久久亚洲综合| 精品国产精品网麻豆系列| 欧美夫妻性生活| **性色生活片久久毛片| 久久精品久久综合| 欧美在线一区二区三区| 国产精品美女久久久久久久久| 麻豆91在线播放| 欧美色图天堂网| 国产精品久久久一区麻豆最新章节| 久久成人免费网| 欧美日韩国产综合草草| 中文字幕一区在线观看| 国产精品一区久久久久| 91精品国产入口| 亚洲国产成人av网| 色综合网站在线| 国产精品麻豆欧美日韩ww| 国产一区二区三区不卡在线观看 | 一区二区三区免费网站| 大美女一区二区三区| 久久免费偷拍视频| 激情综合网av| 欧美成人国产一区二区| 视频一区欧美精品| 91.com视频| 视频一区视频二区在线观看| 欧美午夜不卡在线观看免费| 亚洲精品成人悠悠色影视| 91丨porny丨蝌蚪视频| 国产精品欧美极品| 成人毛片视频在线观看| 国产日韩欧美亚洲| 国产成人精品www牛牛影视| 国产欧美视频一区二区| 国产一区二区三区综合| 欧美精品一区二区三区蜜桃 | 国产精品三级电影| 白白色 亚洲乱淫| 亚洲欧洲99久久| 99久久精品情趣| 又紧又大又爽精品一区二区| 色爱区综合激月婷婷| 一个色综合网站| 欧美日韩国产小视频在线观看| 91精品久久久久久蜜臀| 中文子幕无线码一区tr| fc2成人免费人成在线观看播放| 国产目拍亚洲精品99久久精品| 国产成人免费在线| 亚洲另类在线制服丝袜| 欧美视频一区二区在线观看| 日韩综合一区二区| 精品国产髙清在线看国产毛片| 国产精品一区2区| 国产精品久线观看视频| 91丨九色丨蝌蚪富婆spa| 亚洲影院免费观看| 91精品在线免费观看| 久久福利视频一区二区| 日本一区二区三区四区在线视频| 91麻豆国产福利精品| 无吗不卡中文字幕| 精品久久人人做人人爽| 成人免费va视频| 亚洲一区在线视频观看| 日韩欧美一卡二卡| eeuss国产一区二区三区| 亚洲图片欧美视频|