0001
0002
0003
0004
0005 #include <asm/inst.h>
0006
0007 struct pt_regs;
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #define IS_MTMSRD(instr) ((ppc_inst_val(instr) & 0xfc0007be) == 0x7c000124)
0020 #define IS_RFID(instr) ((ppc_inst_val(instr) & 0xfc0007be) == 0x4c000024)
0021
0022 enum instruction_type {
0023 COMPUTE,
0024 LOAD,
0025 LOAD_MULTI,
0026 LOAD_FP,
0027 LOAD_VMX,
0028 LOAD_VSX,
0029 STORE,
0030 STORE_MULTI,
0031 STORE_FP,
0032 STORE_VMX,
0033 STORE_VSX,
0034 LARX,
0035 STCX,
0036 BRANCH,
0037 MFSPR,
0038 MTSPR,
0039 CACHEOP,
0040 BARRIER,
0041 SYSCALL,
0042 SYSCALL_VECTORED_0,
0043 MFMSR,
0044 MTMSR,
0045 RFI,
0046 INTERRUPT,
0047 UNKNOWN
0048 };
0049
0050 #define INSTR_TYPE_MASK 0x1f
0051
0052 #define OP_IS_LOAD(type) ((LOAD <= (type) && (type) <= LOAD_VSX) || (type) == LARX)
0053 #define OP_IS_STORE(type) ((STORE <= (type) && (type) <= STORE_VSX) || (type) == STCX)
0054 #define OP_IS_LOAD_STORE(type) (LOAD <= (type) && (type) <= STCX)
0055
0056
0057 #define SETREG 0x20
0058 #define SETCC 0x40
0059 #define SETXER 0x80
0060
0061
0062 #define SETLK 0x20
0063 #define BRTAKEN 0x40
0064 #define DECCTR 0x80
0065
0066
0067 #define SIGNEXT 0x20
0068 #define UPDATE 0x40
0069 #define BYTEREV 0x80
0070 #define FPCONV 0x100
0071
0072
0073 #define BARRIER_MASK 0xe0
0074 #define BARRIER_SYNC 0x00
0075 #define BARRIER_ISYNC 0x20
0076 #define BARRIER_EIEIO 0x40
0077 #define BARRIER_LWSYNC 0x60
0078 #define BARRIER_PTESYNC 0x80
0079
0080
0081 #define CACHEOP_MASK 0x700
0082 #define DCBST 0
0083 #define DCBF 0x100
0084 #define DCBTST 0x200
0085 #define DCBT 0x300
0086 #define ICBI 0x400
0087 #define DCBZ 0x500
0088
0089
0090 #define VSX_FPCONV 1
0091 #define VSX_SPLAT 2
0092 #define VSX_LDLEFT 4
0093 #define VSX_CHECK_VEC 8
0094
0095
0096 #define PREFIXED 0x800
0097
0098
0099 #define SIZE(n) ((n) << 12)
0100 #define GETSIZE(w) ((w) >> 12)
0101
0102 #define GETTYPE(t) ((t) & INSTR_TYPE_MASK)
0103 #define GETLENGTH(t) (((t) & PREFIXED) ? 8 : 4)
0104
0105 #define MKOP(t, f, s) ((t) | (f) | SIZE(s))
0106
0107
0108 #define GET_PREFIX_RA(i) (((i) >> 16) & 0x1f)
0109 #define GET_PREFIX_R(i) ((i) & (1ul << 20))
0110
0111 extern s32 patch__exec_instr;
0112
0113 struct instruction_op {
0114 int type;
0115 int reg;
0116 unsigned long val;
0117
0118 unsigned long ea;
0119 int update_reg;
0120
0121 int spr;
0122 u32 ccval;
0123 u32 xerval;
0124 u8 element_size;
0125 u8 vsx_flags;
0126 };
0127
0128 union vsx_reg {
0129 u8 b[16];
0130 u16 h[8];
0131 u32 w[4];
0132 unsigned long d[2];
0133 float fp[4];
0134 double dp[2];
0135 __vector128 v;
0136 };
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147 extern int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
0148 ppc_inst_t instr);
0149
0150
0151
0152
0153
0154 void emulate_update_regs(struct pt_regs *reg, struct instruction_op *op);
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165 int emulate_step(struct pt_regs *regs, ppc_inst_t instr);
0166
0167
0168
0169
0170
0171
0172
0173
0174 extern int emulate_loadstore(struct pt_regs *regs, struct instruction_op *op);
0175
0176 extern void emulate_vsx_load(struct instruction_op *op, union vsx_reg *reg,
0177 const void *mem, bool cross_endian);
0178 extern void emulate_vsx_store(struct instruction_op *op,
0179 const union vsx_reg *reg, void *mem,
0180 bool cross_endian);
0181 extern int emulate_dcbz(unsigned long ea, struct pt_regs *regs);