|
引用 4 楼 xqhrs232 的回复:
加个判断好了,是野指针就打消息到串口
怎么判断?
- //=========================================================================
- //串口初始化
- VOID
- SL_Initq(
- PVOID pHead, // @parm points to device head
- PUCHAR pRegBase, // Pointer to 16550 register base
- UINT8 RegStride, // Stride amongst the 16550 registers
- EVENT_FUNC EventCallback, // This callback exists in MDD
- PVOID pMddHead, // This is the first parm to callback
- PLOOKUP_TBL pBaudTable // BaudRate Table
- )
- {
- PSER16550_INFO pHWHead = (PSER16550_INFO)pHead;
- //pSerObj=(PHWOBJ)LocalAlloc( LPTR ,sizeof(HWOBJ) );
- //if ( !pSerObj )
- // return (NULL);
- //pHWHead=(PSER16550_INFO)LocalAlloc( LPTR ,sizeof(SER16550_INFO) );
- RETAILMSG(QYDEBUG,(TEXT("#include ser16550.h\r\n")));
- //if ( !pHWHead )
- // return (NULL);
-
- RETAILMSG(QYDEBUG,(TEXT("+SL_Initq@@@@gooogleman, 0x%X\r\n"), pHWHead));
- RETAILMSG(QYDEBUG,(TEXT("+SL_Initq, 0x%X\r\n"), pHead));
- RETAILMSG(1,(TEXT("pRegBase, 0x%X\r\n"), pRegBase));
- // Set up pointers to 16550 registers
- pHWHead->pData = pRegBase + (RegStride * RECEIVE_BUFFER_REGISTER);
- pHWHead->pIER = pRegBase + (RegStride * INTERRUPT_ENABLE_REGISTER);
- pHWHead->pIIR_FCR = pRegBase + (RegStride * INTERRUPT_IDENT_REGISTER);
- pHWHead->pLCR = pRegBase + (RegStride * LINE_CONTROL_REGISTER);
- pHWHead->pMCR = pRegBase + (RegStride * MODEM_CONTROL_REGISTER);
- pHWHead->pLSR = pRegBase + (RegStride * LINE_STATUS_REGISTER);
- pHWHead->pMSR = pRegBase + (RegStride * MODEM_STATUS_REGISTER);
- pHWHead->pScratch = pRegBase + (RegStride * SCRATCH_REGISTER);
-
- // if (!SerMapRegisterAddresses3())
- //RETAILMSG( ,(TEXT("+SL_Initq, 0x%X\r\n"), pHead));
-
- RETAILMSG(QYDEBUG,(TEXT("pHWHead->pIER = %X\r\n"),pHWHead->pIER ));
- RETAILMSG(QYDEBUG,(TEXT("pHWHead->pIIR_FCR = %X\r\n"),pHWHead->pIIR_FCR ));
- RETAILMSG(QYDEBUG,(TEXT("pHWHead->pLCR = %X\r\n"),pHWHead->pLCR ));
- RETAILMSG(QYDEBUG,(TEXT("pHWHead->pMCR = %X\r\n"),pHWHead->pMCR ));
- RETAILMSG(QYDEBUG,(TEXT("pHWHead->pLSR = %X\r\n"),pHWHead->pLSR ));
- RETAILMSG(QYDEBUG,(TEXT("pHWHead->pMSR = %X\r\n"), pHWHead->pMSR ));
- RETAILMSG(QYDEBUG,(TEXT("pHWHead->pIER = %X\r\n"),pHWHead->pScratch ));
-
- // Store info for callback function
- pHWHead->EventCallback = EventCallback;
- pHWHead->pMddHead = pMddHead;
- // Now set up remaining fields
- if ( pBaudTable != NULL ){
- pHWHead->pBaudTable = (LOOKUP_TBL *) pBaudTable;
- RETAILMSG(QYDEBUG,(TEXT("pBaudTable != NULL 0x%X\r\n")));
- }
- else
- pHWHead->pBaudTable = (LOOKUP_TBL *) &SER_BaudTable;
- pHWHead->FlushDone = CreateEvent(0, FALSE, FALSE, NULL);
- pHWHead->OpenCount = 0;
- //RETAILMSG(QYDEBUG,(TEXT("OpenCount 0x%X\r\n")));
- //OUTB(pHWHead, pIER, (UCHAR)2);
- //RETAILMSG(QYDEBUG,(TEXT("pIER= 0x%X\r\n"),INB(pHWHead,pIER)));
- RETAILMSG(QYDEBUG,(TEXT("Data Abort Test@@@@@@-before OUTB(pHWHead, pIER, 0x0f);\r\n")));
- OUTB(pHWHead, pIER, (UCHAR)0x0f);
- RETAILMSG(QYDEBUG,(TEXT("Data Abort Test@@@@@@\r\n")));
-
-
- // Don't allow any interrupts till PostInit.
- OUTB(pHWHead, pIER, (UCHAR)0);
- OUTB(pHWHead, pIER, (UCHAR)IER_NORMAL_INTS);
- RETAILMSG(QYDEBUG,(TEXT("pIER 0x%X\r\n"),INB(pHWHead, pIER)));
- OUTB(pHWHead, pMCR, 0x0b);
- RETAILMSG(QYDEBUG,(TEXT("pIER 0x%X\r\n"),INB(pHWHead, pIER)));
- InitializeCriticalSection(&(pHWHead->TransmitCritSec));
- InitializeCriticalSection(&(pHWHead->RegCritSec));
- // Clear any interrupts which may be pending. Normally only
- // happens if we were warm reset.
- ClearPendingIntsq( pHWHead );
- RETAILMSG(QYDEBUG,(TEXT("-SL_INITq, 0x%d\r\n"), pHWHead));
- }
复制代码 |
|