00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
#include "ki.h"
00028
00029
VOID
00030
KiFlushUserRseState (
00031 IN PKTRAP_FRAME TrapFrame
00032 );
00033
00034
VOID
00035 KiRestoreProcessorState (
00036 IN PKTRAP_FRAME TrapFrame,
00037 IN PKEXCEPTION_FRAME ExceptionFrame
00038 )
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 {
00061
00062
#if !defined(NT_UP)
00063
00064 PKPRCB Prcb;
00065
00066
00067
00068
00069
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 }
00083
00084
VOID
00085 KiSaveProcessorState (
00086 IN PKTRAP_FRAME TrapFrame,
00087 IN PKEXCEPTION_FRAME ExceptionFrame
00088 )
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 {
00111
00112
#if !defined(NT_UP)
00113
00114 PKPRCB Prcb;
00115
00116
00117
00118
00119
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
00133
00134
00135 Prcb->ProcessorState.SpecialRegisters.StISR = TrapFrame->StISR;
00136
00137
00138
00139
00140
00141
KiSaveProcessorControlState(&Prcb->ProcessorState);
00142
00143
#endif
00144
00145
return;
00146 }
00147
00148 BOOLEAN
00149 KiIpiServiceRoutine (
00150 IN PKTRAP_FRAME TrapFrame,
00151 IN PKEXCEPTION_FRAME ExceptionFrame
00152 )
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175 {
00176 ULONG RequestSummary;
00177
00178
00179
00180
00181
00182 RequestSummary =
KiIpiProcessRequests();
00183
00184
00185
00186
00187
00188
if ((RequestSummary &
IPI_FREEZE) != 0) {
00189
KiFreezeTargetExecution(TrapFrame, ExceptionFrame);
00190 }
00191
00192
return ((RequestSummary & ~
IPI_FREEZE) != 0);
00193 }
00194
00195 ULONG
00196 KiIpiProcessRequests (
00197 VOID
00198 )
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
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
00225
00226
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 }
00250
00251
00252
VOID
00253 KiIpiSend (
00254 IN KAFFINITY TargetProcessors,
00255 IN KIPI_REQUEST IpiRequest
00256 )
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278 {
00279
#if !defined(NT_UP)
00280
ULONG RequestSummary;
00281 KAFFINITY NextProcessors;
00282 ULONG Next;
00283
00284
00285
00286
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 }
00316
00317
00318
VOID
00319 KiIpiSendPacket (
00320 IN KAFFINITY TargetProcessors,
00321 IN PKIPI_WORKER WorkerFunction,
00322 IN PVOID Parameter1,
00323 IN PVOID Parameter2,
00324 IN PVOID Parameter3
00325 )
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
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
00364
00365
00366 __mf();
00367
00368
00369
00370
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
}
00395
00396
00397
#if !defined(NT_UP)
00398
00399
VOID
00400 KiIpiSignalPacketDone (
00401 IN PKPRCB SignalDone
00402 )
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
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 }
00436
00437
#endif // !defined(NT_UP)