Author: tkreuzer
Date: Thu Dec 17 21:58:58 2009
New Revision: 44640
URL:
http://svn.reactos.org/svn/reactos?rev=44640&view=rev
Log:
[NTOSKRNL]
"Fix things": Add architecture specific macros KeGetTrapFrame,
KeGetExceptionFrame and KeGetContextSwitches. Should fix kernel build on arm. Patch by
Alex, modified by me.
Modified:
trunk/reactos/ntoskrnl/ex/sysinfo.c
trunk/reactos/ntoskrnl/include/internal/arm/ke.h
trunk/reactos/ntoskrnl/include/internal/i386/ke.h
trunk/reactos/ntoskrnl/ps/i386/psctx.c
trunk/reactos/ntoskrnl/ps/thread.c
trunk/reactos/ntoskrnl/rtl/libsupp.c
Modified: trunk/reactos/ntoskrnl/ex/sysinfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ex/sysinfo.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/sysinfo.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ex/sysinfo.c [iso-8859-1] Thu Dec 17 21:58:58 2009
@@ -1238,7 +1238,6 @@
QSI_DEF(SystemInterruptInformation)
{
PKPRCB Prcb;
- PKPCR Pcr;
LONG i;
ULONG ti;
PSYSTEM_INTERRUPT_INFORMATION sii = (PSYSTEM_INTERRUPT_INFORMATION)Buffer;
@@ -1253,12 +1252,7 @@
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;
Modified: trunk/reactos/ntoskrnl/include/internal/arm/ke.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/arm/ke.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/arm/ke.h [iso-8859-1] Thu Dec 17 21:58:58
2009
@@ -35,6 +35,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.
Modified: trunk/reactos/ntoskrnl/include/internal/i386/ke.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/i386/ke.h [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/include/internal/i386/ke.h [iso-8859-1] Thu Dec 17 21:58:58
2009
@@ -40,6 +40,24 @@
#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.
Modified: trunk/reactos/ntoskrnl/ps/i386/psctx.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/i386/psctx.c?r…
==============================================================================
--- trunk/reactos/ntoskrnl/ps/i386/psctx.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ps/i386/psctx.c [iso-8859-1] Thu Dec 17 21:58:58 2009
@@ -50,7 +50,7 @@
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 @@
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 */
Modified: trunk/reactos/ntoskrnl/ps/thread.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ps/thread.c?rev=4…
==============================================================================
--- trunk/reactos/ntoskrnl/ps/thread.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/ps/thread.c [iso-8859-1] Thu Dec 17 21:58:58 2009
@@ -72,10 +72,8 @@
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,
Modified: trunk/reactos/ntoskrnl/rtl/libsupp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/rtl/libsupp.c?rev…
==============================================================================
--- trunk/reactos/ntoskrnl/rtl/libsupp.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/rtl/libsupp.c [iso-8859-1] Thu Dec 17 21:58:58 2009
@@ -285,7 +285,7 @@
ULONG Eip;
BOOLEAN Result, StopSearch = FALSE;
ULONG i = 0;
- PKTHREAD Thread = KeGetCurrentThread();
+ PETHREAD Thread = PsGetCurrentThread();
PTEB Teb;
PKTRAP_FRAME TrapFrame;
@@ -326,14 +326,12 @@
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 @@
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;