mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 00:23:10 +00:00
- Write a basic Clock Interrupt handler in the HAL (doesn't deal with changing increments yet, just like current ROS). It will call KeUpdateSystemTime once ready.
- Implement KeDisconnectInterrupt with the new implementation. - Put Clock Interrupt initialization in the right place (might still be too late: must investigate more). - Added a debug print when unexpected interrupts are called, just noticed this happens on my checked machine, and it's a useful tracing tool. svn path=/trunk/; revision=23678
This commit is contained in:
parent
15899302f6
commit
8b82c0d641
6 changed files with 121 additions and 66 deletions
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
PVOID HalpZeroPageMapping = NULL;
|
PVOID HalpZeroPageMapping = NULL;
|
||||||
HALP_HOOKS HalpHooks;
|
HALP_HOOKS HalpHooks;
|
||||||
|
VOID NTAPI HalpClockInterrupt(VOID);
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
|
@ -31,6 +32,10 @@ DriverEntry(
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MAKEULONG(x, y) \
|
||||||
|
(((((ULONG)(x))<<16) & 0xffff0000) | \
|
||||||
|
((ULONG)(y) & 0xffff))
|
||||||
|
|
||||||
BOOLEAN STDCALL
|
BOOLEAN STDCALL
|
||||||
HalInitSystem (ULONG BootPhase,
|
HalInitSystem (ULONG BootPhase,
|
||||||
PLOADER_PARAMETER_BLOCK LoaderBlock)
|
PLOADER_PARAMETER_BLOCK LoaderBlock)
|
||||||
|
@ -42,6 +47,14 @@ HalInitSystem (ULONG BootPhase,
|
||||||
}
|
}
|
||||||
else if (BootPhase == 1)
|
else if (BootPhase == 1)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
|
/* Enable the clock interrupt */
|
||||||
|
((PKIPCR)KeGetPcr())->IDT[IRQ2VECTOR(0)].ExtendedOffset =
|
||||||
|
(USHORT)(((ULONG_PTR)HalpClockInterrupt >> 16) & 0xFFFF);
|
||||||
|
((PKIPCR)KeGetPcr())->IDT[IRQ2VECTOR(0)].Offset =
|
||||||
|
(USHORT)HalpClockInterrupt;
|
||||||
|
HalEnableSystemInterrupt(IRQ2VECTOR(0), CLOCK2_LEVEL, Latched);
|
||||||
|
#endif
|
||||||
/* Initialize display and make the screen black */
|
/* Initialize display and make the screen black */
|
||||||
HalInitializeDisplay ((PROS_LOADER_PARAMETER_BLOCK)LoaderBlock);
|
HalInitializeDisplay ((PROS_LOADER_PARAMETER_BLOCK)LoaderBlock);
|
||||||
HalpInitBusHandlers();
|
HalpInitBusHandlers();
|
||||||
|
|
|
@ -12,8 +12,7 @@
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
.extern _Kei386EoiHelper@0
|
.extern _Kei386EoiHelper@0
|
||||||
|
.extern _KeUpdateSystemTime@0
|
||||||
/* GLOBALS *******************************************************************/
|
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
@ -21,6 +20,31 @@
|
||||||
.func HalpClockInterrupt@0
|
.func HalpClockInterrupt@0
|
||||||
_HalpClockInterrupt@0:
|
_HalpClockInterrupt@0:
|
||||||
|
|
||||||
jmp $
|
/* Enter trap */
|
||||||
|
INT_PROLOG Hci, DoPushFakeErrorCode
|
||||||
|
|
||||||
|
/* Push vector and make stack for IRQL */
|
||||||
|
push 0x30
|
||||||
|
sub esp, 4
|
||||||
|
|
||||||
|
/* Begin the interrupt */
|
||||||
|
push esp
|
||||||
|
push 0x30
|
||||||
|
push CLOCK2_LEVEL
|
||||||
|
call _HalBeginSystemInterrupt@12
|
||||||
|
|
||||||
|
/* Check if it's spurious */
|
||||||
|
or al, al
|
||||||
|
jz Spurious
|
||||||
|
|
||||||
|
/* Do a tick */
|
||||||
|
//jmp _KeUpdateSystemTime@0
|
||||||
|
|
||||||
|
Spurious:
|
||||||
|
|
||||||
|
/* Exit the interrupt */
|
||||||
|
add esp, 8
|
||||||
|
mov esi, $
|
||||||
|
jmp _Kei386EoiHelper@0
|
||||||
.endfunc
|
.endfunc
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
VOID NTAPI HalpClockInterrupt(VOID);
|
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
|
@ -24,15 +22,6 @@ HalpInitPhase0(PROS_LOADER_PARAMETER_BLOCK LoaderBlock)
|
||||||
{
|
{
|
||||||
HalpInitPICs();
|
HalpInitPICs();
|
||||||
|
|
||||||
/* Enable the clock interrupt */
|
|
||||||
#if 0
|
|
||||||
((PKIPCR)KeGetPcr())->IDT[IRQ2VECTOR(0)].ExtendedOffset =
|
|
||||||
(USHORT)(((ULONG_PTR)HalpClockInterrupt >> 16) & 0xFFFF);
|
|
||||||
((PKIPCR)KeGetPcr())->IDT[IRQ2VECTOR(0)].Offset =
|
|
||||||
(USHORT)HalpClockInterrupt;
|
|
||||||
#endif
|
|
||||||
HalEnableSystemInterrupt(IRQ2VECTOR(0), CLOCK2_LEVEL, Latched);
|
|
||||||
|
|
||||||
/* Setup busy waiting */
|
/* Setup busy waiting */
|
||||||
HalpCalibrateStallExecution();
|
HalpCalibrateStallExecution();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ LARGE_INTEGER SystemBootTime = { 0 };
|
||||||
|
|
||||||
CHAR KiTimerSystemAuditing = 0;
|
CHAR KiTimerSystemAuditing = 0;
|
||||||
static KDPC KiExpireTimerDpc;
|
static KDPC KiExpireTimerDpc;
|
||||||
static BOOLEAN KiClockSetupComplete = FALSE;
|
BOOLEAN KiClockSetupComplete = FALSE;
|
||||||
|
|
||||||
extern ULONG KiMaximumDpcQueueDepth;
|
extern ULONG KiMaximumDpcQueueDepth;
|
||||||
extern ULONG KiMinimumDpcRate;
|
extern ULONG KiMinimumDpcRate;
|
||||||
|
|
|
@ -65,15 +65,10 @@ VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
KiChainedDispatch(VOID);
|
KiChainedDispatch(VOID);
|
||||||
|
|
||||||
|
/* DEPRECATED FUNCTIONS ******************************************************/
|
||||||
/* GLOBALS *****************************************************************/
|
|
||||||
|
|
||||||
void irq_handler_0(void);
|
void irq_handler_0(void);
|
||||||
|
|
||||||
extern IDT_DESCRIPTOR KiIdt[256];
|
extern IDT_DESCRIPTOR KiIdt[256];
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
|
||||||
|
|
||||||
#define PRESENT (0x8000)
|
#define PRESENT (0x8000)
|
||||||
#define I486_INTERRUPT_GATE (0xe00)
|
#define I486_INTERRUPT_GATE (0xe00)
|
||||||
|
|
||||||
|
@ -168,6 +163,8 @@ KiInterruptDispatch (ULONG vector, PKIRQ_TRAPFRAME Trapframe)
|
||||||
HalEndSystemInterrupt (old_level, 0);
|
HalEndSystemInterrupt (old_level, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* PRIVATE FUNCTIONS *********************************************************/
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
KiGetVectorDispatch(IN ULONG Vector,
|
KiGetVectorDispatch(IN ULONG Vector,
|
||||||
|
@ -275,6 +272,8 @@ KiConnectVectorToInterrupt(IN PKINTERRUPT Interrupt,
|
||||||
(USHORT)PtrToUlong(Handler);
|
(USHORT)PtrToUlong(Handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* PUBLIC FUNCTIONS **********************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -430,65 +429,84 @@ KeConnectInterrupt(IN PKINTERRUPT Interrupt)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*
|
|
||||||
* FUNCTION: Releases a drivers isr
|
|
||||||
* ARGUMENTS:
|
|
||||||
* InterruptObject = isr to release
|
|
||||||
*/
|
*/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
STDCALL
|
STDCALL
|
||||||
KeDisconnectInterrupt(PKINTERRUPT InterruptObject)
|
KeDisconnectInterrupt(PKINTERRUPT Interrupt)
|
||||||
{
|
{
|
||||||
#if 0
|
KIRQL OldIrql, Irql;
|
||||||
KIRQL oldlvl,synch_oldlvl;
|
ULONG Vector;
|
||||||
PISR_TABLE CurrentIsr;
|
DISPATCH_INFO Dispatch;
|
||||||
|
PKINTERRUPT NextInterrupt;
|
||||||
BOOLEAN State;
|
BOOLEAN State;
|
||||||
|
|
||||||
DPRINT1("KeDisconnectInterrupt\n");
|
|
||||||
ASSERT (InterruptObject->Number < KeNumberProcessors);
|
|
||||||
|
|
||||||
/* Set the affinity */
|
/* Set the affinity */
|
||||||
KeSetSystemAffinityThread(1 << InterruptObject->Number);
|
KeSetSystemAffinityThread(1 << Interrupt->Number);
|
||||||
|
|
||||||
/* Get the ISR Tabe */
|
/* Lock the dispatcher */
|
||||||
CurrentIsr = &IsrTable[InterruptObject->Vector - IRQ_BASE]
|
OldIrql = KeAcquireDispatcherDatabaseLock();
|
||||||
[(ULONG)InterruptObject->Number];
|
|
||||||
|
|
||||||
/* Raise IRQL to required level and lock table */
|
|
||||||
KeRaiseIrql(VECTOR2IRQL(InterruptObject->Vector),&oldlvl);
|
|
||||||
KiAcquireSpinLock(&CurrentIsr->Lock);
|
|
||||||
|
|
||||||
/* Check if it's actually connected */
|
/* Check if it's actually connected */
|
||||||
if ((State = InterruptObject->Connected))
|
State = Interrupt->Connected;
|
||||||
|
if (State)
|
||||||
{
|
{
|
||||||
/* Lock the Interrupt */
|
/* Get the vector and IRQL */
|
||||||
synch_oldlvl = KeAcquireInterruptSpinLock(InterruptObject);
|
Irql = Interrupt->Irql;
|
||||||
|
Vector = Interrupt->Vector;
|
||||||
|
|
||||||
/* Remove this one, and check if all are gone */
|
/* Get vector dispatch data */
|
||||||
RemoveEntryList(&InterruptObject->InterruptListEntry);
|
KiGetVectorDispatch(Vector, &Dispatch);
|
||||||
if (IsListEmpty(&CurrentIsr->ListHead))
|
|
||||||
|
/* Check if it was chained */
|
||||||
|
if (Dispatch.Type == ChainConnect)
|
||||||
{
|
{
|
||||||
/* Completely Disable the Interrupt */
|
/* Check if the top-level interrupt is being removed */
|
||||||
HalDisableSystemInterrupt(InterruptObject->Vector, InterruptObject->Irql);
|
ASSERT(Irql <= SYNCH_LEVEL);
|
||||||
}
|
if (Interrupt == Dispatch.Interrupt)
|
||||||
|
{
|
||||||
/* Disconnect it */
|
/* Get the next one */
|
||||||
InterruptObject->Connected = FALSE;
|
Dispatch.Interrupt = CONTAINING_RECORD(Dispatch.Interrupt->
|
||||||
|
InterruptListEntry.Flink,
|
||||||
/* Release the interrupt lock */
|
KINTERRUPT,
|
||||||
KeReleaseInterruptSpinLock(InterruptObject, synch_oldlvl);
|
InterruptListEntry);
|
||||||
}
|
|
||||||
/* Release the table spinlock */
|
|
||||||
KiReleaseSpinLock(&CurrentIsr->Lock);
|
|
||||||
KeLowerIrql(oldlvl);
|
|
||||||
|
|
||||||
/* Go back to default affinity */
|
/* Reconnect it */
|
||||||
|
KiConnectVectorToInterrupt(Dispatch.Interrupt, ChainConnect);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Remove it */
|
||||||
|
RemoveEntryList(&Interrupt->InterruptListEntry);
|
||||||
|
|
||||||
|
/* Get the next one */
|
||||||
|
NextInterrupt = CONTAINING_RECORD(Dispatch.Interrupt->
|
||||||
|
InterruptListEntry.Flink,
|
||||||
|
KINTERRUPT,
|
||||||
|
InterruptListEntry);
|
||||||
|
|
||||||
|
/* Check if this is the only one left */
|
||||||
|
if (Dispatch.Interrupt == NextInterrupt)
|
||||||
|
{
|
||||||
|
/* Connect it in non-chained mode */
|
||||||
|
KiConnectVectorToInterrupt(Dispatch.Interrupt, NormalConnect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Only one left, disable and remove it */
|
||||||
|
HalDisableSystemInterrupt(Interrupt->Vector, Irql);
|
||||||
|
KiConnectVectorToInterrupt(Interrupt, NoConnect);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Disconnect it */
|
||||||
|
Interrupt->Connected = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Unlock the dispatcher and revert affinity */
|
||||||
|
KeReleaseDispatcherDatabaseLock(OldIrql);
|
||||||
KeRevertToUserAffinityThread();
|
KeRevertToUserAffinityThread();
|
||||||
|
|
||||||
/* Return Old Interrupt State */
|
/* Return to caller */
|
||||||
return State;
|
return State;
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -81,6 +81,9 @@ _KiIdtDescriptor:
|
||||||
_KiUnexpectedEntrySize:
|
_KiUnexpectedEntrySize:
|
||||||
.long _KiUnexpectedInterrupt1 - _KiUnexpectedInterrupt0
|
.long _KiUnexpectedInterrupt1 - _KiUnexpectedInterrupt0
|
||||||
|
|
||||||
|
_UnexpectedMsg:
|
||||||
|
.asciz "\n\x7\x7!!! Unexpected Interrupt %02lx !!!\n"
|
||||||
|
|
||||||
/* SOFTWARE INTERRUPT SERVICES ***********************************************/
|
/* SOFTWARE INTERRUPT SERVICES ***********************************************/
|
||||||
|
|
||||||
_KiGetTickCount:
|
_KiGetTickCount:
|
||||||
|
@ -1348,7 +1351,15 @@ _KiUnexpectedInterruptTail:
|
||||||
jmp _Kei386EoiHelper2ndEntry
|
jmp _Kei386EoiHelper2ndEntry
|
||||||
|
|
||||||
Handled:
|
Handled:
|
||||||
/* Unexpected, exit the interrupt */
|
/* Unexpected interrupt, print a message on debug builds */
|
||||||
|
#if DBG
|
||||||
|
push [esp+4]
|
||||||
|
push offset _UnexpectedMsg
|
||||||
|
call _DbgPrint
|
||||||
|
add esp, 8
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Exit the interrupt */
|
||||||
mov esi, $
|
mov esi, $
|
||||||
cli
|
cli
|
||||||
call _HalEndSystemInterrupt@8
|
call _HalEndSystemInterrupt@8
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue