/** * ISR handler. * * @return BOOLEAN Indicates whether the IRQ came from us (TRUE) or not (FALSE). * @param pInterrupt Interrupt that was triggered. * @param pServiceContext Context specific pointer. */ BOOLEAN vboxguestwinIsrHandler(PKINTERRUPT pInterrupt, PVOID pServiceContext) { PVBOXGUESTDEVEXT pDevExt = (PVBOXGUESTDEVEXT)pServiceContext; if (pDevExt == NULL) return FALSE; /*Log(("VBoxGuest::vboxguestwinGuestIsrHandler: pDevExt = 0x%p, pVMMDevMemory = 0x%p\n", pDevExt, pDevExt ? pDevExt->pVMMDevMemory : NULL));*/ /* Enter the common ISR routine and do the actual work. */ BOOLEAN fIRQTaken = VBoxGuestCommonISR(pDevExt); /* If we need to wake up some events we do that in a DPC to make * sure we're called at the right IRQL. */ if (fIRQTaken) { Log(("VBoxGuest::vboxguestwinGuestIsrHandler: IRQ was taken! pInterrupt = 0x%p, pDevExt = 0x%p\n", pInterrupt, pDevExt)); if (ASMAtomicUoReadU32(&pDevExt->u32MousePosChangedSeq) || !RTListIsEmpty(&pDevExt->WakeUpList)) { Log(("VBoxGuest::vboxguestwinGuestIsrHandler: Requesting DPC ...\n")); IoRequestDpc(pDevExt->win.s.pDeviceObject, pDevExt->win.s.pCurrentIrp, NULL); } } return fIRQTaken; }
HRESULT vboxDispCmSessionTerm(PVBOXDISPCM_SESSION pSession) { #ifdef DEBUG_misha Assert(RTListIsEmpty(&pSession->CtxList)); #endif BOOL bRc = CloseHandle(pSession->hEvent); Assert(bRc); if (bRc) { DeleteCriticalSection(&pSession->CritSect); return S_OK; } DWORD winEr = GetLastError(); HRESULT hr = HRESULT_FROM_WIN32(winEr); return hr; }
/** * Free a given statement AST node and put everything on the given to free list. * * @returns nothing. * @param pList The free list to append everything to. * @param pAstNode The statement node to free. */ static void vdScriptAstNodeStatmentPutOnFreeList(PRTLISTANCHOR pList, PVDSCRIPTASTCORE pAstNode) { AssertMsgReturnVoid(pAstNode->enmClass == VDSCRIPTASTCLASS_STATEMENT, ("Given AST node is not a statement\n")); PVDSCRIPTASTSTMT pStmt = (PVDSCRIPTASTSTMT)pAstNode; switch (pStmt->enmStmtType) { case VDSCRIPTSTMTTYPE_COMPOUND: { /* Put all declarations on the to free list. */ while (!RTListIsEmpty(&pStmt->Compound.ListDecls)) { PVDSCRIPTASTCORE pNode = RTListGetFirst(&pStmt->Compound.ListDecls, VDSCRIPTASTCORE, ListNode); RTListNodeRemove(&pNode->ListNode); RTListAppend(pList, &pNode->ListNode); } /* Put all statements on the to free list. */ while (!RTListIsEmpty(&pStmt->Compound.ListStmts)) { PVDSCRIPTASTCORE pNode = RTListGetFirst(&pStmt->Compound.ListDecls, VDSCRIPTASTCORE, ListNode); RTListNodeRemove(&pNode->ListNode); RTListAppend(pList, &pNode->ListNode); } break; } case VDSCRIPTSTMTTYPE_EXPRESSION: { RTListAppend(pList, &pStmt->pExpr->Core.ListNode); break; } case VDSCRIPTSTMTTYPE_IF: { RTListAppend(pList, &pStmt->If.pCond->Core.ListNode); RTListAppend(pList, &pStmt->If.pTrueStmt->Core.ListNode); if (pStmt->If.pElseStmt) RTListAppend(pList, &pStmt->If.pElseStmt->Core.ListNode); break; } case VDSCRIPTSTMTTYPE_SWITCH: { RTListAppend(pList, &pStmt->Switch.pCond->Core.ListNode); RTListAppend(pList, &pStmt->Switch.pStmt->Core.ListNode); break; } case VDSCRIPTSTMTTYPE_WHILE: { RTListAppend(pList, &pStmt->While.pCond->Core.ListNode); RTListAppend(pList, &pStmt->While.pStmt->Core.ListNode); break; } case VDSCRIPTSTMTTYPE_FOR: { RTListAppend(pList, &pStmt->For.pExprStart->Core.ListNode); RTListAppend(pList, &pStmt->For.pExprCond->Core.ListNode); RTListAppend(pList, &pStmt->For.pExpr3->Core.ListNode); RTListAppend(pList, &pStmt->For.pStmt->Core.ListNode); break; } case VDSCRIPTSTMTTYPE_RETURN: { if (pStmt->pExpr) RTListAppend(pList, &pStmt->pExpr->Core.ListNode); break; } case VDSCRIPTSTMTTYPE_CASE: { RTListAppend(pList, &pStmt->Case.pExpr->Core.ListNode); RTListAppend(pList, &pStmt->Case.pStmt->Core.ListNode); break; } case VDSCRIPTSTMTTYPE_DEFAULT: { RTListAppend(pList, &pStmt->Case.pStmt->Core.ListNode); break; } case VDSCRIPTSTMTTYPE_CONTINUE: case VDSCRIPTSTMTTYPE_BREAK: break; case VDSCRIPTSTMTTYPE_INVALID: default: AssertMsgFailedReturnVoid(("Invalid AST node statement type %d\n", pStmt->enmStmtType)); } }
DECLHIDDEN(void) vdScriptAstNodeFree(PVDSCRIPTASTCORE pAstNode) { RTLISTANCHOR ListFree; /* * The node is not allowed to be part of a list because we need it * for the nodes to free list. */ Assert(RTListIsEmpty(&pAstNode->ListNode)); RTListInit(&ListFree); RTListAppend(&ListFree, &pAstNode->ListNode); do { pAstNode = RTListGetFirst(&ListFree, VDSCRIPTASTCORE, ListNode); RTListNodeRemove(&pAstNode->ListNode); switch (pAstNode->enmClass) { case VDSCRIPTASTCLASS_FUNCTION: { PVDSCRIPTASTFN pFn = (PVDSCRIPTASTFN)pAstNode; if (pFn->pRetType) RTListAppend(&ListFree, &pFn->pRetType->Core.ListNode); if (pFn->pFnIde) RTListAppend(&ListFree, &pFn->pFnIde->Core.ListNode); /* Put argument list on the to free list. */ while (!RTListIsEmpty(&pFn->ListArgs)) { PVDSCRIPTASTCORE pArg = RTListGetFirst(&pFn->ListArgs, VDSCRIPTASTCORE, ListNode); RTListNodeRemove(&pArg->ListNode); RTListAppend(&ListFree, &pArg->ListNode); } /* Put compound statement onto the list. */ RTListAppend(&ListFree, &pFn->pCompoundStmts->Core.ListNode); break; } case VDSCRIPTASTCLASS_FUNCTIONARG: { PVDSCRIPTASTFNARG pAstNodeArg = (PVDSCRIPTASTFNARG)pAstNode; if (pAstNodeArg->pType) RTListAppend(&ListFree, &pAstNodeArg->pType->Core.ListNode); if (pAstNodeArg->pArgIde) RTListAppend(&ListFree, &pAstNodeArg->pArgIde->Core.ListNode); break; } case VDSCRIPTASTCLASS_IDENTIFIER: break; case VDSCRIPTASTCLASS_DECLARATION: break; case VDSCRIPTASTCLASS_STATEMENT: { vdScriptAstNodeStatmentPutOnFreeList(&ListFree, pAstNode); break; } case VDSCRIPTASTCLASS_EXPRESSION: { vdScriptAStNodeExpressionPutOnFreeList(&ListFree, pAstNode); break; } case VDSCRIPTASTCLASS_INVALID: default: AssertMsgFailedReturnVoid(("Invalid AST node class given %d\n", pAstNode->enmClass)); } RTMemFree(pAstNode); } while (!RTListIsEmpty(&ListFree)); }