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

mpipi.c File Reference

#include "ki.h"

Go to the source code of this file.

Functions

VOID KiFlushUserRseState (IN PKTRAP_FRAME TrapFrame)
VOID KiRestoreProcessorState (IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame)
VOID KiSaveProcessorState (IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame)
BOOLEAN KiIpiServiceRoutine (IN PKTRAP_FRAME TrapFrame, IN PKEXCEPTION_FRAME ExceptionFrame)
ULONG KiIpiProcessRequests (VOID)
VOID KiIpiSend (IN KAFFINITY TargetProcessors, IN KIPI_REQUEST IpiRequest)
VOID KiIpiSendPacket (IN KAFFINITY TargetProcessors, IN PKIPI_WORKER WorkerFunction, IN PVOID Parameter1, IN PVOID Parameter2, IN PVOID Parameter3)
VOID KiIpiSignalPacketDone (IN PKPRCB SignalDone)


Function Documentation

VOID KiFlushUserRseState IN PKTRAP_FRAME  TrapFrame  ) 
 

Definition at line 646 of file ke/ia64/context.c.

00652 : 00653 00654 This routine flushes the user rse state from the kernel backing store to the 00655 user backing store. The user context frame is update to reflect the new 00656 context state. 00657 00658 Arguments: 00659 00660 TrapFrame - Supplies a pointer to a trap frame. 00661 00662 Return Value: 00663 00664 None. 00665 00666 --*/ 00667 00668 { 00669 SHORT BsFrameSize; 00670 SHORT RNatSaveIndex; 00671 SHORT Temp; 00672 USHORT TearPointOffset; 00673 ULONGLONG TopBound, BottomBound; 00674 ULONGLONG UserRnats1, UserRnats2; 00675 ULONGLONG Mask; 00676 00677 // 00678 // Copy user stacked registers' contents to user backing store. 00679 // N.B. Stack overflow could happen. 00680 // 00681 00682 try { 00683 00684 BsFrameSize = (SHORT)(TrapFrame->RsBSP - TrapFrame->RsBSPSTORE); 00685 00686 if (BsFrameSize) { 00687 00688 ULONGLONG Bsp, Rnat, KernelInitBsp; 00689 00690 // 00691 // Copy the dirty stacked registers back into the 00692 // user backing store 00693 // 00694 00695 RtlpFlushRSE(&Bsp, &Rnat); 00696 TearPointOffset = (USHORT) TrapFrame->RsBSPSTORE & 0x1F8; 00697 00698 KernelInitBsp= (PCR->InitialBStore | TearPointOffset) + BsFrameSize; 00699 if ((KernelInitBsp | RNAT_ALIGNMENT) != (Bsp | RNAT_ALIGNMENT)) { 00700 Rnat = *(PULONGLONG)(KernelInitBsp | RNAT_ALIGNMENT); 00701 } 00702 00703 RtlCopyMemory((PVOID)(TrapFrame->RsBSPSTORE), 00704 (PVOID)(PCR->InitialBStore + TearPointOffset), 00705 BsFrameSize); 00706 00707 TopBound = TrapFrame->RsBSP | RNAT_ALIGNMENT; 00708 BottomBound = TrapFrame->RsBSPSTORE | RNAT_ALIGNMENT; 00709 00710 RNatSaveIndex = TearPointOffset >> 3; 00711 Mask = (((1ULL << (NAT_BITS_PER_RNAT_REG - RNatSaveIndex)) - 1) << RNatSaveIndex); 00712 UserRnats1 = TrapFrame->RsRNAT & ((1ULL << RNatSaveIndex) - 1); 00713 00714 if (TopBound > BottomBound) { 00715 00716 // 00717 // user dirty stacked GR span across at least one RNAT 00718 // boundary; need to deposit the valid RNAT bits from 00719 // the trap frame into the kernel backing store. Also, 00720 // the RNAT field in the trap frame has to be updated. 00721 // 00722 00723 UserRnats2 = *(PULONGLONG)BottomBound & Mask; 00724 *(PULONGLONG)BottomBound = UserRnats1 | UserRnats2; 00725 TrapFrame->RsRNAT = Rnat; 00726 00727 #if DEBUG 00728 DbgPrint("KiFlushUserRseState 1: UserRnats1 = 0x%I64x, UserRnats2 = 0x%I64x, TF->RsRNAT = 0x%I64x\n", 00729 UserRnats1, UserRnats2, TrapFrame->RsRNAT); 00730 #endif // DEBUG 00731 00732 } else { 00733 00734 // 00735 // user stacked register region does not span across an 00736 // RNAT boundary; combine the RNAT fields from both the 00737 // trap frame and the context frame. 00738 // 00739 00740 UserRnats2 = Rnat & Mask; 00741 TrapFrame->RsRNAT = UserRnats1 | UserRnats2; 00742 00743 #if DEBUG 00744 DbgPrint("KiFlushUserRseState 2: UserRnats1 = 0x%I64x, UserRnats2 = 0x%I64x, TF->RsRNAT = 0x%I64x\n", 00745 UserRnats1, UserRnats2, TrapFrame->RsRNAT); 00746 #endif // DEBUG 00747 00748 } 00749 } 00750 00751 // 00752 // Successfully copied to user backing store; set the user's 00753 // bspstore to the value of its own bsp. 00754 // 00755 00756 TrapFrame->RsBSPSTORE = TrapFrame->RsBSP; 00757 00758 } except (EXCEPTION_EXECUTE_HANDLER) { 00759 DbgPrint("WARNING: Exception raised in krnl-to-user bstore copy\n"); 00760 } 00761 00762 return; 00763 }

ULONG KiIpiProcessRequests VOID   ) 
 

Definition at line 196 of file mpipi.c.

References APC_LEVEL, DISPATCH_LEVEL, IPI_APC, IPI_DPC, KeGetCurrentPrcb, KiRequestSoftwareInterrupt(), and PKIPI_CONTEXT.

Referenced by KiIpiServiceRoutine().

00202 : 00203 00204 This routine processes interprocessor requests and returns a summary 00205 of the requests that were processed. 00206 00207 Arguments: 00208 00209 None. 00210 00211 Return Value: 00212 00213 The request summary is returned as the function value. 00214 00215 --*/ 00216 { 00217 ULONG RequestSummary; 00218 PKPRCB SignalDone; 00219 PKPRCB Prcb = KeGetCurrentPrcb(); 00220 00221 RequestSummary = (ULONG)InterlockedExchange((PLONG)&Prcb->RequestSummary, 0); 00222 00223 // 00224 // If a packet is ready, then get the address of the requested function 00225 // and call the function passing the address of the packet address as a 00226 // parameter. 00227 // 00228 00229 SignalDone = (PKPRCB)Prcb->SignalDone; 00230 00231 if (SignalDone != 0) { 00232 00233 Prcb->SignalDone = 0; 00234 00235 (*SignalDone->WorkerRoutine) ((PKIPI_CONTEXT)SignalDone, 00236 SignalDone->CurrentPacket[0], 00237 SignalDone->CurrentPacket[1], 00238 SignalDone->CurrentPacket[2]); 00239 00240 } 00241 00242 if ((RequestSummary & IPI_APC) != 0) { 00243 KiRequestSoftwareInterrupt (APC_LEVEL); 00244 } else if ((RequestSummary & IPI_DPC) != 0) { 00245 KiRequestSoftwareInterrupt (DISPATCH_LEVEL); 00246 } 00247 00248 return RequestSummary; 00249 }

VOID KiIpiSend IN KAFFINITY  TargetProcessors,
IN KIPI_REQUEST  IpiRequest
 

Definition at line 253 of file mpipi.c.

References HalRequestIpi(), and KiProcessorBlock.

Referenced by KeBugCheckEx(), KeFreezeExecution(), KeInsertQueueDpc(), and KiReadyThread().

00260 : 00261 00262 This routine requests the specified operation on the target set of 00263 processors. 00264 00265 Arguments: 00266 00267 TargetProcessors (a0) - Supplies the set of processors on which the 00268 specified operation is to be executed. 00269 00270 IpiRequest (a1) - Supplies the request operation mask. 00271 00272 Return Value: 00273 00274 None. 00275 00276 --*/ 00277 00278 { 00279 #if !defined(NT_UP) 00280 ULONG RequestSummary; 00281 KAFFINITY NextProcessors; 00282 ULONG Next; 00283 00284 // 00285 // Loop through the target processors and send the packet to the specified 00286 // recipients. 00287 // 00288 00289 NextProcessors = TargetProcessors; 00290 Next = 0; 00291 00292 while (NextProcessors != 0) { 00293 00294 if ((NextProcessors & 1) != 0) { 00295 00296 do { 00297 00298 RequestSummary = KiProcessorBlock[Next]->RequestSummary; 00299 00300 } while(InterlockedCompareExchange( 00301 (PLONG) &KiProcessorBlock[Next]->RequestSummary, 00302 (LONG) (RequestSummary | IpiRequest), 00303 (LONG) RequestSummary) != (LONG) RequestSummary); 00304 } 00305 00306 NextProcessors = NextProcessors >> 1; 00307 00308 Next = Next + 1; 00309 00310 } 00311 HalRequestIpi (TargetProcessors); 00312 #endif 00313 00314 return; 00315 }

VOID KiIpiSendPacket IN KAFFINITY  TargetProcessors,
IN PKIPI_WORKER  WorkerFunction,
IN PVOID  Parameter1,
IN PVOID  Parameter2,
IN PVOID  Parameter3
 

Definition at line 319 of file mpipi.c.

References HalRequestIpi(), KeGetCurrentPrcb, and KiProcessorBlock.

Referenced by Ke386IoSetAccessProcess(), Ke386SetIoAccessMap(), Ke386SetLdtProcess(), Ke386SetVdmInterruptHandler(), KeChangeColorPage(), KeDetachSessionSpace(), KeFlushEntireTb(), KeFlushIoBuffers(), KeFlushMultipleTb(), KeFlushMultipleTb64(), KeFlushSingleTb(), KeFlushSingleTb64(), KeStartProfile(), KeStopProfile(), KeSweepCacheRange(), KeSweepDcache(), KeSweepDcacheRange(), KeSweepIcache(), KeSweepIcacheRange(), KeSynchronizeMemoryAccess(), KiGetNewRid(), KiIpiGenericCall(), and KiSyncNewRegionId().

00329 : 00330 00331 This routine executes the specified worker function on the specified 00332 set of processors. 00333 00334 Arguments: 00335 00336 TargetProcessors (a0) - Supplies the set of processors on which the 00337 specified operation is to be executed. 00338 00339 WorkerFunction (a1) - Supplies the address of the worker function. 00340 00341 Parameter1 - Parameter3 (a2, a3, 4 * 4(sp)) - Supplies worker 00342 function specific parameters. 00343 00344 Return Value: 00345 00346 None. 00347 00348 --*/ 00349 { 00350 #if !defined(NT_UP) 00351 PKPRCB Prcb; 00352 KAFFINITY NextProcessors; 00353 ULONG Next; 00354 00355 Prcb = KeGetCurrentPrcb(); 00356 Prcb->TargetSet = TargetProcessors; 00357 Prcb->WorkerRoutine = WorkerFunction; 00358 Prcb->CurrentPacket[0] = Parameter1; 00359 Prcb->CurrentPacket[1] = Parameter2; 00360 Prcb->CurrentPacket[2] = Parameter3; 00361 00362 // 00363 // synchronize memory access 00364 // 00365 00366 __mf(); 00367 00368 // 00369 // Loop through the target processors and send the packet to the specified 00370 // recipients. 00371 // 00372 00373 NextProcessors = TargetProcessors; 00374 Next = 0; 00375 00376 while (NextProcessors != 0) { 00377 00378 if ((NextProcessors & 1) != 0) { 00379 00380 while(InterlockedCompareExchangePointer( 00381 (PVOID)&KiProcessorBlock[Next]->SignalDone, 00382 (PVOID)Prcb, 00383 (PVOID)0) != (PVOID)0); 00384 00385 } 00386 00387 NextProcessors = NextProcessors >> 1; 00388 00389 Next = Next + 1; 00390 00391 } 00392 HalRequestIpi (TargetProcessors); 00393 #endif 00394 }

BOOLEAN KiIpiServiceRoutine IN PKTRAP_FRAME  TrapFrame,
IN PKEXCEPTION_FRAME  ExceptionFrame
 

Definition at line 149 of file mpipi.c.

References IPI_FREEZE, KiFreezeTargetExecution(), and KiIpiProcessRequests().

00156 : 00157 00158 00159 This function is called at IPI_LEVEL to process any outstanding 00160 interprocess request for the current processor. 00161 00162 Arguments: 00163 00164 TrapFrame - Supplies a pointer to a trap frame. 00165 00166 ExceptionFrame - Supplies a pointer to an exception frame 00167 00168 Return Value: 00169 00170 A value of TRUE is returned, if one of more requests were service. 00171 Otherwise, FALSE is returned. 00172 00173 --*/ 00174 00175 { 00176 ULONG RequestSummary; 00177 00178 // 00179 // Process any outstanding IPI requests 00180 // 00181 00182 RequestSummary = KiIpiProcessRequests(); 00183 00184 // 00185 // If freeze is requested, then freeze target execution. 00186 // 00187 00188 if ((RequestSummary & IPI_FREEZE) != 0) { 00189 KiFreezeTargetExecution(TrapFrame, ExceptionFrame); 00190 } 00191 00192 return ((RequestSummary & ~IPI_FREEZE) != 0); 00193 }

VOID KiIpiSignalPacketDone IN PKPRCB  SignalDone  ) 
 

Definition at line 400 of file mpipi.c.

References KeGetCurrentPrcb.

00406 : 00407 00408 This routine signals that a processor has completed a packet by 00409 clearing the calling processor's set member of the requesting 00410 processor's packet. 00411 00412 Arguments: 00413 00414 SignalDone (a0) - Supplies a pointer to the processor block of the 00415 sending processor. 00416 00417 Return Value: 00418 00419 None. 00420 00421 --*/ 00422 { 00423 PKPRCB Prcb = KeGetCurrentPrcb(); 00424 00425 KAFFINITY TargetSet; 00426 00427 do { 00428 00429 TargetSet = SignalDone->TargetSet; 00430 00431 } while (InterlockedCompareExchange( 00432 (PLONG) &SignalDone->TargetSet, 00433 (LONG) (TargetSet ^ Prcb->SetMember), 00434 (LONG) TargetSet) != (LONG)TargetSet); 00435 }

VOID KiRestoreProcessorState IN PKTRAP_FRAME  TrapFrame,
IN PKEXCEPTION_FRAME  ExceptionFrame
 

Definition at line 35 of file mpipi.c.

References CONTEXT_FULL, KeContextToKframes(), KeGetCurrentPrcb, and KPROCESSOR_MODE.

00042 : 00043 00044 This function moves processor register state from the current 00045 processor context structure in the processor block to the 00046 specified trap and exception frames. 00047 00048 Arguments: 00049 00050 TrapFrame - Supplies a pointer to a trap frame. 00051 00052 ExceptionFrame - Supplies a pointer to an exception frame. 00053 00054 Return Value: 00055 00056 None. 00057 00058 --*/ 00059 00060 { 00061 00062 #if !defined(NT_UP) 00063 00064 PKPRCB Prcb; 00065 00066 // 00067 // Get the address of the current processor block and move the 00068 // specified register state from the processor context structure 00069 // to the specified trap and exception frames 00070 // 00071 00072 Prcb = KeGetCurrentPrcb(); 00073 KeContextToKframes(TrapFrame, 00074 ExceptionFrame, 00075 &Prcb->ProcessorState.ContextFrame, 00076 CONTEXT_FULL, 00077 (KPROCESSOR_MODE)TrapFrame->PreviousMode); 00078 00079 #endif 00080 00081 return; 00082 }

VOID KiSaveProcessorState IN PKTRAP_FRAME  TrapFrame,
IN PKEXCEPTION_FRAME  ExceptionFrame
 

Definition at line 85 of file mpipi.c.

References CONTEXT_FULL, KeContextFromKframes(), KeGetCurrentPrcb, KiFlushUserRseState(), KiSaveProcessorControlState(), and UserMode.

00092 : 00093 00094 This function moves processor register state from the specified trap 00095 and exception frames to the processor context structure in the current 00096 processor block. 00097 00098 Arguments: 00099 00100 TrapFrame - Supplies a pointer to a trap frame. 00101 00102 ExceptionFrame - Supplies a pointer to an exception frame. 00103 00104 Return Value: 00105 00106 None. 00107 00108 --*/ 00109 00110 { 00111 00112 #if !defined(NT_UP) 00113 00114 PKPRCB Prcb; 00115 00116 // 00117 // Get the address of the current processor block and move the 00118 // specified register state from specified trap and exception 00119 // frames to the current processor context structure. 00120 // 00121 00122 Prcb = KeGetCurrentPrcb(); 00123 Prcb->ProcessorState.ContextFrame.ContextFlags = CONTEXT_FULL; 00124 KeContextFromKframes(TrapFrame, 00125 ExceptionFrame, 00126 &Prcb->ProcessorState.ContextFrame); 00127 00128 if (TrapFrame->PreviousMode == UserMode) 00129 KiFlushUserRseState(TrapFrame); 00130 00131 // 00132 // Save ISR in special registers 00133 // 00134 00135 Prcb->ProcessorState.SpecialRegisters.StISR = TrapFrame->StISR; 00136 00137 // 00138 // Save the current processor control state. 00139 // 00140 00141 KiSaveProcessorControlState(&Prcb->ProcessorState); 00142 00143 #endif 00144 00145 return; 00146 }


Generated on Sat May 15 19:44:48 2004 for test by doxygen 1.3.7