kxia64.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. /**
  2. * This file has no copyright assigned and is placed in the Public Domain.
  3. * This file is part of the mingw-w64 runtime package.
  4. * No warranty is given; refer to the file DISCLAIMER.PD within this package.
  5. */
  6. #define SHADOW_IRQL_IMPLEMENTATION 1
  7. #define PS0 0x0001
  8. #define PS1 0x0002
  9. #define PS2 0x0004
  10. #define PS3 0x0008
  11. #define PS4 0x0010
  12. #define PS5 0x0020
  13. #define PRP 0x0080
  14. #define PT0 0x0040
  15. #define PT1 0x0100
  16. #define PT2 0x0200
  17. #define PT3 0x0400
  18. #define PT4 0x0800
  19. #define PT5 0x1000
  20. #define PT6 0x2000
  21. #define PT7 0x4000
  22. #define PT8 0x8000
  23. #define NOM_BS0 0x0001
  24. #define NOM_BS1 0x0002
  25. #define NOM_BS2 0x0004
  26. #define NOM_BS3 0x0008
  27. #define NOM_BS4 0x0010
  28. #define NOM_BS5 0x0020
  29. #define NOM_BRP 0x0080
  30. #define NOM_BT0 0x0040
  31. #define NOM_BT1 0x0100
  32. #define NOM_BT2 0x0200
  33. #define NOM_BT3 0x0400
  34. #define NOM_BT4 0x0800
  35. #define NOM_BT5 0x1000
  36. #define NOM_BT6 0x2000
  37. #define NOM_BT7 0x4000
  38. #define NOM_BT8 0x8000
  39. #define PSR_MBZ4 0
  40. #define PSR_BE 1
  41. #define PSR_UP 2
  42. #define PSR_AC 3
  43. #define PSR_MFL 4
  44. #define PSR_MFH 5
  45. #define PSR_MBZ0 6
  46. #define PSR_MBZ0_V 0x7fll
  47. #define PSR_IC 13
  48. #define PSR_I 14
  49. #define PSR_PK 15
  50. #define PSR_MBZ1 16
  51. #define PSR_MBZ1_V 0x1ll
  52. #define PSR_DT 17
  53. #define PSR_DFL 18
  54. #define PSR_DFH 19
  55. #define PSR_SP 20
  56. #define PSR_PP 21
  57. #define PSR_DI 22
  58. #define PSR_SI 23
  59. #define PSR_DB 24
  60. #define PSR_LP 25
  61. #define PSR_TB 26
  62. #define PSR_RT 27
  63. #define PSR_MBZ2 28
  64. #define PSR_MBZ2_V 0xfll
  65. #define PSR_CPL 32
  66. #define PSR_CPL_LEN 2
  67. #define PSR_IS 34
  68. #define PSR_MC 35
  69. #define PSR_IT 36
  70. #define PSR_ID 37
  71. #define PSR_DA 38
  72. #define PSR_DD 39
  73. #define PSR_SS 40
  74. #define PSR_RI 41
  75. #define PSR_RI_LEN 2
  76. #define PSR_ED 43
  77. #define PSR_BN 44
  78. #define PSR_IA 45
  79. #define PSR_MBZ3 46
  80. #define PSR_MBZ3_V 0x3ffffll
  81. #define PL_KERNEL 0
  82. #define PL_USER 3
  83. #define IS_EM 0
  84. #define IS_IA 1
  85. #define FPSR_VD 0
  86. #define FPSR_DD 1
  87. #define FPSR_ZD 2
  88. #define FPSR_OD 3
  89. #define FPSR_UD 4
  90. #define FPSR_ID 5
  91. #define FPSR_FTZ0 6
  92. #define FPSR_WRE0 7
  93. #define FPSR_PC0 8
  94. #define FPSR_RC0 10
  95. #define FPSR_TD0 12
  96. #define FPSR_V0 13
  97. #define FPSR_D0 14
  98. #define FPSR_Z0 15
  99. #define FPSR_O0 16
  100. #define FPSR_U0 17
  101. #define FPSR_I0 18
  102. #define FPSR_FTZ1 19
  103. #define FPSR_WRE1 20
  104. #define FPSR_PC1 21
  105. #define FPSR_RC1 23
  106. #define FPSR_TD1 25
  107. #define FPSR_V1 26
  108. #define FPSR_D1 27
  109. #define FPSR_Z1 28
  110. #define FPSR_O1 29
  111. #define FPSR_U1 30
  112. #define FPSR_I1 31
  113. #define FPSR_FTZ2 32
  114. #define FPSR_WRE2 33
  115. #define FPSR_PC2 34
  116. #define FPSR_RC2 36
  117. #define FPSR_TD2 38
  118. #define FPSR_V2 39
  119. #define FPSR_D2 40
  120. #define FPSR_Z2 41
  121. #define FPSR_O2 42
  122. #define FPSR_U2 43
  123. #define FPSR_I2 44
  124. #define FPSR_FTZ3 45
  125. #define FPSR_WRE3 46
  126. #define FPSR_PC3 47
  127. #define FPSR_RC3 49
  128. #define FPSR_TD3 51
  129. #define FPSR_V3 52
  130. #define FPSR_D3 53
  131. #define FPSR_Z3 54
  132. #define FPSR_O3 55
  133. #define FPSR_U3 56
  134. #define FPSR_I3 57
  135. #define FPSR_MBZ0 58
  136. #define FPSR_MBZ0_V 0x3fll
  137. #define FPSR_FOR_KERNEL 0x9804C0270033F
  138. #define TPR_MIC 4
  139. #define TPR_MIC_LEN 4
  140. #define TPR_MMI 16
  141. #define TPR_IRQL_SHIFT TPR_MIC
  142. #define VECTOR_IRQL_SHIFT TPR_IRQL_SHIFT
  143. #define ISR_CODE 0
  144. #define ISR_CODE_LEN 16
  145. #define ISR_CODE_MASK 0xFFFF
  146. #define ISR_NA_CODE_MASK 0xF
  147. #define ISR_IA_VECTOR 16
  148. #define ISR_IA_VECTOR_LEN 8
  149. #define ISR_MBZ0 24
  150. #define ISR_MBZ0_V 0xff
  151. #define ISR_X 32
  152. #define ISR_W 33
  153. #define ISR_R 34
  154. #define ISR_NA 35
  155. #define ISR_SP 36
  156. #define ISR_RS 37
  157. #define ISR_IR 38
  158. #define ISR_NI 39
  159. #define ISR_MBZ1 40
  160. #define ISR_EI 41
  161. #define ISR_ED 43
  162. #define ISR_MBZ2 44
  163. #define ISR_MBZ2_V 0xfffff
  164. #define ISR_TPA 0
  165. #define ISR_FC 1
  166. #define ISR_PROBE 2
  167. #define ISR_TAK 3
  168. #define ISR_LFETCH 4
  169. #define ISR_PROBE_FAULT 5
  170. #define ISR_ILLEGAL_OP 0
  171. #define ISR_PRIV_OP 1
  172. #define ISR_PRIV_REG 2
  173. #define ISR_RESVD_REG 3
  174. #define ISR_ILLEGAL_ISA 4
  175. #define ISR_ILLEGAL_HAZARD 8
  176. #define ISR_NAT_REG 1
  177. #define ISR_NAT_PAGE 2
  178. #define ISR_FP_TRAP 0
  179. #define ISR_LP_TRAP 1
  180. #define ISR_TB_TRAP 2
  181. #define ISR_SS_TRAP 3
  182. #define ISR_UI_TRAP 4
  183. #define DCR_PP 0
  184. #define DCR_BE 1
  185. #define DCR_LC 2
  186. #define DCR_DM 8
  187. #define DCR_DP 9
  188. #define DCR_DK 10
  189. #define DCR_DX 11
  190. #define DCR_DR 12
  191. #define DCR_DA 13
  192. #define DCR_DD 14
  193. #define DCR_DEFER_ALL 0x7f00
  194. #define DCR_MBZ1 2
  195. #define DCR_MBZ1_V 0xffffffffffffll
  196. #define RSC_MODE 0
  197. #define RSC_PL 2
  198. #define RSC_BE 4
  199. #define RSC_MBZ0 5
  200. #define RSC_MBZ0_V 0x3ff
  201. #define RSC_LOADRS 16
  202. #define RSC_LOADRS_LEN 14
  203. #define RSC_MBZ1 30
  204. #define RSC_MBZ1_LEN 34
  205. #define RSC_MBZ1_V 0x3ffffffffll
  206. #define RSC_MODE_LY (0x0)
  207. #define RSC_MODE_SI (0x1)
  208. #define RSC_MODE_LI (0x2)
  209. #define RSC_MODE_EA (0x3)
  210. #define RSC_BE_LITTLE 0
  211. #define RSC_BE_BIG 1
  212. #define RSC_KERNEL ((RSC_MODE_EA<<RSC_MODE) | (RSC_BE_LITTLE<<RSC_BE))
  213. #define RSC_KERNEL_DISABLED ((RSC_MODE_LY<<RSC_MODE) | (RSC_BE_LITTLE<<RSC_BE))
  214. #define IFS_IFM 0
  215. #define IFS_IFM_LEN 38
  216. #define IFS_MBZ0 38
  217. #define IFS_MBZ0_V 0x1ffffffll
  218. #define IFS_V 63
  219. #define IFS_V_LEN 1
  220. #define IFS_VALID 1
  221. #define PFS_PPL 62
  222. #define PFS_PPL_LEN PSR_CPL_LEN
  223. #define PFS_EC_SHIFT 52
  224. #define PFS_EC_SIZE 6
  225. #define PFS_EC_MASK 0x3F
  226. #define PFS_SIZE_SHIFT 7
  227. #define PFS_SIZE_MASK 0x7F
  228. #define NAT_BITS_PER_RNAT_REG 63
  229. #define RNAT_ALIGNMENT (NAT_BITS_PER_RNAT_REG << 3)
  230. #define RR_VE 0
  231. #define RR_MBZ0 1
  232. #define RR_PS 2
  233. #define RR_PS_LEN 6
  234. #define RR_RID 8
  235. #define RR_RID_LEN 24
  236. #define RR_MBZ1 32
  237. #define RR_INDEX 61
  238. #define RR_INDEX_LEN 3
  239. #define RR_PS_VE ((PAGE_SHIFT<<RR_PS) | (1<<RR_VE))
  240. #define NT_RR_SIZE 4
  241. #define RR_SIZE 8
  242. #define PKR_V 0
  243. #define PKR_WD 1
  244. #define PKR_RD 2
  245. #define PKR_XD 3
  246. #define PKR_MBZ0 4
  247. #define PKR_KEY 8
  248. #define PKR_KEY_LEN 24
  249. #define PKR_MBZ1 32
  250. #define PKR_VALID (1<<PKR_V)
  251. #define PKRNUM 16
  252. #define ITIR_RV0 0
  253. #define ITIR_PS 2
  254. #define ITIR_KEY 8
  255. #define ITIR_RV1 32
  256. #define IDTR_MBZ0 0
  257. #define IDTR_PS 2
  258. #define IDTR_KEY 8
  259. #define IDTR_MBZ1 32
  260. #define IDTR_IGN0 48
  261. #define IDTR_PPN 56
  262. #define IDTR_MBZ2 63
  263. #define IITR_MBZ0 IDTR_MBZ0
  264. #define IITR_PS IDTR_PS
  265. #define IITR_KEY IDTR_KEY
  266. #define IITR_MBZ1 IDTR_MBZ1
  267. #define IITR_IGN0 IDTR_IGN0
  268. #define IITR_PPN IDTR_PPN
  269. #define IITR_MBZ2 IDTR_MBZ2
  270. #define IITR_PPN_MASK 0x7FFF000000000000
  271. #define IITR_ATTRIBUTE_PPN_MASK 0x0003FFFFFFFFF000
  272. #define TR_P 0
  273. #define TR_RV0 1
  274. #define TR_MA 2
  275. #define TR_A 5
  276. #define TR_D 6
  277. #define TR_PL 7
  278. #define TR_AR 9
  279. #define TR_PPN 13
  280. #define TR_RV1 50
  281. #define TR_ED 52
  282. #define TR_IGN0 53
  283. #define TR_VALUE(ed,ppn,ar,pl,d,a,ma,p) ((ed << TR_ED) | (ppn & IITR_ATTRIBUTE_PPN_MASK) | (ar << TR_AR) | (pl << TR_PL) | (d << TR_D) | (a << TR_A) | (ma << TR_MA) | (p << TR_P))
  284. #define ITIR_VALUE(key,ps) ((ps << ITIR_PS) | (key << ITIR_KEY))
  285. #define PS_4K 0xC
  286. #define PS_8K 0xD
  287. #define PS_16K 0xE
  288. #define PS_64K 0x10
  289. #define PS_256K 0x12
  290. #define PS_1M 0x14
  291. #define PS_4M 0x16
  292. #define PS_16M 0x18
  293. #define PS_64M 0x1a
  294. #define PS_256M 0x1c
  295. #define NUMBER_OF_DEBUG_REGISTER_PAIRS 4
  296. #define DR_MASK 0
  297. #define DR_MASK_LEN 56
  298. #define DR_PLM0 56
  299. #define DR_PLM1 57
  300. #define DR_PLM2 58
  301. #define DR_PLM3 59
  302. #define DR_IG 60
  303. #define DR_RW 62
  304. #define DR_RW_LEN 2
  305. #define DR_X 63
  306. #define NUMBER_OF_PERFMON_REGISTER_PAIRS 4
  307. #define MASK_IA64(bp,value) (value << bp)
  308. #define APC_VECTOR APC_LEVEL << VECTOR_IRQL_SHIFT
  309. #define DISPATCH_VECTOR DISPATCH_LEVEL << VECTOR_IRQL_SHIFT
  310. #define OFFSET_VECTOR_BREAK 0x2800
  311. #define OFFSET_VECTOR_EXT_INTERRUPT 0x2c00
  312. #define OFFSET_VECTOR_EXC_GENERAL 0x4400
  313. #define PAGEMASK_4KB 0x0
  314. #define PAGEMASK_16KB 0x3
  315. #define PAGEMASK_64KB 0xf
  316. #define PAGEMASK_256KB 0x3f
  317. #define PAGEMASK_1MB 0xff
  318. #define PAGEMASK_4MB 0x3ff
  319. #define PAGEMASK_16MB 0xfff
  320. #define PRIMARY_CACHE_INVALID 0x0
  321. #define PRIMARY_CACHE_SHARED 0x1
  322. #define PRIMARY_CACHE_CLEAN_EXCLUSIVE 0x2
  323. #define PRIMARY_CACHE_DIRTY_EXCLUSIVE 0x3
  324. #define PS_SHIFT 2
  325. #define PS_LEN 6
  326. #define PTE_VALID_MASK 1
  327. #define PTE_ACCESS_MASK 0x20
  328. #define PTE_NOCACHE 0x10
  329. #define PTE_CACHE_SHIFT 2
  330. #define PTE_CACHE_LEN 3
  331. #define PTE_LARGE_PAGE 54
  332. #define PTE_PFN_SHIFT 8
  333. #define PTE_PFN_LEN 24
  334. #define PTE_ATTR_SHIFT 1
  335. #define PTE_ATTR_LEN 5
  336. #define PTE_PS 55
  337. #define PTE_OFFSET_LEN 10
  338. #define PDE_OFFSET_LEN 10
  339. #define VFN_LEN 19
  340. #define VFN_LEN64 24
  341. #define TB_USER_MASK 0x180
  342. #define PTE_DIRTY_MASK 0x40
  343. #define PTE_WRITE_MASK 0x400
  344. #define PTE_EXECUTE_MASK 0x200
  345. #define PTE_CACHE_MASK 0x0
  346. #define PTE_EXC_DEFER 0x10000000000000
  347. #define VALID_KERNEL_PTE (PTE_VALID_MASK|PTE_ACCESS_MASK|PTE_WRITE_MASK|PTE_CACHE_MASK|PTE_DIRTY_MASK)
  348. #define VALID_KERNEL_EXECUTE_PTE (PTE_VALID_MASK|PTE_ACCESS_MASK|PTE_EXECUTE_MASK|PTE_WRITE_MASK|PTE_CACHE_MASK|PTE_DIRTY_MASK|PTE_EXC_DEFER)
  349. #define PTE_VALID 0
  350. #define PTE_ACCESS 5
  351. #define PTE_OWNER 7
  352. #define PTE_WRITE 10
  353. #define PTE_LP_CACHE_SHIFT 53
  354. #define ATE_INDIRECT 62
  355. #define ATE_MASK 0xFFFFFFFFFFFFF9DE
  356. #define ATE_MASK0 0x621
  357. #define PAGE4K_SHIFT 12
  358. #define ALT4KB_BASE 0x6FC00000000
  359. #define ALT4KB_END 0x6FC00800000
  360. #define VRN_SHIFT 61
  361. #define KSEG3_VRN 4
  362. #define KSEG4_VRN 5
  363. #define MAX_PHYSICAL_SHIFT 44
  364. #define DISABLE_TAR_FIX 0
  365. #define DISABLE_BTB_FIX 1
  366. #define DISABLE_DATA_BP_FIX 2
  367. #define DISABLE_DET_STALL_FIX 3
  368. #define ENABLE_FULL_DISPERSAL 4
  369. #define ENABLE_TB_BROADCAST 5
  370. #define DISABLE_CPL_FIX 6
  371. #define ENABLE_POWER_MANAGEMENT 7
  372. #define DISABLE_IA32BR_FIX 8
  373. #define DISABLE_L1_BYPASS 9
  374. #define DISABLE_VHPT_WALKER 10
  375. #define DISABLE_IA32RSB_FIX 11
  376. #define DISABLE_INTERRUPTION_LOG 13
  377. #define DISABLE_UNSAFE_FILL 14
  378. #define DISABLE_STORE_UPDATE 15
  379. #define ENABLE_HISTORY_BUFFER 16
  380. #define BL_4M 0x00400000
  381. #define BL_16M 0x01000000
  382. #define BL_20M 0x01400000
  383. #define BL_24M 0x01800000
  384. #define BL_28M 0x01C00000
  385. #define BL_32M 0x02000000
  386. #define BL_36M 0x02400000
  387. #define BL_40M 0x02800000
  388. #define BL_48M 0x03000000
  389. #define BL_64M 0x04000000
  390. #define BL_80M 0x05000000
  391. #define BL_128M 0x08000000
  392. #define TR_INFO_TABLE_SIZE 10
  393. #define BL_SAL_INDEX 0
  394. #define BL_KERNEL_INDEX 1
  395. #define BL_DRIVER0_INDEX 2
  396. #define BL_DRIVER1_INDEX 3
  397. #define BL_DECOMPRESS_INDEX 4
  398. #define BL_IO_PORT_INDEX 5
  399. #define BL_PAL_INDEX 6
  400. #define BL_LOADER_INDEX 7
  401. #define DTR_KIPCR_INDEX 0
  402. #define DTR_KERNEL_INDEX 1
  403. #define DTR_DRIVER0_INDEX 2
  404. #define DTR_KTBASE_INDEX 2
  405. #define DTR_DRIVER1_INDEX 3
  406. #define DTR_UTBASE_INDEX 3
  407. #define DTR_VIDEO_INDEX 3
  408. #define DTR_KIPCR2_INDEX 4
  409. #define DTR_STBASE_INDEX 4
  410. #define DTR_IO_PORT_INDEX 5
  411. #define DTR_KTBASE_INDEX_TMP 6
  412. #define DTR_HAL_INDEX 6
  413. #define DTR_PAL_INDEX 6
  414. #define DTR_UTBASE_INDEX_TMP 7
  415. #define DTR_LOADER_INDEX 7
  416. #define DTR_UTBASE_INDEX_TMP 7
  417. #define ITR_EPC_INDEX 0
  418. #define ITR_KERNEL_INDEX 1
  419. #define ITR_DRIVER0_INDEX 2
  420. #define ITR_DRIVER1_INDEX 3
  421. #define ITR_HAL_INDEX 4
  422. #define ITR_PAL_INDEX 4
  423. #define ITR_LOADER_INDEX 7
  424. #define MEM_4K 0x1000
  425. #define MEM_8K 0x2000
  426. #define MEM_16K 0x4000
  427. #define MEM_64K 0x10000
  428. #define MEM_256K 0x40000
  429. #define MEM_1M 0x100000
  430. #define MEM_4M 0x400000
  431. #define MEM_16M 0x1000000
  432. #define MEM_64M 0x4000000
  433. #define MEM_256M 0x10000000
  434. #define MEM_SIZE_TO_PS(MemSize,TrPageSize) if (MemSize <= MEM_4K) { TrPageSize = PS_4K; } else if (MemSize <= MEM_8K) { TrPageSize = PS_8K; } else if (MemSize <= MEM_16K) { TrPageSize = PS_16K; } else if (MemSize <= MEM_64K) { TrPageSize = PS_64K; } else if (MemSize <= MEM_256K) { TrPageSize = PS_256K; } else if (MemSize <= MEM_1M) { TrPageSize = PS_1M; } else if (MemSize <= MEM_4M) { TrPageSize = PS_4M; } else if (MemSize <= MEM_16M) { TrPageSize = PS_16M; } else if (MemSize <= MEM_64M) { TrPageSize = PS_64M; } else if (MemSize <= MEM_256M) { TrPageSize = PS_256M; }
  435. #define NUMBER_OF_FWP_ENTRIES 8
  436. #define KERNEL_BASE KADDRESS_BASE+0x80000000
  437. #define KERNEL_BASE2 KADDRESS_BASE+0x81000000
  438. #define PDR_TR_INITIAL TR_VALUE(0,0,2,0,1,1,0,1)
  439. #define KIPCR_TR_INITIAL TR_VALUE(0,0,2,0,1,1,0,1)
  440. #define USPCR_TR_INITIAL TR_VALUE(0,0,0,3,1,1,0,1)
  441. #define PTA_INITIAL 0x001
  442. #define DCR_INITIAL 0x0000000000007e05
  443. #define PSRL_INITIAL 0x086a2008
  444. #define USER_PSR_INITIAL 0x00001013082a6008ll
  445. #define USER_FPSR_INITIAL 0x9804C0270033F
  446. #define USER_DCR_INITIAL 0x0000000000007f05ll
  447. #define USER_RSC_INITIAL ((RSC_MODE_LY<<RSC_MODE) | (RSC_BE_LITTLE<<RSC_BE) | (0x3<<RSC_PL))
  448. #define USER_CODE_DESCRIPTOR 0xCFBFFFFF00000000
  449. #define USER_DATA_DESCRIPTOR 0xCF3FFFFF00000000
  450. #define STACK_SCRATCH_AREA 16
  451. #ifdef _WIN64
  452. #define INT_ROUTINES_SHIFT 3
  453. #else
  454. #define INT_ROUTINES_SHIFT 2
  455. #endif
  456. #define DISABLE_INTERRUPTS(reg) mov reg = psr; rsm 1 << PSR_I
  457. #define RESTORE_INTERRUPTS(reg) tbit##.##nz pt0,pt1 = reg,PSR_I;; ;(pt0) ssm 1 << PSR_I ;(pt1) rsm 1 << PSR_I
  458. #define FAST_DISABLE_INTERRUPTS rsm 1 << PSR_I
  459. #define FAST_ENABLE_INTERRUPTS ssm 1 << PSR_I
  460. #define YIELD hint##.##m 0
  461. #define PCR_ENTRY 0
  462. #define PDR_ENTRY 2
  463. #define LARGE_ENTRY 3
  464. #define DMA_ENTRY 4
  465. #define TB_ENTRY_SIZE (3 *4)
  466. #define FIXED_BASE 0
  467. #define FIXED_ENTRIES (DMA_ENTRY + 1)
  468. #define DCACHE_SIZE 4 *1024
  469. #define ICACHE_SIZE 4 *1024
  470. #define MINIMUM_CACHE_SIZE 4 *1024
  471. #define MAXIMUM_CACHE_SIZE 128 *1024
  472. #define KSEG3_RID 0x00000
  473. #define START_GLOBAL_RID 0x00001
  474. #define HAL_RID 0x00002
  475. #define START_SESSION_RID 0x00003
  476. #define START_PROCESS_RID 0x00004
  477. #define MAXIMUM_RID 0x3FFFF
  478. #define START_SEQUENCE 1
  479. #define MAXIMUM_SEQUENCE 0xFFFFFFFFFFFFFFFF
  480. #define SBTTL(x)
  481. #define PROLOGUE_BEGIN .##prologue;
  482. #define PROLOGUE_END .##body;
  483. #define ALTERNATE_ENTRY(Name) .##global Name; .##type Name,@function; Name::
  484. #define CPUBLIC_LEAF_ENTRY(Name,i) .##text; .##proc Name##@##i; Name##@##i::
  485. #define LEAF_ENTRY(Name) .##text; .##global Name; .##proc Name; Name::
  486. #define LEAF_SETUP(i,l,o,r) .##regstk i,l,o,r; alloc r31=ar##.##pfs,i,l,o,r
  487. #define CPUBLIC_NESTED_ENTRY(Name,i) .##text; .##proc Name##@##i; .##unwentry; Name##@##i::
  488. #define NESTED_ENTRY_EX(Name,Handler) .##text; .##global Name; .##proc Name; .##personality Handler; Name::
  489. #define NESTED_ENTRY(Name) .##text; .##global Name; .##proc Name; Name::
  490. #define NESTED_SETUP(i,l,o,r) .##regstk i,l,o,r; .##prologue 0xC,loc0; alloc savedpfs=ar##.##pfs,i,l,o,r ; mov savedbrp=brp;
  491. #define LEAF_RETURN br##.##ret##.##sptk##.##few##.##clr brp
  492. #define NESTED_RETURN mov ar##.##pfs = savedpfs; mov brp = savedbrp; br##.##ret##.##sptk##.##few##.##clr brp
  493. #define LEAF_EXIT(Name) .##endp Name;
  494. #define NESTED_EXIT(Name) .##endp Name;
  495. #ifdef _WIN64
  496. #define LDPTR(rD,rPtr) ld8 rD = [rPtr]
  497. #else
  498. #define LDPTR(rD,rPtr) ld4 rD = [rPtr] ; ;; ; sxt4 rD = rD
  499. #endif
  500. #ifdef _WIN64
  501. #define LDPTRINC(rD,rPtr,imm) ld8 rD = [rPtr],imm
  502. #else
  503. #define LDPTRINC(rD,rPtr,imm) ld4 rD = [rPtr],imm ; ;; ; sxt4 rD = rD
  504. #endif
  505. #ifdef _WIN64
  506. #define PLDPTRINC(rP,rD,rPtr,imm) (rP) ld8 rD = [rPtr],imm
  507. #else
  508. #define PLDPTRINC(rP,rD,rPtr,imm) (rP) ld4 rD = [rPtr],imm ; ;; ;(rP) sxt4 rD = rD
  509. #endif
  510. #ifdef _WIN64
  511. #define PLDPTR(rP,rD,rPtr) (rP) ld8 rD = [rPtr]
  512. #else
  513. #define PLDPTR(rP,rD,rPtr) (rP) ld4 rD = [rPtr] ; ;; ;(rP) sxt4 rD = rD
  514. #endif
  515. #ifdef _WIN64
  516. #define STPTR(rPtr,rS) st8 [rPtr] = rS
  517. #else
  518. #define STPTR(rPtr,rS) st4 [rPtr] = rS
  519. #endif
  520. #ifdef _WIN64
  521. #define PSTPTR(rP,rPtr,rS) (rP) st8 [rPtr] = rS
  522. #else
  523. #define PSTPTR(rP,rPtr,rS) (rP) st4 [rPtr] = rS
  524. #endif
  525. #ifdef _WIN64
  526. #define STPTRINC(rPtr,rS,imm) st8 [rPtr] = rS,imm
  527. #else
  528. #define STPTRINC(rPtr,rS,imm) st4 [rPtr] = rS,imm
  529. #endif
  530. #ifdef _WIN64
  531. #define ARGPTR(rPtr)
  532. #else
  533. #define ARGPTR(rPtr) sxt4 rPtr = rPtr
  534. #endif
  535. #define ACQUIRE_SPINLOCK(rpLock,rOwn,Loop) cmp##.##eq pt0,pt1 = zero,zero ; ;; ;Loop: ;.pred.rel "mutex",pt0,pt1 ;(pt1) YIELD ;(pt0) xchg8 t22 = [rpLock],rOwn ;(pt1) ld8##.##nt1 t22 = [rpLock] ; ;; ;(pt0) cmp##.##ne pt2 = zero,t22 ; cmp##.##eq pt0,pt1 = zero,t22 ;(pt2) br##.##dpnt Loop
  536. #define RELEASE_SPINLOCK(rpLock) st8##.##rel [rpLock] = zero
  537. #define PRELEASE_SPINLOCK(px,rpLock) (px) st8##.##rel [rpLock] = zero
  538. #define END_OF_INTERRUPT mov cr##.##eoi = zero ; ;; ; srlz##.##d
  539. #ifndef SHADOW_IRQL_IMPLEMENTATION
  540. #define GET_IRQL(rOldIrql) mov rOldIrql = cr##.##tpr ;; extr##.##u rOldIrql = rOldIrql,TPR_MIC,TPR_MIC_LEN
  541. #else
  542. #define GET_IRQL(rOldIrql) movl rOldIrql = KiPcr+PcCurrentIrql;; ld1 rOldIrql = [rOldIrql]
  543. #endif
  544. #ifndef SHADOW_IRQL_IMPLEMENTATION
  545. #define SET_IRQL(rNewIrql) dep##.##z t22 = rNewIrql,TPR_MIC,TPR_MIC_LEN;; ; mov cr##.##tpr = t22;; ; srlz##.##d
  546. #else
  547. #define SET_IRQL(rNewIrql) dep##.##z t22 = rNewIrql,TPR_MIC,TPR_MIC_LEN;; ; movl t21 = KiPcr+PcCurrentIrql;; ; mov cr##.##tpr = t22 ; st1 [t21] = rNewIrql
  548. #endif
  549. #ifndef SHADOW_IRQL_IMPLEMENTATION
  550. #define PSET_IRQL(pr,rNewIrql) dep##.##z t22 = rNewIrql,TPR_MIC,TPR_MIC_LEN;; ;(pr) mov cr##.##tpr = t22;; ;(pr) srlz##.##d
  551. #else
  552. #define PSET_IRQL(pr,rNewIrql) mov t21 = rNewIrql ; dep##.##z t22 = rNewIrql,TPR_MIC,TPR_MIC_LEN;; ;(pr) mov cr##.##tpr = t22 ;(pr) movl t22 = KiPcr+PcCurrentIrql;; ;(pr) st1 [t22] = t21
  553. #endif
  554. #define SWAP_IRQL(rNewIrql) movl t22 = KiPcr+PcCurrentIrql;; ; ld1 v0 = [t22] ; dep##.##z t21 = rNewIrql,TPR_MIC,TPR_MIC_LEN;; ; mov cr##.##tpr = t21 ; st1 [t22] = rNewIrql
  555. #define GET_IRQL_FOR_VECTOR(pGet,rIrql,rVector) (pGet) shr rIrql = rVector,VECTOR_IRQL_SHIFT
  556. #define GET_VECTOR_FOR_IRQL(pGet,rVector,rIrql) (pGet) shl rVector = rIrql,VECTOR_IRQL_SHIFT
  557. #define REQUEST_APC_INT(pReq) mov t20 = 1 ; movl t21 = KiPcr+PcApcInterrupt ; ;; ;(pReq) st1 [t21] = t20
  558. #define REQUEST_DISPATCH_INT(pReq) mov t20 = 1 ; movl t21 = KiPcr+PcDispatchInterrupt ; ;; ;(pReq) st1 [t21] = t20
  559. #define beginSection(SectName) .##section .CRT$##SectName,"a","progbits"
  560. #define endSection(SectName)
  561. #define PublicFunction(Name) .##global Name; .##type Name,@function