Index: pic.cmake =================================================================== --- hal/halx86/pic.cmake (revision 71160) +++ hal/halx86/pic.cmake (working copy) @@ -1,7 +1,8 @@ list(APPEND HAL_PIC_ASM_SOURCE generic/systimer.S - generic/trap.S) + generic/trap.S + up/pic.S) list(APPEND HAL_PIC_SOURCE generic/profil.c Index: up/pic.c =================================================================== --- hal/halx86/up/pic.c (revision 71160) +++ hal/halx86/up/pic.c (working copy) @@ -12,6 +12,11 @@ #define NDEBUG #include +VOID +NTAPI +HalpEndSoftwareInterrupt(IN KIRQL OldIrql, + IN PKTRAP_FRAME TrapFrame); + /* GLOBALS ********************************************************************/ #ifndef _MINIHAL_ @@ -673,7 +678,8 @@ if (PendingIrqlMask) { /* Check if pending IRQL affects hardware state */ - BitScanReverse(&PendingIrql, PendingIrqlMask); + NT_VERIFY(BitScanReverse(&PendingIrql, PendingIrqlMask) != 0); + ASSERT(PendingIrql > OldIrql); if (PendingIrql > DISPATCH_LEVEL) { /* Set new PIC mask */ @@ -732,15 +738,18 @@ KeGetPcr()->IRR &= ~(1 << Irql); } -VOID +PHAL_SW_INTERRUPT_HANDLER_2ND_ENTRY NTAPI -HalpEndSoftwareInterrupt(IN KIRQL OldIrql, - IN PKTRAP_FRAME TrapFrame) +HalpEndSoftwareInterrupt2(IN KIRQL OldIrql, + IN PKTRAP_FRAME TrapFrame) { ULONG PendingIrql, PendingIrqlMask, PendingIrqMask; PKPCR Pcr = KeGetPcr(); PIC_MASK Mask; + UNREFERENCED_PARAMETER(TrapFrame); + + ASSERT(!(__readeflags() & EFLAGS_INTERRUPT_MASK)); /* Set old IRQL */ Pcr->Irql = OldIrql; @@ -749,13 +758,14 @@ { /* Check for pending software interrupts and compare with current IRQL */ PendingIrqlMask = Pcr->IRR & FindHigherIrqlMask[OldIrql]; - if (!PendingIrqlMask) return; + if (!PendingIrqlMask) return NULL; /* Check for in-service delayed interrupt */ - if (Pcr->IrrActive & 0xFFFFFFF0) return; + if (Pcr->IrrActive & 0xFFFFFFF0) return NULL; /* Check if pending IRQL affects hardware state */ - BitScanReverse(&PendingIrql, PendingIrqlMask); + NT_VERIFY(BitScanReverse(&PendingIrql, PendingIrqlMask) != 0); + ASSERT(PendingIrql > OldIrql); if (PendingIrql > DISPATCH_LEVEL) { /* Set new PIC mask */ @@ -770,6 +780,7 @@ /* Handle delayed hardware interrupt */ SWInterruptHandlerTable[PendingIrql](); + ASSERT(!(__readeflags() & EFLAGS_INTERRUPT_MASK)); /* Handling complete */ Pcr->IrrActive ^= PendingIrqMask; @@ -777,10 +788,11 @@ else { /* No need to loop checking for hardware interrupts */ - SWInterruptHandlerTable2[PendingIrql](TrapFrame); - UNREACHABLE; + return SWInterruptHandlerTable2[PendingIrql]; } } + + return NULL; } /* EDGE INTERRUPT DISMISSAL FUNCTIONS *****************************************/ @@ -1083,7 +1095,7 @@ if (Pcr->IrrActive & 0xFFFFFFF0) return; /* Check if pending IRQL affects hardware state */ - BitScanReverse(&PendingIrql, PendingIrqlMask); + NT_VERIFY(BitScanReverse(&PendingIrql, PendingIrqlMask) != 0); /* Clear IRR bit */ Pcr->IRR ^= (1 << PendingIrql); @@ -1201,6 +1213,7 @@ PKPCR Pcr = KeGetPcr(); PIC_MASK Mask; + ASSERT(!(__readeflags() & EFLAGS_INTERRUPT_MASK)); /* Set old IRQL */ Pcr->Irql = OldIrql; @@ -1215,7 +1228,8 @@ while (TRUE) { /* Check if pending IRQL affects hardware state */ - BitScanReverse(&PendingIrql, PendingIrqlMask); + NT_VERIFY(BitScanReverse(&PendingIrql, PendingIrqlMask) != 0); + ASSERT(PendingIrql > OldIrql); if (PendingIrql > DISPATCH_LEVEL) { /* Set new PIC mask */ @@ -1233,6 +1247,7 @@ /* Handle delayed hardware interrupt */ SWInterruptHandlerTable[PendingIrql](); + ASSERT(!(__readeflags() & EFLAGS_INTERRUPT_MASK)); /* Handling complete */ Pcr->IrrActive ^= PendingIrqMask; @@ -1369,7 +1384,8 @@ if (PendingIrqlMask) { /* Check if pending IRQL affects hardware state */ - BitScanReverse(&PendingIrql, PendingIrqlMask); + NT_VERIFY(BitScanReverse(&PendingIrql, PendingIrqlMask) != 0); + ASSERT(PendingIrql > OldIrql); if (PendingIrql > DISPATCH_LEVEL) { /* Set new PIC mask */ Index: up/pic.S =================================================================== --- hal/halx86/up/pic.S (nonexistent) +++ hal/halx86/up/pic.S (working copy) @@ -0,0 +1,50 @@ +/* + * FILE: hal/halx86/up/pic.S + * COPYRIGHT: See COPYING in the top level directory + * PURPOSE: + * PROGRAMMER: Thomas Faber (thomas.faber@reactos.org) + */ + +/* INCLUDES ******************************************************************/ + +#include + +#include + +EXTERN _HalpEndSoftwareInterrupt2@8:PROC + +/* GLOBALS *******************************************************************/ + +.data +ASSUME CS:NOTHING, DS:NOTHING, ES:NOTHING, FS:NOTHING, GS:NOTHING + +/* FUNCTIONS *****************************************************************/ + +.code +PUBLIC _HalpEndSoftwareInterrupt@8 +.PROC _HalpEndSoftwareInterrupt@8 + FPO 0, 2, 0, 0, 0, FRAME_FPO + + /* Call the C function with the same arguments we got */ + push [esp+8] + push [esp+8] + call _HalpEndSoftwareInterrupt2@8 + + /* Check if we got a pointer back */ + test eax, eax + jnz CallIntHandler + + /* No? Just return */ + ret 8 + +CallIntHandler: + /* We got a pointer to call. Since it won't return, free up our stack + space, or we could end up with some nasty deep recursion */ +AreYouSureYouCanWriteHalCode: + mov ecx, [esp+8] +CauseThisWasPrettyBuggy: + add esp, 12 + jmp eax +.ENDP + +END Property changes on: up/pic.S ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property