|
刚练习写了个GPIO的驱动,用来从FPGA读数据到ARM,但在应用程序运行到ReadFile函数时提示运行失败,ReadFile未返回TRUE。串口打印信息如下:
GPIO Driver Open
GPIO Driver Read
Begin Map Address
Transfer data begin
Data Abort: Thread=83eee898 Proc=82026400 'device.exe'
AKY=00000005 PC=01b613f0(gpio.dll+0x000013f0) RA=01b613d8(gpio.dll+0x000013d8) BVA=060000d0 FSR=00000007
RaiseException: Thread=83eee898 Proc=82026400 'device.exe'
AKY=00000005 PC=03f7e064(coredll.dll+0x0001e064) RA=8020fcf4(NK.EXE+0x0000fcf4) BVA=00000001 FSR=00000001GPIO Driver Close
红色部分为Data Abort中断信息,查看了GPIO.map文件,对应上述地址发现错误发生在GIO_Read所在地址区域,又查看了一遍自己写的驱动代码,如下所示:
DWORD GIO_Read(DWORD hOpenContext,LPVOID pBuffer,DWORD Count)
{
LPDWORD pReadBuffer = NULL;
RETAILMSG(1,(TEXT("GPIO Driver Read\r\n")));
if(pBuffer == NULL || (Count <= 0))
{
RETAILMSG(1,(TEXT("GPIO Driver Read Failed\r\n")));
return 0;
}
RETAILMSG(1,(TEXT("Begin Map Address\r\n")));
//Map address
pReadBuffer = (LPDWORD)MapPtrToProcess(pBuffer,GetCallerProcess());
RETAILMSG(1,(TEXT("Transfer data begin\r\n")));
//Read From GPIO
*pReadBuffer = ((gpio_data)&(0x000000FF));
RETAILMSG(1,(TEXT("Transfer data end\r\n")));
return TRUE;
}
对照串口输出的打印信息,发现问题应该出在对pReadBuffer赋值时,请问这是因为什么?应该如何修改?写GPIO驱动时还需要注意些什么?小弟新手,请各位大哥不吝赐教。
注:
gpio_data是GPJDAT寄存器中对应的数据
定义如下:
#define gpio_data (*(volatile DWORD *)GPIO_GPJDAT)
PHYSICAL_ADDRESS GPJDAT = {0x560000d4,0};
GPIO_GPJDAT = (DWORD)MmMapIoSpace(GPJDAT,4,FALSE);
|
|