EvaluateEventFlag (eventMask = 0x80) - device was closed
EvaluateEventFlag (eventMask = 0x40) - device was closed
EvaluateEventFlag (eventMask = 0x2) - device was closed
EvaluateEventFlag (eventMask = 0x80) - device was closed
EvaluateEventFlag (eventMask = 0x40) - device was closed
EvaluateEventFlag (eventMask = 0x2) - device was closed
不知道咋回事,汗。
EvaluateEventFlag 源码在这里,但是我都没有启动完系统,也没有应用去操作它啊。真晕。
/* ****************************************************************
*
* Win32 Comm Api Support follows.
*
* @doc EXTERNAL
*/
// ****************************************************************
//
// @func VOID | EvaluateEventFlag | Evaluate an event mask.
//
// @parm PHW_INDEP_INFO | pHWIHead | MDD context pointer
// @parm ULONG | fdwEventMask | Bitmask of events
//
// @rdesc No return
//
// @remark This function is called by the PDD (and internally in the MDD
// to evaluate a COMM event. If the user is waiting for a
// COMM event (see WaitCommEvent()) then it will signal the
// users thread.
//
VOID
EvaluateEventFlag(PVOID pHead, ULONG fdwEventMask)
{
PHW_INDEP_INFO pHWIHead = (PHW_INDEP_INFO)pHead;
PLIST_ENTRY pEntry;
PHW_OPEN_INFO pOpenHead;
DWORD dwTmpEvent, dwOrigEvent;
BOOL fRetCode;
if ( !pHWIHead->OpenCnt ) {
DEBUGMSG (ZONE_EVENTS|ZONE_ERROR,
(TEXT(" EvaluateEventFlag (eventMask = 0x%x) - device was closed\r\n"),fdwEventMask));
SetLastError (ERROR_INVALID_HANDLE);
return;
}
// Now that we support multiple opens, we must check mask for each open handle
// To keep this relatively painless, we keep a per-device mask which is the
// bitwise or of each current open mask. We can check this first before doing
// all the linked list work to figure out who to notify
if ( pHWIHead->fEventMask & fdwEventMask ) {
pEntry = pHWIHead->OpenList.Flink;
while ( pEntry != &pHWIHead->OpenList ) {
pOpenHead = CONTAINING_RECORD( pEntry, HW_OPEN_INFO, llist);
pEntry = pEntry->Flink; // advance to next
EnterCriticalSection(&(pOpenHead->CommEvents.EventCS));
// Don't do anything unless this event is of interest to the MDD.
if ( pOpenHead->CommEvents.fEventMask & fdwEventMask ) {
// Store the event data
dwOrigEvent = pOpenHead->CommEvents.fEventData;
do {
dwTmpEvent = dwOrigEvent;
dwOrigEvent = InterlockedExchange(&(pOpenHead->CommEvents.fEventData),
dwTmpEvent | fdwEventMask) ;
} while ( dwTmpEvent != dwOrigEvent );
// Signal the MDD that new event data is available.
fRetCode = SetEvent(pOpenHead->CommEvents.hCommEvent);
DEBUGMSG (ZONE_EVENTS, (TEXT(" CommEvent - Event 0x%X, Handle 0x%X Mask 0x%X (%X)\r\n"),
dwTmpEvent | fdwEventMask,
pOpenHead,
pOpenHead->CommEvents.fEventMask,
fRetCode));
而这个函数是被pdd层的
ULONG HWRxIntrHandler(
PVOID pContext,
PUCHAR pTargetBuffer,
PULONG pByteNumber
); // This function handles serial port interrupts.
函数所调用的, cserpdd.cpp中可以看到他的实现
ULONG
SerRxIntr(
PVOID pHead, // @parm Pointer to hardware head
PUCHAR pRxBuffer, // @parm Pointer to receive buffer
ULONG *pBufflen // @parm In = max bytes to read, out = bytes read