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.

234 lines
5.6 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. ia64cpu.h
  5. Abstract:
  6. Structures and types shared between the IA64 CPU and its debugger
  7. extensions.
  8. Author:
  9. 27-Sept-1999 BarryBo
  10. Revision History:
  11. 9-Aug-1999 [askhalid] added WOW64IsCurrentProcess
  12. --*/
  13. #ifndef _IA64CPU_INCLUDE
  14. #define _IA64CPU_INCLUDE
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #define GDT_ENTRIES 24
  19. #define GDT_TABLE_SIZE (GDT_ENTRIES<<3)
  20. // Each 387 register takes 1 ia64 fp register
  21. #define NUMBER_OF_387REGS 8
  22. // Each XMMI register takes 2 ia64 fp registers
  23. #define NUMBER_OF_XMMI_REGS 8
  24. /*
  25. ** The order of this structure is very important. The Reserved space at
  26. ** the beginnig allows the ExtendedRegisters[] array in the CONTEXT32 structure
  27. ** to be aligned properly.
  28. **
  29. ** There are constants in the ISA transisiton code that are dependant on
  30. ** the offsets in this structure. If you make changes here, you must
  31. ** make changes to the cpu\ia64\simulate.s code at the very least
  32. */
  33. #pragma pack(push, 4)
  34. typedef struct _CpuContext {
  35. DWORD Reserved;
  36. CONTEXT32 Context;
  37. //
  38. // Because the sizeof(CONTEXT32) struct above is 4 bytes short of
  39. // being divisible by 16, the padding allows the following
  40. // fields to be on 8 byte boundaries. If they are not, we will
  41. // do misaligned accesses on isa transisitons and we will
  42. // see ASSERTS in the cpumain.c code (CpuThreadInit()).
  43. //
  44. ULONGLONG Gdt[GDT_ENTRIES];
  45. ULONGLONG GdtDescriptor;
  46. ULONGLONG LdtDescriptor;
  47. ULONGLONG FsDescriptor;
  48. #if defined(WOW64_HISTORY)
  49. //
  50. // This MUST be the last entry in the CPUCONTEXT structure
  51. // The size is actually allocated based on a registry entry
  52. // and is appended to the sizeof the CPUCONTEXT structure as reported
  53. // back in CpuProcessInit()
  54. //
  55. WOW64SERVICE_BUF Wow64Service[1];
  56. #endif // defined WOW64_HISTORY
  57. } CPUCONTEXT, *PCPUCONTEXT;
  58. #pragma pack(pop)
  59. //
  60. // GDT Entry
  61. //
  62. #ifndef WOW64EXTS_386
  63. typedef struct _KGDTENTRY {
  64. USHORT LimitLow;
  65. USHORT BaseLow;
  66. union {
  67. struct {
  68. UCHAR BaseMid;
  69. UCHAR Flags1; // Declare as bytes to avoid alignment
  70. UCHAR Flags2; // Problems.
  71. UCHAR BaseHi;
  72. } Bytes;
  73. struct {
  74. ULONG BaseMid : 8;
  75. ULONG Type : 5;
  76. ULONG Dpl : 2;
  77. ULONG Pres : 1;
  78. ULONG LimitHi : 4;
  79. ULONG Sys : 1;
  80. ULONG Reserved_0 : 1;
  81. ULONG Default_Big : 1;
  82. ULONG Granularity : 1;
  83. ULONG BaseHi : 8;
  84. } Bits;
  85. } HighWord;
  86. } KGDTENTRY, *PKGDTENTRY;
  87. #endif
  88. #define TYPE_TSS 0x01 // 01001 = NonBusy TSS
  89. #define TYPE_LDT 0x02 // 00010 = LDT
  90. //
  91. // UnScrambled Descriptor format
  92. //
  93. typedef struct _KDESCRIPTOR_UNSCRAM {
  94. union {
  95. ULONGLONG DescriptorWords;
  96. struct {
  97. ULONGLONG Base : 32;
  98. ULONGLONG Limit : 20;
  99. ULONGLONG Type : 5;
  100. ULONGLONG Dpl : 2;
  101. ULONGLONG Pres : 1;
  102. ULONGLONG Sys : 1;
  103. ULONGLONG Reserved_0 : 1;
  104. ULONGLONG Default_Big : 1;
  105. ULONGLONG Granularity : 1;
  106. } Bits;
  107. } Words;
  108. } KXDESCRIPTOR, *PKXDESCRIPTOR;
  109. #define TYPE_CODE_USER 0x1B // 0x11011 = Code, Readable, Accessed
  110. #define TYPE_DATA_USER 0x13 // 0x10011 = Data, ReadWrite, Accessed
  111. #define DESCRIPTOR_EXPAND_DOWN 0x14
  112. #define DESCRIPTOR_DATA_READWRITE (0x8|0x2) // Data, Read/Write
  113. #define DPL_USER 3
  114. #define DPL_SYSTEM 0
  115. #define GRAN_BYTE 0
  116. #define GRAN_PAGE 1
  117. #define SELECTOR_TABLE_INDEX 0x04
  118. //
  119. // Now define the API's used to convert IA64 hardware into ia32 context
  120. //
  121. VOID Wow64CtxFromIa64(
  122. IN ULONG Ia32ContextFlags,
  123. IN PCONTEXT ContextIa64,
  124. IN OUT PCONTEXT32 ContextX86);
  125. VOID Wow64CtxToIa64(
  126. IN ULONG Ia32ContextFlags,
  127. IN PCONTEXT32 ContextX86,
  128. IN OUT PCONTEXT ContextIa64);
  129. VOID Wow64CopyFpFromIa64Byte16(
  130. IN PVOID Byte16Fp,
  131. IN OUT PVOID Byte10Fp,
  132. IN ULONG NumRegs);
  133. VOID Wow64CopyFpToIa64Byte16(
  134. IN PVOID Byte10Fp,
  135. IN OUT PVOID Byte16Fp,
  136. IN ULONG NumRegs);
  137. VOID Wow64CopyXMMIToIa64Byte16(
  138. IN PVOID ByteXMMI,
  139. IN OUT PVOID Byte16Fp,
  140. IN ULONG NumRegs);
  141. VOID Wow64CopyXMMIFromIa64Byte16(
  142. IN PVOID Byte16Fp,
  143. IN OUT PVOID ByteXMMI,
  144. IN ULONG NumRegs);
  145. VOID
  146. Wow64RotateFpTop(
  147. IN ULONGLONG Ia64_FSR,
  148. IN OUT FLOAT128 UNALIGNED *ia32FxSave);
  149. VOID Wow64CopyIa64ToFill(
  150. IN FLOAT128 UNALIGNED *ia64Fp,
  151. IN OUT PFLOAT128 FillArea,
  152. IN ULONG NumRegs);
  153. VOID Wow64CopyIa64FromSpill(
  154. IN PFLOAT128 SpillArea,
  155. IN OUT FLOAT128 UNALIGNED *ia64Fp,
  156. IN ULONG NumRegs);
  157. // The following ptototypes are to be used only by the cpu debugger extension
  158. NTSTATUS
  159. GetContextRecord(
  160. IN PCPUCONTEXT cpu,
  161. IN OUT PCONTEXT32 Context
  162. );
  163. NTSTATUS
  164. SetContextRecord(
  165. IN PCPUCONTEXT cpu,
  166. IN OUT PCONTEXT32 Context
  167. );
  168. NTSTATUS
  169. CpupGetContextThread(
  170. IN HANDLE ThreadHandle,
  171. IN HANDLE ProcessHandle,
  172. IN PTEB Teb,
  173. IN OUT PCONTEXT32 Context);
  174. NTSTATUS
  175. CpupSetContextThread(
  176. IN HANDLE ThreadHandle,
  177. IN HANDLE ProcessHandle,
  178. IN PTEB Teb,
  179. IN OUT PCONTEXT32 Context);
  180. NTSTATUS
  181. CpupSetContext(
  182. IN PCONTEXT32 Context
  183. );
  184. NTSTATUS
  185. CpupGetContext(
  186. IN OUT PCONTEXT32 Context
  187. );
  188. #ifdef __cplusplus
  189. }
  190. #endif
  191. #endif