3 * Copyright (C) 2000 David Welch <welch@cwcom.net>
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.
20 #ifndef __NTOSKRNL_INCLUDE_INTERNAL_KE_H
21 #define __NTOSKRNL_INCLUDE_INTERNAL_KE_H
23 /* INCLUDES *****************************************************************/
26 #include <ddk/ntifs.h>
28 #endif /* not __ASM__ */
32 /* INTERNAL KERNEL FUNCTIONS ************************************************/
35 struct _KPROCESS
* KeGetCurrentProcess(VOID
);
36 VOID
KeSetGdtSelector(ULONG Entry
, ULONG Value1
, ULONG Value2
);
44 DbgBreakPointNoBugCheck(VOID
);
46 VOID STDCALL
KeRescheduleThread();
52 PKTRAP_FRAME TrapFrame
57 KeProfileInterruptWithSource(
58 IN PKTRAP_FRAME TrapFrame
,
59 IN KPROFILE_SOURCE Source
65 IN PKTRAP_FRAME TrapFrame,
66 IN PKEXCEPTION_FRAME ExceptionFrame
72 IN PKTRAP_FRAME TrapFrame
,
76 VOID
KiUpdateSystemTime (KIRQL oldIrql
, ULONG Eip
);
78 KIRQL
KeAcquireDispatcherDatabaseLock(VOID
);
79 VOID
KeAcquireDispatcherDatabaseLockAtDpcLevel(VOID
);
80 VOID
KeReleaseDispatcherDatabaseLock(KIRQL Irql
);
81 VOID
KeReleaseDispatcherDatabaseLockFromDpcLevel(VOID
);
83 BOOLEAN
KeDispatcherObjectWake(DISPATCHER_HEADER
* hdr
);
84 VOID STDCALL
KeExpireTimers(PKDPC Apc
,
88 VOID
KeInitializeDispatcherHeader(DISPATCHER_HEADER
* Header
, ULONG Type
,
89 ULONG Size
, ULONG SignalState
);
90 VOID
KeDumpStackFrames(PULONG Frame
);
91 BOOLEAN
KiTestAlert(VOID
);
92 VOID
KeRemoveAllWaitsThread(struct _ETHREAD
* Thread
, NTSTATUS WaitStatus
, BOOL Unblock
);
93 PULONG
KeGetStackTopThread(struct _ETHREAD
* Thread
);
94 VOID
KeContextToTrapFrame(PCONTEXT Context
, PKTRAP_FRAME TrapFrame
);
96 KiDeliverNormalApc(VOID
);
98 BOOLEAN STDCALL
KeRemoveQueueApc (PKAPC Apc
);
99 PLIST_ENTRY STDCALL
KeRundownQueue(IN PKQUEUE Queue
);
101 extern LARGE_INTEGER SystemBootTime
;
102 extern volatile ULONGLONG KiKernelTime
;
103 extern volatile ULONGLONG KiUserTime
;
104 extern volatile ULONGLONG KiDpcTime
;
107 /* INITIALIZATION FUNCTIONS *************************************************/
109 VOID
KeInitExceptions(VOID
);
110 VOID
KeInitInterrupts(VOID
);
111 VOID
KeInitTimer(VOID
);
112 VOID
KeInitDpc(VOID
);
113 VOID
KeInitDispatcher(VOID
);
114 VOID
KeInitializeDispatcher(VOID
);
115 VOID
KeInitializeTimerImpl(VOID
);
116 VOID
KeInitializeBugCheck(VOID
);
117 VOID
Phase1Initialization(PVOID Context
);
122 BOOLEAN
KiDeliverUserApc(PKTRAP_FRAME TrapFrame
);
125 KiSwapApcEnvironment(
126 struct _KTHREAD
* Thread
,
127 struct _KPROCESS
* NewProcess
);
130 KiAddProfileEvent(KPROFILE_SOURCE Source
, ULONG Pc
);
132 KiDispatchException(PEXCEPTION_RECORD ExceptionRecord
,
135 KPROCESSOR_MODE PreviousMode
,
136 BOOLEAN SearchFrames
);
137 VOID
KeTrapFrameToContext(PKTRAP_FRAME TrapFrame
,
140 KeApplicationProcessorInit(VOID
);
142 KePrepareForApplicationProcessorInit(ULONG id
);
144 KiUserTrapHandler(PKTRAP_FRAME Tf
, ULONG ExceptionNr
, PVOID Cr2
);
146 KePushAndStackSwitchAndSysRet(ULONG Push
, PVOID NewStack
);
148 KeStackSwitchAndRet(PVOID NewStack
);
150 KeBugCheckWithTf(ULONG BugCheckCode
,
151 ULONG BugCheckParameter1
,
152 ULONG BugCheckParameter2
,
153 ULONG BugCheckParameter3
,
154 ULONG BugCheckParameter4
,
156 #define KEBUGCHECKWITHTF(a,b,c,d,e,f) DbgPrint("KeBugCheckWithTf at %s:%i\n",__FILE__,__LINE__), KeBugCheckWithTf(a,b,c,d,e,f)
158 KiDumpTrapFrame(PKTRAP_FRAME Tf
, ULONG ExceptionNr
, ULONG cr2
);
161 KiUpdateProcessThreadTime(VOID
);
166 IN PKTRAP_FRAME TrapFrame
169 #endif /* not __ASM__ */
171 #define MAXIMUM_PROCESSORS 32
173 #endif /* __NTOSKRNL_INCLUDE_INTERNAL_KE_H */