disassemble.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * This program is free software; you can redistribute it and/or modify
  3. * it under the terms of the GNU General Public License, version 2, as
  4. * published by the Free Software Foundation.
  5. *
  6. * This program is distributed in the hope that it will be useful,
  7. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. * GNU General Public License for more details.
  10. *
  11. * You should have received a copy of the GNU General Public License
  12. * along with this program; if not, write to the Free Software
  13. * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  14. *
  15. * Copyright IBM Corp. 2008
  16. *
  17. * Authors: Hollis Blanchard <hollisb@us.ibm.com>
  18. */
  19. #ifndef __ASM_PPC_DISASSEMBLE_H__
  20. #define __ASM_PPC_DISASSEMBLE_H__
  21. #include <linux/types.h>
  22. static inline unsigned int get_op(u32 inst)
  23. {
  24. return inst >> 26;
  25. }
  26. static inline unsigned int get_xop(u32 inst)
  27. {
  28. return (inst >> 1) & 0x3ff;
  29. }
  30. static inline unsigned int get_sprn(u32 inst)
  31. {
  32. return ((inst >> 16) & 0x1f) | ((inst >> 6) & 0x3e0);
  33. }
  34. static inline unsigned int get_dcrn(u32 inst)
  35. {
  36. return ((inst >> 16) & 0x1f) | ((inst >> 6) & 0x3e0);
  37. }
  38. static inline unsigned int get_tmrn(u32 inst)
  39. {
  40. return ((inst >> 16) & 0x1f) | ((inst >> 6) & 0x3e0);
  41. }
  42. static inline unsigned int get_rt(u32 inst)
  43. {
  44. return (inst >> 21) & 0x1f;
  45. }
  46. static inline unsigned int get_rs(u32 inst)
  47. {
  48. return (inst >> 21) & 0x1f;
  49. }
  50. static inline unsigned int get_ra(u32 inst)
  51. {
  52. return (inst >> 16) & 0x1f;
  53. }
  54. static inline unsigned int get_rb(u32 inst)
  55. {
  56. return (inst >> 11) & 0x1f;
  57. }
  58. static inline unsigned int get_rc(u32 inst)
  59. {
  60. return inst & 0x1;
  61. }
  62. static inline unsigned int get_ws(u32 inst)
  63. {
  64. return (inst >> 11) & 0x1f;
  65. }
  66. static inline unsigned int get_d(u32 inst)
  67. {
  68. return inst & 0xffff;
  69. }
  70. static inline unsigned int get_oc(u32 inst)
  71. {
  72. return (inst >> 11) & 0x7fff;
  73. }
  74. #define IS_XFORM(inst) (get_op(inst) == 31)
  75. #define IS_DSFORM(inst) (get_op(inst) >= 56)
  76. /*
  77. * Create a DSISR value from the instruction
  78. */
  79. static inline unsigned make_dsisr(unsigned instr)
  80. {
  81. unsigned dsisr;
  82. /* bits 6:15 --> 22:31 */
  83. dsisr = (instr & 0x03ff0000) >> 16;
  84. if (IS_XFORM(instr)) {
  85. /* bits 29:30 --> 15:16 */
  86. dsisr |= (instr & 0x00000006) << 14;
  87. /* bit 25 --> 17 */
  88. dsisr |= (instr & 0x00000040) << 8;
  89. /* bits 21:24 --> 18:21 */
  90. dsisr |= (instr & 0x00000780) << 3;
  91. } else {
  92. /* bit 5 --> 17 */
  93. dsisr |= (instr & 0x04000000) >> 12;
  94. /* bits 1: 4 --> 18:21 */
  95. dsisr |= (instr & 0x78000000) >> 17;
  96. /* bits 30:31 --> 12:13 */
  97. if (IS_DSFORM(instr))
  98. dsisr |= (instr & 0x00000003) << 18;
  99. }
  100. return dsisr;
  101. }
  102. #endif /* __ASM_PPC_DISASSEMBLE_H__ */