今天调试2440 串口驱动(把4.2BSP下的2440自带串口和扩展串口驱动),经过一番修改,终于弄成了0错误和0警告,但是郁闷的是在加载驱动的过程中会出现异常,导致加载驱动失败。加载注册表直接和串口MDD的com_init函数相关,该函数里面调用了一些中间层以及PDD层的函数。哈哈,现在看看异常信息。
这个郁闷的问题终于解决了,最后用驱动调试助手+串口打印信息轻松解决。是我在GetSerialObject使用指针不当,呜呜,以后怎么办?已经有两次使用指针造成这样的错误了。 使用博客园wince.he的驱动调试助手,激活卸载,相当方便。强烈推荐使用。
GetSerialObject0
GetUartSysIRQ!
INFO: Mapped UartIrq 0x1c to UartSysIntr 0x22.
Data Abort: Thread=9882f550 Proc=81d36340 'device.exe'
AKY=00000405 PC=01e24b74(ser2440.dll+0x00004b74) RA=01e24b5c(ser2440.dll+0x00004b5c) BVA=03f90d84 FSR=0000000f
RaiseException: Thread=9882f550 Proc=81d36340 'device.exe'
AKY=00000405 PC=03f8dfec(coredll.dll+0x0001dfec) RA=802135e8(NK.EXE+0x000135e8) BVA=00000001 FSR=00000001
就在GetSerialObject加了这么点代码就OK了
// Allocate space for the HWOBJ.
pSerObj=(PHWOBJ)LocalAlloc( LPTR ,sizeof(HWOBJ) );
if ( !pSerObj )
return (NULL);
——————————————————————————
GetSerialObject0
GetUartSysIRQ!
INFO: Mapped UartIrq 0x1c to UartSysIntr 0x23.
GetSerialObject DeviceArrayIndex=0 OK!!!!
SerInit - !!!
SerInit 1- !!!
Try to open Drivers\Active\46
SerInit - Devindex 0, IRQ 19, IOB 50000000, IOLen 2C
SerInit 3- !!!
+ Ser_InternalMapRegisterAddresses : HalTranslateBusAddress
SerInitxxx - !!!
SerInit 11111- !!!
SerInit4 - !!!
SerInit - IRQ 19 = SYSINTR 35
+SerSetOutputMode
-SerSetOutputMode
GetSerialObject1
GetUartSysIRQ!
INFO: Mapped UartIrq 0x17 to UartSysIntr 0x24.
SerInit - !!!
SerInit 1- !!!
Try to open Drivers\Active\47
SerInit - Devindex 1, IRQ 37, IOB 50004000, IOLen 2C
SerInit 3- !!!
+ Ser_InternalMapRegisterAddresses : HalTranslateBusAddress
SerInitxxx - !!!
SerInit 11111- !!!
SerInit4 - !!!
SerInit - IRQ 37 = SYSINTR 36
+SerSetOutputMode
-SerSetOutputMode
————————————————————————————————————————
有人说看驱动的map文件可以直接找出造成异常的函数,现在我来倒推验证一下。
把程序复原到能产生异常的状态。
---------uart0
GetSerialObject0
GetUartSysIRQ!
INFO: Mapped UartIrq 0x1c to UartSysIntr 0x1e.
Data Abort: Thread=98831000 Proc=81d36340 'device.exe'
AKY=00000405 PC=01e24b70(ser2440.dll+0x00004b70) RA=01e24b5c(ser2440.dll+0x00004b5c) BVA=06000008 FSR=00000007
RaiseException: Thread=98831000 Proc=81d36340 'device.exe'
AKY=00000405 PC=03f8dfec(coredll.dll+0x0001dfec) RA=802135e8(NK.EXE+0x000135e8) BVA=00000001 FSR=00000001
---------uart1
GetSerialObject1
GetUartSysIRQ!
INFO: Mapped UartIrq 0x17 to UartSysIntr 0x20.
Data Abort: Thread=98831000 Proc=81d36340 'device.exe'
AKY=00000405 PC=01e24c1c(ser2440.dll+0x00004c1c) RA=01e24b98(ser2440.dll+0x00004b98) BVA=06000000 FSR=00000007
RaiseException: Thread=98831000 Proc=81d36340 'device.exe'
AKY=00000405 PC=03f8dfec(coredll.dll+0x0001dfec) RA=802135e8(NK.EXE+0x000135e8) BVA=00000001 FSR=00000001
----------uart2
GetSerialObject2
GetUartSysIRQ!
INFO: Mapped UartIrq 0xf to UartSysIntr 0x21.
Data Abort: Thread=988310