Author: ros-arm-bringup
Date: Sat Jun 14 17:48:30 2008
New Revision: 33970
URL:
http://svn.reactos.org/svn/reactos?rev=33970&view=rev
Log:
- We now implement the idle loop (thanks for fixing the interrupt code...).
- We are now back to HalInitSystem just like before the previous fixes.
- Now we'll implement stall calibration and switch to the clock interrupt.
Modified:
trunk/reactos/ntoskrnl/ke/arm/kiinit.c
trunk/reactos/ntoskrnl/ke/arm/trapc.c
Modified: trunk/reactos/ntoskrnl/ke/arm/kiinit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/kiinit.c?r…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/kiinit.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/arm/kiinit.c [iso-8859-1] Sat Jun 14 17:48:30 2008
@@ -22,6 +22,9 @@
#define __ARMV6__ KeIsArmV6
/* FUNCTIONS ******************************************************************/
+
+VOID
+KiIdleLoop(VOID);
VOID
DebugService(IN ULONG ServiceType,
@@ -495,5 +498,5 @@
//
// Jump to idle loop
//
- while (TRUE);
+ KiIdleLoop();
}
Modified: trunk/reactos/ntoskrnl/ke/arm/trapc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/trapc.c?re…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/trapc.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/arm/trapc.c [iso-8859-1] Sat Jun 14 17:48:30 2008
@@ -32,6 +32,81 @@
VOID FASTCALL
HalClearSoftwareInterrupt(IN KIRQL Request);
+
+VOID
+KiIdleLoop(VOID)
+{
+ PKPCR Pcr = (PKPCR)KeGetPcr();
+ PKPRCB Prcb = Pcr->Prcb;
+ PKTHREAD OldThread, NewThread;
+
+ //
+ // Loop forever... that's why this is an idle loop
+ //
+ while (TRUE)
+ {
+ //
+ // Cycle interrupts
+ //
+ _disable();
+ _enable();
+
+ //
+ // Check if there's DPC work to do
+ //
+ if ((Prcb->DpcData[0].DpcQueueDepth) ||
+ (Prcb->TimerRequest) ||
+ (Prcb->DeferredReadyListHead.Next))
+ {
+ //
+ // Clear the pending interrupt
+ //
+ HalClearSoftwareInterrupt(DISPATCH_LEVEL);
+
+ //
+ // FIXME: TODO
+ //
+ DPRINT1("DPC/Timer Delivery!\n");
+ while (TRUE);
+ }
+
+ //
+ // Check if there's a thread to schedule
+ //
+ if (Prcb->NextThread)
+ {
+ //
+ // Out with the old, in with the new...
+ //
+ OldThread = Prcb->CurrentThread;
+ NewThread = Prcb->NextThread;
+ Prcb->CurrentThread = NewThread;
+ Prcb->NextThread = NULL;
+
+ //
+ // Update thread state
+ //
+ NewThread->State = Running;
+
+ //
+ // Swap to the new thread
+ // On ARM we call KiSwapContext instead of KiSwapContextInternal,
+ // because we're calling this from C code and not assembly.
+ // This is similar to how it gets called for unwaiting, on x86
+ //
+ DPRINT1("Swapping context!\n");
+ KiSwapContext(OldThread, NewThread);
+ DPRINT1("Back\n");
+ while (TRUE);
+ }
+ else
+ {
+ //
+ // FIXME: Wait-For-Interrupt ARM Opcode
+ //
+ }
+ }
+}
BOOLEAN
KiSwapContextInternal(IN PKTHREAD OldThread,
@@ -155,20 +230,22 @@
KiDispatchInterrupt(VOID)
{
PKPCR Pcr;
+ PKPRCB Prcb;
PKTHREAD NewThread, OldThread;
//
// Get the PCR and disable interrupts
//
Pcr = (PKPCR)KeGetPcr();
+ Prcb = Pcr->Prcb;
_disable();
//
//Check if we have to deliver DPCs, timers, or deferred threads
//
- if ((Pcr->Prcb->DpcData[0].DpcQueueDepth) ||
- (Pcr->Prcb->TimerRequest) ||
- (Pcr->Prcb->DeferredReadyListHead.Next))
+ if ((Prcb->DpcData[0].DpcQueueDepth) ||
+ (Prcb->TimerRequest) ||
+ (Prcb->DeferredReadyListHead.Next))
{
//
// FIXME: TODO
@@ -185,7 +262,7 @@
//
// Check for quantum end
//
- if (Pcr->Prcb->QuantumEnd)
+ if (Prcb->QuantumEnd)
{
//
// FIXME: TODO
@@ -198,15 +275,15 @@
//
// Check if we have a thread to swap to
//
- if (Pcr->Prcb->NextThread)
+ if (Prcb->NextThread)
{
//
// Next is now current
//
- OldThread = Pcr->Prcb->CurrentThread;
- NewThread = Pcr->Prcb->NextThread;
- Pcr->Prcb->CurrentThread = NewThread;
- Pcr->Prcb->NextThread = NULL;
+ OldThread = Prcb->CurrentThread;
+ NewThread = Prcb->NextThread;
+ Prcb->CurrentThread = NewThread;
+ Prcb->NextThread = NULL;
//
// Update thread states
@@ -217,7 +294,7 @@
//
// Make the old thread ready
//
- KxQueueReadyThread(OldThread, Pcr->Prcb);
+ KxQueueReadyThread(OldThread, Prcb);
//
// Swap to the new thread
@@ -227,6 +304,7 @@
//
DPRINT1("Swapping context!\n");
KiSwapContext(OldThread, NewThread);
+ DPRINT1("Back\n");
while (TRUE);
}
}