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

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

?? pnp.cpp

?? pci9052的驅動程序
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
				}		//PCI Bar 0
				else
				{		//PCI Bar 2, 8155 Mem map
					pdx->PdcPhysicalMemBase = ResourceRaw->u.Memory.Start;
					pdx->PdcMemCount = ResourceRaw->u.Memory.Length;
					pdx->PdcMemBase = (ULONG *)MmMapIoSpace(pdx->PdcPhysicalMemBase,
						pdx->PdcMemCount,MmNonCached);
					DebugPrint("The MEM Base SJA1000 is %x;Count is %x.",pdx->PdcMemBase,pdx->PdcMemCount);
					if (pdx->PdcMemBase == NULL)
					{
						DebugPrint("ERROR - Unable to map SJA1000.\n");
						return STATUS_INSUFFICIENT_RESOURCES;
					}
					GotPdcMem = TRUE;
				}			//PCI Bar 2, 8155 Mem map
				break;
			//其他資源一般沒有,可默認處理
/*			case CmResourceTypeNull:
				DebugPrint("Type: Null (unsupported)");
				break;
			case CmResourceTypeDma:
				DebugPrint("Type: DMA (unsupported)");
				break;
			case CmResourceTypeDeviceSpecific:
				DebugPrint("Type: Device Specific (unsupported)");
				break;
			case CmResourceTypeBusNumber:
				DebugPrint("Type: Bus Number (unsupported)\n");
				break;
			// NonArbitrated & ConfigData are currently #defined as the same number
			case CmResourceTypeConfigData:
				DebugPrint("Type: Non-Arbitrated or Config Data (unsupported)");
				break;
			case CmResourceTypeDevicePrivate:
				DebugPrint(" Type: Device Private Data (unsupported)");
				break;
			case CmResourceTypePcCardConfig:
				DebugPrint("Type: PC Card Configuration (unsupported)");
				break;
			case CmResourceTypeMfCardConfig:
				DebugPrint("Type: Multi-function Card Configuration (unsupported)");
				break;
*/
			default:
				DebugPrint("Type: ?Unknown Resource Type?");
				break;
        }
    }

    // Make sure BAR 0 exists or the device can't be started
	if (!GotBaseMem)
	{
		DebugPrint("PCI9052Demo: ERROR - BAR 0 address not configured, unable to load driver.");
		return STATUS_INSUFFICIENT_RESOURCES;	
	}
	if (!GotPdcMem)
	{
		if(pdx->MemBase)
		{
			MmUnmapIoSpace(pdx->MemBase,pdx->MemCount);		//Free Base Memory.
			DebugPrint("PCI9052Demo: ERROR - CanMemBase.");
		}
		return STATUS_INSUFFICIENT_RESOURCES;
	}
	//連接中斷
    if (GotInterrupt)
    {
		DebugPrint("Get Interrupt.");
        // 首先Disable the PCI interrupt
		DisablePciInterrupt(pdx);
		//連接中斷
		status = IoConnectInterrupt(&pdx->pInterruptObject,(PKSERVICE_ROUTINE)OnInterrupt,
						(PVOID)pdx,NULL,vector,IrqL,IrqL,mode,irqshare,affinity,FALSE);	//(PVOID)
		DebugPrint("OK, I haved Connect Interruput!");
		if (!NT_SUCCESS(status))
		{
			pdx->pInterruptObject = NULL;
			return status;
		}
		else
        {	// Re-enable the PCI Interrupt
			DebugPrint("OK, Let's enable interrupt.");
			if (pdx->pInterruptObject == NULL)
			{
				DebugPrint("Interrupt object is NULL.");
			}
			//同步Enable interrupt.
			KeSynchronizeExecution(pdx->pInterruptObject,(PKSYNCHRONIZE_ROUTINE)EnablePciInterrupt,pdx);
			DebugPrint("Have Enabled Interrupt.");
		}
    }
    else
    {
        DebugPrint("PCI9052Demo: No interrupt found.");
		//Free haved mapped memories.
		MmUnmapIoSpace(pdx->MemBase,pdx->MemCount);
		MmUnmapIoSpace(pdx->PdcMemBase,pdx->PdcMemCount);
        pdx->pInterruptObject = NULL;
    }

	pdx->GotResource=TRUE;
	DebugPrint("Start Device end.");
    return STATUS_SUCCESS;
}												//StartDevice

/******************************************************************************
 *
 * Function   :  HandleStopDevice
 *
 * Description:  Handle the IRP_MN_STOP_DEVICE PnP request
 *
 ******************************************************************************/
NTSTATUS PnpStopDevice(IN PDEVICE_OBJECT fdo,
					   IN PIRP pIrp)
{	

    StopDevice(fdo);
	
	return DefaultPnpHandler(fdo,pIrp);
}												//HandleStopDevice

/******************************************************************************
 *
 * Function   :  StopDevice
 *
 * Description:  Stop a device
 *
 ******************************************************************************/
VOID StopDevice(IN PDEVICE_OBJECT fdo)
{												//StopDevice
    DEVICE_EXTENSION *pdx;

    pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension;

	if (!pdx->GotResource)
		return;

	pdx->bStopping = TRUE;
	KeResetEvent(&pdx->StoppingEvent);
	UnlockDevice(pdx);	//必須UnlockDevice兩次
	UnlockDevice(pdx);
	
	KeWaitForSingleObject( &pdx->StoppingEvent, Executive, KernelMode, FALSE, NULL);
	DebugPrint("PnpStopDevice: All pending I/O completed");
	pdx->bStopping = FALSE;

	pdx->GotResource = FALSE;

	DebugPrint("PCI9052Demo is being stopped...");
	
	//等待全部的IRP釋放后再釋放資源
    // Free all interrupt resources
    if (pdx->pInterruptObject != NULL)
    {
        KeSynchronizeExecution(pdx->pInterruptObject,
            (PKSYNCHRONIZE_ROUTINE)DisablePciInterrupt,(PVOID)pdx);

        IoDisconnectInterrupt(pdx->pInterruptObject);
        pdx->pInterruptObject = NULL;
    }
	
	//Free all the mem map.
	if(pdx->MemBase)
		MmUnmapIoSpace(pdx->MemBase,pdx->MemCount);
	if(pdx->PdcMemBase)
		MmUnmapIoSpace(pdx->PdcMemBase,pdx->PdcMemCount);
	pdx->MemBase=NULL;
	pdx->MemCount=0;
	pdx->PdcMemBase=NULL;
	pdx->PdcMemCount=0;

	// Bump usage count back up again
	LockDevice(pdx);
	LockDevice(pdx);

	DebugPrint("PCI9052Demo is stopped.");
}												//StopDevice
#pragma code_seg()	// end PAGE section

/******************************************************************************
 *
 * Function   :  LockDevice
 *
 * Description:  Lock a device for operation, return FALSE if device is being
 *               removed.
 *
 ******************************************************************************/
BOOLEAN LockDevice(IN DEVICE_EXTENSION *pdx)
{												//LockDevice

    // Increment use count on our device object
    InterlockedIncrement(&pdx->UsageCount);

//	DebugPrint("PCI9052Demo: Locking...");
    /* 
       If device is about to be removed, restore the use count and return FALSE.
       If a race exists with HandleRemoveDevice (maybe running on another CPU),
       the sequence we've followed is guaranteed to avoid a mistaken deletion of
       the device object. If we test "removing" after HandleRemoveDevice sets 
       it, we'll restore the use count and return FALSE. In the meantime, if
       HandleRemoveDevice decremented count to 0 before we did our increment,
       its thread will have set the remove event. Otherwise, we'll decrement to
       0 and set the event. Either way, HandleRemoveDevice will wake up to 
       finish removing the device, and we'll return FALSE to our caller.

       If, on the other hand, we test "removing" before HandleRemoveDevice sets
       it, we'll have already incremented the use count past 1 and will return 
       TRUE. Our caller will eventually call UnlockDevice, which will decrement
       the use count and might set the event HandleRemoveDevice is waiting on at
       that point.
    */
    if (pdx->bStopping)
    {
        // Stopping device
        if (InterlockedDecrement(&pdx->UsageCount) == 0)
			KeSetEvent(&pdx->StoppingEvent,0,FALSE);
		return FALSE;
    }
//	DebugPrint("PCI9052Demo is locked.");
    return TRUE;
}												//LockDevice

/******************************************************************************
 *
 * Function   :  UnlockDevice
 *
 * Description:  Unlock a device.
 *
 ******************************************************************************/
VOID UnlockDevice(IN DEVICE_EXTENSION *pdx)
{												//UnlockDevice
	LONG UsageCount = InterlockedDecrement(&pdx->UsageCount);
	
//	DebugPrint("PCI9052Demo is unlocking...");

    KdPrint(("PCI9052Demo: UNLOCKING... (usage = %d)\n", UsageCount));

    if (UsageCount == 0)
    {
        // Stopping device
		KeSetEvent(&pdx->StoppingEvent,0,FALSE);
    }
//	DebugPrint("PCI9052Demo is unlocked.");

}												//UnlockDevice

/******************************************************************************
 *
 * Function   :  PnpRemoveDevice
 *
 * Description:  Handle the IRP_MN_REMOVE_DEVICE PnP request
 *
 ******************************************************************************/
NTSTATUS PnpRemoveDevice(IN PDEVICE_OBJECT fdo,
							IN PIRP pIrp)
{												//HandleRemoveDevice
    NTSTATUS          status;
    DEVICE_EXTENSION  *pdx;

    // Wait for any pending I/O operations to complete

    pdx			   = (PDEVICE_EXTENSION) fdo->DeviceExtension;
	pIrp->IoStatus.Status = STATUS_SUCCESS;			// flag that we handled this IRP
	
    StopDevice(fdo);								

    // Let lower-level drivers handle this request & ignore the result
    status = DefaultPnpHandler(fdo,pIrp);

	IoSetDeviceInterfaceState(&pdx->InterfaceName, FALSE);
	RtlFreeUnicodeString(&pdx->InterfaceName);

    // Detach device from the device object stack
    if (pdx->pLowerDeviceObject)
    {
        IoDetachDevice(pdx->pLowerDeviceObject);
    }

    DebugPrint("PCI9052Demo: Deleting device object...");

    // Delete the functional device object
    IoDeleteDevice(fdo);

	DebugPrint("PCI9052Demo is removed.");

    return status;
}												//HandleRemoveDevice

/***********************************************************
*
* Function		:		CompleteRequestInfo
*
* Description	:		Complete the request with infomation.
*
************************************************************/
#pragma code_seg("PAGE")	// start PAGE section
NTSTATUS CompleteRequestInfo(IN PIRP Irp, 
							 IN NTSTATUS status, 
							 IN ULONG_PTR info)
{												// CompleteRequestInfo
	Irp->IoStatus.Status = status;
	Irp->IoStatus.Information = info;
	IoCompleteRequest(Irp, IO_NO_INCREMENT);
	return status;
}												// CompleteRequestInfo
/***********************************************************
*
* Function		:		CompleteRequestInfo
*
* Description	:		Complete the request without infomation.
*
************************************************************/
NTSTATUS CompleteRequest(IN PIRP Irp,
						 IN NTSTATUS status)
{												// CompleteRequest
	Irp->IoStatus.Status = status;
	IoCompleteRequest(Irp, IO_NO_INCREMENT);
	return status;
}												// CompleteRequest

/******************************************************************************
 *
 * Function   :  OnRequestComplete
 *
 * Description:  Set an event when a lower driver complete an IRP.
 *
 ******************************************************************************/
NTSTATUS OnRequestComplete(IN PDEVICE_OBJECT fdo,
						   IN PIRP pIrp,
						   IN PKEVENT pKEvent)
{												//OnRequestComplete
    KeSetEvent(pKEvent,(KPRIORITY)0,FALSE);

    return STATUS_MORE_PROCESSING_REQUIRED;
}												//OnRequestComplete
#pragma code_seg()	// end PAGE section

/*********************************************************************
*
* Function   :  EnablePciInterrupt
*
* Description:  Enables the PLX Chip PCI Interrupt
*
**********************************************************************/
BOOLEAN EnablePciInterrupt(IN PDEVICE_EXTENSION pdx)
{												//EnablePciInterrupt
    ULONG RegInterrupt;
	ULONG Address;

	LockDevice(pdx);

	Address=(ULONG)pdx->MemBase;
	RegInterrupt = READ_REGISTER_ULONG((ULONG *)(Address + 0x4c));
	RegInterrupt |= 0x40;
	WRITE_REGISTER_ULONG((ULONG *)(Address +0x4c),RegInterrupt);

	UnlockDevice(pdx);

	return TRUE;
}												//EnablePciInterrupt

/*********************************************************************
*
* Function   :  DisablePciInterrupt
*
* Description:  Disables the PLX Chip PCI Interrupt
*
**********************************************************************/
BOOLEAN DisablePciInterrupt(IN PDEVICE_EXTENSION pdx)
{												//DisablePciInterrupt
    ULONG RegInterrupt;
	ULONG Address;

	LockDevice(pdx);
	Address=(ULONG)pdx->MemBase;
    RegInterrupt = READ_REGISTER_ULONG((ULONG *)(Address + 0x4c));
//	DebugPrint("The interrupt register is 0x%x.",RegInterrupt);
	RegInterrupt &= ~(0x40);
    WRITE_REGISTER_ULONG((ULONG *)(Address +0x4c),RegInterrupt);
//	DebugPrint("The interrupt register is 0x%x.",RegInterrupt);
	UnlockDevice(pdx);

    return TRUE;
}												//DisablePciInterrupt


/******************************************************************************
 *
 * Function   :  ForwardAndWait
 *
 * Description:  Forward request to lower level and await completion, used
 *               in PnP's IRP_MN_START_DEVICE
 *
 ******************************************************************************/
NTSTATUS ForwardAndWait(PDEVICE_OBJECT fdo,PIRP pIrp)
{												// ForwardAndWait
    KEVENT    event;
    NTSTATUS  status;

    // Initialize a kernel event object to use in waiting for the lower-level
    // driver to finish processing the object. It's a little known fact that the
    // kernel stack *can* be paged, but only while someone is waiting in user 
    // mode for an event to finish. Since neither we nor a completion routine 
	// can be in the forbidden state, it's okay to put the event object on the 
    // stack.
    KeInitializeEvent(&event,NotificationEvent,FALSE);

	DebugPrint("ForwardAndWait Start.");

    IoCopyCurrentIrpStackLocationToNext(pIrp);

    IoSetCompletionRoutine(pIrp,(PIO_COMPLETION_ROUTINE) OnRequestComplete,
							(PVOID) &event,TRUE,TRUE,TRUE);

    status = IoCallDriver(
					((DEVICE_EXTENSION *) fdo->DeviceExtension)->pLowerDeviceObject,
					pIrp);

    if (status == STATUS_PENDING)
    {
        // Wait for completion
        KeWaitForSingleObject((PVOID)&event,Executive,KernelMode,FALSE,NULL);

        return pIrp->IoStatus.Status;
    }
	DebugPrint("ForwardAndWait End.");
    return pIrp->IoStatus.Status;	//status;
}													// ForwardAndWait


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
五月天一区二区| 日韩一级黄色片| 国产一区二区中文字幕| 欧美日高清视频| 一区二区三区毛片| av成人免费在线| 久久久99精品久久| 久久99精品一区二区三区三区| 欧美午夜精品久久久久久超碰| 亚洲伦理在线免费看| 色综合咪咪久久| 国产精品久久99| 一本一本大道香蕉久在线精品| 中文字幕免费观看一区| 婷婷开心久久网| 95精品视频在线| 国产精品嫩草影院com| 韩国女主播一区| 欧美日韩精品一区视频| 亚洲国产毛片aaaaa无费看 | 99re成人精品视频| 一区在线观看视频| 欧美日韩精品三区| 亚洲精品菠萝久久久久久久| 91在线观看成人| 亚洲精品国产a久久久久久| 欧美亚洲自拍偷拍| 性欧美疯狂xxxxbbbb| 日韩欧美在线影院| 麻豆免费看一区二区三区| 日韩亚洲欧美中文三级| 亚洲成人自拍网| 欧美一区二区日韩| 国产成人aaa| 亚洲摸摸操操av| 精品国产乱码久久久久久免费| 国产精品一级片| 亚洲欧洲色图综合| 一本到不卡免费一区二区| 亚洲国产精品久久人人爱蜜臀| 99久久精品国产一区| 亚洲国产另类av| 欧美一个色资源| 白白色 亚洲乱淫| 蜜臀av一区二区在线免费观看| 欧美精品一区二区三区高清aⅴ| 欧美在线你懂得| 丁香激情综合国产| 日韩电影在线观看电影| 国产精品免费看片| 3d成人动漫网站| 91免费看片在线观看| 久久爱www久久做| 亚洲主播在线观看| 国产欧美一区二区三区鸳鸯浴| av午夜一区麻豆| 国产精品自在在线| 午夜精品久久久久久久久久| 26uuu成人网一区二区三区| 欧美性生交片4| 粉嫩av亚洲一区二区图片| 亚洲mv在线观看| 欧美日韩一区二区三区在线看 | 国产欧美日韩在线观看| 1000部国产精品成人观看| 欧美一区二区视频在线观看 | 久久九九国产精品| 精品免费日韩av| 日韩精品在线一区| 日韩女优视频免费观看| 欧美乱妇20p| 欧美日韩一区二区三区四区 | 成人99免费视频| 国产乱子轮精品视频| 免费成人av资源网| 国产精品国产精品国产专区不蜜 | 激情久久五月天| 无吗不卡中文字幕| 五月天丁香久久| 中文字幕日韩一区| 一区免费观看视频| 欧美经典三级视频一区二区三区| 精品国产乱码91久久久久久网站| 91精品国产综合久久精品性色| 欧美综合久久久| 欧美在线免费视屏| 色狠狠色噜噜噜综合网| 欧美在线制服丝袜| 欧美日韩久久久一区| 欧美高清视频不卡网| 欧美亚洲丝袜传媒另类| 日韩欧美一二三四区| 亚洲码国产岛国毛片在线| 美美哒免费高清在线观看视频一区二区 | 五月婷婷另类国产| 国产精品久久久久毛片软件| 欧美一区二区三区视频| 日韩欧美亚洲国产另类| 欧美一级日韩不卡播放免费| 欧美不卡一区二区| 日韩一区在线看| 五月天丁香久久| 国产精品亚洲午夜一区二区三区| 9i看片成人免费高清| 欧美日本一区二区| 国产婷婷色一区二区三区| 一区二区三区自拍| 黑人巨大精品欧美黑白配亚洲| 成人理论电影网| 6080日韩午夜伦伦午夜伦| 久久久久久久久久久久久久久99 | 在线欧美小视频| 精品国产乱码久久久久久久久| 天堂精品中文字幕在线| 成人免费视频网站在线观看| jlzzjlzz亚洲日本少妇| 国产精品一区二区三区四区| 亚洲va韩国va欧美va精品| 激情综合色播激情啊| 韩国女主播成人在线| 91麻豆免费观看| 欧美亚洲尤物久久| 国产女人18水真多18精品一级做| 依依成人综合视频| 91一区一区三区| 日韩一区二区三区免费看| 亚洲一卡二卡三卡四卡无卡久久| 久久av资源网| 日韩精品欧美精品| jlzzjlzz欧美大全| 精品国产一区二区三区久久久蜜月 | 久久精品国产**网站演员| 91色婷婷久久久久合中文| 久久久噜噜噜久久中文字幕色伊伊| 自拍偷自拍亚洲精品播放| 国产在线播精品第三| 91.com视频| 一区二区三区欧美在线观看| 懂色av一区二区三区免费观看 | 日本韩国一区二区三区视频| 久久久久国产成人精品亚洲午夜| 毛片一区二区三区| 欧美电影免费观看完整版| 韩日av一区二区| 久久精品综合网| 国产成人精品网址| 久久久国际精品| 精品一二三四在线| 欧美日韩精品专区| 亚洲日本在线a| 亚洲第一主播视频| 91国内精品野花午夜精品| 亚洲香蕉伊在人在线观| 色999日韩国产欧美一区二区| 青青草国产成人av片免费| 在线不卡免费av| 国产精品一区二区在线观看不卡| 欧美一区二区人人喊爽| 久草热8精品视频在线观看| 日本一区二区三区免费乱视频| 国产精品色一区二区三区| 国产成人精品一区二| 亚洲靠逼com| 日韩一级精品视频在线观看| 亚洲1区2区3区4区| 日韩精品在线一区| 色999日韩国产欧美一区二区| 一区二区三区影院| 欧美视频一区二区三区| 狠狠色丁香久久婷婷综| 欧美一区午夜精品| 亚洲成人午夜电影| 久久99精品国产.久久久久久| 国产精品每日更新| 色婷婷av一区二区三区之一色屋| 国产亚洲成aⅴ人片在线观看 | 国产精品国产精品国产专区不片| 91在线云播放| 国产又粗又猛又爽又黄91精品| 亚洲欧美影音先锋| 久久综合九色综合久久久精品综合| 国产麻豆视频精品| 亚洲人午夜精品天堂一二香蕉| 国产成人精品免费视频网站| 国产精品初高中害羞小美女文| 久久精品国产99久久6| 午夜精品成人在线视频| 午夜在线电影亚洲一区| 久久久久久久久久看片| 欧美视频日韩视频| 成人午夜看片网址| 奇米影视一区二区三区| 亚洲欧美另类小说| 中文字幕av一区二区三区| 91精品久久久久久久99蜜桃| 亚洲欧美日韩一区二区| 欧美色图免费看| 成年人网站91| 不卡的av电影在线观看| 国产麻豆91精品|