a8fd3d2f54655302334cb9d25568a9f156dd7ca7
[reactos.git] / reactos / ntoskrnl / include / internal / ke.h
1 /*
2 * ReactOS kernel
3 * Copyright (C) 2000 David Welch <welch@cwcom.net>
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
20 #ifndef __NTOSKRNL_INCLUDE_INTERNAL_KERNEL_H
21 #define __NTOSKRNL_INCLUDE_INTERNAL_KERNEL_H
22
23 /* INCLUDES *****************************************************************/
24
25 #include <ddk/ntddk.h>
26
27 #include <stdarg.h>
28
29 /* INTERNAL KERNEL FUNCTIONS ************************************************/
30
31 struct _KTHREAD;
32
33 #define KTRAP_FRAME_DEBUGEBP (0x0)
34 #define KTRAP_FRAME_DEBUGEIP (0x4)
35 #define KTRAP_FRAME_DEBUGARGMARK (0x8)
36 #define KTRAP_FRAME_DEBUGPOINTER (0xC)
37 #define KTRAP_FRAME_TEMPCS (0x10)
38 #define KTRAP_FRAME_TEMPEIP (0x14)
39 #define KTRAP_FRAME_DR0 (0x18)
40 #define KTRAP_FRAME_DR1 (0x1C)
41 #define KTRAP_FRAME_DR2 (0x20)
42 #define KTRAP_FRAME_DR3 (0x24)
43 #define KTRAP_FRAME_DR6 (0x28)
44 #define KTRAP_FRAME_DR7 (0x2C)
45 #define KTRAP_FRAME_GS (0x30)
46 #define KTRAP_FRAME_RESERVED1 (0x32)
47 #define KTRAP_FRAME_ES (0x34)
48 #define KTRAP_FRAME_RESERVED2 (0x36)
49 #define KTRAP_FRAME_DS (0x38)
50 #define KTRAP_FRAME_RESERVED3 (0x3A)
51 #define KTRAP_FRAME_EDX (0x3C)
52 #define KTRAP_FRAME_ECX (0x40)
53 #define KTRAP_FRAME_EAX (0x44)
54 #define KTRAP_FRAME_PREVIOUS_MODE (0x48)
55 #define KTRAP_FRAME_EXCEPTION_LIST (0x4C)
56 #define KTRAP_FRAME_FS (0x50)
57 #define KTRAP_FRAME_RESERVED4 (0x52)
58 #define KTRAP_FRAME_EDI (0x54)
59 #define KTRAP_FRAME_ESI (0x58)
60 #define KTRAP_FRAME_EBX (0x5C)
61 #define KTRAP_FRAME_EBP (0x60)
62 #define KTRAP_FRAME_ERROR_CODE (0x64)
63 #define KTRAP_FRAME_EIP (0x68)
64 #define KTRAP_FRAME_CS (0x6C)
65 #define KTRAP_FRAME_EFLAGS (0x70)
66 #define KTRAP_FRAME_ESP (0x74)
67 #define KTRAP_FRAME_SS (0x78)
68 #define KTRAP_FRAME_RESERVED5 (0x7A)
69 #define KTRAP_FRAME_V86_ES (0x7C)
70 #define KTRAP_FRAME_RESERVED6 (0x7E)
71 #define KTRAP_FRAME_V86_DS (0x80)
72 #define KTRAP_FRAME_RESERVED7 (0x82)
73 #define KTRAP_FRAME_V86_FS (0x84)
74 #define KTRAP_FRAME_RESERVED8 (0x86)
75 #define KTRAP_FRAME_V86_GS (0x88)
76 #define KTRAP_FRAME_RESERVED9 (0x8A)
77
78 typedef struct _KTRAP_FRAME
79 {
80 PVOID DebugEbp;
81 PVOID DebugEip;
82 PVOID DebugArgMark;
83 PVOID DebugPointer;
84 PVOID TempCs;
85 PVOID TempEip;
86 PVOID Dr0;
87 PVOID Dr1;
88 PVOID Dr2;
89 PVOID Dr3;
90 PVOID Dr6;
91 PVOID Dr7;
92 USHORT Gs;
93 USHORT Reserved1;
94 USHORT Es;
95 USHORT Reserved2;
96 USHORT Ds;
97 USHORT Reserved3;
98 ULONG Edx;
99 ULONG Ecx;
100 ULONG Eax;
101 ULONG PreviousMode;
102 PVOID ExceptionList;
103 USHORT Fs;
104 USHORT Reserved4;
105 ULONG Edi;
106 ULONG Esi;
107 ULONG Ebx;
108 ULONG Ebp;
109 ULONG ErrorCode;
110 ULONG Eip;
111 ULONG Cs;
112 ULONG Eflags;
113 ULONG Esp;
114 USHORT Ss;
115 USHORT Reserved5;
116 USHORT V86_Es;
117 USHORT Reserved6;
118 USHORT V86_Ds;
119 USHORT Reserved7;
120 USHORT V86_Fs;
121 USHORT Reserved8;
122 USHORT V86_Gs;
123 USHORT Reserved9;
124 } KTRAP_FRAME, *PKTRAP_FRAME;
125
126 VOID KiUpdateSystemTime (KIRQL oldIrql, ULONG Eip);
127
128 VOID KeAcquireDispatcherDatabaseLock(BOOLEAN Wait);
129 VOID KeReleaseDispatcherDatabaseLock(BOOLEAN Wait);
130 BOOLEAN KeDispatcherObjectWake(DISPATCHER_HEADER* hdr);
131
132 #if 0
133 VOID KiInterruptDispatch(ULONG irq);
134 #endif
135 VOID KeExpireTimers( PKDPC Apc,
136 PVOID Arg1,
137 PVOID Arg2,
138 PVOID Arg3 );
139 VOID KeInitializeDispatcherHeader(DISPATCHER_HEADER* Header, ULONG Type,
140 ULONG Size, ULONG SignalState);
141
142 VOID KeDumpStackFrames(PVOID Stack, ULONG NrFrames);
143 ULONG KeAllocateGdtSelector(ULONG Desc[2]);
144 VOID KeFreeGdtSelector(ULONG Entry);
145 BOOLEAN KiTestAlert(VOID);
146 VOID KeRemoveAllWaitsThread(struct _ETHREAD* Thread, NTSTATUS WaitStatus);
147 PULONG KeGetStackTopThread(struct _ETHREAD* Thread);
148 VOID KeContextToTrapFrame(PCONTEXT Context,
149 PKTRAP_FRAME TrapFrame);
150 VOID KeReleaseDispatcherDatabaseLockAtDpcLevel(BOOLEAN Wait);
151 VOID
152 KiDeliverNormalApc(VOID);
153
154 BOOLEAN STDCALL KeRemoveQueueApc (PKAPC Apc);
155
156 /* INITIALIZATION FUNCTIONS *************************************************/
157
158 VOID KeInitExceptions(VOID);
159 VOID KeInitInterrupts(VOID);
160 VOID KeInitTimer(VOID);
161 VOID KeInitDpc(VOID);
162 VOID KeInitDispatcher(VOID);
163 VOID KeInitializeDispatcher(VOID);
164 VOID KeInitializeTimerImpl(VOID);
165 VOID KeInitializeBugCheck(VOID);
166
167 VOID KeInit1(VOID);
168 VOID KeInit2(VOID);
169
170 BOOLEAN KiDeliverUserApc(PKTRAP_FRAME TrapFrame);
171 VOID
172 NtEarlyInitVdm(VOID);
173 VOID
174 KiAddProfileEvent(KPROFILE_SOURCE Source, ULONG Eip);
175 VOID
176 KiDispatchException(PEXCEPTION_RECORD Er,
177 PCONTEXT Context,
178 PKTRAP_FRAME Tf,
179 KPROCESSOR_MODE PreviousMode,
180 BOOLEAN SearchFrames);
181 VOID KeTrapFrameToContext(PKTRAP_FRAME TrapFrame,
182 PCONTEXT Context);
183 #endif