Remove mouse type selection in usetup.
[reactos.git] / reactos / ntoskrnl / include / internal / i386 / ps.h
1 /*
2 * ReactOS kernel
3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
4 *
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.
9 *
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.
14 *
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.
18 */
19 #ifndef __NTOSKRNL_INCLUDE_INTERNAL_I386_PS_H
20 #define __NTOSKRNL_INCLUDE_INTERNAL_I386_PS_H
21
22 #ifdef __USE_W32API
23 #ifndef __ASM__
24 #include <ndk/potypes.h> /* FIXME: TEMP HACK */
25 #endif
26 #endif
27
28 /*
29 * Defines for accessing KPCR and KTHREAD structure members
30 */
31 #define KTHREAD_INITIAL_STACK 0x18
32 #define KTHREAD_STACK_LIMIT 0x1C
33 #define KTHREAD_TEB 0x20
34 #define KTHREAD_KERNEL_STACK 0x28
35 #define KTHREAD_NPX_STATE 0x31
36 #define KTHREAD_STATE 0x2D
37 #define KTHREAD_APCSTATE_PROCESS 0x34 + 0x10
38 #define KTHREAD_PENDING_USER_APC 0x34 + 0x16
39 #define KTHREAD_PENDING_KERNEL_APC 0x34 + 0x15
40 #define KTHREAD_CONTEXT_SWITCHES 0x4C
41 #define KTHREAD_WAIT_IRQL 0x54
42 #define KTHREAD_SERVICE_TABLE 0xDC
43 #define KTHREAD_PREVIOUS_MODE 0x137
44 #define KTHREAD_TRAP_FRAME 0x128
45 #define KTHREAD_CALLBACK_STACK 0x120
46
47
48 #define KPROCESS_DIRECTORY_TABLE_BASE 0x18
49 #define KPROCESS_LDT_DESCRIPTOR0 0x20
50 #define KPROCESS_LDT_DESCRIPTOR1 0x24
51 #define KPROCESS_IOPM_OFFSET 0x30
52
53 #define KPCR_BASE 0xFF000000
54
55 #define KPCR_EXCEPTION_LIST 0x0
56 #define KPCR_INITIAL_STACK 0x4
57 #define KPCR_STACK_LIMIT 0x8
58 #define KPCR_SELF 0x1C
59 #define KPCR_GDT 0x3C
60 #define KPCR_TSS 0x40
61 #define KPCR_CURRENT_THREAD 0x124
62 #define KPCR_NPX_THREAD 0x2A4
63
64 #ifndef __ASM__
65
66 #include "fpu.h"
67
68 #pragma pack(push,4)
69
70 /* Fixme: Use correct types? */
71 typedef struct _KPROCESSOR_STATE {
72 PCONTEXT ContextFrame;
73 PVOID SpecialRegisters;
74 } KPROCESSOR_STATE;
75
76 /* ProcessoR Control Block */
77 typedef struct _KPRCB {
78 USHORT MinorVersion;
79 USHORT MajorVersion;
80 struct _KTHREAD *CurrentThread;
81 struct _KTHREAD *NextThread;
82 struct _KTHREAD *IdleThread;
83 UCHAR Number;
84 UCHAR Reserved;
85 USHORT BuildType;
86 ULONG SetMember;
87 UCHAR CpuType;
88 UCHAR CpuID;
89 USHORT CpuStep;
90 KPROCESSOR_STATE ProcessorState;
91 ULONG KernelReserved[16];
92 ULONG HalReserved[16];
93 UCHAR PrcbPad0[92];
94 PVOID LockQueue[33]; // Used for Queued Spinlocks
95 struct _KTHREAD *NpxThread;
96 ULONG InterruptCount;
97 ULONG KernelTime;
98 ULONG UserTime;
99 ULONG DpcTime;
100 ULONG DebugDpcTime;
101 ULONG InterruptTime;
102 ULONG AdjustDpcThreshold;
103 ULONG PageColor;
104 UCHAR SkipTick;
105 UCHAR DebuggerSavedIRQL;
106 UCHAR Spare1[6];
107 struct _KNODE *ParentNode;
108 ULONG MultiThreadProcessorSet;
109 struct _KPRCB *MultiThreadSetMaster;
110 ULONG ThreadStartCount[2];
111 ULONG CcFastReadNoWait;
112 ULONG CcFastReadWait;
113 ULONG CcFastReadNotPossible;
114 ULONG CcCopyReadNoWait;
115 ULONG CcCopyReadWait;
116 ULONG CcCopyReadNoWaitMiss;
117 ULONG KeAlignmentFixupCount;
118 ULONG KeContextSwitches;
119 ULONG KeDcacheFlushCount;
120 ULONG KeExceptionDispatchCount;
121 ULONG KeFirstLevelTbFills;
122 ULONG KeFloatingEmulationCount;
123 ULONG KeIcacheFlushCount;
124 ULONG KeSecondLevelTbFills;
125 ULONG KeSystemCalls;
126 ULONG IoReadOperationCount;
127 ULONG IoWriteOperationCount;
128 ULONG IoOtherOperationCount;
129 LARGE_INTEGER IoReadTransferCount;
130 LARGE_INTEGER IoWriteTransferCount;
131 LARGE_INTEGER IoOtherTransferCount;
132 ULONG SpareCounter1[8];
133 PP_LOOKASIDE_LIST PPLookasideList[16];
134 PP_LOOKASIDE_LIST PPNPagedLookasideList[32];
135 PP_LOOKASIDE_LIST PPPagedLookasideList[32];
136 ULONG PacketBarrier;
137 ULONG ReverseStall;
138 PVOID IpiFrame;
139 UCHAR PrcbPad2[52];
140 PVOID CurrentPacket[3];
141 ULONG TargetSet;
142 ULONG_PTR WorkerRoutine;
143 ULONG IpiFrozen;
144 UCHAR PrcbPad3[40];
145 ULONG RequestSummary;
146 struct _KPRCB *SignalDone;
147 UCHAR PrcbPad4[56];
148 struct _KDPC_DATA DpcData[2];
149 PVOID DpcStack;
150 ULONG MaximumDpcQueueDepth;
151 ULONG DpcRequestRate;
152 ULONG MinimumDpcRate;
153 UCHAR DpcInterruptRequested;
154 UCHAR DpcThreadRequested;
155 UCHAR DpcRoutineActive;
156 UCHAR DpcThreadActive;
157 ULONG PrcbLock;
158 ULONG DpcLastCount;
159 ULONG TimerHand;
160 ULONG TimerRequest;
161 PVOID DpcThread;
162 struct _KEVENT *DpcEvent;
163 UCHAR ThreadDpcEnable;
164 BOOLEAN QuantumEnd;
165 UCHAR PrcbPad50;
166 UCHAR IdleSchedule;
167 ULONG DpcSetEventRequest;
168 UCHAR PrcbPad5[18];
169 LONG TickOffset;
170 struct _KDPC* CallDpc;
171 ULONG PrcbPad7[8];
172 LIST_ENTRY WaitListHead;
173 ULONG ReadySummary;
174 ULONG SelectNextLast;
175 LIST_ENTRY DispatcherReadyListHead[32];
176 SINGLE_LIST_ENTRY DeferredReadyListHead;
177 ULONG PrcbPad72[11];
178 PVOID ChainedInterruptList;
179 LONG LookasideIrpFloat;
180 LONG MmPageFaultCount;
181 LONG MmCopyOnWriteCount;
182 LONG MmTransitionCount;
183 LONG MmCacheTransitionCount;
184 LONG MmDemandZeroCount;
185 LONG MmPageReadCount;
186 LONG MmPageReadIoCount;
187 LONG MmCacheReadCount;
188 LONG MmCacheIoCount;
189 LONG MmDirtyPagesWriteCount;
190 LONG MmDirtyWriteIoCount;
191 LONG MmMappedPagesWriteCount;
192 LONG MmMappedWriteIoCount;
193 ULONG SpareFields0[1];
194 CHAR VendorString[13];
195 UCHAR InitialApicId;
196 UCHAR LogicalProcessorsPerPhysicalProcessor;
197 ULONG MHz;
198 ULONG FeatureBits;
199 LARGE_INTEGER UpdateSignature;
200 LARGE_INTEGER IsrTime;
201 LARGE_INTEGER SpareField1;
202 FX_SAVE_AREA NpxSaveArea;
203 PROCESSOR_POWER_STATE PowerState;
204 } KPRCB, *PKPRCB;
205
206 #pragma pack(pop)
207
208 #ifndef __USE_W32API
209
210 #pragma pack(push,4)
211 /*
212 * Processor Control Region Thread Information Block
213 */
214 typedef struct _KPCR_TIB {
215 PVOID ExceptionList; /* 00 */
216 PVOID StackBase; /* 04 */
217 PVOID StackLimit; /* 08 */
218 PVOID SubSystemTib; /* 0C */
219 union {
220 PVOID FiberData; /* 10 */
221 DWORD Version; /* 10 */
222 };
223 PVOID ArbitraryUserPointer; /* 14 */
224 struct _KPCR_TIB* Self; /* 18 */
225 } KPCR_TIB, *PKPCR_TIB; /* 18 */
226
227 /*
228 * Processor Control Region
229 */
230 typedef struct _KPCR {
231 KPCR_TIB Tib; /* 00 */
232 struct _KPCR *Self; /* 1C */
233 struct _KPRCB *Prcb; /* 20 */
234 KIRQL Irql; /* 24 */
235 ULONG IRR; /* 28 */
236 ULONG IrrActive; /* 2C */
237 ULONG IDR; /* 30 */
238 PVOID KdVersionBlock; /* 34 */
239 PUSHORT IDT; /* 38 */
240 PUSHORT GDT; /* 3C */
241 struct _KTSS *TSS; /* 40 */
242 USHORT MajorVersion; /* 44 */
243 USHORT MinorVersion; /* 46 */
244 KAFFINITY SetMember; /* 48 */
245 ULONG StallScaleFactor; /* 4C */
246 UCHAR DebugActive; /* 50 */
247 UCHAR Number; /* 51 */
248 UCHAR Reserved; /* 52 */
249 UCHAR L2CacheAssociativity; /* 53 */
250 ULONG VdmAlert; /* 54 */
251 ULONG KernelReserved[14]; /* 58 */
252 ULONG L2CacheSize; /* 90 */
253 ULONG HalReserved[16]; /* 94 */
254 ULONG InterruptMode; /* D4 */
255 UCHAR KernelReserved2[0x48]; /* D8 */
256 KPRCB PrcbData; /* 120 */
257 } KPCR, *PKPCR;
258
259 #pragma pack(pop)
260 #endif /* __USE_W32API */
261
262 #pragma pack(push,4)
263
264 /*
265 * This is the complete, internal KPCR structure
266 */
267 typedef struct _KIPCR {
268 KPCR_TIB Tib; /* 00 */
269 struct _KPCR *Self; /* 1C */
270 struct _KPRCB *Prcb; /* 20 */
271 KIRQL Irql; /* 24 */
272 ULONG IRR; /* 28 */
273 ULONG IrrActive; /* 2C */
274 ULONG IDR; /* 30 */
275 PVOID KdVersionBlock; /* 34 */
276 PUSHORT IDT; /* 38 */
277 PUSHORT GDT; /* 3C */
278 struct _KTSS *TSS; /* 40 */
279 USHORT MajorVersion; /* 44 */
280 USHORT MinorVersion; /* 46 */
281 KAFFINITY SetMember; /* 48 */
282 ULONG StallScaleFactor; /* 4C */
283 UCHAR SparedUnused; /* 50 */
284 UCHAR Number; /* 51 */
285 UCHAR Reserved; /* 52 */
286 UCHAR L2CacheAssociativity; /* 53 */
287 ULONG VdmAlert; /* 54 */
288 ULONG KernelReserved[14]; /* 58 */
289 ULONG L2CacheSize; /* 90 */
290 ULONG HalReserved[16]; /* 94 */
291 ULONG InterruptMode; /* D4 */
292 UCHAR KernelReserved2[0x48]; /* D8 */
293 KPRCB PrcbData; /* 120 */
294 } KIPCR, *PKIPCR;
295
296 #pragma pack(pop)
297
298 #ifndef __USE_W32API
299
300 #ifdef CONFIG_SMP
301
302 static inline PKPCR KeGetCurrentKPCR(VOID)
303 {
304 ULONG value;
305
306 #if defined(__GNUC__)
307 __asm__ __volatile__ ("movl %%fs:0x1C, %0\n\t"
308 : "=r" (value)
309 : /* no inputs */
310 );
311 #elif defined(_MSC_VER)
312 __asm mov eax, fs:0x1C;
313 __asm mov value, eax;
314 #else
315 #error Unknown compiler for inline assembler
316 #endif
317 return((PKPCR)value);
318 }
319
320 static inline PKPRCB KeGetCurrentPrcb(VOID)
321 {
322 ULONG value;
323
324 #if defined(__GNUC__)
325 __asm__ __volatile__ ("movl %%fs:0x20, %0\n\t"
326 : "=r" (value)
327 : /* no inputs */
328 );
329 #elif defined(_MSC_VER)
330 __asm mov eax, fs:0x20;
331 __asm mov value, eax;
332 #else
333 #error Unknown compiler for inline assembler
334 #endif
335 return((PKPRCB)value);
336 }
337
338 #else
339
340 #define KeGetCurrentKPCR(X) ((PKPCR)KPCR_BASE)
341 #define KeGetCurrentPrcb() (((PKPCR)KPCR_BASE)->Prcb)
342 #define KeGetCurrentThread(X) (((PKPCR)KPCR_BASE)->PrcbData.CurrentThread)
343
344 #endif
345
346 #endif /* __USE_W32API */
347
348 #endif /* __ASM__ */
349
350 #endif /* __NTOSKRNL_INCLUDE_INTERNAL_I386_PS_H */
351
352 /* EOF */