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

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

?? intusb.c

?? Silicon Laboratories C8051F320/1單片機例子
?? C
字號:
/*++


Module Name:

    intusb.c

Abstract:

    Main module

Author:

Environment:

    kernel mode only

Notes:

    All Rights Reserved.

--*/

#include "intusb.h"
#include "intpnp.h"
#include "intpwr.h"
#include "intdev.h"
#include "intwmi.h"
#include "intusr.h"
#include "intrwr.h"

//
// Globals
//

GLOBALS Globals;
ULONG   DebugLevel = 1;
BOOLEAN win98 = FALSE;

#ifdef PAGE_CODE
#ifdef ALLOC_PRAGMA
#pragma alloc_text(INIT, DriverEntry)
#pragma alloc_text(PAGE, IntUsb_DriverUnload)
#endif
#endif

#pragma INITCODE

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

Routine Description:

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

Arguments:
    
    DriverObject - pointer to driver object 

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

Return Values:

    NT status value
    
--*/
{

    NTSTATUS        ntStatus;
    PUNICODE_STRING registryPath;

	// DriverEntry
	KdPrint((DRIVERNAME " - Entering DriverEntry: DriverObject %8.8lX\n", DriverObject));

	// Insist that OS support at least the WDM level of the DDK we use

	if (!IoIsWdmVersionAvailable(1, 0))
		{
		KdPrint((DRIVERNAME " - Expected version of WDM (%d.%2.2d) not available\n", 1, 0));
		return STATUS_UNSUCCESSFUL;
		}

	//
    // initialization of variables
    //

    registryPath = &Globals.IntUsb_RegistryPath;

    //
    // Allocate pool to hold a null-terminated copy of the path.
    // Safe in paged pool since all registry routines execute at
    // PASSIVE_LEVEL.
    //

    registryPath->MaximumLength = UniRegistryPath->Length + sizeof(UNICODE_NULL);
    registryPath->Length        = UniRegistryPath->Length;
    registryPath->Buffer        = ExAllocatePool(PagedPool,
                                                 registryPath->MaximumLength);

    if (!registryPath->Buffer) {

        KdPrint( ("Failed to allocate memory for registryPath\n"));
        ntStatus = STATUS_INSUFFICIENT_RESOURCES;
        goto DriverEntry_Exit;
    } 


    RtlZeroMemory (registryPath->Buffer, 
                   registryPath->MaximumLength);
    RtlMoveMemory (registryPath->Buffer, 
                   UniRegistryPath->Buffer, 
                   UniRegistryPath->Length);

    ntStatus = STATUS_SUCCESS;

    //
    // Initialize the driver object with this driver's entry points.
    //
    DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = IntUsb_DispatchDevCtrl;
    DriverObject->MajorFunction[IRP_MJ_POWER]          = IntUsb_DispatchPower;
    DriverObject->MajorFunction[IRP_MJ_PNP]            = IntUsb_DispatchPnP;
    DriverObject->MajorFunction[IRP_MJ_CREATE]         = IntUsb_DispatchCreate;
    DriverObject->MajorFunction[IRP_MJ_CLOSE]          = IntUsb_DispatchClose;
    DriverObject->MajorFunction[IRP_MJ_CLEANUP]        = IntUsb_DispatchClean;
	DriverObject->MajorFunction[IRP_MJ_READ]           = IntUsb_DispatchRead;
    DriverObject->MajorFunction[IRP_MJ_WRITE]          = IntUsb_DispatchWrite;
    DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = IntUsb_DispatchSysCtrl;
    DriverObject->DriverUnload                         = IntUsb_DriverUnload;
    DriverObject->DriverExtension->AddDevice           = (PDRIVER_ADD_DEVICE)
                                                         IntUsb_AddDevice;
	
	
DriverEntry_Exit:

    return ntStatus;
}

#pragma PAGEDCODE

VOID
IntUsb_DriverUnload(
    IN PDRIVER_OBJECT DriverObject
    )
/*++

Description:

    This function will free the memory allocations in DriverEntry.

Arguments:

    DriverObject - pointer to driver object 

Return:
	
    None

--*/
{
    PUNICODE_STRING registryPath;
	KdPrint((DRIVERNAME " - Entering DriverEntry: DriverObject %8.8lX\n", DriverObject));

    KdPrint((DRIVERNAME " - Entering DriverUnload: DriverObject %8.8lX\n", DriverObject));

    registryPath = &Globals.IntUsb_RegistryPath;

    if(registryPath->Buffer) {

        ExFreePool(registryPath->Buffer);
        registryPath->Buffer = NULL;
    }

    KdPrint( ("IntUsb_DriverUnload - ends\n"));

    return;
}

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

Description:

Arguments:

    DriverObject - Store the pointer to the object representing us.

    PhysicalDeviceObject - Pointer to the device object created by the
                           undelying bus driver.

Return:
	
    STATUS_SUCCESS - if successful 
    STATUS_UNSUCCESSFUL - otherwise

--*/
{
    NTSTATUS          ntStatus;
    PDEVICE_OBJECT    deviceObject;
    PDEVICE_EXTENSION deviceExtension;
    POWER_STATE       state;
    KIRQL             oldIrql;

    KdPrint( (DRIVERNAME " - IntUsb_AddDevice - begins %8.8lX\n"));

    deviceObject = NULL;

    ntStatus = IoCreateDevice(
                    DriverObject,                   // our driver object
                    sizeof(DEVICE_EXTENSION),       // extension size for us
                    NULL,                           // name for this device
                    FILE_DEVICE_UNKNOWN,
                    FILE_AUTOGENERATED_DEVICE_NAME, // device characteristics
                    FALSE,                          // Not exclusive
                    &deviceObject);                 // Our device object

    if(!NT_SUCCESS(ntStatus)) {
        //
        // returning failure here prevents the entire stack from functioning,
        // but most likely the rest of the stack will not be able to create
        // device objects either, so it is still OK.
        //                
        KdPrint( ("Failed to create device object\n"));
        return ntStatus;
    }

    //
    // Initialize the device extension
    //

    deviceExtension = (PDEVICE_EXTENSION) deviceObject->DeviceExtension;
    deviceExtension->FunctionalDeviceObject = deviceObject;
    deviceExtension->PhysicalDeviceObject = PhysicalDeviceObject;
    deviceObject->Flags |= DO_BUFFERED_IO;
		
	IoInitializeRemoveLock(&(deviceExtension->RemoveLock), 0, 0, 0);
	
    //
    // initialize the device state lock and set the device state
    //

    KeInitializeSpinLock(&deviceExtension->DevStateLock);
    INITIALIZE_PNP_STATE(deviceExtension);

    //
    //initialize OpenHandleCount
    //
    deviceExtension->OpenHandleCount = 0;

    //
    // Initialize the selective suspend variables
    //
    KeInitializeSpinLock(&deviceExtension->IdleReqStateLock);
    deviceExtension->IdleReqPend = 0;
    deviceExtension->PendingIdleIrp = NULL;

    //
    // Hold requests until the device is started
    //

    deviceExtension->QueueState = HoldRequests;

    //
    // Initialize the queue and the queue spin lock
    //

    InitializeListHead(&deviceExtension->NewRequestsQueue);
    KeInitializeSpinLock(&deviceExtension->QueueLock);

    //
    // Initialize the remove event to not-signaled.
    //

    KeInitializeEvent(&deviceExtension->RemoveEvent, 
                      SynchronizationEvent, 
                      FALSE);

    //
    // Initialize the stop event to signaled.
    // This event is signaled when the OutstandingIO becomes 1
    //

    KeInitializeEvent(&deviceExtension->StopEvent, 
                      SynchronizationEvent, 
                      TRUE);

    //
    // OutstandingIo count biased to 1.
    // Transition to 0 during remove device means IO is finished.
    // Transition to 1 means the device can be stopped
    //

    deviceExtension->OutStandingIO = 1;
    KeInitializeSpinLock(&deviceExtension->IOCountLock);

    //
    // Delegating to WMILIB
    //
    ntStatus = IntUsb_WmiRegistration(deviceExtension);

    if(!NT_SUCCESS(ntStatus)) {

        KdPrint( ("IntUsb_WmiRegistration failed with %X\n", ntStatus));
        IoDeleteDevice(deviceObject);
        return ntStatus;
    }

    //
    // set the flags as underlying PDO
    //

    if(PhysicalDeviceObject->Flags & DO_POWER_PAGABLE) {

        deviceObject->Flags |= DO_POWER_PAGABLE;
    }

	
	

    //
    // Typically, the function driver for a device is its 
    // power policy owner, although for some devices another 
    // driver or system component may assume this role. 
    // Set the initial power state of the device, if known, by calling 
    // PoSetPowerState.
    // 

    deviceExtension->DevPower = PowerDeviceD0;
    deviceExtension->SysPower = PowerSystemWorking;

    state.DeviceState = PowerDeviceD0;
    PoSetPowerState(deviceObject, DevicePowerState, state);

    //
    // attach our driver to device stack
    // The return value of IoAttachDeviceToDeviceStack is the top of the
    // attachment chain.  This is where all the IRPs should be routed.
    //

    deviceExtension->TopOfStackDeviceObject = 
                IoAttachDeviceToDeviceStack(deviceObject,
                                            PhysicalDeviceObject);

    if(NULL == deviceExtension->TopOfStackDeviceObject) {

        IntUsb_WmiDeRegistration(deviceExtension);
        IoDeleteDevice(deviceObject);
        return STATUS_NO_SUCH_DEVICE;
    }
        
    //
    // Register device interfaces
    //

    ntStatus = IoRegisterDeviceInterface(deviceExtension->PhysicalDeviceObject, 
                                         &GUID_INTERFACE_SILABS_INTERRUPT, 
                                         NULL, 
                                         &deviceExtension->InterfaceName);

    if(!NT_SUCCESS(ntStatus)) {

        IntUsb_WmiDeRegistration(deviceExtension);
        IoDetachDevice(deviceExtension->TopOfStackDeviceObject);
        IoDeleteDevice(deviceObject);
        return ntStatus;
    }

    if(IoIsWdmVersionAvailable(1, 0x20)) {

        deviceExtension->WdmVersion = WinXpOrBetter;
    }
    else if(IoIsWdmVersionAvailable(1, 0x10)) {

        deviceExtension->WdmVersion = Win2kOrBetter;
    }
    else if(IoIsWdmVersionAvailable(1, 0x5)) {

        deviceExtension->WdmVersion = WinMeOrBetter;
    }
    else if(IoIsWdmVersionAvailable(1, 0x0)) {

        deviceExtension->WdmVersion = Win98OrBetter;
    }

    deviceExtension->SSRegistryEnable = 0;
    deviceExtension->SSEnable = 0;

    //
    // WinXP only
    // check the registry flag -
    // whether the device should selectively
    // suspend when idle
    //

    if(WinXpOrBetter == deviceExtension->WdmVersion) {

        IntUsb_GetRegistryDword(INTUSB_REGISTRY_PARAMETERS_PATH,
                                 L"IntUsbEnable",
                                 &deviceExtension->SSRegistryEnable);

        if(deviceExtension->SSRegistryEnable) {

            //
            // initialize DPC
            //
            KeInitializeDpc(&deviceExtension->DeferredProcCall, 
                            DpcRoutine, 
                            deviceObject);

            //
            // initialize the timer.
            // the DPC and the timer in conjunction, 
            // monitor the state of the device to 
            // selectively suspend the device.
            //
            KeInitializeTimerEx(&deviceExtension->Timer,
                                NotificationTimer);

            //
            // Initialize the NoDpcWorkItemPendingEvent to signaled state.
            // This event is cleared when a Dpc is fired and signaled
            // on completion of the work-item.
            //
            KeInitializeEvent(&deviceExtension->NoDpcWorkItemPendingEvent, 
                              NotificationEvent, 
                              TRUE);

            //
            // Initialize the NoIdleReqPendEvent to ensure that the idle request
            // is indeed complete before we unload the drivers.
            //
            KeInitializeEvent(&deviceExtension->NoIdleReqPendEvent,
                              NotificationEvent,
                              TRUE);
        }
    }

	// Create an IRP and a URB to use in polling for interrupts

	ntStatus = CreateInterruptUrbIN(deviceObject);
	if (!NT_SUCCESS(ntStatus))
	{
		KdPrint( ("CreateInterruptUrb failed with %X\n", ntStatus));
        IoDeleteDevice(deviceObject);
        return ntStatus;
	}

	
	InitializeListHead(&deviceExtension->Pending_IOCTL_READINT_List);
	KeInitializeSpinLock(&deviceExtension->Cachelock);
		
    //
    // Clear the DO_DEVICE_INITIALIZING flag.
    // Note: Do not clear this flag until the driver has set the
    // device power state and the power DO flags. 
    //

    deviceObject->Flags &= ~DO_DEVICE_INITIALIZING;

    KdPrint( ("IntUsb_AddDevice - ends\n"));

    return ntStatus;
}


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲综合自拍偷拍| 欧美麻豆精品久久久久久| 精品精品国产高清a毛片牛牛| 国产二区国产一区在线观看| 欧美一区二区福利在线| 国产成人啪午夜精品网站男同| 国产精品久久三区| 欧美精品xxxxbbbb| 成人免费视频caoporn| 亚洲自拍欧美精品| 国产欧美中文在线| 4438x亚洲最大成人网| 成人动漫在线一区| 免费三级欧美电影| 一区二区日韩av| 欧美精品一区二区三区高清aⅴ| 色视频欧美一区二区三区| 蜜臀av性久久久久蜜臀aⅴ四虎| 亚洲欧美综合色| 欧美自拍偷拍一区| 成人国产精品免费观看| 国产一区视频网站| 国产在线日韩欧美| 捆绑调教美女网站视频一区| 亚洲国产日韩精品| 亚洲欧美日韩精品久久久久| 亚洲欧洲av另类| 综合分类小说区另类春色亚洲小说欧美 | 亚洲国产精品成人久久综合一区| 欧美videos大乳护士334| 日韩精品一区在线| 欧美大胆一级视频| 欧美精品一区二区在线观看| 久久奇米777| 欧美国产精品一区| 亚洲一区二区精品3399| 亚洲成人免费观看| 裸体歌舞表演一区二区| 国产成a人亚洲精| 91在线视频在线| 欧美日韩一区二区三区视频| 欧美一级一区二区| 欧美国产日韩精品免费观看| 亚洲欧美国产77777| 亚洲电影一级片| 国产河南妇女毛片精品久久久| 国产精品一卡二卡| 在线播放中文字幕一区| 国产日韩影视精品| 亚洲成av人片在线观看无码| 国产黄色成人av| 欧美三日本三级三级在线播放| 国产欧美1区2区3区| 国产精品一区一区三区| 精品国产伦一区二区三区观看体验| 日韩在线一区二区三区| 欧美日韩国产高清一区| 亚洲777理论| 欧美一区二区三区四区五区 | 欧美一级欧美三级在线观看| 久久久影院官网| 蜜臀精品久久久久久蜜臀| 日本高清成人免费播放| 欧美激情一区二区| 久久不见久久见免费视频7| 欧美欧美欧美欧美首页| 亚洲女厕所小便bbb| 波多野结衣精品在线| 欧美国产视频在线| 国产大陆精品国产| 久久精品视频一区| 国产在线国偷精品免费看| 日韩欧美一区二区免费| 免费人成网站在线观看欧美高清| 欧美精品丝袜中出| 亚洲不卡一区二区三区| 69精品人人人人| 另类小说色综合网站| 精品国产91亚洲一区二区三区婷婷| 精品一区二区三区免费毛片爱| 91精品国产一区二区三区| 欧美videos大乳护士334| 亚洲色图欧美在线| 黄色精品一二区| 91久久国产最好的精华液| 日韩精品一区二区三区中文不卡 | 久久色中文字幕| 乱一区二区av| 国产午夜亚洲精品羞羞网站| 久久99九九99精品| 国产精品理论片| 91久久国产综合久久| 人禽交欧美网站| 久久久久久亚洲综合影院红桃| 丁香婷婷综合激情五月色| 亚洲欧美日韩国产手机在线| 欧美一区二区视频网站| 国产成人99久久亚洲综合精品| 亚洲免费色视频| 精品国产一区二区三区四区四 | 久久精品国产一区二区三区免费看| 精品国产亚洲在线| 91网站最新地址| 六月丁香婷婷久久| 亚洲午夜久久久久中文字幕久| 日韩一区二区影院| 91美女视频网站| 美女免费视频一区| 污片在线观看一区二区| 欧美国产日韩亚洲一区| 欧美一二三四区在线| 日本高清不卡在线观看| 国产精品一区二区久久不卡| 日本欧美大码aⅴ在线播放| 国产精品欧美一区喷水| 日韩视频免费观看高清完整版| 在线看不卡av| 色综合久久久久综合体| 高清shemale亚洲人妖| 激情久久五月天| 蜜桃av一区二区在线观看| 亚洲国产一区在线观看| 18成人在线观看| 亚洲精选在线视频| 亚洲欧美激情一区二区| 中文字幕一区二区三区不卡在线 | 99久久久久久| av不卡在线观看| 色噜噜偷拍精品综合在线| 99久久国产免费看| 91免费在线看| 欧美久久久久免费| 欧美成人精品福利| 久久伊99综合婷婷久久伊| 国产日韩欧美麻豆| 国产精品你懂的| 亚洲一区二区av在线| 日韩精品欧美精品| 国产精品综合一区二区| 成人av电影免费观看| 欧美亚洲国产一卡| 日韩精品一区二区三区四区| 久久无码av三级| 亚洲在线视频一区| 老司机精品视频线观看86| 成人午夜又粗又硬又大| 欧美性受xxxx黑人xyx性爽| 久久综合色播五月| 欧美自拍丝袜亚洲| 亚洲另类中文字| 风流少妇一区二区| 秋霞影院一区二区| 精品国产免费视频| 国产精品久久久久久久蜜臀| 欧美va在线播放| 另类小说综合欧美亚洲| 91精品国产综合久久久久久 | 成人中文字幕电影| 欧美精品一区二区高清在线观看| 久久福利资源站| 日韩欧美国产综合一区 | 丁香激情综合国产| 精品一区二区在线播放| 国产一区二区在线观看视频| 国产成人av电影在线播放| 成人v精品蜜桃久久一区| 色婷婷久久综合| 3atv在线一区二区三区| 久久久久久久国产精品影院| 国产91富婆露脸刺激对白| 亚洲乱码中文字幕| 成人教育av在线| 国产视频不卡一区| 欧美一区午夜精品| 色婷婷av一区二区三区软件| 国产伦精品一区二区三区免费 | 在线日韩一区二区| 国产v综合v亚洲欧| 免费成人深夜小野草| 国产成人在线看| 毛片av一区二区| 亚洲成人高清在线| 国产精品超碰97尤物18| 久久午夜国产精品| 欧美一级xxx| 欧美三级视频在线播放| 成人高清免费在线播放| 国产一区高清在线| 麻豆91在线播放| 日精品一区二区| 亚洲综合小说图片| 亚洲国产精品ⅴa在线观看| 精品国产3级a| 欧美videossexotv100| 婷婷综合五月天| 亚洲人成人一区二区在线观看 | 亚洲精品国产成人久久av盗摄| 国产亚洲欧美色| 亚洲精品一区二区三区影院| 欧美一级在线观看|