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.

88 lines
1.5 KiB

  1. /*++
  2. Copyright (c) 1999-2001 Microsoft Corporation. All Rights Reserved.
  3. Module Name:
  4. irq.h
  5. Abstract:
  6. This module contains defines, global variables, and macros used to enable and disable
  7. processor maskable interrupts as well as the processor performance counter interrupt.
  8. Author:
  9. Joseph Ballantyne
  10. Environment:
  11. Kernel Mode
  12. Revision History:
  13. --*/
  14. extern ULONG PerformanceInterruptState;
  15. #define MASKPERF0INT 1
  16. #define SaveAndDisableMaskableInterrupts() \
  17. __asm \
  18. { \
  19. __asm pushfd \
  20. __asm cli \
  21. }
  22. #define RestoreMaskableInterrupts() \
  23. __asm \
  24. { \
  25. __asm popfd \
  26. }
  27. VOID __inline SaveAndDisablePerformanceCounterInterrupt(ULONG *pOldState)
  28. {
  29. __asm {
  30. __asm or PerformanceInterruptState, MASKPERF0INT
  31. __asm mov eax, ApicPerfInterrupt
  32. __asm mov ecx, dword ptr[eax]
  33. __asm or dword ptr[eax], MASKED
  34. __asm mov eax, pOldState
  35. __asm mov dword ptr[eax], ecx
  36. }
  37. }
  38. #define DisablePerformanceCounterInterrupt() \
  39. __asm \
  40. { \
  41. __asm or PerformanceInterruptState, MASKPERF0INT \
  42. __asm mov eax, ApicPerfInterrupt \
  43. __asm or dword ptr[eax], MASKED \
  44. }
  45. #define RestorePerformanceCounterInterrupt(OldState) \
  46. __asm \
  47. { \
  48. __asm mov ecx, OldState \
  49. __asm mov eax, ApicPerfInterrupt \
  50. __asm test ecx, MASKED \
  51. __asm jz unmask \
  52. __asm or PerformanceInterruptState, MASKPERF0INT \
  53. __asm jmp sethardware \
  54. __asm unmask: \
  55. __asm and PerformanceInterruptState, ~(MASKPERF0INT) \
  56. __asm sethardware: \
  57. __asm mov dword ptr[eax], ecx \
  58. }