disassemble.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. *
  4. * Copyright IBM Corp. 2008
  5. *
  6. * Authors: Hollis Blanchard <[email protected]>
  7. */
  8. #ifndef __ASM_PPC_DISASSEMBLE_H__
  9. #define __ASM_PPC_DISASSEMBLE_H__
  10. #include <linux/types.h>
  11. static inline unsigned int get_op(u32 inst)
  12. {
  13. return inst >> 26;
  14. }
  15. static inline unsigned int get_xop(u32 inst)
  16. {
  17. return (inst >> 1) & 0x3ff;
  18. }
  19. static inline unsigned int get_sprn(u32 inst)
  20. {
  21. return ((inst >> 16) & 0x1f) | ((inst >> 6) & 0x3e0);
  22. }
  23. static inline unsigned int get_dcrn(u32 inst)
  24. {
  25. return ((inst >> 16) & 0x1f) | ((inst >> 6) & 0x3e0);
  26. }
  27. static inline unsigned int get_tmrn(u32 inst)
  28. {
  29. return ((inst >> 16) & 0x1f) | ((inst >> 6) & 0x3e0);
  30. }
  31. static inline unsigned int get_rt(u32 inst)
  32. {
  33. return (inst >> 21) & 0x1f;
  34. }
  35. static inline unsigned int get_rs(u32 inst)
  36. {
  37. return (inst >> 21) & 0x1f;
  38. }
  39. static inline unsigned int get_ra(u32 inst)
  40. {
  41. return (inst >> 16) & 0x1f;
  42. }
  43. static inline unsigned int get_rb(u32 inst)
  44. {
  45. return (inst >> 11) & 0x1f;
  46. }
  47. static inline unsigned int get_rc(u32 inst)
  48. {
  49. return inst & 0x1;
  50. }
  51. static inline unsigned int get_ws(u32 inst)
  52. {
  53. return (inst >> 11) & 0x1f;
  54. }
  55. static inline unsigned int get_d(u32 inst)
  56. {
  57. return inst & 0xffff;
  58. }
  59. static inline unsigned int get_oc(u32 inst)
  60. {
  61. return (inst >> 11) & 0x7fff;
  62. }
  63. static inline unsigned int get_tx_or_sx(u32 inst)
  64. {
  65. return (inst) & 0x1;
  66. }
  67. #define IS_XFORM(inst) (get_op(inst) == 31)
  68. #define IS_DSFORM(inst) (get_op(inst) >= 56)
  69. /*
  70. * Create a DSISR value from the instruction
  71. */
  72. static inline unsigned make_dsisr(unsigned instr)
  73. {
  74. unsigned dsisr;
  75. /* bits 6:15 --> 22:31 */
  76. dsisr = (instr & 0x03ff0000) >> 16;
  77. if (IS_XFORM(instr)) {
  78. /* bits 29:30 --> 15:16 */
  79. dsisr |= (instr & 0x00000006) << 14;
  80. /* bit 25 --> 17 */
  81. dsisr |= (instr & 0x00000040) << 8;
  82. /* bits 21:24 --> 18:21 */
  83. dsisr |= (instr & 0x00000780) << 3;
  84. } else {
  85. /* bit 5 --> 17 */
  86. dsisr |= (instr & 0x04000000) >> 12;
  87. /* bits 1: 4 --> 18:21 */
  88. dsisr |= (instr & 0x78000000) >> 17;
  89. /* bits 30:31 --> 12:13 */
  90. if (IS_DSFORM(instr))
  91. dsisr |= (instr & 0x00000003) << 18;
  92. }
  93. return dsisr;
  94. }
  95. #endif /* __ASM_PPC_DISASSEMBLE_H__ */