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.

1066 lines
52 KiB

  1. /*
  2. * INTEL CORPORATION PROPRIETARY INFORMATION
  3. *
  4. * This software is supplied under the terms of a license
  5. * agreement or nondisclosure agreement with Intel Corporation
  6. * and may not be copied or disclosed except in accordance with
  7. * the terms of that agreement.
  8. * Copyright (c) 1991-2002 Intel Corporation.
  9. *
  10. */
  11. #ifndef BTGENERIC_H
  12. #define BTGENERIC_H
  13. #ifndef NODEBUG
  14. #define OVERRIDE_TIA 1
  15. #endif
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. #define MEM_READ 0x1
  20. #define MEM_WRITE 0x2
  21. #define MEM_EXECUTE 0x4
  22. #define IS_MEM_ACCESSIBLE(permission) ((permission) != 0)
  23. #define R13_FREE (-0x1)
  24. #define R13_USED (-0x2)
  25. #define BLOCK 0x0
  26. #define CHECK 0x1
  27. #define ACCESS_LOCK_OBJECT_SIZE 24
  28. // Defines for initial memory allocation for either code or data.
  29. #define INITIAL_DATA_ALLOC ((void *)0x1)
  30. #define INITIAL_CODE_ALLOC ((void *)0x2)
  31. /* IA32 interrupts */
  32. #define IA32_DIVIDE_ERR_INTR 0
  33. #define IA32_DEBUG_INTR 1
  34. #define IA32_BREAKPOINT_INTR 3
  35. #define IA32_OVERFLOW_INTR 4
  36. #define IA32_BOUND_INTR 5
  37. #define IA32_INV_OPCODE_INTR 6
  38. #define IA32_DEV_NA_INTR 7
  39. #define IA32_DOUBLE_FAULT_INTR 8
  40. #define IA32_INV_TSS_INTR 10
  41. #define IA32_NO_SEG_INTR 11
  42. #define IA32_STK_SEG_FAULT_INTR 12
  43. #define IA32_GEN_PROT_FAULT_INTR 13
  44. #define IA32_PAGE_FAULT_INTR 14
  45. #define IA32_MATH_FAULT_INTR 16
  46. #define IA32_ALIGN_CHECK_INTR 17
  47. #define IA32_MACHINE_CHECK_INTR 18
  48. #define IA32_SIMD_INTR 19
  49. //BT exception codes used to communicate exception information between BTGeneric and BTLib:
  50. //code range 0-255 is reserved for IA32 interrupt vector numbers. The vector numbers are
  51. //used to specify software interrupts (INTn) only; the CPU-detected exceptions should be
  52. //encoded with a corresponding BT_EXCEPT_* value.
  53. //BT_NO_EXCEPT is a special code indicating either false exception or
  54. //external interrupt (suspention)
  55. //BT_EXCEPT_UNKNOWN code used to specify all exceptions unknown to IA-32 Execution Layer
  56. //All values in the BtExceptionCode enumerator should be in the range
  57. //[0, BT_MAX_EXCEPTION_CODE]; other values are reserved for internal use.
  58. enum BtExceptionCode {
  59. BT_MAX_INTERRUPT_NUMBER = 0xFF,
  60. BT_NO_EXCEPT,
  61. BT_EXCEPT_UNKNOWN,
  62. BT_EXCEPT_ACCESS_VIOLATION,
  63. BT_EXCEPT_DATATYPE_MISALIGNMENT,
  64. BT_EXCEPT_ARRAY_BOUNDS_EXCEEDED,
  65. BT_EXCEPT_FLT_DENORMAL_OPERAND,
  66. BT_EXCEPT_FLT_DIVIDE_BY_ZERO,
  67. BT_EXCEPT_FLT_INEXACT_RESULT,
  68. BT_EXCEPT_FLT_INVALID_OPERATION,
  69. BT_EXCEPT_FLT_OVERFLOW,
  70. BT_EXCEPT_FLT_UNDERFLOW,
  71. BT_EXCEPT_FLT_STACK_CHECK,
  72. BT_EXCEPT_INT_DIVIDE_BY_ZERO,
  73. BT_EXCEPT_INT_OVERFLOW,
  74. BT_EXCEPT_PRIV_INSTRUCTION,
  75. BT_EXCEPT_ILLEGAL_INSTRUCTION,
  76. BT_EXCEPT_FLOAT_MULTIPLE_FAULTS,
  77. BT_EXCEPT_FLOAT_MULTIPLE_TRAPS,
  78. BT_EXCEPT_STACK_OVERFLOW,
  79. BT_EXCEPT_GUARD_PAGE,
  80. BT_EXCEPT_BREAKPOINT,
  81. BT_EXCEPT_SINGLE_STEP
  82. };
  83. #define BT_MAX_EXCEPTION_CODE 0xFFF
  84. typedef U32 BT_EXCEPTION_CODE;
  85. //Structure that represents interruption context in addition to thread CONTEXT_64
  86. typedef struct BtExceptionRecord {
  87. BT_EXCEPTION_CODE ExceptionCode;//BT exception code
  88. U64 Ia64IIPA; //Interruption Instruction Previous Address. 0 if unknown
  89. U64 Ia64ISR; //Interruption Status Register. UNKNOWN_ISR_VALUE if unknown
  90. } BT_EXCEPTION_RECORD;
  91. #define UNKNOWN_ISR_VALUE ((U64)(-1))
  92. //BT status codes used to communicate error information between BTGeneric and BTLib:
  93. enum BtStatusCode {
  94. BT_STATUS_SUCCESS = 0,
  95. BT_STATUS_UNSUCCESSFUL,
  96. BT_STATUS_NO_MEMORY,
  97. BT_STATUS_ACCESS_VIOLATION
  98. };
  99. typedef U32 BT_STATUS_CODE;
  100. //BtgFlushIA32InstructionCache reason codes
  101. enum BtFlushReason {
  102. BT_FLUSH_FORCE = 0, //code modification
  103. BT_FLUSH_FREE, //memory release
  104. BT_FLUSH_ALLOC, //memory allocation
  105. BT_FLUSH_PROTECT //permission change
  106. };
  107. typedef U32 BT_FLUSH_REASON;
  108. //BT object handle (process, etc.)
  109. typedef void * BT_HANDLE;
  110. #define BTGENERIC_VERSION 0
  111. #define BTGENERIC_API_STRING 256
  112. #define SIZE_OF_STRING 128
  113. #define NO_OF_APIS 42
  114. // a pointer to plabel.
  115. // This type will be used to define the API_Table
  116. typedef void(*PLABEL_PTR_TYPE)();
  117. typedef struct API_TABLE_ELEMENT_TYPE {
  118. PLABEL_PTR_TYPE PLabelPtr; // ptr to the function's plabel
  119. /* WCHAR APIName[SIZE_OF_STRING]; // API name string*/
  120. } API_TABLE_ELEMENT_TYPE;
  121. // this should be updated if API_TABLE_TYPE changes!!
  122. #define API_TABLE_START_OFFSET ((sizeof(U32) * 4) + SIZE_OF_STRING)
  123. typedef struct APITableType {
  124. U32 VersionNumber; // version number info
  125. U32 SizeOfString; // size of string in version & APIName;
  126. U32 NoOfAPIs; // no. of elements in APITable
  127. U32 TableStartOffset; // offset of APITable from the beginning of the struct
  128. WCHAR VersionString[SIZE_OF_STRING];
  129. API_TABLE_ELEMENT_TYPE APITable[NO_OF_APIS];
  130. } API_TABLE_TYPE;
  131. // BTGeneric APIs indexes
  132. #define IDX_BTGENERIC_START 0
  133. #define IDX_BTGENERIC_THREAD_INIT 1
  134. #define IDX_BTGENERIC_RUN 2
  135. //#define IDX_BTGENERIC_RUN_EXIT 3
  136. #define IDX_BTGENERIC_THREAD_TERMINATED 4
  137. #define IDX_BTGENERIC_THREAD_ABORTED 5
  138. #define IDX_BTGENERIC_PROCESS_TERM 6
  139. //#define IDX_BTGENERIC_PROCESS_ABORTED 7
  140. #define IDX_BTGENERIC_IA32_CONTEXT_SET 8
  141. #define IDX_BTGENERIC_IA32_CONTEXT_GET 9
  142. #define IDX_BTGENERIC_IA32_CONTEXT_SET_REMOTE 10
  143. #define IDX_BTGENERIC_IA32_CONTEXT_GET_REMOTE 11
  144. #define IDX_BTGENERIC_IA32_CANONIZE_CONTEXT 12
  145. #define IDX_BTGENERIC_CANONIZE_SUSPEND_CONTEXT_REMOTE 13
  146. #define IDX_BTGENERIC_REPORT_LOAD 14
  147. #define IDX_BTGENERIC_REPORT_UNLOAD 15
  148. #define IDX_BTGENERIC_NOTIFY_CHANGE_PERMISSION_REQUEST 16
  149. #define IDX_BTGENERIC_FLUSH_IA32_INSTRUCTION_CACHE 17
  150. #define IDX_BTGENERIC_DEBUG_SETTINGS 18
  151. #define IDX_BTGENERIC_CHECK_SUSPEND_CONTEXT 19
  152. #define IDX_BTGENERIC_EXCEPTION_DEBUG_PRINT 20
  153. #define IDX_BTGENERIC_NOTIFY_EXIT 21
  154. #define IDX_BTGENERIC_CANONIZE_SUSPEND_CONTEXT 22
  155. #define IDX_BTGENERIC_NOTIFY_PREPARE_EXIT 23
  156. #define IDX_BTGENERIC_FREEZE 24
  157. #define IDX_BTGENERIC_UNFREEZE 25
  158. #define IDX_BTGENERIC_CHANGE_THREAD_IDENTITY 26
  159. #ifdef OVERRIDE_TIA
  160. #define IDX_BTGENERIC_USE_OVERRIDE_TIA 27
  161. #endif // OVERRIDE_TIA
  162. // BTlib APIs indexes
  163. #define IDX_BTLIB_GET_THREAD_ID 0
  164. #define IDX_BTLIB_IA32_REENTER 1
  165. #define IDX_BTLIB_IA32_LCALL 2
  166. #define IDX_BTLIB_IA32_INTERRUPT 3
  167. #define IDX_BTLIB_IA32_JMP_IA64 4
  168. #define IDX_BTLIB_LOCK_SIGNALS 5
  169. #define IDX_BTLIB_UNLOCK_SIGNALS 6
  170. #define IDX_BTLIB_MEMORY_ALLOC 7
  171. #define IDX_BTLIB_MEMORY_FREE 8
  172. #define IDX_BTLIB_MEMORY_PAGE_SIZE 9
  173. #define IDX_BTLIB_MEMORY_CHANGE_PERMISSIONS 10
  174. #define IDX_BTLIB_MEMORY_QUERY_PERMISSIONS 11
  175. #define IDX_BTLIB_MEMORY_READ_REMOTE 12
  176. #define IDX_BTLIB_MEMORY_WRITE_REMOTE 13
  177. //#define IDX_BTLIB_ATOMIC_MISALIGNED_LOAD 14
  178. //#define IDX_BTLIB_ATOMIC_MISALIGNED_STORE 15
  179. #define IDX_BTLIB_SUSPEND_THREAD 16
  180. #define IDX_BTLIB_RESUME_THREAD 17
  181. #define IDX_BTLIB_INIT_ACCESS_LOCK 18
  182. #define IDX_BTLIB_LOCK_ACCESS 19
  183. #define IDX_BTLIB_UNLOCK_ACCESS 20
  184. #define IDX_BTLIB_INVALIDATE_ACCESS_LOCK 21
  185. #define IDX_BTLIB_QUERY_JMPBUF_SIZE 22
  186. #define IDX_BTLIB_SETJMP 23
  187. #define IDX_BTLIB_LONGJMP 24
  188. #define IDX_BTLIB_DEBUG_PRINT 25
  189. #define IDX_BTLIB_ABORT 26
  190. #define IDX_BTLIB_VTUNE_CODE_CREATED 27
  191. #define IDX_BTLIB_VTUNE_CODE_DELETED 28
  192. #define IDX_BTLIB_VTUNE_ENTERING_DYNAMIC_CODE 29
  193. #define IDX_BTLIB_VTUNE_EXITING_DYNAMIC_CODE 30
  194. #define IDX_BTLIB_VTUNE_CODE_TO_TIA_DMP_FILE 31
  195. #define IDX_BTLIB_SSCPERFGETCOUNTER64 32
  196. #define IDX_BTLIB_SSCPERFSETCOUNTER64 33
  197. #define IDX_BTLIB_SSCPERFSENDEVENT 34
  198. #define IDX_BTLIB_SSCPERFEVENTHANDLE 35
  199. #define IDX_BTLIB_SSCPERFCOUNTERHANDLE 36
  200. #define IDX_BTLIB_YIELD_THREAD_EXECUTION 37
  201. #define IDX_BTLIB_FLUSH_IA64_INSTRUCTION_CACHE 38
  202. #define IDX_BTLIB_PSEUDO_OPEN_FILE 39
  203. #define IDX_BTLIB_PSEUDO_CLOSE_FILE 40
  204. #define IDX_BTLIB_PSEUDO_WRITE_FILE 41
  205. //
  206. // Define the size of the 80387 save area, which is in the context frame.
  207. //
  208. #define SIZE_OF_80387_REGISTERS 80
  209. //
  210. // The following flags control the contents of the CONTEXT structure.
  211. //
  212. #define CONTEXT_IA32 0x00010000 // any IA32 context
  213. #define CONTEXT32_CONTROL (CONTEXT_IA32 | 0x00000001L) // SS:SP, CS:IP, FLAGS, BP
  214. #define CONTEXT32_INTEGER (CONTEXT_IA32 | 0x00000002L) // AX, BX, CX, DX, SI, DI
  215. #define CONTEXT32_SEGMENTS (CONTEXT_IA32 | 0x00000004L) // DS, ES, FS, GS
  216. #define CONTEXT32_FLOATING_POINT (CONTEXT_IA32 | 0x00000008L) // 387 state
  217. #define CONTEXT32_DEBUG_REGISTERS (CONTEXT_IA32 | 0x00000010L) // DB 0-3,6,7
  218. #define CONTEXT32_EXTENDED_REGISTERS (CONTEXT_IA32 | 0x00000020L) // cpu specific extensions
  219. #define CONTEXT32_FULL (CONTEXT32_CONTROL | CONTEXT32_INTEGER |\
  220. CONTEXT32_SEGMENTS)
  221. #define MAXIMUM_SUPPORTED_EXTENSION 512
  222. typedef struct _FLOATING_SAVE_AREA32 {
  223. U32 ControlWord;
  224. U32 StatusWord;
  225. U32 TagWord;
  226. U32 ErrorOffset;
  227. U32 ErrorSelector;
  228. U32 DataOffset;
  229. U32 DataSelector;
  230. U8 RegisterArea[SIZE_OF_80387_REGISTERS];
  231. U32 Cr0NpxState;
  232. } FLOATING_SAVE_AREA32;
  233. typedef struct _CONTEXT32 {
  234. //
  235. // The flags values within this flag control the contents of
  236. // a CONTEXT record.
  237. //
  238. // If the context record is used as an input parameter, then
  239. // for each portion of the context record controlled by a flag
  240. // whose value is set, it is assumed that that portion of the
  241. // context record contains valid context. If the context record
  242. // is being used to modify a threads context, then only that
  243. // portion of the threads context will be modified.
  244. //
  245. // If the context record is used as an IN OUT parameter to capture
  246. // the context of a thread, then only those portions of the thread's
  247. // context corresponding to set flags will be returned.
  248. //
  249. // The context record is never used as an OUT only parameter.
  250. //
  251. U32 ContextFlags;
  252. //
  253. // This section is specified/returned if CONTEXT_DEBUG_REGISTERS is
  254. // set in ContextFlags. Note that CONTEXT_DEBUG_REGISTERS is NOT
  255. // included in CONTEXT_FULL.
  256. //
  257. U32 Dr0;
  258. U32 Dr1;
  259. U32 Dr2;
  260. U32 Dr3;
  261. U32 Dr6;
  262. U32 Dr7;
  263. //
  264. // This section is specified/returned if the
  265. // ContextFlags word contians the flag CONTEXT_FLOATING_POINT.
  266. //
  267. FLOATING_SAVE_AREA32 FloatSave;
  268. //
  269. // This section is specified/returned if the
  270. // ContextFlags word contians the flag CONTEXT_SEGMENTS.
  271. //
  272. U32 SegGs;
  273. U32 SegFs;
  274. U32 SegEs;
  275. U32 SegDs;
  276. //
  277. // This section is specified/returned if the
  278. // ContextFlags word contians the flag CONTEXT_INTEGER.
  279. //
  280. U32 Edi;
  281. U32 Esi;
  282. U32 Ebx;
  283. U32 Edx;
  284. U32 Ecx;
  285. U32 Eax;
  286. //
  287. // This section is specified/returned if the
  288. // ContextFlags word contians the flag CONTEXT_CONTROL.
  289. //
  290. U32 Ebp;
  291. U32 Eip;
  292. U32 SegCs; // MUST BE SANITIZED
  293. U32 EFlags; // MUST BE SANITIZED
  294. U32 Esp;
  295. U32 SegSs;
  296. //
  297. // This section is specified/returned if the ContextFlags word
  298. // contains the flag CONTEXT_EXTENDED_REGISTERS.
  299. // The format and contexts are processor specific
  300. //
  301. U8 ExtendedRegisters[MAXIMUM_SUPPORTED_EXTENSION];
  302. } BTGENERIC_IA32_CONTEXT;
  303. #define CONTEXT_IA64 0x00080000
  304. #define CONTEXT_LOWER_FLOATING_POINT (CONTEXT_IA64 | 0x00000002L)
  305. #define CONTEXT_HIGHER_FLOATING_POINT (CONTEXT_IA64 | 0x00000004L)
  306. #define CONTEXT_DEBUG (CONTEXT_IA64 | 0x00000010L)
  307. #define CONTEXT_IA32_CONTROL (CONTEXT_IA64 | 0x00000020L) // Includes StIPSR
  308. #if (! defined CONTEXT_INTEGER) || ( ! defined CONTEXT_INTEGER ) || ( ! defined CONTEXT_FLOATING_POINT ) || ( ! defined CONTEXT_FULL )
  309. #define CONTEXT_CONTROL (CONTEXT_IA64 | 0x00000001L)
  310. #define CONTEXT_INTEGER (CONTEXT_IA64 | 0x00000008L)
  311. #define CONTEXT_FLOATING_POINT (CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT)
  312. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_FLOATING_POINT | CONTEXT_INTEGER | CONTEXT_IA32_CONTROL)
  313. #endif
  314. typedef struct _CONTEXT64 {
  315. //
  316. // The flags values within this flag control the contents of
  317. // a CONTEXT record.
  318. //
  319. // If the context record is used as an input parameter, then
  320. // for each portion of the context record controlled by a flag
  321. // whose value is set, it is assumed that that portion of the
  322. // context record contains valid context. If the context record
  323. // is being used to modify a thread's context, then only that
  324. // portion of the threads context will be modified.
  325. //
  326. // If the context record is used as an IN OUT parameter to capture
  327. // the context of a thread, then only those portions of the thread's
  328. // context corresponding to set flags will be returned.
  329. //
  330. // The context record is never used as an OUT only parameter.
  331. //
  332. U32 ContextFlags;
  333. U32 Fill1[3]; // for alignment of following on 16-byte boundary
  334. //
  335. // This section is specified/returned if the ContextFlags word contains
  336. // the flag CONTEXT_DEBUG.
  337. //
  338. // N.B. CONTEXT_DEBUG is *not* part of CONTEXT_FULL.
  339. //
  340. // Please contact INTEL to get IA64-specific information
  341. // @@BEGIN_DDKSPLIT
  342. U64 DbI0; // Intel-IA64-Filler
  343. U64 DbI1; // Intel-IA64-Filler
  344. U64 DbI2; // Intel-IA64-Filler
  345. U64 DbI3; // Intel-IA64-Filler
  346. U64 DbI4; // Intel-IA64-Filler
  347. U64 DbI5; // Intel-IA64-Filler
  348. U64 DbI6; // Intel-IA64-Filler
  349. U64 DbI7; // Intel-IA64-Filler
  350. U64 DbD0; // Intel-IA64-Filler
  351. U64 DbD1; // Intel-IA64-Filler
  352. U64 DbD2; // Intel-IA64-Filler
  353. U64 DbD3; // Intel-IA64-Filler
  354. U64 DbD4; // Intel-IA64-Filler
  355. U64 DbD5; // Intel-IA64-Filler
  356. U64 DbD6; // Intel-IA64-Filler
  357. U64 DbD7; // Intel-IA64-Filler
  358. //
  359. // This section is specified/returned if the ContextFlags word contains
  360. // the flag CONTEXT_LOWER_FLOATING_POINT.
  361. //
  362. FLOAT128 FltS0; // Intel-IA64-Filler
  363. FLOAT128 FltS1; // Intel-IA64-Filler
  364. FLOAT128 FltS2; // Intel-IA64-Filler
  365. FLOAT128 FltS3; // Intel-IA64-Filler
  366. FLOAT128 FltT0; // Intel-IA64-Filler
  367. FLOAT128 FltT1; // Intel-IA64-Filler
  368. FLOAT128 FltT2; // Intel-IA64-Filler
  369. FLOAT128 FltT3; // Intel-IA64-Filler
  370. FLOAT128 FltT4; // Intel-IA64-Filler
  371. FLOAT128 FltT5; // Intel-IA64-Filler
  372. FLOAT128 FltT6; // Intel-IA64-Filler
  373. FLOAT128 FltT7; // Intel-IA64-Filler
  374. FLOAT128 FltT8; // Intel-IA64-Filler
  375. FLOAT128 FltT9; // Intel-IA64-Filler
  376. //
  377. // This section is specified/returned if the ContextFlags word contains
  378. // the flag CONTEXT_HIGHER_FLOATING_POINT.
  379. //
  380. FLOAT128 FltS4; // Intel-IA64-Filler
  381. FLOAT128 FltS5; // Intel-IA64-Filler
  382. FLOAT128 FltS6; // Intel-IA64-Filler
  383. FLOAT128 FltS7; // Intel-IA64-Filler
  384. FLOAT128 FltS8; // Intel-IA64-Filler
  385. FLOAT128 FltS9; // Intel-IA64-Filler
  386. FLOAT128 FltS10; // Intel-IA64-Filler
  387. FLOAT128 FltS11; // Intel-IA64-Filler
  388. FLOAT128 FltS12; // Intel-IA64-Filler
  389. FLOAT128 FltS13; // Intel-IA64-Filler
  390. FLOAT128 FltS14; // Intel-IA64-Filler
  391. FLOAT128 FltS15; // Intel-IA64-Filler
  392. FLOAT128 FltS16; // Intel-IA64-Filler
  393. FLOAT128 FltS17; // Intel-IA64-Filler
  394. FLOAT128 FltS18; // Intel-IA64-Filler
  395. FLOAT128 FltS19; // Intel-IA64-Filler
  396. FLOAT128 FltF32; // Intel-IA64-Filler
  397. FLOAT128 FltF33; // Intel-IA64-Filler
  398. FLOAT128 FltF34; // Intel-IA64-Filler
  399. FLOAT128 FltF35; // Intel-IA64-Filler
  400. FLOAT128 FltF36; // Intel-IA64-Filler
  401. FLOAT128 FltF37; // Intel-IA64-Filler
  402. FLOAT128 FltF38; // Intel-IA64-Filler
  403. FLOAT128 FltF39; // Intel-IA64-Filler
  404. FLOAT128 FltF40; // Intel-IA64-Filler
  405. FLOAT128 FltF41; // Intel-IA64-Filler
  406. FLOAT128 FltF42; // Intel-IA64-Filler
  407. FLOAT128 FltF43; // Intel-IA64-Filler
  408. FLOAT128 FltF44; // Intel-IA64-Filler
  409. FLOAT128 FltF45; // Intel-IA64-Filler
  410. FLOAT128 FltF46; // Intel-IA64-Filler
  411. FLOAT128 FltF47; // Intel-IA64-Filler
  412. FLOAT128 FltF48; // Intel-IA64-Filler
  413. FLOAT128 FltF49; // Intel-IA64-Filler
  414. FLOAT128 FltF50; // Intel-IA64-Filler
  415. FLOAT128 FltF51; // Intel-IA64-Filler
  416. FLOAT128 FltF52; // Intel-IA64-Filler
  417. FLOAT128 FltF53; // Intel-IA64-Filler
  418. FLOAT128 FltF54; // Intel-IA64-Filler
  419. FLOAT128 FltF55; // Intel-IA64-Filler
  420. FLOAT128 FltF56; // Intel-IA64-Filler
  421. FLOAT128 FltF57; // Intel-IA64-Filler
  422. FLOAT128 FltF58; // Intel-IA64-Filler
  423. FLOAT128 FltF59; // Intel-IA64-Filler
  424. FLOAT128 FltF60; // Intel-IA64-Filler
  425. FLOAT128 FltF61; // Intel-IA64-Filler
  426. FLOAT128 FltF62; // Intel-IA64-Filler
  427. FLOAT128 FltF63; // Intel-IA64-Filler
  428. FLOAT128 FltF64; // Intel-IA64-Filler
  429. FLOAT128 FltF65; // Intel-IA64-Filler
  430. FLOAT128 FltF66; // Intel-IA64-Filler
  431. FLOAT128 FltF67; // Intel-IA64-Filler
  432. FLOAT128 FltF68; // Intel-IA64-Filler
  433. FLOAT128 FltF69; // Intel-IA64-Filler
  434. FLOAT128 FltF70; // Intel-IA64-Filler
  435. FLOAT128 FltF71; // Intel-IA64-Filler
  436. FLOAT128 FltF72; // Intel-IA64-Filler
  437. FLOAT128 FltF73; // Intel-IA64-Filler
  438. FLOAT128 FltF74; // Intel-IA64-Filler
  439. FLOAT128 FltF75; // Intel-IA64-Filler
  440. FLOAT128 FltF76; // Intel-IA64-Filler
  441. FLOAT128 FltF77; // Intel-IA64-Filler
  442. FLOAT128 FltF78; // Intel-IA64-Filler
  443. FLOAT128 FltF79; // Intel-IA64-Filler
  444. FLOAT128 FltF80; // Intel-IA64-Filler
  445. FLOAT128 FltF81; // Intel-IA64-Filler
  446. FLOAT128 FltF82; // Intel-IA64-Filler
  447. FLOAT128 FltF83; // Intel-IA64-Filler
  448. FLOAT128 FltF84; // Intel-IA64-Filler
  449. FLOAT128 FltF85; // Intel-IA64-Filler
  450. FLOAT128 FltF86; // Intel-IA64-Filler
  451. FLOAT128 FltF87; // Intel-IA64-Filler
  452. FLOAT128 FltF88; // Intel-IA64-Filler
  453. FLOAT128 FltF89; // Intel-IA64-Filler
  454. FLOAT128 FltF90; // Intel-IA64-Filler
  455. FLOAT128 FltF91; // Intel-IA64-Filler
  456. FLOAT128 FltF92; // Intel-IA64-Filler
  457. FLOAT128 FltF93; // Intel-IA64-Filler
  458. FLOAT128 FltF94; // Intel-IA64-Filler
  459. FLOAT128 FltF95; // Intel-IA64-Filler
  460. FLOAT128 FltF96; // Intel-IA64-Filler
  461. FLOAT128 FltF97; // Intel-IA64-Filler
  462. FLOAT128 FltF98; // Intel-IA64-Filler
  463. FLOAT128 FltF99; // Intel-IA64-Filler
  464. FLOAT128 FltF100; // Intel-IA64-Filler
  465. FLOAT128 FltF101; // Intel-IA64-Filler
  466. FLOAT128 FltF102; // Intel-IA64-Filler
  467. FLOAT128 FltF103; // Intel-IA64-Filler
  468. FLOAT128 FltF104; // Intel-IA64-Filler
  469. FLOAT128 FltF105; // Intel-IA64-Filler
  470. FLOAT128 FltF106; // Intel-IA64-Filler
  471. FLOAT128 FltF107; // Intel-IA64-Filler
  472. FLOAT128 FltF108; // Intel-IA64-Filler
  473. FLOAT128 FltF109; // Intel-IA64-Filler
  474. FLOAT128 FltF110; // Intel-IA64-Filler
  475. FLOAT128 FltF111; // Intel-IA64-Filler
  476. FLOAT128 FltF112; // Intel-IA64-Filler
  477. FLOAT128 FltF113; // Intel-IA64-Filler
  478. FLOAT128 FltF114; // Intel-IA64-Filler
  479. FLOAT128 FltF115; // Intel-IA64-Filler
  480. FLOAT128 FltF116; // Intel-IA64-Filler
  481. FLOAT128 FltF117; // Intel-IA64-Filler
  482. FLOAT128 FltF118; // Intel-IA64-Filler
  483. FLOAT128 FltF119; // Intel-IA64-Filler
  484. FLOAT128 FltF120; // Intel-IA64-Filler
  485. FLOAT128 FltF121; // Intel-IA64-Filler
  486. FLOAT128 FltF122; // Intel-IA64-Filler
  487. FLOAT128 FltF123; // Intel-IA64-Filler
  488. FLOAT128 FltF124; // Intel-IA64-Filler
  489. FLOAT128 FltF125; // Intel-IA64-Filler
  490. FLOAT128 FltF126; // Intel-IA64-Filler
  491. FLOAT128 FltF127; // Intel-IA64-Filler
  492. //
  493. // This section is specified/returned if the ContextFlags word contains
  494. // the flag CONTEXT_LOWER_FLOATING_POINT | CONTEXT_HIGHER_FLOATING_POINT | CONTEXT_CONTROL.
  495. //
  496. U64 StFPSR; // Intel-IA64-Filler ; FP status
  497. //
  498. // This section is specified/returned if the ContextFlags word contains
  499. // the flag CONTEXT_INTEGER.
  500. //
  501. // N.B. The registers gp, sp, rp are part of the control context
  502. //
  503. U64 IntGp; // Intel-IA64-Filler ; r1, volatile
  504. U64 IntT0; // Intel-IA64-Filler ; r2-r3, volatile
  505. U64 IntT1; // Intel-IA64-Filler ;
  506. U64 IntS0; // Intel-IA64-Filler ; r4-r7, preserved
  507. U64 IntS1; // Intel-IA64-Filler
  508. U64 IntS2; // Intel-IA64-Filler
  509. U64 IntS3; // Intel-IA64-Filler
  510. U64 IntV0; // Intel-IA64-Filler ; r8, volatile
  511. U64 IntT2; // Intel-IA64-Filler ; r9-r11, volatile
  512. U64 IntT3; // Intel-IA64-Filler
  513. U64 IntT4; // Intel-IA64-Filler
  514. U64 IntSp; // Intel-IA64-Filler ; stack pointer (r12), special
  515. U64 IntTeb; // Intel-IA64-Filler ; teb (r13), special
  516. U64 IntT5; // Intel-IA64-Filler ; r14-r31, volatile
  517. U64 IntT6; // Intel-IA64-Filler
  518. U64 IntT7; // Intel-IA64-Filler
  519. U64 IntT8; // Intel-IA64-Filler
  520. U64 IntT9; // Intel-IA64-Filler
  521. U64 IntT10; // Intel-IA64-Filler
  522. U64 IntT11; // Intel-IA64-Filler
  523. U64 IntT12; // Intel-IA64-Filler
  524. U64 IntT13; // Intel-IA64-Filler
  525. U64 IntT14; // Intel-IA64-Filler
  526. U64 IntT15; // Intel-IA64-Filler
  527. U64 IntT16; // Intel-IA64-Filler
  528. U64 IntT17; // Intel-IA64-Filler
  529. U64 IntT18; // Intel-IA64-Filler
  530. U64 IntT19; // Intel-IA64-Filler
  531. U64 IntT20; // Intel-IA64-Filler
  532. U64 IntT21; // Intel-IA64-Filler
  533. U64 IntT22; // Intel-IA64-Filler
  534. U64 IntNats; // Intel-IA64-Filler ; Nat bits for r1-r31
  535. // Intel-IA64-Filler ; r1-r31 in bits 1 thru 31.
  536. U64 Preds; // Intel-IA64-Filler ; predicates, preserved
  537. U64 BrRp; // Intel-IA64-Filler ; return pointer, b0, preserved
  538. U64 BrS0; // Intel-IA64-Filler ; b1-b5, preserved
  539. U64 BrS1; // Intel-IA64-Filler
  540. U64 BrS2; // Intel-IA64-Filler
  541. U64 BrS3; // Intel-IA64-Filler
  542. U64 BrS4; // Intel-IA64-Filler
  543. U64 BrT0; // Intel-IA64-Filler ; b6-b7, volatile
  544. U64 BrT1; // Intel-IA64-Filler
  545. //
  546. // This section is specified/returned if the ContextFlags word contains
  547. // the flag CONTEXT_CONTROL.
  548. //
  549. // Other application registers
  550. U64 ApUNAT; // Intel-IA64-Filler ; User Nat collection register, preserved
  551. U64 ApLC; // Intel-IA64-Filler ; Loop counter register, preserved
  552. U64 ApEC; // Intel-IA64-Filler ; Epilog counter register, preserved
  553. U64 ApCCV; // Intel-IA64-Filler ; CMPXCHG value register, volatile
  554. U64 ApDCR; // Intel-IA64-Filler ; Default control register (TBD)
  555. // Register stack info
  556. U64 RsPFS; // Intel-IA64-Filler ; Previous function state, preserved
  557. U64 RsBSP; // Intel-IA64-Filler ; Backing store pointer, preserved
  558. U64 RsBSPSTORE; // Intel-IA64-Filler
  559. U64 RsRSC; // Intel-IA64-Filler ; RSE configuration, volatile
  560. U64 RsRNAT; // Intel-IA64-Filler ; RSE Nat collection register, preserved
  561. // Trap Status Information
  562. U64 StIPSR; // Intel-IA64-Filler ; Interruption Processor Status
  563. U64 StIIP; // Intel-IA64-Filler ; Interruption IP
  564. U64 StIFS; // Intel-IA64-Filler ; Interruption Function State
  565. // iA32 related control registers
  566. U64 StFCR; // Intel-IA64-Filler ; copy of Ar21
  567. U64 Eflag; // Intel-IA64-Filler ; Eflag copy of Ar24
  568. U64 SegCSD; // Intel-IA64-Filler ; iA32 CSDescriptor (Ar25)
  569. U64 SegSSD; // Intel-IA64-Filler ; iA32 SSDescriptor (Ar26)
  570. U64 Cflag; // Intel-IA64-Filler ; Cr0+Cr4 copy of Ar27
  571. U64 StFSR; // Intel-IA64-Filler ; x86 FP status (copy of AR28)
  572. U64 StFIR; // Intel-IA64-Filler ; x86 FP status (copy of AR29)
  573. U64 StFDR; // Intel-IA64-Filler ; x86 FP status (copy of AR30)
  574. U64 UNUSEDPACK; // Intel-IA64-Filler ; added to pack StFDR to 16-bytes
  575. // @@END_DDKSPLIT
  576. } BTGENERIC_IA64_CONTEXT;
  577. // Vtune stuff
  578. typedef enum {
  579. VTUNE_CALL_ID_CREATED=1,
  580. VTUNE_CALL_ID_DELETED,
  581. VTUNE_CALL_ID_FLUSH,
  582. VTUNE_CALL_ID_ENTER,
  583. VTUNE_CALL_ID_EXIT,
  584. VTUNE_CALL_ID_EVENT,
  585. VTUNE_BTGENERIC_LOADED
  586. } VTUNE_CALL_ID_TYPE;
  587. typedef enum {
  588. VTUNE_COLD_BLOCK=1,
  589. VTUNE_HOT_BLOCK,
  590. VTUNE_HOT_LOOP_BLOCK,
  591. VTUNE_COLD_WRITABLE_BLOCK
  592. } VTUNE_BLOCK_CATEGORY_TYPE;
  593. typedef struct {
  594. U64 name; // length is smaller then 256 chars
  595. VTUNE_BLOCK_CATEGORY_TYPE type; // Vtune++ should be aware of this type, for breakdown
  596. U64 start; // index, i.e. guaranteed not to repeat
  597. U64 size; // in bytes
  598. U32 IA32start; // IA32 address
  599. U64 traversal; // An ID
  600. //char *assembly; // if needed
  601. U64 reserved; // unused
  602. } VTUNE_BLOCK_TYPE;
  603. typedef enum
  604. {
  605. ESTIMATED_TIME,
  606. CODE_SIZE,
  607. INST_COUNT
  608. } VTUNE_EVENT_TYPE;
  609. // BtgCanonizeSuspendContext return values
  610. enum BtThreadSuspendState
  611. {
  612. SUSPEND_STATE_CONSISTENT, // thread suspended in a consistent IA32 state;
  613. // no changes in IA64Context
  614. SUSPEND_STATE_CANONIZED, // IA32 thread state canonized;
  615. // there are changes in IA64Context
  616. SUSPEND_STATE_READY_FOR_CANONIZATION, // target thread is ready to canonize IA32 state by itself.
  617. // IA64Context has been changed so that resumed thread
  618. // will cannonize IA32 state and exit simulation
  619. BAD_SUSPEND_STATE, // recoverable error:
  620. // thread can not be suspended in the current state
  621. SUSPEND_STATE_INACCESIBLE // fatal error: thread can not be suspended
  622. };
  623. typedef U32 BT_THREAD_SUSPEND_STATE;
  624. // BTGeneric's APIs
  625. #if (BTGENERIC)
  626. extern BT_STATUS_CODE BtgStart(IN API_TABLE_TYPE * BTLlibApiTable,void * BTGenericLoadAddress, void * BTGenericEndAddress, int glstPoffset, U32 * BTGenericTlsSizeP, U32 * BTGenericContextOffsetP);
  627. extern BT_STATUS_CODE BtgThreadInit(BTGENERIC_LOCAL_STORAGE * glstMemory, U32 ia32StackPointer, BT_U64 FS_offset /*, BT_U64 GS_offset */);
  628. extern void BtgRun(void);
  629. extern void BtgThreadTerminated(void);
  630. extern void BtgThreadAborted(U64 threadId);
  631. extern void BtgProcessTerm(void);
  632. extern BT_STATUS_CODE BtgIA32ContextSet(BTGENERIC_LOCAL_STORAGE * glstMemory, const BTGENERIC_IA32_CONTEXT * context);
  633. extern BT_STATUS_CODE BtgIA32ContextGet(BTGENERIC_LOCAL_STORAGE * glstMemory, BTGENERIC_IA32_CONTEXT * context);
  634. extern BT_STATUS_CODE BtgIA32ContextSetRemote(BT_HANDLE processHandle, BTGENERIC_LOCAL_STORAGE * glstMemory, const BTGENERIC_IA32_CONTEXT * context);
  635. extern BT_STATUS_CODE BtgIA32ContextGetRemote(BT_HANDLE processHandle, BTGENERIC_LOCAL_STORAGE * glstMemory, BTGENERIC_IA32_CONTEXT * context);
  636. extern BT_EXCEPTION_CODE BtgIA32CanonizeContext(BTGENERIC_LOCAL_STORAGE * glstMemory, const BTGENERIC_IA64_CONTEXT * ia64context, const BT_EXCEPTION_RECORD * exceptionRecordP);
  637. extern void BtgReportLoad(U64 * location,U32 size,U8 * name);
  638. extern void BtgReportUnload(U64 * location,U32 size,U8 * name);
  639. extern void BtgNotifyChangePermissionRequest(void * startPage, U32 numPages, U64 permissions);
  640. extern void BtgFlushIA32InstructionCache(void * address, U32 size, BT_FLUSH_REASON reason);
  641. extern BT_STATUS_CODE BtgDebugSettings(int argc, char *argv[]);
  642. extern void BtgExceptionDebugPrint (void);
  643. extern void BtgNotifyExit (void);
  644. extern BT_THREAD_SUSPEND_STATE BtgCanonizeSuspendContext(BTGENERIC_LOCAL_STORAGE * glstMemory, BTGENERIC_IA64_CONTEXT * ia64context, U64 prevSuspendCount);
  645. extern BT_THREAD_SUSPEND_STATE BtgCanonizeSuspendContextRemote(BT_HANDLE processHandle, BTGENERIC_LOCAL_STORAGE * glstMemory, BTGENERIC_IA64_CONTEXT * ia64context, U64 prevSuspendCount);
  646. extern BT_THREAD_SUSPEND_STATE BtgCheckSuspendContext(BTGENERIC_LOCAL_STORAGE * glstMemory, const BTGENERIC_IA64_CONTEXT * ia64context);
  647. extern void BtgNotifyPrepareExit (void);
  648. extern void BtgFreeze(void);
  649. extern void BtgUnfreeze(void);
  650. extern BT_STATUS_CODE BtgChangeThreadIdentity(void);
  651. #ifdef OVERRIDE_TIA
  652. extern void BtgUseOverrideTIA(unsigned int OvrTiaSize, unsigned char * OvrTiaBuffer);
  653. #endif // OVERRIDE_TIA
  654. #else // BTLib
  655. extern PLABEL_PTR_TYPE BtlPlaceHolderTable[NO_OF_APIS];
  656. #define BTGENERIC(APIName) (*(BtlPlaceHolderTable[IDX_BTGENERIC_##APIName]))
  657. #define BTGENERIC_(TYPE,APIName) (*(TYPE (*)())(BtlPlaceHolderTable[IDX_BTGENERIC_##APIName]))
  658. //extern BT_STATUS_CODE BtgStart(API_TABLE_TYPE * BTLibAPITable,void * BTGenericAddress, void * BTGenericEnd, int glstOffset, U32 * BTGenericTlsSizeP, U32 * BTGenericContextOffsetP);
  659. #define BTGENERIC_START(BTLibAPITable, BTGenericAddress, BTGenericEnd, glstOffset, BTGenericTlsSizeP, BTGenericContextOffsetP) \
  660. BTGENERIC_(BT_STATUS_CODE, START)((API_TABLE_TYPE *)(BTLibAPITable), (void *)(BTGenericAddress), (void *)(BTGenericEnd), (S32)(glstOffset), (U32 *)(BTGenericTlsSizeP), (U32 *)(BTGenericContextOffsetP))
  661. //extern BT_STATUS_CODE BtgThreadInit(BTGENERIC_LOCAL_STORAGE * glstMemory, U32 ia32StackPointer, U64 FS_offset, U64 GS_offset);
  662. #define BTGENERIC_THREAD_INIT(glstMemory,ia32StackPointer, FS_offset /*, GS_offset */) \
  663. BTGENERIC_(BT_STATUS_CODE, THREAD_INIT)((void *)(glstMemory), (U32)(ia32StackPointer), (U64) FS_offset /*, (U64) GS_offset */)
  664. //extern void BtgRun(void);
  665. #define BTGENERIC_RUN() \
  666. BTGENERIC(RUN)()
  667. //extern void BtgThreadTerminated(void);
  668. #define BTGENERIC_THREAD_TERMINATED() \
  669. BTGENERIC(THREAD_TERMINATED)()
  670. //extern void BtgThreadAborted(U64 threadId);
  671. #define BTGENERIC_THREAD_ABORTED(threadId) \
  672. BTGENERIC(THREAD_ABORTED)((U64)(threadId))
  673. //extern void BtgProcessTerm(void);
  674. #define BTGENERIC_PROCESS_TERM() \
  675. BTGENERIC(PROCESS_TERM)()
  676. //extern BT_STATUS_CODE BtgIA32ContextSet(BTGENERIC_LOCAL_STORAGE * glstMemory, const BTGENERIC_IA32_CONTEXT * context);
  677. #define BTGENERIC_IA32_CONTEXT_SET(glstMemory, context) \
  678. BTGENERIC_(BT_STATUS_CODE, IA32_CONTEXT_SET)((void *)(glstMemory), (const BTGENERIC_IA32_CONTEXT *)(context))
  679. //extern BT_STATUS_CODE BtgIA32ContextGet(BTGENERIC_LOCAL_STORAGE * glstMemory, BTGENERIC_IA32_CONTEXT * context);
  680. #define BTGENERIC_IA32_CONTEXT_GET(glstMemory, context) \
  681. BTGENERIC_(BT_STATUS_CODE, IA32_CONTEXT_GET)((void *)(glstMemory), (BTGENERIC_IA32_CONTEXT *)(context))
  682. //extern BT_STATUS_CODE BtgIA32ContextSetRemote(BT_HANDLE processHandle, BTGENERIC_LOCAL_STORAGE * glstMemory, const BTGENERIC_IA32_CONTEXT * context);
  683. #define BTGENERIC_IA32_CONTEXT_SET_REMOTE(processHandle, glstMemory, context) \
  684. BTGENERIC_(BT_STATUS_CODE, IA32_CONTEXT_SET_REMOTE)((BT_HANDLE)(processHandle), (void *)(glstMemory), (const BTGENERIC_IA32_CONTEXT *)(context))
  685. //extern BT_STATUS_CODE BtgIA32ContextGetRemote(BT_HANDLE processHandle, BTGENERIC_LOCAL_STORAGE * glstMemory, BTGENERIC_IA32_CONTEXT * context);
  686. #define BTGENERIC_IA32_CONTEXT_GET_REMOTE(processHandle, glstMemory, context) \
  687. BTGENERIC_(BT_STATUS_CODE, IA32_CONTEXT_GET_REMOTE)((BT_HANDLE)(processHandle), (void *)(glstMemory), (BTGENERIC_IA32_CONTEXT *)(context))
  688. //extern BT_EXCEPTION_CODE BtgIA32CanonizeContext(BTGENERIC_LOCAL_STORAGE * glstMemory, const BTGENERIC_IA64_CONTEXT * ia64context, const BT_EXCEPTION_RECORD * exceptionRecordP);
  689. #define BTGENERIC_IA32_CANONIZE_CONTEXT(glstMemory, ia64context, exceptionRecordP) \
  690. BTGENERIC_(BT_EXCEPTION_CODE, IA32_CANONIZE_CONTEXT)((void *)glstMemory, (const BTGENERIC_IA64_CONTEXT *)(ia64context), (const BT_EXCEPTION_RECORD *)(exceptionRecordP))
  691. //extern void BtgReportLoad(U64 * location,U32 size,U8 * name);
  692. #define BTGENERIC_REPORT_LOAD(location, size, name) \
  693. BTGENERIC(REPORT_LOAD)((U64 *)(location),(U32)(size),(U8 *)(name))
  694. //extern void BtgReportUnload(U64 * location,U32 size,U8 * name);
  695. #define BTGENERIC_REPORT_UNLOAD(location, size, name) \
  696. BTGENERIC(REPORT_UNLOAD)((U64 *)(location),(U32)(size),(U8 *)(name))
  697. //extern void BtgNotifyChangePermissionRequest(void * startPage, U32 numPages, U64 permissions);
  698. #define BTGENERIC_NOTIFY_CHANGE_PERMISSION_REQUEST(pageStart, numPages, permissions) \
  699. BTGENERIC(NOTIFY_CHANGE_PERMISSION_REQUEST)((void *)(pageStart), (U32)(numPages), (U64)(permissions))
  700. //extern void BtgFlushIA32InstructionCache(void * address, U32 size, BT_FLUSH_REASON reason);
  701. #define BTGENERIC_FLUSH_IA32_INSTRUCTION_CACHE(address, size, reason) \
  702. BTGENERIC(FLUSH_IA32_INSTRUCTION_CACHE)((void *)(address), (U32)(size), (BT_FLUSH_REASON)reason)
  703. //extern BT_STATUS_CODE BtgDebugSettings(int argc, char *argv[])
  704. #define BTGENERIC_DEBUG_SETTINGS(argc, argv) \
  705. BTGENERIC_(BT_STATUS_CODE, DEBUG_SETTINGS)((int)(argc), (char **)(argv))
  706. //extern void BtgExceptionDebugPrint (void);
  707. #define BTGENERIC_EXCEPTION_DEBUG_PRINT() \
  708. BTGENERIC(EXCEPTION_DEBUG_PRINT)()
  709. //extern void BtgNotifyExit (void);
  710. #define BTGENERIC_NOTIFY_EXIT() \
  711. BTGENERIC(NOTIFY_EXIT)()
  712. //extern BT_THREAD_SUSPEND_STATE BtgCanonizeSuspendContext(BTGENERIC_LOCAL_STORAGE * glstMemory, BTGENERIC_IA64_CONTEXT * ia64context, U64 prevSuspendCount);
  713. #define BTGENERIC_CANONIZE_SUSPEND_CONTEXT(glstMemory, ia64context, prevSuspendCount) \
  714. BTGENERIC_(BT_THREAD_SUSPEND_STATE,CANONIZE_SUSPEND_CONTEXT)((void *)(glstMemory), (BTGENERIC_IA64_CONTEXT *)(ia64context), (U64)prevSuspendCount)
  715. //extern BT_THREAD_SUSPEND_STATE BtgCanonizeSuspendContextRemote(BT_HANDLE processHandle, BTGENERIC_LOCAL_STORAGE * glstMemory, BTGENERIC_IA64_CONTEXT * ia64context, U64 prevSuspendCount);
  716. #define BTGENERIC_CANONIZE_SUSPEND_CONTEXT_REMOTE(processHandle, glstMemory, ia64context, prevSuspendCount) \
  717. BTGENERIC_(BT_THREAD_SUSPEND_STATE,CANONIZE_SUSPEND_CONTEXT_REMOTE)((BT_HANDLE)(processHandle), (void *)(glstMemory), (BTGENERIC_IA64_CONTEXT *)(ia64context), (U64)prevSuspendCount)
  718. //extern BT_THREAD_SUSPEND_STATE BtgCheckSuspendContext(BTGENERIC_LOCAL_STORAGE * glstMemory, const BTGENERIC_IA64_CONTEXT * ia64context);
  719. #define BTGENERIC_CHECK_SUSPEND_CONTEXT(glstMemory, ia64context) \
  720. BTGENERIC_(BT_THREAD_SUSPEND_STATE, CHECK_SUSPEND_CONTEXT)((void *)(glstMemory), (const BTGENERIC_IA64_CONTEXT *)(ia64context))
  721. //extern void BtgNotifyPrepareExit (void);
  722. #define BTGENERIC_NOTIFY_PREPARE_EXIT() \
  723. BTGENERIC(NOTIFY_PREPARE_EXIT)()
  724. //extern void BtgFreezeBtrans(void);
  725. #define BTGENERIC_FREEZE() \
  726. BTGENERIC(FREEZE)()
  727. //extern void BtgUnfreezeBtrans(void);
  728. #define BTGENERIC_UNFREEZE() \
  729. BTGENERIC(UNFREEZE)()
  730. //extern BT_STATUS_CODE BtgChangeThreadIdentity(void);
  731. #define BTGENERIC_CHANGE_THREAD_IDENTITY() \
  732. BTGENERIC_(BT_STATUS_CODE, CHANGE_THREAD_IDENTITY)()
  733. #endif
  734. #ifdef OVERRIDE_TIA
  735. //extern void BtgUseOverrideTIA(unsigned int OvrTiaSize, unsigned char * OvrTiaBuffer);
  736. #define BTGENERIC_USE_OVERRIDE_TIA(OvrTiaSize, OvrTiaBuffer) \
  737. BTGENERIC(USE_OVERRIDE_TIA)((unsigned int)(OvrTiaSize), (unsigned char *)(OvrTiaBuffer))
  738. #endif // OVERRIDE_TIA
  739. // BTLib's APIs
  740. #if (BTGENERIC)
  741. extern PLABEL_PTR_TYPE BtgPlaceholderTable[NO_OF_APIS];
  742. #define BTLIB(APIName) (*(BtgPlaceholderTable[IDX_BTLIB_##APIName]))
  743. #define BTLIB_(TYPE,APIName) (*(TYPE (*)())(BtgPlaceholderTable[IDX_BTLIB_##APIName]))
  744. //extern U64 BtlGetThreadId(void);
  745. #define BTLIB_GET_THREAD_ID() \
  746. BTLIB_(U64,GET_THREAD_ID)()
  747. //extern void BtlIA32Reenter(IN OUT BTGENERIC_IA32_CONTEXT * ia32context);
  748. #define BTLIB_IA32_REENTER(ia32context) \
  749. BTLIB(IA32_REENTER)((BTGENERIC_IA32_CONTEXT *)(ia32context))
  750. //extern void BtlIA32LCall (IN OUT BTGENERIC_IA32_CONTEXT * ia32context, IN U32 returnAddress, IN U32 targetAddress);
  751. #define BTLIB_IA32_LCALL(ia32context, returnAddress, targetAddress) \
  752. BTLIB(IA32_LCALL)((BTGENERIC_IA32_CONTEXT *)(ia32context), (U32)(returnAddress), (U32)(targetAddress))
  753. //extern void BtlIA32JmpIA64 (IN OUT BTGENERIC_IA32_CONTEXT * ia32context, IN U32 returnAddress, IN U32 targetAddress);
  754. #define BTLIB_IA32_JMP_IA64(ia32context, returnAddress, targetAddress) \
  755. BTLIB(IA32_JMP_IA64)((BTGENERIC_IA32_CONTEXT *)(ia32context), (U32)(returnAddress), (U32)(targetAddress))
  756. //extern void BtlIA32Interrupt(IN OUT BTGENERIC_IA32_CONTEXT * ia32context, IN BT_EXCEPTION_CODE exceptionCode, IN U32 returnAddress);
  757. #define BTLIB_IA32_INTERRUPT(ia32context, exceptionCode, returnAddress) \
  758. BTLIB(IA32_INTERRUPT)((BTGENERIC_IA32_CONTEXT *)(ia32context), (BT_EXCEPTION_CODE)(exceptionCode), (U32)(returnAddress))
  759. //extern void BtlLockSignals(void);
  760. #define BTLIB_LOCK_SIGNALS() \
  761. BTLIB(LOCK_SIGNALS)()
  762. //extern void BtlUnlockSignals(void);
  763. #define BTLIB_UNLOCK_SIGNALS() \
  764. BTLIB(UNLOCK_SIGNALS)()
  765. //extern void * BtlMemoryAlloc(void * startAddress,U32 size, U64 prot);
  766. #define BTLIB_MEMORY_ALLOC(startAddress,size,prot) \
  767. BTLIB_(void *,MEMORY_ALLOC)((void *)(startAddress),(U32)(size), (U64)(prot))
  768. //extern BT_STATUS_CODE BtlMemoryFree(void * startAddress,U32 size);
  769. #define BTLIB_MEMORY_FREE(startAddress,size) \
  770. BTLIB_(BT_STATUS_CODE, MEMORY_FREE)((void *)(startAddress),(U32)(size))
  771. //extern U32 BtlMemoryPageSize(void);
  772. #define BTLIB_MEMORY_PAGE_SIZE() \
  773. BTLIB_(U32,MEMORY_PAGE_SIZE)()
  774. //extern U64 BtlMemoryChangePermissions(void * startAddress, U32 size, U64 prot);
  775. #define BTLIB_MEMORY_CHANGE_PERMISSIONS(startAddress, size, prot) \
  776. BTLIB_(U64,MEMORY_CHANGE_PERMISSIONS)((void *)(startAddress), (U32)(size), (U64)(prot))
  777. //extern U64 BtlMemoryQueryPermissions(void * address, void ** pRegionStart, U32 * pRegionSize);
  778. #define BTLIB_MEMORY_QUERY_PERMISSIONS(address, pRegionStart, pRegionSize) \
  779. BTLIB_(U64,MEMORY_QUERY_PERMISSIONS)((void *)(address), (void **)(pRegionStart), (U32 *)(pRegionSize))
  780. //extern BT_STATUS_CODE BtlMemoryReadRemote(BT_HANDLE processHandle, void * baseAddress, void * buffer, U32 requestedSize);
  781. #define BTLIB_MEMORY_READ_REMOTE(processHandle, baseAddress, buffer, requestedSize) \
  782. BTLIB_(BT_STATUS_CODE,MEMORY_READ_REMOTE)((BT_HANDLE)(processHandle), (void *)(baseAddress), (void *)buffer, (U32)(requestedSize))
  783. //extern BT_STATUS_CODE BtlMemoryWriteRemote(BT_HANDLE processHandle, void * baseAddress, const void * buffer, U32 requestedSize);
  784. #define BTLIB_MEMORY_WRITE_REMOTE(processHandle, baseAddress, buffer, requestedSize) \
  785. BTLIB_(BT_STATUS_CODE,MEMORY_WRITE_REMOTE)((BT_HANDLE)(processHandle), (void *)(baseAddress), (const void *)buffer, (U32)(requestedSize))
  786. //extern BT_STATUS_CODE BtlSuspendThread(U64 ThreadId, U32 TryCounter);
  787. #define BTLIB_SUSPEND_THREAD(ThreadId, TryCounter) \
  788. BTLIB_(BT_STATUS_CODE, SUSPEND_THREAD)((U64)(ThreadId), (U32)(TryCounter))
  789. //extern BT_STATUS_CODE BtlResumeThread(U64 ThreadId);
  790. #define BTLIB_RESUME_THREAD(ThreadId) \
  791. BTLIB_(BT_STATUS_CODE, RESUME_THREAD)((U64)(ThreadId))
  792. //extern BT_STATUS_CODE BtlInitAccessLock(void * lock);
  793. #define BTLIB_INIT_ACCESS_LOCK(lock) \
  794. BTLIB_(BT_STATUS_CODE,INIT_ACCESS_LOCK)((void *)(lock))
  795. //extern BT_STATUS_CODE BtlLockAccess(void * lock, U64 flag);
  796. #define BTLIB_LOCK_ACCESS(lock,flag) \
  797. BTLIB_(BT_STATUS_CODE,LOCK_ACCESS)((void *)(lock),(U64)(flag))
  798. //extern void BtlUnlockAccess(void * lock);
  799. #define BTLIB_UNLOCK_ACCESS(lock) \
  800. BTLIB(UNLOCK_ACCESS)((void *)(lock))
  801. //extern void BtlInvalidateAccessLock(void * lock);
  802. #define BTLIB_INVALIDATE_ACCESS_LOCK(lock) \
  803. BTLIB(INVALIDATE_ACCESS_LOCK)((void *)(lock))
  804. //extern U32 BtlQueryJmpbufSize(void);
  805. #define BTLIB_QUERY_JMPBUF_SIZE() \
  806. BTLIB_(U32,QUERY_JMPBUF_SIZE)()
  807. ////extern U32 BtlSetjmp(void * jmpbufAddress);
  808. //#define BTLIB_SETJMP(jmpbufAddress) BTLIB_(U32,SETJMP)((void *)(jmpbufAddress))
  809. ////extern void BtlLongjmp(void * jmpbufAddress,U32 value);
  810. //#define BTLIB_LONGJMP(jmpbufAddress, value) BTLIB(LONGJMP)((void *)(jmpbufAddress),(U32)(value))
  811. //extern void BtlDebugPrint(U8 * buffer);
  812. #define BTLIB_DEBUG_PRINT(buffer) \
  813. BTLIB(DEBUG_PRINT)((U8 *)(buffer))
  814. //extern void BtlAbort(void);
  815. #define BTLIB_ABORT() \
  816. BTLIB(ABORT)()
  817. //extern void BtlVtuneCodeCreated(VTUNE_BLOCK_TYPE *block);
  818. #define BTLIB_VTUNE_CODE_CREATED(block) \
  819. BTLIB(VTUNE_CODE_CREATED)((VTUNE_BLOCK_TYPE *)(block))
  820. //extern void BtlVtuneCodeDeleted(U64 block_start);
  821. #define BTLIB_VTUNE_CODE_DELETED(blockStart) \
  822. BTLIB(VTUNE_CODE_DELETED)((U64)(blockStart))
  823. //extern void BtlVtuneEnteringDynamicCode(void);
  824. #define BTLIB_VTUNE_ENTERING_DYNAMIC_CODE() \
  825. BTLIB(VTUNE_ENTERING_DYNAMIC_CODE)()
  826. //extern void BtlVtuneExitingDynamicCode(void);
  827. #define BTLIB_VTUNE_EXITING_DYNAMIC_CODE() \
  828. BTLIB(VTUNE_EXITING_DYNAMIC_CODE)()
  829. //extern void BtlVtuneCodeToTIADmpFile (U64 * em_code, U64 em_size);
  830. #define BTLIB_VTUNE_CODE_TO_TIA_DMP_FILE(emCode, emSize) \
  831. BTLIB(VTUNE_CODE_TO_TIA_DMP_FILE)((U64 *)(emCode),(U64)(emSize))
  832. //extern U64 BtlSscPerfGetCounter64(U32 Handle);
  833. #define BTLIB_SSCPERFGETCOUNTER64(Handle) \
  834. BTLIB_(U64,SSCPERFGETCOUNTER64)((U32)(Handle))
  835. //extern U32 BtlSscPerfSetCounter64(U32 Handle, U64 Value);
  836. #define BTLIB_SSCPERFSETCOUNTER64(Handle, Value) \
  837. BTLIB_(U32,SSCPERFSETCOUNTER64)((U32)(Handle),(U64)(Value))
  838. //extern U32 BtlSscPerfSendEvent(U32 Handle);
  839. #define BTLIB_SSCPERFSENDEVENT(Handle) \
  840. BTLIB_(U32,SSCPERFSENDEVENT)((U32)(Handle))
  841. //extern U64 BtlSscPerfEventHandle(U64 EventName);
  842. #define BTLIB_SSCPERFEVENTHANDLE(EventName) \
  843. BTLIB_(U64,SSCPERFEVENTHANDLE)((U64)(EventName))
  844. //extern U64 BtlSscPerfCounterHandle(U64 DataItemName);
  845. #define BTLIB_SSCPERFCOUNTERHANDLE(DataItemName) \
  846. BTLIB_(U64,SSCPERFCOUNTERHANDLE)((U64)(DataItemName))
  847. //extern void BtlYieldThreadExecution(void);
  848. #define BTLIB_YIELD_THREAD_EXECUTION() \
  849. BTLIB(YIELD_THREAD_EXECUTION)()
  850. #define BTLIB_FLUSH_IA64_INSTRUCTION_CACHE(Address,Length) \
  851. BTLIB(FLUSH_IA64_INSTRUCTION_CACHE)((U64)(Address),(U32)(Length))
  852. #else // BTLib
  853. #define BTLIB_GET_THREAD_ID BtlGetThreadId
  854. #define BTLIB_IA32_REENTER BtlIA32Reenter
  855. #define BTLIB_IA32_LCALL BtlIA32LCall
  856. #define BTLIB_IA32_INTERRUPT BtlIA32Interrupt
  857. #define BTLIB_IA32_JMP_IA64 BtlIA32JmpIA64
  858. #define BTLIB_LOCK_SIGNALS BtlLockSignals
  859. #define BTLIB_UNLOCK_SIGNALS BtlUnlockSignals
  860. #define BTLIB_MEMORY_ALLOC BtlMemoryAlloc
  861. #define BTLIB_MEMORY_FREE BtlMemoryFree
  862. #define BTLIB_MEMORY_PAGE_SIZE BtlMemoryPageSize
  863. #define BTLIB_MEMORY_CHANGE_PERMISSIONS BtlMemoryChangePermissions
  864. #define BTLIB_MEMORY_QUERY_PERMISSIONS BtlMemoryQueryPermissions
  865. #define BTLIB_MEMORY_READ_REMOTE BtlMemoryReadRemote
  866. #define BTLIB_MEMORY_WRITE_REMOTE BtlMemoryWriteRemote
  867. #define BTLIB_SUSPEND_THREAD BtlSuspendThread
  868. #define BTLIB_RESUME_THREAD BtlResumeThread
  869. #define BTLIB_INIT_ACCESS_LOCK BtlInitAccessLock
  870. #define BTLIB_LOCK_ACCESS BtlLockAccess
  871. #define BTLIB_UNLOCK_ACCESS BtlUnlockAccess
  872. #define BTLIB_INVALIDATE_ACCESS_LOCK BtlInvalidateAccessLock
  873. #define BTLIB_QUERY_JMPBUF_SIZE BtlQueryJmpbufSize
  874. //#define BTLIB_SETJMP BtlSetjmp
  875. //#define BTLIB_LONGJMP BtlLongjmp
  876. #define BTLIB_DEBUG_PRINT BtlDebugPrint
  877. #define BTLIB_ABORT BtlAbort
  878. #define BTLIB_VTUNE_CODE_CREATED BtlVtuneCodeCreated
  879. #define BTLIB_VTUNE_CODE_DELETED BtlVtuneCodeDeleted
  880. #define BTLIB_VTUNE_ENTERING_DYNAMIC_CODE BtlVtuneEnteringDynamicCode
  881. #define BTLIB_VTUNE_EXITING_DYNAMIC_CODE BtlVtuneExitingDynamicCode
  882. #define BTLIB_VTUNE_CODE_TO_TIA_DMP_FILE BtlVtuneCodeToTIADmpFile
  883. #define BTLIB_SSCPERFGETCOUNTER64 BtlSscPerfGetCounter64
  884. #define BTLIB_SSCPERFSETCOUNTER64 BtlSscPerfSetCounter64
  885. #define BTLIB_SSCPERFSENDEVENT BtlSscPerfSendEvent
  886. #define BTLIB_SSCPERFEVENTHANDLE BtlSscPerfEventHandle
  887. #define BTLIB_SSCPERFCOUNTERHANDLE BtlSscPerfCounterHandle
  888. #define BTLIB_YIELD_THREAD_EXECUTION BtlYieldThreadExecution
  889. #define BTLIB_FLUSH_INSTRUCTION_CACHE BtlFlushIA64InstructionCache
  890. extern U64 BtlGetThreadId(void);
  891. extern void BtlIA32Reenter (IN OUT BTGENERIC_IA32_CONTEXT * ia32context);
  892. extern void BtlIA32JmpIA64 (IN OUT BTGENERIC_IA32_CONTEXT * ia32context, IN U32 returnAddress, IN U32 targetAddress);
  893. extern void BtlIA32LCall (IN OUT BTGENERIC_IA32_CONTEXT * ia32context, IN U32 returnAddress, IN U32 targetAddress);
  894. extern void BtlIA32Interrupt(IN OUT BTGENERIC_IA32_CONTEXT * ia32context, IN BT_EXCEPTION_CODE exceptionCode, IN U32 returnAddress);
  895. extern void BtlLockSignals(void);
  896. extern void BtlUnlockSignals(void);
  897. extern void * BtlMemoryAlloc(IN void * startAddress, IN U32 size, IN U64 prot);
  898. extern BT_STATUS_CODE BtlMemoryFree(IN void * startAddress, IN U32 size);
  899. extern U32 BtlMemoryPageSize(void);
  900. extern U64 BtlMemoryChangePermissions(IN void * start_address, IN U32 size, IN U64 prot);
  901. extern U64 BtlMemoryQueryPermissions(IN void * address, OUT void ** pRegionStart, OUT U32 * pRegionSize);
  902. extern BT_STATUS_CODE BtlMemoryReadRemote(IN BT_HANDLE processHandle, IN void * baseAddress, OUT void * buffer, IN U32 requestedSize);
  903. extern BT_STATUS_CODE BtlMemoryWriteRemote(IN BT_HANDLE processHandle, OUT void * baseAddress, IN const void * buffer, IN U32 requestedSize);
  904. extern BT_STATUS_CODE BtlSuspendThread(IN U64 ThreadId, IN U32 TryCounter);
  905. extern BT_STATUS_CODE BtlResumeThread(IN U64 ThreadId);
  906. extern BT_STATUS_CODE BtlInitAccessLock(OUT void * lock);
  907. extern BT_STATUS_CODE BtlLockAccess(IN OUT void * lock, IN U64 flag);
  908. extern void BtlUnlockAccess(IN OUT void * lock);
  909. extern void BtlInvalidateAccessLock(IN OUT void * lock);
  910. extern U32 BtlQueryJmpbufSize(void);
  911. //extern U32 BtlSetjmp(IN OUT void * jmpbufAddress);
  912. //extern void BtlLongjmp(IN OUT void * jmpbufAddress,U32 value);
  913. extern void BtlDebugPrint(IN U8 * buffer);
  914. extern void BtlAbort(void);
  915. extern void BtlVtuneCodeCreated(IN VTUNE_BLOCK_TYPE *block);
  916. extern void BtlVtuneCodeDeleted(IN U64 blockStart);
  917. extern void BtlVtuneEnteringDynamicCode(void);
  918. extern void BtlVtuneExitingDynamicCode(void);
  919. extern void BtlVtuneCodeToTIADmpFile (IN U64 * emCode, IN U64 emSize);
  920. extern U64 BtlSscPerfGetCounter64(IN U32 Handle);
  921. extern U32 BtlSscPerfSetCounter64(IN U32 Handle, IN U64 Value);
  922. extern U32 BtlSscPerfSendEvent(IN U32 Handle);
  923. extern U64 BtlSscPerfEventHandle(IN U64 EventName);
  924. extern U64 BtlSscPerfCounterHandle(IN U64 DataItemName);
  925. extern void BtlYieldThreadExecution(void);
  926. extern void BtlFlushIA64InstructionCache(IN void * Address, IN U32 Length);
  927. #endif
  928. #ifdef __cplusplus
  929. }
  930. #endif
  931. #endif // BTGENERIC_H