From 81cd907fc7553aed2d2aaaa002d8e37e652daef2 Mon Sep 17 00:00:00 2001 From: ReactOS Portable Systems Group Date: Tue, 5 Feb 2008 11:08:34 +0000 Subject: [PATCH] Implement ARM version of DbgBreakPoint in the RTL. We do a bkpt with a special value of 3 (to be as close as possible to x86 int 3). 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 | 58 +++++++++++++++++-------------- reactos/include/psdk/winnt.h | 18 +++++++++- reactos/lib/rtl/arm/debug_asm.S | 18 ++++++++++ reactos/lib/rtl/rtl.rbuild | 5 +++ 4 files changed, 72 insertions(+), 27 deletions(-) create mode 100644 reactos/lib/rtl/arm/debug_asm.S diff --git a/reactos/include/ndk/arm/ketypes.h b/reactos/include/ndk/arm/ketypes.h index d374e2a00a2..4ddd0745172 100644 --- a/reactos/include/ndk/arm/ketypes.h +++ b/reactos/include/ndk/arm/ketypes.h @@ -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 // diff --git a/reactos/include/psdk/winnt.h b/reactos/include/psdk/winnt.h index 9835cd6cb61..03333f1927e 100644 --- a/reactos/include/psdk/winnt.h +++ b/reactos/include/psdk/winnt.h @@ -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 + +// +// 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 index 00000000000..efa9383db47 --- /dev/null +++ b/reactos/lib/rtl/arm/debug_asm.S @@ -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 diff --git a/reactos/lib/rtl/rtl.rbuild b/reactos/lib/rtl/rtl.rbuild index 673703bc2e2..7fae2021b0e 100644 --- a/reactos/lib/rtl/rtl.rbuild +++ b/reactos/lib/rtl/rtl.rbuild @@ -28,6 +28,11 @@ rtlswap.s thread.c + + + + debug_asm.S + avl.c