The Pedigree Project  0.1
kernel/core/processor/ppc_common/Disassembler.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef PPC_DISASSEMBLER_H
21 #define PPC_DISASSEMBLER_H
22 
23 #include "pedigree/kernel/processor/Disassembler.h"
24 
30 {
31  public:
33  ~PPCDisassembler();
34 
38  void setLocation(uintptr_t nLocation);
39 
43  uintptr_t getLocation();
44 
51  void setMode(size_t nMode);
52 
57  void disassemble(LargeStaticString &text);
58 
59  public:
63  uintptr_t m_nLocation;
64 
67  {
68  uint32_t opcode : 6;
69  uint32_t li : 24;
70  uint32_t aa : 1;
71  uint32_t lk : 1;
72  };
74  {
75  uint32_t opcode : 6;
76  uint32_t bo : 5;
77  uint32_t bi : 5;
78  uint32_t bd : 14;
79  uint32_t aa : 1;
80  uint32_t lk : 1;
81  };
83  {
84  uint32_t opcode : 6;
85  uint32_t zero : 22;
86  uint32_t one : 1;
87  uint32_t zero2 : 1;
88  };
90  {
91  uint32_t opcode : 6;
92  uint32_t d : 5;
93  uint32_t a : 5;
94  uint32_t imm : 16;
95  };
97  {
98  uint32_t opcode : 6;
99  uint32_t d : 5;
100  uint32_t a : 5;
101  uint32_t ds : 14;
102  uint32_t xo : 2;
103  };
105  {
106  uint32_t opcode : 6;
107  uint32_t d : 5;
108  uint32_t s : 5;
109  uint32_t b : 5;
110  uint32_t xo : 10;
111  uint32_t rc : 1;
112  };
114  {
115  uint32_t opcode : 6;
116  uint32_t bo : 5;
117  uint32_t bi : 5;
118  uint32_t crbB : 5;
119  uint32_t xo : 10;
120  uint32_t lk : 1;
121  };
123  {
124  uint32_t opcode : 6;
125  uint32_t d : 5;
126  uint32_t spr : 10;
127  uint32_t xo : 10;
128  uint32_t zero : 1;
129  };
131  {
132  uint32_t opcode : 6;
133  uint32_t d : 5;
134  uint32_t a : 5;
135  uint32_t b : 5;
136  uint32_t oe : 1;
137  uint32_t xo : 9;
138  uint32_t rc : 1;
139  };
141  {
142  uint32_t opcode : 6;
143  uint32_t s : 5;
144  uint32_t a : 5;
145  uint32_t sh : 5;
146  uint32_t mb : 5;
147  uint32_t me : 5;
148  uint32_t rc : 1;
149  };
150 
153  {
161  InstructionFormXFX xfx;
164  uint32_t integer;
165  };
166 
168  void twi(Instruction insn, LargeStaticString &text);
169  void mulli(Instruction insn, LargeStaticString &text);
170  void subfic(Instruction insn, LargeStaticString &text);
171  void cmpli(Instruction insn, LargeStaticString &text);
172  void cmpi(Instruction insn, LargeStaticString &text);
173  void addic(Instruction insn, LargeStaticString &text);
174  void addic_dot(Instruction insn, LargeStaticString &text);
175  void addi(Instruction insn, LargeStaticString &text);
176  void addis(Instruction insn, LargeStaticString &text);
177  void bc(Instruction insn, LargeStaticString &text);
178  void sc(Instruction insn, LargeStaticString &text);
179  void b(Instruction insn, LargeStaticString &text);
180  void op13(Instruction insn, LargeStaticString &text);
181  void rlwimi(Instruction insn, LargeStaticString &text);
182  void rlwinm(Instruction insn, LargeStaticString &text);
183  void rlwnm(Instruction insn, LargeStaticString &text);
184  void ori(Instruction insn, LargeStaticString &text);
185  void oris(Instruction insn, LargeStaticString &text);
186  void xori(Instruction insn, LargeStaticString &text);
187  void xoris(Instruction insn, LargeStaticString &text);
188  void andi_dot(Instruction insn, LargeStaticString &text);
189  void andis_dot(Instruction insn, LargeStaticString &text);
190  void op1e(Instruction insn, LargeStaticString &text);
191  void op1f(Instruction insn, LargeStaticString &text);
192  void lwz(Instruction insn, LargeStaticString &text);
193  void lwzu(Instruction insn, LargeStaticString &text);
194  void lbz(Instruction insn, LargeStaticString &text);
195  void lbzu(Instruction insn, LargeStaticString &text);
196  void stw(Instruction insn, LargeStaticString &text);
197  void stwu(Instruction insn, LargeStaticString &text);
198  void stb(Instruction insn, LargeStaticString &text);
199  void stbu(Instruction insn, LargeStaticString &text);
200  void lhz(Instruction insn, LargeStaticString &text);
201  void lhzu(Instruction insn, LargeStaticString &text);
202  void lha(Instruction insn, LargeStaticString &text);
203  void lhau(Instruction insn, LargeStaticString &text);
204  void sth(Instruction insn, LargeStaticString &text);
205  void sthu(Instruction insn, LargeStaticString &text);
206  void lmw(Instruction insn, LargeStaticString &text);
207  void stmw(Instruction insn, LargeStaticString &text);
208  void lfs(Instruction insn, LargeStaticString &text);
209  void lfsu(Instruction insn, LargeStaticString &text);
210  void lfd(Instruction insn, LargeStaticString &text);
211  void lfdu(Instruction insn, LargeStaticString &text);
212  void stfs(Instruction insn, LargeStaticString &text);
213  void stfsu(Instruction insn, LargeStaticString &text);
214  void stfd(Instruction insn, LargeStaticString &text);
215  void stfdu(Instruction insn, LargeStaticString &text);
216  void op3a(Instruction insn, LargeStaticString &text);
217  void op3b(Instruction insn, LargeStaticString &text);
218  void op3e(Instruction insn, LargeStaticString &text);
219  void op3f(Instruction insn, LargeStaticString &text);
220 
221  void null(Instruction insn, LargeStaticString &text);
222 };
223 
225 
226 #endif
void disassemble(LargeStaticString &text)
void setMode(size_t nMode)
void twi(Instruction insn, LargeStaticString &text)
void setLocation(uintptr_t nLocation)