//
#define SSDT_MAX_ENTRIES 2
+//
+// Processor Architectures
+//
+#define PROCESSOR_ARCHITECTURE_INTEL 0
+
//
// Object Type Mask for Kernel Dispatcher Objects
//
#define KOBJECT_TYPE_MASK 0x7F
+#define KOBJECT_LOCK_BIT 0x80
//
// Dispatcher Priority increments
//
#define KI_USER_SHARED_DATA_PHYSICAL 0x41000
+//
+// Quantum values and decrements
+//
+#define MAX_QUANTUM 0x7F
+#define WAIT_QUANTUM_DECREMENT 1
+#define CLOCK_QUANTUM_DECREMENT 3
+
//
// Kernel Feature Bits
//
+#define KF_V86_VIS 0x00000001
#define KF_RDTSC 0x00000002
+#define KF_CR4 0x00000004
+#define KF_CMOV 0x00000008
+#define KF_GLOBAL_PAGE 0x00000010
+#define KF_LARGE_PAGE 0x00000020
+#define KF_MTRR 0x00000040
+#define KF_CMPXCHG8B 0x00000080
+#define KF_MMX 0x00000100
+#define KF_WORKING_PTE 0x00000200
+#define KF_PAT 0x00000400
+#define KF_FXSR 0x00000800
+#define KF_FAST_SYSCALL 0x00001000
+#define KF_XMMI 0x00002000
+#define KF_3DNOW 0x00004000
+#define KF_AMDK6MTRR 0x00008000
+#define KF_XMMI64 0x00010000
+#define KF_DTS 0x00020000
+#define KF_NX_BIT 0x20000000
+#define KF_NX_DISABLED 0x40000000
+#define KF_NX_ENABLED 0x80000000
+
+//
+// Internal Exception Codes
+//
+#define KI_EXCEPTION_INTERNAL 0x10000000
+#define KI_EXCEPTION_ACCESS_VIOLATION (KI_EXCEPTION_INTERNAL | 0x04)
//
// KPCR Access for non-IA64 builds
//
#define K0IPCR ((ULONG_PTR)(KIP0PCRADDRESS))
#define PCR ((volatile KPCR * const)K0IPCR)
+#if !defined(CONFIG_SMP) && !defined(NT_BUILD)
#define KeGetPcr() PCR
+#else
+#define KeGetPcr() ((volatile KPCR * const)__readfsdword(0x1C))
+#endif
//
// Number of dispatch codes supported by KINTERRUPT
#endif
} KTHREAD_STATE, *PKTHREAD_STATE;
+//
+// Adjust reasons
+//
+typedef enum _ADJUST_REASON
+{
+ AdjustNone = 0,
+ AdjustUnwait = 1,
+ AdjustBoost = 2
+} ADJUST_REASON;
+
+//
+// Continue Status
+//
+typedef enum _KCONTINUE_STATUS
+{
+ ContinueError = 0,
+ ContinueSuccess,
+ ContinueProcessorReselected,
+ ContinueNextProcessor
+} KCONTINUE_STATUS;
+
//
// Process States
//
{
OriginalApcEnvironment,
AttachedApcEnvironment,
- CurrentApcEnvironment
+ CurrentApcEnvironment,
+ InsertApcEnvironment
} KAPC_ENVIRONMENT;
//
{
LIST_ENTRY DpcListHead;
ULONG DpcLock;
- ULONG DpcQueueDepth;
+ volatile ULONG DpcQueueDepth;
ULONG DpcCount;
} KDPC_DATA, *PKDPC_DATA;
//
// Kernel Thread (KTHREAD)
//
-#include <pshpack1.h>
typedef struct _KTHREAD
{
DISPATCHER_HEADER DispatcherHeader;
{
UCHAR ApcStateFill[23];
UCHAR ApcQueueable;
+ volatile UCHAR NextProcessor;
+ volatile UCHAR DeferredProcessor;
+ UCHAR AdjustReason;
+ SCHAR AdjustIncrement;
};
};
- UCHAR NextProcessor;
- UCHAR DeferredProcessor;
- UCHAR AdjustReason;
- UCHAR AdjustIncrement;
KSPIN_LOCK ApcQueueLock;
ULONG ContextSwitches;
- UCHAR State;
+ volatile UCHAR State;
UCHAR NpxState;
- UCHAR WaitIrql;
- UCHAR WaitMode;
- LONG WaitStatus;
+ KIRQL WaitIrql;
+ KPROCESSOR_MODE WaitMode;
+ LONG_PTR WaitStatus;
union
{
PKWAIT_BLOCK WaitBlockList;
PKGATE GateObject;
};
- UCHAR Alertable;
- UCHAR WaitNext;
+ BOOLEAN Alertable;
+ BOOLEAN WaitNext;
UCHAR WaitReason;
- UCHAR Priority;
- UCHAR EnableStackSwap;
- UCHAR SwapBusy;
- UCHAR Alerted[2];
+ SCHAR Priority;
+ BOOLEAN EnableStackSwap;
+ volatile UCHAR SwapBusy;
+ BOOLEAN Alerted[MaximumMode];
union
{
LIST_ENTRY WaitListEntry;
{
struct
{
- USHORT KernelApcDisable;
- USHORT SpecialApcDisable;
+ SHORT KernelApcDisable;
+ SHORT SpecialApcDisable;
};
ULONG CombinedApcDisable;
};
union
{
KTIMER Timer;
- UCHAR TimerFill[40];
- };
- union
- {
struct
{
- LONG AutoAlignment:1;
- LONG DisableBoost:1;
+ UCHAR TimerFill[40];
+ union
+ {
+ struct
+ {
+ LONG AutoAlignment:1;
+ LONG DisableBoost:1;
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
- LONG EtwStackTrace1ApcInserted:1;
- LONG EtwStackTrace2ApcInserted:1;
- LONG CycleChargePending:1;
- LONG ReservedFlags:27;
+ LONG EtwStackTrace1ApcInserted:1;
+ LONG EtwStackTrace2ApcInserted:1;
+ LONG CycleChargePending:1;
+ LONG ReservedFlags:27;
#else
- LONG ReservedFlags:30;
+ LONG ReservedFlags:30;
#endif
+ };
+ LONG ThreadFlags;
+ };
};
- LONG ThreadFlags;
};
- PVOID Padding;
union
{
- KWAIT_BLOCK WaitBlock[4];
- union
+ KWAIT_BLOCK WaitBlock[THREAD_WAIT_OBJECTS + 1];
+ struct
{
- struct
- {
- UCHAR WaitBlockFill0[23];
- UCHAR SystemAffinityActive;
- };
- struct
- {
- UCHAR WaitBlockFill1[47];
- UCHAR PreviousMode;
- };
- struct
- {
- UCHAR WaitBlockFill2[71];
- UCHAR ResourceIndex;
- };
- struct
- {
- UCHAR WaitBlockFill3[95];
- UCHAR LargeStack;
- };
+ UCHAR WaitBlockFill0[23];
+ BOOLEAN SystemAffinityActive;
+ };
+ struct
+ {
+ UCHAR WaitBlockFill1[47];
+ CCHAR PreviousMode;
+ };
+ struct
+ {
+ UCHAR WaitBlockFill2[71];
+ UCHAR ResourceIndex;
+ };
+ struct
+ {
+ UCHAR WaitBlockFill3[95];
+ UCHAR LargeStack;
};
};
LIST_ENTRY QueueListEntry;
PVOID ServiceTable;
UCHAR ApcStateIndex;
UCHAR IdealProcessor;
- UCHAR Preempted;
+ BOOLEAN Preempted;
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
- UCHAR CalloutActive;
+ BOOLEAN CalloutActive;
#else
- UCHAR ProcessReadyQueue;
+ BOOLEAN ProcessReadyQueue;
#endif
- UCHAR KernelStackResident;
- CHAR BasePriority;
- CHAR PriorityDecrement;
+ BOOLEAN KernelStackResident;
+ SCHAR BasePriority;
+ SCHAR PriorityDecrement;
CHAR Saturation;
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
ULONG SystemCallNumber;
union
{
KAPC_STATE SavedApcState;
- union
+ struct
{
UCHAR SavedApcStateFill[23];
- CHAR FreezeCount;
- };
- };
- CHAR SuspendCount;
- UCHAR UserIdealProcessor;
+ CCHAR FreezeCount;
+ CCHAR SuspendCount;
+ UCHAR UserIdealProcessor;
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
- union
- {
- struct
- {
- UCHAR ReservedBits0:1;
- UCHAR SegmentsPresent:1;
- UCHAR Reservedbits1:1;
- };
- UCHAR NestedStateFlags;
- };
+ union
+ {
+ struct
+ {
+ UCHAR ReservedBits0:1;
+ UCHAR SegmentsPresent:1;
+ UCHAR Reservedbits1:1;
+ };
+ UCHAR NestedStateFlags;
+ };
#else
- UCHAR CalloutActive;
+ UCHAR CalloutActive;
#endif
- UCHAR Iopl;
+ UCHAR Iopl;
+ };
+ };
PVOID Win32Thread;
PVOID StackBase;
union
struct
{
UCHAR SuspendApcFill0[1];
- CHAR Quantum;
+ SCHAR Quantum;
};
struct
{
{
UCHAR SuspendApcFill5[47];
UCHAR PowerState;
+ ULONG UserTime;
};
};
- ULONG UserTime;
union
{
KSEMAPHORE SuspendSemaphore;
- UCHAR SuspendSemaphorefill[20];
+ struct
+ {
+ UCHAR SuspendSemaphorefill[20];
+ ULONG SListFaultCount;
+ };
};
- ULONG SListFaultCount;
LIST_ENTRY ThreadListEntry;
#if (NTDDI_VERSION >= NTDDI_LONGHORN)
LIST_ENTRY MutantListHead;
PVOID MdlForLockedteb;
#endif
} KTHREAD;
-#include <poppack.h>
+
+#define ASSERT_THREAD(object) \
+ ASSERT((((object)->DispatcherHeader.Type & KOBJECT_TYPE_MASK) == ThreadObject))
//
// Kernel Process (KPROCESS)
{
DISPATCHER_HEADER Header;
LIST_ENTRY ProfileListHead;
- PHYSICAL_ADDRESS DirectoryTableBase;
+ LARGE_INTEGER DirectoryTableBase;
#if defined(_M_IX86)
KGDTENTRY LdtDescriptor;
KIDTENTRY Int21Descriptor;
UCHAR Iopl;
UCHAR Unused;
#endif
- ULONG ActiveProcessors;
+ volatile ULONG ActiveProcessors;
ULONG KernelTime;
ULONG UserTime;
LIST_ENTRY ReadyListHead;
{
struct
{
- ULONG AutoAlignment:1;
- ULONG DisableBoost:1;
- ULONG DisableQuantum:1;
- ULONG ReservedFlags:29;
+ LONG AutoAlignment:1;
+ LONG DisableBoost:1;
+ LONG DisableQuantum:1;
+ LONG ReservedFlags:29;
};
- ULONG ProcessFlags;
+ LONG ProcessFlags;
};
- CHAR BasePriority;
- CHAR QuantumReset;
+ SCHAR BasePriority;
+ SCHAR QuantumReset;
UCHAR State;
UCHAR ThreadSeed;
UCHAR PowerState;
union
{
KEXECUTE_OPTIONS Flags;
-#if (NTDDI_VERSION >= NTDDI_LONGHORN)
UCHAR ExecuteOptions;
-#endif
};
ULONG StackCount;
LIST_ENTRY ProcessListEntry;
#endif
} KPROCESS, *PKPROCESS;
+#define ASSERT_PROCESS(object) \
+ ASSERT((((object)->Header.Type & KOBJECT_TYPE_MASK) == ProcessObject))
+
//
// System Service Table Descriptor
//
//
// Exported Loader Parameter Block
//
-#ifndef _REACTOS_
extern struct _LOADER_PARAMETER_BLOCK NTSYSAPI *KeLoaderBlock;
-#else
-extern struct _ROS_LOADER_PARAMETER_BLOCK NTSYSAPI KeLoaderBlock;
-#endif
//
// Exported Hardware Data
//
extern KAFFINITY NTSYSAPI KeActiveProcessors;
-extern CHAR NTSYSAPI KeNumberProcessors;
+#if (NTDDI_VERSION >= NTDDI_LONGHORN)
+extern volatile CCHAR NTSYSAPI KeNumberProcessors;
+#else
+#if (NTDDI_VERSION >= NTDDI_WINXP)
+extern CCHAR NTSYSAPI KeNumberProcessors;
+#else
+//extern PCCHAR KeNumberProcessors;
+extern NTSYSAPI CCHAR KeNumberProcessors; //FIXME: Note to Alex: I won't fix this atm, since I prefer to discuss this with you first.
+#endif
+#endif
extern ULONG NTSYSAPI KiDmaIoCoherency;
extern ULONG NTSYSAPI KeMaximumIncrement;
extern ULONG NTSYSAPI KeMinimumIncrement;