请教Windriver中WD_MultiTransfer使用方法(内有写好的程序)
[复制链接]
以下是自己编写的Windriver开发PCI驱动的程序,目前已经调通,但是dwResult结果不对,跟踪程序结果是00xc3f000e8,但与Windriver的自带程序读同一地址所得到的结果086300A2不同。请问问题出现在哪里? 我想认识开发Windriver的朋友们,我QQ号码:81967858, eMail:yanyan3fish@126.com,希望能和大家取得联系。
#include "stdafx.h"
#include
#include "include/wdc_defs.h"
#include "include/wdc_lib.h"
#include "include/utils.h"
#include "pcitest_lib.h"
#include "samples/shared/diag_lib.h"
#include "samples/shared/wdc_diag_lib.h"
#include "samples/shared/pci_regs.h"
#define PCITEST_DEFAULT_LICENSE_STRING "6C3CC2CFE89E7AD0425ECCB375D728D6B53BF05F.EMBRACE"
#define BZERO(buf) memset(&(buf), 0, sizeof(buf))
#define ACTIVE_ADDR_SPACE_NEEDS_INIT 0xFF
typedef struct {
PCITEST_INT_HANDLER funcDiagIntHandler;
PCITEST_EVENT_HANDLER funcDiagEventHandler;
} PCITEST_DEV_CTX, *PPCITEST_DEV_CTX;
int _tmain(int argc, _TCHAR* argv[])
{
DWORD dwStatusScan,dwStatusCardInfo,dwStatusRegister,dwStatusMultiTransfer;
HANDLE hWD;
hWD = WD_Open();
WD_VERSION ver;
BZERO(ver);
WD_Version(hWD, &ver);
WD_PCI_SCAN_CARDS pciScan;
WD_PCI_SLOT pciSlot;
BZERO(pciScan);
pciScan.searchId.dwVendorId = 0x10DE;
pciScan.searchId.dwDeviceId = 0x423;
dwStatusScan=WD_PciScanCards(hWD, &pciScan);
if (pciScan.dwCards>0) /* Found at least one device */
pciSlot = pciScan.cardSlot[0]; /* Use the first card found */
else
std::cout << "Hello world!\n";
WD_PCI_CARD_INFO pciCardInfo;
WD_CARD Card;
BZERO(pciCardInfo);
pciCardInfo.pciSlot = pciSlot;
dwStatusCardInfo=WD_PciGetCardInfo(hWD, &pciCardInfo);
if (pciCardInfo.Card.dwItems!=0) /* At least one item was found */
{
Card = pciCardInfo.Card;
printf("success fetching PCI card information\n");
}
else
{
printf("Failed fetching PCI card information\n");
}
WD_CARD_REGISTER cardReg;
BZERO(cardReg);
cardReg.Card=Card;
cardReg.Card.Item[0].item = ITEM_MEMORY;
dwStatusRegister=WD_CardRegister(hWD, &cardReg);
if (cardReg.hCard == 0)
{
printf("Failed locking device\n");
return FALSE;
}
WD_TRANSFER Trans;
DWORD dwResult;
BZERO(Trans);
Trans.cmdTrans = RM_DWORD; /* Read Port Dword */
Trans.dwPort = cardReg.Card.Item[0].I.Mem.dwTransAddr;
Trans.dwBytes=5;
Trans.fAutoinc=FALSE;
Trans.dwOptions=0;
dwStatusMultiTransfer = WD_MultiTransfer(hWD, &Trans,1);
dwResult = Trans.Data.Dword;
return 0;
}