1 /* SPDX-License-Identifier: GPL-2.0-only */
4 * Copyright IBM Corp. 2008
6 * Authors: Hollis Blanchard <hollisb@us.ibm.com>
9 #ifndef __ASM_PPC_DISASSEMBLE_H__
10 #define __ASM_PPC_DISASSEMBLE_H__
12 #include <linux/types.h>
14 static inline unsigned int get_op(u32 inst)
19 static inline unsigned int get_xop(u32 inst)
21 return (inst >> 1) & 0x3ff;
24 static inline unsigned int get_sprn(u32 inst)
26 return ((inst >> 16) & 0x1f) | ((inst >> 6) & 0x3e0);
29 static inline unsigned int get_dcrn(u32 inst)
31 return ((inst >> 16) & 0x1f) | ((inst >> 6) & 0x3e0);
34 static inline unsigned int get_tmrn(u32 inst)
36 return ((inst >> 16) & 0x1f) | ((inst >> 6) & 0x3e0);
39 static inline unsigned int get_rt(u32 inst)
41 return (inst >> 21) & 0x1f;
44 static inline unsigned int get_rs(u32 inst)
46 return (inst >> 21) & 0x1f;
49 static inline unsigned int get_ra(u32 inst)
51 return (inst >> 16) & 0x1f;
54 static inline unsigned int get_rb(u32 inst)
56 return (inst >> 11) & 0x1f;
59 static inline unsigned int get_rc(u32 inst)
64 static inline unsigned int get_ws(u32 inst)
66 return (inst >> 11) & 0x1f;
69 static inline unsigned int get_d(u32 inst)
74 static inline unsigned int get_oc(u32 inst)
76 return (inst >> 11) & 0x7fff;
79 static inline unsigned int get_tx_or_sx(u32 inst)
84 #define IS_XFORM(inst) (get_op(inst) == 31)
85 #define IS_DSFORM(inst) (get_op(inst) >= 56)
88 * Create a DSISR value from the instruction
90 static inline unsigned make_dsisr(unsigned instr)
95 /* bits 6:15 --> 22:31 */
96 dsisr = (instr & 0x03ff0000) >> 16;
98 if (IS_XFORM(instr)) {
99 /* bits 29:30 --> 15:16 */
100 dsisr |= (instr & 0x00000006) << 14;
102 dsisr |= (instr & 0x00000040) << 8;
103 /* bits 21:24 --> 18:21 */
104 dsisr |= (instr & 0x00000780) << 3;
107 dsisr |= (instr & 0x04000000) >> 12;
108 /* bits 1: 4 --> 18:21 */
109 dsisr |= (instr & 0x78000000) >> 17;
110 /* bits 30:31 --> 12:13 */
111 if (IS_DSFORM(instr))
112 dsisr |= (instr & 0x00000003) << 18;
117 #endif /* __ASM_PPC_DISASSEMBLE_H__ */