00313 :
00314
00315 This function selectively moves
the contents of
the specified context
00316 record to
the specified trap frame and nonvolatile context.
00317
00318 We're expecting a plabel to have been passed in
the IIP (we won't have a valid
00319 Global pointer) and
if we have a plabel we fill in
the correct Global pointer and
00320 IIP. Technically,
the GP
is part of
the CONTEXT_CONTROL with
the EM architecture
00321 so we
only need to check to see
if CONTEXT_CONTROL has been specified.
00322
00323 Arguments:
00324
00325 TrapFrame - Supplies
the address of
the trap frame.
00326
00327 ContextPointers - Supplies
the address of context pointers record.
00328
00329 ContextEM - Supplies
the address of a context record.
00330
00331 ProcessorMode - Supplies
the processor mode to use when sanitizing
00332
the PSR and FSR.
00333
00334 Return Value:
00335
00336 None.
00337
00338 --*/
00339
00340 {
00341
SHORT BsFrameSize;
00342
SHORT TempFrameSize;
00343
USHORT R1Offset, R4Offset;
00344
USHORT RNatSaveIndex;
00345
00346
if ((ContextEM->ContextFlags &
CONTEXT_CONTROL) ==
CONTEXT_CONTROL) {
00347
00348
if (ContextEM->IntGp == 0) {
00349
try {
00350
00351
00352
00353
00354
00355
ProbeForRead(ContextEM->StIIP,
00356
sizeof(PLABEL_DESCRIPTOR),
00357
sizeof(ULONGLONG));
00358 ContextEM->IntGp = ((PPLABEL_DESCRIPTOR)(ContextEM->StIIP))->GlobalPointer;
00359 ContextEM->StIIP = ((PPLABEL_DESCRIPTOR)(ContextEM->StIIP))->EntryPoint;
00360
00361 } except(EXCEPTION_EXECUTE_HANDLER) {
00362
00363
00364
00365
00366
00367
00368 ;
00369 }
00370 }
00371
00372 TrapFrame->IntGp = ContextEM->IntGp;
00373 TrapFrame->IntSp = ContextEM->IntSp;
00374 TrapFrame->ApUNAT = ContextEM->ApUNAT;
00375 TrapFrame->BrRp = ContextEM->BrRp;
00376 TrapFrame->ApCCV = ContextEM->ApCCV;
00377 TrapFrame->ApDCR = SANITIZE_DCR(ContextEM->ApDCR, ProcessorMode);
00378
00379
00380
00381
00382
00383 *ContextPointers->ApLC = ContextEM->ApLC;
00384 *ContextPointers->ApEC &= ~(PFS_EC_MASK << PFS_EC_SHIFT);
00385 *ContextPointers->ApEC |= ((ContextEM->ApEC & PFS_EC_MASK) << PFS_EC_SHIFT);
00386
00387 TrapFrame->StFPSR = SANITIZE_FSR(ContextEM->StFPSR, ProcessorMode);
00388 TrapFrame->StIIP = ContextEM->StIIP;
00389 TrapFrame->StIFS = SANITIZE_IFS(ContextEM->StIFS, ProcessorMode);
00390 TrapFrame->StIPSR = SANITIZE_PSR(ContextEM->StIPSR, ProcessorMode);
00391
00392
if (((TrapFrame->StIPSR >> PSR_RI) & 3) == 3) {
00393
00394
00395
00396
00397
00398 TrapFrame->StIPSR &= ~(3i64 << PSR_RI);
00399 }
00400
00401 TrapFrame->RsPFS = ContextEM->RsPFS;
00402
00403
if (TRAP_FRAME_TYPE(TrapFrame) == SYSCALL_FRAME) {
00404
if (TrapFrame->StIPSR & (1i64 << PSR_SS)) {
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414 TrapFrame->StIPSR |= (1i64 << PSR_LP);
00415 }
00416
00417
00418
00419
00420
00421
00422 BsFrameSize = (
SHORT) (ContextEM->StIFS >> PFS_SIZE_SHIFT) & PFS_SIZE_MASK;
00423 }
else {
00424 BsFrameSize = (
SHORT) ContextEM->StIFS & PFS_SIZE_MASK;
00425 }
00426 RNatSaveIndex = (
USHORT)((ContextEM->RsBSP >> 3) & NAT_BITS_PER_RNAT_REG);
00427
00428 TempFrameSize = RNatSaveIndex + BsFrameSize - NAT_BITS_PER_RNAT_REG;
00429
while (TempFrameSize >= 0) {
00430 BsFrameSize++;
00431 TempFrameSize -= NAT_BITS_PER_RNAT_REG;
00432 }
00433
00434 TrapFrame->RsBSPSTORE = ContextEM->RsBSPSTORE + BsFrameSize * 8;
00435 TrapFrame->RsBSP = TrapFrame->RsBSPSTORE;
00436 TrapFrame->RsRSC = ContextEM->RsRSC;
00437 TrapFrame->RsRNAT = ContextEM->RsRNAT;
00438
00439
#ifdef DEBUG
00440
DbgPrint (
"PspSetContext CONTROL: TrapFrame->RsRNAT = 0x%I64x\n",
00441 TrapFrame->RsRNAT);
00442
#endif
00443
00444
00445
00446
00447
00448
KeGetCurrentThread()->DebugActive = ((TrapFrame->StIPSR & (1I64 << PSR_DB)) != 0);
00449
00450
00451
00452
00453
00454
00455 *ContextPointers->StFSR = ContextEM->StFSR;
00456 *ContextPointers->StFIR = ContextEM->StFIR;
00457 *ContextPointers->StFDR = ContextEM->StFDR;
00458 *ContextPointers->Cflag = ContextEM->Cflag;
00459
00460 }
00461
00462
if ((ContextEM->ContextFlags &
CONTEXT_INTEGER) ==
CONTEXT_INTEGER) {
00463
00464 TrapFrame->IntT0 = ContextEM->IntT0;
00465 TrapFrame->IntT1 = ContextEM->IntT1;
00466 TrapFrame->IntT2 = ContextEM->IntT2;
00467 TrapFrame->IntT3 = ContextEM->IntT3;
00468 TrapFrame->IntT4 = ContextEM->IntT4;
00469 TrapFrame->IntV0 = ContextEM->IntV0;
00470 TrapFrame->IntTeb = ContextEM->IntTeb;
00471 TrapFrame->Preds = ContextEM->Preds;
00472
00473
00474
00475
00476
00477 RtlCopyMemory(&TrapFrame->IntT5, &ContextEM->IntT5, 18*
sizeof(ULONGLONG));
00478
00479
00480
00481
00482
00483 R1Offset = (
USHORT)((ULONG_PTR)(&TrapFrame->IntGp) >> 3) & 0x3f;
00484
00485
EXTRACT_NATS(TrapFrame->IntNats, ContextEM->IntNats,
00486 1, R1Offset, 0xFFFFFF0E);
00487
00488
00489
00490
00491
00492 R4Offset = (
USHORT)((ULONG_PTR)(ContextPointers->IntS0) >> 3) & 0x3f;
00493
00494
00495
00496
00497
00498
00499
00500 *ContextPointers->IntS0 = ContextEM->IntS0;
00501 *ContextPointers->IntS1 = ContextEM->IntS1;
00502 *ContextPointers->IntS2 = ContextEM->IntS2;
00503 *ContextPointers->IntS3 = ContextEM->IntS3;
00504
00505 *ContextPointers->IntS0Nat &= ~(0x1 << (((ULONG_PTR)ContextPointers->IntS0 & 0x1F8) >> 3));
00506 *ContextPointers->IntS1Nat &= ~(0x1 << (((ULONG_PTR)ContextPointers->IntS1 & 0x1F8) >> 3));
00507 *ContextPointers->IntS2Nat &= ~(0x1 << (((ULONG_PTR)ContextPointers->IntS2 & 0x1F8) >> 3));
00508 *ContextPointers->IntS3Nat &= ~(0x1 << (((ULONG_PTR)ContextPointers->IntS3 & 0x1F8) >> 3));
00509
00510 *ContextPointers->IntS0Nat |= (((ContextEM->IntNats >> 4) & 0x1) << (((ULONG_PTR)ContextPointers->IntS0 & 0x1F8) >> 3));
00511 *ContextPointers->IntS1Nat |= (((ContextEM->IntNats >> 4) & 0x1) << (((ULONG_PTR)ContextPointers->IntS1 & 0x1F8) >> 3));
00512 *ContextPointers->IntS2Nat |= (((ContextEM->IntNats >> 4) & 0x1) << (((ULONG_PTR)ContextPointers->IntS2 & 0x1F8) >> 3));
00513 *ContextPointers->IntS3Nat |= (((ContextEM->IntNats >> 4) & 0x1) << (((ULONG_PTR)ContextPointers->IntS3 & 0x1F8) >> 3));
00514
00515
#ifdef DEBUG
00516
DbgPrint(
"PspSetContext INTEGER: R1Offset = 0x%x, TF->IntNats = 0x%I64x, Context->IntNats = 0x%I64x\n",
00517 R1Offset, TrapFrame->IntNats, ContextEM->IntNats);
00518
#endif
00519
00520 *ContextPointers->BrS0 = ContextEM->BrS0;
00521 *ContextPointers->BrS1 = ContextEM->BrS1;
00522 *ContextPointers->BrS2 = ContextEM->BrS2;
00523 *ContextPointers->BrS3 = ContextEM->BrS3;
00524 *ContextPointers->BrS4 = ContextEM->BrS4;
00525 TrapFrame->BrT0 = ContextEM->BrT0;
00526 TrapFrame->BrT1 = ContextEM->BrT1;
00527 }
00528
00529
if ((ContextEM->ContextFlags & CONTEXT_LOWER_FLOATING_POINT) == CONTEXT_LOWER_FLOATING_POINT) {
00530
00531 TrapFrame->StFPSR = SANITIZE_FSR(ContextEM->StFPSR, ProcessorMode);
00532 *ContextPointers->StFSR = ContextEM->StFSR;
00533 *ContextPointers->StFIR = ContextEM->StFIR;
00534 *ContextPointers->StFDR = ContextEM->StFDR;
00535
00536
00537
00538
00539
00540 *ContextPointers->FltS0 = ContextEM->FltS0;
00541 *ContextPointers->FltS1 = ContextEM->FltS1;
00542 *ContextPointers->FltS2 = ContextEM->FltS2;
00543 *ContextPointers->FltS3 = ContextEM->FltS3;
00544
00545 *ContextPointers->FltS4 = ContextEM->FltS4;
00546 *ContextPointers->FltS5 = ContextEM->FltS5;
00547 *ContextPointers->FltS6 = ContextEM->FltS6;
00548 *ContextPointers->FltS7 = ContextEM->FltS7;
00549
00550 *ContextPointers->FltS8 = ContextEM->FltS8;
00551 *ContextPointers->FltS9 = ContextEM->FltS9;
00552 *ContextPointers->FltS10 = ContextEM->FltS10;
00553 *ContextPointers->FltS11 = ContextEM->FltS11;
00554
00555 *ContextPointers->FltS12 = ContextEM->FltS12;
00556 *ContextPointers->FltS13 = ContextEM->FltS13;
00557 *ContextPointers->FltS14 = ContextEM->FltS14;
00558 *ContextPointers->FltS15 = ContextEM->FltS15;
00559
00560 *ContextPointers->FltS16 = ContextEM->FltS16;
00561 *ContextPointers->FltS17 = ContextEM->FltS17;
00562 *ContextPointers->FltS18 = ContextEM->FltS18;
00563 *ContextPointers->FltS19 = ContextEM->FltS19;
00564
00565
00566
00567
00568
00569 RtlCopyIa64FloatRegisterContext(&TrapFrame->FltT0,
00570 &ContextEM->FltT0,
00571
sizeof(FLOAT128) * (10));
00572 }
00573
00574
if ((ContextEM->ContextFlags & CONTEXT_HIGHER_FLOATING_POINT) == CONTEXT_HIGHER_FLOATING_POINT) {
00575
00576
00577 TrapFrame->StFPSR = SANITIZE_FSR(ContextEM->StFPSR, ProcessorMode);
00578 *ContextPointers->StFSR = ContextEM->StFSR;
00579 *ContextPointers->StFIR = ContextEM->StFIR;
00580 *ContextPointers->StFDR = ContextEM->StFDR;
00581
00582
if (ProcessorMode ==
UserMode) {
00583
00584
00585
00586
00587
00588
00589 RtlCopyIa64FloatRegisterContext(
00590 (PFLOAT128)GET_HIGH_FLOATING_POINT_REGISTER_SAVEAREA(),
00591 &ContextEM->FltF32,
00592 96*
sizeof(FLOAT128));
00593
00594
00595
00596
00597
00598
00599 TrapFrame->StIPSR |= (1i64 << PSR_DFH);
00600 }
00601
00602 }
00603
00604
00605
00606
00607
00608
if ((ContextEM->ContextFlags & CONTEXT_DEBUG) == CONTEXT_DEBUG) {
00609
KiSetDebugContext (TrapFrame, ContextEM, ProcessorMode);
00610 }
00611
00612
return;
00613 }