3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #ifndef __NTOSKRNL_INCLUDE_INTERNAL_I386_PS_H
20 #define __NTOSKRNL_INCLUDE_INTERNAL_I386_PS_H
23 * Defines for accessing KPCR and KTHREAD structure members
25 #define KTHREAD_INITIAL_STACK 0x18
26 #define KTHREAD_STACK_LIMIT 0x1C
27 #define KTHREAD_TEB 0x20
28 #define KTHREAD_KERNEL_STACK 0x28
29 #define KTHREAD_SERVICE_TABLE 0xDC
30 #define KTHREAD_PREVIOUS_MODE 0x137
31 #define KTHREAD_TRAP_FRAME 0x128
32 #define KTHREAD_CALLBACK_STACK 0x120
34 #define ETHREAD_THREADS_PROCESS 0x234
36 #define KPROCESS_DIRECTORY_TABLE_BASE 0x18
37 #define KPROCESS_LDT_DESCRIPTOR0 0x20
38 #define KPROCESS_LDT_DESCRIPTOR1 0x24
39 #define KPROCESS_IOPM_OFFSET 0x30
41 #define KPCR_BASE 0xFF000000
43 #define KPCR_EXCEPTION_LIST 0x0
44 #define KPCR_SELF 0x18
46 #define KPCR_CURRENT_THREAD 0x124
55 * Processor Control Region Thread Information Block
57 typedef struct _KPCR_TIB {
58 PVOID ExceptionList; /* 00 */
59 PVOID StackBase; /* 04 */
60 PVOID StackLimit; /* 08 */
61 PVOID SubSystemTib; /* 0C */
63 PVOID FiberData; /* 10 */
64 DWORD Version; /* 10 */
66 PVOID ArbitraryUserPointer; /* 14 */
67 } KPCR_TIB, *PKPCR_TIB; /* 18 */
69 typedef struct _KPCR {
70 KPCR_TIB Tib; /* 00 */
71 struct _KPCR *Self; /* 18 */
72 struct _KPRCB *PCRCB; /* 1C */
75 ULONG IrrActive; /* 28 */
77 PVOID KdVersionBlock; /* 30 */
80 struct _KTSS *TSS; /* 3C */
81 USHORT MajorVersion; /* 40 */
82 USHORT MinorVersion; /* 42 */
83 KAFFINITY SetMember; /* 44 */
84 ULONG StallScaleFactor; /* 48 */
85 UCHAR DebugActive; /* 4C */
86 UCHAR ProcessorNumber; /* 4D */
87 UCHAR Reserved[2]; /* 4E */
92 typedef struct _KPCR *PKPCR;
94 #endif /* __USE_W32API */
99 * Processor Control Region
100 * The first part of this structure must match the KPCR structure in w32api
102 typedef struct _IKPCR {
103 KPCR_TIB Tib; /* 00 */
104 struct _KPCR *Self; /* 18 */
105 struct _KPRCB *PCRCB; /* 1C */
108 ULONG IrrActive; /* 28 */
110 PVOID KdVersionBlock; /* 30 */
111 PUSHORT IDT; /* 34 */
112 PUSHORT GDT; /* 38 */
113 struct _KTSS *TSS; /* 3C */
114 USHORT MajorVersion; /* 40 */
115 USHORT MinorVersion; /* 42 */
116 KAFFINITY SetMember; /* 44 */
117 ULONG StallScaleFactor; /* 48 */
118 UCHAR DebugActive; /* 4C */
119 UCHAR ProcessorNumber; /* 4D */
120 UCHAR Reserved[2]; /* 4E */
121 UCHAR Reserved2[0xD4]; /* 50 */
122 struct _KTHREAD* CurrentThread; /* 124 */
129 static inline PKPCR KeGetCurrentKPCR(VOID)
133 __asm__ __volatile__ ("movl %%fs:0x18, %0\n\t"
137 return((PKPCR)value);
140 #endif /* __USE_W32API */
143 Ki386ContextSwitch(struct _KTHREAD* NewThread,
144 struct _KTHREAD* OldThread);
146 Ke386InitThread(struct _KTHREAD* Thread, PKSTART_ROUTINE fn,
149 Ke386InitThreadWithContext(struct _KTHREAD* Thread, PCONTEXT Context);
151 Ki386ValidateUserContext(PCONTEXT Context);
155 #endif /* __NTOSKRNL_INCLUDE_INTERNAL_I386_PS_H */