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

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

?? ezusbdevice.cpp

?? DriverStdio的一個USB驅動程序
?? CPP
?? 第 1 頁 / 共 4 頁
字號:
// EzUsbDevice.cpp - Implementation of EzUsbDevice device class
//=============================================================================
//
// Compuware Corporation
// NuMega Lab
// 9 Townsend West
// Nashua, NH 03060  USA
//
// Copyright (c) 1999 Compuware Corporation. All Rights Reserved.
// Unpublished - rights reserved under the Copyright laws of the
// United States.
//
//=============================================================================

#pragma warning(disable:4200)		  
#include <vdw.h>
#pragma warning (default:4710)

#include <kusb.h>
#include <KUsbBusIntf.h>

#include "EzUsbFirmware.h"
#include "EzUsbDeviceIoctl.h"
#include "EzUsbIsoTransfer.h"
#include "EzUsbIntTransfer.h"
#include "EzUsbDevice.h"

extern KDebugOnlyTrace t;				// Global driver trace object	

extern INTEL_HEX_RECORD loader[];		// Firmware for the EZUSB device
extern INTEL_HEX_RECORD EzUsbMonitor[]; // Firmware for the EZUSB device
extern INTEL_HEX_RECORD EzUsbMonitorFx2[]; // Firmware for the EZUSB-FX2 device

//=============================================================================
// EzUsbDevice Constructor
//
//		This is the constructor for the Functional Device Object, or FDO.
//		It is derived from KPnpDevice, which builds in automatic
//	    dispatching of subfunctions of IRP_MJ_POWER and IRP_MJ_PNP to
//		virtual member functions.
//
// Input
//		Pdo		Physical Device Object - this is a pointer to a system
//				device object that represents the physical device.
//
//		Unit	Unit number - this is a number to append to the device's
//				base device name to form the Logical Device Object's name
//
EzUsbDevice::EzUsbDevice(PDEVICE_OBJECT Pdo, ULONG Unit)
	:KPnpDevice(
		Pdo,
		KUnitizedName(L"Ezusb-", Unit), 
		FILE_DEVICE_UNKNOWN,
		KUnitizedName(L"Ezusb-", Unit),
		0,
		DO_DIRECT_IO | DO_POWER_PAGABLE
		),
	 m_pIsoDM(NULL),
	 m_LastFailedUrbStatus(0)
{
	t << "Entering EzUsbDevice (ctor)\n";

	// Check constructor status
    if( ! NT_SUCCESS(m_ConstructorStatus) )
	{
	    return;
	}

	// Remember our unit number
	m_Unit = Unit;

	// Initialize the lower device
	m_Lower.Initialize(this, Pdo);

	// Initialize the interface object
	m_UsbInterface.Initialize(m_Lower, 0, 1, 0); 

	// Initialize the pipe objects
	for( UCHAR i = 0; i < EZUSB_MAX_ENDPOINTS/2; i++ )
	{
		m_Endpoints[i].Initialize(m_Lower, static_cast<UCHAR>(i + 1));
		m_Endpoints[i + EZUSB_MAX_ENDPOINTS/2].Initialize(m_Lower,  static_cast<UCHAR>(i + 1 + 0x80));
	}

	//Most drivers would have KUsbPipe data members for each endpoint
	//and call the Initialize method for each member
	//m_Endpoint1_OUT.Initialize(m_Lower, 0x01); 
	//m_Endpoint2_IN .Initialize(m_Lower, 0x82); 
	//m_Endpoint2_OUT.Initialize(m_Lower, 0x02); 

	// Initialize the interrupt transfer object
	NTSTATUS Status = m_IntXfer.Initialize(
		&m_Lower,
		&m_Endpoints[EZUSB_MAX_ENDPOINTS/2 + 1]
		);

	ASSERT( STATUS_SUCCESS == Status );

	IntBuffLen = 4;
	pIntBuff = new (NonPagedPool) UCHAR[IntBuffLen];
	ASSERT( pIntBuff );

    // Inform the base class of the lower edge device object
	SetLowerDevice(&m_Lower);

	// Initialize the PnP Policy settings to the "standard" policy
	SetPnpPolicy();

	// Initialize the Power Policy settings to the "standard" policy
	SetPowerPolicy();

	// Adjust the power policy.  By default, the base class will power the
	// device down when the last file handle is closed.  For this 
	// development kit, this is not the desired behavior.  
    m_PowerPolicies.m_GeneralPolicy.m_PowerDnOnClose = FALSE; 

#if (_WDM_ && (WDM_MAJORVERSION > 1 ||((WDM_MAJORVERSION == 1) && (WDM_MINORVERSION >= 0x20))))
	Status = m_BusIntf.Initialize(m_Lower.TopOfStack());
	if (STATUS_SUCCESS == Status)
		m_fBusIntfAvailable = TRUE;
	else
		m_fBusIntfAvailable = FALSE;
#endif
}

//=============================================================================
// EzUsbDevice Destructor
//
//		This is the destructor for the Functional Device Object, or FDO.
//
EzUsbDevice::~EzUsbDevice()
{
	t << "Entering ~EzUsbDevice() (dtor)\n";

	delete pIntBuff;
}

//=============================================================================
// PNPMinorFunctionName
//
//		Return a string describing the Plug and Play minor function	
//
char *PNPMinorFunctionName(ULONG mn)
{
#ifdef 	DBG
	static char* minors[] = {
		"IRP_MN_START_DEVICE",
		"IRP_MN_QUERY_REMOVE_DEVICE",
		"IRP_MN_REMOVE_DEVICE",
		"IRP_MN_CANCEL_REMOVE_DEVICE",
		"IRP_MN_STOP_DEVICE",
		"IRP_MN_QUERY_STOP_DEVICE",
		"IRP_MN_CANCEL_STOP_DEVICE",
		"IRP_MN_QUERY_DEVICE_RELATIONS",
		"IRP_MN_QUERY_INTERFACE",
		"IRP_MN_QUERY_CAPABILITIES",
		"IRP_MN_QUERY_RESOURCES",
		"IRP_MN_QUERY_RESOURCE_REQUIREMENTS",
		"IRP_MN_QUERY_DEVICE_TEXT",
		"IRP_MN_FILTER_RESOURCE_REQUIREMENTS",
		"<unknown minor function>",
		"IRP_MN_READ_CONFIG",
		"IRP_MN_WRITE_CONFIG",
		"IRP_MN_EJECT",
		"IRP_MN_SET_LOCK",
		"IRP_MN_QUERY_ID",
		"IRP_MN_QUERY_PNP_DEVICE_STATE",
		"IRP_MN_QUERY_BUS_INFORMATION",
		"IRP_MN_DEVICE_USAGE_NOTIFICATION",
		"IRP_MN_SURPRISE_REMOVAL"
	};

	if (mn > IRP_MN_SURPRISE_REMOVAL) 
		return "<unknown minor function>";
	else
		return minors[mn];
#else
	return NULL;

	UNREFERENCED_PARAMETER(mn);
#endif
}

//=============================================================================
// EzUsbDevice::DefaultPnp - Default handler for IRP_MJ_PNP
//
//		This routine just passes the IRP through to the lower device. It is 
//		the default handler for IRP_MJ_PNP. IRPs that correspond to
//		any virtual members of KpnpDevice that handle minor functions of
//		IRP_MJ_PNP and that are not overridden get passed to this routine.
//
NTSTATUS EzUsbDevice::DefaultPnp(KIrp I) 
{
	t << "Entering DefaultPnp with IRP minor function="
	  << PNPMinorFunctionName(I.MinorFunction()) << "\n";

	I.ForceReuseOfCurrentStackLocationInCalldown();
	return m_Lower.PnpCall(this, I);
}

//=============================================================================
// EzUsbDevice::DefaultPower - Default handler for IRP_MJ_POWER 
//
//		This routine just passes the IRP through to the lower device. It is 
//		the default handler for IRP_MJ_POWER.
//
NTSTATUS EzUsbDevice::DefaultPower(KIrp I) 
{
	t << "Entering DefaultPower\n";

	I.IndicatePowerIrpProcessed();
	I.CopyParametersDown();
	return m_Lower.PnpPowerCall(this, I);
}

//=============================================================================
// EzUsbDevice::SystemControl - Handler for IRP_MJ_SYSTEM_CONTROL
//
//		This routine just passes the IRP through to the next device since 
//		this driver is not a WMI provider.
//
NTSTATUS EzUsbDevice::SystemControl(KIrp I) 
{
	I.ForceReuseOfCurrentStackLocationInCalldown();
	return m_Lower.PnpCall(this, I);
}

//=============================================================================
// EzUsbDevice::OnStartDevice - Handler for IRP_MJ_PNP / IRP_MN_START_DEVICE
//
//		This is the routine where the driver configures the USB device and
//		sets up its USB related data members.
//
//		The EZUSB device has one interface and numerous endpoints. Other USB 
//		devices likely have less endpoints, but it simply a matter of adding 
//		or removing data members to the device class in order to support more 
//		interfaces and model the USB device endpoints.
//
NTSTATUS EzUsbDevice::OnStartDevice(KIrp I)
{
	t << "Entering OnStartDevice\n";

	NTSTATUS status = STATUS_UNSUCCESSFUL;
	BOOLEAN bDownloadMonitor = FALSE;
	AC_STATUS acStatus = AC_SUCCESS;

	I.Information() = 0;

	// Since this driver supports all of the EZUSB family of chips, determine
	// the device and vendor ID of this device.  If its the default device,
	// change the alternate setting of the interface to 1 and download the 
	// 8051 debug monitor.
	USB_DEVICE_DESCRIPTOR desc;
	status = m_Lower.GetDeviceDescriptor( &desc );
	if ( !NT_SUCCESS(status) )
	{ 
		return status;
	}

	if(desc.idVendor == 0x0547 && desc.idProduct == 0x0080)
	{
		// default Anchor device, change the initial alternate setting to 1.
		m_UsbInterface.m_CurrentAlternateSetting = 1;
		bDownloadMonitor = TRUE;
	}

	if(desc.idVendor == 0x04B4 && desc.idProduct == 0x0081)
	{
		// default Anchor device, change the initial alternate setting to 1.
		m_UsbInterface.m_CurrentAlternateSetting = 1;
		bDownloadMonitor = TRUE;
	}

	// Activate Configuration value 1, the first configuration (index 0) of the device
	// described by the first configuration descriptor
	acStatus = m_Lower.ActivateConfiguration(1);

	switch (acStatus)
	{
		case AC_SUCCESS:
			t << "USB Configuration OK\n";

			if(TRUE	== bDownloadMonitor)
			{
				status = DownloadFirmware();
			}
			else
			{
				status = STATUS_SUCCESS;
			}

			//This is the Product ID for Walter Oney's sample device
			//for testing interrupt transfers
			if(desc.idVendor == 0x0547 && desc.idProduct == 0x102D)
			{
				//Start an interrupt transfer
				m_IntXfer.StartPolling(
					pIntBuff,
					IntBuffLen,
					OnInterrupt
					);
			}

			TestBusInterface();
			break;

		case AC_COULD_NOT_LOCATE_INTERFACE:
			t << "Could not locate interface\n";
			break;

		case AC_COULD_NOT_PRECONFIGURE_INTERFACE:
			t << "Could not get configuration descriptor\n";
			break;

		case AC_CONFIGURATION_REQUEST_FAILED:
			t << "Board did not accept configuration URB\n";
			break;

		case AC_FAILED_TO_INITIALIZE_INTERFACE_OBJECT:
			t << "Failed to initialize interface object\n";
			break;

		case AC_FAILED_TO_GET_DESCRIPTOR:
			t << "Failed to get device descriptor\n";
			break;

		case AC_FAILED_TO_OPEN_PIPE_OBJECT:
			//NOTE: this may or may not be fatal.  It could mean that
			//the device has an endpoint for which a KUsbPipe object has
			//not been instanced.  If the intention is to not use this pipe,
			//then it's ok.  Otherwise, there could be a failure.  Clients can
			//iterate through the pipe array to check which are open/closed
			//vs. what interface info says to figure out what is going on.
			status = STATUS_SUCCESS;
			t << "Failed to open pipe object \n";
			break;

		default:
			t << "Unexpected error activating USB configuration\n";
			break;
	}

   return status;  // base class completes the IRP
}


//=============================================================================
// EzUsbDevice::TestBusInterface
//
void EzUsbDevice::TestBusInterface()
{
#if (_WDM_ && (WDM_MAJORVERSION > 1 ||((WDM_MAJORVERSION == 1) && (WDM_MINORVERSION >= 0x20))))

	if (m_fBusIntfAvailable) {
		t << "USB Bus Interface Size: " << m_BusIntf.Size() << "\n";
		t << "USB Bus Interface Version: " << m_BusIntf.Version() << "\n";
		t << "High Speed Device: " << (m_BusIntf.IsDeviceHighSpeed()?"TRUE":"FALSE") << "\n";

		USBD_VERSION_INFORMATION UsbVerInfo;
		RtlZeroMemory(&UsbVerInfo, sizeof(USBD_VERSION_INFORMATION));
		ULONG HcdCapabilities = 0;

		m_BusIntf.GetUSBDIVersion(&UsbVerInfo, &HcdCapabilities);

		t << "USBDI_Version: " << UsbVerInfo.USBDI_Version << "\n";
		t << "Supported_USB_Version: " << UsbVerInfo.Supported_USB_Version << "\n";


		ULONG TotalBW, ConsumedBW;
		NTSTATUS Status = m_BusIntf.GetBandwidth(&TotalBW,&ConsumedBW);

		if (STATUS_SUCCESS == Status) {
			t << "Total Bandwidth: " << TotalBW << "\n";
			t << "Consumed Bandwidth: " << ConsumedBW << "\n";
		}

		PWSTR HcName = NULL;
		Status = m_BusIntf.GetControllerName(HcName);

		if (STATUS_SUCCESS == Status && HcName) {

			t << "HC Name: " << HcName << "\n";
			delete HcName;
		}

		ULONG CurrentFrame;
		m_BusIntf.QueryBusTime(&CurrentFrame);

		t << "Current Frame: " << CurrentFrame << "\n";
	}
#endif
}


//=============================================================================
// EzUsbDevice::OnQueryCapabilities
//
//		This function is implemented to allow surprise removal of EzUsb so
//		that the annoying dialog is not presented to the user.
//
NTSTATUS EzUsbDevice::OnQueryCapabilities(KIrp I)
{
	t << "Entering OnQueryCapabilitiesn";

	I.CopyParametersDown();
	I.SetCompletionRoutine(LinkTo(OnQueryCapabilitiesComplete), this, TRUE, TRUE, TRUE);

	return m_Lower.PnpCall(this, I);
}


NTSTATUS EzUsbDevice::OnQueryCapabilitiesComplete(KIrp I)
{
	if (I->PendingReturned)
		I.MarkPending();

	I.DeviceCapabilities()->SurpriseRemovalOK = TRUE;

	return STATUS_SUCCESS;
}

//=============================================================================
// EzUsbDevice::DownloadFirmware
//
//		This routine will download firmware to the default USB device -
//		VendorID = 0x0547 and DeviceID = 0x0080.  It is called from
//		EzUsbDevice::OnStartDevice
//
NTSTATUS EzUsbDevice::DownloadFirmware(void)
{
	t << "Entering DownloadFirmware\n";

	NTSTATUS status = STATUS_SUCCESS;

	Reset8051(1);

	status = DownloadIntelHex(loader);
	if( !NT_SUCCESS(status) )
		return status;

	Reset8051(0);

	if (IsFx2()) {
		status = DownloadIntelHex(EzUsbMonitor);
	} 
	else {
		status = DownloadIntelHex(EzUsbMonitorFx2);
	}

	if( !NT_SUCCESS(status) )
		return status;

	Reset8051(1);
	Reset8051(0);
	
	return status;
}

//=============================================================================
// EzUsbDevice::Reset8051

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩一区二区视频| 欧美aaaaaa午夜精品| 欧美电影免费观看高清完整版在| 91老司机福利 在线| 91麻豆精品在线观看| 色国产精品一区在线观看| 色婷婷亚洲一区二区三区| 91福利国产成人精品照片| 欧美午夜一区二区三区免费大片| 色婷婷av一区二区三区软件| 不卡大黄网站免费看| 中文字幕一区二区不卡| 亚洲欧美日韩一区二区三区在线观看| 欧美日韩成人在线| 欧美一区二区视频观看视频 | 肉丝袜脚交视频一区二区| 自拍偷拍欧美精品| 亚洲成人免费视| 久久99在线观看| 高潮精品一区videoshd| 99久久综合国产精品| 欧美午夜视频网站| 日韩一区二区免费电影| 国产欧美日韩精品一区| 亚洲一级不卡视频| fc2成人免费人成在线观看播放 | 亚洲国产精品一区二区www在线| 亚洲成在人线在线播放| 极品少妇一区二区三区精品视频| 成人午夜电影久久影院| 欧美喷水一区二区| 精品一区二区三区久久久| 国产成人亚洲综合色影视| 国产大陆a不卡| 欧美自拍偷拍午夜视频| 欧美哺乳videos| 亚洲欧洲综合另类| 人人超碰91尤物精品国产| 成人精品鲁一区一区二区| 在线91免费看| 久久嫩草精品久久久精品| 午夜精品在线视频一区| 国产99精品在线观看| 欧美肥大bbwbbw高潮| 久久一二三国产| 亚洲成av人综合在线观看| 国产又粗又猛又爽又黄91精品| 91在线观看视频| 久久久亚洲国产美女国产盗摄| 亚洲一区二区在线播放相泽| 国产精品理伦片| 欧美一卡2卡3卡4卡| 一区二区三区视频在线观看| 久久精品国产在热久久| 欧美在线一区二区三区| 欧美激情一区二区三区四区| 免费成人深夜小野草| 欧美综合亚洲图片综合区| 中文欧美字幕免费| 国产精品一二三四五| 精品国产不卡一区二区三区| 六月丁香综合在线视频| 欧美日韩成人综合在线一区二区| 亚洲美女少妇撒尿| 色哟哟日韩精品| 亚洲色图视频网站| 91蜜桃传媒精品久久久一区二区| 久久九九久久九九| 国产福利视频一区二区三区| 精品成人一区二区三区| 久久99国产精品成人| 日韩欧美久久一区| 黄一区二区三区| 久久一二三国产| 成人性色生活片免费看爆迷你毛片| 久久综合精品国产一区二区三区| 狠狠色狠狠色合久久伊人| 韩国女主播成人在线观看| 天天综合日日夜夜精品| av中文字幕亚洲| 国产精品视频一二| 99久久伊人网影院| 中文字幕一区二区三区精华液| 成人免费三级在线| 亚洲色图另类专区| 欧美少妇一区二区| 婷婷久久综合九色综合伊人色| 555www色欧美视频| 精品一区二区免费看| 欧美激情综合五月色丁香| 一本久久综合亚洲鲁鲁五月天| 亚洲精品国产a| 欧美一区二区在线免费观看| 久久国产福利国产秒拍| 日韩欧美电影一区| 激情综合色综合久久综合| 亚洲精品在线免费观看视频| 国产精品一区二区男女羞羞无遮挡 | 色婷婷综合视频在线观看| 亚洲精品午夜久久久| 91精品免费观看| 麻豆一区二区99久久久久| 久久久精品免费观看| 在线亚洲免费视频| 天堂在线亚洲视频| 中文天堂在线一区| 欧美三级蜜桃2在线观看| 国产自产视频一区二区三区| 亚洲欧洲一区二区在线播放| 91精品国产乱码久久蜜臀| 久久99精品国产麻豆不卡| 国产精品另类一区| 91精品国产一区二区三区| 成人美女视频在线观看18| 日本强好片久久久久久aaa| 欧美男人的天堂一二区| 国产精品一区二区在线观看不卡| 亚洲综合偷拍欧美一区色| 久久一区二区视频| 91.com在线观看| 色婷婷亚洲一区二区三区| 成人久久视频在线观看| 精品一区二区三区av| 亚洲线精品一区二区三区八戒| 久久亚洲捆绑美女| 欧美日韩精品一区二区三区四区| 国产宾馆实践打屁股91| 免费欧美在线视频| 五月天激情综合网| 亚洲色图丝袜美腿| 国产精品美女久久久久久久| 欧美精品一区二区三区很污很色的| 欧美三级三级三级| 一本色道久久综合亚洲精品按摩| 国产成人av自拍| 国产高清精品久久久久| 美女视频黄a大片欧美| 婷婷中文字幕综合| 麻豆国产91在线播放| 国产视频一区二区三区在线观看| 欧美日韩国产精品自在自线| 成人晚上爱看视频| 国产在线观看免费一区| 日av在线不卡| 男人的天堂亚洲一区| 亚洲国产成人av网| 亚洲第一主播视频| 亚洲成a人v欧美综合天堂下载| 国产精品伦理在线| 国产精品护士白丝一区av| 精品国产乱码久久久久久久久| 在线综合+亚洲+欧美中文字幕| 日本久久一区二区三区| 色婷婷av一区二区三区大白胸| 99在线精品免费| 97久久精品人人爽人人爽蜜臀| 色呦呦日韩精品| 91免费看`日韩一区二区| www.在线成人| 欧美午夜精品久久久久久超碰 | 国产视频一区二区三区在线观看| 精品视频资源站| 色哟哟精品一区| 欧美亚洲丝袜传媒另类| 欧美日韩视频在线第一区| 91精品欧美综合在线观看最新 | gogo大胆日本视频一区| 日本韩国欧美在线| 欧美三区免费完整视频在线观看| 欧美日韩美女一区二区| 日韩免费视频线观看| 久久午夜羞羞影院免费观看| 中文字幕av一区二区三区高| 亚洲人亚洲人成电影网站色| 亚洲日本一区二区| 亚洲国产成人av网| 狠狠色丁香久久婷婷综合_中 | 日韩免费看网站| 欧美一区二区三区免费视频| 色综合天天综合在线视频| 在线免费观看日韩欧美| 久久久午夜精品理论片中文字幕| 欧美国产日产图区| 亚洲伊人伊色伊影伊综合网| 日本一道高清亚洲日美韩| 久久精品国产精品亚洲精品| 国产精品一级片| 欧美撒尿777hd撒尿| 欧美tickling挠脚心丨vk| 国产精品素人一区二区| 亚洲精品中文字幕乱码三区| 久久精品国产精品亚洲综合| 色婷婷亚洲一区二区三区| 欧美成人官网二区| 亚洲欧洲精品成人久久奇米网| 日韩影院精彩在线| 99国产精品视频免费观看| 欧美精品一区二区三区蜜臀| 亚洲一级二级三级在线免费观看| 国产99久久久久久免费看农村|