欢迎来到天天文库
浏览记录
ID:47863747
大小:89.50 KB
页数:10页
时间:2019-07-10
《WinDriver教程》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、一、如何用windrive打开、关闭设备以及查看设备的信息1.所有有关的WD_API在安装后的相关目录下可以找到,建议打印出来,仔细看下。2.打开、关闭设备与查看相应信息:HANDLEm_hPex;DWORDBus,Slot,Fun,Interrupt;DWORDBaseAddrCS0,BaseAddrCS1,BaseAddrCS2,BaseAddrCS3;DWORDRangeAddrCS0,RangeAddrCS1,RangeAddrCS2,RangeAddrCS3;//打开设备:WD_LICENSElic;m_hPex=WD_Ope
2、n();if(m_hPex==INVALID_HANDLE_VALUE){ str="INVALID_HANDLE_VALUE";}else{ //重新注册wd,去除过期限制 strcpy(lic.cLicense,"你的注册号"); WD_License(m_hPex,&lic);}//检查WD版本WD_VERSIONver;BZERO(ver);WD_Version(m_hPex,&ver);if(ver.dwVer3、n; WD_PCI_SLOTpciSlot;BZERO(pciScan);//以PEX8311为例pciScan.searchId.dwVendorId=0x10b5;pciScan.searchId.dwDeviceId=0x86e1;WD_PciScanCards(m_hPex,&pciScan);if(pciScan.dwCards>0){ pciSlot=pciScan.cardSlot[0]; WD_PCI_CARD_INFOpciCardInfo; WD_CARDCard; BZERO(pciCardInf4、o); pciCardInfo.pciSlot=pciSlot; WD_PciGetCardInfo(m_hPex,&pciCardInfo); if(pciCardInfo.Card.dwItems!=0) { Card=pciCardInfo.Card; } else { str="Pcicard=0"; } WD_CARD_REGISTERcardReg; //Card.Item[0]PC机基本端口操作 //Card.Item[1]中断信息 BZERO(cardReg); 5、cardReg.Card=Card; cardReg.fCheckLockOnly=FALSE; WD_CardRegister(m_hPex,&cardReg); if(cardReg.hCard==0) { str="cardReg=0"; } str="opensuccessfully"; //取得当前设备信息并显示 Interrupt=Card.Item[1].I.Int.dwInterrupt); Bus=pciScan.cardSlot[0].dwBus; Slot=pciScan.c6、ardSlot[0].dwSlot; Fun=pciScan.cardSlot[0].dwFunction; //CS0-CS3的地址映射信息 BaseAddrCS0=Card.Item[2].I.Mem.dwPhysicalAddr; RangeAddrCS0=Card.Item[2].I.Mem.dwBytes; BaseAddrCS1=Card.Item[3].I.IO.dwAddr; RangeAddrCS1=Card.Item[3].I.Mem.dwBytes; BaseAddrCS2=Card7、.Item[4].I.Mem.dwPhysicalAddr; RangeAddrCS2=Card.Item[4].I.Mem.dwBytes; BaseAddrCS3=Card.Item[5].I.Mem.dwPhysicalAddr; RangeAddrCS3=Card.Item[5].I.Mem.dwBytes;else{ str="OpenFailed"; WD_Close(m_hPex);}AfxMessageBox(str); 注:Card.Item[0-5]就是DEVICE/IO/MEM映射的地方,这8、里得到的值和windrivewizard里看到的是一样的。二、设备的读写操作1.写操作 WD_TRANSFERtrans; BZERO(trans); trans.cmdTrans=WP_BYT
3、n; WD_PCI_SLOTpciSlot;BZERO(pciScan);//以PEX8311为例pciScan.searchId.dwVendorId=0x10b5;pciScan.searchId.dwDeviceId=0x86e1;WD_PciScanCards(m_hPex,&pciScan);if(pciScan.dwCards>0){ pciSlot=pciScan.cardSlot[0]; WD_PCI_CARD_INFOpciCardInfo; WD_CARDCard; BZERO(pciCardInf
4、o); pciCardInfo.pciSlot=pciSlot; WD_PciGetCardInfo(m_hPex,&pciCardInfo); if(pciCardInfo.Card.dwItems!=0) { Card=pciCardInfo.Card; } else { str="Pcicard=0"; } WD_CARD_REGISTERcardReg; //Card.Item[0]PC机基本端口操作 //Card.Item[1]中断信息 BZERO(cardReg);
5、cardReg.Card=Card; cardReg.fCheckLockOnly=FALSE; WD_CardRegister(m_hPex,&cardReg); if(cardReg.hCard==0) { str="cardReg=0"; } str="opensuccessfully"; //取得当前设备信息并显示 Interrupt=Card.Item[1].I.Int.dwInterrupt); Bus=pciScan.cardSlot[0].dwBus; Slot=pciScan.c
6、ardSlot[0].dwSlot; Fun=pciScan.cardSlot[0].dwFunction; //CS0-CS3的地址映射信息 BaseAddrCS0=Card.Item[2].I.Mem.dwPhysicalAddr; RangeAddrCS0=Card.Item[2].I.Mem.dwBytes; BaseAddrCS1=Card.Item[3].I.IO.dwAddr; RangeAddrCS1=Card.Item[3].I.Mem.dwBytes; BaseAddrCS2=Card
7、.Item[4].I.Mem.dwPhysicalAddr; RangeAddrCS2=Card.Item[4].I.Mem.dwBytes; BaseAddrCS3=Card.Item[5].I.Mem.dwPhysicalAddr; RangeAddrCS3=Card.Item[5].I.Mem.dwBytes;else{ str="OpenFailed"; WD_Close(m_hPex);}AfxMessageBox(str); 注:Card.Item[0-5]就是DEVICE/IO/MEM映射的地方,这
8、里得到的值和windrivewizard里看到的是一样的。二、设备的读写操作1.写操作 WD_TRANSFERtrans; BZERO(trans); trans.cmdTrans=WP_BYT
此文档下载收益归作者所有