- Add KCALLOUT_FRAME to define the kernel callback stack layout during user mode...
authorStefan Ginsberg <stefanginsberg@gmail.com>
Mon, 9 Nov 2009 23:19:03 +0000 (23:19 +0000)
committerStefan Ginsberg <stefanginsberg@gmail.com>
Mon, 9 Nov 2009 23:19:03 +0000 (23:19 +0000)
- AMD64's is a copy of x86's to match asm.h's the assembly offsets. ARM's is a stub containing two necessary members to have some offsets for the debugger data block.
- Add ARM stub for KiCallUserMode as this is referenced from the debugger data block.

svn path=/trunk/; revision=44063

reactos/include/ndk/amd64/asm.h
reactos/include/ndk/amd64/ketypes.h
reactos/include/ndk/arm/ketypes.h
reactos/include/ndk/i386/asm.h
reactos/include/ndk/i386/ketypes.h
reactos/ntoskrnl/kd64/kddata.c
reactos/ntoskrnl/ke/arm/stubs_asm.s

index d80b35d..4538e0c 100644 (file)
@@ -255,7 +255,6 @@ Author:
 #define CBSTACK_RBP                             0x18
 #define CBSTACK_RESULT                          0x20
 #define CBSTACK_RESULT_LENGTH                   0x28
-#define CBSTACK_FRAME_POINTER                   CBSTACK_RBP
 
 
 /* Following ones are ASM only! ***********************************************/
index 03ee79c..b572420 100644 (file)
@@ -231,6 +231,23 @@ typedef struct _KTRAP_FRAME
     LONG CodePatchCycle;
 } KTRAP_FRAME, *PKTRAP_FRAME;
 
+//
+// Defines the Callback Stack Layout for User Mode Callbacks
+//
+typedef struct _KCALLOUT_FRAME
+{
+    ULONG64 InitialStack;
+    ULONG64 TrapFrame;
+    ULONG64 CallbackStack;
+    ULONG64 Rdi;
+    ULONG64 Rsi;
+    ULONG64 Rbx;
+    ULONG64 Rbp;
+    ULONG64 ReturnAddress;
+    ULONG64 Result;
+    ULONG64 ResultLength;
+} KCALLOUT_FRAME, *PKCALLOUT_FRAME;
+
 //
 // Dummy LDT_ENTRY
 //
index 587e1b6..2e63ea5 100644 (file)
@@ -84,6 +84,17 @@ typedef struct _KTRAP_FRAME
     ULONG PreviousTrapFrame;
 } KTRAP_FRAME, *PKTRAP_FRAME;
 
+//
+// Defines the Callback Stack Layout for User Mode Callbacks
+//
+// Just a stub with some required members for now
+//
+typedef struct _KCALLOUT_FRAME
+{
+    ULONG CallbackStack;
+    ULONG DummyFramePointer;
+} KCALLOUT_FRAME, *PKCALLOUT_FRAME;
+
 #ifndef NTOS_MODE_USER
 
 //
index 095cb5d..f0e1be8 100644 (file)
@@ -534,7 +534,6 @@ Author:
 #define CBSTACK_EBP                             0x18
 #define CBSTACK_RESULT                          0x20
 #define CBSTACK_RESULT_LENGTH                   0x24
-#define CBSTACK_FRAME_POINTER                   CBSTACK_EBP
 
 //
 // NTSTATUS, Bugcheck Codes and Debug Codes
index 78b47c4..ad2c5a5 100644 (file)
@@ -201,6 +201,23 @@ typedef struct _KTRAP_FRAME
     ULONG V86Gs;
 } KTRAP_FRAME, *PKTRAP_FRAME;
 
+//
+// Defines the Callback Stack Layout for User Mode Callbacks
+//
+typedef struct _KCALLOUT_FRAME
+{
+    ULONG InitialStack;
+    ULONG TrapFrame;
+    ULONG CallbackStack;
+    ULONG Edi;
+    ULONG Esi;
+    ULONG Ebx;
+    ULONG Ebp;
+    ULONG ReturnAddress;
+    ULONG Result;
+    ULONG ResultLength;
+} KCALLOUT_FRAME, *PKCALLOUT_FRAME;
+
 //
 // LDT Entry Definition
 //
index 54e5b0d..c5db36d 100644 (file)
@@ -30,6 +30,7 @@ VOID NTAPI RtlpBreakWithStatusInstruction(VOID);
 #define KPCR_INITIAL_STACK_OFFSET      0
 #define KPCR_STACK_LIMIT_OFFSET        0
 #define KPRCB_PCR_PAGE_OFFSET          0
+#define CBSTACK_FRAME_POINTER          Ebp
 
 #elif defined(_AMD64_)
 
@@ -39,6 +40,7 @@ VOID NTAPI RtlpBreakWithStatusInstruction(VOID);
 #define KPCR_INITIAL_STACK_OFFSET      0
 #define KPCR_STACK_LIMIT_OFFSET        0
 #define KPRCB_PCR_PAGE_OFFSET          0
+#define CBSTACK_FRAME_POINTER          Rbp
 
 #elif defined(_ARM_)
 
@@ -48,6 +50,7 @@ VOID NTAPI RtlpBreakWithStatusInstruction(VOID);
 #define KPCR_INITIAL_STACK_OFFSET      FIELD_OFFSET(KPCR, InitialStack)
 #define KPCR_STACK_LIMIT_OFFSET        FIELD_OFFSET(KPCR, StackLimit)
 #define KPRCB_PCR_PAGE_OFFSET          FIELD_OFFSET(KPRCB, PcrPage)
+#define CBSTACK_FRAME_POINTER          DummyFramePointer
 
 #else
 #error Unsupported Architecture
@@ -392,8 +395,8 @@ KDDEBUGGER_DATA64 KdDebuggerDataBlock =
     {(ULONG_PTR)RtlpBreakWithStatusInstruction},
     0,
     FIELD_OFFSET(KTHREAD, CallbackStack),
-    CBSTACK_CALLBACK_STACK,
-    CBSTACK_FRAME_POINTER,
+    FIELD_OFFSET(KCALLOUT_FRAME, CallbackStack),
+    FIELD_OFFSET(KCALLOUT_FRAME, CBSTACK_FRAME_POINTER),
     FALSE,
     {(ULONG_PTR)KiCallUserMode},
     0,
@@ -505,7 +508,7 @@ KDDEBUGGER_DATA64 KdDebuggerDataBlock =
     KPCR_STACK_LIMIT_OFFSET,
     KPRCB_PCR_PAGE_OFFSET,
     FIELD_OFFSET(KPRCB, ProcessorState.SpecialRegisters),
-#if defined(_M_IX86)
+#if defined(_X86_)
     //
     // x86 GDT/LDT/TSS constants
     //
@@ -519,7 +522,7 @@ KDDEBUGGER_DATA64 KdDebuggerDataBlock =
     KGDT_TSS,
     0,
     0,
-#elif defined(_M_AMD64)
+#elif defined(_AMD64_)
     //
     // AMD64 GDT/LDT/TSS constants
     //
index 11b8f3a..f7d4900 100644 (file)
@@ -34,6 +34,7 @@ GENERATE_ARM_STUB KeSynchronizeExecution
 GENERATE_ARM_STUB KeSwitchKernelStack
 GENERATE_ARM_STUB RtlCreateUserThread
 GENERATE_ARM_STUB RtlInitializeContext
-GENERATE_ARM_STUB KeUserModeCallback 
+GENERATE_ARM_STUB KeUserModeCallback
+GENERATE_ARM_STUB KiCallUserMode
 GENERATE_ARM_STUB NtCallbackReturn
 GENERATE_ARM_STUB NtContinue