mirror of
https://github.com/reactos/reactos.git
synced 2025-04-15 01:47:30 +00:00
[NTOSKRNL]
"Fix things": Add architecture specific macros KeGetTrapFrame, KeGetExceptionFrame and KeGetContextSwitches. Should fix kernel build on arm. Patch by Alex, modified by me. svn path=/trunk/; revision=44640
This commit is contained in:
parent
26c9ccdb64
commit
32014b63b8
6 changed files with 47 additions and 23 deletions
|
@ -1238,7 +1238,6 @@ QSI_DEF(SystemPoolTagInformation)
|
|||
QSI_DEF(SystemInterruptInformation)
|
||||
{
|
||||
PKPRCB Prcb;
|
||||
PKPCR Pcr;
|
||||
LONG i;
|
||||
ULONG ti;
|
||||
PSYSTEM_INTERRUPT_INFORMATION sii = (PSYSTEM_INTERRUPT_INFORMATION)Buffer;
|
||||
|
@ -1253,12 +1252,7 @@ QSI_DEF(SystemInterruptInformation)
|
|||
for (i = 0; i < KeNumberProcessors; i++)
|
||||
{
|
||||
Prcb = KiProcessorBlock[i];
|
||||
Pcr = (PKPCR)CONTAINING_RECORD(Prcb, KIPCR, PrcbData);
|
||||
#ifdef _M_ARM // This code should probably be done differently
|
||||
sii->ContextSwitches = Pcr->ContextSwitches;
|
||||
#else
|
||||
sii->ContextSwitches = ((PKIPCR)Pcr)->ContextSwitches;
|
||||
#endif
|
||||
sii->ContextSwitches = KeGetContextSwitches(Prcb);
|
||||
sii->DpcCount = Prcb->DpcData[0].DpcCount;
|
||||
sii->DpcRate = Prcb->DpcRequestRate;
|
||||
sii->TimeIncrement = ti;
|
||||
|
|
|
@ -36,6 +36,24 @@
|
|||
#define KeSetContextReturnRegister(Context, ReturnValue) \
|
||||
((Context)->R0 = (ReturnValue))
|
||||
|
||||
//
|
||||
// Macro to get trap and exception frame from a thread stack
|
||||
//
|
||||
#define KeGetTrapFrame(Thread) \
|
||||
(PKTRAP_FRAME)((ULONG_PTR)((Thread)->InitialStack) - \
|
||||
sizeof(KTRAP_FRAME))
|
||||
|
||||
#define KeGetExceptionFrame(Thread) \
|
||||
(PKEXCEPTION_FRAME)((ULONG_PTR)KeGetTrapFrame(Thread) - \
|
||||
sizeof(KEXCEPTION_FRAME))
|
||||
|
||||
//
|
||||
// Macro to get context switches from the PRCB
|
||||
// All architectures but x86 have it in the PRCB's KeContextSwitches
|
||||
//
|
||||
#define KeGetContextSwitches(Prcb) \
|
||||
Prcb->KeContextSwitches
|
||||
|
||||
//
|
||||
// Returns the Interrupt State from a Trap Frame.
|
||||
// ON = TRUE, OFF = FALSE
|
||||
|
|
|
@ -41,6 +41,24 @@ extern ULONG Ke386CacheAlignment;
|
|||
#define KeSetContextReturnRegister(Context, ReturnValue) \
|
||||
((Context)->Eax = (ReturnValue))
|
||||
|
||||
//
|
||||
// Macro to get trap and exception frame from a thread stack
|
||||
//
|
||||
#define KeGetTrapFrame(Thread) \
|
||||
(PKTRAP_FRAME)((ULONG_PTR)((Thread)->InitialStack) - \
|
||||
sizeof(KTRAP_FRAME) - \
|
||||
sizeof(FX_SAVE_AREA))
|
||||
|
||||
#define KeGetExceptionFrame(Thread) \
|
||||
NULL
|
||||
|
||||
//
|
||||
// Macro to get context switches from the PRCB
|
||||
// All architectures but x86 have it in the PRCB's KeContextSwitches
|
||||
//
|
||||
#define KeGetContextSwitches(Prcb) \
|
||||
CONTAINING_RECORD(Prcb, KIPCR, PrcbData)->ContextSwitches
|
||||
|
||||
//
|
||||
// Returns the Interrupt State from a Trap Frame.
|
||||
// ON = TRUE, OFF = FALSE
|
||||
|
|
|
@ -50,7 +50,7 @@ PspGetOrSetContextKernelRoutine(IN PKAPC Apc,
|
|||
PGET_SET_CTX_CONTEXT GetSetContext;
|
||||
PKEVENT Event;
|
||||
PCONTEXT Context;
|
||||
PKTHREAD Thread;
|
||||
PETHREAD Thread;
|
||||
KPROCESSOR_MODE Mode;
|
||||
PKTRAP_FRAME TrapFrame = NULL;
|
||||
PAGED_CODE();
|
||||
|
@ -63,15 +63,13 @@ PspGetOrSetContextKernelRoutine(IN PKAPC Apc,
|
|||
Thread = Apc->SystemArgument2;
|
||||
|
||||
/* If this is a kernel-mode request, grab the saved trap frame */
|
||||
if (Mode == KernelMode) TrapFrame = Thread->TrapFrame;
|
||||
if (Mode == KernelMode) TrapFrame = Thread->Tcb.TrapFrame;
|
||||
|
||||
/* If we don't have one, grab it from the stack */
|
||||
if (!TrapFrame)
|
||||
{
|
||||
/* Trap frame is right under our initial stack */
|
||||
TrapFrame = (PKTRAP_FRAME)((ULONG_PTR)Thread->InitialStack -
|
||||
ROUND_UP(sizeof(KTRAP_FRAME), KTRAP_FRAME_ALIGN) -
|
||||
sizeof(FX_SAVE_AREA));
|
||||
TrapFrame = KeGetTrapFrame(&Thread->Tcb);
|
||||
}
|
||||
|
||||
/* Check if it's a set or get */
|
||||
|
|
|
@ -72,10 +72,8 @@ PspUserThreadStartup(IN PKSTART_ROUTINE StartRoutine,
|
|||
KeRaiseIrql(APC_LEVEL, &OldIrql);
|
||||
|
||||
/* Queue the User APC */
|
||||
KiInitializeUserApc(NULL,
|
||||
(PVOID)((ULONG_PTR)Thread->Tcb.InitialStack -
|
||||
sizeof(KTRAP_FRAME) -
|
||||
SIZEOF_FX_SAVE_AREA),
|
||||
KiInitializeUserApc(KeGetExceptionFrame(&Thread->Tcb),
|
||||
KeGetTrapFrame(&Thread->Tcb),
|
||||
PspSystemDllEntryPoint,
|
||||
NULL,
|
||||
PspSystemDllBase,
|
||||
|
|
|
@ -285,7 +285,7 @@ RtlWalkFrameChain(OUT PVOID *Callers,
|
|||
ULONG Eip;
|
||||
BOOLEAN Result, StopSearch = FALSE;
|
||||
ULONG i = 0;
|
||||
PKTHREAD Thread = KeGetCurrentThread();
|
||||
PETHREAD Thread = PsGetCurrentThread();
|
||||
PTEB Teb;
|
||||
PKTRAP_FRAME TrapFrame;
|
||||
|
||||
|
@ -326,14 +326,12 @@ RtlWalkFrameChain(OUT PVOID *Callers,
|
|||
if (Flags == 1)
|
||||
{
|
||||
/* Get the trap frame and TEB */
|
||||
TrapFrame = Thread->TrapFrame;
|
||||
Teb = Thread->Teb;
|
||||
TrapFrame = KeGetTrapFrame(&Thread->Tcb);
|
||||
Teb = Thread->Tcb.Teb;
|
||||
|
||||
/* Make sure we can trust the TEB and trap frame */
|
||||
if (!(Teb) ||
|
||||
!((PVOID)((ULONG_PTR)TrapFrame & 0x80000000)) ||
|
||||
((PVOID)TrapFrame <= (PVOID)Thread->StackLimit) ||
|
||||
((PVOID)TrapFrame >= (PVOID)Thread->StackBase) ||
|
||||
!(Thread->SystemThread) ||
|
||||
(KeIsAttachedProcess()) ||
|
||||
(KeGetCurrentIrql() >= DISPATCH_LEVEL))
|
||||
{
|
||||
|
@ -390,7 +388,7 @@ RtlWalkFrameChain(OUT PVOID *Callers,
|
|||
if ((StackBegin < Eip) && (Eip < StackEnd)) break;
|
||||
|
||||
/* Check if we reached a user-mode address */
|
||||
if (!(Flags) && !(Eip & 0x80000000)) break;
|
||||
if (!(Flags) && !(Eip & 0x80000000)) break; // FIXME: 3GB breakage
|
||||
|
||||
/* Save this frame */
|
||||
Callers[i] = (PVOID)Eip;
|
||||
|
|
Loading…
Reference in a new issue