* LICENSE: GPL - See COPYING in the top level directory
* FILE: ntoskrnl/ke/i386/irq.c
* PURPOSE: Manages the Kernel's IRQ support for external drivers,
- * for the purpopses of connecting, disconnecting and setting
+ * for the purposes of connecting, disconnecting and setting
* up ISRs for drivers. The backend behind the Io* Interrupt
* routines.
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
/* PRIVATE FUNCTIONS *********************************************************/
-BOOLEAN
-NTAPI
-KeDisableInterrupts(VOID)
-{
- ULONG Flags = 0;
- BOOLEAN Return;
-
- /* Get EFLAGS and check if the interrupt bit is set */
- Ke386SaveFlags(Flags);
- Return = (Flags & EFLAGS_INTERRUPT_MASK) ? TRUE: FALSE;
-
- /* Disable interrupts */
- _disable();
- return Return;
-}
-
VOID
NTAPI
KiGetVectorDispatch(IN ULONG Vector,
{
PKINTERRUPT_ROUTINE Handler;
ULONG Current;
+ UCHAR Type;
+ UCHAR Entry;
+
+ /* Check if this is a primary or 2nd-level dispatch */
+ Type = HalSystemVectorDispatchEntry(Vector,
+ &Dispatch->FlatDispatch,
+ &Dispatch->NoDispatch);
+ ASSERT(Type == 0);
+
+ /* Get the IDT entry for this vector */
+ Entry = HalVectorToIDTEntry(Vector);
/* Setup the unhandled dispatch */
Dispatch->NoDispatch = (PVOID)(((ULONG_PTR)&KiStartUnexpectedRange) +
- (Vector - PRIMARY_VECTOR_BASE) *
+ (Entry - PRIMARY_VECTOR_BASE) *
KiUnexpectedEntrySize);
/* Setup the handlers */
Dispatch->FlatDispatch = NULL;
/* Get the current handler */
- Current = ((((PKIPCR)KeGetPcr())->IDT[Vector].ExtendedOffset << 16)
+ Current = ((((PKIPCR)KeGetPcr())->IDT[Entry].ExtendedOffset << 16)
& 0xFFFF0000) |
- (((PKIPCR)KeGetPcr())->IDT[Vector].Offset & 0xFFFF);
+ (((PKIPCR)KeGetPcr())->IDT[Entry].Offset & 0xFFFF);
/* Set the interrupt */
Dispatch->Interrupt = CONTAINING_RECORD(Current,
DISPATCH_INFO Dispatch;
PKINTERRUPT_ROUTINE Handler;
PULONG Patch = &Interrupt->DispatchCode[0];
+ UCHAR Entry;
/* Get vector data */
KiGetVectorDispatch(Interrupt->Vector, &Dispatch);
Handler = (PVOID)&Interrupt->DispatchCode;
}
+ /* Get the IDT entry for this vector */
+ Entry = HalVectorToIDTEntry(Interrupt->Vector);
+
/* Set the pointer in the IDT */
- ((PKIPCR)KeGetPcr())->IDT[Interrupt->Vector].ExtendedOffset =
+ ((PKIPCR)KeGetPcr())->IDT[Entry].ExtendedOffset =
(USHORT)(((ULONG_PTR)Handler >> 16) & 0xFFFF);
- ((PKIPCR)KeGetPcr())->IDT[Interrupt->Vector].Offset =
+ ((PKIPCR)KeGetPcr())->IDT[Entry].Offset =
(USHORT)PtrToUlong(Handler);
}
Interrupt->ShareVector = ShareVector;
Interrupt->Number = ProcessorNumber;
Interrupt->FloatingSave = FloatingSave;
- Interrupt->TickCount = (ULONG)-1;
- Interrupt->DispatchCount = (ULONG)-1;
+ Interrupt->TickCount = MAXULONG;
+ Interrupt->DispatchCount = MAXULONG;
/* Loop the template in memory */
for (i = 0; i < KINTERRUPT_DISPATCH_CODES; i++)
(Dispatch.Interrupt->Mode == Interrupt->Mode))
{
/* The vector is shared and the interrupts are compatible */
- ASSERT(FALSE); // FIXME: NOT YET SUPPORTED/TESTED
Interrupt->Connected = Connected = TRUE;
- ASSERT(Irql <= SYNCH_LEVEL);
+
+ /* FIXME */
+ // ASSERT(Irql <= SYNCH_LEVEL);
/* Check if this is the first chain */
if (Dispatch.Type != ChainConnect)
{
+ /* This is not supported */
+ ASSERT(Dispatch.Interrupt->Mode != Latched);
+
/* Setup the chainned handler */
KiConnectVectorToInterrupt(Dispatch.Interrupt, ChainConnect);
}