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.

648 lines
15 KiB

  1. /*++
  2. Copyright (c) 1993 IBM Corporation
  3. Module Name:
  4. ppcinst.h
  5. Abstract:
  6. PowerPC instruction and floating constant definitions.
  7. Author:
  8. Rick Simpson 30 July 1993
  9. Revision History:
  10. --*/
  11. #ifndef _PPCINST_
  12. #define _PPCINST_
  13. #if _MSC_VER > 1000
  14. #pragma once
  15. #endif
  16. //
  17. // POWERPC INSTRUCTION FORMAT STRUCTURES
  18. //
  19. typedef union _PPC_INSTRUCTION {
  20. ULONG Long;
  21. UCHAR Byte[4];
  22. struct {
  23. ULONG bit31 : 1;
  24. ULONG bit30 : 1;
  25. LONG bit6_29 : 24;
  26. ULONG bit0_5 : 6;
  27. } i_f;
  28. #define Primary_Op i_f.bit0_5
  29. #define Iform_LI i_f.bit6_29
  30. #define Iform_AA i_f.bit30
  31. #define Iform_LK i_f.bit31
  32. struct {
  33. ULONG bit31 : 1;
  34. ULONG bit30 : 1;
  35. LONG bit16_29 : 14;
  36. ULONG bit11_15 : 5;
  37. ULONG bit6_10 : 5;
  38. ULONG bit0_5 : 6;
  39. } b_f;
  40. #define Bform_BO b_f.bit6_10
  41. #define Bform_BI b_f.bit11_15
  42. #define Bform_BD b_f.bit16_29
  43. #define Bform_AA b_f.bit30
  44. #define Bform_LK b_f.bit31
  45. struct {
  46. ULONG bit31 : 1;
  47. ULONG bit30 : 1;
  48. ULONG bit6_29 : 24;
  49. ULONG bit0_5 : 6;
  50. } sc_f;
  51. #define SCform_XO sc_f.bit30
  52. struct {
  53. LONG bit16_31 : 16;
  54. ULONG bit11_15 : 5;
  55. ULONG bit6_10 : 5;
  56. ULONG bit0_5 : 6;
  57. } d_f1;
  58. struct {
  59. ULONG bit16_31 : 16;
  60. ULONG bit11_15 : 5;
  61. ULONG bit10 : 1;
  62. ULONG bit9 : 1;
  63. ULONG bit6_8 : 3;
  64. ULONG bit0_5 : 6;
  65. } d_f2;
  66. #define Dform_RT d_f1.bit6_10
  67. #define Dform_RS d_f1.bit6_10
  68. #define Dform_TO d_f1.bit6_10
  69. #define Dform_FRT d_f1.bit6_10
  70. #define Dform_FRS d_f1.bit6_10
  71. #define Dform_BF d_f2.bit6_8
  72. #define Dform_L d_f2.bit10
  73. #define Dform_RA d_f1.bit11_15
  74. #define Dform_D d_f1.bit16_31
  75. #define Dform_SI d_f1.bit16_31
  76. #define Dform_UI d_f2.bit16_31
  77. struct {
  78. ULONG bit30_31 : 2;
  79. LONG bit16_29 : 14;
  80. ULONG bit11_15 : 5;
  81. ULONG bit6_10 : 5;
  82. ULONG bit0_5 : 6;
  83. } ds_f;
  84. #define DSform_RT ds_f.bit6_10
  85. #define DSform_RS ds_f.bit6_10
  86. #define DSform_RA ds_f.bit11_15
  87. #define DSform_DS ds_f.bit16_29
  88. #define DSform_XO ds_f.bit30_31
  89. struct {
  90. ULONG bit31 : 1;
  91. ULONG bit21_30 : 10;
  92. ULONG bit16_20 : 5;
  93. ULONG bit11_15 : 5;
  94. ULONG bit6_10 : 5;
  95. ULONG bit0_5 : 6;
  96. } x_f1;
  97. struct {
  98. ULONG bit20_31 : 12;
  99. ULONG bit16_19 : 4;
  100. ULONG bit14_15 : 2;
  101. ULONG bit11_13 : 3;
  102. ULONG bit10 : 1;
  103. ULONG bit9 : 1;
  104. ULONG bit6_8 : 3;
  105. ULONG bit0_5 : 6;
  106. } x_f2;
  107. struct {
  108. ULONG bit16_31 : 16;
  109. ULONG bit12_15 : 4;
  110. ULONG bit0_11 : 12;
  111. } x_f3;
  112. #define Xform_RT x_f1.bit6_10
  113. #define Xform_RS x_f1.bit6_10
  114. #define Xform_TO x_f1.bit6_10
  115. #define Xform_FRT x_f1.bit6_10
  116. #define Xform_FRS x_f1.bit6_10
  117. #define Xform_BT x_f1.bit6_10
  118. #define Xform_BF x_f2.bit6_8
  119. #define Xform_L x_f2.bit10
  120. #define Xform_RA x_f1.bit11_15
  121. #define Xform_FRA x_f1.bit11_15
  122. #define Xform_BFA x_f2.bit11_13
  123. #define Xform_SR x_f3.bit12_15
  124. #define Xform_RB x_f1.bit16_20
  125. #define Xform_NB x_f1.bit16_20
  126. #define Xform_SH x_f1.bit16_20
  127. #define Xform_FRB x_f1.bit16_20
  128. #define Xform_U x_f2.bit16_19
  129. #define Xform_XO x_f1.bit21_30
  130. #define Xform_RC x_f1.bit31
  131. struct {
  132. ULONG bit31 : 1;
  133. ULONG bit21_30 : 10;
  134. ULONG bit16_20 : 5;
  135. ULONG bit11_15 : 5;
  136. ULONG bit6_10 : 5;
  137. ULONG bit0_5 : 6;
  138. } xl_f1;
  139. struct {
  140. ULONG bit14_31 : 18;
  141. ULONG bit11_13 : 3;
  142. ULONG bit9_10 : 2;
  143. ULONG bit6_8 : 3;
  144. ULONG bit0_5 : 6;
  145. } xl_f2;
  146. #define XLform_LK xl_f1.bit31
  147. #define XLform_XO xl_f1.bit21_30
  148. #define XLform_BB xl_f1.bit16_20
  149. #define XLform_BA xl_f1.bit11_15
  150. #define XLform_BI xl_f1.bit11_15
  151. #define XLform_BFA xl_f2.bit11_13
  152. #define XLform_BT xl_f1.bit6_10
  153. #define XLform_BO xl_f1.bit6_10
  154. #define XLform_BF xl_f2.bit6_8
  155. struct {
  156. ULONG bit31 : 1;
  157. ULONG bit21_30 : 10;
  158. ULONG bit11_20 : 10;
  159. ULONG bit6_10 : 5;
  160. ULONG bit0_5 : 6;
  161. } xfx_f1;
  162. struct {
  163. ULONG bit20_31 : 12;
  164. ULONG bit12_19 : 8;
  165. ULONG bit6_11 : 6;
  166. ULONG bit0_5 : 6;
  167. } xfx_f2;
  168. #define XFXform_RT xfx_f1.bit6_10
  169. #define XFXform_RS xfx_f1.bit6_10
  170. #define XFXform_spr xfx_f1.bit11_20
  171. #define XFXform_tbr xfx_f1.bit11_20
  172. #define XFXform_spr xfx_f1.bit11_20
  173. #define XFXform_FXM xfx_f2.bit12_19
  174. #define XFXform_XO xfx_f1.bit21_30
  175. struct {
  176. ULONG bit31 : 1;
  177. ULONG bit21_30 : 10;
  178. ULONG bit16_20 : 5;
  179. ULONG bit15 : 1;
  180. ULONG bit7_14 : 8;
  181. ULONG bit6 : 1;
  182. ULONG bit0_5 : 6;
  183. } xfl_f;
  184. #define XFLform_FLM xfl_f.bit7_14
  185. #define XFLform_FRB xfl_f.bit16_20
  186. #define XFLform_XO xfl_f.bit21_30
  187. #define XFLform_RC xfl_f.bit31
  188. struct {
  189. ULONG bit31 : 1;
  190. ULONG bit30 : 1;
  191. ULONG bit21_29 : 9;
  192. ULONG bit16_20 : 5;
  193. ULONG bit10_15 : 5;
  194. ULONG bit6_10 : 5;
  195. ULONG bit0_5 : 6;
  196. } xs_f;
  197. #define XSform_RS xs_f.bit6_10
  198. #define XSform_RA xs_f.bit11_15
  199. #define XSform_sh1 xs_f.bit16_20
  200. #define XSform_XO xs_f.bit21_29
  201. #define XSform_sh2 xs_f.bit30
  202. #define XSform_RC xs_f.bit31
  203. struct {
  204. ULONG bit31 : 1;
  205. ULONG bit22_30 : 9;
  206. ULONG bit21 : 1;
  207. ULONG bit16_20 : 5;
  208. ULONG bit10_15 : 5;
  209. ULONG bit6_10 : 5;
  210. ULONG bit0_5 : 6;
  211. } xo_f;
  212. #define XOform_RT xo_f.bit6_10
  213. #define XOform_RA xo_f.bit11_15
  214. #define XOform_RB xo_f.bit16_20
  215. #define XOform_OE xo_f.bit21
  216. #define XOform_XO xo_f.bit22_30
  217. #define XOform_RC xo_f.bit31
  218. struct {
  219. ULONG bit31 : 1;
  220. ULONG bit26_30 : 5;
  221. ULONG bit21_25 : 5;
  222. ULONG bit16_20 : 5;
  223. ULONG bit11_15 : 5;
  224. ULONG bit6_10 : 5;
  225. ULONG bit0_5 : 6;
  226. } a_f;
  227. #define Aform_FRT a_f.bit6_10
  228. #define Aform_FRA a_f.bit11_15
  229. #define Aform_FRB a_f.bit16_20
  230. #define Aform_FRC a_f.bit21_25
  231. #define Aform_XO a_f.bit26_30
  232. #define Aform_RC a_f.bit31
  233. struct {
  234. ULONG bit31 : 1;
  235. ULONG bit26_30 : 5;
  236. ULONG bit21_25 : 5;
  237. ULONG bit16_20 : 5;
  238. ULONG bit11_15 : 5;
  239. ULONG bit6_10 : 5;
  240. ULONG bit0_5 : 6;
  241. } m_f;
  242. #define Mform_RS m_f.bit6_10
  243. #define Mform_RA m_f.bit11_15
  244. #define Mform_RB m_f.bit16_20
  245. #define Mform_SH m_f.bit16_20
  246. #define Mform_MB m_f.bit21_25
  247. #define Mform_ME m_f.bit26_30
  248. #define Mform_RC m_f.bit31
  249. struct {
  250. ULONG bit31 : 1;
  251. ULONG bit30 : 1;
  252. ULONG bit27_29 : 3;
  253. ULONG bit21_26 : 6;
  254. ULONG bit16_20 : 5;
  255. ULONG bit11_15 : 5;
  256. ULONG bit6_10 : 5;
  257. ULONG bit0_5 : 6;
  258. } md_f;
  259. #define MDform_RS md_f.bit6_10
  260. #define MDform_RA md_f.bit11_15
  261. #define MDform_sh1 md_f.bit16_20
  262. #define MDform_mb md_f.bit21_26
  263. #define MDform_me md_f.bit21_26
  264. #define MDform_XO md_f.bit27_29
  265. #define MDform_sh2 md_f.bit30
  266. #define MDform_RC md_f.bit31
  267. struct {
  268. ULONG bit31 : 1;
  269. ULONG bit27_30 : 4;
  270. ULONG bit21_26 : 6;
  271. ULONG bit16_20 : 5;
  272. ULONG bit11_15 : 5;
  273. ULONG bit6_10 : 5;
  274. ULONG bit0_5 : 6;
  275. } mds_f;
  276. #define MDSform_RS mds_f.bit6_10
  277. #define MDSform_RA mds_f.bit11_15
  278. #define MDSform_RB mds_f.bit16_20
  279. #define MDSform_mb mds_f.bit21_26
  280. #define MDSform_me mds_f.bit21_26
  281. #define MDSform_XO mds_f.bit27_30
  282. #define MDSform_RC mds_f.bit31
  283. } PPC_INSTRUCTION, *PPPC_INSTRUCTION;
  284. //
  285. // POWERPC PRIMARY AND SECONDARY (EXTENDED) OPCODES
  286. //
  287. #define TDI_OP 2
  288. #define TWI_OP 3
  289. #define MULLI_OP 7
  290. #define SUBFIC_OP 8
  291. #define CMPLI_OP 10
  292. #define CMPI_OP 11
  293. #define ADDIC_OP 12
  294. #define ADDIC_RC_OP 13
  295. #define ADDI_OP 14
  296. #define ADDIS_OP 15
  297. #define BC_OP 16
  298. #define SC_OP 17
  299. #define B_OP 18
  300. #define X19_OP 19 // Extended ops for primary code 19:
  301. #define MCRF_OP 0
  302. #define BCLR_OP 16
  303. #define CRNOR_OP 33
  304. #define RFI_OP 50
  305. #define CRANDC_OP 129
  306. #define ISYNC_OP 150
  307. #define CRXOR_OP 193
  308. #define CRNAND_OP 225
  309. #define CRAND_OP 257
  310. #define CREQV_OP 289
  311. #define CRORC_OP 417
  312. #define CROR_OP 449
  313. #define BCCTR_OP 528
  314. #define RLWIMI_OP 20
  315. #define RLWINM_OP 21
  316. #define RLWNM_OP 23
  317. #define ORI_OP 24
  318. #define ORIS_OP 25
  319. #define XORI_OP 26
  320. #define XORIS_OP 27
  321. #define ANDI_RC_OP 28
  322. #define ANDIS_RC_OP 29
  323. #define X30_OP 30 // Extended ops for primary code 30:
  324. #define RLDICL_OP 0
  325. #define RLDICR_OP 1
  326. #define RLDIC_OP 2
  327. #define RLDIMI_OP 3
  328. #define RLDCL_OP 8
  329. #define RLDCR_OP 9
  330. #define X31_OP 31 // Extended ops for primary code 31:
  331. #define CMP_OP 0
  332. #define TW_OP 4
  333. #define SUBFC_OP 8
  334. #define MULHDU_OP 9
  335. #define ADDC_OP 10
  336. #define MULHWU_OP 11
  337. #define MFCR_OP 19
  338. #define LWARX_OP 20
  339. #define LDX_OP 21
  340. #define LWZX_OP 23
  341. #define SLW_OP 24
  342. #define CNTLZW_OP 26
  343. #define SLD_OP 27
  344. #define AND_OP 28
  345. #define CMPL_OP 32
  346. #define SUBF_OP 40
  347. #define LDUX_OP 53
  348. #define DCBST_OP 54
  349. #define LWZUX_OP 55
  350. #define CNTLZD_OP 58
  351. #define ANDC_OP 60
  352. #define TD_OP 68
  353. #define MULHD_OP 73
  354. #define MULHW_OP 75
  355. #define MFMSR_OP 83
  356. #define LDARX_OP 84
  357. #define DCBF_OP 86
  358. #define LBZX_OP 87
  359. #define NEG_OP 104
  360. #define LBZUX_OP 119
  361. #define NOR_OP 124
  362. #define SUBFE_OP 136
  363. #define ADDE_OP 138
  364. #define MTCRF_OP 144
  365. #define MTMSR_OP 146
  366. #define STDX_OP 149
  367. #define STWCX_RC_OP 150
  368. #define STWX_OP 151
  369. #define STDUX_OP 181
  370. #define STWUX_OP 183
  371. #define SUBFZE_OP 200
  372. #define ADDZE_OP 202
  373. #define MTSR_OP 210
  374. #define STDCX_RC_OP 214
  375. #define STBX_OP 215
  376. #define SUBFME_OP 232
  377. #define MULLD_OP 233
  378. #define ADDME_OP 234
  379. #define MULLW_OP 235
  380. #define MTSRIN_OP 242
  381. #define DCBTST_OP 246
  382. #define STBUX_OP 247
  383. #define ADD_OP 266
  384. #define DCBT_OP 278
  385. #define LHZX_OP 279
  386. #define EQV_OP 284
  387. #define TLBIE_OP 306
  388. #define ECIWX_OP 310
  389. #define LHZUX_OP 311
  390. #define XOR_OP 316
  391. #define MFSPR_OP 339
  392. #define LWAX_OP 341
  393. #define LHAX_OP 343
  394. #define TLBIA_OP 370
  395. #define MFTB_OP 371
  396. #define LWAUX_OP 373
  397. #define LHAUX_OP 375
  398. #define STHX_OP 407
  399. #define ORC_OP 412
  400. #define SRADI_OP 413
  401. #define SLBIE_OP 434
  402. #define ECOWX_OP 438
  403. #define STHUX_OP 439
  404. #define OR_OP 444
  405. #define DIVDU_OP 457
  406. #define DIVWU_OP 459
  407. #define MTSPR_OP 467
  408. #define DCBI_OP 470
  409. #define NAND_OP 476
  410. #define DIVD_OP 489
  411. #define DIVW_OP 491
  412. #define SLBIA_OP 498
  413. #define MCRXR_OP 512
  414. #define LSWX_OP 533
  415. #define LWBRX_OP 534
  416. #define LFSX_OP 535
  417. #define SRW_OP 536
  418. #define SRD_OP 539
  419. #define TLBSYNC_OP 566
  420. #define LFSUX_OP 567
  421. #define MFSR_OP 595
  422. #define LSWI_OP 597
  423. #define SYNC_OP 598
  424. #define LFDX_OP 599
  425. #define LFDUX_OP 631
  426. #define MFSRIN_OP 659
  427. #define STSWX_OP 661
  428. #define STWBRX_OP 662
  429. #define STFSX_OP 663
  430. #define STFSUX_OP 695
  431. #define STSWI_OP 725
  432. #define STFDX_OP 727
  433. #define STFDUX_OP 759
  434. #define LHBRX_OP 790
  435. #define SRAW_OP 792
  436. #define SRAD_OP 794
  437. #define SRAWI_OP 824
  438. #define EIEIO_OP 854
  439. #define STHBRX_OP 918
  440. #define EXTSH_OP 922
  441. #define EXTSB_OP 954
  442. #define ICBI_OP 982
  443. #define STFIWX_OP 983
  444. #define EXTSW_OP 986
  445. #define DCBZ_OP 1014
  446. #define LWZ_OP 32
  447. #define LWZU_OP 33
  448. #define LBZ_OP 34
  449. #define LBZU_OP 35
  450. #define STW_OP 36
  451. #define STWU_OP 37
  452. #define STB_OP 38
  453. #define STBU_OP 39
  454. #define LHZ_OP 40
  455. #define LHZU_OP 41
  456. #define LHA_OP 42
  457. #define LHAU_OP 43
  458. #define STH_OP 44
  459. #define STHU_OP 45
  460. #define LFS_OP 48
  461. #define LFSU_OP 49
  462. #define LFD_OP 50
  463. #define LFDU_OP 51
  464. #define STFS_OP 52
  465. #define STFSU_OP 53
  466. #define STFD_OP 54
  467. #define STFDU_OP 55
  468. #define X58_OP 58 // Extended ops for primary code 58:
  469. #define LD_OP 0
  470. #define LDU_OP 1
  471. #define LWA_OP 2
  472. #define X59_OP 59 // Extended ops for primary code 59:
  473. #define FDIVS_OP 18
  474. #define FSUBS_OP 20
  475. #define FADDS_OP 21
  476. #define FSQRTS_OP 22
  477. #define FRES_OP 24
  478. #define FMULS_OP 25
  479. #define FMSUBS_OP 28
  480. #define FMADDS_OP 29
  481. #define FNMSUBS_OP 30
  482. #define FNMADDS_OP 31
  483. #define X62_OP 62 // Extended ops for primary code 62:
  484. #define STD_OP 0
  485. #define STDU_OP 1
  486. #define X63_OP 63 // Extended ops for primary code 63:
  487. #define FCMPU_OP 0
  488. #define FRSP_OP 12
  489. #define FCTIW_OP 14
  490. #define FCTIWZ_OP 15
  491. #define FDIV_OP 18
  492. #define FSUB_OP 20
  493. #define FADD_OP 21
  494. #define FSQRT_OP 22
  495. #define FSEL_OP 23
  496. #define FMUL_OP 25
  497. #define FSQRTE_OP 26
  498. #define FMSUB_OP 28
  499. #define FMADD_OP 29
  500. #define FNMSUB_OP 30
  501. #define FNMADD_OP 31
  502. #define FCMPO_OP 32
  503. #define MTFSB1_OP 38
  504. #define FNEG_OP 40
  505. #define MCRFS_OP 64
  506. #define MTFSB0_OP 70
  507. #define FMR_OP 72
  508. #define MTFSFI_OP 134
  509. #define FNABS_OP 136
  510. #define FABS_OP 264
  511. #define MFFS_OP 583
  512. #define MTFSF_OP 711
  513. #define FCTID_OP 814
  514. #define FCTIDZ_OP 815
  515. #define FCFID_OP 846
  516. //
  517. // Define certain specific instructions
  518. //
  519. #define SYSTEM_CALL_INSTR 0x44000002L // sc
  520. #define RETURN_INSTR 0x4E800020L // blr
  521. #define BREAK_INSTR 0x0FE00000L // break <number>
  522. #define TRAP_INSTR 0x0C000000L // trap word immediate
  523. #define NO_OP_INSTR 0x60000000L // ori r.0, r.0, 0
  524. #define INVALID_INSTR 0x00000000L // all 0's => invalid
  525. //
  526. // Define specific values for the TO field of the TRAP_INSTR
  527. //
  528. #define TO_BREAKPOINT 0x03E00000L // Unconditional breakpoint
  529. #define TO_DIVIDE_BY_ZERO 0x00C00000L // Integer divide by zero
  530. #define TO_UNCONDITIONAL_DIVIDE_BY_ZERO 0x00E00000L // Unconditional divide
  531. // by zero
  532. //
  533. // IEEE FLOATING POINT VALUE REPRESENTATION
  534. //
  535. //
  536. // Define maximum and minimum single and double exponent values.
  537. //
  538. #define DOUBLE_MAXIMUM_EXPONENT 2047
  539. #define DOUBLE_MINIMUM_EXPONENT 0
  540. #define SINGLE_MAXIMUM_EXPONENT 255
  541. #define SINGLE_MINIMUM_EXPONENT 0
  542. //
  543. // Define single and double exponent bias values.
  544. //
  545. #define SINGLE_EXPONENT_BIAS 127
  546. #define DOUBLE_EXPONENT_BIAS 1023
  547. //
  548. // Define the largest single and double values;
  549. //
  550. #define DOUBLE_MAXIMUM_VALUE_LOW 0xffffffff
  551. #define DOUBLE_MAXIMUM_VALUE_HIGH 0x7fefffff
  552. #define SINGLE_MAXIMUM_VALUE 0x7f7fffff
  553. //
  554. // Define single and double quite and signaling Nan values.
  555. //
  556. #define DOUBLE_NAN_LOW 0xffffffff
  557. #define DOUBLE_QUIET_NAN 0x7ff7ffff
  558. #define DOUBLE_SIGNAL_NAN 0x7fffffff
  559. #define SINGLE_QUIET_NAN 0x7fbfffff
  560. #define SINGLE_SIGNAL_NAN 0x7fffffff
  561. //
  562. // Define positive single and double infinity values.
  563. //
  564. #define DOUBLE_INFINITY_VALUE_LOW 0x0
  565. #define DOUBLE_INFINITY_VALUE_HIGH 0x7ff00000
  566. #define SINGLE_INFINITY_VALUE 0x7f800000
  567. //
  568. // Define rounding modes.
  569. //
  570. #define ROUND_TO_NEAREST 0
  571. #define ROUND_TO_ZERO 1
  572. #define ROUND_TO_PLUS_INFINITY 2
  573. #define ROUND_TO_MINUS_INFINITY 3
  574. #endif // _PPCINST_