mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 07:55:56 +00:00
- move CONTEXT stuff from wdm.h to winddk.h / armddk.h
- inlcude intrin.h in wdm.h - avoid redefining PCONTEXT - use intrinsics for BitScanForward/Reverse svn path=/trunk/; revision=37902
This commit is contained in:
parent
72d7ea8bc3
commit
d610c156c6
4 changed files with 111 additions and 150 deletions
|
@ -9,7 +9,11 @@
|
||||||
#include <ntdef.h>
|
#include <ntdef.h>
|
||||||
#include <ntstatus.h>
|
#include <ntstatus.h>
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#include "intrin.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct _CONTEXT *PCONTEXT;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Resource list definitions
|
// Resource list definitions
|
||||||
|
@ -582,131 +586,6 @@ typedef struct _SE_IMPERSONATION_STATE {
|
||||||
#define SERVICE_DEMAND_START 0x00000003
|
#define SERVICE_DEMAND_START 0x00000003
|
||||||
#define SERVICE_DISABLED 0x00000004
|
#define SERVICE_DISABLED 0x00000004
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Architecture Defined Contexts
|
|
||||||
//
|
|
||||||
#if defined(_M_IX86)
|
|
||||||
#define SIZE_OF_80387_REGISTERS 80
|
|
||||||
#define CONTEXT_i386 0x10000
|
|
||||||
#define CONTEXT_i486 0x10000
|
|
||||||
#define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L)
|
|
||||||
#define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L)
|
|
||||||
#define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L)
|
|
||||||
#define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L)
|
|
||||||
#define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L)
|
|
||||||
#define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L)
|
|
||||||
#define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS)
|
|
||||||
#define MAXIMUM_SUPPORTED_EXTENSION 512
|
|
||||||
|
|
||||||
#define EXCEPTION_READ_FAULT 0
|
|
||||||
#define EXCEPTION_WRITE_FAULT 1
|
|
||||||
#define EXCEPTION_EXECUTE_FAULT 8
|
|
||||||
|
|
||||||
typedef struct _FLOATING_SAVE_AREA {
|
|
||||||
ULONG ControlWord;
|
|
||||||
ULONG StatusWord;
|
|
||||||
ULONG TagWord;
|
|
||||||
ULONG ErrorOffset;
|
|
||||||
ULONG ErrorSelector;
|
|
||||||
ULONG DataOffset;
|
|
||||||
ULONG DataSelector;
|
|
||||||
UCHAR RegisterArea[SIZE_OF_80387_REGISTERS];
|
|
||||||
ULONG Cr0NpxState;
|
|
||||||
} FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
|
|
||||||
|
|
||||||
typedef struct _CONTEXT {
|
|
||||||
ULONG ContextFlags;
|
|
||||||
ULONG Dr0;
|
|
||||||
ULONG Dr1;
|
|
||||||
ULONG Dr2;
|
|
||||||
ULONG Dr3;
|
|
||||||
ULONG Dr6;
|
|
||||||
ULONG Dr7;
|
|
||||||
FLOATING_SAVE_AREA FloatSave;
|
|
||||||
ULONG SegGs;
|
|
||||||
ULONG SegFs;
|
|
||||||
ULONG SegEs;
|
|
||||||
ULONG SegDs;
|
|
||||||
ULONG Edi;
|
|
||||||
ULONG Esi;
|
|
||||||
ULONG Ebx;
|
|
||||||
ULONG Edx;
|
|
||||||
ULONG Ecx;
|
|
||||||
ULONG Eax;
|
|
||||||
ULONG Ebp;
|
|
||||||
ULONG Eip;
|
|
||||||
ULONG SegCs;
|
|
||||||
ULONG EFlags;
|
|
||||||
ULONG Esp;
|
|
||||||
ULONG SegSs;
|
|
||||||
UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
|
|
||||||
} CONTEXT, *PCONTEXT;
|
|
||||||
|
|
||||||
#elif defined(_M_AMD64)
|
|
||||||
#error FIXME-TODO: 64-bit
|
|
||||||
#elif defined(_M_ARM)
|
|
||||||
|
|
||||||
//
|
|
||||||
// FIXME: Move to armddk.h?
|
|
||||||
//
|
|
||||||
|
|
||||||
/* The following flags control the contents of the CONTEXT structure. */
|
|
||||||
|
|
||||||
#define CONTEXT_ARM 0x0000040
|
|
||||||
#define CONTEXT_CONTROL (CONTEXT_ARM | 0x00000001L)
|
|
||||||
#define CONTEXT_INTEGER (CONTEXT_ARM | 0x00000002L)
|
|
||||||
|
|
||||||
#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
|
|
||||||
|
|
||||||
typedef struct _CONTEXT {
|
|
||||||
/* The flags values within this flag control the contents of
|
|
||||||
a CONTEXT record.
|
|
||||||
|
|
||||||
If the context record is used as an input parameter, then
|
|
||||||
for each portion of the context record controlled by a flag
|
|
||||||
whose value is set, it is assumed that that portion of the
|
|
||||||
context record contains valid context. If the context record
|
|
||||||
is being used to modify a thread's context, then only that
|
|
||||||
portion of the threads context will be modified.
|
|
||||||
|
|
||||||
If the context record is used as an IN OUT parameter to capture
|
|
||||||
the context of a thread, then only those portions of the thread's
|
|
||||||
context corresponding to set flags will be returned.
|
|
||||||
|
|
||||||
The context record is never used as an OUT only parameter. */
|
|
||||||
|
|
||||||
ULONG ContextFlags;
|
|
||||||
|
|
||||||
/* This section is specified/returned if the ContextFlags word contains
|
|
||||||
the flag CONTEXT_INTEGER. */
|
|
||||||
ULONG R0;
|
|
||||||
ULONG R1;
|
|
||||||
ULONG R2;
|
|
||||||
ULONG R3;
|
|
||||||
ULONG R4;
|
|
||||||
ULONG R5;
|
|
||||||
ULONG R6;
|
|
||||||
ULONG R7;
|
|
||||||
ULONG R8;
|
|
||||||
ULONG R9;
|
|
||||||
ULONG R10;
|
|
||||||
ULONG R11;
|
|
||||||
ULONG R12;
|
|
||||||
|
|
||||||
ULONG Sp;
|
|
||||||
ULONG Lr;
|
|
||||||
ULONG Pc;
|
|
||||||
ULONG Psr;
|
|
||||||
} CONTEXT, *PCONTEXT;
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error "Undefined processor architecture"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Exception Records
|
// Exception Records
|
||||||
//
|
//
|
||||||
|
|
|
@ -215,6 +215,10 @@ struct _COMPRESSED_DATA_INFO;
|
||||||
#define KERNEL_LARGE_STACK_SIZE 61440
|
#define KERNEL_LARGE_STACK_SIZE 61440
|
||||||
#define KERNEL_LARGE_STACK_COMMIT 12288
|
#define KERNEL_LARGE_STACK_COMMIT 12288
|
||||||
|
|
||||||
|
#define EXCEPTION_READ_FAULT 0
|
||||||
|
#define EXCEPTION_WRITE_FAULT 1
|
||||||
|
#define EXCEPTION_EXECUTE_FAULT 8
|
||||||
|
|
||||||
#define DPFLTR_ERROR_LEVEL 0
|
#define DPFLTR_ERROR_LEVEL 0
|
||||||
#define DPFLTR_WARNING_LEVEL 1
|
#define DPFLTR_WARNING_LEVEL 1
|
||||||
#define DPFLTR_TRACE_LEVEL 2
|
#define DPFLTR_TRACE_LEVEL 2
|
||||||
|
@ -5448,6 +5452,58 @@ typedef VOID
|
||||||
|
|
||||||
#ifdef _X86_
|
#ifdef _X86_
|
||||||
|
|
||||||
|
#define SIZE_OF_80387_REGISTERS 80
|
||||||
|
#define CONTEXT_i386 0x10000
|
||||||
|
#define CONTEXT_i486 0x10000
|
||||||
|
#define CONTEXT_CONTROL (CONTEXT_i386|0x00000001L)
|
||||||
|
#define CONTEXT_INTEGER (CONTEXT_i386|0x00000002L)
|
||||||
|
#define CONTEXT_SEGMENTS (CONTEXT_i386|0x00000004L)
|
||||||
|
#define CONTEXT_FLOATING_POINT (CONTEXT_i386|0x00000008L)
|
||||||
|
#define CONTEXT_DEBUG_REGISTERS (CONTEXT_i386|0x00000010L)
|
||||||
|
#define CONTEXT_EXTENDED_REGISTERS (CONTEXT_i386|0x00000020L)
|
||||||
|
#define CONTEXT_FULL (CONTEXT_CONTROL|CONTEXT_INTEGER|CONTEXT_SEGMENTS)
|
||||||
|
#define MAXIMUM_SUPPORTED_EXTENSION 512
|
||||||
|
|
||||||
|
typedef struct _FLOATING_SAVE_AREA {
|
||||||
|
ULONG ControlWord;
|
||||||
|
ULONG StatusWord;
|
||||||
|
ULONG TagWord;
|
||||||
|
ULONG ErrorOffset;
|
||||||
|
ULONG ErrorSelector;
|
||||||
|
ULONG DataOffset;
|
||||||
|
ULONG DataSelector;
|
||||||
|
UCHAR RegisterArea[SIZE_OF_80387_REGISTERS];
|
||||||
|
ULONG Cr0NpxState;
|
||||||
|
} FLOATING_SAVE_AREA, *PFLOATING_SAVE_AREA;
|
||||||
|
|
||||||
|
typedef struct _CONTEXT {
|
||||||
|
ULONG ContextFlags;
|
||||||
|
ULONG Dr0;
|
||||||
|
ULONG Dr1;
|
||||||
|
ULONG Dr2;
|
||||||
|
ULONG Dr3;
|
||||||
|
ULONG Dr6;
|
||||||
|
ULONG Dr7;
|
||||||
|
FLOATING_SAVE_AREA FloatSave;
|
||||||
|
ULONG SegGs;
|
||||||
|
ULONG SegFs;
|
||||||
|
ULONG SegEs;
|
||||||
|
ULONG SegDs;
|
||||||
|
ULONG Edi;
|
||||||
|
ULONG Esi;
|
||||||
|
ULONG Ebx;
|
||||||
|
ULONG Edx;
|
||||||
|
ULONG Ecx;
|
||||||
|
ULONG Eax;
|
||||||
|
ULONG Ebp;
|
||||||
|
ULONG Eip;
|
||||||
|
ULONG SegCs;
|
||||||
|
ULONG EFlags;
|
||||||
|
ULONG Esp;
|
||||||
|
ULONG SegSs;
|
||||||
|
UCHAR ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
|
||||||
|
} CONTEXT;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Types to use to contain PFNs and their counts.
|
// Types to use to contain PFNs and their counts.
|
||||||
//
|
//
|
||||||
|
|
|
@ -2229,7 +2229,7 @@ typedef struct DECLSPEC_ALIGN(16) _CONTEXT {
|
||||||
DWORD64 LastBranchFromRip;
|
DWORD64 LastBranchFromRip;
|
||||||
DWORD64 LastExceptionToRip;
|
DWORD64 LastExceptionToRip;
|
||||||
DWORD64 LastExceptionFromRip;
|
DWORD64 LastExceptionFromRip;
|
||||||
} CONTEXT, *PCONTEXT;
|
} CONTEXT;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
|
typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
|
||||||
|
@ -2299,7 +2299,7 @@ typedef struct _KNONVOLATILE_CONTEXT_POINTERS {
|
||||||
NTSYSAPI
|
NTSYSAPI
|
||||||
VOID
|
VOID
|
||||||
__cdecl
|
__cdecl
|
||||||
RtlRestoreContext(PCONTEXT ContextRecord,
|
RtlRestoreContext(struct _CONTEXT *ContextRecord,
|
||||||
struct _EXCEPTION_RECORD *ExceptionRecord);
|
struct _EXCEPTION_RECORD *ExceptionRecord);
|
||||||
|
|
||||||
NTSYSAPI
|
NTSYSAPI
|
||||||
|
@ -4796,29 +4796,8 @@ InterlockedBitTestAndReset(IN LONG volatile *Base,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ BOOLEAN
|
#define BitScanForward _BitScanForward
|
||||||
BitScanReverse(OUT ULONG *Index,
|
#define BitScanReverse _BitScanReverse
|
||||||
IN ULONG Mask)
|
|
||||||
{
|
|
||||||
BOOLEAN BitPosition = 0;
|
|
||||||
#if defined(_M_IX86)
|
|
||||||
__asm__ __volatile__("bsrl %2,%0\n\t"
|
|
||||||
"setnz %1\n\t"
|
|
||||||
:"=&r" (*Index), "=q" (BitPosition)
|
|
||||||
:"rm" (Mask)
|
|
||||||
:"memory");
|
|
||||||
return BitPosition;
|
|
||||||
#else
|
|
||||||
/* Slow implementation for now */
|
|
||||||
for( *Index = 31; *Index; (*Index)-- ) {
|
|
||||||
if( (1<<*Index) & Mask ) {
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,53 @@ typedef struct _KFLOATING_SAVE
|
||||||
ULONG Reserved;
|
ULONG Reserved;
|
||||||
} KFLOATING_SAVE, *PKFLOATING_SAVE;
|
} KFLOATING_SAVE, *PKFLOATING_SAVE;
|
||||||
|
|
||||||
|
/* The following flags control the contents of the CONTEXT structure. */
|
||||||
|
#define CONTEXT_ARM 0x0000040
|
||||||
|
#define CONTEXT_CONTROL (CONTEXT_ARM | 0x00000001L)
|
||||||
|
#define CONTEXT_INTEGER (CONTEXT_ARM | 0x00000002L)
|
||||||
|
#define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER)
|
||||||
|
|
||||||
|
typedef struct _CONTEXT {
|
||||||
|
/* The flags values within this flag control the contents of
|
||||||
|
a CONTEXT record.
|
||||||
|
|
||||||
|
If the context record is used as an input parameter, then
|
||||||
|
for each portion of the context record controlled by a flag
|
||||||
|
whose value is set, it is assumed that that portion of the
|
||||||
|
context record contains valid context. If the context record
|
||||||
|
is being used to modify a thread's context, then only that
|
||||||
|
portion of the threads context will be modified.
|
||||||
|
|
||||||
|
If the context record is used as an IN OUT parameter to capture
|
||||||
|
the context of a thread, then only those portions of the thread's
|
||||||
|
context corresponding to set flags will be returned.
|
||||||
|
|
||||||
|
The context record is never used as an OUT only parameter. */
|
||||||
|
|
||||||
|
ULONG ContextFlags;
|
||||||
|
|
||||||
|
/* This section is specified/returned if the ContextFlags word contains
|
||||||
|
the flag CONTEXT_INTEGER. */
|
||||||
|
ULONG R0;
|
||||||
|
ULONG R1;
|
||||||
|
ULONG R2;
|
||||||
|
ULONG R3;
|
||||||
|
ULONG R4;
|
||||||
|
ULONG R5;
|
||||||
|
ULONG R6;
|
||||||
|
ULONG R7;
|
||||||
|
ULONG R8;
|
||||||
|
ULONG R9;
|
||||||
|
ULONG R10;
|
||||||
|
ULONG R11;
|
||||||
|
ULONG R12;
|
||||||
|
|
||||||
|
ULONG Sp;
|
||||||
|
ULONG Lr;
|
||||||
|
ULONG Pc;
|
||||||
|
ULONG Psr;
|
||||||
|
} CONTEXT;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Processor Control Region
|
// Processor Control Region
|
||||||
// On ARM, it's actually readable from user-mode, much like KUSER_SHARED_DATA
|
// On ARM, it's actually readable from user-mode, much like KUSER_SHARED_DATA
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue