Annotation of tme/ic/m68k/m68k-impl.h, revision 1.1.1.2

1.1.1.2 ! root        1: /* $Id: m68k-impl.h,v 1.13 2003/10/16 02:48:24 fredette Exp $ */
1.1       root        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>
1.1.1.2 ! root       40: _TME_RCSID("$Id: m68k-impl.h,v 1.13 2003/10/16 02:48:24 fredette Exp $");
1.1       root       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: */
1.1.1.2 ! root      330:   unsigned int _tme_m68k_sequence_mode;
1.1       root      331: 
                    332:   /* any mode-specific flags for the sequence: */
1.1.1.2 ! root      333:   unsigned int _tme_m68k_sequence_mode_flags;
1.1       root      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: 
1.1.1.2 ! root      388:   /* the instruction decoder root map: */
1.1       root      389:   const struct _tme_m68k_decoder_root *_tme_m68k_decoder_root;
1.1.1.2 ! root      390: 
        !           391:   /* the instruction burst count, and the remaining burst: */
1.1       root      392:   unsigned int _tme_m68k_instruction_burst;
1.1.1.2 ! root      393:   unsigned int _tme_m68k_instruction_burst_remaining;
1.1       root      394: 
                    395:   /* the effective address: */
                    396:   tme_uint32_t _tme_m68k_ea_address;
                    397:   unsigned int _tme_m68k_ea_function_code;
                    398: 
                    399:   /* instruction fetch information: */
                    400:   tme_uint16_t _tme_m68k_insn_opcode;
                    401:   tme_uint16_t _tme_m68k_insn_specop;
                    402:   tme_uint16_t _tme_m68k_insn_specop2;
                    403:   
                    404:   /* the instruction buffer: */
                    405:   tme_uint8_t _tme_m68k_insn_buffer[TME_M68K_INSN_WORDS_MAX * sizeof(tme_uint32_t)];
                    406:   unsigned int _tme_m68k_insn_buffer_off;
                    407:   tme_uint16_t _tme_m68k_insn_buffer_fetch_total;
                    408:   tme_uint16_t _tme_m68k_insn_buffer_fetch_sizes;
                    409: 
                    410:   /* the TLB entry set, and a separate instruction TLB entry set
                    411:      reserved for the executors: */
                    412:   TME_ATOMIC(struct tme_m68k_tlb *, _tme_m68k_tlb_array);
                    413:   TME_ATOMIC(struct tme_m68k_tlb *, _tme_m68k_itlb);
                    414: 
                    415:   /* exception handling information: */
                    416:   tme_uint32_t _tme_m68k_exceptions;
                    417: 
                    418:   /* nonzero iff this CPU has a 16-bit bus: */
                    419:   int _tme_m68k_bus_16bit;
                    420: 
                    421:   /* group 0 exception information: */
                    422:   void (*_tme_m68k_group0_hook) _TME_P((struct tme_m68k *));
                    423:   unsigned int _tme_m68k_group0_flags;
                    424:   unsigned int _tme_m68k_group0_function_code;
                    425:   tme_uint32_t _tme_m68k_group0_address;
                    426:   struct _tme_m68k_sequence _tme_m68k_group0_sequence;
                    427:   tme_uint8_t _tme_m68k_group0_buffer_read[sizeof(tme_uint32_t)];
                    428:   unsigned int _tme_m68k_group0_buffer_read_size;
                    429:   unsigned int _tme_m68k_group0_buffer_read_softrr;
                    430:   tme_uint8_t _tme_m68k_group0_buffer_write[sizeof(tme_uint32_t)];
                    431:   unsigned int _tme_m68k_group0_buffer_write_size;
                    432:   unsigned int _tme_m68k_group0_buffer_write_softrr;
                    433: 
                    434:   /* the external request lines: */
                    435:   tme_mutex_t tme_m68k_external_mutex;
                    436:   tme_cond_t tme_m68k_external_cond;
                    437:   unsigned int tme_m68k_external_reset;
                    438:   unsigned int tme_m68k_external_halt;
                    439:   unsigned int tme_m68k_external_ipl;
                    440:   unsigned int tme_m68k_external_vector;
                    441: };
                    442: 
                    443: /* globals: */
                    444: extern const tme_uint16_t _tme_m68k_conditions[32];
                    445: extern const tme_uint32_t _tme_m68k_imm32[9];
                    446: extern const tme_uint16_t _tme_m68k_imm16[9];
                    447: extern const tme_uint8_t _tme_m68k_imm8[9];
                    448: extern const _tme_m68k_xfer_memx _tme_m68k_read_memx[5];
                    449: extern const _tme_m68k_xfer_memx _tme_m68k_write_memx[5];
                    450: extern const _tme_m68k_xfer_mem _tme_m68k_read_mem[5];
                    451: extern const _tme_m68k_xfer_mem _tme_m68k_write_mem[5];
                    452: 
                    453: /* prototypes: */
                    454: int tme_m68k_new _TME_P((struct tme_m68k *, const char * const *, const void *, char **));
                    455: void tme_m68k_redispatch _TME_P((struct tme_m68k *));
                    456: int tme_m68k_go_slow _TME_P((const struct tme_m68k *));
                    457: void tme_m68k_change_sr _TME_P((struct tme_m68k *, tme_uint16_t));
                    458: void tme_m68k_external_check _TME_P((struct tme_m68k *, tme_uint32_t));
                    459: void tme_m68k_tlb_fill _TME_P((struct tme_m68k *, struct tme_m68k_tlb *, unsigned int, tme_uint32_t, unsigned int));
                    460: void tme_m68k_do_reset _TME_P((struct tme_m68k *));
                    461: 
                    462: /* exception support: */
                    463: void tme_m68k_exception _TME_P((struct tme_m68k *, tme_uint32_t));
                    464: void tme_m68k_exception_process_start _TME_P((struct tme_m68k *, unsigned int));
                    465: void tme_m68k_exception_process_finish _TME_P((struct tme_m68k *, tme_uint8_t, tme_uint8_t));
                    466: void tme_m68k_exception_process _TME_P((struct tme_m68k *));
                    467: 
                    468: /* rte support: */
                    469: tme_uint16_t tme_m68k_rte_start _TME_P((struct tme_m68k *));
                    470: void tme_m68k_rte_finish _TME_P((struct tme_m68k *, tme_uint32_t));
                    471: 
                    472: /* decoder map support: */
                    473: void _tme_m68000_decoder_map_init _TME_P((struct tme_m68k *));
                    474: void _tme_m68010_decoder_map_init _TME_P((struct tme_m68k *));
                    475: void _tme_m68020_decoder_map_init _TME_P((struct tme_m68k *));
                    476: 
                    477: /* read/modify/write cycle support: */
                    478: struct tme_m68k_tlb *tme_m68k_rmw_start _TME_P((struct tme_m68k *));
                    479: void tme_m68k_rmw_finish _TME_P((struct tme_m68k *, struct tme_m68k_tlb *));
                    480: 
                    481: /* group 0 fault support: */
                    482: int tme_m68k_insn_buffer_xfer _TME_P((struct tme_m68k *, tme_uint8_t *, unsigned int, int));
                    483: void tme_m68k_group0_hook_fast _TME_P((struct tme_m68k *));
                    484: #define tme_m68k_insn_buffer_empty(ic, r, ra) \
                    485:   tme_m68k_insn_buffer_xfer(ic, r, ra, 1)
                    486: #define tme_m68k_insn_buffer_fill(ic, r, ra) \
                    487:   tme_m68k_insn_buffer_xfer(ic, r, ra, 2)
                    488: int tme_m68k_sequence_empty _TME_P((const struct tme_m68k *, tme_uint8_t *, unsigned int));
                    489: int tme_m68k_sequence_fill _TME_P((struct tme_m68k *, const tme_uint8_t *, unsigned int));
                    490: 
                    491: /* bitfield support: */
                    492: unsigned int tme_m68k_bitfield_width _TME_P((struct tme_m68k *));
                    493: tme_uint32_t _tme_m68k_bitfield_read _TME_P((struct tme_m68k *, int));
                    494: #define tme_m68k_bitfield_read_signed(ic) ((tme_int32_t) _tme_m68k_bitfield_read(ic, TRUE))
                    495: #define tme_m68k_bitfield_read_unsigned(ic) _tme_m68k_bitfield_read(ic, FALSE)
                    496: void tme_m68k_bitfield_write_unsigned _TME_P((struct tme_m68k *, tme_uint32_t, int));
                    497: #define tme_m68k_bitfield_write_signed(ic, v, sf) tme_m68k_bitfield_write_unsigned(ic, (tme_uint32_t) (v), sf)
                    498: 
                    499: /* verification: */
1.1.1.2 ! root      500: void tme_m68k_verify_hook _TME_P((void));
1.1       root      501: #ifdef _TME_M68K_VERIFY
                    502: void tme_m68k_verify_init _TME_P((void));
                    503: void tme_m68k_verify_begin _TME_P((const struct tme_m68k *, const tme_uint8_t *));
                    504: void tme_m68k_verify_mem_any _TME_P((const struct tme_m68k *,
                    505:                                     unsigned int, tme_uint32_t,
                    506:                                     tme_uint8_t *, int, int));
                    507: void tme_m68k_verify_end_branch _TME_P((const struct tme_m68k *, tme_uint32_t));
                    508: void tme_m68k_verify_end _TME_P((const struct tme_m68k *,
                    509:                                 void (*)(struct tme_m68k *, void *, void *)));
                    510: #else  /* _TME_M68K_VERIFY */
                    511: #define tme_m68k_verify_init() do { } while (/* CONSTCOND */ 0)
                    512: #define tme_m68k_verify_begin(ic, s) do { } while (/* CONSTCOND */ 0)
                    513: #define tme_m68k_verify_mem_any(ic, fc, a, v, c, rw) do { } while (/* CONSTCOND */ 0)
                    514: #define tme_m68k_verify_end_branch(ic, pc) do { } while (/* CONSTCOND */ 0)
                    515: #define tme_m68k_verify_end(ic, f) do { } while (/* CONSTCOND */ 0)
                    516: #define tme_m68k_verify_hook() do { } while (/* CONSTCOND */ 0)
                    517: #endif /* _TME_M68K_VERIFY */
                    518: #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)
                    519: #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)
                    520: #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)
                    521: 
                    522: /* instruction functions: */
                    523: TME_M68K_INSN_DECL(tme_m68k_illegal);
                    524: TME_M68K_INSN_DECL(tme_m68k_exg);
                    525: TME_M68K_INSN_DECL(tme_m68k_extw);
                    526: TME_M68K_INSN_DECL(tme_m68k_extl);
                    527: TME_M68K_INSN_DECL(tme_m68k_extbl);
                    528: TME_M68K_INSN_DECL(tme_m68k_lea);
                    529: TME_M68K_INSN_DECL(tme_m68k_move_from_ccr);
                    530: TME_M68K_INSN_DECL(tme_m68k_move_from_sr);
                    531: TME_M68K_INSN_DECL(tme_m68k_move_from_sr0);
                    532: TME_M68K_INSN_DECL(tme_m68k_swap);
                    533: TME_M68K_INSN_DECL(tme_m68k_nop);
                    534: TME_M68K_INSN_DECL(tme_m68k_scc);
                    535: TME_M68K_INSN_DECL(tme_m68k_dbcc);
                    536: TME_M68K_INSN_DECL(tme_m68k_bcc);
                    537: TME_M68K_INSN_DECL(tme_m68k_bsr);
                    538: TME_M68K_INSN_DECL(tme_m68k_pea);
                    539: TME_M68K_INSN_DECL(tme_m68k_bkpt);
                    540: TME_M68K_INSN_DECL(tme_m68k_tas);
                    541: TME_M68K_INSN_DECL(tme_m68k_tas_r);
                    542: TME_M68K_INSN_DECL(tme_m68k_move_usp);
                    543: TME_M68K_INSN_DECL(tme_m68k_trap);
                    544: TME_M68K_INSN_DECL(tme_m68k_trapv);
                    545: TME_M68K_INSN_DECL(tme_m68k_link);
                    546: TME_M68K_INSN_DECL(tme_m68k_unlk);
                    547: TME_M68K_INSN_DECL(tme_m68k_movec);
                    548: TME_M68K_INSN_DECL(tme_m68k_reset);
                    549: TME_M68K_INSN_DECL(tme_m68k_rtd);
                    550: TME_M68K_INSN_DECL(tme_m68k_rtr);
                    551: TME_M68K_INSN_DECL(tme_m68k_rts);
                    552: TME_M68K_INSN_DECL(tme_m68k_jsr);
                    553: TME_M68K_INSN_DECL(tme_m68k_jmp);
                    554: TME_M68K_INSN_DECL(tme_m68k_rte);
                    555: TME_M68K_INSN_DECL(tme_m68k_stop);
                    556: TME_M68K_INSN_DECL(tme_m68k_priv);
                    557: TME_M68K_INSN_DECL(tme_m68k_cmp2_chk2);
                    558: TME_M68K_INSN_DECL(tme_m68k_callm);
                    559: TME_M68K_INSN_DECL(tme_m68k_rtm);
                    560: TME_M68K_INSN_DECL(tme_m68k_trapcc);
                    561: TME_M68K_INSN_DECL(tme_m68k_bfchg);
                    562: TME_M68K_INSN_DECL(tme_m68k_bfclr);
                    563: TME_M68K_INSN_DECL(tme_m68k_bfexts);
                    564: TME_M68K_INSN_DECL(tme_m68k_bfextu);
                    565: TME_M68K_INSN_DECL(tme_m68k_bfffo);
                    566: TME_M68K_INSN_DECL(tme_m68k_bfins);
                    567: TME_M68K_INSN_DECL(tme_m68k_bfset);
                    568: TME_M68K_INSN_DECL(tme_m68k_bftst);
                    569: TME_M68K_INSN_DECL(tme_m68k_pack);
                    570: TME_M68K_INSN_DECL(tme_m68k_unpk);
                    571: 
                    572: #endif /* !_IC_M68K_IMPL_H */
                    573: 
                    574: /* the automatically-generated header information: */
                    575: #include <m68k-auto.h>

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.