1 #ifndef __DISASM_GLUE_H__
2 #define __DISASM_GLUE_H__
3 
4 /*
5  * generic interface to various disassemblers that are freely available.
6  *
7  * currently supported:
8  *
9  * - DISASM_USE_BUILTIN: uses the builtin disassembler.
10  *   This is the default.
11  *   It's always available, and rather short.
12  * - DISASM_USE_OPCODES: uses GNU opcodes library.
13  *   Available for most systems, and can probably handle everything
14  *   we can think of. For this reason, rather bloated.
15  *   The problem with this is if the systems default
16  *   library doesn't contain support for 68k, you have to compile one yourself,
17  *   and install it in a non-default place, or it clashes with the system library.
18  */
19 
20 #if defined(MAIN) && !defined(DISASM_USE_BUILTIN) && !defined(DISASM_USE_OPCODES)
21 #  define DISASM_USE_BUILTIN
22 #endif
23 
24 #if defined(DISASM_USE_BUILTIN) || defined(DISASM_USE_OPCODES)
25 #  define HAVE_DISASM_M68K
26 #else
27 #  undef HAVE_DISASM_M68K
28 #endif
29 #if (defined(DISASM_USE_BUILTIN) + defined(DISASM_USE_OPCODES)) > 1
30   #error only one disassembler may be defined
31 #endif
32 
33 #ifdef HAVE_DISASM_M68K
34 
35 enum m68k_cpu {
36 	CPU_AUTO,
37 	CPU_68000,
38 	CPU_68008,
39 	CPU_68010,
40 	CPU_68020,
41 	CPU_CPU32,
42 	CPU_68030,
43 	CPU_68EC030,
44 	CPU_68040,
45 	CPU_68EC040,
46 	CPU_68LC040,
47 	CPU_68060,
48 	CPU_68302,
49 	CPU_68331,
50 	CPU_68332,
51 	CPU_68333,
52 	CPU_68360,
53 	CPU_5200,
54 	CPU_5202,
55 	CPU_5204,
56 	CPU_5206,
57 	CPU_5206e,
58 	CPU_5207,
59 	CPU_5208,
60 	CPU_521x,
61 	CPU_5249,
62 	CPU_528x,
63 	CPU_5307,
64 	CPU_537x,
65 	CPU_5407,
66 	CPU_547x,
67 	CPU_548x,
68 	CPU_CFV4,
69 	CPU_CFV4e,
70 	CPU_CF_FIRST = CPU_5200,
71 	CPU_CF_LAST = CPU_CFV4e
72 };
73 
74 enum m68k_fpu {
75 	FPU_AUTO,
76 	FPU_NONE,
77 	FPU_68881,
78 	FPU_68882,
79 	FPU_68040,
80 	FPU_COLDFIRE
81 };
82 
83 enum m68k_mmu {
84 	MMU_AUTO,
85 	MMU_NONE,
86 	MMU_68851,
87 	MMU_68040
88 };
89 
90 typedef struct _m68k_disasm_info {
91 	enum m68k_cpu cpu;
92 	enum m68k_fpu fpu;
93 	enum m68k_mmu mmu;
94 
95 	int is_64bit;
96 
97 	memptr memory_vma;
98 	uae_u32 reloffset;
99 
100 	/*
101 	 * for use by the caller
102 	 */
103 	void *application_data;
104 
105 	/*
106 	 * for use by the disassembler
107 	 */
108 	void *disasm_data;
109 
110 	/*
111 	 * opcode of decoded instruction
112 	 */
113 	char opcode[22];
114 
115 	/*
116 	 * number of operands in decoded instruction, 0-2
117 	 */
118 	int num_oper;
119 
120 	/*
121 	 * the operands
122 	 */
123 	char operands[128];
124 
125 	/*
126 	 * any comments
127 	 */
128 	char comments[128];
129 
130 	/*
131 	 * the number of instruction words, and their values (in host format)
132 	 */
133 	int num_insn_words;
134 	unsigned short insn_words[11];
135 } m68k_disasm_info;
136 
137 extern m68k_disasm_info disasm_info;
138 
139 void m68k_disasm_init(m68k_disasm_info *info, enum m68k_cpu cpu);
140 void m68k_disasm_exit(m68k_disasm_info *info);
141 int m68k_disasm_insn(m68k_disasm_info *info);
142 int m68k_disasm_to_buf(m68k_disasm_info *info, char *buf, int allbytes);
143 
144 memptr gdb_dis(memptr start, unsigned int count);
145 void gdb_regs(void);
146 memptr gdb_pc(void);
147 
148 #ifdef DISASM_USE_BUILTIN
149 
150 int m68k_disasm_builtin(m68k_disasm_info *info);
151 
152 #endif
153 
154 #endif /* HAVE_DISASM_M68K */
155 
156 #if (defined(DISASM_USE_BUILTIN) || defined(DISASM_USE_OPCODES)) && (defined(CPU_i386) || defined(CPU_x86_64))
157 
158 #define HAVE_DISASM_X86 1
159 
160 const uint8 *x86_disasm(const uint8 *ainstr, char *buf, int allbytes);
161 
162 #endif
163 
164 #if defined(DISASM_USE_OPCODES) && (defined(CPU_powerpc))
165 
166 #define HAVE_DISASM_PPC 1
167 
168 const uint8 *ppc_disasm(const uint8 *ainstr, char *buf, int allbytes);
169 
170 #endif
171 
172 #if (defined(DISASM_USE_BUILTIN) || defined(DISASM_USE_OPCODES)) && (defined(CPU_arm))
173 
174 #define HAVE_DISASM_ARM 1
175 
176 const uint8 *arm_disasm(const uint8 *ainstr, char *buf, int allbytes);
177 
178 #endif
179 
180 #endif /* __DISASM_GLUE_H__ */
181