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.

257 lines
5.3 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. kix86.h
  5. Abstract:
  6. This module contains the private (internal) platform specific header file
  7. for the kernel.
  8. Author:
  9. David N. Cutler (davec) 17-May-2000
  10. Revision History:
  11. --*/
  12. #if !defined(_KIX86_)
  13. #define _KIX86_
  14. //
  15. // VOID
  16. // KiIpiSendSynchronousPacket (
  17. // IN PKPRCB Prcb,
  18. // IN KAFFINITY TargetProcessors,
  19. // IN PKIPI_WORKER WorkerFunction,
  20. // IN PVOID Parameter1,
  21. // IN PVOID Parameter2,
  22. // IN PVOID Parameter3
  23. // )
  24. //
  25. // Routine Description:
  26. //
  27. // Similar to KiIpiSendPacket except that the pointer to the
  28. // originating PRCB (SignalDone) is kept in the global variable
  29. // KiSynchPacket and is protected by the context swap lock. The
  30. // actual IPI is sent via KiIpiSend with a request type of
  31. // IPI_SYNCH_REQUEST. This mechanism is used to send IPI's that
  32. // (reverse) stall until released by the originator. This avoids
  33. // a deadlock that can occur if two processors are trying to deliver
  34. // IPI packets at the same time and one of them is a reverse stall.
  35. //
  36. // N.B. The low order bit of the packet address is set if there is
  37. // exactly one target recipient. Otherwise, the low order bit
  38. // of the packet address is clear.
  39. //
  40. #define KiIpiSendSynchronousPacket(Prcb,Target,Function,P1,P2,P3) \
  41. { \
  42. extern PKPRCB KiSynchPacket; \
  43. \
  44. Prcb->CurrentPacket[0] = (PVOID)(P1); \
  45. Prcb->CurrentPacket[1] = (PVOID)(P2); \
  46. Prcb->CurrentPacket[2] = (PVOID)(P3); \
  47. Prcb->TargetSet = (Target); \
  48. Prcb->WorkerRoutine = (Function); \
  49. if (((Target) & ((Target) - 1)) == 0) { \
  50. KiSynchPacket = (PKPRCB)((ULONG_PTR)(Prcb) | 1); \
  51. } else { \
  52. KiSynchPacket = (Prcb); \
  53. Prcb->PacketBarrier = 1; \
  54. } \
  55. KiIpiSend((Target),IPI_SYNCH_REQUEST); \
  56. }
  57. VOID
  58. KiInitializePcr (
  59. IN ULONG Processor,
  60. IN PKPCR Pcr,
  61. IN PKIDTENTRY Idt,
  62. IN PKGDTENTRY Gdt,
  63. IN PKTSS Tss,
  64. IN PKTHREAD Thread,
  65. IN PVOID DpcStack
  66. );
  67. VOID
  68. KiFlushNPXState (
  69. PFLOATING_SAVE_AREA SaveArea
  70. );
  71. //
  72. // Kix86FxSave(NpxFame) - performs an FxSave to the address specificied
  73. //
  74. __inline
  75. VOID
  76. Kix86FxSave(
  77. PFX_SAVE_AREA NpxFrame
  78. )
  79. {
  80. _asm {
  81. mov eax, NpxFrame
  82. ;fxsave [eax]
  83. _emit 0fh
  84. _emit 0aeh
  85. _emit 0
  86. }
  87. }
  88. //
  89. // Kix86FnSave(NpxFame) - performs an FxSave to the address specificied
  90. //
  91. __inline
  92. VOID
  93. Kix86FnSave(
  94. PFX_SAVE_AREA NpxFrame
  95. )
  96. {
  97. __asm {
  98. mov eax, NpxFrame
  99. fnsave [eax]
  100. }
  101. }
  102. //
  103. // Load Katmai New Instruction Technology Control/Status
  104. //
  105. __inline
  106. VOID
  107. Kix86LdMXCsr(
  108. PULONG MXCsr
  109. )
  110. {
  111. _asm {
  112. mov eax, MXCsr
  113. ;LDMXCSR [eax]
  114. _emit 0fh
  115. _emit 0aeh
  116. _emit 10h
  117. }
  118. }
  119. //
  120. // Store Katmai New Instruction Technology Control/Status
  121. //
  122. __inline
  123. VOID
  124. Kix86StMXCsr(
  125. PULONG MXCsr
  126. )
  127. {
  128. _asm {
  129. mov eax, MXCsr
  130. ;STMXCSR [eax]
  131. _emit 0fh
  132. _emit 0aeh
  133. _emit 18h
  134. }
  135. }
  136. VOID
  137. Ke386ConfigureCyrixProcessor (
  138. VOID
  139. );
  140. ULONG
  141. KiCopyInformation (
  142. IN OUT PEXCEPTION_RECORD ExceptionRecord1,
  143. IN PEXCEPTION_RECORD ExceptionRecord2
  144. );
  145. VOID
  146. KiSetHardwareTrigger (
  147. VOID
  148. );
  149. #ifdef DBGMP
  150. VOID
  151. KiPollDebugger (
  152. VOID
  153. );
  154. #endif
  155. VOID
  156. FASTCALL
  157. KiIpiSignalPacketDoneAndStall (
  158. IN PKIPI_CONTEXT Signaldone,
  159. IN ULONG volatile *ReverseStall
  160. );
  161. extern KIRQL KiProfileIrql;
  162. BOOLEAN
  163. KeInvalidateAllCaches (
  164. IN BOOLEAN AllProcessors
  165. );
  166. //
  167. // PAE definitions.
  168. //
  169. #define MAX_IDENTITYMAP_ALLOCATIONS 30
  170. typedef struct _IDENTITY_MAP {
  171. PHARDWARE_PTE TopLevelDirectory;
  172. ULONG IdentityCR3;
  173. ULONG IdentityAddr;
  174. ULONG PagesAllocated;
  175. PVOID PageList[ MAX_IDENTITYMAP_ALLOCATIONS ];
  176. } IDENTITY_MAP, *PIDENTITY_MAP;
  177. VOID
  178. Ki386ClearIdentityMap(
  179. PIDENTITY_MAP IdentityMap
  180. );
  181. VOID
  182. Ki386EnableTargetLargePage(
  183. PIDENTITY_MAP IdentityMap
  184. );
  185. BOOLEAN
  186. Ki386CreateIdentityMap(
  187. IN OUT PIDENTITY_MAP IdentityMap,
  188. IN PVOID StartVa,
  189. IN PVOID EndVa
  190. );
  191. BOOLEAN
  192. Ki386EnableCurrentLargePage (
  193. IN ULONG IdentityAddr,
  194. IN ULONG IdentityCr3
  195. );
  196. extern PVOID Ki386EnableCurrentLargePageEnd;
  197. #if defined(_X86PAE_)
  198. #define PPI_BITS 2
  199. #define PDI_BITS 9
  200. #define PTI_BITS 9
  201. #else
  202. #define PPI_BITS 0
  203. #define PDI_BITS 10
  204. #define PTI_BITS 10
  205. #endif
  206. #define PPI_MASK ((1 << PPI_BITS) - 1)
  207. #define PDI_MASK ((1 << PDI_BITS) - 1)
  208. #define PTI_MASK ((1 << PTI_BITS) - 1)
  209. #define KiGetPpeIndex(va) ((((ULONG)(va)) >> PPI_SHIFT) & PPI_MASK)
  210. #define KiGetPdeIndex(va) ((((ULONG)(va)) >> PDI_SHIFT) & PDI_MASK)
  211. #define KiGetPteIndex(va) ((((ULONG)(va)) >> PTI_SHIFT) & PTI_MASK)
  212. #endif // _KIX86_