Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

ki.h

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1989 Microsoft Corporation 00004 00005 Module Name: 00006 00007 ki.h 00008 00009 Abstract: 00010 00011 This module contains the private (internal) header file for the 00012 kernel. 00013 00014 Author: 00015 00016 David N. Cutler (davec) 28-Feb-1989 00017 00018 Revision History: 00019 00020 --*/ 00021 00022 #ifndef _KI_ 00023 #define _KI_ 00024 #include "ntos.h" 00025 #include "stdio.h" 00026 #include "stdlib.h" 00027 #include "zwapi.h" 00028 00029 // 00030 // Private (internal) constant definitions. 00031 // 00032 // Priority increment value definitions 00033 // 00034 00035 #define ALERT_INCREMENT 2 // Alerted unwait priority increment 00036 #define BALANCE_INCREMENT 10 // Balance set priority increment 00037 #define RESUME_INCREMENT 0 // Resume thread priority increment 00038 #define TIMER_EXPIRE_INCREMENT 0 // Timer expiration priority increment 00039 00040 // 00041 // Define time critical priority class base. 00042 // 00043 00044 #define TIME_CRITICAL_PRIORITY_BOUND 14 00045 00046 // 00047 // Define NIL pointer value. 00048 // 00049 00050 #define NIL (PVOID)NULL // Null pointer to void 00051 00052 // 00053 // Define macros which are used in the kernel only 00054 // 00055 // Clear member in set 00056 // 00057 00058 #define ClearMember(Member, Set) \ 00059 Set = Set & (~(1 << (Member))) 00060 00061 // 00062 // Set member in set 00063 // 00064 00065 #define SetMember(Member, Set) \ 00066 Set = Set | (1 << (Member)) 00067 00068 #define FindFirstSetLeftMember(Set, Member) { \ 00069 ULONG _Bit; \ 00070 ULONG _Mask; \ 00071 ULONG _Offset = 16; \ 00072 if ((_Mask = Set >> 16) == 0) { \ 00073 _Offset = 0; \ 00074 _Mask = Set; \ 00075 } \ 00076 if (_Mask >> 8) { \ 00077 _Offset += 8; \ 00078 } \ 00079 if ((_Bit = Set >> _Offset) & 0xf0) { \ 00080 _Bit >>= 4; \ 00081 _Offset += 4; \ 00082 } \ 00083 *(Member) = KiFindLeftNibbleBitTable[_Bit] + _Offset; \ 00084 } 00085 00086 // 00087 // Lock and unlock APC queue lock. 00088 // 00089 00090 #if defined(NT_UP) 00091 #define KiLockApcQueue(Thread, OldIrql) \ 00092 *(OldIrql) = KeRaiseIrqlToSynchLevel() 00093 #else 00094 #define KiLockApcQueue(Thread, OldIrql) \ 00095 *(OldIrql) = KeAcquireSpinLockRaiseToSynch(&(Thread)->ApcQueueLock) 00096 #endif 00097 00098 #if defined(NT_UP) 00099 #define KiUnlockApcQueue(Thread, OldIrql) KeLowerIrql((OldIrql)) 00100 #else 00101 #define KiUnlockApcQueue(Thread, OldIrql) KeReleaseSpinLock(&(Thread)->ApcQueueLock, (OldIrql)) 00102 #endif 00103 00104 // 00105 // Lock and unlock context swap lock. 00106 // 00107 00108 #if defined(_ALPHA_) || defined(_X86_) 00109 00110 #define KiLockContextSwap(OldIrql) \ 00111 *(OldIrql) = KeAcquireQueuedSpinLockRaiseToSynch(LockQueueContextSwapLock) 00112 00113 #define KiUnlockContextSwap(OldIrql) \ 00114 KeReleaseQueuedSpinLock(LockQueueContextSwapLock, OldIrql) 00115 00116 #else 00117 00118 #if defined(NT_UP) 00119 00120 #define KiLockContextSwap(OldIrql) \ 00121 *(OldIrql) = KeRaiseIrqlToSynchLevel() 00122 00123 #define KiUnlockContextSwap(OldIrql) \ 00124 KeLowerIrql((OldIrql)) 00125 00126 #else 00127 00128 #define KiLockContextSwap(OldIrql) \ 00129 *(OldIrql) = KeAcquireSpinLockRaiseToSynch(&KiContextSwapLock) 00130 00131 #define KiUnlockContextSwap(OldIrql) \ 00132 KeReleaseSpinLock(&KiContextSwapLock, (OldIrql)) 00133 00134 #endif 00135 #endif 00136 00137 VOID 00138 FASTCALL 00139 KiUnlockDispatcherDatabase ( 00140 IN KIRQL OldIrql 00141 ); 00142 00143 LOGICAL 00144 FASTCALL 00145 KiTryToAcquireQueuedSpinLock ( 00146 IN PKSPIN_LOCK_QUEUE QueuedLock 00147 ); 00148 00149 #define KiQueuedSpinLockContext(n) (&(KeGetCurrentPrcb()->LockQueue[n])) 00150 00151 00152 // VOID 00153 // KiBoostPriorityThread ( 00154 // IN PKTHREAD Thread, 00155 // IN KPRIORITY Increment 00156 // ) 00157 // 00158 //*++ 00159 // 00160 // Routine Description: 00161 // 00162 // This function boosts the priority of the specified thread using 00163 // the same algorithm used when a thread gets a boost from a wait 00164 // operation. 00165 // 00166 // Arguments: 00167 // 00168 // Thread - Supplies a pointer to a dispatcher object of type thread. 00169 // 00170 // Increment - Supplies the priority increment that is to be applied to 00171 // the thread's priority. 00172 // 00173 // Return Value: 00174 // 00175 // None. 00176 // 00177 //--* 00178 00179 #define KiBoostPriorityThread(Thread, Increment) { \ 00180 KPRIORITY NewPriority; \ 00181 PKPROCESS Process; \ 00182 \ 00183 if ((Thread)->Priority < LOW_REALTIME_PRIORITY) { \ 00184 if ((Thread)->PriorityDecrement == 0) { \ 00185 NewPriority = (Thread)->BasePriority + (Increment); \ 00186 if (NewPriority > (Thread)->Priority) { \ 00187 if (NewPriority >= LOW_REALTIME_PRIORITY) { \ 00188 NewPriority = LOW_REALTIME_PRIORITY - 1; \ 00189 } \ 00190 \ 00191 Process = (Thread)->ApcState.Process; \ 00192 (Thread)->Quantum = Process->ThreadQuantum; \ 00193 KiSetPriorityThread((Thread), NewPriority); \ 00194 } \ 00195 } \ 00196 } \ 00197 } 00198 00199 // VOID 00200 // KiInsertWaitList ( 00201 // IN KPROCESSOR_MODE WaitMode, 00202 // IN PKTHREAD Thread 00203 // ) 00204 // 00205 //*++ 00206 // 00207 // Routine Description: 00208 // 00209 // This function inserts the specified thread in the appropriate 00210 // wait list. 00211 // 00212 // Arguments: 00213 // 00214 // WaitMode - Supplies the processor mode of the wait operation. 00215 // 00216 // Thread - Supplies a pointer to a dispatcher object of type 00217 // thread. 00218 // 00219 // Return Value: 00220 // 00221 // None. 00222 // 00223 //--* 00224 00225 #define KiInsertWaitList(_WaitMode, _Thread) { \ 00226 PLIST_ENTRY _ListHead; \ 00227 _ListHead = &KiWaitInListHead; \ 00228 if (((_WaitMode) == KernelMode) || \ 00229 ((_Thread)->EnableStackSwap == FALSE) || \ 00230 ((_Thread)->Priority >= (LOW_REALTIME_PRIORITY + 9))) { \ 00231 _ListHead = &KiWaitOutListHead; \ 00232 } \ 00233 InsertTailList(_ListHead, &(_Thread)->WaitListEntry); \ 00234 } 00235 00236 // 00237 // Private (internal) structure definitions. 00238 // 00239 // APC Parameter structure. 00240 // 00241 00242 typedef struct _KAPC_RECORD { 00243 PKNORMAL_ROUTINE NormalRoutine; 00244 PVOID NormalContext; 00245 PVOID SystemArgument1; 00246 PVOID SystemArgument2; 00247 } KAPC_RECORD, *PKAPC_RECORD; 00248 00249 // 00250 // Executive initialization. 00251 // 00252 00253 VOID 00254 ExpInitializeExecutive ( 00255 IN ULONG Number, 00256 IN PLOADER_PARAMETER_BLOCK LoaderBlock 00257 ); 00258 00259 // 00260 // Kernel executive object function definitions. 00261 // 00262 00263 BOOLEAN 00264 KiChannelInitialization ( 00265 VOID 00266 ); 00267 00268 VOID 00269 KiRundownChannel ( 00270 VOID 00271 ); 00272 00273 // 00274 // Interprocessor interrupt function definitions. 00275 // 00276 // Define immediate interprocessor commands. 00277 // 00278 00279 #define IPI_APC 1 // APC interrupt request 00280 #define IPI_DPC 2 // DPC interrupt request 00281 #define IPI_FREEZE 4 // freeze execution request 00282 #define IPI_PACKET_READY 8 // packet ready request 00283 #define IPI_SYNCH_REQUEST 0x10 // synchronous Reverse Stall packet 00284 00285 // 00286 // Define interprocess interrupt types. 00287 // 00288 00289 typedef ULONG KIPI_REQUEST; 00290 00291 typedef 00292 ULONG_PTR 00293 (*PKIPI_BROADCAST_WORKER)( 00294 IN ULONG_PTR Argument 00295 ); 00296 00297 #if NT_INST 00298 00299 #define IPI_INSTRUMENT_COUNT(a,b) KiIpiCounts[a].b++; 00300 00301 #else 00302 00303 #define IPI_INSTRUMENT_COUNT(a,b) 00304 00305 #endif 00306 00307 // 00308 // Define interprocessor interrupt function prototypes. 00309 // 00310 00311 ULONG_PTR 00312 KiIpiGenericCall ( 00313 IN PKIPI_BROADCAST_WORKER BroadcastFunction, 00314 IN ULONG_PTR Context 00315 ); 00316 00317 #if defined(_ALPHA_) || defined(_IA64_) 00318 00319 ULONG 00320 KiIpiProcessRequests ( 00321 VOID 00322 ); 00323 00324 #endif 00325 00326 VOID 00327 FASTCALL 00328 KiIpiSend ( 00329 IN KAFFINITY TargetProcessors, 00330 IN KIPI_REQUEST Request 00331 ); 00332 00333 VOID 00334 KiIpiSendPacket ( 00335 IN KAFFINITY TargetProcessors, 00336 IN PKIPI_WORKER WorkerFunction, 00337 IN PVOID Parameter1, 00338 IN PVOID Parameter2, 00339 IN PVOID Parameter3 00340 ); 00341 00342 // begin_nthal 00343 00344 BOOLEAN 00345 KiIpiServiceRoutine ( 00346 IN struct _KTRAP_FRAME *TrapFrame, 00347 IN struct _KEXCEPTION_FRAME *ExceptionFrame 00348 ); 00349 00350 // end_nthal 00351 00352 VOID 00353 FASTCALL 00354 KiIpiSignalPacketDone ( 00355 IN PKIPI_CONTEXT SignalDone 00356 ); 00357 00358 VOID 00359 KiIpiStallOnPacketTargets ( 00360 KAFFINITY TargetSet 00361 ); 00362 00363 #if defined(_X86_) 00364 00365 // 00366 // VOID 00367 // KiIpiSendSynchronousPacket ( 00368 // IN PKPRCB Prcb, 00369 // IN KAFFINITY TargetProcessors, 00370 // IN PKIPI_WORKER WorkerFunction, 00371 // IN PVOID Parameter1, 00372 // IN PVOID Parameter2, 00373 // IN PVOID Parameter3 00374 // ) 00375 // 00376 // Routine Description: 00377 // 00378 // Similar to KiIpiSendPacket except that the pointer to the 00379 // originating PRCB (SignalDone) is kept in the global variable 00380 // KiSynchPacket and is protected by the context swap lock. The 00381 // actual IPI is sent via KiIpiSend with a request type of 00382 // IPI_SYNCH_REQUEST. This mechanism is used to send IPI's that 00383 // (reverse) stall until released by the originator. This avoids 00384 // a deadlock that can occur if two processors are trying to deliver 00385 // IPI packets at the same time and one of them is a reverse stall. 00386 // 00387 00388 #define KiIpiSendSynchronousPacket(Prcb,Target,Function,P1,P2,P3) \ 00389 { \ 00390 extern PKPRCB KiSynchPacket; \ 00391 \ 00392 Prcb->CurrentPacket[0] = (PVOID)(P1); \ 00393 Prcb->CurrentPacket[1] = (PVOID)(P2); \ 00394 Prcb->CurrentPacket[2] = (PVOID)(P3); \ 00395 Prcb->TargetSet = (Target); \ 00396 Prcb->WorkerRoutine = (Function); \ 00397 KiSynchPacket = (Prcb); \ 00398 KiIpiSend((Target),IPI_SYNCH_REQUEST); \ 00399 } 00400 00401 #endif 00402 00403 // 00404 // Private (internal) function definitions. 00405 // 00406 00407 VOID 00408 FASTCALL 00409 KiActivateWaiterQueue ( 00410 IN PRKQUEUE Queue 00411 ); 00412 00413 BOOLEAN 00414 KiAdjustInterruptTime ( 00415 IN LONGLONG TimeDelta 00416 ); 00417 00418 VOID 00419 KiApcInterrupt ( 00420 VOID 00421 ); 00422 00423 NTSTATUS 00424 KiCallUserMode ( 00425 IN PVOID *OutputBuffer, 00426 IN PULONG OutputLength 00427 ); 00428 00429 typedef struct { 00430 ULONGLONG Adjustment; 00431 LARGE_INTEGER NewCount; 00432 volatile LONG KiNumber; 00433 volatile LONG HalNumber; 00434 volatile LONG Barrier; 00435 } ADJUST_INTERRUPT_TIME_CONTEXT, *PADJUST_INTERRUPT_TIME_CONTEXT; 00436 00437 VOID 00438 KiCalibrateTimeAdjustment ( 00439 PADJUST_INTERRUPT_TIME_CONTEXT Adjust 00440 ); 00441 00442 VOID 00443 KiChainedDispatch ( 00444 VOID 00445 ); 00446 00447 #if DBG 00448 00449 VOID 00450 KiCheckTimerTable ( 00451 IN ULARGE_INTEGER SystemTime 00452 ); 00453 00454 #endif 00455 00456 LARGE_INTEGER 00457 KiComputeReciprocal ( 00458 IN LONG Divisor, 00459 OUT PCCHAR Shift 00460 ); 00461 00462 ULONG 00463 KiComputeTimerTableIndex ( 00464 IN LARGE_INTEGER Interval, 00465 IN LARGE_INTEGER CurrentCount, 00466 IN PRKTIMER Timer 00467 ); 00468 00469 PLARGE_INTEGER 00470 FASTCALL 00471 KiComputeWaitInterval ( 00472 IN PLARGE_INTEGER OriginalTime, 00473 IN PLARGE_INTEGER DueTime, 00474 IN OUT PLARGE_INTEGER NewTime 00475 ); 00476 00477 NTSTATUS 00478 KiContinue ( 00479 IN PCONTEXT ContextRecord, 00480 IN PKEXCEPTION_FRAME ExceptionFrame, 00481 IN PKTRAP_FRAME TrapFrame 00482 ); 00483 00484 VOID 00485 KiDeliverApc ( 00486 IN KPROCESSOR_MODE PreviousMode, 00487 IN PKEXCEPTION_FRAME ExceptionFrame, 00488 IN PKTRAP_FRAME TrapFrame 00489 ); 00490 00491 BOOLEAN 00492 KiDisableInterrupts ( 00493 VOID 00494 ); 00495 00496 VOID 00497 KiRestoreInterrupts ( 00498 IN BOOLEAN Enable 00499 ); 00500 00501 VOID 00502 KiDispatchException ( 00503 IN PEXCEPTION_RECORD ExceptionRecord, 00504 IN PKEXCEPTION_FRAME ExceptionFrame, 00505 IN PKTRAP_FRAME TrapFrame, 00506 IN KPROCESSOR_MODE PreviousMode, 00507 IN BOOLEAN FirstChance 00508 ); 00509 00510 KCONTINUE_STATUS 00511 KiSetDebugProcessor ( 00512 IN PKTRAP_FRAME TrapFrame, 00513 IN PKEXCEPTION_FRAME ExceptionFrame, 00514 IN KPROCESSOR_MODE PreviousMode 00515 ); 00516 00517 ULONG 00518 KiCopyInformation ( 00519 IN OUT PEXCEPTION_RECORD ExceptionRecord1, 00520 IN PEXCEPTION_RECORD ExceptionRecord2 00521 ); 00522 00523 VOID 00524 KiDispatchInterrupt ( 00525 VOID 00526 ); 00527 00528 PKTHREAD 00529 FASTCALL 00530 KiFindReadyThread ( 00531 IN ULONG Processor, 00532 KPRIORITY LowPriority 00533 ); 00534 00535 VOID 00536 KiFloatingDispatch ( 00537 VOID 00538 ); 00539 00540 #if !defined(_IA64_) 00541 00542 VOID 00543 FASTCALL 00544 KiFlushSingleTb ( 00545 IN BOOLEAN Invalid, 00546 IN PVOID Virtual 00547 ); 00548 00549 #endif // !_IA64_ 00550 00551 VOID 00552 KiFlushMultipleTb ( 00553 IN BOOLEAN Invalid, 00554 IN PVOID *Virtual, 00555 IN ULONG Count 00556 ); 00557 00558 #if defined(_ALPHA_) 00559 00560 VOID 00561 KiFlushMultipleTb64 ( 00562 IN BOOLEAN Invalid, 00563 IN PULONG_PTR Virtual, 00564 IN ULONG Count 00565 ); 00566 00567 VOID 00568 FASTCALL 00569 KiFlushSingleTb64 ( 00570 IN BOOLEAN Invalid, 00571 IN ULONG_PTR Virtual 00572 ); 00573 00574 #endif 00575 00576 PULONG 00577 KiGetUserModeStackAddress ( 00578 VOID 00579 ); 00580 00581 VOID 00582 KiInitializeContextThread ( 00583 IN PKTHREAD Thread, 00584 IN PKSYSTEM_ROUTINE SystemRoutine, 00585 IN PKSTART_ROUTINE StartRoutine OPTIONAL, 00586 IN PVOID StartContext OPTIONAL, 00587 IN PCONTEXT ContextFrame OPTIONAL 00588 ); 00589 00590 VOID 00591 KiInitializeKernel ( 00592 IN PKPROCESS Process, 00593 IN PKTHREAD Thread, 00594 IN PVOID IdleStack, 00595 IN PKPRCB Prcb, 00596 IN CCHAR Number, 00597 IN PLOADER_PARAMETER_BLOCK LoaderBlock 00598 ); 00599 00600 VOID 00601 KiInitSystem ( 00602 VOID 00603 ); 00604 00605 BOOLEAN 00606 KiInitMachineDependent ( 00607 VOID 00608 ); 00609 00610 VOID 00611 KiInitializeUserApc ( 00612 IN PKEXCEPTION_FRAME ExceptionFrame, 00613 IN PKTRAP_FRAME TrapFrame, 00614 IN PKNORMAL_ROUTINE NormalRoutine, 00615 IN PVOID NormalContext, 00616 IN PVOID SystemArgument1, 00617 IN PVOID SystemArgument2 00618 ); 00619 00620 LONG 00621 FASTCALL 00622 KiInsertQueue ( 00623 IN PRKQUEUE Queue, 00624 IN PLIST_ENTRY Entry, 00625 IN BOOLEAN Head 00626 ); 00627 00628 BOOLEAN 00629 FASTCALL 00630 KiInsertQueueApc ( 00631 IN PKAPC Apc, 00632 IN KPRIORITY Increment 00633 ); 00634 00635 LOGICAL 00636 FASTCALL 00637 KiInsertTreeTimer ( 00638 IN PRKTIMER Timer, 00639 IN LARGE_INTEGER Interval 00640 ); 00641 00642 VOID 00643 KiInterruptDispatch ( 00644 VOID 00645 ); 00646 00647 VOID 00648 KiInterruptDispatchRaise ( 00649 IN PKINTERRUPT Interrupt 00650 ); 00651 00652 VOID 00653 KiInterruptDispatchSame ( 00654 IN PKINTERRUPT Interrupt 00655 ); 00656 00657 #if defined(i386) 00658 00659 VOID 00660 KiInitializePcr ( 00661 IN ULONG Processor, 00662 IN PKPCR Pcr, 00663 IN PKIDTENTRY Idt, 00664 IN PKGDTENTRY Gdt, 00665 IN PKTSS Tss, 00666 IN PKTHREAD Thread, 00667 IN PVOID DpcStack 00668 ); 00669 00670 VOID 00671 KiFlushNPXState ( 00672 PFLOATING_SAVE_AREA 00673 ); 00674 00675 VOID 00676 Ke386ConfigureCyrixProcessor ( 00677 VOID 00678 ); 00679 00680 ULONG 00681 KiCopyInformation ( 00682 IN OUT PEXCEPTION_RECORD ExceptionRecord1, 00683 IN PEXCEPTION_RECORD ExceptionRecord2 00684 ); 00685 00686 VOID 00687 KiSetHardwareTrigger ( 00688 VOID 00689 ); 00690 00691 #ifdef DBGMP 00692 VOID 00693 KiPollDebugger ( 00694 VOID 00695 ); 00696 #endif 00697 00698 VOID 00699 FASTCALL 00700 KiIpiSignalPacketDoneAndStall ( 00701 IN PKIPI_CONTEXT Signaldone, 00702 IN ULONG volatile *ReverseStall 00703 ); 00704 00705 #endif 00706 00707 00708 KIRQL 00709 KiLockDeviceQueue ( 00710 IN PKDEVICE_QUEUE DeviceQueue 00711 ); 00712 00713 VOID 00714 KiPassiveRelease ( 00715 VOID 00716 ); 00717 00718 PRKTHREAD 00719 KiQuantumEnd ( 00720 VOID 00721 ); 00722 00723 NTSTATUS 00724 KiRaiseException ( 00725 IN PEXCEPTION_RECORD ExceptionRecord, 00726 IN PCONTEXT ContextRecord, 00727 IN PKEXCEPTION_FRAME ExceptionFrame, 00728 IN PKTRAP_FRAME TrapFrame, 00729 IN BOOLEAN FirstChance 00730 ); 00731 00732 VOID 00733 FASTCALL 00734 KiReadyThread ( 00735 IN PRKTHREAD Thread 00736 ); 00737 00738 LOGICAL 00739 FASTCALL 00740 KiReinsertTreeTimer ( 00741 IN PRKTIMER Timer, 00742 IN ULARGE_INTEGER DueTime 00743 ); 00744 00745 #if DBG 00746 00747 #define KiRemoveTreeTimer(Timer) \ 00748 (Timer)->Header.Inserted = FALSE; \ 00749 RemoveEntryList(&(Timer)->TimerListEntry); \ 00750 (Timer)->TimerListEntry.Flink = NULL; \ 00751 (Timer)->TimerListEntry.Blink = NULL 00752 00753 #else 00754 00755 #define KiRemoveTreeTimer(Timer) \ 00756 (Timer)->Header.Inserted = FALSE; \ 00757 RemoveEntryList(&(Timer)->TimerListEntry) 00758 00759 #endif 00760 00761 #if defined(NT_UP) 00762 00763 #define KiRequestApcInterrupt(Processor) KiRequestSoftwareInterrupt(APC_LEVEL) 00764 00765 #else 00766 00767 #define KiRequestApcInterrupt(Processor) \ 00768 if (KeGetCurrentPrcb()->Number == (CCHAR)Processor) { \ 00769 KiRequestSoftwareInterrupt(APC_LEVEL); \ 00770 } else { \ 00771 KiIpiSend((KAFFINITY)(1 << Processor), IPI_APC); \ 00772 } 00773 00774 #endif 00775 00776 #if defined(NT_UP) 00777 00778 #define KiRequestDispatchInterrupt(Processor) 00779 00780 #else 00781 00782 #define KiRequestDispatchInterrupt(Processor) \ 00783 if (KeGetCurrentPrcb()->Number != (CCHAR)Processor) { \ 00784 KiIpiSend((KAFFINITY)(1 << Processor), IPI_DPC); \ 00785 } 00786 00787 #endif 00788 00789 PRKTHREAD 00790 FASTCALL 00791 KiSelectNextThread ( 00792 IN PRKTHREAD Thread 00793 ); 00794 00795 VOID 00796 KiSetSystemTime ( 00797 IN PLARGE_INTEGER NewTime, 00798 OUT PLARGE_INTEGER OldTime 00799 ); 00800 00801 VOID 00802 KiSuspendNop ( 00803 IN struct _KAPC *Apc, 00804 IN OUT PKNORMAL_ROUTINE *NormalRoutine, 00805 IN OUT PVOID *NormalContext, 00806 IN OUT PVOID *SystemArgument1, 00807 IN OUT PVOID *SystemArgument2 00808 ); 00809 00810 VOID 00811 KiSuspendThread ( 00812 IN PVOID NormalContext, 00813 IN PVOID SystemArgument1, 00814 IN PVOID SystemArgument2 00815 ); 00816 00817 BOOLEAN 00818 KiSwapProcess ( 00819 IN PKPROCESS NewProcess, 00820 IN PKPROCESS OldProcess 00821 ); 00822 00823 LONG_PTR 00824 FASTCALL 00825 KiSwapThread ( 00826 VOID 00827 ); 00828 00829 VOID 00830 KiThreadStartup ( 00831 IN PVOID StartContext 00832 ); 00833 00834 VOID 00835 KiTimerExpiration ( 00836 IN PKDPC Dpc, 00837 IN PVOID DeferredContext, 00838 IN PVOID SystemArgument1, 00839 IN PVOID SystemArgument2 00840 ); 00841 00842 VOID 00843 FASTCALL 00844 KiTimerListExpire ( 00845 IN PLIST_ENTRY ExpiredListHead, 00846 IN KIRQL OldIrql 00847 ); 00848 00849 VOID 00850 KiUnexpectedInterrupt ( 00851 VOID 00852 ); 00853 00854 VOID 00855 KiUnlockDeviceQueue ( 00856 IN PKDEVICE_QUEUE DeviceQueue, 00857 IN KIRQL OldIrql 00858 ); 00859 00860 VOID 00861 FASTCALL 00862 KiUnwaitThread ( 00863 IN PRKTHREAD Thread, 00864 IN LONG_PTR WaitStatus, 00865 IN KPRIORITY Increment 00866 ); 00867 00868 VOID 00869 KiUserApcDispatcher ( 00870 IN PVOID NormalContext, 00871 IN PVOID SystemArgument1, 00872 IN PVOID SystemArgument2, 00873 IN PKNORMAL_ROUTINE NormalRoutine 00874 ); 00875 00876 VOID 00877 KiUserExceptionDispatcher ( 00878 IN PEXCEPTION_RECORD ExceptionRecord, 00879 IN PCONTEXT ContextFrame 00880 ); 00881 00882 VOID 00883 FASTCALL 00884 KiWaitSatisfyAll ( 00885 IN PRKWAIT_BLOCK WaitBlock 00886 ); 00887 00888 // 00889 // VOID 00890 // FASTCALL 00891 // KiWaitSatisfyAny ( 00892 // IN PKMUTANT Object, 00893 // IN PKTHREAD Thread 00894 // ) 00895 // 00896 // 00897 // Routine Description: 00898 // 00899 // This function satisfies a wait for any type of object and performs 00900 // any side effects that are necessary. 00901 // 00902 // Arguments: 00903 // 00904 // Object - Supplies a pointer to a dispatcher object. 00905 // 00906 // Thread - Supplies a pointer to a dispatcher object of type thread. 00907 // 00908 // Return Value: 00909 // 00910 // None. 00911 // 00912 00913 #define KiWaitSatisfyAny(_Object_, _Thread_) { \ 00914 if (((_Object_)->Header.Type & DISPATCHER_OBJECT_TYPE_MASK) == EventSynchronizationObject) { \ 00915 (_Object_)->Header.SignalState = 0; \ 00916 \ 00917 } else if ((_Object_)->Header.Type == SemaphoreObject) { \ 00918 (_Object_)->Header.SignalState -= 1; \ 00919 \ 00920 } else if ((_Object_)->Header.Type == MutantObject) { \ 00921 (_Object_)->Header.SignalState -= 1; \ 00922 if ((_Object_)->Header.SignalState == 0) { \ 00923 (_Thread_)->KernelApcDisable -= (_Object_)->ApcDisable; \ 00924 (_Object_)->OwnerThread = (_Thread_); \ 00925 if ((_Object_)->Abandoned == TRUE) { \ 00926 (_Object_)->Abandoned = FALSE; \ 00927 (_Thread_)->WaitStatus = STATUS_ABANDONED; \ 00928 } \ 00929 \ 00930 InsertHeadList((_Thread_)->MutantListHead.Blink, \ 00931 &(_Object_)->MutantListEntry); \ 00932 } \ 00933 } \ 00934 } 00935 00936 // 00937 // VOID 00938 // FASTCALL 00939 // KiWaitSatisfyMutant ( 00940 // IN PKMUTANT Object, 00941 // IN PKTHREAD Thread 00942 // ) 00943 // 00944 // 00945 // Routine Description: 00946 // 00947 // This function satisfies a wait for a mutant object. 00948 // 00949 // Arguments: 00950 // 00951 // Object - Supplies a pointer to a dispatcher object. 00952 // 00953 // Thread - Supplies a pointer to a dispatcher object of type thread. 00954 // 00955 // Return Value: 00956 // 00957 // None. 00958 // 00959 00960 #define KiWaitSatisfyMutant(_Object_, _Thread_) { \ 00961 (_Object_)->Header.SignalState -= 1; \ 00962 if ((_Object_)->Header.SignalState == 0) { \ 00963 (_Thread_)->KernelApcDisable -= (_Object_)->ApcDisable; \ 00964 (_Object_)->OwnerThread = (_Thread_); \ 00965 if ((_Object_)->Abandoned == TRUE) { \ 00966 (_Object_)->Abandoned = FALSE; \ 00967 (_Thread_)->WaitStatus = STATUS_ABANDONED; \ 00968 } \ 00969 \ 00970 InsertHeadList((_Thread_)->MutantListHead.Blink, \ 00971 &(_Object_)->MutantListEntry); \ 00972 } \ 00973 } 00974 00975 // 00976 // VOID 00977 // FASTCALL 00978 // KiWaitSatisfyOther ( 00979 // IN PKMUTANT Object 00980 // ) 00981 // 00982 // 00983 // Routine Description: 00984 // 00985 // This function satisfies a wait for any type of object except a mutant 00986 // and performs any side effects that are necessary. 00987 // 00988 // Arguments: 00989 // 00990 // Object - Supplies a pointer to a dispatcher object. 00991 // 00992 // Return Value: 00993 // 00994 // None. 00995 // 00996 00997 #define KiWaitSatisfyOther(_Object_) { \ 00998 if (((_Object_)->Header.Type & DISPATCHER_OBJECT_TYPE_MASK) == EventSynchronizationObject) { \ 00999 (_Object_)->Header.SignalState = 0; \ 01000 \ 01001 } else if ((_Object_)->Header.Type == SemaphoreObject) { \ 01002 (_Object_)->Header.SignalState -= 1; \ 01003 \ 01004 } \ 01005 } 01006 01007 VOID 01008 FASTCALL 01009 KiWaitTest ( 01010 IN PVOID Object, 01011 IN KPRIORITY Increment 01012 ); 01013 01014 VOID 01015 KiFreezeTargetExecution ( 01016 IN PKTRAP_FRAME TrapFrame, 01017 IN PKEXCEPTION_FRAME ExceptionFrame 01018 ); 01019 01020 VOID 01021 KiPollFreezeExecution ( 01022 VOID 01023 ); 01024 01025 VOID 01026 KiSaveProcessorState ( 01027 IN PKTRAP_FRAME TrapFrame, 01028 IN PKEXCEPTION_FRAME ExceptionFrame 01029 ); 01030 01031 VOID 01032 KiSaveProcessorControlState ( 01033 IN PKPROCESSOR_STATE ProcessorState 01034 ); 01035 01036 VOID 01037 KiRestoreProcessorState ( 01038 IN PKTRAP_FRAME TrapFrame, 01039 IN PKEXCEPTION_FRAME ExceptionFrame 01040 ); 01041 01042 VOID 01043 KiRestoreProcessorControlState ( 01044 IN PKPROCESSOR_STATE ProcessorState 01045 ); 01046 01047 #if defined(_ALPHA_) 01048 01049 VOID 01050 KiSynchronizeProcessIds ( 01051 VOID 01052 ); 01053 01054 #endif 01055 01056 BOOLEAN 01057 KiTryToAcquireSpinLock ( 01058 IN PKSPIN_LOCK SpinLock 01059 ); 01060 01061 #if defined(_ALPHA_) 01062 01063 // 01064 // Prototypes for memory barrier instructions 01065 // 01066 01067 VOID 01068 KiImb( 01069 VOID 01070 ); 01071 01072 VOID 01073 KiMb( 01074 VOID 01075 ); 01076 01077 // 01078 // Functions for enabling/disabling alignment exceptions 01079 // 01080 extern ULONG KiEnableAlignmentFaultExceptions; 01081 01082 VOID 01083 KiEnableAlignmentExceptions( 01084 VOID 01085 ); 01086 01087 VOID 01088 KiDisableAlignmentExceptions( 01089 VOID 01090 ); 01091 01092 #else 01093 01094 #define KiEnableAlignmentExceptions() 01095 #define KiDisableAlignmentExceptions() 01096 01097 #endif 01098 01099 #endif // _KI_ 01100 01101 // 01102 // External references to private kernel data structures 01103 // 01104 01105 #if DEVL 01106 extern PMESSAGE_RESOURCE_DATA KiBugCodeMessages; 01107 #endif 01108 01109 extern ULONG KiDmaIoCoherency; 01110 extern ULONG KiMaximumDpcQueueDepth; 01111 extern ULONG KiMinimumDpcRate; 01112 extern ULONG KiAdjustDpcThreshold; 01113 extern KSPIN_LOCK KiContextSwapLock; 01114 extern PKDEBUG_ROUTINE KiDebugRoutine; 01115 extern PKDEBUG_SWITCH_ROUTINE KiDebugSwitchRoutine; 01116 extern KSPIN_LOCK KiDispatcherLock; 01117 extern LIST_ENTRY KiDispatcherReadyListHead[MAXIMUM_PRIORITY]; 01118 extern CCHAR KiFindFirstSetLeft[256]; 01119 extern CALL_PERFORMANCE_DATA KiFlushSingleCallData; 01120 extern ULONG_PTR KiHardwareTrigger; 01121 extern KAFFINITY KiIdleSummary; 01122 extern UCHAR KiFindLeftNibbleBitTable[]; 01123 extern KEVENT KiSwapEvent; 01124 extern LIST_ENTRY KiProcessInSwapListHead; 01125 extern LIST_ENTRY KiProcessOutSwapListHead; 01126 extern LIST_ENTRY KiStackInSwapListHead; 01127 extern LIST_ENTRY KiProfileSourceListHead; 01128 extern BOOLEAN KiProfileAlignmentFixup; 01129 extern ULONG KiProfileAlignmentFixupInterval; 01130 extern ULONG KiProfileAlignmentFixupCount; 01131 extern ULONG KiProfileInterval; 01132 extern LIST_ENTRY KiProfileListHead; 01133 extern KSPIN_LOCK KiProfileLock; 01134 extern ULONG KiReadySummary; 01135 extern UCHAR KiArgumentTable[]; 01136 extern ULONG KiServiceLimit; 01137 extern ULONG_PTR KiServiceTable[]; 01138 extern CALL_PERFORMANCE_DATA KiSetEventCallData; 01139 extern ULONG KiTickOffset; 01140 extern LARGE_INTEGER KiTimeIncrementReciprocal; 01141 extern CCHAR KiTimeIncrementShiftCount; 01142 extern LIST_ENTRY KiTimerTableListHead[TIMER_TABLE_SIZE]; 01143 extern KAFFINITY KiTimeProcessor; 01144 extern KDPC KiTimerExpireDpc; 01145 extern KSPIN_LOCK KiFreezeExecutionLock; 01146 extern BOOLEAN KiSlavesStartExecution; 01147 extern PSWAP_CONTEXT_NOTIFY_ROUTINE KiSwapContextNotifyRoutine; 01148 extern PTHREAD_SELECT_NOTIFY_ROUTINE KiThreadSelectNotifyRoutine; 01149 extern PTIME_UPDATE_NOTIFY_ROUTINE KiTimeUpdateNotifyRoutine; 01150 extern LIST_ENTRY KiWaitInListHead; 01151 extern LIST_ENTRY KiWaitOutListHead; 01152 extern CALL_PERFORMANCE_DATA KiWaitSingleCallData; 01153 extern ULONG KiEnableTimerWatchdog; 01154 01155 #if defined(_IA64_) 01156 01157 extern ULONG KiGlobalRid; 01158 extern ULONG KiMasterRid; 01159 extern ULONG KiMasterSequence; 01160 extern ULONG KiIdealDpcRate; 01161 01162 #if !defined(UP_NT) 01163 01164 extern KSPIN_LOCK KiMasterRidLock; 01165 01166 #endif 01167 01168 VOID 01169 KiSaveEmDebugContext ( 01170 IN OUT PCONTEXT Context 01171 ); 01172 01173 VOID 01174 KiLoadEmDebugContext ( 01175 IN PCONTEXT Context 01176 ); 01177 01178 VOID 01179 KiFlushRse ( 01180 VOID 01181 ); 01182 01183 VOID 01184 KiInvalidateStackedRegisters ( 01185 VOID 01186 ); 01187 01188 VOID 01189 KiSetNewRid ( 01190 ULONG NewGlobalRid, 01191 ULONG NewProcessRid 01192 ); 01193 01194 NTSTATUS 01195 Ki386CheckDivideByZeroTrap( 01196 IN PKTRAP_FRAME Frame 01197 ); 01198 01199 #endif // defined(_IA64_) 01200 01201 #if defined(i386) 01202 01203 extern KIRQL KiProfileIrql; 01204 01205 BOOLEAN 01206 KeInvalidateAllCaches ( 01207 IN BOOLEAN AllProcessors 01208 ); 01209 01210 #endif 01211 01212 #if defined(_ALPHA_) 01213 01214 extern ULONG KiMaximumAsn; 01215 extern ULONGLONG KiMasterSequence; 01216 extern LONG KiMbTimeStamp; 01217 extern ULONG KiSynchIrql; 01218 01219 #endif 01220 01221 #if defined(_ALPHA_) || defined(_IA64_) 01222 01223 extern KINTERRUPT KxUnexpectedInterrupt; 01224 01225 #endif 01226 01227 #if NT_INST 01228 01229 extern KIPI_COUNTS KiIpiCounts[MAXIMUM_PROCESSORS]; 01230 01231 #endif 01232 01233 extern KSPIN_LOCK KiFreezeLockBackup; 01234 extern ULONG KiFreezeFlag; 01235 extern volatile ULONG KiSuspendState; 01236 01237 #if DBG 01238 01239 extern ULONG KiMaximumSearchCount; 01240 01241 #endif 01242 

Generated on Sat May 15 19:40:35 2004 for test by doxygen 1.3.7