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

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

?? m8usbdrvdevice.cpp

?? avr mega8單片機與pdiusbd12芯片實現usb通信
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
//

NTSTATUS M8usbdrvDevice::Create(KIrp I)
{
	NTSTATUS status;

	t << "Entering M8usbdrvDevice::Create, " << I << EOL;

// TODO: Add driver specific create handling code here

	// Generally a create IRP is targeted at our FDO, so we don't need
	// to pass it down to the PDO.  We have found for some devices, the
	// PDO is not expecting this Irp and returns an error code.
	// The default wizard code, therefore completes the Irp here using
	// PnpComplete().  The following commented code could be used instead
	// of PnpComplete() to pass the Irp to the PDO, which would complete it.
	//
//	I.ForceReuseOfCurrentStackLocationInCalldown();
//	status = m_Lower.PnpCall(this, I);

	status = I.PnpComplete(this, STATUS_SUCCESS, IO_NO_INCREMENT);

	t << "M8usbdrvDevice::Create Status " << (ULONG)status << EOL;

	return status;
}


////////////////////////////////////////////////////////////////////////
//  M8usbdrvDevice::Close
//
//	Routine Description:
//		Handler for IRP_MJ_CLOSE
//
//	Parameters:
//		I - Current IRP
//
//	Return Value:
//		NTSTATUS - Result code
//
//	Comments:
//

NTSTATUS M8usbdrvDevice::Close(KIrp I)
{
	NTSTATUS status;

	t << "Entering M8usbdrvDevice::Close, " << I << EOL;

// TODO: Add driver specific close handling code here

	// Generally a close IRP is targeted at our FDO, so we don't need
	// to pass it down to the PDO.  We have found for some devices, the
	// PDO is not expecting this Irp and returns an error code.
	// The default wizard code, therefore completes the Irp here using
	// PnpComplete().  The following commented code could be used instead
	// of PnpComplete() to pass the Irp to the PDO, which would complete it.
	//
//	I.ForceReuseOfCurrentStackLocationInCalldown();
//	status = m_Lower.PnpCall(this, I);

	status = I.PnpComplete(this, STATUS_SUCCESS, IO_NO_INCREMENT);

	t << "M8usbdrvDevice::Close Status " << (ULONG)status << EOL;

    return status;
}

////////////////////////////////////////////////////////////////////////
//  M8usbdrvDevice::Cleanup
//
//	Routine Description:
//		Handler for IRP_MJ_CLEANUP	
//
//	Parameters:
//		I - Current IRP
//
//	Return Value:
//		NTSTATUS - Result code
//
//	Comments:
//

NTSTATUS M8usbdrvDevice::CleanUp(KIrp I)
{
	t << "Entering CleanUp, " << I << EOL;

// TODO:	Insert your code to respond to the CLEANUP message.
	return I.PnpComplete(this, STATUS_SUCCESS);
}


////////////////////////////////////////////////////////////////////////
//  M8usbdrvDevice::Read
//
//	Routine Description:
//		Handler for IRP_MJ_READ
//
//	Parameters:
//		I			Current IRP
//
//	Return Value:
//		NTSTATUS	Result code
//
//	Comments:
//		This routine handles read requests.
//
//		The KPnpDevice class handles restricting IRP flow
//		if the device is stopping or being removed.
//

NTSTATUS M8usbdrvDevice::Read(KIrp I) 
{
	t << "Entering M8usbdrvDevice::Read, " << I << EOL;
// TODO:	Check the incoming request.  Replace "FALSE" in the following
//			line with a check that returns TRUE if the request is not valid.

    if (FALSE)		// If (Request is invalid)
	{
		// Invalid parameter in the Read request
		I.Information() = 0;
		return I.PnpComplete(this, STATUS_INVALID_PARAMETER);
	}

	// Always ok to read 0 elements.
	if (I.ReadSize() == 0)
	{
		I.Information() = 0;
		return I.PnpComplete(this, STATUS_SUCCESS);
	}

	// Declare a memory object
	KMemory Mem(I.Mdl());

    ULONG dwTotalSize = I.ReadSize(CURRENT);
	ULONG dwMaxSize = m_Endpoint2IN.MaximumTransferSize();

	// If the total requested read size is greater than the Maximum Transfer
	// Size for the Pipe, request to read only the Maximum Transfer Size since
	// the bus driver will fail an URB with a TransferBufferLength of greater
	// than the Maximum Transfer Size. 
	if (dwTotalSize > dwMaxSize)
	{
		ASSERT(dwMaxSize);
		dwTotalSize = dwMaxSize;
	}

	// Allocate a new context structure for Irp completion
	USB_COMPLETION_INFO* pCompInfo = new (NonPagedPool) USB_COMPLETION_INFO;
	if (pCompInfo == NULL)
	{
		I.Information() = 0;
		return I.PnpComplete(this, STATUS_INSUFFICIENT_RESOURCES);
	}

// TODO:	Select the correct pipe to read from

	// Create an URB to do actual Bulk read from the pipe
	PURB pUrb = m_Endpoint2IN.BuildBulkTransfer(
			    	Mem,      		// Where is data coming from?
					dwTotalSize,  	// How much data to read?
					TRUE,         	// direction (TRUE = IN)
					NULL,			// Link to next URB
					TRUE			// Allow a short transfer
					);        		

	if (pUrb == NULL)
	{
		delete pCompInfo;
		I.Information() = 0;
		return I.PnpComplete(this, STATUS_INSUFFICIENT_RESOURCES);
	}

	// Initialize context structure
	pCompInfo->m_pClass = this;
	pCompInfo->m_pUrb = pUrb;

    // Submit the URB to our USB device
	NTSTATUS status;
	status = m_Endpoint2IN.SubmitUrb(I, pUrb, LinkTo(ReadComplete), pCompInfo, 0);
	return status;
}

////////////////////////////////////////////////////////////////////////
//  M8usbdrvDevice::ReadComplete
//
//	Routine Description:
//		Completion Handler for IRP_MJ_READ
//
//	Parameters:
//		I - IRP just completed by USB
//		pContext - Context structure containing pointer to Urb
//
//	Parameters:
//		NTSTATUS - STATUS_SUCCESS
//
//	Comments:
//		This routine is called when USBD completes the read request
//

NTSTATUS M8usbdrvDevice::ReadComplete(KIrp I, USB_COMPLETION_INFO* pContext)
{
	// Normal completion routine code to propagate pending flag

	if (I->PendingReturned) 
	{
		I.MarkPending();
	}
	
	NTSTATUS status = I.Status();
	PURB pUrb = pContext->m_pUrb;
	ULONG nBytesRead = 0;

	if ( NT_SUCCESS(status) ) 
	{
		nBytesRead = pUrb->UrbBulkOrInterruptTransfer.TransferBufferLength;
		if (nBytesRead > 0) 
			t << "Read() got " << nBytesRead<< " bytes from USB\n";
    }

	// Deallocate Urb and context structure
	delete pUrb;
	delete pContext;

	// set returned count
	I.Information() = nBytesRead;
	
	// Plug and Play accounting
	DecrementOutstandingRequestCount();

	// allow IRP completion processing
	return STATUS_SUCCESS;
}

////////////////////////////////////////////////////////////////////////
//  M8usbdrvDevice::Write
//
//	Routine Description:
//		Handler for IRP_MJ_WRITE
//
//	Parameters:
//		I - Current IRP
//
//	Return Value:
//		NTSTATUS - Result code
//
//	Comments:
//		This routine handles write requests.
//
//		The KPnpDevice class handles restricting IRP flow
//		if the device is stopping or being removed.
//

NTSTATUS M8usbdrvDevice::Write(KIrp I) 
{
	t << "Entering M8usbdrvDevice::Write, " << I << EOL;
// TODO:	Check the incoming request.  Replace "FALSE" in the following
//			line with a check that returns TRUE if the request is not valid.
    if (FALSE)
	{
		// Invalid parameter in the Write request
		I.Information() = 0;
		return I.PnpComplete(this, STATUS_INVALID_PARAMETER);
	}

	// Always ok to write 0 elements.
	if (I.WriteSize() == 0)
	{
		I.Information() = 0;
		return I.PnpComplete(this, STATUS_SUCCESS);
	}
	ULONG dwTotalSize = I.WriteSize(CURRENT);
	ULONG dwMaxSize = m_Endpoint2OUT.MaximumTransferSize();

	// If the total requested read size is greater than the Maximum Transfer
	// Size for the Pipe, request to read only the Maximum Transfer Size since
	// the bus driver will fail an URB with a TransferBufferLength of greater
	// than the Maximum Transfer Size. 
	if (dwTotalSize > dwMaxSize)
	{
		ASSERT(dwMaxSize);
		dwTotalSize = dwMaxSize;
	}

	// Declare a memory object
	KMemory Mem(I.Mdl());

	// Allocate a new context structure for Irp completion
	USB_COMPLETION_INFO* pCompInfo = new (NonPagedPool) USB_COMPLETION_INFO;
	if (pCompInfo == NULL)
	{
		I.Information() = 0;
		return I.PnpComplete(this, STATUS_INSUFFICIENT_RESOURCES);
	}

// TODO:	Select the correct pipe to write to

	// Create an URB to do actual Bulk write to the pipe
	PURB pUrb = m_Endpoint2OUT.BuildBulkTransfer(
					Mem,          // Where is data coming from?
					dwTotalSize,  // How much data to read?
					FALSE,        // direction (FALSE = OUT)
					NULL		  // Link to next URB
					);	        

	if (pUrb == NULL)
	{
		delete pCompInfo;
		I.Information() = 0;
		return I.PnpComplete(this, STATUS_INSUFFICIENT_RESOURCES);
	}

	// Initialize context structure
	pCompInfo->m_pClass = this;
	pCompInfo->m_pUrb = pUrb;

    // Submit the URB to our USB device
	NTSTATUS status;
	status = m_Endpoint2OUT.SubmitUrb(I, pUrb, LinkTo(WriteComplete), pCompInfo, 0);
	return status;
}

////////////////////////////////////////////////////////////////////////
//  M8usbdrvDevice::WriteComplete
//
//	Routine Description:
//		Completion Handler for IRP_MJ_WRITE
//
//	Parameters:
//		I - IRP just completed by USB
//		pContext - Context structure containing pointer to Urb
//
//	Return Value:
//		NTSTATUS	STATUS_SUCCESS
//
//	Comments:
//		This routine is called when USBD completes the write request
//

NTSTATUS M8usbdrvDevice::WriteComplete(KIrp I, USB_COMPLETION_INFO* pContext)
{
	// Normal completion routine code to propagate pending flag

	if (I->PendingReturned) 
	{
		I.MarkPending();
	}
	
	NTSTATUS status = I.Status();
	PURB pUrb = pContext->m_pUrb;
	ULONG nBytesWritten = 0;

	if ( NT_SUCCESS(status) ) 
	{
		nBytesWritten = pUrb->UrbBulkOrInterruptTransfer.TransferBufferLength;
		if (nBytesWritten > 0) 
			t << "Wrote " << nBytesWritten	<< " bytes to USB\n";
    }

	// Deallocate Urb and context structure
	delete pUrb;
	delete pContext;

	// set returned count
	I.Information() = nBytesWritten;
	
	// Plug and Play accounting
	DecrementOutstandingRequestCount();

	// allow IRP completion processing
	return STATUS_SUCCESS;
}

////////////////////////////////////////////////////////////////////////
//  M8usbdrvDevice::DeviceControl
//
//	Routine Description:
//		Handler for IRP_MJ_DEVICE_CONTROL
//
//	Parameters:
//		I - Current IRP
// 
//	Return Value:
//		None
//
//	Comments:
//		This routine is the first handler for Device Control requests.
//		The KPnpDevice class handles restricting IRP flow
//		if the device is stopping or being removed.
//

NTSTATUS M8usbdrvDevice::DeviceControl(KIrp I) 
{
	NTSTATUS status;

	t << "Entering M8usbdrvDevice::Device Control, " << I << EOL;
	switch (I.IoctlCode())
	{
		case TEST_LED:
			status = TEST_LED_Handler(I);
			break;

		default:
			// Unrecognized IOCTL request
			status = STATUS_INVALID_PARAMETER;
			break;
	}

	// If the IRP's IOCTL handler deferred processing using some driver
	// specific scheme, the status variable is set to STATUS_PENDING.
	// In this case we simply return that status, and the IRP will be
	// completed later.  Otherwise, complete the IRP using the status
	// returned by the IOCTL handler.
	if (status == STATUS_PENDING)
	{
		return status;
	}
	else
	{
		return I.PnpComplete(this, status);
	}
}

////////////////////////////////////////////////////////////////////////
//  M8usbdrvDevice::TEST_LED_Handler
//
//	Routine Description:
//		Handler for IO Control Code TEST_LED
//
//	Parameters:
//		I - IRP containing IOCTL request
//
//	Return Value:
//		NTSTATUS - Status code indicating success or failure
//
//	Comments:
//		This routine implements the TEST_LED function.
//		This routine runs at passive level.
//

NTSTATUS M8usbdrvDevice::TEST_LED_Handler(KIrp I)
{
	NTSTATUS status=STATUS_INVALID_PARAMETER;
	t << "Entering M8usbdrvDevice::TEST_LED_Handler, " << I << EOL;
	// TODO:	Verify that the input parameters are correct
	//			If not, return STATUS_INVALID_PARAMETER
	__try
	{
		
		if(I.IoctlOutputBufferSize() || !I.IoctlBuffer()|| (I.IoctlInputBufferSize() != sizeof(UCHAR)))
			__leave;
		
		// TODO:	Handle the the TEST_LED request, or 
		//			defer the processing of the IRP (i.e. by queuing) and set
		//			status to STATUS_PENDING.
		PURB pUrb = m_Lower.BuildVendorRequest
			(
			NULL,					// transfer buffer
			0,					// transfer buffer size
			0xc2,					// request reserved bits
			(UCHAR)(*(PUCHAR)I.IoctlBuffer()),	// request. 1 = LED_ON, 0 = LED_OFF
			0					// Value
			)
			;
		// transmit
		status = m_Lower.SubmitUrb(pUrb, NULL, NULL, 5000L);
	}
	__finally
	{
		
		// TODO:	Assuming that the request was handled here. Set I.Information
		//			to indicate how much data to copy back to the user.
		
		I.Information() = 0;
		I.Status() = status;
	}
	
	return status;
	
}


////////////////////////////////////////////////////////////////////////
// M8usbdrvDevice::OnQueryCapabilities
//
// Handler for IRP_MJ_PNP subfunction IRP_MN_QUERY_DEVICE_CAPABILITIES
//
// Input
//		I			Current IRP
//
//	Notes
//		This function is implemented to allow surprise removal of the
//		M8usbdrvDevice
//
NTSTATUS M8usbdrvDevice::OnQueryCapabilities(KIrp I)
{
	t << "Entering UsbThermometer::OnQueryCapabilities\n";
	
	I.CopyParametersDown();
	I.SetCompletionRoutine(LinkTo(OnQueryCapabilitiesComplete), this, TRUE, TRUE, TRUE);
	
	
	return m_Lower.PnpCall(this, I);
}


NTSTATUS M8usbdrvDevice::OnQueryCapabilitiesComplete(KIrp I)
{
	if (I->PendingReturned)
		I.MarkPending();
	
	I.DeviceCapabilities()->SurpriseRemovalOK = TRUE;
	
	return STATUS_SUCCESS;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一区二区三区四区视频| 欧美精品久久天天躁| 蜜臀国产一区二区三区在线播放| 一区二区三区在线免费| 成人免费视频在线观看| 一区二区三区四区不卡在线| 一区二区三区日韩在线观看| 亚洲福利国产精品| 日韩不卡在线观看日韩不卡视频| 日本麻豆一区二区三区视频| 久久电影国产免费久久电影| 九九九精品视频| 床上的激情91.| 色一情一伦一子一伦一区| 在线免费不卡电影| 在线综合亚洲欧美在线视频| 精品粉嫩aⅴ一区二区三区四区| 欧美精品一区二区精品网| 国产精品视频看| 亚洲线精品一区二区三区八戒| 五月天一区二区| 精品一区二区在线免费观看| 国产成人在线观看| 99国产精品久久| 日韩午夜电影av| 欧美国产视频在线| 亚洲一区av在线| 国产剧情在线观看一区二区| 成人av电影免费观看| 欧美日韩中字一区| 久久精品欧美日韩| 亚洲不卡av一区二区三区| 精一区二区三区| 色欧美88888久久久久久影院| 日韩一区二区三区免费看 | 在线免费亚洲电影| 欧美精品一级二级| 久久久久久99精品| 午夜久久福利影院| 99精品视频一区二区三区| 宅男在线国产精品| 亚洲免费伊人电影| 国产传媒一区在线| 4438x成人网最大色成网站| 国产精品久久久久影院色老大| 亚洲成年人影院| www.欧美.com| 26uuu国产一区二区三区| 亚洲成a人片在线不卡一二三区| 国产乱一区二区| 欧美一级欧美三级在线观看| 18成人在线视频| 国产成人免费网站| www成人在线观看| 久久精品国产亚洲a| 欧美精品v国产精品v日韩精品| 亚洲同性gay激情无套| 国产精品伊人色| 欧美xxx久久| 丝袜美腿一区二区三区| 欧美色区777第一页| 一区二区三区**美女毛片| 97精品视频在线观看自产线路二 | 成人性视频网站| 精品国产伦一区二区三区免费| 亚洲成人777| 欧美日韩一区二区三区视频| 一区二区理论电影在线观看| 在线精品视频免费播放| 亚洲欧美日韩久久精品| 91麻豆国产精品久久| 亚洲欧美另类图片小说| 色综合久久久久综合体桃花网| 成人免费一区二区三区视频 | 一本色道久久综合亚洲精品按摩| 欧美一级艳片视频免费观看| 亚洲国产精品尤物yw在线观看| 91官网在线观看| 亚洲高清免费一级二级三级| 欧美性猛交xxxx乱大交退制版| 亚洲在线视频一区| 欧美性受xxxx黑人xyx性爽| 亚洲午夜一区二区三区| 欧美视频一区二区在线观看| 爽好多水快深点欧美视频| 日韩三级av在线播放| 精品一区二区在线视频| 亚洲国产高清不卡| 91免费版在线看| 午夜精品福利一区二区蜜股av| 91精品久久久久久蜜臀| 久草热8精品视频在线观看| 欧美国产日韩在线观看| 一本大道久久a久久精二百| 午夜精品福利在线| 久久嫩草精品久久久精品| 92国产精品观看| 日韩精品一卡二卡三卡四卡无卡| 精品福利一区二区三区| 成人免费毛片高清视频| 亚洲va欧美va人人爽| www成人在线观看| 色婷婷一区二区| 精彩视频一区二区三区| 亚洲四区在线观看| 日韩视频永久免费| eeuss鲁片一区二区三区| 日韩高清不卡在线| 中文字幕永久在线不卡| 91精品国产综合久久香蕉的特点| 国产精品综合在线视频| 午夜欧美视频在线观看| 国产欧美一区二区三区网站| 在线播放中文字幕一区| 99国产欧美另类久久久精品| 精品一区二区三区在线播放 | 欧美日韩大陆一区二区| 国产美女精品一区二区三区| 一区二区三区四区在线播放 | 天天亚洲美女在线视频| 国产欧美日韩另类一区| 91麻豆精品国产91久久久久久| 成人网男人的天堂| 久久国产日韩欧美精品| 亚洲成人一区二区在线观看| 中文字幕日本不卡| 国产日本一区二区| 欧美成人video| 91麻豆精品国产自产在线 | 亚洲精品一卡二卡| 国产农村妇女毛片精品久久麻豆| 日韩欧美国产麻豆| 制服丝袜中文字幕一区| 在线观看国产日韩| 99久久免费精品高清特色大片| 国产激情一区二区三区| 老司机精品视频导航| 免费xxxx性欧美18vr| 日韩国产欧美一区二区三区| 亚洲成av人片一区二区梦乃| 亚洲美女电影在线| 亚洲视频在线一区二区| 国产亚洲视频系列| 久久久不卡网国产精品一区| 日韩美女视频在线| 精品av久久707| 精品日韩在线观看| 日韩精品一区二区三区在线播放 | 亚洲国产成人av网| 亚洲国产精品影院| 亚洲福利国产精品| 日日骚欧美日韩| 免费观看30秒视频久久| 日韩和欧美的一区| 男女视频一区二区| 韩国一区二区在线观看| 国产真实精品久久二三区| 精品在线你懂的| 国产成人无遮挡在线视频| 成人av片在线观看| 色综合久久中文字幕| 欧美日本乱大交xxxxx| 日韩三级中文字幕| 久久亚洲一区二区三区四区| 久久久电影一区二区三区| 中文字幕乱码久久午夜不卡| 综合亚洲深深色噜噜狠狠网站| 一区二区三区电影在线播| 亚洲成人高清在线| 国产一区高清在线| 91在线国产观看| 欧美另类一区二区三区| 久久网这里都是精品| 国产精品久久精品日日| 亚洲mv在线观看| 韩国欧美一区二区| 一本色道**综合亚洲精品蜜桃冫| 欧美精品v国产精品v日韩精品| 精品成人一区二区| 亚洲日本青草视频在线怡红院| 日本强好片久久久久久aaa| 风间由美一区二区av101| 欧美亚洲丝袜传媒另类| 亚洲精品一区二区三区影院| 亚洲图片另类小说| 精品一区二区综合| 在线日韩av片| 国产欧美日韩精品一区| 五月综合激情网| 99久久伊人精品| 日韩欧美色电影| 亚洲精品ww久久久久久p站| 久久av资源网| 欧美唯美清纯偷拍| 中文字幕免费一区| 精品一区二区三区久久久| 欧美综合欧美视频| 国产欧美日本一区视频| 日日夜夜精品视频免费| 色国产精品一区在线观看|