Leaked source code of windows server 2003
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.

167 lines
2.8 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. flush.c
  5. Abstract:
  6. This module implements AMD64 machine dependent kernel functions to
  7. flush the data and instruction caches on all processors.
  8. Author:
  9. David N. Cutler (davec) 22-Apr-2000
  10. Environment:
  11. Kernel mode only.
  12. Revision History:
  13. --*/
  14. #include "ki.h"
  15. //
  16. // Define prototypes for forward referenced functions.
  17. //
  18. VOID
  19. KiInvalidateAllCachesTarget (
  20. IN PKIPI_CONTEXT SignalDone,
  21. IN PVOID Parameter1,
  22. IN PVOID Parameter2,
  23. IN PVOID Parameter3
  24. );
  25. BOOLEAN
  26. KeInvalidateAllCaches (
  27. VOID
  28. )
  29. /*++
  30. Routine Description:
  31. This function writes back and invalidates the cache on all processors
  32. in the host configuration.
  33. Arguments:
  34. None.
  35. Return Value:
  36. TRUE is returned as the function value.
  37. --*/
  38. {
  39. #if !defined(NT_UP)
  40. KIRQL OldIrql;
  41. PKPRCB Prcb;
  42. KAFFINITY TargetProcessors;
  43. //
  44. // Compute the target set of processors, disable context switching,
  45. // and send the writeback invalidate all to the target processors,
  46. // if any, for execution.
  47. //
  48. OldIrql = KeRaiseIrqlToSynchLevel();
  49. Prcb = KeGetCurrentPrcb();
  50. TargetProcessors = KeActiveProcessors & ~Prcb->SetMember;
  51. //
  52. // Send packet to target processors.
  53. //
  54. if (TargetProcessors != 0) {
  55. KiIpiSendPacket(TargetProcessors,
  56. KiInvalidateAllCachesTarget,
  57. NULL,
  58. NULL,
  59. NULL);
  60. }
  61. #endif
  62. //
  63. // Invalidate cache on current processor.
  64. //
  65. WritebackInvalidate();
  66. //
  67. // Wait until all target processors have finished and complete packet.
  68. //
  69. #if !defined(NT_UP)
  70. if (TargetProcessors != 0) {
  71. KiIpiStallOnPacketTargets(TargetProcessors);
  72. }
  73. //
  74. // Lower IRQL to its previous value.
  75. //
  76. KeLowerIrql(OldIrql);
  77. #endif
  78. return TRUE;
  79. }
  80. #if !defined(NT_UP)
  81. VOID
  82. KiInvalidateAllCachesTarget (
  83. IN PKIPI_CONTEXT SignalDone,
  84. IN PVOID Parameter1,
  85. IN PVOID Parameter2,
  86. IN PVOID Parameter3
  87. )
  88. /*++
  89. Routine Description:
  90. This is the target function for writeback invalidating the cache on
  91. target processors.
  92. Arguments:
  93. SignalDone - Supplies a pointer to a variable that is cleared when the
  94. requested operation has been performed.
  95. Parameter2 - Parameter3 - not used.
  96. Return Value:
  97. None.
  98. --*/
  99. {
  100. UNREFERENCED_PARAMETER(Parameter1);
  101. UNREFERENCED_PARAMETER(Parameter2);
  102. UNREFERENCED_PARAMETER(Parameter3);
  103. //
  104. // Write back invalidate current cache.
  105. //
  106. KiIpiSignalPacketDone(SignalDone);
  107. WritebackInvalidate();
  108. return;
  109. }
  110. #endif