- 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.


svn path=/trunk/; revision=34584
This commit is contained in:
ReactOS Portable Systems Group 2008-07-19 06:53:03 +00:00
parent b95845bf85
commit c0cde8777b
8 changed files with 88 additions and 47 deletions

View file

@ -148,5 +148,11 @@ KeArmFlushIcache(VOID)
__asm__ __volatile__ ("mcr p15, 0, %0, c7, c5, 0" : : "r"(0) : "cc"); __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 #endif

View file

@ -155,6 +155,7 @@ extern UCHAR KiDebugRegisterContextOffsets[9];
extern ULONG KeTimeIncrement; extern ULONG KeTimeIncrement;
extern ULONG_PTR KiBugCheckData[5]; extern ULONG_PTR KiBugCheckData[5];
extern ULONG KiFreezeFlag; extern ULONG KiFreezeFlag;
extern ULONG KiDPCTimeout;
/* MACROS *************************************************************************/ /* MACROS *************************************************************************/

View file

@ -25,7 +25,7 @@
// //
// Build exception frame // Build exception frame
// FIXME: Change to stmdb later // FIXME-PERF: Change to stmdb later
// //
str r4, [sp, #ExR4] str r4, [sp, #ExR4]
str r5, [sp, #ExR5] str r5, [sp, #ExR5]
@ -58,7 +58,7 @@
// //
// Restore the registers // Restore the registers
// FIXME: Use LDMIA later // FIXME-PERF: Use LDMIA later
// //
ldr r4, [sp, #ExR4] ldr r4, [sp, #ExR4]
ldr r5, [sp, #ExR5] ldr r5, [sp, #ExR5]
@ -85,10 +85,6 @@
NESTED_ENTRY KiThreadStartup NESTED_ENTRY KiThreadStartup
PROLOG_END KiThreadStartup PROLOG_END KiThreadStartup
//
// FIXME: Make space on stack and clean it up?
//
// //
// Lower to APC_LEVEL // Lower to APC_LEVEL
// //

View file

@ -23,17 +23,6 @@ extern PVOID KiArmVectorTable;
/* FUNCTIONS ******************************************************************/ /* FUNCTIONS ******************************************************************/
VOID
DebugService2(IN ULONG Arg1,
IN ULONG Arg2,
IN ULONG Service)
{
//
// FIXME-TODO: Implement this for symbol load and such
//
return;
}
VOID VOID
NTAPI NTAPI
KiInitMachineDependent(VOID) KiInitMachineDependent(VOID)

View file

@ -224,8 +224,31 @@ KeUpdateRunTime(IN PKTRAP_FRAME TrapFrame,
Prcb->DpcTime++; 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;
}
} }
} }

View file

@ -17,7 +17,7 @@
ldr pc, _KiSoftwareInterruptJump // Software Interrupt ldr pc, _KiSoftwareInterruptJump // Software Interrupt
ldr pc, _KiPrefetchAbortJump // Prefetch Abort ldr pc, _KiPrefetchAbortJump // Prefetch Abort
ldr pc, _KiDataAbortJump // Data Abort ldr pc, _KiDataAbortJump // Data Abort
ldr pc, _KiReservedJump // Reserved b . // Reserved
ldr pc, _KiInterruptJump // Interrupt ldr pc, _KiInterruptJump // Interrupt
ldr pc, _KiFastInterruptJump // Fast Interrupt ldr pc, _KiFastInterruptJump // Fast Interrupt
@ -25,7 +25,6 @@
_KiSoftwareInterruptJump: .word KiSoftwareInterruptException _KiSoftwareInterruptJump: .word KiSoftwareInterruptException
_KiPrefetchAbortJump: .word KiPrefetchAbortException _KiPrefetchAbortJump: .word KiPrefetchAbortException
_KiDataAbortJump: .word KiDataAbortException _KiDataAbortJump: .word KiDataAbortException
_KiReservedJump: .word KiReservedException
_KiInterruptJump: .word KiInterruptException _KiInterruptJump: .word KiInterruptException
_KiFastInterruptJump: .word KiFastInterruptException _KiFastInterruptJump: .word KiFastInterruptException
@ -34,9 +33,22 @@
PROLOG_END KiUndefinedInstructionException 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 ENTRY_END KiUndefinedInstructionException
@ -137,19 +149,8 @@
PROLOG_END KiFastInterruptException PROLOG_END KiFastInterruptException
// //
// FIXME: TODO // FIXME-PERF: Implement FIQ exception
// //
b . b .
ENTRY_END KiFastInterruptException ENTRY_END KiFastInterruptException
NESTED_ENTRY KiReservedException
PROLOG_END KiReservedException
//
// FIXME: TODO
//
b .
ENTRY_END KiReservedException

View file

@ -80,8 +80,9 @@ KiIdleLoop(VOID)
else else
{ {
// //
// FIXME-TODO: Wait-For-Interrupt ARM Opcode // Go into WFI (sleep more)
// //
KeArmWaitForInterrupt();
} }
} }
} }
@ -155,10 +156,13 @@ KiSwapContextInternal(IN PKTHREAD OldThread,
if (Prcb->DpcRoutineActive) if (Prcb->DpcRoutineActive)
{ {
// //
// FIXME-TODO: Implement bugcheck code // Crash the machine
// //
DPRINT1("DPCS ACTIVE!!!\n"); KeBugCheckEx(ATTEMPTED_SWITCH_FROM_DPC,
ASSERT(FALSE); (ULONG_PTR)OldThread,
(ULONG_PTR)NewThread,
(ULONG_PTR)OldThread->InitialStack,
0);
} }
// //
@ -167,10 +171,16 @@ KiSwapContextInternal(IN PKTHREAD OldThread,
if (NewThread->ApcState.KernelApcPending) if (NewThread->ApcState.KernelApcPending)
{ {
// //
// FIXME-TODO: Implement bugcheck code // Are APCs enabled?
// //
DPRINT1("APCs pending!\n"); if (NewThread->SpecialApcDisable == 0)
ASSERT(FALSE); {
//
// Request APC delivery
//
HalRequestSoftwareInterrupt(APC_LEVEL);
return TRUE;
}
} }
// //
@ -518,12 +528,22 @@ KiSoftwareInterruptHandler(IN PKTRAP_FRAME TrapFrame)
// //
Instruction = *(PULONG)(TrapFrame->Pc - sizeof(ULONG)); Instruction = *(PULONG)(TrapFrame->Pc - sizeof(ULONG));
//
// FIXME-TODO: Enable interrupts?
//
// //
// Call the service call dispatcher // Call the service call dispatcher
// //
KiSystemService(Thread, TrapFrame, Instruction); 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;
}

View file

@ -199,6 +199,11 @@ KiSystemService(IN PKTHREAD Thread,
} }
} }
//
// We can safely enable interrupts here
//
_enable();
// //
// Do the system call and save result in EAX // Do the system call and save result in EAX
// //