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.

289 lines
6.8 KiB

  1. /*++ BUILD Version: 0002 Increment this if a change has global effects
  2. Module Name:
  3. wx86nt.h
  4. Abstract:
  5. defines Nt i386 specific data structures (from nti386)
  6. Revision History:
  7. --*/
  8. #ifndef _WX86NT_
  9. #define _WX86NT_
  10. // Size of Global Descriptor Table
  11. #define GDT_SIZE 4096 // big enough...
  12. #define IDT_SIZE (8*256)
  13. //
  14. // Rename some of the platform dependent datatypes,
  15. // so that we can access the i386 form on risc.
  16. //
  17. #ifndef _X86_
  18. #define _X86_
  19. #endif
  20. #ifndef _FLOATING_SAVE_AREA
  21. #define _FLOATING_SAVE_AREA _FLOATING_SAVE_AREA_WX86
  22. #define FLOATING_SAVE_AREA FLOATING_SAVE_AREA_WX86
  23. #define PFLOATING_SAVE_AREA PFLOATING_SAVE_AREA_WX86
  24. #endif
  25. #define _CONTEXT _CONTEXT_WX86
  26. #define CONTEXT CONTEXT_WX86
  27. #define PCONTEXT PCONTEXT_WX86
  28. #define FXSAVE_FORMAT FXSAVE_FORMAT_WX86
  29. #define PFXSAVE_FORMAT PFXSAVE_FORMAT_WX86
  30. #ifdef _X86_
  31. //
  32. // Disable these two pramas that evaluate to "sti" "cli" on x86 so that driver
  33. // writers to not leave them inadvertantly in their code.
  34. //
  35. #if !defined(MIDL_PASS)
  36. #if !defined(RC_INVOKED)
  37. #if _MSC_VER >= 1200
  38. #pragma warning(push)
  39. #endif
  40. #pragma warning(disable:4164) // disable C4164 warning so that apps that
  41. // build with /Od don't get weird errors !
  42. #ifdef _M_IX86
  43. #pragma function(_enable)
  44. #pragma function(_disable)
  45. #endif
  46. #if _MSC_VER >= 1200
  47. #pragma warning(pop)
  48. #else
  49. #pragma warning(default:4164) // reenable C4164 warning
  50. #endif
  51. #endif
  52. #endif
  53. //
  54. // Define the size of the 80387 save area, which is in the context frame.
  55. //
  56. #define SIZE_OF_80387_REGISTERS 80
  57. //
  58. // The following flags control the contents of the CONTEXT structure.
  59. //
  60. #if !defined(RC_INVOKED)
  61. #define CONTEXT_i386 0x00010000 // this assumes that i386 and
  62. #define CONTEXT_i486 0x00010000 // i486 have identical context records
  63. #endif
  64. #define MAXIMUM_SUPPORTED_EXTENSION 512
  65. typedef struct _FLOATING_SAVE_AREA {
  66. DWORD ControlWord;
  67. DWORD StatusWord;
  68. DWORD TagWord;
  69. DWORD ErrorOffset;
  70. DWORD ErrorSelector;
  71. DWORD DataOffset;
  72. DWORD DataSelector;
  73. BYTE RegisterArea[SIZE_OF_80387_REGISTERS];
  74. DWORD Cr0NpxState;
  75. } FLOATING_SAVE_AREA;
  76. typedef FLOATING_SAVE_AREA *PFLOATING_SAVE_AREA;
  77. //
  78. // Context Frame
  79. //
  80. // This frame has a several purposes: 1) it is used as an argument to
  81. // NtContinue, 2) is is used to constuct a call frame for APC delivery,
  82. // and 3) it is used in the user level thread creation routines.
  83. //
  84. // The layout of the record conforms to a standard call frame.
  85. //
  86. typedef struct _CONTEXT {
  87. //
  88. // The flags values within this flag control the contents of
  89. // a CONTEXT record.
  90. //
  91. // If the context record is used as an input parameter, then
  92. // for each portion of the context record controlled by a flag
  93. // whose value is set, it is assumed that that portion of the
  94. // context record contains valid context. If the context record
  95. // is being used to modify a threads context, then only that
  96. // portion of the threads context will be modified.
  97. //
  98. // If the context record is used as an IN OUT parameter to capture
  99. // the context of a thread, then only those portions of the thread's
  100. // context corresponding to set flags will be returned.
  101. //
  102. // The context record is never used as an OUT only parameter.
  103. //
  104. DWORD ContextFlags;
  105. //
  106. // This section is specified/returned if CONTEXT_DEBUG_REGISTERS is
  107. // set in ContextFlags. Note that CONTEXT_DEBUG_REGISTERS is NOT
  108. // included in CONTEXT_FULL.
  109. //
  110. DWORD Dr0;
  111. DWORD Dr1;
  112. DWORD Dr2;
  113. DWORD Dr3;
  114. DWORD Dr6;
  115. DWORD Dr7;
  116. //
  117. // This section is specified/returned if the
  118. // ContextFlags word contians the flag CONTEXT_FLOATING_POINT.
  119. //
  120. FLOATING_SAVE_AREA FloatSave;
  121. //
  122. // This section is specified/returned if the
  123. // ContextFlags word contians the flag CONTEXT_SEGMENTS.
  124. //
  125. DWORD SegGs;
  126. DWORD SegFs;
  127. DWORD SegEs;
  128. DWORD SegDs;
  129. //
  130. // This section is specified/returned if the
  131. // ContextFlags word contians the flag CONTEXT_INTEGER.
  132. //
  133. DWORD Edi;
  134. DWORD Esi;
  135. DWORD Ebx;
  136. DWORD Edx;
  137. DWORD Ecx;
  138. DWORD Eax;
  139. //
  140. // This section is specified/returned if the
  141. // ContextFlags word contians the flag CONTEXT_CONTROL.
  142. //
  143. DWORD Ebp;
  144. DWORD Eip;
  145. DWORD SegCs; // MUST BE SANITIZED
  146. DWORD EFlags; // MUST BE SANITIZED
  147. DWORD Esp;
  148. DWORD SegSs;
  149. //
  150. // This section is specified/returned if the ContextFlags word
  151. // contains the flag CONTEXT_EXTENDED_REGISTERS.
  152. // The format and contexts are processor specific
  153. //
  154. BYTE ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
  155. } CONTEXT;
  156. typedef CONTEXT *PCONTEXT;
  157. // begin_ntminiport
  158. #endif //_X86_
  159. //
  160. // Define the size of FP registers in the FXSAVE format
  161. //
  162. #define SIZE_OF_FX_REGISTERS 128
  163. //
  164. // Format of data for fxsave/fxrstor instruction
  165. //
  166. #include "pshpack1.h"
  167. #ifndef WOW64EXTS_386
  168. #ifndef _NTDBG_
  169. typedef struct _FXSAVE_FORMAT {
  170. USHORT ControlWord;
  171. USHORT StatusWord;
  172. USHORT TagWord;
  173. USHORT ErrorOpcode;
  174. ULONG ErrorOffset;
  175. ULONG ErrorSelector;
  176. ULONG DataOffset;
  177. ULONG DataSelector;
  178. ULONG MXCsr;
  179. ULONG Reserved2;
  180. UCHAR RegisterArea[SIZE_OF_FX_REGISTERS];
  181. UCHAR Reserved3[SIZE_OF_FX_REGISTERS];
  182. UCHAR Reserved4[224];
  183. UCHAR Align16Byte[8];
  184. } FXSAVE_FORMAT, *PFXSAVE_FORMAT;
  185. #endif
  186. #endif
  187. #include "poppack.h"
  188. #define KGDT_R0_DATA 16
  189. #define KGDT_R3_CODE 24
  190. #define KGDT_R3_DATA 32
  191. #define KGDT_TSS 40
  192. #define KGDT_R0_PCR 48
  193. #define KGDT_R3_TEB 56
  194. #define KGDT_VDM_TILE 64
  195. #define KGDT_LDT 72
  196. #define KGDT_DF_TSS 80
  197. #define KGDT_NMI_TSS 88
  198. //
  199. // Stop the renaming so that the risc datatypes
  200. // are accessible by their normal names
  201. //
  202. #undef _FLOATING_SAVE_AREA
  203. #undef FLOATING_SAVE_AREA
  204. #undef PFLOATING_SAVE_AREA
  205. #undef _CONTEXT
  206. #undef CONTEXT
  207. #undef PCONTEXT
  208. #undef FXSAVE_FORMAT
  209. #undef PFXSAVE_FORMAT
  210. //
  211. // set up the i386 CONTEXT bits for the ContextFlags
  212. // warning: this MUST match nti386.h
  213. //
  214. #define CONTEXT_CONTROL_WX86 (CONTEXT_i386 | 0x00000001L) // SS:SP, CS:IP, FLAGS, BP
  215. #define CONTEXT_INTEGER_WX86 (CONTEXT_i386 | 0x00000002L) // AX, BX, CX, DX, SI, DI
  216. #define CONTEXT_SEGMENTS_WX86 (CONTEXT_i386 | 0x00000004L) // DS, ES, FS, GS
  217. #define CONTEXT_FLOATING_POINT_WX86 (CONTEXT_i386 | 0x00000008L) // 387 state
  218. #define CONTEXT_DEBUG_REGISTERS_WX86 (CONTEXT_i386 | 0x00000010L) // DB 0-3,6,7
  219. #define CONTEXT_EXTENDED_REGISTERS_WX86 (CONTEXT_i386 | 0x00000020L) // cpu specific extensions
  220. #define CONTEXT_FULL_WX86 (CONTEXT_CONTROL_WX86 | CONTEXT_INTEGER_WX86 | CONTEXT_SEGMENTS_WX86)
  221. #undef _X86_
  222. #endif /* _WX86NT_ */