test: psctxmip.c File Reference

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

# psctxmip.c File Reference

`#include "psp.h"`

Go to the source code of this file.

## Functions

ULONGLONG | PspGetSavedValue (IN PVOID ContextPointer)
VOID | PspSetSavedValue (IN ULONGLONG ContextValue, IN PVOID ContextPointer)
VOID | PspGetContext (IN PKTRAP_FRAME TrapFrame, IN PKNONVOLATILE_CONTEXT_POINTERS ContextPointers, IN OUT PCONTEXT ContextRecord)
VOID | PspSetContext (IN OUT PKTRAP_FRAME TrapFrame, IN PKNONVOLATILE_CONTEXT_POINTERS ContextPointers, IN PCONTEXT ContextRecord, IN KPROCESSOR_MODE ProcessorMode)
VOID | PspGetSetContextSpecialApc (IN PKAPC Apc, IN PKNORMAL_ROUTINE *NormalRoutine, IN PVOID *NormalContext, IN PVOID *SystemArgument1, IN PVOID *SystemArgument2)

## Function Documentation

VOID PspGetContext | ( | IN PKTRAP_FRAME | TrapFrame,
|  | IN PKNONVOLATILE_CONTEXT_POINTERS | ContextPointers,
|  | IN OUT PCONTEXT | ContextRecord
| ) |

Definition at line 107 of file psctxmip.c.

References CONTEXT_CONTROL, CONTEXT_EXTENDED_INTEGER, CONTEXT_FLOATING_POINT, CONTEXT_INTEGER, Index, and PspGetSavedValue().

    00115                    :
    00116
    00117     This function selectively moves the contents of the specified trap frame
    00118     and nonvolatile context to the specified context record.
    00119
    00120 Arguments:
    00121
    00122     TrapFrame - Supplies a pointer to a trap frame.
    00123
    00124     ContextPointers - Supplies the address of context pointers record.
    00125
    00126     ContextRecord - Supplies the address of a context record.
    00127
    00128 Return Value:
    00129
    00130     None.
    00131
    00132 --*/
    00133
    00134 {
    00135
    00136     ULONG ContextFlags;
    00137     LONG Index;
    00138
    00139     //
    00140     // Get context.
    00141     //
    00142
    00143     ContextFlags = ContextRecord->ContextFlags;
    00144     if ((ContextFlags & CONTEXT_CONTROL) == CONTEXT_CONTROL) {
    00145
    00146         //
    00147         // Get integer registers gp, sp, ra, FIR, and PSR.
    00148         //
    00149
    00150         ContextRecord->Fir = TrapFrame->Fir;
    00151         ContextRecord->Psr = TrapFrame->Psr;
    00152         if ((ContextFlags & CONTEXT_EXTENDED_INTEGER) != CONTEXT_EXTENDED_INTEGER) {
    00153             ContextRecord->IntGp = (ULONG)TrapFrame->XIntGp;
    00154             ContextRecord->IntSp = (ULONG)TrapFrame->XIntSp;
    00155             ContextRecord->IntRa = (ULONG)TrapFrame->XIntRa;
    00156
    00157         } else {
    00158             ContextRecord->XIntGp = TrapFrame->XIntGp;
    00159             ContextRecord->XIntSp = TrapFrame->XIntSp;
    00160             ContextRecord->XIntRa = TrapFrame->XIntRa;
    00161         }
    00162     }
    00163
    00164     if ((ContextFlags & CONTEXT_INTEGER) == CONTEXT_INTEGER) {
    00165
    00166         //
    00167         // Get integer registers zero, and, at - t9, k0, k1, lo, and hi.
    00168         //
    00169
    00170         if ((ContextFlags & CONTEXT_EXTENDED_INTEGER) != CONTEXT_EXTENDED_INTEGER) {
    00171             ContextRecord->IntZero = 0;
    00172             ContextRecord->IntAt = (ULONG)TrapFrame->XIntAt;
    00173             ContextRecord->IntV0 = (ULONG)TrapFrame->XIntV0;
    00174             ContextRecord->IntV1 = (ULONG)TrapFrame->XIntV1;
    00175             ContextRecord->IntA0 = (ULONG)TrapFrame->XIntA0;
    00176             ContextRecord->IntA1 = (ULONG)TrapFrame->XIntA1;
    00177             ContextRecord->IntA2 = (ULONG)TrapFrame->XIntA2;
    00178             ContextRecord->IntA3 = (ULONG)TrapFrame->XIntA3;
    00179             ContextRecord->IntT0 = (ULONG)TrapFrame->XIntT0;
    00180             ContextRecord->IntT1 = (ULONG)TrapFrame->XIntT1;
    00181             ContextRecord->IntT2 = (ULONG)TrapFrame->XIntT2;
    00182             ContextRecord->IntT3 = (ULONG)TrapFrame->XIntT3;
    00183             ContextRecord->IntT4 = (ULONG)TrapFrame->XIntT4;
    00184             ContextRecord->IntT5 = (ULONG)TrapFrame->XIntT5;
    00185             ContextRecord->IntT6 = (ULONG)TrapFrame->XIntT6;
    00186             ContextRecord->IntT7 = (ULONG)TrapFrame->XIntT7;
    00187             ContextRecord->IntT8 = (ULONG)TrapFrame->XIntT8;
    00188             ContextRecord->IntT9 = (ULONG)TrapFrame->XIntT9;
    00189             ContextRecord->IntK0 = 0;
    00190             ContextRecord->IntK1 = 0;
    00191             ContextRecord->IntLo = (ULONG)TrapFrame->XIntLo;
    00192             ContextRecord->IntHi = (ULONG)TrapFrame->XIntHi;
    00193
    00194         } else {
    00195             ContextRecord->XIntZero = 0;
    00196             ContextRecord->XIntAt = TrapFrame->XIntAt;
    00197             ContextRecord->XIntV0 = TrapFrame->XIntV0;
    00198             ContextRecord->XIntV1 = TrapFrame->XIntV1;
    00199             ContextRecord->XIntA0 = TrapFrame->XIntA0;
    00200             ContextRecord->XIntA1 = TrapFrame->XIntA1;
    00201             ContextRecord->XIntA2 = TrapFrame->XIntA2;
    00202             ContextRecord->XIntA3 = TrapFrame->XIntA3;
    00203             ContextRecord->XIntT0 = TrapFrame->XIntT0;
    00204             ContextRecord->XIntT1 = TrapFrame->XIntT1;
    00205             ContextRecord->XIntT2 = TrapFrame->XIntT2;
    00206             ContextRecord->XIntT3 = TrapFrame->XIntT3;
    00207             ContextRecord->XIntT4 = TrapFrame->XIntT4;
    00208             ContextRecord->XIntT5 = TrapFrame->XIntT5;
    00209             ContextRecord->XIntT6 = TrapFrame->XIntT6;
    00210             ContextRecord->XIntT7 = TrapFrame->XIntT7;
    00211             ContextRecord->XIntT8 = TrapFrame->XIntT8;
    00212             ContextRecord->XIntT9 = TrapFrame->XIntT9;
    00213             ContextRecord->XIntK0 = 0;
    00214             ContextRecord->XIntK1 = 0;
    00215             ContextRecord->XIntLo = TrapFrame->XIntLo;
    00216             ContextRecord->XIntHi = TrapFrame->XIntHi;
    00217         }
    00218
    00219         //
    00220         // Get nonvolatile integer registers s0 - s7, and s8.
    00221         //
    00222
    00223         if ((ContextFlags & CONTEXT_EXTENDED_INTEGER) != CONTEXT_EXTENDED_INTEGER) {
    00224             Index = 7;
    00225             do {
    00226                 if (TrapFrame->SavedFlag == 0) {
    00227                     (&ContextRecord->IntS0)[Index] =
    00228                         (ULONG)PspGetSavedValue((&ContextPointers->XIntS0)[Index]);
    00229
    00230                 } else {
    00231                     (&ContextRecord->IntS0)[Index] = (ULONG)(&TrapFrame->XIntS0)[Index];
    00232                 }
    00233
    00234                 Index -= 1;
    00235             } while (Index >= 0);
    00236             ContextRecord->IntS8 = (ULONG)TrapFrame->XIntS8;
    00237
    00238         } else {
    00239             Index = 7;
    00240             do {
    00241                 if (TrapFrame->SavedFlag == 0) {
    00242                     (&ContextRecord->XIntS0)[Index] =
    00243                         PspGetSavedValue((&ContextPointers->XIntS0)[Index]);
    00244
    00245                 } else {
    00246                     (&ContextRecord->XIntS0)[Index] = (&TrapFrame->XIntS0)[Index];
    00247                 }
    00248
    00249                 Index -= 1;
    00250             } while (Index >= 0);
    00251             ContextRecord->XIntS8 = TrapFrame->XIntS8;
    00252         }
    00253     }
    00254
    00255     if ((ContextFlags & CONTEXT_FLOATING_POINT) == CONTEXT_FLOATING_POINT) {
    00256
    00257         //
    00258         // Get volatile floating registers f0 - f19.
    00259         //
    00260
    00261         RtlMoveMemory(&ContextRecord->FltF0, &TrapFrame->FltF0,
    00262                      sizeof(ULONG) * (20));
    00263
    00264         //
    00265         // Get nonvolatile floating registers f20 - f31.
    00266         //
    00267
    00268         ContextRecord->FltF20 = *ContextPointers->FltF20;
    00269         ContextRecord->FltF21 = *ContextPointers->FltF21;
    00270         ContextRecord->FltF22 = *ContextPointers->FltF22;
    00271         ContextRecord->FltF23 = *ContextPointers->FltF23;
    00272         ContextRecord->FltF24 = *ContextPointers->FltF24;
    00273         ContextRecord->FltF25 = *ContextPointers->FltF25;
    00274         ContextRecord->FltF26 = *ContextPointers->FltF26;
    00275         ContextRecord->FltF27 = *ContextPointers->FltF27;
    00276         ContextRecord->FltF28 = *ContextPointers->FltF28;
    00277         ContextRecord->FltF29 = *ContextPointers->FltF29;
    00278         ContextRecord->FltF30 = *ContextPointers->FltF30;
    00279         ContextRecord->FltF31 = *ContextPointers->FltF31;
    00280
    00281         //
    00282         // Get floating status register.
    00283         //
    00284
    00285         ContextRecord->Fsr = TrapFrame->Fsr;
    00286     }
    00287
    00288     return;
    00289 }

ULONGLONG PspGetSavedValue | ( | IN PVOID | ContextPointer | ) |

Definition at line 24 of file psctxmip.c.

Referenced by PspGetContext().

    00030                    :
    00031
    00032     This function loads the context value specified by the argument
    00033     pointer.
    00034
    00035     N.B. The low bit of the pointer specifies the operand type.
    00036
    00037 Arguments:
    00038
    00039     ContextPointer - Supplies a pointer to the context value that is
    00040         loaded.
    00041
    00042 Return Value:
    00043
    00044     The value specified by the argument pointer.
    00045
    00046 --*/
    00047
    00048 {
    00049
    00050     //
    00051     // If the low bit of the argument pointer is zero, then the argument
    00052     // value is 32-bits. Otherwise, the argument value is 64-bits.
    00053     //
    00054
    00055     if (((ULONG)ContextPointer & 1) != 0) {
    00056         return *((PULONGLONG)((ULONG)ContextPointer & ~1));
    00057
    00058     } else {
    00059         return *((PLONG)ContextPointer);
    00060     }
    00061 }

VOID PspGetSetContextSpecialApc | ( | IN PKAPC | Apc,
|  | IN PKNORMAL_ROUTINE * | NormalRoutine,
|  | IN PVOID * | NormalContext,
|  | IN PVOID * | SystemArgument1,
|  | IN PVOID * | SystemArgument2
| ) |

Definition at line 475 of file psctxmip.c.

References _GETSETCONTEXT::Context, FALSE, _KTHREAD::InitialStack, KeSetEvent(), _GETSETCONTEXT::Mode, NULL, _GETSETCONTEXT::OperationComplete, PsGetCurrentThread, PspGetContext(), PspSetContext(), RtlLookupFunctionEntry(), RtlVirtualUnwind(), and _ETHREAD::Tcb.

    00485                    :
    00486
    00487     This function either captures the user mode state of the current
    00488     thread, or sets the user mode state of the current thread. The
    00489     operation type is determined by the value of SystemArgument1. A
    00490     zero value is used for get context, and a nonzero value is used
    00491     for set context.
    00492
    00493 Arguments:
    00494
    00495     Apc - Supplies a pointer to the APC control object that caused entry
    00496           into this routine.
    00497
    00498     NormalRoutine - Supplies a pointer to the normal routine function that
    00499         was specified when the APC was initialized. This parameter is not
    00500         used.
    00501
    00502     NormalContext - Supplies a pointer to an arbitrary data structure that
    00503         was specified when the APC was initialized. This parameter is not
    00504         used.
    00505
    00506     SystemArgument1, SystemArgument2 - Supplies a set of two pointer to two
    00507         arguments that contain untyped data. These parameters are not used.
    00508
    00509 Return Value:
    00510
    00511     None.
    00512
    00513 --*/
    00514
    00515 {
    00516
    00517     PGETSETCONTEXT ContextBlock;
    00518     KNONVOLATILE_CONTEXT_POINTERS ContextPointers;
    00519     CONTEXT ContextRecord;
    00520     ULONG ControlPc;
    00521     ULONG EstablisherFrame;
    00522     PRUNTIME_FUNCTION FunctionEntry;
    00523     BOOLEAN InFunction;
    00524     PETHREAD Thread;
    00525     ULONG TrapFrame1;
    00526     ULONG TrapFrame2;
    00527
    00528     //
    00529     // Get the address of the context block and compute the address of the
    00530     // system entry trap frame.
    00531     //
    00532
    00533     ContextBlock = CONTAINING_RECORD(Apc, GETSETCONTEXT, Apc);
    00534     Thread = PsGetCurrentThread();
    00535     TrapFrame1 = (ULONG)Thread->Tcb.InitialStack - KTRAP_FRAME_LENGTH;
    00536     TrapFrame2 = (ULONG)Thread->Tcb.InitialStack - KTRAP_FRAME_LENGTH - KTRAP_FRAME_ARGUMENTS;
    00537
    00538     //
    00539     // Capture the current thread context and set the initial control PC
    00540     // value.
    00541     //
    00542
    00543     RtlCaptureContext(&ContextRecord);
    00544     ControlPc = (ULONG)ContextRecord.XIntRa;
    00545
    00546     //
    00547     // Initialize context pointers for the nonvolatile integer and floating
    00548     // registers.
    00549     //
    00550
    00551     ContextPointers.XIntS0 = &ContextRecord.XIntS0;
    00552     ContextPointers.XIntS1 = &ContextRecord.XIntS1;
    00553     ContextPointers.XIntS2 = &ContextRecord.XIntS2;
    00554     ContextPointers.XIntS3 = &ContextRecord.XIntS3;
    00555     ContextPointers.XIntS4 = &ContextRecord.XIntS4;
    00556     ContextPointers.XIntS5 = &ContextRecord.XIntS5;
    00557     ContextPointers.XIntS6 = &ContextRecord.XIntS6;
    00558     ContextPointers.XIntS7 = &ContextRecord.XIntS7;
    00559
    00560     ContextPointers.FltF20 = &ContextRecord.FltF20;
    00561     ContextPointers.FltF21 = &ContextRecord.FltF21;
    00562     ContextPointers.FltF22 = &ContextRecord.FltF22;
    00563     ContextPointers.FltF23 = &ContextRecord.FltF23;
    00564     ContextPointers.FltF24 = &ContextRecord.FltF24;
    00565     ContextPointers.FltF25 = &ContextRecord.FltF25;
    00566     ContextPointers.FltF26 = &ContextRecord.FltF26;
    00567     ContextPointers.FltF27 = &ContextRecord.FltF27;
    00568     ContextPointers.FltF28 = &ContextRecord.FltF28;
    00569     ContextPointers.FltF29 = &ContextRecord.FltF29;
    00570     ContextPointers.FltF30 = &ContextRecord.FltF30;
    00571     ContextPointers.FltF31 = &ContextRecord.FltF31;
    00572
    00573     //
    00574     // Start with the frame specified by the context record and virtually
    00575     // unwind call frames until the system entry trap frame is encountered.
    00576     //
    00577
    00578     do {
    00579
    00580         //
    00581         // Lookup the function table entry using the point at which control
    00582         // left the procedure.
    00583         //
    00584
    00585         FunctionEntry = RtlLookupFunctionEntry(ControlPc);
    00586
    00587         //
    00588         // If there is a function table entry for the routine, then virtually
    00589         // unwind to the caller of the current routine to obtain the address
    00590         // where control left the caller. Otherwise, the function is a leaf
    00591         // function and the return address register contains the address of
    00592         // where control left the caller.
    00593         //
    00594
    00595         if (FunctionEntry != NULL) {
    00596             ControlPc = RtlVirtualUnwind(ControlPc | 1,
    00597                                          FunctionEntry,
    00598                                          &ContextRecord,
    00599                                          &InFunction,
    00600                                          &EstablisherFrame,
    00601                                          &ContextPointers);
    00602
    00603         } else {
    00604             ControlPc = (ULONG)ContextRecord.XIntRa;
    00605         }
    00606
    00607     } while (((ULONG)ContextRecord.XIntSp != TrapFrame1) &&
    00608              (((ULONG)ContextRecord.XIntSp != TrapFrame2) ||
    00609              (ControlPc < PCR->SystemServiceDispatchStart) ||
    00610              (ControlPc >= PCR->SystemServiceDispatchEnd)));
    00611
    00612     //
    00613     // If system argument one is nonzero, then set the context of the current
    00614     // thread. Otherwise, get the context of the current thread.
    00615     //
    00616
    00617     if (Apc->SystemArgument1 != 0) {
    00618
    00619         //
    00620         // Set context of current thread.
    00621         //
    00622
    00623         PspSetContext((PKTRAP_FRAME)TrapFrame1,
    00624                       &ContextPointers,
    00625                       &ContextBlock->Context,
    00626                       ContextBlock->Mode);
    00627
    00628     } else {
    00629
    00630         //
    00631         // Get context of current thread.
    00632         //
    00633
    00634         PspGetContext((PKTRAP_FRAME)TrapFrame1,
    00635                       &ContextPointers,
    00636                       &ContextBlock->Context);
    00637     }
    00638
    00639     KeSetEvent(&ContextBlock->OperationComplete, 0, FALSE);
    00640     return;
    00641 }
    }

VOID PspSetContext | ( | IN OUT PKTRAP_FRAME | TrapFrame,
|  | IN PKNONVOLATILE_CONTEXT_POINTERS | ContextPointers,
|  | IN PCONTEXT | ContextRecord,
|  | IN KPROCESSOR_MODE | ProcessorMode
| ) |

Definition at line 292 of file psctxmip.c.

References CONTEXT_CONTROL, CONTEXT_EXTENDED_INTEGER, CONTEXT_FLOATING_POINT, CONTEXT_INTEGER, Index, and PspSetSavedValue().

    00301                    :
    00302
    00303     This function selectively moves the contents of the specified context
    00304     record to the specified trap frame and nonvolatile context.
    00305
    00306 Arguments:
    00307
    00308     TrapFrame - Supplies the address of a trap frame.
    00309
    00310     ContextPointers - Supplies the address of a context pointers record.
    00311
    00312     ContextRecord - Supplies the address of a context record.
    00313
    00314     ProcessorMode - Supplies the processor mode to use when sanitizing
    00315         the PSR and FSR.
    00316
    00317 Return Value:
    00318
    00319     None.
    00320
    00321 --*/
    00322
    00323 {
    00324
    00325     ULONG ContextFlags;
    00326     LONG Index;
    00327
    00328     //
    00329     // Set context.
    00330     //
    00331
    00332     ContextFlags = ContextRecord->ContextFlags;
    00333     if ((ContextFlags & CONTEXT_CONTROL) == CONTEXT_CONTROL) {
    00334
    00335         //
    00336         // Set integer registers gp, sp, ra, FIR, and PSR.
    00337         //
    00338
    00339         TrapFrame->Fir = ContextRecord->Fir;
    00340         TrapFrame->Psr = SANITIZE_PSR(ContextRecord->Psr, ProcessorMode);
    00341         if ((ContextFlags & CONTEXT_EXTENDED_INTEGER) != CONTEXT_EXTENDED_INTEGER) {
    00342             TrapFrame->XIntGp = (LONG)ContextRecord->IntGp;
    00343             TrapFrame->XIntSp = (LONG)ContextRecord->IntSp;
    00344             TrapFrame->XIntRa = (LONG)ContextRecord->IntRa;
    00345
    00346         } else {
    00347             TrapFrame->XIntGp = ContextRecord->XIntGp;
    00348             TrapFrame->XIntSp = ContextRecord->XIntSp;
    00349             TrapFrame->XIntRa = ContextRecord->XIntRa;
    00350         }
    00351     }
    00352
    00353     if ((ContextFlags & CONTEXT_INTEGER) == CONTEXT_INTEGER) {
    00354
    00355         //
    00356         // Set integer registers at - t9, lo, and hi.
    00357         //
    00358
    00359         if ((ContextFlags & CONTEXT_EXTENDED_INTEGER) != CONTEXT_EXTENDED_INTEGER) {
    00360             TrapFrame->XIntAt = (LONG)ContextRecord->IntAt;
    00361             TrapFrame->XIntV0 = (LONG)ContextRecord->IntV0;
    00362             TrapFrame->XIntV1 = (LONG)ContextRecord->IntV1;
    00363             TrapFrame->XIntA0 = (LONG)ContextRecord->IntA0;
    00364             TrapFrame->XIntA1 = (LONG)ContextRecord->IntA1;
    00365             TrapFrame->XIntA2 = (LONG)ContextRecord->IntA2;
    00366             TrapFrame->XIntA3 = (LONG)ContextRecord->IntA3;
    00367             TrapFrame->XIntT0 = (LONG)ContextRecord->IntT0;
    00368             TrapFrame->XIntT1 = (LONG)ContextRecord->IntT1;
    00369             TrapFrame->XIntT2 = (LONG)ContextRecord->IntT2;
    00370             TrapFrame->XIntT3 = (LONG)ContextRecord->IntT3;
    00371             TrapFrame->XIntT4 = (LONG)ContextRecord->IntT4;
    00372             TrapFrame->XIntT5 = (LONG)ContextRecord->IntT5;
    00373             TrapFrame->XIntT6 = (LONG)ContextRecord->IntT6;
    00374             TrapFrame->XIntT7 = (LONG)ContextRecord->IntT7;
    00375             TrapFrame->XIntT8 = (LONG)ContextRecord->IntT8;
    00376             TrapFrame->XIntT9 = (LONG)ContextRecord->IntT9;
    00377             TrapFrame->XIntLo = (LONG)ContextRecord->IntLo;
    00378             TrapFrame->XIntHi = (LONG)ContextRecord->IntHi;
    00379
    00380         } else {
    00381             TrapFrame->XIntAt = ContextRecord->XIntAt;
    00382             TrapFrame->XIntV0 = ContextRecord->XIntV0;
    00383             TrapFrame->XIntV1 = ContextRecord->XIntV1;
    00384             TrapFrame->XIntA0 = ContextRecord->XIntA0;
    00385             TrapFrame->XIntA1 = ContextRecord->XIntA1;
    00386             TrapFrame->XIntA2 = ContextRecord->XIntA2;
    00387             TrapFrame->XIntA3 = ContextRecord->XIntA3;
    00388             TrapFrame->XIntT0 = ContextRecord->XIntT0;
    00389             TrapFrame->XIntT1 = ContextRecord->XIntT1;
    00390             TrapFrame->XIntT2 = ContextRecord->XIntT2;
    00391             TrapFrame->XIntT3 = ContextRecord->XIntT3;
    00392             TrapFrame->XIntT4 = ContextRecord->XIntT4;
    00393             TrapFrame->XIntT5 = ContextRecord->XIntT5;
    00394             TrapFrame->XIntT6 = ContextRecord->XIntT6;
    00395             TrapFrame->XIntT7 = ContextRecord->XIntT7;
    00396             TrapFrame->XIntT8 = ContextRecord->XIntT8;
    00397             TrapFrame->XIntT9 = ContextRecord->XIntT9;
    00398             TrapFrame->XIntLo = ContextRecord->XIntLo;
    00399             TrapFrame->XIntHi = ContextRecord->XIntHi;
    00400         }
    00401
    00402         //
    00403         // Set nonvolatile integer registers s0 - s7, and s8.
    00404         //
    00405
    00406         if ((ContextFlags & CONTEXT_EXTENDED_INTEGER) != CONTEXT_EXTENDED_INTEGER) {
    00407             Index = 7;
    00408             do {
    00409                 if (TrapFrame->SavedFlag == 0) {
    00410                     PspSetSavedValue((LONG)(&ContextRecord->IntS0)[Index],
    00411                                      (&ContextPointers->XIntS0)[Index]);
    00412
    00413                 } else {
    00414                     (&TrapFrame->XIntS0)[Index] = (LONG)(&ContextRecord->IntS0)[Index];
    00415                 }
    00416
    00417                 Index -= 1;
    00418             } while (Index >= 0);
    00419             TrapFrame->XIntS8 = (LONG)ContextRecord->IntS8;
    00420
    00421         } else {
    00422             Index = 7;
    00423             do {
    00424                 if (TrapFrame->SavedFlag == 0) {
    00425                     PspSetSavedValue((&ContextRecord->XIntS0)[Index],
    00426                                      (&ContextPointers->XIntS0)[Index]);
    00427
    00428                 } else {
    00429                     (&TrapFrame->XIntS0)[Index] = (&ContextRecord->XIntS0)[Index];
    00430                 }
    00431
    00432                 Index -= 1;
    00433             } while (Index >= 0);
    00434             TrapFrame->XIntS8 = ContextRecord->XIntS8;
    00435         }
    00436     }
    00437
    00438     if ((ContextFlags & CONTEXT_FLOATING_POINT) == CONTEXT_FLOATING_POINT) {
    00439
    00440         //
    00441         // Set volatile floating registers f0 - f19.
    00442         //
    00443
    00444         RtlMoveMemory(&TrapFrame->FltF0, &ContextRecord->FltF0,
    00445                      sizeof(ULONG) * (20));
    00446
    00447         //
    00448         // Set nonvolatile floating registers f20 - f31.
    00449         //
    00450
    00451         *ContextPointers->FltF20 = ContextRecord->FltF20;
    00452         *ContextPointers->FltF21 = ContextRecord->FltF21;
    00453         *ContextPointers->FltF22 = ContextRecord->FltF22;
    00454         *ContextPointers->FltF23 = ContextRecord->FltF23;
    00455         *ContextPointers->FltF24 = ContextRecord->FltF24;
    00456         *ContextPointers->FltF25 = ContextRecord->FltF25;
    00457         *ContextPointers->FltF26 = ContextRecord->FltF26;
    00458         *ContextPointers->FltF27 = ContextRecord->FltF27;
    00459         *ContextPointers->FltF28 = ContextRecord->FltF28;
    00460         *ContextPointers->FltF29 = ContextRecord->FltF29;
    00461         *ContextPointers->FltF30 = ContextRecord->FltF30;
    00462         *ContextPointers->FltF31 = ContextRecord->FltF31;
    00463
    00464         //
    00465         // Set floating status register.
    00466         //
    00467
    00468         TrapFrame->Fsr = SANITIZE_FSR(ContextRecord->Fsr, ProcessorMode);
    00469     }
    00470
    00471     return;
    00472 }

VOID PspSetSavedValue | ( | IN ULONGLONG | ContextValue,
|  | IN PVOID | ContextPointer
| ) |

Definition at line 64 of file psctxmip.c.

Referenced by PspSetContext().

    00071                    :
    00072
    00073     This function stores the context value specified in the location
    00074     specified by the argument pointer.
    00075
    00076     N.B. The low bit of the pointer specifies the operand type.
    00077
    00078 Arguments:
    00079
    00080     ContextValue - Supplies the context value to be stored.
    00081
    00082     ContextPointer - Supplies a pointer to the context value that is
    00083         stored.
    00084
    00085 Return Value:
    00086
    00087     None.
    00088
    00089 --*/
    00090
    00091 {
    00092
    00093     //
    00094     // If the low bit of the argument pointer is zero, then the argument
    00095     // value is 32-bits. Otherwise, the argument value is 64-bits.
    00096     //
    00097
    00098     if (((ULONG)ContextPointer & 1) != 0) {
    00099         *((PULONGLONG)((ULONG)ContextPointer & ~1)) = ContextValue;
    00100
    00101     } else {
    00102         *((PULONG)ContextPointer) = (ULONG)ContextValue;
    00103     }
    00104 }