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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? pnp.cpp

?? 這個(gè)是PCI9052芯片的驅(qū)動(dòng)程序的源代碼 是用DriverStudio編寫(xiě)的
?? CPP
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
				}		//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;
			//其他資源一般沒(méi)有,可默認(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


?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美色精品在线视频| 麻豆成人在线观看| 日韩中文字幕不卡| 久久黄色级2电影| 国产夫妻精品视频| 91黄色免费网站| 久久欧美中文字幕| 中文字幕一区二区三区不卡| 亚洲电影你懂得| 国产伦精品一区二区三区免费迷| 本田岬高潮一区二区三区| 色呦呦国产精品| 精品国偷自产国产一区| 国产精品久久看| 免费在线观看一区二区三区| 丁香婷婷综合激情五月色| 欧美日韩国产精选| 国产精品入口麻豆九色| 亚洲www啪成人一区二区麻豆| 国产一区三区三区| 欧美日韩在线播放| 国产精品免费看片| 另类专区欧美蜜桃臀第一页| 99国内精品久久| 精品久久五月天| 亚洲午夜激情av| jizzjizzjizz欧美| 精品国产一区二区三区久久久蜜月 | 日韩一级完整毛片| 亚洲欧洲在线观看av| 久久精品国产精品亚洲精品| 色婷婷亚洲精品| 亚洲国产精品二十页| 日本麻豆一区二区三区视频| av网站免费线看精品| 2024国产精品视频| 亚洲成国产人片在线观看| 成人深夜在线观看| 26uuu国产电影一区二区| 亚洲在线免费播放| 91免费在线视频观看| 久久综合久久鬼色| 日本女人一区二区三区| 91久久精品国产91性色tv| 中文字幕巨乱亚洲| 国产一区二区精品久久91| 欧美丰满少妇xxxxx高潮对白 | 成人永久看片免费视频天堂| 精品日韩在线观看| 天堂资源在线中文精品| 色综合天天性综合| 国产精品久久久久影院亚瑟| 国产精品一区二区男女羞羞无遮挡| 欧美乱妇20p| 亚洲一区二区三区精品在线| thepron国产精品| 欧美高清在线一区| 国产福利一区二区三区在线视频| 日韩一区二区免费电影| 天天射综合影视| 欧美精选在线播放| 午夜日韩在线电影| 欧美日韩免费电影| 午夜免费久久看| 欧美日韩视频在线观看一区二区三区 | 蜜臀a∨国产成人精品| 欧美精品在线观看一区二区| 夜夜嗨av一区二区三区| 一本大道av一区二区在线播放| 国产精品成人免费| 91麻豆免费在线观看| 亚洲婷婷综合久久一本伊一区 | 一区二区三区在线视频观看| 99国产精品久久久久久久久久| 国产精品免费视频观看| 93久久精品日日躁夜夜躁欧美| 亚洲色图制服诱惑| 欧美中文字幕一区| 丝袜美腿亚洲一区二区图片| 制服丝袜av成人在线看| 日韩精品一二三| 日韩一级二级三级| 久草在线在线精品观看| 久久久久久久久久看片| 国产成人在线视频网站| 国产精品麻豆久久久| 99久久99久久精品国产片果冻 | 欧美日韩你懂得| 免费一级欧美片在线观看| 日韩欧美激情在线| 国产91在线观看| 国产一区在线观看麻豆| 亚洲国产高清在线| 色狠狠桃花综合| 视频一区在线视频| 精品999在线播放| 成人国产亚洲欧美成人综合网| 亚洲欧美日韩在线| 91精品国产综合久久精品| 久久国产综合精品| 国产精品青草综合久久久久99| 色婷婷激情久久| 免费成人小视频| 国产精品久99| 欧美日韩国产大片| 国产在线国偷精品产拍免费yy| 中文欧美字幕免费| 欧美日韩国产电影| 国产精品99久久久久久似苏梦涵| 最好看的中文字幕久久| 欧美天天综合网| 国产中文字幕一区| 亚洲女同一区二区| 日韩一区二区免费在线观看| 成人小视频在线| 亚洲444eee在线观看| 国产日韩欧美一区二区三区乱码| 91亚洲精品久久久蜜桃网站| 日韩精品91亚洲二区在线观看| 日本一区二区三区在线不卡| 欧美亚洲综合网| 国产精品一区二区久激情瑜伽| 一区二区三区精品| 精品99999| 欧美日韩一区二区三区视频 | 久久综合av免费| 91国内精品野花午夜精品| 国产在线精品不卡| 香蕉成人啪国产精品视频综合网| 久久精品男人天堂av| 欧美日韩极品在线观看一区| 成人看片黄a免费看在线| 日日夜夜精品视频免费| 国产精品美女久久久久久2018| 欧美精品精品一区| 色综合久久久久久久久久久| 国产一区二区三区日韩| 午夜精品福利一区二区三区蜜桃| 欧美国产欧美亚州国产日韩mv天天看完整| 欧美猛男超大videosgay| 成人国产视频在线观看| 美女脱光内衣内裤视频久久影院| 亚洲视频在线一区| 久久久久高清精品| 6080日韩午夜伦伦午夜伦| 色综合视频在线观看| 福利91精品一区二区三区| 免费一级片91| 亚洲一区免费观看| 国产精品理论片在线观看| 精品少妇一区二区三区日产乱码| 欧美日韩中文字幕一区二区| 不卡一区二区中文字幕| 国产精品羞羞答答xxdd| 欧美aⅴ一区二区三区视频| 亚洲综合激情网| 亚洲素人一区二区| 国产精品女主播av| 国产偷国产偷亚洲高清人白洁| 91精品国产91久久久久久最新毛片| 色综合色综合色综合色综合色综合| 国产不卡视频一区| 国产成人啪免费观看软件| 狠狠久久亚洲欧美| 蜜桃av噜噜一区| 日韩专区在线视频| 三级在线观看一区二区 | 欧美日韩精品欧美日韩精品一| 91在线码无精品| av中文字幕不卡| 这里是久久伊人| 69成人精品免费视频| 欧美放荡的少妇| 欧美一区二区三区四区在线观看| 欧美偷拍一区二区| 欧美日韩aaaaaa| 欧美精品九九99久久| 91精品国产手机| 日韩免费高清av| www久久精品| 国产校园另类小说区| 国产网站一区二区| 国产精品电影一区二区三区| 国产精品福利一区| 亚洲精品自拍动漫在线| 尤物av一区二区| 亚洲mv在线观看| 秋霞电影网一区二区| 美女一区二区视频| 久久99精品久久只有精品| 韩国精品在线观看| 国产精品一区久久久久| 国产成人午夜精品影院观看视频 | 欧美成人精品高清在线播放| 日韩精品专区在线影院重磅| 日韩一级完整毛片| 久久久久9999亚洲精品| 国产精品五月天| 伊人开心综合网| 午夜精品福利一区二区蜜股av |