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.

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