阅读:926回复:2
初编的驱动,为什么一访问硬件,就马上重启
void PCIS5920Device::SerialRead(KIrp I)
{ NTSTATUS status = STATUS_SUCCESS; // Declare a memory object KMemory Mem(I.Mdl()); PUCHAR pBuffer = (PUCHAR)Mem.MapToSystemSpace(); // Requested read size ULONG dwTotalSize = I.ReadSize(CURRENT); ULONG dwBytesRead = 0;// Count of bytes read char buff; buff=m_MemoryRange0.inb(0X60);//读s5920的一个配置寄存器 strcpy((char *)pBuffer,&buff); dwBytesRead=strlen(&buff); I.Information() = dwBytesRead; m_DriverManagedQueue.PnpNextIrp(I); } 其中m_MemoryRange0的定义为 KMemoryRange m_MemoryRange0; 初始化为: status = m_MemoryRange0.Initialize( pResListTranslated, pResListRaw, PciConfig.BaseAddressIndexToOrdinal(0) ); 这是测试程序test中的函数: void doRead(int n) { char *buf; ULONG nRead; int i; // int j; buf = (char *) malloc(n); if (buf == NULL) { printf("Failed to allocate buffer for read"); Exit(1); } // Read data from driver printf("Reading from device - "); ReadFile(hDevice, buf, n, &nRead, NULL); printf("%c, ",buf[0]); free(buf); } 可是每次用测试程序(test)一访问,test r 1,马上重启,小弟才开始学习驱动,实在不知道是什么原因555555.....,请各位大侠帮助呀! |
|
沙发#
发布于:2004-04-07 08:33
配置或硬件有问题! :P
|
|
板凳#
发布于:2004-04-07 09:10
在PCIS5920Device::SerialRead(KIrp I)
下断点,看看是哪一步出的问题. |
|
|