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_PREVIOUS_MODE 0x137
30 #define KTHREAD_TRAP_FRAME 0x128
31 #define KTHREAD_CALLBACK_STACK 0x120
33 #define ETHREAD_THREADS_PROCESS 0x234
35 #define KPROCESS_DIRECTORY_TABLE_BASE 0x18
37 #define KPCR_BASE 0xFF000000
39 #define KPCR_EXCEPTION_LIST 0x0
40 #define KPCR_SELF 0x18
42 #define KPCR_CURRENT_THREAD 0x124
47 * Processor Control Region
51 PVOID ExceptionList; /* 00 */
52 PVOID StackBase; /* 04 */
53 PVOID StackLimit; /* 08 */
54 PVOID SubSystemTib; /* 0C */
55 PVOID Reserved1; /* 10 */
56 PVOID ArbitraryUserPointer; /* 14 */
57 struct _KPCR* Self; /* 18 */
58 UCHAR ProcessorNumber; /* 1C */
60 UCHAR Reserved2[0x2]; /* 1E */
64 UCHAR Reserved3[0xF8]; /* 2C */
65 struct _KTHREAD* CurrentThread; /* 124 */
66 } __attribute__((packed)) KPCR, *PKPCR;
68 static inline PKPCR KeGetCurrentKPCR(VOID)
72 __asm__ __volatile__ ("movl %%fs:0x18, %0\n\t"
80 Ki386ContextSwitch(struct _KTHREAD* NewThread,
81 struct _KTHREAD* OldThread);
83 Ke386InitThread(struct _KTHREAD* Thread, PKSTART_ROUTINE fn,
86 Ke386InitThreadWithContext(struct _KTHREAD* Thread, PCONTEXT Context);
88 Ki386ValidateUserContext(PCONTEXT Context);
92 #endif /* __NTOSKRNL_INCLUDE_INTERNAL_I386_PS_H */