Implement ARM version of DbgBreakPoint in the RTL. We do a bkpt with a special value...
authorReactOS Portable Systems Group <ros-arm-bringup@svn.reactos.org>
Tue, 5 Feb 2008 11:08:34 +0000 (11:08 +0000)
committerReactOS Portable Systems Group <ros-arm-bringup@svn.reactos.org>
Tue, 5 Feb 2008 11:08:34 +0000 (11:08 +0000)
Fix NtCurrentTeb definition for ARM. We will expose the KPCR to user-mode much like KUSER_SHARED_DATA on x86 (this is how ARM-CE and NT-MIPS do it) and link the TEB there.

svn path=/trunk/; revision=32134

reactos/include/ndk/arm/ketypes.h
reactos/include/psdk/winnt.h
reactos/lib/rtl/arm/debug_asm.S [new file with mode: 0644]
reactos/lib/rtl/rtl.rbuild

index d374e2a..4ddd074 100644 (file)
@@ -66,7 +66,9 @@ Author:
 // FIXME: mmtypes.h?
 //
 #define KIPCR                   0xFFFFF000
-#define PCR                     ((volatile KPCR * const)KIPCR)
+#define USPCR                   0x7FFF0000
+#define PCR                     ((volatile KPCR * const)USPCR)
+#define USERPCR                 ((volatile KPCR * const)KIPCR)
 
 //
 // Synchronization-level IRQL
@@ -104,34 +106,13 @@ typedef struct _KTRAP_FRAME
     ULONG FpExtra[8];
 } KTRAP_FRAME, *PKTRAP_FRAME;
 
-#ifndef NTOS_MODE_USER
-//
-// Stub
-//
-typedef struct _KFLOATING_SAVE
-{
-    ULONG Reserved;
-} KFLOATING_SAVE, *PKFLOATING_SAVE;
-
-//
-// Processor Region Control Block
-//
-typedef struct _KPRCB
-{
-    USHORT MinorVersion;
-    USHORT MajorVersion;
-    struct _KTHREAD *CurrentThread;
-    struct _KTHREAD *NextThread;
-    struct _KTHREAD *IdleThread;
-    UCHAR Number;
-    //
-    // TODO
-    //
-} KPRCB, *PKPRCB;
-
 //
 // Processor Control Region
+// On ARM, it's actually readable from user-mode, much like KUSER_SHARED_DATA
 //
+#ifdef NTOS_MODE_USER
+#define PKINTERRUPT_ROUTINE PVOID // Hack!
+#endif
 typedef struct _KPCR
 {
     ULONG MinorVersion;
@@ -186,6 +167,31 @@ typedef struct _KPCR
     ULONG QuantumEnd;
 } KPCR, *PKPCR;
 
+#ifndef NTOS_MODE_USER
+//
+// Stub
+//
+typedef struct _KFLOATING_SAVE
+{
+    ULONG Reserved;
+} KFLOATING_SAVE, *PKFLOATING_SAVE;
+
+//
+// Processor Region Control Block
+//
+typedef struct _KPRCB
+{
+    USHORT MinorVersion;
+    USHORT MajorVersion;
+    struct _KTHREAD *CurrentThread;
+    struct _KTHREAD *NextThread;
+    struct _KTHREAD *IdleThread;
+    UCHAR Number;
+    //
+    // TODO
+    //
+} KPRCB, *PKPRCB;
+
 //
 // Macro to get current KPRCB
 //
index 9835cd6..03333f1 100644 (file)
@@ -4104,7 +4104,23 @@ static __inline__ struct _TEB * NtCurrentTeb(void)
     return ret;
 }
 #elif _M_ARM
-    struct _TEB* WINAPI NtCurrentTeb(VOID);
+    
+//
+// NT-ARM is not documented, need NDK
+//
+#define NTOS_MODE_USER
+#include <arm/ketypes.h>
+    
+//
+// FIXME: Move _M_ARM stuff away from here
+// *** AND NOT IN THE NDK! NDK IS ONLY FOR OFFICIALLY OBTAINABLE/EXISTING NT
+//
+FORCEINLINE
+struct _TEB* NtCurrentTeb(VOID)
+{
+    return (struct _TEB*)USERPCR->Teb;
+}
+
 #else
 static __inline__ struct _TEB * NtCurrentTeb(void)
 {
diff --git a/reactos/lib/rtl/arm/debug_asm.S b/reactos/lib/rtl/arm/debug_asm.S
new file mode 100644 (file)
index 0000000..efa9383
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * COPYRIGHT:         See COPYING in the top level directory
+ * PROJECT:           ReactOS Run-Time Library
+ * PURPOSE:           Debug Routines
+ * FILE:              lib/rtl/arm/debug_asm.S
+ */
+
+/* GLOBALS ********************************************************************/
+
+.globl DbgBreakPoint
+
+/* FUNCTIONS ******************************************************************/
+
+.func DbgBreakPoint
+DbgBreakPoint:
+    bkpt 3
+    bx lr
+.endfunc
index 673703b..7fae202 100644 (file)
                <file>rtlswap.s</file>
                <file>thread.c</file>
        </directory>
+       </if>
+       <if property="ARCH" value="arm">
+               <directory name="arm">
+                       <file>debug_asm.S</file>
+               </directory>
        </if>
        <directory name="austin">
                <file>avl.c</file>