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_len(struct ppc_inst x) 21 { 22 return sizeof(struct ppc_inst); 23 } 24 25 static inline int ppc_inst_primary_opcode(struct ppc_inst x) 26 { 27 return ppc_inst_val(x) >> 26; 28 } 29 30 static inline struct ppc_inst ppc_inst_swab(struct ppc_inst x) 31 { 32 return ppc_inst(swab32(ppc_inst_val(x))); 33 } 34 35 static inline struct ppc_inst ppc_inst_read(const struct ppc_inst *ptr) 36 { 37 return *ptr; 38 } 39 40 static inline bool ppc_inst_equal(struct ppc_inst x, struct ppc_inst y) 41 { 42 return ppc_inst_val(x) == ppc_inst_val(y); 43 } 44 45 int probe_user_read_inst(struct ppc_inst *inst, 46 struct ppc_inst __user *nip); 47 48 int probe_kernel_read_inst(struct ppc_inst *inst, 49 struct ppc_inst *src); 50 51 #endif /* _ASM_POWERPC_INST_H */ 52