xref: /openbmc/linux/arch/powerpc/include/asm/inst.h (revision 95b980a0)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #ifndef _ASM_POWERPC_INST_H
3 #define _ASM_POWERPC_INST_H
4 
5 /*
6  * Instruction data type for POWER
7  */
8 
9 struct ppc_inst {
10 	u32 val;
11 } __packed;
12 
13 #define ppc_inst(x) ((struct ppc_inst){ .val = x })
14 
15 static inline u32 ppc_inst_val(struct ppc_inst x)
16 {
17 	return x.val;
18 }
19 
20 static inline int ppc_inst_primary_opcode(struct ppc_inst x)
21 {
22 	return ppc_inst_val(x) >> 26;
23 }
24 
25 static inline struct ppc_inst ppc_inst_swab(struct ppc_inst x)
26 {
27 	return ppc_inst(swab32(ppc_inst_val(x)));
28 }
29 
30 static inline struct ppc_inst ppc_inst_read(const struct ppc_inst *ptr)
31 {
32 	return *ptr;
33 }
34 
35 static inline bool ppc_inst_equal(struct ppc_inst x, struct ppc_inst y)
36 {
37 	return ppc_inst_val(x) == ppc_inst_val(y);
38 }
39 
40 int probe_user_read_inst(struct ppc_inst *inst,
41 			 struct ppc_inst __user *nip);
42 
43 int probe_kernel_read_inst(struct ppc_inst *inst,
44 			   struct ppc_inst *src);
45 
46 #endif /* _ASM_POWERPC_INST_H */
47