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

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

?? pnp.cpp

?? PCI開發(fā)寶典隨書配套光盤
?? 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;
			//其他資源一般沒有,可默認(rèn)處理
/*			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


?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国内精品免费**视频| av在线综合网| 亚洲精品成a人| 日韩欧美国产一区在线观看| 91视频免费观看| 欧美视频在线一区二区三区 | 日韩免费看网站| 一区二区三区高清在线| 精品成人私密视频| 久久综合国产精品| 亚洲成av人片| 欧美一二三区在线观看| 7777精品伊人久久久大香线蕉完整版 | 欧美一级搡bbbb搡bbbb| 国产精品久久看| 亚洲一区二区三区爽爽爽爽爽| 久久久不卡网国产精品一区| 自拍偷拍国产亚洲| 亚洲码国产岛国毛片在线| 亚洲欧美一区二区三区极速播放 | 成人性生交大合| 国产91精品精华液一区二区三区 | 国产激情精品久久久第一区二区| 91精品国产综合久久香蕉的特点 | 亚洲美女屁股眼交| 91在线小视频| 免费美女久久99| 26uuu久久综合| 一本一道久久a久久精品| 亚洲三级免费观看| 日韩三级中文字幕| 久久99热99| 夜色激情一区二区| 欧美日韩www| 国产激情视频一区二区三区欧美 | 蜜臀av性久久久久蜜臀aⅴ| 制服丝袜亚洲精品中文字幕| 国产精品影音先锋| 亚洲欧洲精品天堂一级| 丝袜美腿亚洲一区| 精品美女在线播放| 韩国午夜理伦三级不卡影院| 亚洲欧洲美洲综合色网| 欧洲精品中文字幕| 日韩在线a电影| 91伊人久久大香线蕉| 一区二区视频免费在线观看| 91美女在线观看| 亚洲成人综合视频| 久久一二三国产| 欧美日韩免费一区二区三区 | 久久久久国产精品麻豆ai换脸 | 国产欧美日韩另类一区| 五月天丁香久久| 精品欧美久久久| 青娱乐精品视频| 一区二区三区在线视频观看| 欧美日韩一区成人| 99久久精品免费看国产免费软件| 亚洲综合激情网| 国产精品成人免费精品自在线观看| 91免费版pro下载短视频| 成人免费三级在线| 有坂深雪av一区二区精品| 91黄色在线观看| 日本午夜一本久久久综合| 亚洲第一综合色| 亚洲综合免费观看高清在线观看| 欧美一区二区三区系列电影| 欧美性淫爽ww久久久久无| 国产精品一区一区三区| 麻豆成人久久精品二区三区小说| 中文字幕av一区二区三区高| 国产成人午夜片在线观看高清观看 | 三级精品在线观看| 亚洲成av人片| 中文字幕日本乱码精品影院| 国产亚洲精品aa| 欧美人xxxx| 成人污污视频在线观看| 午夜久久久久久| 天堂在线一区二区| 国产精品久久久久久久久快鸭| 欧美极品另类videosde| 欧美日韩精品一区二区三区| 欧美日韩亚洲综合一区| 国产成a人无v码亚洲福利| 国产成人午夜电影网| 日韩国产精品久久| 一区2区3区在线看| 中文字幕免费观看一区| 国产精品久久久久影院| 91精品国产综合久久蜜臀| 欧美日韩在线播放三区四区| 不卡电影一区二区三区| 97精品久久久久中文字幕| 国产乱子轮精品视频| 成人黄色a**站在线观看| 九九**精品视频免费播放| 国产一区二三区好的| 免费人成在线不卡| 国产成人aaa| 夜色激情一区二区| 蜜桃av一区二区三区电影| 色婷婷国产精品| 欧美久久久一区| 午夜a成v人精品| 久久成人免费日本黄色| 51精品久久久久久久蜜臀| 91精品国产欧美一区二区| 国产一区二区精品久久99| 91在线一区二区三区| 国产精品自在在线| 激情六月婷婷久久| 91污在线观看| 91视频你懂的| 日韩美一区二区三区| 7777精品伊人久久久大香线蕉的 | 久久久另类综合| 国产精品久久久久久久第一福利 | 日本韩国精品在线| 国内成人免费视频| 亚洲va欧美va国产va天堂影院| 亚洲免费观看高清完整版在线 | 日本午夜一区二区| fc2成人免费人成在线观看播放| 国产69精品久久久久毛片| 欧美午夜精品一区二区三区 | 欧美色图在线观看| 欧美午夜精品一区| 国产精品网站在线播放| 亚洲欧洲综合另类| 国产aⅴ综合色| 国产一区二区在线观看免费| 日本黄色一区二区| 国产91精品一区二区麻豆网站| 欧美视频在线观看一区二区| 欧美久久久久久久久久| 91精品国产综合久久香蕉的特点| 亚洲天天做日日做天天谢日日欢 | 国产精品毛片无遮挡高清| 免费看日韩a级影片| 风流少妇一区二区| 日韩欧美综合一区| 国产精品国产自产拍高清av王其 | 高清在线不卡av| 丁香六月久久综合狠狠色| 91福利在线导航| 国产精品久久久久天堂| 亚洲自拍偷拍欧美| 一本大道av伊人久久综合| 欧美年轻男男videosbes| 亚洲精品免费看| 激情综合一区二区三区| 欧美一卡二卡在线观看| 欧美激情一区二区三区| 国产精品亚洲一区二区三区在线| 日本不卡的三区四区五区| 欧美日韩视频专区在线播放| 亚洲美女在线国产| 99热99精品| 欧美日韩久久不卡| 日韩美女视频一区二区| k8久久久一区二区三区| 精品国产髙清在线看国产毛片| 日本怡春院一区二区| 99国产精品99久久久久久| 中文字幕精品—区二区四季| 视频一区在线视频| 日韩一级高清毛片| 亚洲免费观看高清完整版在线观看熊| 91香蕉视频黄| 日本精品一级二级| 亚洲国产精品久久久久秋霞影院| 亚洲午夜电影在线观看| av电影在线观看一区| 国产精品久久久久久久久晋中| 蓝色福利精品导航| 久久色在线视频| 婷婷六月综合亚洲| 97久久精品人人澡人人爽| 国产欧美一区二区三区沐欲| 日本少妇一区二区| 欧美色综合网站| 怡红院av一区二区三区| 成人免费的视频| 欧美成人精品3d动漫h| 亚洲国产高清aⅴ视频| 欧美亚洲综合色| 日本不卡一二三区黄网| 欧美偷拍一区二区| 久久www免费人成看片高清| 欧美少妇一区二区| 国产在线精品一区二区三区不卡| 欧美精品乱人伦久久久久久| 麻豆91在线播放| 在线播放国产精品二区一二区四区| 日本中文一区二区三区| 国产亚洲欧洲一区高清在线观看| 男人操女人的视频在线观看欧美|