Author: ros-arm-bringup
Date: Sat Jul 19 01:53:03 2008
New Revision: 34584
URL:
http://svn.reactos.org/svn/reactos?rev=34584&view=rev
Log:
- Enable interrupts after probing and capturing parameters during a system call.
- Enable WFI during idle loop.
- Implement undefined exception handler, and get rid of reserved exception code -- this
will never happen except for an SoC bug.
- Request an APC interrupt if the new thread we context switched to has APCs pending and
enabled.
- Perform DPC watchdog debugging code if a DPC lasted more than a second.
- Do the appropriate bugcheck if DPCs are active during a context switch.
- Go over the FIXMEs in the assembly files too, and create a new FIXME-PERF category.
Modified:
trunk/reactos/ntoskrnl/include/internal/arm/intrin_i.h
trunk/reactos/ntoskrnl/include/internal/ke.h
trunk/reactos/ntoskrnl/ke/arm/ctxswtch.s
trunk/reactos/ntoskrnl/ke/arm/kiinit.c
trunk/reactos/ntoskrnl/ke/arm/time.c
trunk/reactos/ntoskrnl/ke/arm/trap.s
trunk/reactos/ntoskrnl/ke/arm/trapc.c
trunk/reactos/ntoskrnl/ke/arm/usercall.c
Modified: trunk/reactos/ntoskrnl/include/internal/arm/intrin_i.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/arm/intrin_i.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/arm/intrin_i.h [iso-8859-1] Sat Jul 19
01:53:03 2008
@@ -148,5 +148,11 @@
__asm__ __volatile__ ("mcr p15, 0, %0, c7, c5, 0" : : "r"(0) :
"cc");
}
+FORCEINLINE
+VOID
+KeArmWaitForInterrupt(VOID)
+{
+ __asm__ __volatile__ ("mcr p15, 0, %0, c7, c0, 4" : : "r"(0) :
"cc");
+}
#endif
Modified: trunk/reactos/ntoskrnl/include/internal/ke.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ke.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/ke.h [iso-8859-1] Sat Jul 19 01:53:03 2008
@@ -155,6 +155,7 @@
extern ULONG KeTimeIncrement;
extern ULONG_PTR KiBugCheckData[5];
extern ULONG KiFreezeFlag;
+extern ULONG KiDPCTimeout;
/* MACROS *************************************************************************/
Modified: trunk/reactos/ntoskrnl/ke/arm/ctxswtch.s
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/ctxswtch.s…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/ctxswtch.s [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/arm/ctxswtch.s [iso-8859-1] Sat Jul 19 01:53:03 2008
@@ -25,7 +25,7 @@
//
// Build exception frame
- // FIXME: Change to stmdb later
+ // FIXME-PERF: Change to stmdb later
//
str r4, [sp, #ExR4]
str r5, [sp, #ExR5]
@@ -58,7 +58,7 @@
//
// Restore the registers
- // FIXME: Use LDMIA later
+ // FIXME-PERF: Use LDMIA later
//
ldr r4, [sp, #ExR4]
ldr r5, [sp, #ExR5]
@@ -84,11 +84,7 @@
NESTED_ENTRY KiThreadStartup
PROLOG_END KiThreadStartup
-
- //
- // FIXME: Make space on stack and clean it up?
- //
-
+
//
// Lower to APC_LEVEL
//
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 Jul 19 01:53:03 2008
@@ -22,17 +22,6 @@
#define __ARMV6__ KeIsArmV6
/* FUNCTIONS ******************************************************************/
-
-VOID
-DebugService2(IN ULONG Arg1,
- IN ULONG Arg2,
- IN ULONG Service)
-{
- //
- // FIXME-TODO: Implement this for symbol load and such
- //
- return;
-}
VOID
NTAPI
Modified: trunk/reactos/ntoskrnl/ke/arm/time.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/time.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/time.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/arm/time.c [iso-8859-1] Sat Jul 19 01:53:03 2008
@@ -224,8 +224,31 @@
Prcb->DpcTime++;
//
- // FIXME-TODO: Handle DPC checks
- //
+ // Update Debug DPC time
+ //
+ Prcb->DebugDpcTime++;
+
+ //
+ // Check if we've timed out
+ //
+ if (Prcb->DebugDpcTime >= KiDPCTimeout)
+ {
+ //
+ // Print a message
+ //
+ DbgPrint("\n*** DPC routine > 1 sec --- This is not a break in
"
+ "KeUpdateSystemTime\n");
+
+ //
+ // Break if a debugger is attached
+ //
+ if (KdDebuggerEnabled) DbgBreakPoint();
+
+ //
+ // Restore the debug DPC time
+ //
+ Prcb->DebugDpcTime = 0;
+ }
}
}
Modified: trunk/reactos/ntoskrnl/ke/arm/trap.s
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/trap.s?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/trap.s [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/arm/trap.s [iso-8859-1] Sat Jul 19 01:53:03 2008
@@ -17,7 +17,7 @@
ldr pc, _KiSoftwareInterruptJump // Software Interrupt
ldr pc, _KiPrefetchAbortJump // Prefetch Abort
ldr pc, _KiDataAbortJump // Data Abort
- ldr pc, _KiReservedJump // Reserved
+ b . // Reserved
ldr pc, _KiInterruptJump // Interrupt
ldr pc, _KiFastInterruptJump // Fast Interrupt
@@ -25,7 +25,6 @@
_KiSoftwareInterruptJump: .word KiSoftwareInterruptException
_KiPrefetchAbortJump: .word KiPrefetchAbortException
_KiDataAbortJump: .word KiDataAbortException
- _KiReservedJump: .word KiReservedException
_KiInterruptJump: .word KiInterruptException
_KiFastInterruptJump: .word KiFastInterruptException
@@ -34,9 +33,22 @@
PROLOG_END KiUndefinedInstructionException
//
- // FIXME: TODO
+ // Handle trap entry
//
- b .
+ TRAP_PROLOG 0 // NotFromAbort
+
+ //
+ // Call the C handler
+ //
+ adr lr, 1f
+ mov r0, sp
+ ldr pc, =KiUndefinedExceptionHandler
+
+1:
+ //
+ // Handle trap exit
+ //
+ TRAP_EPILOG 0 // NotFromSystemCall
ENTRY_END KiUndefinedInstructionException
@@ -137,19 +149,8 @@
PROLOG_END KiFastInterruptException
//
- // FIXME: TODO
+ // FIXME-PERF: Implement FIQ exception
//
b .
ENTRY_END KiFastInterruptException
-
-
- NESTED_ENTRY KiReservedException
- PROLOG_END KiReservedException
-
- //
- // FIXME: TODO
- //
- b .
-
- ENTRY_END KiReservedException
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 Jul 19 01:53:03 2008
@@ -80,8 +80,9 @@
else
{
//
- // FIXME-TODO: Wait-For-Interrupt ARM Opcode
- //
+ // Go into WFI (sleep more)
+ //
+ KeArmWaitForInterrupt();
}
}
}
@@ -155,10 +156,13 @@
if (Prcb->DpcRoutineActive)
{
//
- // FIXME-TODO: Implement bugcheck code
- //
- DPRINT1("DPCS ACTIVE!!!\n");
- ASSERT(FALSE);
+ // Crash the machine
+ //
+ KeBugCheckEx(ATTEMPTED_SWITCH_FROM_DPC,
+ (ULONG_PTR)OldThread,
+ (ULONG_PTR)NewThread,
+ (ULONG_PTR)OldThread->InitialStack,
+ 0);
}
//
@@ -167,10 +171,16 @@
if (NewThread->ApcState.KernelApcPending)
{
//
- // FIXME-TODO: Implement bugcheck code
- //
- DPRINT1("APCs pending!\n");
- ASSERT(FALSE);
+ // Are APCs enabled?
+ //
+ if (NewThread->SpecialApcDisable == 0)
+ {
+ //
+ // Request APC delivery
+ //
+ HalRequestSoftwareInterrupt(APC_LEVEL);
+ return TRUE;
+ }
}
//
@@ -517,13 +527,23 @@
// Read the opcode
//
Instruction = *(PULONG)(TrapFrame->Pc - sizeof(ULONG));
-
- //
- // FIXME-TODO: Enable interrupts?
- //
-
+
//
// Call the service call dispatcher
//
KiSystemService(Thread, TrapFrame, Instruction);
}
+
+NTSTATUS
+KiUndefinedExceptionHandler(IN PKTRAP_FRAME TrapFrame)
+{
+ ASSERT(TrapFrame->DbgArgMark == 0xBADB0D00);
+
+ //
+ // This should never happen
+ //
+ DPRINT1("[UNDEF] @ %p/%p\n", TrapFrame->SvcLr, TrapFrame->Pc);
+ UNIMPLEMENTED;
+ ASSERT(FALSE);
+ return STATUS_SUCCESS;
+}
Modified: trunk/reactos/ntoskrnl/ke/arm/usercall.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/arm/usercall.c…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/arm/usercall.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ke/arm/usercall.c [iso-8859-1] Sat Jul 19 01:53:03 2008
@@ -200,6 +200,11 @@
}
//
+ // We can safely enable interrupts here
+ //
+ _enable();
+
+ //
// Do the system call and save result in EAX
//
TrapFrame->R0 = KiSyscallHandlers[ArgumentCount]((PVOID)SystemCall,