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.

262 lines
5.7 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. //
  163. // PAE definitions.
  164. //
  165. #define MAX_IDENTITYMAP_ALLOCATIONS 30
  166. typedef struct _IDENTITY_MAP {
  167. PHARDWARE_PTE TopLevelDirectory;
  168. ULONG IdentityCR3;
  169. ULONG IdentityAddr;
  170. ULONG PagesAllocated;
  171. PVOID PageList[ MAX_IDENTITYMAP_ALLOCATIONS ];
  172. } IDENTITY_MAP, *PIDENTITY_MAP;
  173. VOID
  174. Ki386ClearIdentityMap(
  175. PIDENTITY_MAP IdentityMap
  176. );
  177. VOID
  178. Ki386EnableTargetLargePage(
  179. PIDENTITY_MAP IdentityMap
  180. );
  181. BOOLEAN
  182. Ki386CreateIdentityMap(
  183. IN OUT PIDENTITY_MAP IdentityMap,
  184. IN PVOID StartVa,
  185. IN PVOID EndVa
  186. );
  187. BOOLEAN
  188. Ki386EnableCurrentLargePage (
  189. IN ULONG IdentityAddr,
  190. IN ULONG IdentityCr3
  191. );
  192. extern PVOID Ki386EnableCurrentLargePageEnd;
  193. #if defined(_X86PAE_)
  194. #define PPI_BITS 2
  195. #define PDI_BITS 9
  196. #define PTI_BITS 9
  197. #else
  198. #define PPI_BITS 0
  199. #define PDI_BITS 10
  200. #define PTI_BITS 10
  201. #endif
  202. #define PPI_MASK ((1 << PPI_BITS) - 1)
  203. #define PDI_MASK ((1 << PDI_BITS) - 1)
  204. #define PTI_MASK ((1 << PTI_BITS) - 1)
  205. #define KiGetPpeIndex(va) ((((ULONG)(va)) >> PPI_SHIFT) & PPI_MASK)
  206. #define KiGetPdeIndex(va) ((((ULONG)(va)) >> PDI_SHIFT) & PDI_MASK)
  207. #define KiGetPteIndex(va) ((((ULONG)(va)) >> PTI_SHIFT) & PTI_MASK)
  208. //
  209. // Define MTRR register variables.
  210. //
  211. extern LONG64 KiMtrrMaskBase;
  212. extern LONG64 KiMtrrMaskMask;
  213. extern LONG64 KiMtrrOverflowMask;
  214. extern LONG64 KiMtrrResBitMask;
  215. extern UCHAR KiMtrrMaxRangeShift;
  216. #endif // _KIX86_