Sat, 27 Nov 2010 01:13:12 +0000
initial commit
philpem@0 | 1 | /* ======================================================================== */ |
philpem@0 | 2 | /* ========================= LICENSING & COPYRIGHT ======================== */ |
philpem@0 | 3 | /* ======================================================================== */ |
philpem@0 | 4 | /* |
philpem@0 | 5 | * MUSASHI |
philpem@0 | 6 | * Version 3.3 |
philpem@0 | 7 | * |
philpem@0 | 8 | * A portable Motorola M680x0 processor emulation engine. |
philpem@0 | 9 | * Copyright 1998-2001 Karl Stenerud. All rights reserved. |
philpem@0 | 10 | * |
philpem@0 | 11 | * This code may be freely used for non-commercial purposes as long as this |
philpem@0 | 12 | * copyright notice remains unaltered in the source code and any binary files |
philpem@0 | 13 | * containing this code in compiled form. |
philpem@0 | 14 | * |
philpem@0 | 15 | * All other lisencing terms must be negotiated with the author |
philpem@0 | 16 | * (Karl Stenerud). |
philpem@0 | 17 | * |
philpem@0 | 18 | * The latest version of this code can be obtained at: |
philpem@0 | 19 | * http://kstenerud.cjb.net |
philpem@0 | 20 | */ |
philpem@0 | 21 | |
philpem@0 | 22 | |
philpem@0 | 23 | |
philpem@0 | 24 | #ifndef M68KCONF__HEADER |
philpem@0 | 25 | #define M68KCONF__HEADER |
philpem@0 | 26 | |
philpem@0 | 27 | |
philpem@0 | 28 | /* Configuration switches. |
philpem@0 | 29 | * Use OPT_SPECIFY_HANDLER for configuration options that allow callbacks. |
philpem@0 | 30 | * OPT_SPECIFY_HANDLER causes the core to link directly to the function |
philpem@0 | 31 | * or macro you specify, rather than using callback functions whose pointer |
philpem@0 | 32 | * must be passed in using m68k_set_xxx_callback(). |
philpem@0 | 33 | */ |
philpem@0 | 34 | #define OPT_OFF 0 |
philpem@0 | 35 | #define OPT_ON 1 |
philpem@0 | 36 | #define OPT_SPECIFY_HANDLER 2 |
philpem@0 | 37 | |
philpem@0 | 38 | |
philpem@0 | 39 | /* ======================================================================== */ |
philpem@0 | 40 | /* ============================== MAME STUFF ============================== */ |
philpem@0 | 41 | /* ======================================================================== */ |
philpem@0 | 42 | |
philpem@0 | 43 | /* If you're compiling this for MAME, only change M68K_COMPILE_FOR_MAME |
philpem@0 | 44 | * to OPT_ON and use m68kmame.h to configure the 68k core. |
philpem@0 | 45 | */ |
philpem@0 | 46 | #ifndef M68K_COMPILE_FOR_MAME |
philpem@0 | 47 | #define M68K_COMPILE_FOR_MAME OPT_OFF |
philpem@0 | 48 | #endif /* M68K_COMPILE_FOR_MAME */ |
philpem@0 | 49 | |
philpem@0 | 50 | #if M68K_COMPILE_FOR_MAME == OPT_ON |
philpem@0 | 51 | #include "m68kmame.h" |
philpem@0 | 52 | #else |
philpem@0 | 53 | |
philpem@0 | 54 | |
philpem@0 | 55 | |
philpem@0 | 56 | /* ======================================================================== */ |
philpem@0 | 57 | /* ============================= CONFIGURATION ============================ */ |
philpem@0 | 58 | /* ======================================================================== */ |
philpem@0 | 59 | |
philpem@0 | 60 | /* Turn on if you want to use the following M68K variants */ |
philpem@0 | 61 | #define M68K_EMULATE_010 OPT_ON |
philpem@0 | 62 | #define M68K_EMULATE_EC020 OPT_ON |
philpem@0 | 63 | #define M68K_EMULATE_020 OPT_ON |
philpem@0 | 64 | |
philpem@0 | 65 | |
philpem@0 | 66 | /* If on, the CPU will call m68k_read_immediate_xx() for immediate addressing |
philpem@0 | 67 | * and m68k_read_pcrelative_xx() for PC-relative addressing. |
philpem@0 | 68 | * If off, all read requests from the CPU will be redirected to m68k_read_xx() |
philpem@0 | 69 | */ |
philpem@0 | 70 | #define M68K_SEPARATE_READS OPT_OFF |
philpem@0 | 71 | |
philpem@0 | 72 | |
philpem@0 | 73 | /* If on, CPU will call the interrupt acknowledge callback when it services an |
philpem@0 | 74 | * interrupt. |
philpem@0 | 75 | * If off, all interrupts will be autovectored and all interrupt requests will |
philpem@0 | 76 | * auto-clear when the interrupt is serviced. |
philpem@0 | 77 | */ |
philpem@0 | 78 | #define M68K_EMULATE_INT_ACK OPT_OFF |
philpem@0 | 79 | #define M68K_INT_ACK_CALLBACK(A) your_int_ack_handler_function(A) |
philpem@0 | 80 | |
philpem@0 | 81 | |
philpem@0 | 82 | /* If on, CPU will call the breakpoint acknowledge callback when it encounters |
philpem@0 | 83 | * a breakpoint instruction and it is running a 68010+. |
philpem@0 | 84 | */ |
philpem@0 | 85 | #define M68K_EMULATE_BKPT_ACK OPT_OFF |
philpem@0 | 86 | #define M68K_BKPT_ACK_CALLBACK() your_bkpt_ack_handler_function() |
philpem@0 | 87 | |
philpem@0 | 88 | |
philpem@0 | 89 | /* If on, the CPU will monitor the trace flags and take trace exceptions |
philpem@0 | 90 | */ |
philpem@0 | 91 | #define M68K_EMULATE_TRACE OPT_OFF |
philpem@0 | 92 | |
philpem@0 | 93 | |
philpem@0 | 94 | /* If on, CPU will call the output reset callback when it encounters a reset |
philpem@0 | 95 | * instruction. |
philpem@0 | 96 | */ |
philpem@0 | 97 | #define M68K_EMULATE_RESET OPT_OFF |
philpem@0 | 98 | #define M68K_RESET_CALLBACK() your_reset_handler_function() |
philpem@0 | 99 | |
philpem@0 | 100 | |
philpem@0 | 101 | /* If on, CPU will call the set fc callback on every memory access to |
philpem@0 | 102 | * differentiate between user/supervisor, program/data access like a real |
philpem@0 | 103 | * 68000 would. This should be enabled and the callback should be set if you |
philpem@0 | 104 | * want to properly emulate the m68010 or higher. (moves uses function codes |
philpem@0 | 105 | * to read/write data from different address spaces) |
philpem@0 | 106 | */ |
philpem@0 | 107 | #define M68K_EMULATE_FC OPT_OFF |
philpem@0 | 108 | #define M68K_SET_FC_CALLBACK(A) your_set_fc_handler_function(A) |
philpem@0 | 109 | |
philpem@0 | 110 | |
philpem@0 | 111 | /* If on, CPU will call the pc changed callback when it changes the PC by a |
philpem@0 | 112 | * large value. This allows host programs to be nicer when it comes to |
philpem@0 | 113 | * fetching immediate data and instructions on a banked memory system. |
philpem@0 | 114 | */ |
philpem@0 | 115 | #define M68K_MONITOR_PC OPT_OFF |
philpem@0 | 116 | #define M68K_SET_PC_CALLBACK(A) your_pc_changed_handler_function(A) |
philpem@0 | 117 | |
philpem@0 | 118 | |
philpem@0 | 119 | /* If on, CPU will call the instruction hook callback before every |
philpem@0 | 120 | * instruction. |
philpem@0 | 121 | */ |
philpem@0 | 122 | #define M68K_INSTRUCTION_HOOK OPT_OFF |
philpem@0 | 123 | #define M68K_INSTRUCTION_CALLBACK() your_instruction_hook_function() |
philpem@0 | 124 | |
philpem@0 | 125 | |
philpem@0 | 126 | /* If on, the CPU will emulate the 4-byte prefetch queue of a real 68000 */ |
philpem@0 | 127 | #define M68K_EMULATE_PREFETCH OPT_OFF |
philpem@0 | 128 | |
philpem@0 | 129 | |
philpem@0 | 130 | /* If on, the CPU will generate address error exceptions if it tries to |
philpem@0 | 131 | * access a word or longword at an odd address. |
philpem@0 | 132 | * NOTE: Do not enable this! It is not working! |
philpem@0 | 133 | */ |
philpem@0 | 134 | #define M68K_EMULATE_ADDRESS_ERROR OPT_OFF |
philpem@0 | 135 | |
philpem@0 | 136 | |
philpem@0 | 137 | /* Turn on to enable logging of illegal instruction calls. |
philpem@0 | 138 | * M68K_LOG_FILEHANDLE must be #defined to a stdio file stream. |
philpem@0 | 139 | * Turn on M68K_LOG_1010_1111 to log all 1010 and 1111 calls. |
philpem@0 | 140 | */ |
philpem@0 | 141 | #define M68K_LOG_ENABLE OPT_OFF |
philpem@0 | 142 | #define M68K_LOG_1010_1111 OPT_OFF |
philpem@0 | 143 | #define M68K_LOG_FILEHANDLE some_file_handle |
philpem@0 | 144 | |
philpem@0 | 145 | |
philpem@0 | 146 | /* ----------------------------- COMPATIBILITY ---------------------------- */ |
philpem@0 | 147 | |
philpem@0 | 148 | /* The following options set optimizations that violate the current ANSI |
philpem@0 | 149 | * standard, but will be compliant under the forthcoming C9X standard. |
philpem@0 | 150 | */ |
philpem@0 | 151 | |
philpem@0 | 152 | |
philpem@0 | 153 | /* If on, the enulation core will use 64-bit integers to speed up some |
philpem@0 | 154 | * operations. |
philpem@0 | 155 | */ |
philpem@0 | 156 | #define M68K_USE_64_BIT OPT_OFF |
philpem@0 | 157 | |
philpem@0 | 158 | |
philpem@0 | 159 | /* Set to your compiler's static inline keyword to enable it, or |
philpem@0 | 160 | * set it to blank to disable it. |
philpem@0 | 161 | * If you define INLINE in the makefile, it will override this value. |
philpem@0 | 162 | * NOTE: not enabling inline functions will SEVERELY slow down emulation. |
philpem@0 | 163 | */ |
philpem@0 | 164 | #ifndef INLINE |
philpem@0 | 165 | #define INLINE static __inline__ |
philpem@0 | 166 | #endif /* INLINE */ |
philpem@0 | 167 | |
philpem@0 | 168 | |
philpem@0 | 169 | /* If your environment requires special prefixes for system callback functions |
philpem@0 | 170 | * such as the argument to qsort(), then set them here or in the makefile. |
philpem@0 | 171 | */ |
philpem@0 | 172 | #ifndef DECL_SPEC |
philpem@0 | 173 | #define DECL_SPEC |
philpem@0 | 174 | #endif |
philpem@0 | 175 | |
philpem@0 | 176 | #endif /* M68K_COMPILE_FOR_MAME */ |
philpem@0 | 177 | |
philpem@0 | 178 | |
philpem@0 | 179 | /* ======================================================================== */ |
philpem@0 | 180 | /* ============================== END OF FILE ============================= */ |
philpem@0 | 181 | /* ======================================================================== */ |
philpem@0 | 182 | |
philpem@0 | 183 | #endif /* M68KCONF__HEADER */ |