|
|
1.1 root 1: /* $Id: m68k-impl.h,v 1.10 2003/05/16 21:48:10 fredette Exp $ */
2:
3: /* ic/m68k/m68k-impl.h - implementation header file for Motorola 68k emulation: */
4:
5: /*
6: * Copyright (c) 2002, 2003 Matt Fredette
7: * All rights reserved.
8: *
9: * Redistribution and use in source and binary forms, with or without
10: * modification, are permitted provided that the following conditions
11: * are met:
12: * 1. Redistributions of source code must retain the above copyright
13: * notice, this list of conditions and the following disclaimer.
14: * 2. Redistributions in binary form must reproduce the above copyright
15: * notice, this list of conditions and the following disclaimer in the
16: * documentation and/or other materials provided with the distribution.
17: * 3. All advertising materials mentioning features or use of this software
18: * must display the following acknowledgement:
19: * This product includes software developed by Matt Fredette.
20: * 4. The name of the author may not be used to endorse or promote products
21: * derived from this software without specific prior written permission.
22: *
23: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25: * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26: * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
27: * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29: * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32: * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33: * POSSIBILITY OF SUCH DAMAGE.
34: */
35:
36: #ifndef _IC_M68K_IMPL_H
37: #define _IC_M68K_IMPL_H
38:
39: #include <tme/common.h>
40: _TME_RCSID("$Id: m68k-impl.h,v 1.10 2003/05/16 21:48:10 fredette Exp $");
41:
42: /* includes: */
43: #include <tme/ic/m68k.h>
44: #include <tme/generic/ic.h>
45: #include <setjmp.h>
46:
47: /* macros: */
48:
49: /* CPUs: */
50: #define TME_M68K_M68000 (0)
51: #define TME_M68K_M68010 (1)
52: #define TME_M68K_M68020 (2)
53: #define TME_M68K_M68030 (3)
54:
55: /* generic registers: */
56: #define tme_m68k_ireg_uint32(x) tme_m68k_ic.tme_ic_ireg_uint32(x)
57: #define tme_m68k_ireg_int32(x) tme_m68k_ic.tme_ic_ireg_int32(x)
58: #define tme_m68k_ireg_uint16(x) tme_m68k_ic.tme_ic_ireg_uint16(x)
59: #define tme_m68k_ireg_int16(x) tme_m68k_ic.tme_ic_ireg_int16(x)
60: #define tme_m68k_ireg_uint8(x) tme_m68k_ic.tme_ic_ireg_uint8(x)
61: #define tme_m68k_ireg_int8(x) tme_m68k_ic.tme_ic_ireg_int8(x)
62:
63: /* flags: */
64: #define TME_M68K_FLAG_C TME_BIT(0)
65: #define TME_M68K_FLAG_V TME_BIT(1)
66: #define TME_M68K_FLAG_Z TME_BIT(2)
67: #define TME_M68K_FLAG_N TME_BIT(3)
68: #define TME_M68K_FLAG_X TME_BIT(4)
69: #define TME_M68K_FLAG_IPM(x) TME_FIELD_EXTRACTU(x, 8, 3)
70: #define TME_M68K_FLAG_M TME_BIT(12)
71: #define TME_M68K_FLAG_S TME_BIT(13)
72: #define TME_M68K_FLAG_T(x) TME_FIELD_EXTRACTU(x, 14, 2)
73: #define TME_M68K_FLAG_CCR (TME_M68K_FLAG_C | TME_M68K_FLAG_V | \
74: TME_M68K_FLAG_Z | TME_M68K_FLAG_N | \
75: TME_M68K_FLAG_X)
76: #define TME_M68K_FLAG_SR (TME_M68K_FLAG_CCR | (0x7 << 8) | \
77: TME_M68K_FLAG_M | TME_M68K_FLAG_S | \
78: (0x3 << 14))
79:
80: /* conditions: */
81: #define TME_M68K_C_T (0)
82: #define TME_M68K_C_F (1)
83: #define TME_M68K_C_HI (2)
84: #define TME_M68K_C_LS (3)
85: #define TME_M68K_C_CC (4)
86: #define TME_M68K_C_CS (5)
87: #define TME_M68K_C_NE (6)
88: #define TME_M68K_C_EQ (7)
89: #define TME_M68K_C_VC (8)
90: #define TME_M68K_C_VS (9)
91: #define TME_M68K_C_PL (10)
92: #define TME_M68K_C_MI (11)
93: #define TME_M68K_C_GE (12)
94: #define TME_M68K_C_LT (13)
95: #define TME_M68K_C_GT (14)
96: #define TME_M68K_C_LE (15)
97: #define TME_M68K_COND_TRUE(ic, c) (_tme_m68k_conditions[(ic)->tme_m68k_ireg_ccr] & TME_BIT(c))
98:
99: /* bus cycles: */
100: #define TME_M68K_BUS_CYCLE_NORMAL (0)
101: #define TME_M68K_BUS_CYCLE_READ TME_BIT(0)
102: #define TME_M68K_BUS_CYCLE_FETCH TME_BIT(1)
103: #define TME_M68K_BUS_CYCLE_RMW TME_BIT(2)
104: #define TME_M68K_BUS_CYCLE_RAW TME_BIT(3)
105:
106: /* exceptions: */
107: #define TME_M68K_EXCEPTION_NONE (0)
108: #define TME_M68K_EXCEPTION_GROUP0_RESET TME_BIT(0)
109: #define TME_M68K_EXCEPTION_GROUP0_AERR TME_BIT(1)
110: #define TME_M68K_EXCEPTION_GROUP0_BERR TME_BIT(2)
111: #define TME_M68K_EXCEPTION_GROUP1_TRACE TME_BIT(3)
112: #define TME_M68K_EXCEPTION_GROUP1_INT(ipl, vec) (((ipl) << 4) | ((vec) << 7))
113: #define TME_M68K_EXCEPTION_IS_GROUP1_INT(x) (((x) >> 4) & 0x7)
114: #define TME_M68K_EXCEPTION_GROUP1_INT_VEC(x) (((x) >> 7) & 0xff)
115: #define TME_M68K_EXCEPTION_GROUP1_ILL TME_BIT(15)
116: #define TME_M68K_EXCEPTION_GROUP1_PRIV TME_BIT(16)
117: #define TME_M68K_EXCEPTION_GROUP2(x) ((x) << 17)
118: #define TME_M68K_EXCEPTION_IS_GROUP2(x) ((x) >> 17)
119:
120: /* exception frame formats: */
121: #define TME_M68K_FORMAT_0 (0)
122: #define TME_M68K_FORMAT_8 (8)
123:
124: /* sizes: */
125: #define TME_M68K_SIZE_SUBMAP_X (-2)
126: #define TME_M68K_SIZE_UNDEF (-1)
127: #define TME_M68K_SIZE_UNSIZED (0)
128: #define TME_M68K_SIZE_8 (1)
129: #define TME_M68K_SIZE_16 (2)
130: #define TME_M68K_SIZE_16U8 (3)
131: #define TME_M68K_SIZE_32 (4)
132: #define TME_M68K_SIZE_16S32 (5)
133:
134: /* special opcodes: */
135: #define TME_M68K_SPECOP_UNDEF (-1)
136: #define TME_M68K_SPECOP_BCC (0)
137: #define TME_M68K_SPECOP_SPECOP16 (1)
138: #define TME_M68K_SPECOP_MOVES (2)
139: #define TME_M68K_SPECOP_MOVEMEMTOMEM (3)
140: #define TME_M68K_SPECOP_ILLEGAL (4)
141: #define TME_M68K_SPECOP_MULUL (5)
142: #define TME_M68K_SPECOP_DIVUL (6)
143: #define TME_M68K_SPECOP_CAS2 (7)
144: #define TME_M68K_SPECOP_MOVENONMEMTOMEM (8)
145:
146: /* major modes of the emulator: */
147: #define TME_M68K_MODE_EXECUTION (0)
148: #define TME_M68K_MODE_EXCEPTION (1)
149: #define TME_M68K_MODE_RTE (2)
150: #define TME_M68K_MODE_STOP (3)
151: #define TME_M68K_MODE_HALT (4)
152:
153: /* mode-specific flags: */
154: #define TME_M68K_EXECUTION_INST_CANFAULT TME_BIT(0)
155:
156: /* given a linear address, this hashes it into a TLB entry: */
157: #define _TME_M68K_TLB_HASH_SIZE (1024)
158: #define TME_M68K_TLB_ENTRY(ic, function_code, linear_address) \
159: (TME_ATOMIC_READ(struct tme_m68k_tlb *, (ic)->_tme_m68k_tlb_array) \
160: + ((linear_address >> 10) & (_TME_M68K_TLB_HASH_SIZE - 1)))
161:
162: /* macros for sequence control: */
163: #define TME_M68K_SEQUENCE_START \
164: do { \
165: ic->_tme_m68k_sequence._tme_m68k_sequence_mode_flags = 0; \
166: ic->_tme_m68k_sequence._tme_m68k_sequence_transfer_faulted = 0; \
167: ic->_tme_m68k_sequence._tme_m68k_sequence_transfer_next = 1; \
168: } while (/* CONSTCOND */ 0)
169: #define TME_M68K_SEQUENCE_RESTARTING \
170: (ic->_tme_m68k_sequence._tme_m68k_sequence_transfer_faulted \
171: >= ic->_tme_m68k_sequence._tme_m68k_sequence_transfer_next)
172: #define TME_M68K_SEQUENCE_RESTART \
173: do { \
174: if (!TME_M68K_SEQUENCE_RESTARTING) \
175: ic->_tme_m68k_sequence._tme_m68k_sequence_transfer_faulted = \
176: ic->_tme_m68k_sequence._tme_m68k_sequence_transfer_next; \
177: ic->_tme_m68k_sequence._tme_m68k_sequence_transfer_next = 1; \
178: } while (/* CONSTCOND */ 0)
179: #define TME_M68K_SEQUENCE_TRANSFER_STEP \
180: do { \
181: ic->_tme_m68k_sequence._tme_m68k_sequence_transfer_next++; \
182: } while (/* CONSTCOND */ 0)
183:
184: /* instruction handler macros: */
185: #define TME_M68K_INSN_DECL(name) void name _TME_P((struct tme_m68k *, void *, void *))
186: #ifdef __STDC__
187: #define TME_M68K_INSN(name) void name(struct tme_m68k *ic, void *_op0, void *_op1)
188: #else /* !__STDC__ */
189: #define TME_M68K_INSN(name) void name(ic, _op0, _op1) struct tme_m68k *ic; void *_op0, *_op1;
190: #endif /* !__STDC__ */
191: #define TME_M68K_INSN_OP0(t) (*((t *) _op0))
192: #define TME_M68K_INSN_OP1(t) (*((t *) _op1))
193: #define TME_M68K_INSN_OPCODE ic->_tme_m68k_insn_opcode
194: #define TME_M68K_INSN_SPECOP ic->_tme_m68k_insn_specop
195: #define TME_M68K_INSN_OK return
196: #define TME_M68K_INSN_EXCEPTION(e) tme_m68k_exception(ic, e)
197: #define TME_M68K_INSN_PRIV \
198: if (!TME_M68K_PRIV(ic)) \
199: TME_M68K_INSN_EXCEPTION(TME_M68K_EXCEPTION_GROUP1_PRIV)
200: #define TME_M68K_INSN_ILL \
201: TME_M68K_INSN_EXCEPTION(TME_M68K_EXCEPTION_GROUP1_ILL)
202: #define TME_M68K_INSN_CANFAULT \
203: do { \
204: ic->_tme_m68k_mode_flags \
205: |= TME_M68K_EXECUTION_INST_CANFAULT; \
206: } while (/* CONSTCOND */ 0)
207: #define TME_M68K_INSN_BRANCH(pc) \
208: do { \
209: tme_m68k_verify_end_branch(ic, pc); \
210: ic->tme_m68k_ireg_pc = ic->tme_m68k_ireg_pc_next = (pc); \
211: if (tme_m68k_go_slow(ic)) { \
212: TME_M68K_SEQUENCE_START; \
213: tme_m68k_redispatch(ic); \
214: } \
215: } while (/* CONSTCOND */ 0)
216: #define TME_M68K_INSN_CHANGE_SR(reg) \
217: do { \
218: TME_M68K_INSN_PRIV; \
219: tme_m68k_change_sr(ic, reg); \
220: } while (/* CONSTCOND */ 0)
221:
222: /* logging: */
223: #define TME_M68K_LOG_HANDLE(ic) \
224: (&(ic)->tme_m68k_element->tme_element_log_handle)
225: #define tme_m68k_log_start(ic, level, rc) \
226: do { \
227: tme_log_start(TME_M68K_LOG_HANDLE(ic), level, rc) { \
228: if ((ic)->_tme_m68k_mode != TME_M68K_MODE_EXECUTION) { \
229: tme_log_part(TME_M68K_LOG_HANDLE(ic), \
230: "mode=%d ", \
231: (ic)->_tme_m68k_mode); \
232: } \
233: else { \
234: tme_log_part(TME_M68K_LOG_HANDLE(ic), \
235: "pc=%c/0x%08x ", \
236: (((ic)->tme_m68k_ireg_sr \
237: & (TME_M68K_FLAG_M \
238: | TME_M68K_FLAG_S)) \
239: ? 'S' \
240: : 'U'), \
241: ic->tme_m68k_ireg_pc); \
242: } \
243: do
244: #define tme_m68k_log_finish(ic) \
245: while (/* CONSTCOND */ 0); \
246: } tme_log_finish(TME_M68K_LOG_HANDLE(ic)); \
247: } while (/* CONSTCOND */ 0)
248: #define tme_m68k_log(ic, level, rc, x) \
249: do { \
250: tme_m68k_log_start(ic, level, rc) { \
251: tme_log_part x; \
252: } tme_m68k_log_finish(ic); \
253: } while (/* CONSTCOND */ 0)
254:
255: /* miscellaneous: */
256: #define TME_M68K_OPNUM_SUBMAP_X (-2)
257: #define TME_M68K_OPNUM_UNDEF (-1)
258: #define TME_M68K_PRIV(ic) ((ic)->tme_m68k_ireg_sr & TME_M68K_FLAG_S)
259: #define TME_M68K_FUNCTION_CODE_DATA(ic) \
260: (TME_M68K_PRIV(ic) ? TME_M68K_FC_SD : TME_M68K_FC_UD)
261: #define TME_M68K_FUNCTION_CODE_PROGRAM(ic) \
262: (TME_M68K_PRIV(ic) ? TME_M68K_FC_SP : TME_M68K_FC_UP)
263: #define TME_M68K_INSN_WORDS_MAX (11)
264:
265: /* structures: */
266: struct tme_m68k;
267:
268: /* an memory read or write function: */
269: typedef void (*_tme_m68k_xfer_memx) _TME_P((struct tme_m68k *));
270: typedef void (*_tme_m68k_xfer_mem) _TME_P((struct tme_m68k *, int));
271:
272: /* an m68k opcode map entry: */
273: struct _tme_m68k_opcode {
274:
275: /* the instruction: */
276: void (*_tme_m68k_opcode_func) _TME_P((struct tme_m68k *, void *, void *));
277:
278: /* iff this opcode requires some special operand processing, this is
279: its type, else this is TME_M68K_SPECOP_TYPE_UNDEF: */
280: int _tme_m68k_opcode_specop_type;
281:
282: /* if this opcode has an EA, this is the mask of bus cycles: */
283: int _tme_m68k_opcode_eax_cycles;
284: };
285:
286: /* an m68k decoder generic map entry: */
287: struct _tme_m68k_decoder_gen {
288:
289: /* any known operands, else NULL: */
290: void *_tme_m68k_decoder_gen_operand0;
291: void *_tme_m68k_decoder_gen_operand1;
292:
293: /* any known EA size, else TME_M68K_SIZE_UNDEF: */
294: int _tme_m68k_decoder_gen_eax_size;
295:
296: /* any known immediate operand number, else TME_M68K_OPNUM_UNDEF: */
297: int _tme_m68k_decoder_gen_imm_operand;
298:
299: /* any known immediate operand size: */
300: int _tme_m68k_decoder_gen_imm_size;
301: };
302:
303: /* an m68k decoder submap entry: */
304: struct _tme_m68k_decoder_submap {
305:
306: /* the generic map entry: */
307: struct _tme_m68k_decoder_gen _tme_m68k_decoder_submap_gen;
308:
309: /* the index for the opcode map: */
310: unsigned int _tme_m68k_decoder_submap_opcode_map_index;
311: };
312:
313: /* an m68k decoder root map entry: */
314: struct _tme_m68k_decoder_root {
315:
316: /* the generic map entry: */
317: struct _tme_m68k_decoder_gen _tme_m68k_decoder_root_gen;
318:
319: /* the opcode map: */
320: const struct _tme_m68k_opcode *_tme_m68k_decoder_root_opcode_map;
321:
322: /* the submap: */
323: const struct _tme_m68k_decoder_submap *_tme_m68k_decoder_root_submap;
324: };
325:
326: /* an m68k sequence: */
327: struct _tme_m68k_sequence {
328:
329: /* the mode of the emulator: */
330: int _tme_m68k_sequence_mode;
331:
332: /* any mode-specific flags for the sequence: */
333: int _tme_m68k_sequence_mode_flags;
334:
335: /* the ordinal of the next memory transfer. always starts from one: */
336: unsigned short _tme_m68k_sequence_transfer_next;
337:
338: /* the ordinal of the memory transfer that faulted. if this is
339: greater than or equal to _tme_m68k_sequence_transfer_next, we are
340: restarting, and bus cycles and changes to the m68k state are
341: forbidden: */
342: unsigned short _tme_m68k_sequence_transfer_faulted;
343:
344: /* the fault happened after this number of bytes were successfully
345: transferred: */
346: unsigned short _tme_m68k_sequence_transfer_faulted_after;
347:
348: #ifdef _TME_M68K_VERIFY
349: /* the sequence unique identifier: */
350: unsigned long _tme_m68k_sequence_uid;
351: #endif /* _TME_M68K_VERIFY */
352: };
353:
354: /* the m68k state: */
355: struct tme_m68k {
356:
357: /* the IC data structure. it is beneficial to have this structure
358: first, since register numbers can often simply be scaled and
359: added without an offset to the struct tme_m68k pointer to get
360: to their contents: */
361: struct tme_ic tme_m68k_ic;
362:
363: /* the m68k type: */
364: int tme_m68k_type;
365:
366: /* the backpointer to our element: */
367: struct tme_element *tme_m68k_element;
368:
369: /* our bus connection. if both are defined, the m68k bus connection
370: is an adaptation layer for the generic bus connection: */
371: struct tme_m68k_bus_connection *_tme_m68k_bus_connection;
372: struct tme_bus_connection *_tme_m68k_bus_generic;
373:
374: /* a jmp_buf back to the dispatcher: */
375: jmp_buf _tme_m68k_dispatcher;
376:
377: /* the current sequence: */
378: struct _tme_m68k_sequence _tme_m68k_sequence;
379: #define _tme_m68k_mode _tme_m68k_sequence._tme_m68k_sequence_mode
380: #define _tme_m68k_mode_flags _tme_m68k_sequence._tme_m68k_sequence_mode_flags
381: #define _tme_m68k_insn_uid _tme_m68k_sequence._tme_m68k_sequence_uid
382:
383: /* the CPU-dependent functions for the different modes: */
384: void (*_tme_m68k_mode_execute) _TME_P((struct tme_m68k *));
385: void (*_tme_m68k_mode_exception) _TME_P((struct tme_m68k *));
386: void (*_tme_m68k_mode_rte) _TME_P((struct tme_m68k *));
387:
388: /* the instruction decoder root map, and the instruction burst count: */
389: const struct _tme_m68k_decoder_root *_tme_m68k_decoder_root;
390: unsigned int _tme_m68k_instruction_burst;
391:
392: /* the effective address: */
393: tme_uint32_t _tme_m68k_ea_address;
394: unsigned int _tme_m68k_ea_function_code;
395:
396: /* instruction fetch information: */
397: tme_uint16_t _tme_m68k_insn_opcode;
398: tme_uint16_t _tme_m68k_insn_specop;
399: tme_uint16_t _tme_m68k_insn_specop2;
400:
401: /* the instruction buffer: */
402: tme_uint8_t _tme_m68k_insn_buffer[TME_M68K_INSN_WORDS_MAX * sizeof(tme_uint32_t)];
403: unsigned int _tme_m68k_insn_buffer_off;
404: tme_uint16_t _tme_m68k_insn_buffer_fetch_total;
405: tme_uint16_t _tme_m68k_insn_buffer_fetch_sizes;
406:
407: /* the TLB entry set, and a separate instruction TLB entry set
408: reserved for the executors: */
409: TME_ATOMIC(struct tme_m68k_tlb *, _tme_m68k_tlb_array);
410: TME_ATOMIC(struct tme_m68k_tlb *, _tme_m68k_itlb);
411:
412: /* exception handling information: */
413: tme_uint32_t _tme_m68k_exceptions;
414:
415: /* nonzero iff this CPU has a 16-bit bus: */
416: int _tme_m68k_bus_16bit;
417:
418: /* group 0 exception information: */
419: void (*_tme_m68k_group0_hook) _TME_P((struct tme_m68k *));
420: unsigned int _tme_m68k_group0_flags;
421: unsigned int _tme_m68k_group0_function_code;
422: tme_uint32_t _tme_m68k_group0_address;
423: struct _tme_m68k_sequence _tme_m68k_group0_sequence;
424: tme_uint8_t _tme_m68k_group0_buffer_read[sizeof(tme_uint32_t)];
425: unsigned int _tme_m68k_group0_buffer_read_size;
426: unsigned int _tme_m68k_group0_buffer_read_softrr;
427: tme_uint8_t _tme_m68k_group0_buffer_write[sizeof(tme_uint32_t)];
428: unsigned int _tme_m68k_group0_buffer_write_size;
429: unsigned int _tme_m68k_group0_buffer_write_softrr;
430:
431: /* the external request lines: */
432: tme_mutex_t tme_m68k_external_mutex;
433: tme_cond_t tme_m68k_external_cond;
434: unsigned int tme_m68k_external_reset;
435: unsigned int tme_m68k_external_halt;
436: unsigned int tme_m68k_external_ipl;
437: unsigned int tme_m68k_external_vector;
438: };
439:
440: /* globals: */
441: extern const tme_uint16_t _tme_m68k_conditions[32];
442: extern const tme_uint32_t _tme_m68k_imm32[9];
443: extern const tme_uint16_t _tme_m68k_imm16[9];
444: extern const tme_uint8_t _tme_m68k_imm8[9];
445: extern const _tme_m68k_xfer_memx _tme_m68k_read_memx[5];
446: extern const _tme_m68k_xfer_memx _tme_m68k_write_memx[5];
447: extern const _tme_m68k_xfer_mem _tme_m68k_read_mem[5];
448: extern const _tme_m68k_xfer_mem _tme_m68k_write_mem[5];
449:
450: /* prototypes: */
451: int tme_m68k_new _TME_P((struct tme_m68k *, const char * const *, const void *, char **));
452: void tme_m68k_redispatch _TME_P((struct tme_m68k *));
453: int tme_m68k_go_slow _TME_P((const struct tme_m68k *));
454: void tme_m68k_change_sr _TME_P((struct tme_m68k *, tme_uint16_t));
455: void tme_m68k_external_check _TME_P((struct tme_m68k *, tme_uint32_t));
456: void tme_m68k_tlb_fill _TME_P((struct tme_m68k *, struct tme_m68k_tlb *, unsigned int, tme_uint32_t, unsigned int));
457: void tme_m68k_do_reset _TME_P((struct tme_m68k *));
458:
459: /* exception support: */
460: void tme_m68k_exception _TME_P((struct tme_m68k *, tme_uint32_t));
461: void tme_m68k_exception_process_start _TME_P((struct tme_m68k *, unsigned int));
462: void tme_m68k_exception_process_finish _TME_P((struct tme_m68k *, tme_uint8_t, tme_uint8_t));
463: void tme_m68k_exception_process _TME_P((struct tme_m68k *));
464:
465: /* rte support: */
466: tme_uint16_t tme_m68k_rte_start _TME_P((struct tme_m68k *));
467: void tme_m68k_rte_finish _TME_P((struct tme_m68k *, tme_uint32_t));
468:
469: /* decoder map support: */
470: void _tme_m68000_decoder_map_init _TME_P((struct tme_m68k *));
471: void _tme_m68010_decoder_map_init _TME_P((struct tme_m68k *));
472: void _tme_m68020_decoder_map_init _TME_P((struct tme_m68k *));
473:
474: /* read/modify/write cycle support: */
475: struct tme_m68k_tlb *tme_m68k_rmw_start _TME_P((struct tme_m68k *));
476: void tme_m68k_rmw_finish _TME_P((struct tme_m68k *, struct tme_m68k_tlb *));
477:
478: /* group 0 fault support: */
479: int tme_m68k_insn_buffer_xfer _TME_P((struct tme_m68k *, tme_uint8_t *, unsigned int, int));
480: void tme_m68k_group0_hook_fast _TME_P((struct tme_m68k *));
481: #define tme_m68k_insn_buffer_empty(ic, r, ra) \
482: tme_m68k_insn_buffer_xfer(ic, r, ra, 1)
483: #define tme_m68k_insn_buffer_fill(ic, r, ra) \
484: tme_m68k_insn_buffer_xfer(ic, r, ra, 2)
485: int tme_m68k_sequence_empty _TME_P((const struct tme_m68k *, tme_uint8_t *, unsigned int));
486: int tme_m68k_sequence_fill _TME_P((struct tme_m68k *, const tme_uint8_t *, unsigned int));
487:
488: /* bitfield support: */
489: unsigned int tme_m68k_bitfield_width _TME_P((struct tme_m68k *));
490: tme_uint32_t _tme_m68k_bitfield_read _TME_P((struct tme_m68k *, int));
491: #define tme_m68k_bitfield_read_signed(ic) ((tme_int32_t) _tme_m68k_bitfield_read(ic, TRUE))
492: #define tme_m68k_bitfield_read_unsigned(ic) _tme_m68k_bitfield_read(ic, FALSE)
493: void tme_m68k_bitfield_write_unsigned _TME_P((struct tme_m68k *, tme_uint32_t, int));
494: #define tme_m68k_bitfield_write_signed(ic, v, sf) tme_m68k_bitfield_write_unsigned(ic, (tme_uint32_t) (v), sf)
495:
496: /* verification: */
497: #ifdef _TME_M68K_VERIFY
498: void tme_m68k_verify_init _TME_P((void));
499: void tme_m68k_verify_begin _TME_P((const struct tme_m68k *, const tme_uint8_t *));
500: void tme_m68k_verify_mem_any _TME_P((const struct tme_m68k *,
501: unsigned int, tme_uint32_t,
502: tme_uint8_t *, int, int));
503: void tme_m68k_verify_end_branch _TME_P((const struct tme_m68k *, tme_uint32_t));
504: void tme_m68k_verify_end _TME_P((const struct tme_m68k *,
505: void (*)(struct tme_m68k *, void *, void *)));
506: void tme_m68k_verify_hook _TME_P((void));
507: #else /* _TME_M68K_VERIFY */
508: #define tme_m68k_verify_init() do { } while (/* CONSTCOND */ 0)
509: #define tme_m68k_verify_begin(ic, s) do { } while (/* CONSTCOND */ 0)
510: #define tme_m68k_verify_mem_any(ic, fc, a, v, c, rw) do { } while (/* CONSTCOND */ 0)
511: #define tme_m68k_verify_end_branch(ic, pc) do { } while (/* CONSTCOND */ 0)
512: #define tme_m68k_verify_end(ic, f) do { } while (/* CONSTCOND */ 0)
513: #define tme_m68k_verify_hook() do { } while (/* CONSTCOND */ 0)
514: #endif /* _TME_M68K_VERIFY */
515: #define tme_m68k_verify_mem8(ic, fc, a, v, rw) tme_m68k_verify_mem_any(ic, fc, a, (tme_uint8_t *) &(v), -sizeof(tme_uint8_t), rw)
516: #define tme_m68k_verify_mem16(ic, fc, a, v, rw) tme_m68k_verify_mem_any(ic, fc, a, (tme_uint8_t *) &(v), -sizeof(tme_uint16_t), rw)
517: #define tme_m68k_verify_mem32(ic, fc, a, v, rw) tme_m68k_verify_mem_any(ic, fc, a, (tme_uint8_t *) &(v), -sizeof(tme_uint32_t), rw)
518:
519: /* instruction functions: */
520: TME_M68K_INSN_DECL(tme_m68k_illegal);
521: TME_M68K_INSN_DECL(tme_m68k_exg);
522: TME_M68K_INSN_DECL(tme_m68k_extw);
523: TME_M68K_INSN_DECL(tme_m68k_extl);
524: TME_M68K_INSN_DECL(tme_m68k_extbl);
525: TME_M68K_INSN_DECL(tme_m68k_lea);
526: TME_M68K_INSN_DECL(tme_m68k_move_from_ccr);
527: TME_M68K_INSN_DECL(tme_m68k_move_from_sr);
528: TME_M68K_INSN_DECL(tme_m68k_move_from_sr0);
529: TME_M68K_INSN_DECL(tme_m68k_swap);
530: TME_M68K_INSN_DECL(tme_m68k_nop);
531: TME_M68K_INSN_DECL(tme_m68k_scc);
532: TME_M68K_INSN_DECL(tme_m68k_dbcc);
533: TME_M68K_INSN_DECL(tme_m68k_bcc);
534: TME_M68K_INSN_DECL(tme_m68k_bsr);
535: TME_M68K_INSN_DECL(tme_m68k_pea);
536: TME_M68K_INSN_DECL(tme_m68k_bkpt);
537: TME_M68K_INSN_DECL(tme_m68k_tas);
538: TME_M68K_INSN_DECL(tme_m68k_tas_r);
539: TME_M68K_INSN_DECL(tme_m68k_move_usp);
540: TME_M68K_INSN_DECL(tme_m68k_trap);
541: TME_M68K_INSN_DECL(tme_m68k_trapv);
542: TME_M68K_INSN_DECL(tme_m68k_link);
543: TME_M68K_INSN_DECL(tme_m68k_unlk);
544: TME_M68K_INSN_DECL(tme_m68k_movec);
545: TME_M68K_INSN_DECL(tme_m68k_reset);
546: TME_M68K_INSN_DECL(tme_m68k_rtd);
547: TME_M68K_INSN_DECL(tme_m68k_rtr);
548: TME_M68K_INSN_DECL(tme_m68k_rts);
549: TME_M68K_INSN_DECL(tme_m68k_jsr);
550: TME_M68K_INSN_DECL(tme_m68k_jmp);
551: TME_M68K_INSN_DECL(tme_m68k_rte);
552: TME_M68K_INSN_DECL(tme_m68k_stop);
553: TME_M68K_INSN_DECL(tme_m68k_priv);
554: TME_M68K_INSN_DECL(tme_m68k_cmp2_chk2);
555: TME_M68K_INSN_DECL(tme_m68k_callm);
556: TME_M68K_INSN_DECL(tme_m68k_rtm);
557: TME_M68K_INSN_DECL(tme_m68k_trapcc);
558: TME_M68K_INSN_DECL(tme_m68k_bfchg);
559: TME_M68K_INSN_DECL(tme_m68k_bfclr);
560: TME_M68K_INSN_DECL(tme_m68k_bfexts);
561: TME_M68K_INSN_DECL(tme_m68k_bfextu);
562: TME_M68K_INSN_DECL(tme_m68k_bfffo);
563: TME_M68K_INSN_DECL(tme_m68k_bfins);
564: TME_M68K_INSN_DECL(tme_m68k_bfset);
565: TME_M68K_INSN_DECL(tme_m68k_bftst);
566: TME_M68K_INSN_DECL(tme_m68k_pack);
567: TME_M68K_INSN_DECL(tme_m68k_unpk);
568:
569: #endif /* !_IC_M68K_IMPL_H */
570:
571: /* the automatically-generated header information: */
572: #include <m68k-auto.h>
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.