00776 :
00777
00778 This routine moves
the selected contents of
the specified context frame into
00779
the specified trap and exception frames according to
the specified context
00780 flags.
00781
00782 Arguments:
00783
00784 TrapFrame - Supplies a pointer to a trap frame that receives
the volatile
00785 context from
the context record.
00786
00787 ExceptionFrame - Supplies a pointer to an exception frame that receives
00788
the nonvolatile context from
the context record.
00789
00790 ContextFrame - Supplies a pointer to a context frame that contains
the
00791 context that
is to be copied into
the trap and exception frames.
00792
00793 ContextFlags - Supplies
the set of flags that specify which parts of
the
00794 context frame are to be copied into
the trap and exception frames.
00795
00796 PreviousMode - Supplies
the processor mode
for which
the trap and exception
00797 frames are being built.
00798
00799 Return Value:
00800
00801 None.
00802
00803 --*/
00804
00805 {
00806
USHORT R1Offset, R4Offset;
00807
USHORT RNatSaveIndex;
00808
SHORT BsFrameSize;
00809
SHORT TempFrameSize;
00810
00811
00812
00813
00814
00815
if ((ContextFlags &
CONTEXT_CONTROL) ==
CONTEXT_CONTROL) {
00816
00817 TrapFrame->IntGp = ContextFrame->IntGp;
00818 TrapFrame->IntSp = ContextFrame->IntSp;
00819 TrapFrame->ApUNAT = ContextFrame->ApUNAT;
00820 TrapFrame->BrRp = ContextFrame->BrRp;
00821 TrapFrame->ApCCV = ContextFrame->ApCCV;
00822 TrapFrame->ApDCR = SANITIZE_DCR(ContextFrame->ApDCR, UserMode);
00823
00824
00825
00826
00827
00828 ExceptionFrame->ApLC = ContextFrame->ApLC;
00829 ExceptionFrame->ApEC &= ~(PFS_EC_MASK << PFS_EC_MASK);
00830 ExceptionFrame->ApEC |= ((ContextFrame->ApEC & PFS_EC_MASK) << PFS_EC_SHIFT);
00831
00832
00833
00834
00835
00836 TrapFrame->RsPFS = ContextFrame->RsPFS;
00837
00838 BsFrameSize = (
SHORT)(ContextFrame->StIFS & PFS_SIZE_MASK);
00839 RNatSaveIndex = (
USHORT)((ContextFrame->RsBSP >> 3) & NAT_BITS_PER_RNAT_REG);
00840
00841 TempFrameSize = RNatSaveIndex + BsFrameSize - NAT_BITS_PER_RNAT_REG;
00842
while (TempFrameSize >= 0) {
00843 BsFrameSize++;
00844 TempFrameSize -= NAT_BITS_PER_RNAT_REG;
00845 }
00846
00847 TrapFrame->RsBSPSTORE = ContextFrame->RsBSPSTORE + BsFrameSize * 8;
00848 TrapFrame->RsBSP = TrapFrame->RsBSPSTORE;
00849 TrapFrame->RsRSC = ContextFrame->RsRSC;
00850 TrapFrame->RsRNAT = ContextFrame->RsRNAT;
00851
00852
#if DEBUG
00853
DbgPrint(
"KeContextToKFrames: RsRNAT = 0x%I64x\n", TrapFrame->RsRNAT);
00854
#endif // DEBUG
00855
00856
00857
00858
00859
00860 TrapFrame->StFPSR = SANITIZE_FSR(ContextFrame->StFPSR, UserMode);
00861 TrapFrame->StIPSR = SANITIZE_PSR(ContextFrame->StIPSR, UserMode);
00862
if (((TrapFrame->StIPSR >> PSR_RI) & 3) == 3) {
00863 TrapFrame->StIPSR &= ~(3i64 << PSR_RI);
00864 }
00865 TrapFrame->StIFS = SANITIZE_IFS(ContextFrame->StIFS, UserMode);
00866 TrapFrame->StIIP = ContextFrame->StIIP;
00867
00868
00869
00870
00871
00872
KeGetCurrentThread()->DebugActive = ((TrapFrame->StIPSR & (1I64 << PSR_DB)) != 0);
00873
00874
00875
00876
00877
00878
if (Thread ==
KeGetCurrentThread()) {
00879 __setReg(CV_IA64_AR21, ContextFrame->StFCR);
00880 __setReg(CV_IA64_AR24, ContextFrame->Eflag);
00881 __setReg(CV_IA64_AR25, ContextFrame->SegCSD);
00882 __setReg(CV_IA64_AR26, ContextFrame->SegSSD);
00883 __setReg(CV_IA64_AR27, ContextFrame->Cflag);
00884 __setReg(CV_IA64_AR28, ContextFrame->StFSR);
00885 __setReg(CV_IA64_AR29, ContextFrame->StFIR);
00886 __setReg(CV_IA64_AR30, ContextFrame->StFDR);
00887 }
else {
00888 PKAPPLICATION_REGISTERS AppRegs;
00889
00890 AppRegs = GET_APPLICATION_REGISTER_SAVEAREA(Thread->StackBase);
00891 AppRegs->Ar21 = ContextFrame->StFCR;
00892 AppRegs->Ar24 = ContextFrame->Eflag;
00893 AppRegs->Ar25 = ContextFrame->SegCSD;
00894 AppRegs->Ar26 = ContextFrame->SegSSD;
00895 AppRegs->Ar27 = ContextFrame->Cflag;
00896 AppRegs->Ar28 = ContextFrame->StFSR;
00897 AppRegs->Ar29 = ContextFrame->StFIR;
00898 AppRegs->Ar30 = ContextFrame->StFDR;
00899 }
00900 }
00901
00902
00903
00904
00905
00906
if ((ContextFlags &
CONTEXT_INTEGER) ==
CONTEXT_INTEGER) {
00907
00908 TrapFrame->IntT0 = ContextFrame->IntT0;
00909 TrapFrame->IntT1 = ContextFrame->IntT1;
00910 TrapFrame->IntT2 = ContextFrame->IntT2;
00911 TrapFrame->IntT3 = ContextFrame->IntT3;
00912 TrapFrame->IntT4 = ContextFrame->IntT4;
00913 TrapFrame->IntV0 = ContextFrame->IntV0;
00914 TrapFrame->IntTeb = ContextFrame->IntTeb;
00915 TrapFrame->Preds = ContextFrame->Preds;
00916
00917
00918
00919
00920
00921 memcpy(&TrapFrame->IntT5, &ContextFrame->IntT5, 18*
sizeof(ULONGLONG));
00922
00923
00924
00925
00926
00927 ExceptionFrame->IntS0 = ContextFrame->IntS0;
00928 ExceptionFrame->IntS1 = ContextFrame->IntS1;
00929 ExceptionFrame->IntS2 = ContextFrame->IntS2;
00930 ExceptionFrame->IntS3 = ContextFrame->IntS3;
00931
00932
00933
00934
00935
00936 R1Offset = (
USHORT)((ULONG_PTR)(&TrapFrame->IntGp) >> 3) & 0x3f;
00937 R4Offset = (
USHORT)((ULONG_PTR)(&ExceptionFrame->IntS0) >> 3) & 0x3f;
00938
00939
EXTRACT_NATS(TrapFrame->IntNats, ContextFrame->IntNats,
00940 1, R1Offset, 0xFFFFFF0E);
00941
EXTRACT_NATS(ExceptionFrame->IntNats, ContextFrame->IntNats,
00942 4, R4Offset, 0xF0);
00943
00944
#if DEBUG
00945
DbgPrint(
"KeContextToKFrames: TF->IntNats = 0x%I64x, ContestFrame->IntNats = 0x%I64x, R1OffSet = 0x%x\n",
00946 TrapFrame->IntNats, ContextFrame->IntNats, R1Offset);
00947
DbgPrint(
"KeContextToKFrames: EF->IntNats = 0x%I64x, R4OffSet = 0x%x\n",
00948 ExceptionFrame->IntNats, R4Offset);
00949
#endif // DEBUG
00950
00951
00952
00953
00954
00955 TrapFrame->BrT0 = ContextFrame->BrT0;
00956 TrapFrame->BrT1 = ContextFrame->BrT1;
00957
00958 memcpy(&ExceptionFrame->BrS0, &ContextFrame->BrS0, 5*
sizeof(ULONGLONG));
00959
00960 }
00961
00962
00963
00964
00965
00966
if ((ContextFlags & CONTEXT_LOWER_FLOATING_POINT) == CONTEXT_LOWER_FLOATING_POINT) {
00967
00968 TrapFrame->StFPSR = SANITIZE_FSR(ContextFrame->StFPSR, UserMode);
00969
00970
00971
00972
00973
00974 RtlCopyIa64FloatRegisterContext(&ExceptionFrame->FltS0,
00975 &ContextFrame->FltS0,
00976
sizeof(FLOAT128) * (4));
00977
00978 RtlCopyIa64FloatRegisterContext(&ExceptionFrame->FltS4,
00979 &ContextFrame->FltS4,
00980 16*
sizeof(FLOAT128));
00981
00982
00983
00984
00985
00986 RtlCopyIa64FloatRegisterContext(&TrapFrame->FltT0,
00987 &ContextFrame->FltT0,
00988
sizeof(FLOAT128) * (10));
00989
00990 }
00991
00992
00993
00994
00995
00996
if ((ContextFlags & CONTEXT_HIGHER_FLOATING_POINT) == CONTEXT_HIGHER_FLOATING_POINT) {
00997
00998 TrapFrame->StFPSR = SANITIZE_FSR(ContextFrame->StFPSR, UserMode);
00999
01000
01001
01002
01003
01004
01005 RtlCopyIa64FloatRegisterContext(
01006 (PFLOAT128)GET_HIGH_FLOATING_POINT_REGISTER_SAVEAREA(),
01007 &ContextFrame->FltF32,
01008 96*
sizeof(FLOAT128)
01009 );
01010
01011 TrapFrame->StIPSR |= (1i64 << PSR_DFH);
01012
01013 }
01014
01015
01016
01017
01018
01019
if ((ContextFlags & CONTEXT_DEBUG) == CONTEXT_DEBUG) {
01020
KiSetDebugContext (TrapFrame, ContextFrame, UserMode);
01021 }
01022
01023
return;
01024 }
}