1
2
3
4
5
6 struct pt_regs;
7
8
9
10
11
12
13
14
15
16
17
18 #define IS_MTMSRD(instr) (((instr) & 0xfc0007be) == 0x7c000124)
19 #define IS_RFID(instr) (((instr) & 0xfc0007fe) == 0x4c000024)
20 #define IS_RFI(instr) (((instr) & 0xfc0007fe) == 0x4c000064)
21
22 enum instruction_type {
23 COMPUTE,
24 LOAD,
25 LOAD_MULTI,
26 LOAD_FP,
27 LOAD_VMX,
28 LOAD_VSX,
29 STORE,
30 STORE_MULTI,
31 STORE_FP,
32 STORE_VMX,
33 STORE_VSX,
34 LARX,
35 STCX,
36 BRANCH,
37 MFSPR,
38 MTSPR,
39 CACHEOP,
40 BARRIER,
41 SYSCALL,
42 MFMSR,
43 MTMSR,
44 RFI,
45 INTERRUPT,
46 UNKNOWN
47 };
48
49 #define INSTR_TYPE_MASK 0x1f
50
51 #define OP_IS_LOAD_STORE(type) (LOAD <= (type) && (type) <= STCX)
52
53
54 #define SETREG 0x20
55 #define SETCC 0x40
56 #define SETXER 0x80
57
58
59 #define SETLK 0x20
60 #define BRTAKEN 0x40
61 #define DECCTR 0x80
62
63
64 #define SIGNEXT 0x20
65 #define UPDATE 0x40
66 #define BYTEREV 0x80
67 #define FPCONV 0x100
68
69
70 #define BARRIER_MASK 0xe0
71 #define BARRIER_SYNC 0x00
72 #define BARRIER_ISYNC 0x20
73 #define BARRIER_EIEIO 0x40
74 #define BARRIER_LWSYNC 0x60
75 #define BARRIER_PTESYNC 0x80
76
77
78 #define CACHEOP_MASK 0x700
79 #define DCBST 0
80 #define DCBF 0x100
81 #define DCBTST 0x200
82 #define DCBT 0x300
83 #define ICBI 0x400
84 #define DCBZ 0x500
85
86
87 #define VSX_FPCONV 1
88 #define VSX_SPLAT 2
89 #define VSX_LDLEFT 4
90 #define VSX_CHECK_VEC 8
91
92
93 #define SIZE(n) ((n) << 12)
94 #define GETSIZE(w) ((w) >> 12)
95
96 #define GETTYPE(t) ((t) & INSTR_TYPE_MASK)
97
98 #define MKOP(t, f, s) ((t) | (f) | SIZE(s))
99
100 struct instruction_op {
101 int type;
102 int reg;
103 unsigned long val;
104
105 unsigned long ea;
106 int update_reg;
107
108 int spr;
109 u32 ccval;
110 u32 xerval;
111 u8 element_size;
112 u8 vsx_flags;
113 };
114
115 union vsx_reg {
116 u8 b[16];
117 u16 h[8];
118 u32 w[4];
119 unsigned long d[2];
120 float fp[4];
121 double dp[2];
122 __vector128 v;
123 };
124
125
126
127
128
129
130
131
132
133
134 extern int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
135 unsigned int instr);
136
137
138
139
140
141 void emulate_update_regs(struct pt_regs *reg, struct instruction_op *op);
142
143
144
145
146
147
148
149
150
151
152 extern int emulate_step(struct pt_regs *regs, unsigned int instr);
153
154
155
156
157
158
159
160
161 extern int emulate_loadstore(struct pt_regs *regs, struct instruction_op *op);
162
163 extern void emulate_vsx_load(struct instruction_op *op, union vsx_reg *reg,
164 const void *mem, bool cross_endian);
165 extern void emulate_vsx_store(struct instruction_op *op,
166 const union vsx_reg *reg, void *mem,
167 bool cross_endian);
168 extern int emulate_dcbz(unsigned long ea, struct pt_regs *regs);