Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
2.8 KiB

  1. /**
  2. *** Copyright (C) 1996-97 Intel Corporation. All rights reserved.
  3. ***
  4. *** The information and source code contained herein is the exclusive
  5. *** property of Intel Corporation and may not be disclosed, examined
  6. *** or reproduced in whole or in part without explicit written authorization
  7. *** from the company.
  8. **/
  9. /*++
  10. Copyright (c) 1996 Intel Corporation
  11. Module Name:
  12. floatem.c
  13. Abstract:
  14. This module implements IA64 machine dependent floating point emulation
  15. functions to support the IEEE floating point standard.
  16. Author:
  17. Marius Cornea-Hasegan Sep-96
  18. Environment:
  19. Kernel mode only.
  20. Revision History:
  21. Modfied Jan. 97, Jan 98, Jun 98 (new API)
  22. --*/
  23. #include "ki.h"
  24. #include "ntfpia64.h"
  25. #include "floatem.h"
  26. extern LONG
  27. HalFpEmulate (
  28. ULONG trap_type,
  29. BUNDLE *pBundle,
  30. ULONGLONG *pipsr,
  31. ULONGLONG *pfpsr,
  32. ULONGLONG *pisr,
  33. ULONGLONG *ppreds,
  34. ULONGLONG *pifs,
  35. FP_STATE *fp_state
  36. );
  37. #define ALL_FP_REGISTERS_SAVED 0xFFFFFFFFFFFFFFFFi64
  38. int
  39. fp_emulate (
  40. int trap_type,
  41. BUNDLE *pbundle,
  42. EM_int64_t *pipsr,
  43. EM_int64_t *pfpsr,
  44. EM_int64_t *pisr,
  45. EM_int64_t *ppreds,
  46. EM_int64_t *pifs,
  47. void *fp_state
  48. )
  49. {
  50. //
  51. // Pointer to old Floating point state FLOATING_POINT_STATE
  52. //
  53. FLOATING_POINT_STATE *Ptr0FPState;
  54. PKEXCEPTION_FRAME LocalExceptionFramePtr;
  55. PKTRAP_FRAME LocalTrapFramePtr;
  56. FP_STATE FpState;
  57. KIRQL OldIrql;
  58. BOOLEAN LessThanAPC;
  59. int Status;
  60. Ptr0FPState = (PFLOATING_POINT_STATE) fp_state;
  61. LocalExceptionFramePtr = (PKEXCEPTION_FRAME) (Ptr0FPState->ExceptionFrame);
  62. LocalTrapFramePtr = (PKTRAP_FRAME) (Ptr0FPState->TrapFrame);
  63. FpState.bitmask_low64 = ALL_FP_REGISTERS_SAVED;
  64. FpState.bitmask_high64 = ALL_FP_REGISTERS_SAVED;
  65. (FLOAT128 *)FpState.fp_state_low_preserved = &(LocalExceptionFramePtr->FltS0);
  66. (FLOAT128 *)FpState.fp_state_low_volatile = &(LocalTrapFramePtr->FltT0);
  67. (FLOAT128 *)FpState.fp_state_high_preserved = &(LocalExceptionFramePtr->FltS4);
  68. (FLOAT128 *)FpState.fp_state_high_volatile = (PFLOAT128)GET_HIGH_FLOATING_POINT_REGISTER_SAVEAREA(KeGetCurrentThread()->StackBase);
  69. if (KeGetCurrentIrql() < APC_LEVEL) {
  70. LessThanAPC = 1;
  71. } else {
  72. LessThanAPC = 0;
  73. }
  74. if (LessThanAPC) {
  75. KeRaiseIrql (APC_LEVEL, &OldIrql);
  76. }
  77. Status = HalFpEmulate(trap_type,
  78. pbundle,
  79. pipsr,
  80. pfpsr,
  81. pisr,
  82. ppreds,
  83. pifs,
  84. &FpState
  85. );
  86. if (LessThanAPC) {
  87. KeLowerIrql (OldIrql);
  88. }
  89. return Status;
  90. }